pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>
Cc: David Rowley <david.rowley@2ndquadrant.com>
Cc: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp>
Cc: Alan Jackson <ajax@tvsquared.com>
Cc: PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>
Subject: Re: inconsistent results querying table partitioned by date
Date: Thu, 16 May 2019 16:37:50 -0400
Message-ID: <26062.1558039070@sss.pgh.pa.us> (raw)
In-Reply-To: <12600.1558034735@sss.pgh.pa.us>
References: <FAD28A83-AC73-489E-A058-2681FA31D648@tvsquared.com>
	<90aeaf38-270a-7e45-6b7d-af2e3d1e3719@lab.ntt.co.jp>
	<20307.1557522309@sss.pgh.pa.us>
	<a0bca4f7-b493-4d0a-8080-8dad3748c5ae@lab.ntt.co.jp>
	<CAKJS1f92Uq+SV+WKKa+B5Fd9PcrwhYFsvxUudm_9F8egi4paXQ@mail.gmail.com>
	<d7878f1f-f7c5-4f23-127e-ced79a64ddf1@lab.ntt.co.jp>
	<CAKJS1f-xHgnr0QVfGtt9BU38kB8a5fp4Y=CYbChV8xSqw6pZ9w@mail.gmail.com>
	<e903adfc-c7a5-58f9-6b7f-16ab6f48be5c@lab.ntt.co.jp>
	<28453.1557867500@sss.pgh.pa.us>
	<CAKJS1f82n-WNsu6G5WNXGFV4MsnosydiouRvTNnZYmQz0tciuQ@mail.gmail.com>
	<588f56cb-aaed-14b0-8a21-13486bd1c706@lab.ntt.co.jp>
	<CAKJS1f-QVbr-9-m+=b6mxWxaJYzdK554uptnNyV5M6AhkUMcdg@mail.gmail.com>
	<CAKJS1f-ABcw68AH7tRRRmBTEwhd-Y_Lm8HpfydWw6aPS8G715A@mail.gmail.com>
	<10502.1557941878@sss.pgh.pa.us>
	<CAKJS1f9QP2tDczHDFk=55Jh-wS+bCUWTuBd0uiqg5dfpz6r44g@mail.gmail.com>
	<23372.1557966530@sss.pgh.pa.us>
	<CAKJS1f_wn4qiQfi0Bnfc6uA3rm=ususVyixF8yGFUTjdaY6omg@mail.gmail.com>
	<a4d441a2-bd04-1f5c-c2bc-471a16cc2c21@lab.nt! t.co.jp>
	<14871.1558022797@sss.pgh.pa.us>
	<12600.1558034735@sss.pgh.pa.us>

I wrote:
> So, the changes in gen_prune_steps_from_opexps seem okay, but
> the change in perform_pruning_base_step is just wrong,

I went ahead and pushed the non-controversial part of that patch,
just to avoid carrying it around longer.

I propose that we use the attached test cases once we have a fix
for the remaining problem.  The results shown are the wrong answers
that HEAD produces.  Amit's patch fixes the first case but not the
second, since substituting equality semantics is the right thing
to do in only the first case.

			regards, tom lane

Attachments:

