postgresql/src/backend
David Rowley 2cca95e175 Improve NestLoopParam generation for lateral subqueries
It was possible in cases where we had a LATERAL joined subquery that
when the same Var is mentioned in both the lateral references and in the
outer Vars of the scan clauses that the given Var wouldn't be assigned
to the same NestLoopParam.

This could cause issues in Memoize as the cache key would reference the
Var for the scan clauses but when the parameter for the lateral references
changed some code in Memoize would see that some other parameter had
changed that's not part of the cache key and end up purging the entire
cache as a result, thinking the cache had become stale.  This could
result in a Nested Loop -> Memoize plan being quite inefficient as, in
the worst case, the cache purging could result in never getting a cache
hit.  In no cases could this problem lead to incorrect query results.

Here we switch the order of operations so that we create NestLoopParam
for the lateral references first before doing replace_nestloop_params().
replace_nestloop_params() will find and reuse the existing NestLoopParam
in cases where the Var exists in both locations.

Author: Richard Guo
Reviewed-by: Tom Lane, David Rowley
Discussion: https://postgr.es/m/CAMbWs48XHJEK1Q1CzAQ7L9sTANTs9W1cepXu8%3DKc0quUL%2Btg4Q%40mail.gmail.com
2024-01-26 16:18:58 +13:00
..
access Add more LOG messages when starting and ending recovery from a backup 2024-01-25 17:07:56 +09:00
archive Update copyright for 2024 2024-01-03 20:49:05 -05:00
backup Add new function pg_get_wal_summarizer_state(). 2024-01-11 12:41:18 -05:00
bootstrap Make attstattarget nullable 2024-01-13 18:14:53 +01:00
catalog Implement various jsonpath methods 2024-01-25 10:15:43 -05:00
commands MergeAttributes: convert pg_attribute back to ColumnDef before comparing 2024-01-25 11:30:01 +01:00
executor Add soft error handling to some expression nodes 2024-01-24 15:04:33 +09:00
foreign Update copyright for 2024 2024-01-03 20:49:05 -05:00
jit jit: Require at least LLVM 10. 2024-01-25 15:42:34 +13:00
lib Fix broken Bitmapset optimization in DiscreteKnapsack() 2024-01-19 10:44:36 +13:00
libpq Update copyright for 2024 2024-01-03 20:49:05 -05:00
main Remove dummy_spinlock 2024-01-25 11:43:47 +01:00
nodes Add temporal PRIMARY KEY and UNIQUE constraints 2024-01-24 16:34:37 +01:00
optimizer Improve NestLoopParam generation for lateral subqueries 2024-01-26 16:18:58 +13:00
parser Add a const decoration 2024-01-25 13:34:49 +01:00
partitioning Update copyright for 2024 2024-01-03 20:49:05 -05:00
po Update copyright for 2024 2024-01-03 20:49:05 -05:00
port Close socket in case of errors in setting non-blocking 2024-01-17 11:24:11 +01:00
postmaster Remove redundant HandleWalWriterInterrupts(). 2024-01-25 12:50:08 +09:00
regex Update copyright for 2024 2024-01-03 20:49:05 -05:00
replication Allow to enable failover property for replication slots via SQL API. 2024-01-25 12:15:46 +05:30
rewrite Support identity columns in partitioned tables 2024-01-16 17:24:52 +01:00
snowball Add copyright notices to a few perl scripts that don't have them 2024-01-05 13:15:50 +00:00
statistics Update copyright for 2024 2024-01-03 20:49:05 -05:00
storage Remove dummy_spinlock 2024-01-25 11:43:47 +01:00
tcop Error message capitalisation 2024-01-18 09:35:12 +01:00
tsearch Update copyright for 2024 2024-01-03 20:49:05 -05:00
utils Revert "Add support for parsing of large XML data (>= 10MB)" 2024-01-26 10:15:32 +09:00
.gitignore
common.mk
Makefile Cross-check lists of predefined LWLocks. 2024-01-09 11:05:19 -06:00
meson.build Update copyright for 2024 2024-01-03 20:49:05 -05:00
nls.mk