postgresql/src/backend
Dean Rasheed 8d8464445a 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:03 +01:00
..
access Fix visibility check when XID is committed in CLOG but not in procarray. 2022-06-27 08:24:30 +03:00
bootstrap Rethink definition of pg_attribute.attcompression. 2021-05-27 13:24:27 -04:00
catalog Make relation-enumerating operations be security-restricted operations. 2022-05-09 08:35:12 -07:00
commands CREATE INDEX: use the original userid for more ACL checks. 2022-06-25 09:07:44 -07:00
executor Fix SPI's handling of errors during transaction commit. 2022-06-22 12:11:59 -04:00
foreign Update copyright for 2021 2021-01-02 13:06:25 -05:00
jit Back-patch LLVM 14 API changes. 2022-03-16 11:42:00 +13:00
lib Fix typo in comment 2021-04-20 14:35:16 +02:00
libpq Remove misguided SSL key file ownership check in libpq. 2022-05-26 14:14:05 -04:00
main Update copyright for 2021 2021-01-02 13:06:25 -05:00
nodes Fix assorted missing logic for GroupingFunc nodes. 2022-03-21 17:44:29 -04:00
optimizer Fix incorrect row estimates used for Memoize costing 2022-05-16 16:08:37 +12:00
parser Fix alias matching in transformLockingClause(). 2022-07-07 13:08:03 +01:00
partitioning Avoid using ambiguous word "non-negative" in error messages. 2021-07-28 01:21:35 +09:00
po Translation updates 2022-06-13 07:32:39 +02:00
port Reject huge_pages=on if shared_memory_type=sysv. 2021-10-26 13:09:00 +13:00
postmaster Wake up for latches in CheckpointWriteDelay(). 2022-03-16 13:57:07 +13:00
regex Make pg_regexec() robust against out-of-range search_start. 2021-09-11 15:19:43 -04:00
replication Fix memory leak due to LogicalRepRelMapEntry.attrmap. 2022-06-23 09:20:41 +05:30
rewrite Fix incautious CTE matching in rewriteSearchAndCycle(). 2022-04-23 12:16:12 -04:00
snowball Update snowball 2021-02-19 08:10:15 +01:00
statistics Build inherited extended stats on partitioned tables 2022-01-15 19:05:22 +01:00
storage Harden dsm_impl.c against unexpected EEXIST. 2022-07-01 13:16:27 +12:00
tcop Fix SPI's handling of errors during transaction commit. 2022-06-22 12:11:59 -04:00
tsearch Fix typos and grammar in comments and docs 2021-04-19 11:32:30 +09:00
utils Remove %error-verbose directive from jsonpath parser 2022-07-03 17:16:11 -04:00
.gitignore Add .gitignore entries for AIX-specific intermediate build artifacts. 2015-07-08 20:44:22 -04:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
Makefile Use sort_template.h for qsort_tuple() and qsort_ssup(). 2021-03-03 17:02:32 +13:00
nls.mk Translation updates 2021-09-20 16:23:13 +02:00