Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
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

pgsql-hackers by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group