test-case.patch (text/x-diff, 2.8K) download diff --git a/src/test/regress/expected/partition_prune.out b/src/test/regress/expected/partition_prune.out index 723fc70..88701d8 100644 --- a/src/test/regress/expected/partition_prune.out +++ b/src/test/regress/expected/partition_prune.out @@ -3149,6 +3149,43 @@ select * from mc3p where a < 3 and abs(b) = 1; Filter: ((a < 3) AND (abs(b) = 1)) (7 rows) +-- +-- Check that pruning with composite range partitioning works correctly when +-- a combination of runtime parameters is specified, not all of whose values +-- are available at the same time +-- +set plan_cache_mode = force_generic_plan; +prepare ps1 as + select * from mc3p where a = $1 and abs(b) < (select 3); +explain (analyze, costs off, summary off, timing off) +execute ps1(1); + QUERY PLAN +---------------------------------------------- + Append (actual rows=0 loops=1) + InitPlan 1 (returns $0) + -> Result (never executed) + Subplans Removed: 2 + -> Seq Scan on mc3p0 (never executed) + Filter: ((a = $1) AND (abs(b) < $0)) +(6 rows) + +deallocate ps1; +prepare ps2 as + select * from mc3p where a <= $1 and abs(b) < (select 3); +explain (analyze, costs off, summary off, timing off) +execute ps2(1); + QUERY PLAN +------------------------------------------------- + Append (actual rows=1 loops=1) + InitPlan 1 (returns $0) + -> Result (actual rows=1 loops=1) + Subplans Removed: 2 + -> Seq Scan on mc3p0 (actual rows=1 loops=1) + Filter: ((a <= $1) AND (abs(b) < $0)) +(6 rows) + +deallocate ps2; +reset plan_cache_mode; drop table mc3p; -- Ensure runtime pruning works with initplans params with boolean types create table boolvalues (value bool not null); diff --git a/src/test/regress/sql/partition_prune.sql b/src/test/regress/sql/partition_prune.sql index 2373bd8..071e28d 100644 --- a/src/test/regress/sql/partition_prune.sql +++ b/src/test/regress/sql/partition_prune.sql @@ -809,6 +809,24 @@ insert into mc3p values (0, 1, 1), (1, 1, 1), (2, 1, 1); explain (analyze, costs off, summary off, timing off) select * from mc3p where a < 3 and abs(b) = 1; +-- +-- Check that pruning with composite range partitioning works correctly when +-- a combination of runtime parameters is specified, not all of whose values +-- are available at the same time +-- +set plan_cache_mode = force_generic_plan; +prepare ps1 as + select * from mc3p where a = $1 and abs(b) < (select 3); +explain (analyze, costs off, summary off, timing off) +execute ps1(1); +deallocate ps1; +prepare ps2 as + select * from mc3p where a <= $1 and abs(b) < (select 3); +explain (analyze, costs off, summary off, timing off) +execute ps2(1); +deallocate ps2; +reset plan_cache_mode; + drop table mc3p; -- Ensure runtime pruning works with initplans params with boolean types

view thread (41+ messages)  latest in thread

Message-ID: <26062.1558039070@sss.pgh.pa.us>
Permalink:  ../26062.1558039070@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/26062.1558039070@sss.pgh.pa.us

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Langote_Amit_f8@lab.ntt.co.jp, david.rowley@2ndquadrant.com, horiguchi.kyotaro@lab.ntt.co.jp, ajax@tvsquared.com
  Subject: Re: inconsistent results querying table partitioned by date
  In-Reply-To: <26062.1558039070@sss.pgh.pa.us>
  References: <FAD28A83-AC73-489E-A058-2681FA31D648@tvsquared.com> <20307.1557522309@sss.pgh.pa.us> <a0bca4f7-b493-4d0a-8080-8dad3748c5ae@lab.ntt.co.jp> <CAKJS1f92Uq+SV+WKKa+B5Fd9PcrwhYFsvxUudm_9F8egi4paXQ@mail.gmail.com> <d7878f1f-f7c5-4f23-127e-ced79a64ddf1@lab.ntt.co.jp> <CAKJS1f-xHgnr0QVfGtt9BU38kB8a5fp4Y=CYbChV8xSqw6pZ9w@mail.gmail.com> <e903adfc-c7a5-58f9-6b7f-16ab6f48be5c@lab.ntt.co.jp> <28453.1557867500@sss.pgh.pa.us> <CAKJS1f82n-WNsu6G5WNXGFV4MsnosydiouRvTNnZYmQz0tciuQ@mail.gmail.com> <588f56cb-aaed-14b0-8a21-13486bd1c706@lab.ntt.co.jp> <CAKJS1f-QVbr-9-m+=b6mxWxaJYzdK554uptnNyV5M6AhkUMcdg@mail.gmail.com> <CAKJS1f-ABcw68AH7tRRRmBTEwhd-Y_Lm8HpfydWw6aPS8G715A@mail.gmail.com> <10502.1557941878@sss.pgh.pa.us> <CAKJS1f9QP2tDczHDFk=55Jh-wS+bCUWTuBd0uiqg5dfpz6r44g@mail.gmail.com> <23372.1557966530@sss.pgh.pa.us> <CAKJS1f_wn4qiQfi0Bnfc6uA3rm=ususVyixF8yGFUTjdaY6omg@mail.gmail.com> <14871.1558022797@sss.pgh.pa.us> <12600.1558034735@sss.pgh.pa.us> <26062.1558039070@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox