Re: [HACKERS] Bug or feature? COPY ignores column defaults - Mailing list pgsql-hackers

From Tom Lane
Subject Re: [HACKERS] Bug or feature? COPY ignores column defaults
Date
Msg-id 24026.917553898@sss.pgh.pa.us
Whole thread Raw
In response to Re: [HACKERS] Bug or feature? COPY ignores column defaults  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
I wrote:
> You ought to be getting something much like the result of

> play=> select '':int4;
> ERROR:  parser: parse error at or near ":"

Sheesh, need to learn to count my colons.  Of course, what I should've
written was:

play=> select ''::int4;
?column?
--------      0
(1 row)

which strikes me as being a bug in the INT4 text-to-value conversion
routine: it ought to be griping about bad input.  (float4 and float8
also seem overly permissive.)

The other thing COPY is evidently doing is substituting NULLs for
the remaining fields if it hits RETURN before getting the right number
of column separators.  I still say that's a bad idea, and that raising
a syntax error would be safer behavior.  COPY is not particularly
intended to be user-friendly, it's intended to be a simple and reliable
dump/reload syntax (no?).  Allowing omissions in order to ease typing
just makes the behavior less predictable.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Bug or feature? COPY ignores column defaults
Next
From: Bruce Momjian
Date:
Subject: TEMP table code