Re: Is it safe to rename an index through pg_class update? - Mailing list pgsql-general

From Tom Lane
Subject Re: Is it safe to rename an index through pg_class update?
Date
Msg-id 21995.1582818756@sss.pgh.pa.us
Whole thread Raw
In response to Is it safe to rename an index through pg_class update?  (Kouber Saparev <kouber@gmail.com>)
Responses Re: Is it safe to rename an index through pg_class update?  (Kouber Saparev <kouber@gmail.com>)
Re: Is it safe to rename an index through pg_class update?  (Andres Freund <andres@anarazel.de>)
List pgsql-general
Kouber Saparev <kouber@gmail.com> writes:
> Renaming an index the classical way through "ALTER INDEX xxx RENAME TO yyy"
> needs an AccessExclusiveLock over the table holding the index (at least on
> 9.3 it does). Instead, couldn't I simply:

> UPDATE pg_class SET relname = 'yyy' WHERE oid = 'xxx'::regclass;

There's a lot of stuff like that that you can probably get away with...
but I'm not sure it's prudent to try it on valuable production data.
If it breaks your database nobody is going to have any sympathy for you.

FWIW, I can't immediately think of a reason this would cause a problem,
at least not on 9.4 and up which use MVCC catalog scans.  If you're
really still on 9.3 then it's notably more risky.  In any case, I've
not had any caffeine yet today, so this doesn't count for much.

            regards, tom lane



pgsql-general by date:

Previous
From: Iban Rodriguez
Date:
Subject: Re: unexpected behavior with pglogical -- bug?
Next
From: Adrian Klaver
Date:
Subject: Re: Error “cache lookup failed for function”