postgresql/src
Dean Rasheed 8d367a44d3 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
2022-07-07 13:08:08 +01:00
..
backend Fix alias matching in transformLockingClause(). 2022-07-07 13:08:08 +01:00
bin Make Windows 10 the minimal runtime requirement for WIN32 2022-07-07 13:25:45 +09:00
common Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
fe_utils Remove redundant null pointer checks before PQclear and PQconninfoFree 2022-07-03 20:11:05 +02:00
include Convert macros to static inline functions (block.h) 2022-07-07 08:36:51 +02:00
interfaces Reorder ecpg_config.h.in alphabetically 2022-07-06 07:16:46 +02:00
makefiles Unify DLSUFFIX on Darwin 2022-07-06 07:41:33 +02:00
pl PL/Python: Update guide to alternative expected files 2022-06-27 12:53:05 +02:00
port Remove redundant null pointer checks before free() 2022-07-03 11:47:15 +02:00
template Unify DLSUFFIX on Darwin 2022-07-06 07:41:33 +02:00
test Fix alias matching in transformLockingClause(). 2022-07-07 13:08:08 +01:00
timezone Update time zone data files to tzdata release 2022a. 2022-05-05 14:54:53 -04:00
tools Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
tutorial Update copyright for 2022 2022-01-07 19:04:57 -05:00
.gitignore
DEVELOPERS
Makefile Remove the option to build thread_test.c outside configure. 2020-10-21 12:08:48 -04:00
Makefile.global.in Remove LLVM_CONFIG from Makefile.global.in 2022-07-06 08:11:39 -07:00
Makefile.shlib Tiny capitalization adjustment in pkg-config files 2022-07-06 10:35:33 +02:00
nls-global.mk Improve frontend error logging style. 2022-04-08 14:55:14 -04:00