Re: alter table schema, default sequences stay the same

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sim Zacks <sim(at)compulab(dot)co(dot)il>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: alter table schema, default sequences stay the same
Date: 2010-06-29 14:51:12
Message-ID: 18513.1277823072@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sim Zacks <sim(at)compulab(dot)co(dot)il> writes:
>> id integer NOT NULL DEFAULT
>> nextval(('public.tblname_id_seq'::text)::regclass)

> Shouldn't this change automatically as well?

It would have changed automatically if the default expression were what
it's supposed to be, namely nextval('sequencename'::regclass). What
you've got there is a text constant, which of course is static.

I haven't consumed enough caffeine today to recall the details, but
I think you could have ended up with default expressions like the above
if the database had been dumped and reloaded from 8.0 or earlier.
nextval(regclass) was introduced in 8.1 precisely to solve this type
of problem.

> Is there an easy way to modify all the default values now?

Not especially :-(. You're going to need to run around and change them
all to the right name. Be sure to lose the ::text bit while at it,
so it works right the next time.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Arnaud Lesauvage 2010-06-29 14:52:22 Prevent characters not transposable to LATIN9
Previous Message erobles 2010-06-29 14:47:32 Re: Fwd: Re: Weird trouble with select