Unix Technical Forum

ALTER INDEX/ALTER TABLE on indexes can cause unrestorable dumps

This is a discussion on ALTER INDEX/ALTER TABLE on indexes can cause unrestorable dumps within the pgsql Bugs forums, part of the PostgreSQL category; --> Andy just reported on IRC that renaming indexes can lead to unrestorable dumps under certain circumstances. A simple example(8.2 ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Bugs

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-10-2008, 12:13 PM
Stefan Kaltenbrunner
 
Posts: n/a
Default ALTER INDEX/ALTER TABLE on indexes can cause unrestorable dumps

Andy just reported on IRC that renaming indexes can lead to unrestorable
dumps under certain circumstances. A simple example(8.2 but at least 8.1
and 8.3 seem to behave exactly the same) for that is:

test=# CREATE TABLE foo(bar int PRIMARY KEY);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index
"foo_pkey" for table "foo"
CREATE TABLE
test=# ALTER TABLE foo_pkey RENAME TO mynew_pkey;
ALTER TABLE
test=# CLUSTER mynew_pkey ON foo ;
CLUSTER

which - if dumped & restored leads to:

ERROR: index "mynew_pkey" for table "foo" does not exist

the reason for this seems to be that pg_dump is using the constraint
name (which is not changed by ALTER TABLE/ALTER INDEX) and not the index
name to dump this kind of information but I wonder if it would actually
be more sensible (until we get ALTER TABLE .. ALTER CONSTRAINT) to
simply forbid renaming indexes that are part of a constraint like that
and hint towards ALTER TABLE ADD/DROP CONSTRAINT ?



Stefan

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-10-2008, 12:13 PM
Alvaro Herrera
 
Posts: n/a
Default Re: ALTER INDEX/ALTER TABLE on indexes can causeunrestorable dumps

dup 3854
thanks

Stefan Kaltenbrunner wrote:

> the reason for this seems to be that pg_dump is using the constraint name
> (which is not changed by ALTER TABLE/ALTER INDEX) and not the index name to
> dump this kind of information but I wonder if it would actually be more
> sensible (until we get ALTER TABLE .. ALTER CONSTRAINT) to simply forbid
> renaming indexes that are part of a constraint like that and hint towards
> ALTER TABLE ADD/DROP CONSTRAINT ?


I think the fix is to make pg_dump emit ALTER TABLE/CLUSTER ON using the
right index name ...

(This makes me wonder whether we should be making pg_dump emit sorted
output for tables with a clustering index.)

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 01:07 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com