Commit 0f8e9b4d authored by Tom Lane's avatar Tom Lane

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.
parent 3a4f7dde
...@@ -124,3 +124,74 @@ SELECT DISTINCT p.age FROM person* p ORDER BY age using >; ...@@ -124,3 +124,74 @@ SELECT DISTINCT p.age FROM person* p ORDER BY age using >;
8 8
(20 rows) (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)
...@@ -34,3 +34,25 @@ SELECT DISTINCT two, string4, ten ...@@ -34,3 +34,25 @@ SELECT DISTINCT two, string4, ten
-- --
SELECT DISTINCT p.age FROM person* p ORDER BY age using >; 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";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment