pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kouber Saparev <kouber@gmail.com>
Cc: pgsql-general@postgresql.org
Subject: Re: Is it safe to rename an index through pg_class update?
Date: Thu, 27 Feb 2020 10:52:36 -0500
Message-ID: <21995.1582818756@sss.pgh.pa.us> (raw)
In-Reply-To: <CAN4RuQtkwaP90yUvpP8=nJGoYTk_ni50=8e=jHvwHyetz3=MJA@mail.gmail.com>
References: <CAN4RuQtkwaP90yUvpP8=nJGoYTk_ni50=8e=jHvwHyetz3=MJA@mail.gmail.com>

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





view thread (9+ messages)  latest in thread

Message-ID: <21995.1582818756@sss.pgh.pa.us>
Permalink:  ../21995.1582818756@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/21995.1582818756@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, kouber@gmail.com
  Subject: Re: Is it safe to rename an index through pg_class update?
  In-Reply-To: <21995.1582818756@sss.pgh.pa.us>
  References: <CAN4RuQtkwaP90yUvpP8=nJGoYTk_ni50=8e=jHvwHyetz3=MJA@mail.gmail.com> <21995.1582818756@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox