~drizzle-trunk/drizzle/development

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 boolean, B boolean, C boolean);
6
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 | is associative
146
select 0xF0 | 0x0F | 0x55, (0xF0 | 0x0F) | 0x55, 0xF0 | (0x0F | 0x55);
147
148
-- echo Testing that & is associative
149
select 0xF5 & 0x5F & 0x55, (0xF5 & 0x5F) & 0x55, 0xF5 & (0x5F & 0x55);
150
151
-- echo Testing that << is left associative
152
select 4 << 3 << 2, (4 << 3) << 2, 4 << (3 << 2);
153
154
-- echo Testing that >> is left associative
155
select 256 >> 3 >> 2, (256 >> 3) >> 2, 256 >> (3 >> 2);
156
157
--echo Testing that & has precedence over |
158
select 0xF0 & 0x0F | 0x55, (0xF0 & 0x0F) | 0x55, 0xF0 & (0x0F | 0x55);
159
select 0x55 | 0xF0 & 0x0F, (0x55 | 0xF0) & 0x0F, 0x55 | (0xF0 & 0x0F);
160
161
--echo Testing that << has precedence over |
162
select 0x0F << 4 | 0x0F, (0x0F << 4) | 0x0F, 0x0F << (4 | 0x0F);
163
select 0x0F | 0x0F << 4, (0x0F | 0x0F) << 4, 0x0F | (0x0F << 4);
164
165
--echo Testing that >> has precedence over |
166
select 0xF0 >> 4 | 0xFF, (0xF0 >> 4) | 0xFF, 0xF0 >> (4 | 0xFF);
167
select 0xFF | 0xF0 >> 4, (0xFF | 0xF0) >> 4, 0xFF | (0xF0 >> 4);
168
169
--echo Testing that << has precedence over &
170
select 0x0F << 4 & 0xF0, (0x0F << 4) & 0xF0, 0x0F << (4 & 0xF0);
171
select 0xF0 & 0x0F << 4, (0xF0 & 0x0F) << 4, 0xF0 & (0x0F << 4);
172
173
--echo Testing that >> has precedence over &
174
select 0xF0 >> 4 & 0x55, (0xF0 >> 4) & 0x55, 0xF0 >> (4 & 0x55);
175
select 0x0F & 0xF0 >> 4, (0x0F & 0xF0) >> 4, 0x0F & (0xF0 >> 4);
176
177
--echo Testing that >> and << have the same precedence
178
select 0xFF >> 4 << 2, (0xFF >> 4) << 2, 0xFF >> (4 << 2);
179
select 0x0F << 4 >> 2, (0x0F << 4) >> 2, 0x0F << (4 >> 2);
180
181
--echo Testing that binary + is associative
182
select 1 + 2 + 3, (1 + 2) + 3, 1 + (2 + 3);
183
184
--echo Testing that binary - is left associative
185
select 1 - 2 - 3, (1 - 2) - 3, 1 - (2 - 3);
186
187
--echo Testing that binary + and binary - have the same precedence
188
# evaluated left to right
189
select 1 + 2 - 3, (1 + 2) - 3, 1 + (2 - 3);
190
select 1 - 2 + 3, (1 - 2) + 3, 1 - (2 + 3);
191
192
--echo Testing that binary + has precedence over |
193
select 0xF0 + 0x0F | 0x55, (0xF0 + 0x0F) | 0x55, 0xF0 + (0x0F | 0x55);
194
select 0x55 | 0xF0 + 0x0F, (0x55 | 0xF0) + 0x0F, 0x55 | (0xF0 + 0x0F);
195
196
--echo Testing that binary + has precedence over &
197
select 0xF0 + 0x0F & 0x55, (0xF0 + 0x0F) & 0x55, 0xF0 + (0x0F & 0x55);
198
select 0x55 & 0xF0 + 0x0F, (0x55 & 0xF0) + 0x0F, 0x55 & (0xF0 + 0x0F);
199
200
--echo Testing that binary + has precedence over <<
201
select 2 + 3 << 4, (2 + 3) << 4, 2 + (3 << 4);
202
select 3 << 4 + 2, (3 << 4) + 2, 3 << (4 + 2);
203
204
--echo Testing that binary + has precedence over >>
205
select 4 + 3 >> 2, (4 + 3) >> 2, 4 + (3 >> 2);
206
select 3 >> 2 + 1, (3 >> 2) + 1, 3 >> (2 + 1);
207
208
--echo Testing that binary - has precedence over |
209
select 0xFF - 0x0F | 0x55, (0xFF - 0x0F) | 0x55, 0xFF - (0x0F | 0x55);
210
select 0x55 | 0xFF - 0xF0, (0x55 | 0xFF) - 0xF0, 0x55 | (0xFF - 0xF0);
211
212
--echo Testing that binary - has precedence over &
213
select 0xFF - 0xF0 & 0x55, (0xFF - 0xF0) & 0x55, 0xFF - (0xF0 & 0x55);
214
select 0x55 & 0xFF - 0xF0, (0x55 & 0xFF) - 0xF0, 0x55 & (0xFF - 0xF0);
215
216
--echo Testing that binary - has precedence over <<
217
select 16 - 3 << 2, (16 - 3) << 2, 16 - (3 << 2);
218
select 4 << 3 - 2, (4 << 3) - 2, 4 << (3 - 2);
219
220
--echo Testing that binary - has precedence over >>
221
select 16 - 3 >> 2, (16 - 3) >> 2, 16 - (3 >> 2);
222
select 16 >> 3 - 2, (16 >> 3) - 2, 16 >> (3 - 2);
223
224
--echo Testing that * is associative
225
select 2 * 3 * 4, (2 * 3) * 4, 2 * (3 * 4);
226
227
--echo Testing that * has precedence over |
228
select 2 * 0x40 | 0x0F, (2 * 0x40) | 0x0F, 2 * (0x40 | 0x0F);
229
select 0x0F | 2 * 0x40, (0x0F | 2) * 0x40, 0x0F | (2 * 0x40);
230
231
--echo Testing that * has precedence over &
232
select 2 * 0x40 & 0x55, (2 * 0x40) & 0x55, 2 * (0x40 & 0x55);
233
select 0xF0 & 2 * 0x40, (0xF0 & 2) * 0x40, 0xF0 & (2 * 0x40);
234
235
--echo Testing that * has precedence over << 
236
# Actually, can't prove it for the first case,
237
# since << is a multiplication by a power of 2,
238
# and * is associative
239
select 5 * 3 << 4, (5 * 3) << 4, 5 * (3 << 4);
240
select 2 << 3 * 4, (2 << 3) * 4, 2 << (3 * 4);
241
242
--echo Testing that * has precedence over >>
243
# >> is a multiplication by a (negative) power of 2,
244
# see above.
245
select 3 * 4 >> 2, (3 * 4) >> 2, 3 * (4 >> 2);
246
select 4 >> 2 * 3, (4 >> 2) * 3, 4 >> (2 * 3);
247
248
--echo Testing that * has precedence over binary +
249
select 2 * 3 + 4, (2 * 3) + 4, 2 * (3 + 4);
250
select 2 + 3 * 4, (2 + 3) * 4, 2 + (3 * 4);
251
252
--echo Testing that * has precedence over binary -
253
select 4 * 3 - 2, (4 * 3) - 2, 4 * (3 - 2);
254
select 4 - 3 * 2, (4 - 3) * 2, 4 - (3 * 2);
255
256
--echo Testing that / is left associative
257
select 15 / 5 / 3, (15 / 5) / 3, 15 / (5 / 3);
258
259
--echo Testing that / has precedence over |
260
select 105 / 5 | 2, (105 / 5) | 2, 105 / (5 | 2);
261
select 105 | 2 / 5, (105 | 2) / 5, 105 | (2 / 5);
262
263
--echo Testing that / has precedence over &
264
select 105 / 5 & 0x0F, (105 / 5) & 0x0F, 105 / (5 & 0x0F);
265
select 0x0F & 105 / 5, (0x0F & 105) / 5, 0x0F & (105 / 5);
266
267
--echo Testing that / has precedence over << 
268
select 0x80 / 4 << 2, (0x80 / 4) << 2, 0x80 / (4 << 2);
269
select 0x80 << 4 / 2, (0x80 << 4) / 2, 0x80 << (4 / 2);
270
271
--echo Testing that / has precedence over >>
272
select 0x80 / 4 >> 2, (0x80 / 4) >> 2, 0x80 / (4 >> 2);
273
select 0x80 >> 4 / 2, (0x80 >> 4) / 2, 0x80 >> (4 / 2);
274
275
--echo Testing that / has precedence over binary +
276
select 0x80 / 2 + 2, (0x80 / 2) + 2, 0x80 / (2 + 2);
277
select 0x80 + 2 / 2, (0x80 + 2) / 2, 0x80 + (2 / 2);
278
279
--echo Testing that / has precedence over binary -
280
select 0x80 / 4 - 2, (0x80 / 4) - 2, 0x80 / (4 - 2);
281
select 0x80 - 4 / 2, (0x80 - 4) / 2, 0x80 - (4 / 2);
282
283
# TODO: %, DIV, MOD
284
285
--echo Testing that ^ is associative
286
select 0xFF ^ 0xF0 ^ 0x0F, (0xFF ^ 0xF0) ^ 0x0F, 0xFF ^ (0xF0 ^ 0x0F);
287
select 0xFF ^ 0xF0 ^ 0x55, (0xFF ^ 0xF0) ^ 0x55, 0xFF ^ (0xF0 ^ 0x55);
288
289
--echo Testing that ^ has precedence over |
290
select 0xFF ^ 0xF0 | 0x0F, (0xFF ^ 0xF0) | 0x0F, 0xFF ^ (0xF0 | 0x0F);
291
select 0xF0 | 0xFF ^ 0xF0, (0xF0 | 0xFF) ^ 0xF0, 0xF0 | (0xFF ^ 0xF0);
292
293
--echo Testing that ^ has precedence over &
294
select 0xFF ^ 0xF0 & 0x0F, (0xFF ^ 0xF0) & 0x0F, 0xFF ^ (0xF0 & 0x0F);
295
select 0x0F & 0xFF ^ 0xF0, (0x0F & 0xFF) ^ 0xF0, 0x0F & (0xFF ^ 0xF0);
296
297
--echo Testing that ^ has precedence over <<
298
select 0xFF ^ 0xF0 << 2, (0xFF ^ 0xF0) << 2, 0xFF ^ (0xF0 << 2);
299
select 0x0F << 2 ^ 0xFF, (0x0F << 2) ^ 0xFF, 0x0F << (2 ^ 0xFF);
300
301
--echo Testing that ^ has precedence over >>
302
select 0xFF ^ 0xF0 >> 2, (0xFF ^ 0xF0) >> 2, 0xFF ^ (0xF0 >> 2);
303
select 0xFF >> 2 ^ 0xF0, (0xFF >> 2) ^ 0xF0, 0xFF >> (2 ^ 0xF0);
304
305
--echo Testing that ^ has precedence over binary +
306
select 0xFF ^ 0xF0 + 0x0F, (0xFF ^ 0xF0) + 0x0F, 0xFF ^ (0xF0 + 0x0F);
307
select 0x0F + 0xFF ^ 0xF0, (0x0F + 0xFF) ^ 0xF0, 0x0F + (0xFF ^ 0xF0);
308
309
--echo Testing that ^ has precedence over binary -
310
select 0xFF ^ 0xF0 - 1, (0xFF ^ 0xF0) - 1, 0xFF ^ (0xF0 - 1);
311
select 0x55 - 0x0F ^ 0x55, (0x55 - 0x0F) ^ 0x55, 0x55 - (0x0F ^ 0x55);
312
313
--echo Testing that ^ has precedence over *
314
select 0xFF ^ 0xF0 * 2, (0xFF ^ 0xF0) * 2, 0xFF ^ (0xF0 * 2);
315
select 2 * 0xFF ^ 0xF0, (2 * 0xFF) ^ 0xF0, 2 * (0xFF ^ 0xF0);
316
317
--echo Testing that ^ has precedence over /
318
select 0xFF ^ 0xF0 / 2, (0xFF ^ 0xF0) / 2, 0xFF ^ (0xF0 / 2);
319
select 0xF2 / 2 ^ 0xF0, (0xF2 / 2) ^ 0xF0, 0xF2 / (2 ^ 0xF0);
320
321
--echo Testing that ^ has precedence over %
322
select 0xFF ^ 0xF0 % 0x20, (0xFF ^ 0xF0) % 0x20, 0xFF ^ (0xF0 % 0x20);
323
select 0xFF % 0x20 ^ 0xF0, (0xFF % 0x20) ^ 0xF0, 0xFF % (0x20 ^ 0xF0);
324
325
--echo Testing that ^ has precedence over DIV
326
select 0xFF ^ 0xF0 DIV 2, (0xFF ^ 0xF0) DIV 2, 0xFF ^ (0xF0 DIV 2);
327
select 0xF2 DIV 2 ^ 0xF0, (0xF2 DIV 2) ^ 0xF0, 0xF2 DIV (2 ^ 0xF0);
328
329
--echo Testing that ^ has precedence over MOD
330
select 0xFF ^ 0xF0 MOD 0x20, (0xFF ^ 0xF0) MOD 0x20, 0xFF ^ (0xF0 MOD 0x20);
331
select 0xFF MOD 0x20 ^ 0xF0, (0xFF MOD 0x20) ^ 0xF0, 0xFF MOD (0x20 ^ 0xF0);
332
333