postgresql/src/backend
Tom Lane 912fb290c5 Be more careful about the shape of hashable subplan clauses.
nodeSubplan.c expects that the testexpr for a hashable ANY SubPlan
has the form of one or more OpExprs whose LHS is an expression of the
outer query's, while the RHS is an expression over Params representing
output columns of the subquery.  However, the planner only went as far
as verifying that the clauses were all binary OpExprs.  This works
99.99% of the time, because the clauses have the right shape when
emitted by the parser --- but it's possible for function inlining to
break that, as reported by PegoraroF10.  To fix, teach the planner
to check that the LHS and RHS contain the right things, or more
accurately don't contain the wrong things.  Given that this has been
broken for years without anyone noticing, it seems sufficient to just
give up hashing when it happens, rather than go to the trouble of
commuting the clauses back again (which wouldn't necessarily work
anyway).

While poking at that, I also noticed that nodeSubplan.c had a baked-in
assumption that the number of hash clauses is identical to the number
of subquery output columns.  Again, that's fine as far as parser output
goes, but it's not hard to break it via function inlining.  There seems
little reason for that assumption though --- AFAICS, the only thing
it's buying us is not having to store the number of hash clauses
explicitly.  Adding code to the planner to reject such cases would take
more code than getting nodeSubplan.c to cope, so I fixed it that way.

This has been broken for as long as we've had hashable SubPlans,
so back-patch to all supported branches.

Discussion: https://postgr.es/m/1549209182255-0.post@n3.nabble.com
2020-08-14 22:14:03 -04:00
..
access Handle new HOT chains in index-build table scans 2020-08-13 17:33:49 -04:00
bootstrap Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:13 -07:00
catalog Assert that we don't insert nulls into attnotnull catalog columns. 2020-07-21 12:38:08 -04:00
commands Make contrib modules' installation scripts more secure. 2020-08-10 10:44:42 -04:00
executor Be more careful about the shape of hashable subplan clauses. 2020-08-14 22:14:03 -04:00
foreign Update copyright for 2019 2019-01-02 12:44:25 -05:00
jit Kluge slot_compile_deform() to ignore incorrect attnotnull markings. 2020-07-20 15:54:24 -04:00
lib Fix more typos and inconsistencies in the tree 2019-06-17 16:13:16 +09:00
libpq gss: add missing references to hostgssenc and hostnogssenc 2020-05-25 20:19:28 -04:00
main Replace @postgresql.org with @lists.postgresql.org for mailinglists 2019-01-19 19:06:35 +01:00
nodes Get rid of trailing semicolons in C macro definitions. 2020-05-01 17:28:00 -04:00
optimizer Be more careful about the shape of hashable subplan clauses. 2020-08-14 22:14:03 -04:00
parser Fix CREATE TABLE LIKE INCLUDING GENERATED column order issue 2020-04-09 16:34:30 +02:00
partitioning Fix yet another issue with step generation in partition pruning. 2020-08-07 14:45:02 +09:00
po Translation updates 2020-08-10 15:21:18 +02:00
port Fix race condition in our Windows signal emulation. 2019-12-09 15:03:51 -05:00
postmaster Fix postmaster's behavior during smart shutdown. 2020-08-14 13:26:57 -04:00
regex Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
replication Empty search_path in logical replication apply worker and walsender. 2020-08-10 09:22:58 -07:00
rewrite Make rewriter prevent auto-updates on views with conditional INSTEAD rules. 2020-01-14 09:51:28 +00:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Fix race condition in statext_store(). 2020-03-31 17:06:22 -04:00
storage Fix error message. 2020-07-23 21:17:47 +12:00
tcop Re-implement the ereport() macro using __VA_ARGS__. 2020-03-24 11:48:33 -04:00
tsearch Fix recently-introduced performance problem in ts_headline(). 2020-07-31 11:43:12 -04:00
utils Fix postmaster's behavior during smart shutdown. 2020-08-14 13:26:57 -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 Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
nls.mk Translation updates 2020-08-10 15:21:18 +02:00