gpdb icon indicating copy to clipboard operation
gpdb copied to clipboard

Wrong result in planner for nullable constraint

Open chrishajas opened this issue 5 years ago • 1 comments

Greenplum version or build

master, 6, 5

Step to reproduce the behavior

create table ta(a int check(a = 1));
insert into ta values(null);
select * from ta where a is null;

In Greenplum planner:

test=# select * from ta where a is null;
 a
---
(0 rows)
test=# explain select * from ta where a is null;
                QUERY PLAN
------------------------------------------
 Result  (cost=0.00..0.01 rows=1 width=0)
   One-Time Filter: false
 Optimizer: Postgres query optimizer
(3 rows)

In postgres 9.3 and 9.6:

select * from ta where a is null;
 a 
---
  
(1 row)

This issue also exists in ORCA and is being fixed there.

chrishajas avatar Sep 06 '19 17:09 chrishajas

Effect of Unknown in WHERE clauses. See https://en.wikipedia.org/wiki/Null_(SQL)

gfphoenix78 avatar Nov 01 '19 09:11 gfphoenix78

Close this since this is fixed by https://github.com/greenplum-db/gpdb/pull/14553 in main branch. For 6X we don't want to change behavior until we hear from real complains.

kainwen avatar Dec 01 '22 12:12 kainwen