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:04:45
Message-ID: E11v87Z-0007BU-00@sapphire.noc.gxn.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
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.

Browse pgsql-bugs by date

  From Date Subject
Next Message Richard Poole 1999-12-07 00:21:25 renaming index leaves database inconsistent
Previous Message Daniel Stolk 1999-12-06 20:07:20 Too large tuples corrupting tables