Is it safe to rename an index through pg_class update?

From: Kouber Saparev <kouber(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Is it safe to rename an index through pg_class update?
Date: 2020-02-27 14:54:34
Message-ID: CAN4RuQtkwaP90yUvpP8=nJGoYTk_ni50=8e=jHvwHyetz3=MJA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello everybody,

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;

Are there any risks to corrupt the database or to lose concurrent
transactions? I tried to make some tests with parallel queries and locks
over the table, but I did not discover anything special.

--
Kouber Saparev

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Iban Rodriguez 2020-02-27 15:30:56 Re: unexpected behavior with pglogical -- bug?
Previous Message sivapostgres@yahoo.com 2020-02-27 14:26:22 Re: Need to find the no. of connections for a database