From: PG Bug reporting form <noreply@postgresql.org>
To: pgsql-bugs@lists.postgresql.org
Cc: hisanori.kobayashi.bp@nttdata.com
Subject: BUG #16501: Incorrect result. select multi_key_columns_range_partition_table
Date: Thu, 18 Jun 2020 09:41:44 +0000
Message-ID: <16501-5234a9a0394f6754@postgresql.org> (raw)
The following bug has been logged on the website:
Bug reference: 16501
Logged by: Kobayashi Hisanori
Email address: hisanori.kobayashi.bp@nttdata.com
PostgreSQL version: 12.2
Operating system: Windows10
Description:
I found that Incorrect-result sql.
Same for 12.2 and 12.3
I am not good at English, so I will send a reproduction script.
------------------------------
-- ***** execute from psql
--
-- ***** Create Test Table
drop table if exists pt_test02 ;
create table pt_test02
( kbn smallint not null
, nen char(4) not null
, mm char(2) not null
, cd char(3) not null
, val00 numeric(15, 3)
, usr varchar(10)
)
partition by list(kbn) with (oids=false)
;
create table pt_test02_1 partition of pt_test02 for values in
(1) partition by range(nen, mm) with (oids=false) ;
create table pt_test02_1_2019_01 partition of pt_test02_1 for values from
('2019', '01') to ('2019', '07') ;
create table pt_test02_1_2019_02 partition of pt_test02_1 for values from
('2019', '07') to ('2019', '13') ;
create table pt_test02_1_2020_01 partition of pt_test02_1 for values from
('2020', '01') to ('2020', '07') ;
create table pt_test02_1_2020_02 partition of pt_test02_1 for values from
('2020', '07') to ('2020', '13') ;
create table pt_test02_2 partition of pt_test02 for values in
(2) partition by range(nen, mm) with (oids=false) ;
create table pt_test02_2_2019_01 partition of pt_test02_2 for values from
('2019', '01') to ('2019', '07') ;
create table pt_test02_2_2019_02 partition of pt_test02_2 for values from
('2019', '07') to ('2019', '13') ;
create table pt_test02_2_2020_01 partition of pt_test02_2 for values from
('2020', '01') to ('2020', '07') ;
create table pt_test02_2_2020_02 partition of pt_test02_2 for values from
('2020', '07') to ('2020', '13') ;
--
-- ***** Test Data Insert
insert into pt_test02 values(1, '2020', '01', 1, null, null) ;
--
-- ***** Test SQL and result
--
select count(*) from pt_test02 where kbn = 1 and nen <= '2020' and
mm = '01' ;
-- ***** Result = 0 ... incorrect
--
select count(*) from pt_test02_1 where kbn = 1 and nen <= '2020' and
mm = '01' ;
-- ***** Result = 0 ... incorrect
--
select count(*) from pt_test02_1_2020_01 where kbn = 1 and nen <= '2020' and
mm = '01' ;
-- ***** Result = 1 ... correct
--
select count(*) from pt_test02 where kbn = 1 and nen = '2020' and
mm = '01' ;
-- ***** Result = 1 ... correct
------------------------------
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 using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: noreply@postgresql.org, pgsql-bugs@lists.postgresql.org, hisanori.kobayashi.bp@nttdata.com
Subject: Re: BUG #16501: Incorrect result. select multi_key_columns_range_partition_table
In-Reply-To: <16501-5234a9a0394f6754@postgresql.org>
* 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