pgsql: Ensure correct lock level is used in ALTER ... RENAME

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Ensure correct lock level is used in ALTER ... RENAME
Date: 2021-10-19 22:11:24
Message-ID: E1mcxKO-0004Jd-4q@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Ensure correct lock level is used in ALTER ... RENAME

Commit 1b5d797cd4f7 intended to relax the lock level used to rename
indexes, but inadvertently allowed *any* relation to be renamed with a
lowered lock level, as long as the command is spelled ALTER INDEX.
That's undesirable for other relation types, so retry the operation with
the higher lock if the relation turns out not to be an index.

After this fix, ALTER INDEX <sometable> RENAME will require access
exclusive lock, which it didn't before.

Author: Nathan Bossart <bossartn(at)amazon(dot)com>
Author: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Reported-by: Onder Kalaci <onderk(at)microsoft(dot)com>
Discussion: https://postgr.es/m/PH0PR21MB1328189E2821CDEC646F8178D8AE9@PH0PR21MB1328.namprd21.prod.outlook.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/6c8d1c197bd67e78c12c68d8f0bd111a59e7bccd

Modified Files
--------------
src/backend/commands/tablecmds.c | 62 ++++++++++++++++++++++++-------
src/test/regress/expected/alter_table.out | 48 ++++++++++++++++++++++++
src/test/regress/sql/alter_table.sql | 31 ++++++++++++++++
3 files changed, 127 insertions(+), 14 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Dilip Kumar 2021-10-20 04:55:05 Re: pgsql: Document XLOG_INCLUDE_XID a little better
Previous Message Tom Lane 2021-10-19 21:22:29 pgsql: pg_dump: Reorganize getTables()