Skip site navigation (1) Skip section navigation (2)

Re: BUG #4582: Renaming sequences and default value

From: Jan-Peter Seifert <Jan-Peter(dot)Seifert(at)gmx(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4582: Renaming sequences and default value
Date: 2008-12-16 20:28:27
Message-ID: 49480F6B.4090302@gmx.de (view raw or flat)
Thread:
Lists: pgsql-bugs
Tom Lane wrote:

Thank you very much for your quick reply. I wanted to do some testing
before reporting back.

> "Jan-Peter Seifert" <jan-peter(dot)seifert(at)gmx(dot)de> writes:
>> there's a problem with renaming sequences in our databases.
> 
> I don't think there's really a problem here.  You've apparently got some
> obsolete syntax in your CREATE commands:
> 
>>   id integer NOT NULL DEFAULT nextval(('public.t2_id_seq'::text)::regclass)
> 
> This specifically says that 'public.t2_id_seq' is a string (text) constant,
> which is not going to change in response to anything.  If you would
> like it to track renamings of the sequence then it needs to be a
> regclass constant:
> 
>     id integer NOT NULL DEFAULT nextval('public.t2_id_seq'::regclass)

At first I thought the reason why a renamed sequence couldn't be found
via nextval anymore - even with 'owned by' set - was evaluating the
'historical' adsrc and not the adbin column in pg_attrdef within the
maintenance script. But then I saw the difference in nextval syntax
etc.. The update tool in question uses the obsolete syntax. Has this
text constant thing been official syntax for some time? I wonder why the
person implementing this syntax into the tool did it in the first place.
 Now after changing the nextval syntax with an ALTER TABLE as well all
seems to be alright again. Even pgAdmin III now shows 'serial' as data
type for the column again.

> Also, neither of these forms will by itself establish an OWNED BY
> relationship --- you'll need a separate ALTER SEQUENCE OWNED BY
> command if you want that.

Thank you very much for pointing this out. We only discovered it after
looking through a dump some time ago.

Peter Seifert

In response to

Responses

pgsql-bugs by date

Next:From: Mark MuzenhardtDate: 2008-12-16 20:39:49
Subject: BUG #4584: PostgreSQL service doesn't start
Previous:From: Bruno PimentaDate: 2008-12-16 17:35:16
Subject: BUG #4583: Db stop

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group