diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out index 4dcbd3a30edd3c7c489a33d54b94667c249874b5..019638ed176c4a50ff70e51a099c88d121a05903 100644 --- a/src/test/regress/expected/select_distinct.out +++ b/src/test/regress/expected/select_distinct.out @@ -124,3 +124,74 @@ SELECT DISTINCT p.age FROM person* p ORDER BY age using >; 8 (20 rows) +-- +-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its +-- very own regression file. +-- +CREATE TEMP TABLE disttable (f1 integer); +INSERT INTO DISTTABLE VALUES(1); +INSERT INTO DISTTABLE VALUES(2); +INSERT INTO DISTTABLE VALUES(3); +INSERT INTO DISTTABLE VALUES(NULL); +-- basic cases +SELECT f1, f1 IS DISTINCT FROM 2 as "not 2" FROM disttable; + f1 | not 2 +----+------- + 1 | t + 2 | f + 3 | t + | t +(4 rows) + +SELECT f1, f1 IS DISTINCT FROM NULL as "not null" FROM disttable; + f1 | not null +----+---------- + 1 | t + 2 | t + 3 | t + | f +(4 rows) + +SELECT f1, f1 IS DISTINCT FROM f1 as "false" FROM disttable; + f1 | false +----+------- + 1 | f + 2 | f + 3 | f + | f +(4 rows) + +SELECT f1, f1 IS DISTINCT FROM f1+1 as "not null" FROM disttable; + f1 | not null +----+---------- + 1 | t + 2 | t + 3 | t + | f +(4 rows) + +-- check that optimizer constant-folds it properly +SELECT 1 IS DISTINCT FROM 2 as "yes"; + yes +----- + t +(1 row) + +SELECT 2 IS DISTINCT FROM 2 as "no"; + no +---- + f +(1 row) + +SELECT 2 IS DISTINCT FROM null as "yes"; + yes +----- + t +(1 row) + +SELECT null IS DISTINCT FROM null as "no"; + no +---- + f +(1 row) + diff --git a/src/test/regress/sql/select_distinct.sql b/src/test/regress/sql/select_distinct.sql index 7cd98002e0f3bc18a818933b884092c0e59f8097..94032c312eed5aff51f5ee7404e7851e0c8ad3f7 100644 --- a/src/test/regress/sql/select_distinct.sql +++ b/src/test/regress/sql/select_distinct.sql @@ -34,3 +34,25 @@ SELECT DISTINCT two, string4, ten -- SELECT DISTINCT p.age FROM person* p ORDER BY age using >; +-- +-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its +-- very own regression file. +-- + +CREATE TEMP TABLE disttable (f1 integer); +INSERT INTO DISTTABLE VALUES(1); +INSERT INTO DISTTABLE VALUES(2); +INSERT INTO DISTTABLE VALUES(3); +INSERT INTO DISTTABLE VALUES(NULL); + +-- basic cases +SELECT f1, f1 IS DISTINCT FROM 2 as "not 2" FROM disttable; +SELECT f1, f1 IS DISTINCT FROM NULL as "not null" FROM disttable; +SELECT f1, f1 IS DISTINCT FROM f1 as "false" FROM disttable; +SELECT f1, f1 IS DISTINCT FROM f1+1 as "not null" FROM disttable; + +-- check that optimizer constant-folds it properly +SELECT 1 IS DISTINCT FROM 2 as "yes"; +SELECT 2 IS DISTINCT FROM 2 as "no"; +SELECT 2 IS DISTINCT FROM null as "yes"; +SELECT null IS DISTINCT FROM null as "no";