Re: Regression in COPY FROM caused by 9f8377f7a2
Laurenz Albe <laurenz.albe@cybertec.at>
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: pgsql-hackers@lists.postgresql.org
Date: 2023-09-25T08:59:21Z
Lists: pgsql-hackers
Attachments
- 0001-Evaluate-defaults-in-COPY-FROM-only-if-necessary.patch (text/x-patch) patch 0001
On Mon, 2023-09-25 at 09:54 +0200, Laurenz Albe wrote: > In v16 and later, the following fails: > > CREATE TABLE boom (t character varying(5) DEFAULT 'a long string'); > > COPY boom FROM STDIN; > ERROR: value too long for type character varying(5) > > In PostgreSQL v15 and earlier, the COPY statement succeeds. > > The error is thrown in BeginCopyFrom in line 1578 (HEAD) > > defexpr = expression_planner(defexpr); > > Bisecting shows that the regression was introduced by commit 9f8377f7a2, > which introduced DEFAULT values for COPY FROM. I suggest the attached fix, which evaluates default values only if the DEFAULT option was specified or if the column does not appear in the column list of COPY. Yours, Laurenz Albe
Commits
-
Only evaluate default values as required when doing COPY FROM
- 910eb61b2bbd 16.1 landed
- 276393f53efb 17.0 landed
-
Add a DEFAULT option to COPY FROM
- 9f8377f7a279 16.0 cited