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

From: jwieck(at)debis(dot)com (Jan Wieck)
To: vadim(at)krs(dot)ru (Vadim Mikheev)
Cc: olly(at)lfix(dot)co(dot)uk, hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Bug or feature? COPY ignores column defaults
Date: 1999-01-28 14:37:03
Message-ID: m105sZ6-000EBQC@orion.SAPserv.Hamburg.dsh.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>
> Oliver Elphick wrote:
> >
> > At release 6.4.2, COPY does not respect column defaults:
> >
> > INSERT works correctly, however.
> >
> > Is this intentional, or a bug?
>
> This is standard behaviour. DEFAULT value is sabstituted
> only if column value (including NULL) is not specified in
> INSERT statement.

And so for the rule system. It is not invoked on COPY, so
rewrite rules don't take effect.

If you want some columns to have defaults assigned when the
value in COPY is NULL, or maybe override something like a
timestamp field, you could define a trigger. Triggers are
called from COPY.

Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me. #
#======================================== jwieck(at)debis(dot)com (Jan Wieck) #

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Oliver Elphick 1999-01-28 15:07:33 Re: [HACKERS] Bug or feature? COPY ignores column defaults
Previous Message Reiner Nippes 1999-01-28 14:22:30 (Fwd) Re: [ADMIN] Running Postgres on a HP-Ux 10.10 System