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

renaming index leaves database inconsistent

From: Richard Poole <rp(at)gxn(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: renaming index leaves database inconsistent
Date: 1999-12-07 00:21:25
Message-ID: E11v8Nh-0007Wm-00@sapphire.noc.gxn.net (view raw or flat)
Thread:
Lists: pgsql-bugs
Your name		: Richard Poole
Your email address	: rp(at)gxn(dot)net


System Configuration
---------------------
  Architecture (example: Intel Pentium)  	: Intel Pentium

  Operating System (example: Linux 2.0.26 ELF) 	: Linux 2.2.5 ELF

  PostgreSQL version (example: PostgreSQL-6.5.3): PostgreSQL-6.5.3 

  Compiler used (example:  gcc 2.8.0)		: egcs 1.1.2


Please enter a FULL description of your problem:
------------------------------------------------

If I try to do ALTER TABLE ... RENAME on an index, it fails and does not
change the system catalogues, but does rename the file containing the
index. Any operation which would access the index then fails.

I know I shouldn't do that but if I try it should fail gracefully; as it
is this seems to need hand-repairing.

Please describe a way to repeat the problem.   Please try to provide a
concise reproducible example, if at all possible: 
----------------------------------------------------------------------

rptest=> create table foo(i int);
CREATE
rptest=> create index foo_index on foo(i);
CREATE
rptest=> alter table foo_index rename to new_foo_index;
ERROR:  TypeRename: type foo_index not defined
rptest=> insert into foo values (42);
ERROR:  mdopen: couldn't open foo_index: No such file or directory
rptest=> \q
[rp(at)judy rp]$ su postgres          
Password: 
[postgres(at)judy rp]$ ls /var/pgsql/base/rptest/ | grep foo
foo
new_foo_index


If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

I don't know the code at all, but it seems there should be a check at the
top of renamerel() (in src/backend/commands/rename.c) that the relation
you're renaming isn't an index, before you do the rename of the file.
Alternatively it would be nice if you *could* rename indices, but I don't
know what other repercussions that might have.


pgsql-bugs by date

Next:From: Tom LaneDate: 1999-12-07 01:59:13
Subject: Re: [BUGS] renaming index leaves database inconsistent
Previous:From: Richard PooleDate: 1999-12-07 00:04:45
Subject: renaming index leaves database inconsistent

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