postgresql/src/include
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 Fix minor problems with non-exclusive backup cleanup. 2020-08-06 13:58:23 -04:00
bootstrap Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
catalog Avoid direct C access to possibly-null pg_subscription_rel.srsublsn. 2020-07-21 11:40:46 -04:00
commands Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
common Move connect.h from fe_utils to src/include/common. 2020-08-10 09:22:58 -07:00
datatype Update copyright for 2019 2019-01-02 12:44:25 -05:00
executor Minor code review for tuple slot rewrite. 2019-11-06 12:00:17 -05:00
fe_utils Fix parallel restore of FKs to partitioned tables 2019-10-17 09:58:01 +02:00
foreign Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
jit Fix duplicated words in comments 2019-05-14 09:37:35 +09:00
lib Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
libpq Fix postmaster's behavior during smart shutdown. 2020-08-14 13:26:57 -04:00
mb Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
nodes Be more careful about the shape of hashable subplan clauses. 2020-08-14 22:14:03 -04:00
optimizer Be more careful about the shape of hashable subplan clauses. 2020-08-14 22:14:03 -04:00
parser Fill in extraUpdatedCols in logical replication 2020-02-17 15:21:12 +01:00
partitioning Improve pruning of a default partition 2019-08-04 11:18:45 -04:00
port Avoid need for valgrind suppressions for pg_atomic_init_u64 on some platforms. 2020-06-08 20:02:52 -07:00
portability Update copyright for 2019 2019-01-02 12:44:25 -05:00
postmaster Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
regex Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
replication Don't call palloc() while holding a spinlock, either. 2020-06-03 12:36:24 -04:00
rewrite Defend against self-referential views in relation_is_updatable(). 2019-11-21 16:21:43 -05:00
snowball Update copyright for 2019 2019-01-02 12:44:25 -05:00
statistics Fix choose_best_statistics to check clauses individually 2019-11-28 22:26:25 +01:00
storage Revert "Skip WAL for new relfilenodes, under wal_level=minimal." 2020-03-22 09:24:13 -07:00
tcop Fix many typos and inconsistencies 2019-07-01 10:00:23 +09:00
tsearch Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
utils Use query collation, not column's collation, while examining statistics. 2020-06-05 16:18:50 -04:00
.gitignore Refactor dlopen() support 2018-09-06 11:33:04 +02:00
c.h Fix integer-overflow edge case detection in interval_mul and pgbench. 2019-11-07 11:22:59 -05:00
fmgr.h Fix minor violations of FunctionCallInvoke usage protocol. 2020-04-21 14:23:58 -04:00
funcapi.h Avoid holding a directory FD open across assorted SRF calls. 2020-03-16 21:05:53 -04:00
getaddrinfo.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
getopt_long.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
Makefile Get rid of jsonpath_gram.h and jsonpath_scanner.h 2019-03-20 11:13:34 +03:00
miscadmin.h Add unlikely() to CHECK_FOR_INTERRUPTS() 2020-06-05 16:49:28 -04:00
pg_config.h.in Stamp 12.2. 2020-02-10 17:14:51 -05:00
pg_config.h.win32 Stamp 12.4. 2020-08-10 17:15:53 -04:00
pg_config_ext.h.in Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_ext.h.win32 Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
pg_config_manual.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pg_getopt.h Use our own getopt() on OpenBSD. 2019-01-18 15:06:26 -05:00
pg_trace.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
pgstat.h Add GUC variables for stat tracking and timeout as PGDLLIMPORT 2020-01-21 13:46:55 +09:00
pgtar.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
pgtime.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
port.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
postgres.h Change function call information to be variable length. 2019-01-26 14:17:52 -08:00
postgres_ext.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
postgres_fe.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
rusagestub.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
windowapi.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00