pgsql: Fix alias matching in transformLockingClause().

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема pgsql: Fix alias matching in transformLockingClause().
Дата
Msg-id E1o9QOe-001dVV-IA@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix alias matching in transformLockingClause().

When locking a specific named relation for a FOR [KEY] UPDATE/SHARE
clause, transformLockingClause() finds the relation to lock by
scanning the rangetable for an RTE with a matching eref->aliasname.
However, it failed to account for the visibility rules of a join RTE.

If a join RTE doesn't have a user-supplied alias, it will have a
generated eref->aliasname of "unnamed_join" that is not visible as a
relation name in the parse namespace. Such an RTE needs to be skipped,
otherwise it might be found in preference to a regular base relation
with a user-supplied alias of "unnamed_join", preventing it from being
locked.

In addition, if a join RTE doesn't have a user-supplied alias, but
does have a join_using_alias, then the RTE needs to be matched using
that alias rather than the generated eref->aliasname, otherwise a
misleading "relation not found" error will be reported rather than a
"join cannot be locked" error.

Backpatch all the way, except for the second part which only goes back
to 14, where JOIN USING aliases were added.

Dean Rasheed, reviewed by Tom Lane.

Discussion: https://postgr.es/m/CAEZATCUY_KOBnqxbTSPf=7fz9HWPnZ5Xgb9SwYzZ8rFXe7nb=w@mail.gmail.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/8d8464445a476f0de961006d684922ada545d9a4

Modified Files
--------------
src/backend/parser/analyze.c       | 19 ++++++++++++++++++-
src/test/regress/expected/join.out | 33 +++++++++++++++++++++++++++++++++
src/test/regress/sql/join.sql      | 22 ++++++++++++++++++++++
3 files changed, 73 insertions(+), 1 deletion(-)


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

Предыдущее
От: Etsuro Fujita
Дата:
Сообщение: pgsql: postgres_fdw: Fix grammar.
Следующее
От: Fujii Masao
Дата:
Сообщение: pgsql: Add checkpoint and REDO LSN to log_checkpoints message.