pgsql: Fix DROP ROLE when specifying duplicated roles

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Fix DROP ROLE when specifying duplicated roles
Дата
Msg-id E1rUEEF-003b1Z-Db@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix DROP ROLE when specifying duplicated roles

This commit fixes failures with "tuple already updated by self" when
listing twice the same role and in a DROP ROLE query.

This is an oversight in 6566133c5f52, that has introduced a two-phase
logic in DropRole() where dependencies of all the roles to drop are
removed in a first phase, with the roles themselves removed from
pg_authid in a second phase.

The code is simplified to not rely on a List of ObjectAddress built in
the first phase used to remove the pg_authid entries in the second
phase, switching to a list of OIDs.  Duplicated OIDs can be simply
avoided in the first phase thanks to that.  Using ObjectAddress was not
necessary for the roles as they are not used for anything specific to
dependency.c, building all the ObjectAddress in the List with
AuthIdRelationId as class ID.

In 15 and older versions, where a single phase is used, DROP ROLE with
duplicated role names would fail on "role \"blah\" does not exist" for
the second entry after the CCI() done by the first deletion.  This is
not really incorrect, but it does not seem worth changing based on a
lack of complaints.

Reported-by: Alexander Lakhin
Reviewed-by: Tender Wang
Discussion: https://postgr.es/m/18310-1eb233c5908189c8@postgresql.org
Backpatch-through: 16

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/50b797dc99ec3bf97ea5d0955a3b42d356c1522d

Modified Files
--------------
src/backend/commands/user.c               | 16 +++++-----------
src/test/regress/expected/create_role.out |  3 ++-
src/test/regress/sql/create_role.sql      |  3 ++-
3 files changed, 9 insertions(+), 13 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: David Rowley
Дата:
Сообщение: pgsql: Attempt to fix newly added Memoize regression test
Следующее
От: Michael Paquier
Дата:
Сообщение: Re: pgsql: Temporary patch to help debug pg_walsummary test failures.