Re: CREATE TABLE LIKE and SERIAL - Mailing list pgsql-general

From Tom Lane
Subject Re: CREATE TABLE LIKE and SERIAL
Date
Msg-id 22535.1256939042@sss.pgh.pa.us
Whole thread Raw
In response to Re: CREATE TABLE LIKE and SERIAL  (Thom Brown <thombrown@gmail.com>)
Responses Re: CREATE TABLE LIKE and SERIAL
List pgsql-general
Thom Brown <thombrown@gmail.com> writes:
> Well I realise SERIAL is a convenience rather than a datatype in its
> own right, but I'm surprised that LIKE can't differentiate between a
> column created with integer and one created with serial.  The table
> continues to report a serial datatype after its creation.

Really?

regression=# create table foo (f1 serial);
NOTICE:  CREATE TABLE will create implicit sequence "foo_f1_seq" for serial column "foo.f1"
CREATE TABLE
regression=# \d foo
                         Table "public.foo"
 Column |  Type   |                    Modifiers
--------+---------+--------------------------------------------------
 f1     | integer | not null default nextval('foo_f1_seq'::regclass)

regression=#

We used to try to treat serial as more like a real type (in particular
pg_dump used to try to dump the results of this using "serial") but we
found out that that was actively a bad idea, because there were too
many corner cases where it did the wrong thing.  I doubt we'll want
to go back in that direction.

            regards, tom lane

pgsql-general by date:

Previous
From: Thom Brown
Date:
Subject: Re: CREATE TABLE LIKE and SERIAL
Next
From: "Phil Cairns"
Date:
Subject: Re: Rewriting select statements