pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Cc: Michael Paquier <michael.paquier@gmail.com>
Cc: steven.winfield@cantabcapital.com, PostgreSQL mailing lists <pgsql-bugs@postgresql.org>
Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
Date: Wed, 27 Dec 2017 15:43:05 -0500
Message-ID: <12169.1514407385@sss.pgh.pa.us> (raw)
In-Reply-To: <f1d4c6aa-d91b-ebc8-c249-17d7c847ac3b@2ndquadrant.com>
References: <20171207112930.21696.79944@wrigleys.postgresql.org>
	<12618e2c-0eb0-3e15-c45d-96891c52eb5f@2ndquadrant.com>
	<CAB7nPqTMCmO_Y3HcQn9-oKFQBcWXckf24urAk+_ifBjfjhD0sA@mail.gmail.com>
	<31740.1513222740@sss.pgh.pa.us>
	<21a6da72-fb24-4b9e-d300-7439425f7492@2ndquadrant.com>
	<CAB7nPqRMzeUqG2JHo81KTWz=gWGrkKbfLn2S3fOiMZ87JmVJ5w@mail.gmail.com>
	<f1d4c6aa-d91b-ebc8-c249-17d7c847ac3b@2ndquadrant.com>

Peter Eisentraut <peter.eisentraut@2ndquadrant.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




view thread (14+ messages)  latest in thread

Message-ID: <12169.1514407385@sss.pgh.pa.us>
Permalink:  ../12169.1514407385@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12169.1514407385@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, peter.eisentraut@2ndquadrant.com, michael.paquier@gmail.com
  Subject: Re: BUG #14952: COPY fails to fill in IDENTITY column default value
  In-Reply-To: <12169.1514407385@sss.pgh.pa.us>
  References: <20171207112930.21696.79944@wrigleys.postgresql.org> <12618e2c-0eb0-3e15-c45d-96891c52eb5f@2ndquadrant.com> <CAB7nPqTMCmO_Y3HcQn9-oKFQBcWXckf24urAk+_ifBjfjhD0sA@mail.gmail.com> <31740.1513222740@sss.pgh.pa.us> <21a6da72-fb24-4b9e-d300-7439425f7492@2ndquadrant.com> <CAB7nPqRMzeUqG2JHo81KTWz=gWGrkKbfLn2S3fOiMZ87JmVJ5w@mail.gmail.com> <f1d4c6aa-d91b-ebc8-c249-17d7c847ac3b@2ndquadrant.com> <12169.1514407385@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox