]> granicus.if.org Git - postgresql/blobdiff - src/test/regress/expected/select_distinct.out
Add a basic regression test for IS DISTINCT FROM, which has spent way too
[postgresql] / src / test / regress / expected / select_distinct.out
index 4dcbd3a30edd3c7c489a33d54b94667c249874b5..019638ed176c4a50ff70e51a099c88d121a05903 100644 (file)
@@ -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)
+