~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysql-test/t/parser_precedence.test

Merged from trunk.

Show diffs side-by-side

added added

removed removed

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