Re: Soon-to-be-broken regression test case

Alvaro Herrera <alvherre@2ndquadrant.com>

From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Haas <robertmhaas@gmail.com>, Jeevan Chalke <jeevan.chalke@enterprisedb.com>, pgsql-hackers@lists.postgresql.org, David Rowley <david.rowley@2ndquadrant.com>
Date: 2018-10-11T16:52:51Z
Lists: pgsql-hackers
On 2018-Oct-11, Tom Lane wrote:

> Hm, I'm not seeing any regression test result changes there.  However,
> if you're just executing queries and not EXPLAIN'ing them, it's possible
> something unwanted is happening under the hood.

Hmm, no, the explains are there.  Here's one example -- maybe your new
planner smarts do not change these plans for some reason (I note that
you mentioned EXISTS in your OP, which this one does not use; I further
note that we don't use EXISTS anywhere in partition_prune.sql, which
probably amounts to uncovered cases):

prepare ab_q2 (int, int) as
select a from ab where a between $1 and $2 and b < (select 3);

explain (analyze, costs off, summary off, timing off) execute ab_q2 (2, 2);
                       QUERY PLAN                       
--------------------------------------------------------
 Append (actual rows=0 loops=1)
   InitPlan 1 (returns $0)
     ->  Result (actual rows=1 loops=1)
   Subplans Removed: 6
   ->  Seq Scan on ab_a2_b1 (actual rows=0 loops=1)
         Filter: ((a >= $1) AND (a <= $2) AND (b < $0))
   ->  Seq Scan on ab_a2_b2 (actual rows=0 loops=1)
         Filter: ((a >= $1) AND (a <= $2) AND (b < $0))
   ->  Seq Scan on ab_a2_b3 (never executed)
         Filter: ((a >= $1) AND (a <= $2) AND (b < $0))
(10 rows)

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Commits

  1. Make some subquery-using test cases a bit more robust.

  2. Prevent generation of bogus subquery scan paths.