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 <[email protected]>
Author: Álvaro Herrera <[email protected]>
Reported-by: Onder Kalaci <[email protected]>
Discussion: 
https://postgr.es/m/ph0pr21mb1328189e2821cdec646f8178d8...@ph0pr21mb1328.namprd21.prod.outlook.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/3ce3fb2f7dc66fef67c8184b96245d74372b729e

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(-)

Reply via email to