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

From jwieck@debis.com (Jan Wieck)
Subject Re: [HACKERS] Bug or feature? COPY ignores column defaults
Date
Msg-id m105sZ6-000EBQC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
In response to Re: [HACKERS] Bug or feature? COPY ignores column defaults  (Vadim Mikheev <vadim@krs.ru>)
List 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@debis.com (Jan Wieck) #

pgsql-hackers by date:

Previous
From: "Reiner Nippes"
Date:
Subject: (Fwd) Re: [ADMIN] Running Postgres on a HP-Ux 10.10 System
Next
From: Massimo Dal Zotto
Date:
Subject: Re: [HACKERS] Postgres Speed or lack thereof