Re: [HACKERS] Bug or feature? COPY ignores column defaults

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Oliver Elphick" <olly(at)lfix(dot)co(dot)uk>
Cc: hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Bug or feature? COPY ignores column defaults
Date: 1999-01-28 20:04:58
Message-ID: 24026.917553898@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-01-28 21:38:47 TEMP table code
Previous Message Tom Lane 1999-01-28 19:48:37 Re: [HACKERS] Bug or feature? COPY ignores column defaults