Re: [HACKERS] DROPping tables with SERIALs - Mailing list pgsql-hackers

From jwieck@debis.com (Jan Wieck)
Subject Re: [HACKERS] DROPping tables with SERIALs
Date
Msg-id m0zjQfU-000EBjC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
In response to DROPping tables with SERIALs  (Jan Iven <j.iven@rz.uni-sb.de>)
List pgsql-hackers
>
> Hi,
>
> I have run into a problem dropping and re-creating tables with
> type SERIAL:
>
> CREATE TABLE t ( s SERIAL);
> DROP TABLE t;
> CREATE TABLE t ( s SERIAL);
>
> gives
> ERROR:  t_s_seq relation already exists
>
> This looks like the implicitly created sequence t_s_seq is not dropped
> together with the table.
>
> I am running a current (?) cvs snapshot from anoncvs@postgresql.org.
>
> Jan
>
>

    Yepp.  The  serial  type  is implemented as an integer with a
    default of nextval('tab_attr_seq') and  the  sequence  itself
    created on the fly.

    I   think   we   should  have  an  additional  oid  field  in
    pg_attribute that holds the oid of the created  sequence  and
    that  is examined at drop table time to drop the serials too.

    TODO for v6.5 ?


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: Gilmar Ribeiro da Rosa
Date:
Subject: ...
Next
From: Tom Lane
Date:
Subject: Re: [HACKERS] copy