From: Tom Lane Date: Fri, 13 Dec 2002 20:16:11 +0000 (+0000) Subject: Add a basic regression test for IS DISTINCT FROM, which has spent way too X-Git-Tag: REL7_4_BETA1~1367 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f8e9b4d741c8599165e4a5978a828ca903b65d1;p=postgresql Add a basic regression test for IS DISTINCT FROM, which has spent way too much time in a broken state for lack of anyone noticing. --- diff --git a/src/test/regress/expected/select_distinct.out b/src/test/regress/expected/select_distinct.out index 4dcbd3a30e..019638ed17 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 7cd98002e0..94032c312e 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";