Re: BUG #1883: Renaming a schema leaves inconsistent sequence - Mailing list pgsql-bugs
From | Bruce Momjian |
---|---|
Subject | Re: BUG #1883: Renaming a schema leaves inconsistent sequence |
Date | |
Msg-id | 200509230213.j8N2DVv20251@candle.pha.pa.us Whole thread Raw |
In response to | BUG #1883: Renaming a schema leaves inconsistent sequence names ("Kouber Saparev" <postgresql@saparev.com>) |
Responses |
Re: BUG #1883: Renaming a schema leaves inconsistent sequence
|
List | pgsql-bugs |
This item has been added to the 8.1 bugs list: http://momjian.postgresql.org/cgi-bin/pgbugs --------------------------------------------------------------------------- Kouber Saparev wrote: > > The following bug has been logged online: > > Bug reference: 1883 > Logged by: Kouber Saparev > Email address: postgresql@saparev.com > PostgreSQL version: 8.0.3 > Operating system: Linux 2.6.11.4 > Description: Renaming a schema leaves inconsistent sequence names > Details: > > When I rename a schema, all the serial fields are pointing to the old > schema, which no longer exists. So trying to insert new records fails. > > Here there is an example: > > ------ begin ------ > > bugs=# create schema sch1; > CREATE SCHEMA > > bugs=# create table sch1.test (id serial primary key, name char(1)) without > oids; > NOTICE: CREATE TABLE will create implicit sequence "test_id_seq" for serial > column "test.id" > NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "test_pkey" > for table "test" > CREATE TABLE > > bugs=# \d sch1.test > Table "sch1.test" > Column | Type | Modifiers > --------+--------------+---------------------------------------------------- > > id | integer | not null default nextval('sch1.test_id_seq'::text) > name | character(1) | > Indexes: > "test_pkey" PRIMARY KEY, btree (id) > > bugs=# insert into sch1.test (name) values ('a'); > INSERT 0 1 > > bugs=# alter schema sch1 rename to sch2; > ALTER SCHEMA > > bugs=# \d sch2.test > Table "sch2.test" > Column | Type | Modifiers > --------+--------------+---------------------------------------------------- > > id | integer | not null default nextval('sch1.test_id_seq'::text) > name | character(1) | > Indexes: > "test_pkey" PRIMARY KEY, btree (id) > > bugs=# insert into sch2.test (name) values ('b'); > ERROR: schema "sch1" does not exist > > ------ end ------ > > As you see, the default value of the serial field is pointing to a sequence > in schema "sch1" which is now "sch2". Changing the default value manually > fixes the problem, but it's not very convenient in case when there are a lot > of tables. > > After I looked over the bugs submitted so far, I've found that the problem > is already reported, but I'm not sure whether it's well described there. > Take a look at > - http://article.gmane.org/gmane.comp.db.postgresql.bugs/3033/ > > I apologize, if it is a known bug. > > Regards, > Kouber Saparev > > ---------------------------(end of broadcast)--------------------------- > TIP 3: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq > -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001 + If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania 19073
pgsql-bugs by date: