Re: BUG #14952: COPY fails to fill in IDENTITY column default value

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, steven(dot)winfield(at)cantabcapital(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
Date: 2017-12-27 20:43:05
Message-ID: 12169.1514407385@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> On 12/18/17 00:49, Michael Paquier wrote:
>> In my opinion, this ALTER TABLE handling should be done by treating
>> identity columns a way similar to default expressions in
>> transformColumnDefinition(), by storing the FuncExpr node at parsing
>> time instead of storing the information needed to rebuild it when
>> executing the query. In short the mapping should get closer to what
>> default does with nextval or serial.

> The serial case works because it stores the sequence *name* in the
> default value in the catalog.

Just to clarify: what's *actually* stored for a regular serial column
is the sequence OID (as a regclass constant), not the name. If it
were a name then ALTER SEQUENCE RENAME would break it.

> That doesn't work because for the
> identity case we don't store the expression in the catalog. The
> proposed patch works by storing the sequence *name* in the internal
> structures so that it can be used in place of the stored default value.

I trust you really mean you're storing an OID ...

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message David Rowley 2017-12-28 04:46:44 Re: Order of columns in GROUP BY is significant to the planner.
Previous Message Peter Eisentraut 2017-12-27 20:01:37 Re: BUG #14952: COPY fails to fill in IDENTITY column default value