Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0f8e9b4

Browse files
committed
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.
1 parent3a4f7dd commit0f8e9b4

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed

‎src/test/regress/expected/select_distinct.out

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,74 @@ SELECT DISTINCT p.age FROM person* p ORDER BY age using >;
124124
8
125125
(20 rows)
126126

127+
--
128+
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
129+
-- very own regression file.
130+
--
131+
CREATE TEMP TABLE disttable (f1 integer);
132+
INSERT INTO DISTTABLE VALUES(1);
133+
INSERT INTO DISTTABLE VALUES(2);
134+
INSERT INTO DISTTABLE VALUES(3);
135+
INSERT INTO DISTTABLE VALUES(NULL);
136+
-- basic cases
137+
SELECT f1, f1 IS DISTINCT FROM 2 as "not 2" FROM disttable;
138+
f1 | not 2
139+
----+-------
140+
1 | t
141+
2 | f
142+
3 | t
143+
| t
144+
(4 rows)
145+
146+
SELECT f1, f1 IS DISTINCT FROM NULL as "not null" FROM disttable;
147+
f1 | not null
148+
----+----------
149+
1 | t
150+
2 | t
151+
3 | t
152+
| f
153+
(4 rows)
154+
155+
SELECT f1, f1 IS DISTINCT FROM f1 as "false" FROM disttable;
156+
f1 | false
157+
----+-------
158+
1 | f
159+
2 | f
160+
3 | f
161+
| f
162+
(4 rows)
163+
164+
SELECT f1, f1 IS DISTINCT FROM f1+1 as "not null" FROM disttable;
165+
f1 | not null
166+
----+----------
167+
1 | t
168+
2 | t
169+
3 | t
170+
| f
171+
(4 rows)
172+
173+
-- check that optimizer constant-folds it properly
174+
SELECT 1 IS DISTINCT FROM 2 as "yes";
175+
yes
176+
-----
177+
t
178+
(1 row)
179+
180+
SELECT 2 IS DISTINCT FROM 2 as "no";
181+
no
182+
----
183+
f
184+
(1 row)
185+
186+
SELECT 2 IS DISTINCT FROM null as "yes";
187+
yes
188+
-----
189+
t
190+
(1 row)
191+
192+
SELECT null IS DISTINCT FROM null as "no";
193+
no
194+
----
195+
f
196+
(1 row)
197+

‎src/test/regress/sql/select_distinct.sql

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,25 @@ SELECT DISTINCT two, string4, ten
3434
--
3535
SELECT DISTINCTp.ageFROM person* pORDER BY age using>;
3636

37+
--
38+
-- Also, some tests of IS DISTINCT FROM, which doesn't quite deserve its
39+
-- very own regression file.
40+
--
41+
42+
CREATE TEMP TABLE disttable (f1integer);
43+
INSERT INTO DISTTABLEVALUES(1);
44+
INSERT INTO DISTTABLEVALUES(2);
45+
INSERT INTO DISTTABLEVALUES(3);
46+
INSERT INTO DISTTABLEVALUES(NULL);
47+
48+
-- basic cases
49+
SELECT f1, f1 IS DISTINCTFROM2as"not 2"FROM disttable;
50+
SELECT f1, f1 IS DISTINCTFROMNULLas"not null"FROM disttable;
51+
SELECT f1, f1 IS DISTINCTFROM f1as"false"FROM disttable;
52+
SELECT f1, f1 IS DISTINCTFROM f1+1as"not null"FROM disttable;
53+
54+
-- check that optimizer constant-folds it properly
55+
SELECT1 IS DISTINCTFROM2as"yes";
56+
SELECT2 IS DISTINCTFROM2as"no";
57+
SELECT2 IS DISTINCTFROMnullas"yes";
58+
SELECTnull IS DISTINCTFROMnullas"no";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp