Renaming tables and their indexes simultaneously

From: Moshe Jacobson <moshe(at)neadwerx(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Renaming tables and their indexes simultaneously
Date: 2012-08-26 18:26:26
Message-ID: CAJ4CxLn5LivrdLa7rZUrZxD0RHJar=YWhuM5YMh2FMsZ4anSyw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a stored procedure that renames a table as part of a partitioning
scheme, then re-creates it.
Up until recently (I'm not sure what changed), renaming the table would
cause the pkey index/constraint, as well as all other indexes, to be
renamed according to the new table name.
However, they now do not rename, and cause collisions when the new table is
created.

I would prefer not having to drop and re-create the primary key index, as
it takes quite a while to drop and re-create an index that large.

How can I cause Postgres to rename the table's attached indexes when I
rename the table, and what might have caused it to stop doing so recently?

We are on Postgres 9.1, but we did not recently upgrade...

Thanks.

--
Moshe Jacobson
Nead Werx, Inc. | Senior Systems Engineer
2323 Cumberland Parkway, Suite 201 | Atlanta, GA 30339
moshe(at)neadwerx(dot)com | www.neadwerx.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jeff Janes 2012-08-26 18:45:48 Re: 9.2 and index only scans
Previous Message Wolfgang Keller 2012-08-26 17:57:02 Re: Some thoughts on table inheritance (which is uniquely awesome on PostgreSQL)