postgresql/src/backend
Tom Lane 689696c711 Fix bitmap AND/OR scans on the inside of a nestloop partition-wise join.
reparameterize_path_by_child() failed to reparameterize BitmapAnd
and BitmapOr paths.  This matters only if such a path is chosen as
the inside of a nestloop partition-wise join, where we have to pass
in parameters from the outside of the nestloop.  If that did happen,
we generated a bad plan that would likely lead to crashes at execution.

This is not entirely reparameterize_path_by_child()'s fault though;
it's the victim of an ancient decision (my ancient decision, I think)
to not bother filling in param_info in BitmapAnd/Or path nodes.  That
caused the function to believe that such nodes and their children
contain no parameter references and so need not be processed.

In hindsight that decision looks pretty penny-wise and pound-foolish:
while it saves a few cycles during path node setup, we do commonly
need the information later.  In particular, by reversing the decision
and requiring valid param_info data in all nodes of a bitmap path
tree, we can get rid of indxpath.c's get_bitmap_tree_required_outer()
function, which computed the data on-demand.  It's not unlikely that
that nets out as a savings of cycles in many scenarios.  A couple
of other things in indxpath.c can be simplified as well.

While here, get rid of some cases in reparameterize_path_by_child()
that are visibly dead or useless, given that we only care about
reparameterizing paths that can be on the inside of a parameterized
nestloop.  This case reminds one of the maxim that untested code
probably does not work, so I'm unwilling to leave unreachable code
in this function.  (I did leave the T_Gather case in place even
though it's not reached in the regression tests.  It's not very
clear to me when the planner might prefer to put Gather below
rather than above a nestloop, but at least in principle the case
might be interesting.)

Per bug #16536, originally from Arne Roland but with a test case
by Andrew Gierth.  Back-patch to v11 where this code came in.

Discussion: https://postgr.es/m/16536-2213ee0b3aad41fd@postgresql.org
2020-07-14 18:56:56 -04:00
..
access Fix comments related to table AMs 2020-07-14 13:17:11 +09:00
bootstrap Skip WAL for new relfilenodes, under wal_level=minimal. 2020-04-04 12:25:34 -07:00
catalog Revert "Track statistics for spilling of changes from ReorderBuffer". 2020-07-13 08:53:23 +05:30
commands Add comment to explain an unused function parameter 2020-07-14 17:29:52 +12:00
executor HashAgg: before spilling tuples, set unneeded columns to NULL. 2020-07-12 22:59:32 -07:00
foreign Update copyrights for 2020 2020-01-01 12:21:45 -05:00
jit pgindent run prior to branching v13. 2020-06-07 16:57:08 -04:00
lib Move src/backend/utils/hash/hashfn.c to src/common 2020-02-27 09:25:41 +05:30
libpq code: replace most remaining uses of 'master'. 2020-07-08 13:24:35 -07:00
main Clean up includes of s_lock.h. 2020-06-18 19:41:05 -07:00
nodes Rename field "relkind" to "objtype" for CTAS and ALTER TABLE nodes 2020-07-11 13:32:28 +09:00
optimizer Fix bitmap AND/OR scans on the inside of a nestloop partition-wise join. 2020-07-14 18:56:56 -04:00
parser Rename field "relkind" to "objtype" for CTAS and ALTER TABLE nodes 2020-07-11 13:32:28 +09:00
partitioning Fix two typos in a comment 2020-05-22 17:39:16 -04:00
po Translation updates 2020-05-18 12:49:30 +02:00
port Spelling adjustments 2020-06-07 15:06:51 +02:00
postmaster code: replace 'master' with 'primary' where appropriate. 2020-07-08 12:57:23 -07:00
regex Dial back -Wimplicit-fallthrough to level 3 2020-05-13 15:31:14 -04:00
replication Revert "Track statistics for spilling of changes from ReorderBuffer". 2020-07-13 08:53:23 +05:30
rewrite Add missing invocations to object access hooks 2020-05-23 14:03:04 +09:00
snowball code: replace most remaining uses of 'master'. 2020-07-08 13:24:35 -07:00
statistics Run pgindent with new pg_bsd_indent version 2.1.1. 2020-05-16 11:54:51 -04:00
storage code: replace 'master' with 'primary' where appropriate. 2020-07-08 12:57:23 -07:00
tcop Rename field "relkind" to "objtype" for CTAS and ALTER TABLE nodes 2020-07-11 13:32:28 +09:00
tsearch Mop up some no-longer-necessary hacks around printf %.*s format. 2020-06-29 17:12:38 -04:00
utils Fix -Wcast-function-type warnings 2020-07-14 19:55:25 +02:00
.gitignore
Makefile Update copyrights for 2020 2020-01-01 12:21:45 -05:00
common.mk Remove PARTIAL_LINKING build mode. 2018-03-30 17:33:04 -07:00
nls.mk Add missing gettext triggers 2020-04-28 13:35:40 +02:00