postgresql/src/backend
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
..
access Overload index_form_tuple to allow the memory context to be supplied 2022-07-07 08:14:00 +12:00
bootstrap Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
catalog Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
commands pgstat: drop subscription stats without slot as well, fix comment 2022-07-06 08:56:34 -07:00
executor Remove size increase in ExprEvalStep caused by hashed saops 2022-07-06 19:40:32 +12:00
foreign Create routine able to set single-call SRFs for Materialize mode 2022-03-07 10:26:29 +09:00
jit Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
lib Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
libpq Prevent write operations on large objects in read-only transactions 2022-07-04 15:48:52 +09:00
main Make Windows 10 the minimal runtime requirement for WIN32 2022-07-07 13:25:45 +09:00
nodes Fix wrong field order in _readMergeWhenClause(). 2022-07-06 17:26:42 -04:00
optimizer Remove no-longer-used parameter for create_groupingsets_path(). 2022-07-01 18:39:30 -04:00
parser Fix alias matching in transformLockingClause(). 2022-07-07 13:08:08 +01:00
partitioning Pre-beta mechanical code beautification. 2022-05-12 15:17:30 -04:00
po Translation updates 2022-06-27 08:19:02 +02:00
port Ensure that the argument of shmdt(2) is declared "void *". 2022-02-15 17:17:28 -05:00
postmaster Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
regex Remove redundant null pointer checks before free() 2022-07-03 11:47:15 +02:00
replication Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
rewrite Fix incautious CTE matching in rewriteSearchAndCycle(). 2022-04-23 12:16:12 -04:00
snowball Update copyright for 2022 2022-01-07 19:04:57 -05:00
statistics Add construct_array_builtin, deconstruct_array_builtin 2022-07-01 11:23:15 +02:00
storage Change internal RelFileNode references to RelFileNumber or RelFileLocator. 2022-07-06 11:39:09 -04:00
tcop pgstat: reduce timer overhead by leaving timer running. 2022-07-05 11:54:46 -07:00
tsearch Add construct_array_builtin, deconstruct_array_builtin 2022-07-01 11:23:15 +02:00
utils Make Windows 10 the minimal runtime requirement for WIN32 2022-07-07 13:25:45 +09:00
.gitignore
Makefile Server-side gzip compression. 2022-01-24 15:13:18 -05:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Report progress of startup operations that take a long time. 2021-10-25 11:51:57 -04:00