6 -- sanity check - if this fails go insane!
11 -- ******************testing built-in type bool********************
13 -- check bool input syntax
17 SELECT false AS false;
19 SELECT bool 't' AS true;
21 SELECT bool ' f ' AS false;
23 SELECT bool 'true' AS true;
25 SELECT bool 'test' AS error;
27 SELECT bool 'false' AS false;
29 SELECT bool 'foo' AS error;
31 SELECT bool 'y' AS true;
33 SELECT bool 'yes' AS true;
35 SELECT bool 'yeah' AS error;
37 SELECT bool 'n' AS false;
39 SELECT bool 'no' AS false;
41 SELECT bool 'nay' AS error;
43 SELECT bool 'on' AS true;
45 SELECT bool 'off' AS false;
47 SELECT bool 'of' AS false;
49 SELECT bool 'o' AS error;
51 SELECT bool 'on_' AS error;
53 SELECT bool 'off_' AS error;
55 SELECT bool '1' AS true;
57 SELECT bool '11' AS error;
59 SELECT bool '0' AS false;
61 SELECT bool '000' AS error;
63 SELECT bool '' AS error;
65 -- and, or, not in qualifications
67 SELECT bool 't' or bool 'f' AS true;
69 SELECT bool 't' and bool 'f' AS false;
71 SELECT not bool 'f' AS true;
73 SELECT bool 't' = bool 'f' AS false;
75 SELECT bool 't' <> bool 'f' AS true;
77 SELECT bool 't' > bool 'f' AS true;
79 SELECT bool 't' >= bool 'f' AS true;
81 SELECT bool 'f' < bool 't' AS true;
83 SELECT bool 'f' <= bool 't' AS true;
85 -- explicit casts to/from text
86 SELECT 'TrUe'::text::boolean AS true, 'fAlse'::text::boolean AS false;
87 SELECT ' true '::text::boolean AS true,
88 ' FALSE'::text::boolean AS false;
89 SELECT true::boolean::text AS true, false::boolean::text AS false;
91 SELECT ' tru e '::text::boolean AS invalid; -- error
92 SELECT ''::text::boolean AS invalid; -- error
94 CREATE TABLE BOOLTBL1 (f1 bool);
96 INSERT INTO BOOLTBL1 (f1) VALUES (bool 't');
98 INSERT INTO BOOLTBL1 (f1) VALUES (bool 'True');
100 INSERT INTO BOOLTBL1 (f1) VALUES (bool 'true');
103 -- BOOLTBL1 should be full of true's at this point
104 SELECT '' AS t_3, BOOLTBL1.* FROM BOOLTBL1;
107 SELECT '' AS t_3, BOOLTBL1.*
109 WHERE f1 = bool 'true';
112 SELECT '' AS t_3, BOOLTBL1.*
114 WHERE f1 <> bool 'false';
116 SELECT '' AS zero, BOOLTBL1.*
118 WHERE booleq(bool 'false', f1);
120 INSERT INTO BOOLTBL1 (f1) VALUES (bool 'f');
122 SELECT '' AS f_1, BOOLTBL1.*
124 WHERE f1 = bool 'false';
127 CREATE TABLE BOOLTBL2 (f1 bool);
129 INSERT INTO BOOLTBL2 (f1) VALUES (bool 'f');
131 INSERT INTO BOOLTBL2 (f1) VALUES (bool 'false');
133 INSERT INTO BOOLTBL2 (f1) VALUES (bool 'False');
135 INSERT INTO BOOLTBL2 (f1) VALUES (bool 'FALSE');
137 -- This is now an invalid expression
138 -- For pre-v6.3 this evaluated to false - thomas 1997-10-23
139 INSERT INTO BOOLTBL2 (f1)
142 -- BOOLTBL2 should be full of false's at this point
143 SELECT '' AS f_4, BOOLTBL2.* FROM BOOLTBL2;
146 SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
147 FROM BOOLTBL1, BOOLTBL2
148 WHERE BOOLTBL2.f1 <> BOOLTBL1.f1;
151 SELECT '' AS tf_12, BOOLTBL1.*, BOOLTBL2.*
152 FROM BOOLTBL1, BOOLTBL2
153 WHERE boolne(BOOLTBL2.f1,BOOLTBL1.f1);
156 SELECT '' AS ff_4, BOOLTBL1.*, BOOLTBL2.*
157 FROM BOOLTBL1, BOOLTBL2
158 WHERE BOOLTBL2.f1 = BOOLTBL1.f1 and BOOLTBL1.f1 = bool 'false';
161 SELECT '' AS tf_12_ff_4, BOOLTBL1.*, BOOLTBL2.*
162 FROM BOOLTBL1, BOOLTBL2
163 WHERE BOOLTBL2.f1 = BOOLTBL1.f1 or BOOLTBL1.f1 = bool 'true'
164 ORDER BY BOOLTBL1.f1, BOOLTBL2.f1;
168 -- Try all combinations to ensure that we get nothing when we expect nothing
169 -- - thomas 2000-01-04
172 SELECT '' AS "True", f1
176 SELECT '' AS "Not False", f1
178 WHERE f1 IS NOT FALSE;
180 SELECT '' AS "False", f1
184 SELECT '' AS "Not True", f1
186 WHERE f1 IS NOT TRUE;
188 SELECT '' AS "True", f1
192 SELECT '' AS "Not False", f1
194 WHERE f1 IS NOT FALSE;
196 SELECT '' AS "False", f1
200 SELECT '' AS "Not True", f1
202 WHERE f1 IS NOT TRUE;
206 -- Many tables are retained by the regression test, but these do not seem
207 -- particularly useful so just get rid of them for now.
208 -- - thomas 1997-11-30