1
drop table if exists t1,t2;
2
set @my_key_buffer_size =@@global.key_buffer_size;
3
set @my_max_connect_errors =@@global.max_connect_errors;
4
set @my_max_heap_table_size =@@global.max_heap_table_size;
5
set @my_max_join_size =@@global.max_join_size;
6
set @my_oldlibdrizzle_buffer_length =@@global.oldlibdrizzle_buffer_length;
7
set @my_server_id =@@global.server_id;
8
set @my_storage_engine =@@global.storage_engine;
9
set @my_myisam_sort_buffer_size =@@global.myisam_sort_buffer_size;
11
select @test, @`test`, @TEST, @`TEST`, @"teSt";
12
@test @`test` @TEST @`TEST` @"teSt"
15
select @test, @`test`, @TEST, @`TEST`, @"teSt";
16
@test @`test` @TEST @`TEST` @"teSt"
19
select @test, @`test`, @TEST, @`TEST`, @"teSt";
20
@test @`test` @TEST @`TEST` @"teSt"
23
select @test, @`test`, @TEST, @`TEST`, @"teSt";
24
@test @`test` @TEST @`TEST` @"teSt"
29
select @test, @`test`, @TEST, @`TEST`, @"teSt";
30
@test @`test` @TEST @`TEST` @"teSt"
32
set @select=2,@t5=1.23456;
33
select @`select`,@not_used;
36
set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
37
select @test_int,@test_double,@test_string,@test_string2,@select;
38
@test_int @test_double @test_string @test_string2 @select
39
10 0.0000000001 abcdeghi abcdefghij NULL
40
set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello";
41
select @test_int,@test_double,@test_string,@test_string2;
42
@test_int @test_double @test_string @test_string2
43
hello hello hello hello
44
set @test_int="hellohello",@test_double="hellohello",@test_string="hellohello",@test_string2="hellohello";
45
select @test_int,@test_double,@test_string,@test_string2;
46
@test_int @test_double @test_string @test_string2
47
hellohello hellohello hellohello hellohello
48
set @test_int=null,@test_double=null,@test_string=null,@test_string2=null;
49
select @test_int,@test_double,@test_string,@test_string2;
50
@test_int @test_double @test_string @test_string2
52
select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
53
@t1:=(@t2:=1)+@t3:=4 @t1 @t2 @t3
55
explain extended select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
56
id select_type table type possible_keys key key_len ref rows filtered Extra
57
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
59
Note 1003 select (@t1:=((@t2:=1) + (@t3:=4))) AS `@t1:=(@t2:=1)+@t3:=4`,(@t1) AS `@t1`,(@t2) AS `@t2`,(@t3) AS `@t3`
63
CREATE TABLE t1 (c_id INT NOT NULL, c_name VARCHAR(250), c_country VARCHAR(250), PRIMARY KEY(c_id));
64
INSERT INTO t1 VALUES (1,'Bozo','USA'),(2,'Ronald','USA'),(3,'Kinko','IRE'),(4,'Mr. Floppy','GB');
65
SELECT @min_cid:=min(c_id), @max_cid:=max(c_id) from t1;
66
@min_cid:=min(c_id) @max_cid:=max(c_id)
68
SELECT * FROM t1 WHERE c_id=@min_cid OR c_id=@max_cid;
72
SELECT * FROM t1 WHERE c_id=@min_cid OR c_id=@max_cid OR c_id=666;
76
ALTER TABLE t1 DROP PRIMARY KEY;
77
select * from t1 where c_id=@min_cid OR c_id=@max_cid;
82
set GLOBAL max_join_size=10;
83
set max_join_size=100;
84
show variables like 'max_join_size';
87
select * from information_schema.session_variables where variable_name like 'max_join_size';
88
VARIABLE_NAME VARIABLE_VALUE
90
show global variables like 'max_join_size';
93
select * from information_schema.global_variables where variable_name like 'max_join_size';
94
VARIABLE_NAME VARIABLE_VALUE
96
set GLOBAL max_join_size=2000;
97
show global variables like 'max_join_size';
100
select * from information_schema.global_variables where variable_name like 'max_join_size';
101
VARIABLE_NAME VARIABLE_VALUE
103
set max_join_size=DEFAULT;
104
show variables like 'max_join_size';
107
select * from information_schema.session_variables where variable_name like 'max_join_size';
108
VARIABLE_NAME VARIABLE_VALUE
110
set GLOBAL max_join_size=DEFAULT;
111
show global variables like 'max_join_size';
113
max_join_size 2147483647
114
select * from information_schema.global_variables where variable_name like 'max_join_size';
115
VARIABLE_NAME VARIABLE_VALUE
116
MAX_JOIN_SIZE 2147483647
117
set @@max_join_size=1000, @@global.max_join_size=2000;
118
select @@local.max_join_size, @@global.max_join_size;
119
@@local.max_join_size @@global.max_join_size
121
select @@identity, length(@@version)>0;
122
@@identity length(@@version)>0
124
select @@VERSION=version();
127
select last_insert_id(345);
130
explain extended select last_insert_id(345);
131
id select_type table type possible_keys key key_len ref rows filtered Extra
132
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
134
Note 1003 select last_insert_id(345) AS `last_insert_id(345)`
135
select @@IDENTITY,last_insert_id(), @@identity;
136
@@IDENTITY last_insert_id() @@identity
138
explain extended select @@IDENTITY,last_insert_id(), @@identity;
139
id select_type table type possible_keys key key_len ref rows filtered Extra
140
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL NULL No tables used
142
Note 1003 select 345 AS `@@IDENTITY`,last_insert_id() AS `last_insert_id()`,345 AS `@@identity`
143
set global timed_mutexes=ON;
144
show variables like 'timed_mutexes';
147
select * from information_schema.session_variables where variable_name like 'timed_mutexes';
148
VARIABLE_NAME VARIABLE_VALUE
150
set global timed_mutexes=0;
151
show variables like 'timed_mutexes';
154
select * from information_schema.session_variables where variable_name like 'timed_mutexes';
155
VARIABLE_NAME VARIABLE_VALUE
157
set storage_engine=MYISAM, storage_engine="HEAP";
158
show local variables like 'storage_engine';
160
storage_engine MEMORY
161
select * from information_schema.session_variables where variable_name like 'storage_engine';
162
VARIABLE_NAME VARIABLE_VALUE
163
STORAGE_ENGINE MEMORY
164
show global variables like 'storage_engine';
167
select * from information_schema.global_variables where variable_name like 'storage_engine';
168
VARIABLE_NAME VARIABLE_VALUE
170
set GLOBAL myisam_max_sort_file_size=2000000;
171
show global variables like 'myisam_max_sort_file_size';
173
myisam_max_sort_file_size 2000000
174
select * from information_schema.global_variables where variable_name like 'myisam_max_sort_file_size';
175
VARIABLE_NAME VARIABLE_VALUE
176
MYISAM_MAX_SORT_FILE_SIZE 2000000
177
set GLOBAL myisam_max_sort_file_size=default;
178
show global variables like 'myisam_max_sort_file_size';
180
myisam_max_sort_file_size 2147483647
181
select * from information_schema.global_variables where variable_name like 'myisam_max_sort_file_size';
182
VARIABLE_NAME VARIABLE_VALUE
183
MYISAM_MAX_SORT_FILE_SIZE 2147483647
184
set global oldlibdrizzle_buffer_length=1024;
185
show global variables like 'oldlibdrizzle_buffer_%';
187
oldlibdrizzle_buffer_length 1024
188
select * from information_schema.global_variables where variable_name like 'oldlibdrizzle_buffer_%' order by 1;
189
VARIABLE_NAME VARIABLE_VALUE
190
OLDLIBDRIZZLE_BUFFER_LENGTH 1024
191
show global variables like 'oldlibdrizzle_buffer_%';
193
oldlibdrizzle_buffer_length 1024
194
select * from information_schema.global_variables where variable_name like 'oldlibdrizzle_buffer_%' order by 1;
195
VARIABLE_NAME VARIABLE_VALUE
196
OLDLIBDRIZZLE_BUFFER_LENGTH 1024
197
set global oldlibdrizzle_buffer_length=1;
199
Error 1292 Truncated incorrect buffer_length value: '1'
200
show variables like 'oldlibdrizzle_buffer_length';
202
oldlibdrizzle_buffer_length 1024
203
set global oldlibdrizzle_buffer_length=2000000000;
205
Error 1292 Truncated incorrect buffer_length value: '2000000000'
206
show variables like 'oldlibdrizzle_buffer_length';
208
oldlibdrizzle_buffer_length 1048576
209
show variables like '%alloc%';
211
innodb_use_sys_malloc ON
212
query_alloc_block_size 8192
213
query_prealloc_size 8192
214
range_alloc_block_size
215
transaction_alloc_block_size 8192
216
transaction_prealloc_size 4096
217
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
218
VARIABLE_NAME VARIABLE_VALUE
219
INNODB_USE_SYS_MALLOC ON
220
QUERY_ALLOC_BLOCK_SIZE 8192
221
QUERY_PREALLOC_SIZE 8192
222
RANGE_ALLOC_BLOCK_SIZE
223
TRANSACTION_ALLOC_BLOCK_SIZE 8192
224
TRANSACTION_PREALLOC_SIZE 4096
225
set @@range_alloc_block_size=1024*16;
226
set @@query_alloc_block_size=1024*17+2;
227
set @@query_prealloc_size=1024*18;
228
set @@transaction_alloc_block_size=1024*20-1;
229
set @@transaction_prealloc_size=1024*21-1;
230
select @@query_alloc_block_size;
231
@@query_alloc_block_size
233
show variables like '%alloc%';
235
innodb_use_sys_malloc ON
236
query_alloc_block_size 17408
237
query_prealloc_size 18432
238
range_alloc_block_size
239
transaction_alloc_block_size 19456
240
transaction_prealloc_size 20480
241
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
242
VARIABLE_NAME VARIABLE_VALUE
243
INNODB_USE_SYS_MALLOC ON
244
QUERY_ALLOC_BLOCK_SIZE 17408
245
QUERY_PREALLOC_SIZE 18432
246
RANGE_ALLOC_BLOCK_SIZE
247
TRANSACTION_ALLOC_BLOCK_SIZE 19456
248
TRANSACTION_PREALLOC_SIZE 20480
249
set @@range_alloc_block_size=default;
250
set @@query_alloc_block_size=default, @@query_prealloc_size=default;
251
set transaction_alloc_block_size=default, @@transaction_prealloc_size=default;
252
show variables like '%alloc%';
254
innodb_use_sys_malloc ON
255
query_alloc_block_size 8192
256
query_prealloc_size 8192
257
range_alloc_block_size
258
transaction_alloc_block_size 8192
259
transaction_prealloc_size 4096
260
select * from information_schema.session_variables where variable_name like '%alloc%' order by 1;
261
VARIABLE_NAME VARIABLE_VALUE
262
INNODB_USE_SYS_MALLOC ON
263
QUERY_ALLOC_BLOCK_SIZE 8192
264
QUERY_PREALLOC_SIZE 8192
265
RANGE_ALLOC_BLOCK_SIZE
266
TRANSACTION_ALLOC_BLOCK_SIZE 8192
267
TRANSACTION_PREALLOC_SIZE 4096
268
SELECT @@version LIKE 'non-existent';
269
@@version LIKE 'non-existent'
271
SELECT @@version_compile_os LIKE 'non-existent';
272
@@version_compile_os LIKE 'non-existent'
274
set unknown_variable=1;
275
ERROR HY000: Unknown system variable 'unknown_variable'
276
set max_join_size="hello";
277
ERROR 42000: Incorrect argument type to variable 'max_join_size'
278
set storage_engine=UNKNOWN_TABLE_TYPE;
279
ERROR 42000: Unknown table engine 'UNKNOWN_TABLE_TYPE'
280
set GLOBAL storage_engine=DEFAULT;
281
ERROR 42000: Variable 'storage_engine' doesn't have a default value
282
set global autocommit=1;
283
ERROR HY000: Variable 'autocommit' is a SESSION variable and can't be used with SET GLOBAL
284
select @@global.timestamp;
285
ERROR HY000: Variable 'timestamp' is a SESSION variable
287
ERROR HY000: Variable 'version' is a read only variable
288
set myisam_max_sort_file_size=100;
289
ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
290
set @@SQL_WARNINGS=NULL;
291
ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'NULL'
296
set bulk_insert_buffer_size=100;
297
set join_buffer_size=100;
299
Error 1292 Truncated incorrect join_buffer_size value: '100'
300
set last_insert_id=1;
301
set max_allowed_packet=100;
303
Error 1292 Truncated incorrect max_allowed_packet value: '100'
304
set global max_connect_errors=100;
305
set max_heap_table_size=100;
307
Error 1292 Truncated incorrect max_heap_table_size value: '100'
308
set max_join_size=100;
309
set max_sort_length=100;
310
set global max_write_lock_count=100;
311
set global myisam_sort_buffer_size=100;
313
Error 1292 Truncated incorrect sort_buffer_size value: '100'
314
set global oldlibdrizzle_buffer_length=100;
316
Error 1292 Truncated incorrect buffer_length value: '100'
317
set read_buffer_size=100;
319
Error 1292 Truncated incorrect read_buffer_size value: '100'
320
set read_rnd_buffer_size=100;
321
set global server_id=100;
322
set sort_buffer_size=100;
324
Error 1292 Truncated incorrect sort_buffer_size value: '100'
325
set sql_big_selects=1;
326
set sql_buffer_result=1;
327
set sql_safe_updates=1;
328
set sql_select_limit=1;
329
set sql_select_limit=default;
331
set global table_open_cache=100;
332
set storage_engine=myisam;
333
set timestamp=1, timestamp=default;
334
set tmp_table_size=100;
336
Error 1292 Truncated incorrect tmp_table_size value: '100'
337
set tx_isolation="READ-COMMITTED";
338
create temporary table t1 (a int not null auto_increment, primary key(a));
339
create temporary table t2 (a int not null auto_increment, primary key(a));
340
insert into t1 values(null),(null),(null);
341
insert into t2 values(null),(null),(null);
342
set global key_buffer_size=100000;
343
select @@key_buffer_size;
346
select * from t1 where a=2;
349
select * from t2 where a=3;
353
Table Op Msg_type Msg_text
354
test.t1 check status OK
355
test.t2 check status OK
356
select max(a) +1, max(a) +2 into @xx,@yy from t1;
359
ERROR HY000: Unknown system variable 'xxxxxxxxxx'
363
select @@session.key_buffer_size;
364
ERROR HY000: Variable 'key_buffer_size' is a GLOBAL variable
365
set global myisam_max_sort_file_size=4294967296;
366
show global variables like 'myisam_max_sort_file_size';
368
myisam_max_sort_file_size MAX_FILE_SIZE
369
select * from information_schema.global_variables where variable_name like 'myisam_max_sort_file_size';
370
VARIABLE_NAME VARIABLE_VALUE
371
MYISAM_MAX_SORT_FILE_SIZE MAX_FILE_SIZE
372
set global myisam_max_sort_file_size=default;
373
set @@global.global.key_buffer_size= 1;
374
ERROR HY000: Unknown system variable 'global'
375
set GLOBAL global.key_buffer_size= 1;
376
ERROR HY000: Unknown system variable 'global'
377
SELECT @@global.global.key_buffer_size;
378
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'key_buffer_size' at line 1
379
SELECT @@global.session.key_buffer_size;
380
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'key_buffer_size' at line 1
381
SELECT @@global.local.key_buffer_size;
382
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near 'key_buffer_size' at line 1
383
create temporary table t1 (
389
show create table t1;
391
t1 CREATE TEMPORARY TABLE `t1` (
392
`c1` int DEFAULT NULL,
393
`c2` int DEFAULT NULL,
394
`c3` int DEFAULT NULL,
395
`c4` int DEFAULT NULL,
396
`c5` bigint DEFAULT NULL
399
set @arg00= 8, @arg01= 8.8, @arg02= 'a string', @arg03= 0.2e0;
400
create temporary table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3, @arg03 as c4;
401
show create table t1;
403
t1 CREATE TEMPORARY TABLE `t1` (
404
`c1` bigint DEFAULT NULL,
405
`c2` decimal(65,30) DEFAULT NULL,
407
`c4` double DEFAULT NULL
410
SET GLOBAL table_open_cache=-1;
412
Error 1292 Truncated incorrect table_open_cache value: '18446744073709551615'
413
SHOW VARIABLES LIKE 'table_open_cache';
416
SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache';
417
VARIABLE_NAME VARIABLE_VALUE
419
SET GLOBAL table_open_cache=DEFAULT;
420
*** Various tests with LC_TIME_NAMES
421
*** LC_TIME_NAMES: testing case insensitivity
422
set @@lc_time_names='ru_ru';
423
select @@lc_time_names;
426
*** LC_TIME_NAMES: testing with a user variable
428
set @@lc_time_names=@lc;
429
select @@lc_time_names;
432
*** LC_TIME_NAMES: testing with string expressions
433
set lc_time_names=concat('de','_','DE');
434
select @@lc_time_names;
437
set lc_time_names=concat('de','+','DE');
438
ERROR HY000: Unknown locale: 'de+DE'
439
select @@lc_time_names;
442
LC_TIME_NAMES: testing with numeric expressions
443
set @@lc_time_names=1+2;
444
select @@lc_time_names;
447
set @@lc_time_names=1/0;
448
ERROR 42000: Incorrect argument type to variable 'lc_time_names'
449
select @@lc_time_names;
452
set lc_time_names=en_US;
453
LC_TIME_NAMES: testing NULL and a negative number:
454
set lc_time_names=NULL;
455
ERROR 42000: Variable 'lc_time_names' can't be set to the value of 'NULL'
456
set lc_time_names=-1;
457
ERROR HY000: Unknown locale: '-1'
458
select @@lc_time_names;
461
LC_TIME_NAMES: testing locale with the last ID:
462
set lc_time_names=108;
463
select @@lc_time_names;
466
LC_TIME_NAMES: testing a number beyond the valid ID range:
467
set lc_time_names=109;
468
ERROR HY000: Unknown locale: '109'
469
select @@lc_time_names;
472
LC_TIME_NAMES: testing that 0 is en_US:
474
select @@lc_time_names;
477
select @@global.lc_time_names, @@lc_time_names;
478
@@global.lc_time_names @@lc_time_names
480
set @@global.lc_time_names=fr_FR;
481
select @@global.lc_time_names, @@lc_time_names;
482
@@global.lc_time_names @@lc_time_names
485
select @@global.lc_time_names, @@lc_time_names;
486
@@global.lc_time_names @@lc_time_names
488
set @@lc_time_names=ru_RU;
489
select @@global.lc_time_names, @@lc_time_names;
490
@@global.lc_time_names @@lc_time_names
492
Returnung to default connection
493
select @@global.lc_time_names, @@lc_time_names;
494
@@global.lc_time_names @@lc_time_names
496
set lc_time_names=default;
497
select @@global.lc_time_names, @@lc_time_names;
498
@@global.lc_time_names @@lc_time_names
500
set @@global.lc_time_names=default;
501
select @@global.lc_time_names, @@lc_time_names;
502
@@global.lc_time_names @@lc_time_names
504
set @@lc_time_names=default;
505
select @@global.lc_time_names, @@lc_time_names;
506
@@global.lc_time_names @@lc_time_names
508
set @test = @@query_prealloc_size;
509
set @@query_prealloc_size = @test;
510
select @@query_prealloc_size = @test;
511
@@query_prealloc_size = @test
514
create temporary table t1 (a int);
515
select a into @x from t1;
517
Warning 1329 No data - zero rows fetched, selected, or processed
520
Warning 1329 No data - zero rows fetched, selected, or processed
522
set @@warning_count=1;
523
ERROR HY000: Variable 'warning_count' is a read only variable
524
set @@global.error_count=1;
525
ERROR HY000: Variable 'error_count' is a read only variable
526
select @@character_set_system;
527
ERROR HY000: Unknown system variable 'character_set_system'
528
set global character_set_system = utf8;
529
ERROR HY000: Unknown system variable 'character_set_system'
530
set @@global.version_compile_os='234';
531
ERROR HY000: Variable 'version_compile_os' is a read only variable
532
set @@global.character_set_filesystem=utf8;
533
ERROR HY000: Unknown system variable 'character_set_filesystem'
534
set character_set_filesystem=utf8;
535
ERROR HY000: Unknown system variable 'character_set_filesystem'
536
set @old_sql_big_selects = @@sql_big_selects;
537
set @@sql_big_selects = 1;
538
show variables like 'sql_big_selects';
541
set @@sql_big_selects = @old_sql_big_selects;
542
set @@sql_notes = 0, @@sql_warnings = 0;
543
show variables like 'sql_notes';
546
show variables like 'sql_warnings';
549
set @@sql_notes = 1, @@sql_warnings = 1;
550
show variables like 'sql_notes';
553
show variables like 'sql_warnings';
556
select @@version, @@version_comment, @@version_compile_machine,
557
@@version_compile_os;
558
@@version @@version_comment @@version_compile_machine @@version_compile_os
560
select @@basedir, @@datadir, @@tmpdir;
561
@@basedir @@datadir @@tmpdir
563
show variables like 'basedir';
566
show variables like 'datadir';
569
show variables like 'tmpdir';
573
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '""' at line 1
575
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '&' at line 1
577
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your Drizzle server version for the right syntax to use near '@' at line 1
581
set @@hostname= "anothername";
582
ERROR HY000: Variable 'hostname' is a read only variable
583
show variables like 'hostname';
587
set global flush_time =@my_flush_time;
588
ERROR HY000: Unknown system variable 'flush_time'
589
set global key_buffer_size =@my_key_buffer_size;
590
set global max_connect_errors =@my_max_connect_errors;
591
set global max_heap_table_size =@my_max_heap_table_size;
592
set global max_join_size =@my_max_join_size;
593
set global max_write_lock_count =default;
594
set global myisam_data_pointer_size =@my_myisam_data_pointer_size;
595
ERROR 42000: Incorrect argument type to variable 'myisam_data_pointer_size'
596
set global oldlibdrizzle_buffer_length= @my_oldlibdrizzle_buffer_length;
597
set global server_id =@my_server_id;
598
set global storage_engine =@my_storage_engine;
599
set global thread_cache_size =@my_thread_cache_size;
600
ERROR HY000: Unknown system variable 'thread_cache_size'
601
set global myisam_sort_buffer_size =@my_myisam_sort_buffer_size;
602
show global variables where variable_name='table_definition_cache' or Variable_name='table_lock_wait_timeout';
604
table_definition_cache #
605
table_lock_wait_timeout #