1
by brian
clean slate |
1 |
--disable_warnings
|
2 |
drop table if exists t1_30237_bool; |
|
3 |
--enable_warnings
|
|
4 |
||
5 |
create table t1_30237_bool(A char, B char, C char); |
|
520.1.8
by Brian Aker
Updating tests. |
6 |
|
1
by brian
clean slate |
7 |
insert into t1_30237_bool values |
8 |
(FALSE, FALSE, FALSE), |
|
9 |
(FALSE, FALSE, NULL), |
|
10 |
(FALSE, FALSE, TRUE), |
|
11 |
(FALSE, NULL, FALSE), |
|
12 |
(FALSE, NULL, NULL), |
|
13 |
(FALSE, NULL, TRUE), |
|
14 |
(FALSE, TRUE, FALSE), |
|
15 |
(FALSE, TRUE, NULL), |
|
16 |
(FALSE, TRUE, TRUE), |
|
17 |
(NULL, FALSE, FALSE), |
|
18 |
(NULL, FALSE, NULL), |
|
19 |
(NULL, FALSE, TRUE), |
|
20 |
(NULL, NULL, FALSE), |
|
21 |
(NULL, NULL, NULL), |
|
22 |
(NULL, NULL, TRUE), |
|
23 |
(NULL, TRUE, FALSE), |
|
24 |
(NULL, TRUE, NULL), |
|
25 |
(NULL, TRUE, TRUE), |
|
26 |
(TRUE, FALSE, FALSE), |
|
27 |
(TRUE, FALSE, NULL), |
|
28 |
(TRUE, FALSE, TRUE), |
|
29 |
(TRUE, NULL, FALSE), |
|
30 |
(TRUE, NULL, NULL), |
|
31 |
(TRUE, NULL, TRUE), |
|
32 |
(TRUE, TRUE, FALSE), |
|
33 |
(TRUE, TRUE, NULL), |
|
34 |
(TRUE, TRUE, TRUE) ; |
|
35 |
||
36 |
--echo Testing OR, XOR, AND
|
|
37 |
select A, B, A OR B, A XOR B, A AND B |
|
38 |
from t1_30237_bool where C is null order by A, B; |
|
39 |
||
40 |
--echo Testing that OR is associative
|
|
41 |
select A, B, C, (A OR B) OR C, A OR (B OR C), A OR B OR C |
|
42 |
from t1_30237_bool order by A, B, C; |
|
43 |
||
44 |
select count(*) from t1_30237_bool |
|
45 |
where ((A OR B) OR C) != (A OR (B OR C)); |
|
46 |
||
47 |
--echo Testing that XOR is associative
|
|
48 |
select A, B, C, (A XOR B) XOR C, A XOR (B XOR C), A XOR B XOR C |
|
49 |
from t1_30237_bool order by A, B, C; |
|
50 |
||
51 |
select count(*) from t1_30237_bool |
|
52 |
where ((A XOR B) XOR C) != (A XOR (B XOR C)); |
|
53 |
||
54 |
--echo Testing that AND is associative
|
|
55 |
select A, B, C, (A AND B) AND C, A AND (B AND C), A AND B AND C |
|
56 |
from t1_30237_bool order by A, B, C; |
|
57 |
||
58 |
select count(*) from t1_30237_bool |
|
59 |
where ((A AND B) AND C) != (A AND (B AND C)); |
|
60 |
||
61 |
--echo Testing that AND has precedence over OR
|
|
62 |
select A, B, C, (A OR B) AND C, A OR (B AND C), A OR B AND C |
|
63 |
from t1_30237_bool order by A, B, C; |
|
64 |
select count(*) from t1_30237_bool |
|
65 |
where (A OR (B AND C)) != (A OR B AND C); |
|
66 |
select A, B, C, (A AND B) OR C, A AND (B OR C), A AND B OR C |
|
67 |
from t1_30237_bool order by A, B, C; |
|
68 |
select count(*) from t1_30237_bool |
|
69 |
where ((A AND B) OR C) != (A AND B OR C); |
|
70 |
||
71 |
--echo Testing that AND has precedence over XOR
|
|
72 |
select A, B, C, (A XOR B) AND C, A XOR (B AND C), A XOR B AND C |
|
73 |
from t1_30237_bool order by A, B, C; |
|
74 |
select count(*) from t1_30237_bool |
|
75 |
where (A XOR (B AND C)) != (A XOR B AND C); |
|
76 |
select A, B, C, (A AND B) XOR C, A AND (B XOR C), A AND B XOR C |
|
77 |
from t1_30237_bool order by A, B, C; |
|
78 |
select count(*) from t1_30237_bool |
|
79 |
where ((A AND B) XOR C) != (A AND B XOR C); |
|
80 |
||
81 |
--echo Testing that XOR has precedence over OR
|
|
82 |
select A, B, C, (A XOR B) OR C, A XOR (B OR C), A XOR B OR C |
|
83 |
from t1_30237_bool order by A, B, C; |
|
84 |
select count(*) from t1_30237_bool |
|
85 |
where ((A XOR B) OR C) != (A XOR B OR C); |
|
86 |
select A, B, C, (A OR B) XOR C, A OR (B XOR C), A OR B XOR C |
|
87 |
from t1_30237_bool order by A, B, C; |
|
88 |
select count(*) from t1_30237_bool |
|
89 |
where (A OR (B XOR C)) != (A OR B XOR C); |
|
90 |
||
91 |
drop table t1_30237_bool; |
|
92 |
||
93 |
--echo Testing that NOT has precedence over OR
|
|
94 |
select (NOT FALSE) OR TRUE, NOT (FALSE OR TRUE), NOT FALSE OR TRUE; |
|
95 |
||
96 |
--echo Testing that NOT has precedence over XOR
|
|
97 |
select (NOT FALSE) XOR FALSE, NOT (FALSE XOR FALSE), NOT FALSE XOR FALSE; |
|
98 |
||
99 |
--echo Testing that NOT has precedence over AND
|
|
100 |
select (NOT FALSE) AND FALSE, NOT (FALSE AND FALSE), NOT FALSE AND FALSE; |
|
101 |
||
102 |
--echo Testing that NOT is associative
|
|
103 |
select NOT NOT TRUE, NOT NOT NOT FALSE; |
|
104 |
||
105 |
--echo Testing that IS has precedence over NOT
|
|
106 |
select (NOT NULL) IS TRUE, NOT (NULL IS TRUE), NOT NULL IS TRUE; |
|
107 |
select (NOT NULL) IS NOT TRUE, NOT (NULL IS NOT TRUE), NOT NULL IS NOT TRUE; |
|
108 |
select (NOT NULL) IS FALSE, NOT (NULL IS FALSE), NOT NULL IS FALSE; |
|
109 |
select (NOT NULL) IS NOT FALSE, NOT (NULL IS NOT FALSE), NOT NULL IS NOT FALSE; |
|
110 |
select (NOT TRUE) IS UNKNOWN, NOT (TRUE IS UNKNOWN), NOT TRUE IS UNKNOWN; |
|
111 |
select (NOT TRUE) IS NOT UNKNOWN, NOT (TRUE IS NOT UNKNOWN), NOT TRUE IS NOT UNKNOWN; |
|
112 |
select (NOT TRUE) IS NULL, NOT (TRUE IS NULL), NOT TRUE IS NULL; |
|
113 |
select (NOT TRUE) IS NOT NULL, NOT (TRUE IS NOT NULL), NOT TRUE IS NOT NULL; |
|
114 |
||
115 |
--echo Testing that IS [NOT] TRUE/FALSE/UNKNOWN predicates are not associative
|
|
116 |
# Documenting existing behavior in 5.0.48 |
|
117 |
-- error ER_PARSE_ERROR
|
|
118 |
select TRUE IS TRUE IS TRUE IS TRUE; |
|
119 |
-- error ER_PARSE_ERROR
|
|
120 |
select FALSE IS NOT TRUE IS NOT TRUE IS NOT TRUE; |
|
121 |
-- error ER_PARSE_ERROR
|
|
122 |
select NULL IS FALSE IS FALSE IS FALSE; |
|
123 |
-- error ER_PARSE_ERROR
|
|
124 |
select TRUE IS NOT FALSE IS NOT FALSE IS NOT FALSE; |
|
125 |
-- error ER_PARSE_ERROR
|
|
126 |
select FALSE IS UNKNOWN IS UNKNOWN IS UNKNOWN; |
|
127 |
-- error ER_PARSE_ERROR
|
|
128 |
select TRUE IS NOT UNKNOWN IS NOT UNKNOWN IS NOT UNKNOWN; |
|
129 |
||
130 |
--echo Testing that IS [NOT] NULL predicates are associative
|
|
131 |
# Documenting existing behavior in 5.0.48 |
|
132 |
select FALSE IS NULL IS NULL IS NULL; |
|
133 |
select TRUE IS NOT NULL IS NOT NULL IS NOT NULL; |
|
134 |
||
135 |
--echo Testing that comparison operators are left associative
|
|
136 |
select 1 <=> 2 <=> 2, (1 <=> 2) <=> 2, 1 <=> (2 <=> 2); |
|
137 |
select 1 = 2 = 2, (1 = 2) = 2, 1 = (2 = 2); |
|
138 |
select 1 != 2 != 3, (1 != 2) != 3, 1 != (2 != 3); |
|
139 |
select 1 <> 2 <> 3, (1 <> 2) <> 3, 1 <> (2 <> 3); |
|
140 |
select 1 < 2 < 3, (1 < 2) < 3, 1 < (2 < 3); |
|
141 |
select 3 <= 2 <= 1, (3 <= 2) <= 1, 3 <= (2 <= 1); |
|
142 |
select 1 > 2 > 3, (1 > 2) > 3, 1 > (2 > 3); |
|
143 |
select 1 >= 2 >= 3, (1 >= 2) >= 3, 1 >= (2 >= 3); |
|
144 |
||
145 |
--echo Testing that binary + is associative
|
|
146 |
select 1 + 2 + 3, (1 + 2) + 3, 1 + (2 + 3); |
|
147 |
||
148 |
--echo Testing that binary - is left associative
|
|
149 |
select 1 - 2 - 3, (1 - 2) - 3, 1 - (2 - 3); |
|
150 |
||
151 |
--echo Testing that binary + and binary - have the same precedence
|
|
152 |
# evaluated left to right |
|
153 |
select 1 + 2 - 3, (1 + 2) - 3, 1 + (2 - 3); |
|
154 |
select 1 - 2 + 3, (1 - 2) + 3, 1 - (2 + 3); |
|
155 |
||
156 |
--echo Testing that * is associative
|
|
157 |
select 2 * 3 * 4, (2 * 3) * 4, 2 * (3 * 4); |
|
158 |
||
159 |
--echo Testing that * has precedence over binary +
|
|
160 |
select 2 * 3 + 4, (2 * 3) + 4, 2 * (3 + 4); |
|
161 |
select 2 + 3 * 4, (2 + 3) * 4, 2 + (3 * 4); |
|
162 |
||
163 |
--echo Testing that * has precedence over binary -
|
|
164 |
select 4 * 3 - 2, (4 * 3) - 2, 4 * (3 - 2); |
|
165 |
select 4 - 3 * 2, (4 - 3) * 2, 4 - (3 * 2); |
|
166 |
||
167 |
--echo Testing that / is left associative
|
|
168 |
select 15 / 5 / 3, (15 / 5) / 3, 15 / (5 / 3); |
|
169 |
||
170 |
--echo Testing that / has precedence over binary +
|
|
171 |
select 0x80 / 2 + 2, (0x80 / 2) + 2, 0x80 / (2 + 2); |
|
172 |
select 0x80 + 2 / 2, (0x80 + 2) / 2, 0x80 + (2 / 2); |
|
173 |
||
174 |
--echo Testing that / has precedence over binary -
|
|
175 |
select 0x80 / 4 - 2, (0x80 / 4) - 2, 0x80 / (4 - 2); |
|
176 |
select 0x80 - 4 / 2, (0x80 - 4) / 2, 0x80 - (4 / 2); |
|
177 |