pgsql: Fix EXPLAIN to handle gating Result nodes within inner-indexscan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix EXPLAIN to handle gating Result nodes within inner-indexscan
Date: 2011-07-03 05:35:39
Message-ID: E1QdFLH-0004d4-Qo@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix EXPLAIN to handle gating Result nodes within inner-indexscan subplans.

It is possible for a NestLoop plan node to pass an OUTER Var into an
"inner indexscan" that is an Append construct (derived from an inheritance
tree or UNION ALL subquery). The OUTER tuple is then passed down at
runtime to the leaf indexscan node(s) where it will actually be used.
EXPLAIN has to likewise pass the information about the nestloop's outer
subplan down through the Append node, else it will fail to print the
outer-reference Vars (with complaints like "bogus varno: 65001").

However, there was a case missed in all this: we could also have gating
Result nodes that were inserted into the appendrel plan tree to deal with
pseudoconstant qual conditions. So EXPLAIN has to pass down the outer plan
node to a Result's subplan, too. Per example from Jon Nelson.

The problem is gone in 9.1 because we replaced the nestloop outer-tuple
kluge with a Param-based data transfer mechanism. Also, so far as I can
tell, the case can't happen before 8.4 because of restrictions on what
sorts of appendrel members could be pulled up into the parent query.
So this patch is only needed for 8.4 and 9.0.

Branch
------
REL9_0_STABLE

Details
-------
http://git.postgresql.org/pg/commitdiff/789d3d4541e95c6079a55196bd63a6ab90e57c7c

Modified Files
--------------
src/backend/commands/explain.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Magnus Hagander 2011-07-03 11:18:12 pgsql: Mark pg_stat_reset_shared as strict
Previous Message Hiroshi Saito 2011-07-03 05:34:27 psqlodbc - psqlodbc: Prep release the minor version.