1
drop table if exists t1,t2;
2
set @my_myisam_key_cache_size =@@global.myisam_key_cache_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_mysql_protocol_buffer_length =@@global.mysql_protocol_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 data_dictionary.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 data_dictionary.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 data_dictionary.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 data_dictionary.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 data_dictionary.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 data_dictionary.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 data_dictionary.session_variables where variable_name like 'timed_mutexes';
155
VARIABLE_NAME VARIABLE_VALUE
157
set storage_engine=MYISAM, storage_engine="MEMORY";
158
show local variables like 'storage_engine';
160
storage_engine MEMORY
161
select * from data_dictionary.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 data_dictionary.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 data_dictionary.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 data_dictionary.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 mysql_protocol_buffer_length=1024;
185
show global variables like 'mysql_protocol_buffer_%';
187
mysql_protocol_buffer_length 1024
188
select * from data_dictionary.global_variables where variable_name like 'mysql_protocol_buffer_%';
189
VARIABLE_NAME VARIABLE_VALUE
190
mysql_protocol_buffer_length 1024
191
show global variables like 'mysql_protocol_buffer_%';
193
mysql_protocol_buffer_length 1024
194
select * from data_dictionary.global_variables where variable_name like 'mysql_protocol_buffer_%';
195
VARIABLE_NAME VARIABLE_VALUE
196
mysql_protocol_buffer_length 1024
197
set global mysql_protocol_buffer_length=1;
199
Error 1292 Truncated incorrect buffer_length value: '1'
200
show variables like 'mysql_protocol_buffer_length';
202
mysql_protocol_buffer_length 1024
203
set global mysql_protocol_buffer_length=2000000000;
205
Error 1292 Truncated incorrect buffer_length value: '2000000000'
206
show variables like 'mysql_protocol_buffer_length';
208
mysql_protocol_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 4096
215
select * from data_dictionary.session_variables where variable_name like '%alloc%';
216
VARIABLE_NAME VARIABLE_VALUE
217
innodb_use_sys_malloc ON
218
query_alloc_block_size 8192
219
query_prealloc_size 8192
220
range_alloc_block_size 4096
221
set @@range_alloc_block_size=1024*16;
222
set @@query_alloc_block_size=1024*17+2;
223
set @@query_prealloc_size=1024*18;
224
select @@query_alloc_block_size;
225
@@query_alloc_block_size
227
show variables like '%alloc%';
229
innodb_use_sys_malloc ON
230
query_alloc_block_size 17408
231
query_prealloc_size 18432
232
range_alloc_block_size 16384
233
select * from data_dictionary.session_variables where variable_name like '%alloc%';
234
VARIABLE_NAME VARIABLE_VALUE
235
innodb_use_sys_malloc ON
236
query_alloc_block_size 17408
237
query_prealloc_size 18432
238
range_alloc_block_size 16384
239
set @@range_alloc_block_size=default;
240
set @@query_alloc_block_size=default, @@query_prealloc_size=default;
241
show variables like '%alloc%';
243
innodb_use_sys_malloc ON
244
query_alloc_block_size 8192
245
query_prealloc_size 8192
246
range_alloc_block_size 4096
247
select * from data_dictionary.session_variables where variable_name like '%alloc%';
248
VARIABLE_NAME VARIABLE_VALUE
249
innodb_use_sys_malloc ON
250
query_alloc_block_size 8192
251
query_prealloc_size 8192
252
range_alloc_block_size 4096
253
SELECT @@version LIKE 'non-existent';
254
@@version LIKE 'non-existent'
256
SELECT @@version_compile_os LIKE 'non-existent';
257
@@version_compile_os LIKE 'non-existent'
259
set unknown_variable=1;
260
ERROR HY000: Unknown system variable 'unknown_variable'
261
set max_join_size="hello";
262
ERROR 42000: Incorrect argument type to variable 'max_join_size'
263
set storage_engine=UNKNOWN_TABLE_TYPE;
264
ERROR 42000: Unknown table engine 'UNKNOWN_TABLE_TYPE'
265
set GLOBAL storage_engine=DEFAULT;
266
ERROR 42000: Variable 'storage_engine' doesn't have a default value
267
set global autocommit=1;
268
ERROR HY000: Variable 'autocommit' is a SESSION variable and can't be used with SET GLOBAL
269
select @@global.timestamp;
270
ERROR HY000: Variable 'timestamp' is a SESSION variable
272
ERROR HY000: Variable 'version' is a read only variable
273
set myisam_max_sort_file_size=100;
274
ERROR HY000: Variable 'myisam_max_sort_file_size' is a GLOBAL variable and should be set with SET GLOBAL
275
set @@SQL_WARNINGS=NULL;
276
ERROR 42000: Variable 'sql_warnings' can't be set to the value of 'NULL'
281
set bulk_insert_buffer_size=100;
282
set join_buffer_size=100;
284
Error 1292 Truncated incorrect join_buffer_size value: '100'
285
set last_insert_id=1;
286
set max_allowed_packet=100;
288
Error 1292 Truncated incorrect max_allowed_packet value: '100'
289
set global max_connect_errors=100;
290
set max_heap_table_size=100;
292
Error 1292 Truncated incorrect max_heap_table_size value: '100'
293
set max_join_size=100;
294
set max_sort_length=100;
295
set global max_write_lock_count=100;
296
set global myisam_sort_buffer_size=100;
298
Error 1292 Truncated incorrect sort_buffer_size value: '100'
299
set global mysql_protocol_buffer_length=100;
301
Error 1292 Truncated incorrect buffer_length value: '100'
302
set read_buffer_size=100;
304
Error 1292 Truncated incorrect read_buffer_size value: '100'
305
set read_rnd_buffer_size=100;
306
set global server_id=100;
307
set sort_buffer_size=100;
309
Error 1292 Truncated incorrect sort_buffer_size value: '100'
310
set sql_big_selects=1;
311
set sql_buffer_result=1;
312
set sql_select_limit=1;
313
set sql_select_limit=default;
315
set global table_open_cache=100;
316
set storage_engine=myisam;
317
set timestamp=1, timestamp=default;
318
set tmp_table_size=100;
320
Error 1292 Truncated incorrect tmp_table_size value: '100'
321
set tx_isolation="READ-COMMITTED";
322
create temporary table t1 (a int not null auto_increment, primary key(a));
323
create temporary table t2 (a int not null auto_increment, primary key(a));
324
insert into t1 values(null),(null),(null);
325
insert into t2 values(null),(null),(null);
326
set global myisam_key_cache_size=100000;
328
Error 1292 Truncated incorrect key_cache_size value: '100000'
329
select @@myisam_key_cache_size;
330
@@myisam_key_cache_size
332
select * from t1 where a=2;
335
select * from t2 where a=3;
339
Table Op Msg_type Msg_text
340
test.t1 check status OK
341
test.t2 check status OK
342
select max(a) +1, max(a) +2 into @xx,@yy from t1;
345
ERROR HY000: Unknown system variable 'xxxxxxxxxx'
349
select @@session.myisam_key_cache_size;
350
ERROR HY000: Variable 'myisam_key_cache_size' is a GLOBAL variable
351
set global myisam_max_sort_file_size=4294967296;
352
show global variables like 'myisam_max_sort_file_size';
354
myisam_max_sort_file_size MAX_FILE_SIZE
355
select * from data_dictionary.global_variables where variable_name like 'myisam_max_sort_file_size';
356
VARIABLE_NAME VARIABLE_VALUE
357
myisam_max_sort_file_size MAX_FILE_SIZE
358
set global myisam_max_sort_file_size=default;
359
set @@global.global.myisam_key_cache_size= 1;
360
ERROR HY000: Unknown system variable 'global'
361
set GLOBAL global.myisam_key_cache_size= 1;
362
ERROR HY000: Unknown system variable 'global'
363
SELECT @@global.global.myisam_key_cache_size;
364
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 'myisam_key_cache_size' at line 1
365
SELECT @@global.session.myisam_key_cache_size;
366
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 'myisam_key_cache_size' at line 1
367
SELECT @@global.local.myisam_key_cache_size;
368
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 'myisam_key_cache_size' at line 1
369
create temporary table t1 (
375
show create table t1;
377
t1 CREATE TEMPORARY TABLE `t1` (
378
`c1` int DEFAULT NULL,
379
`c2` int DEFAULT NULL,
380
`c3` int DEFAULT NULL,
381
`c4` int DEFAULT NULL,
382
`c5` bigint DEFAULT NULL
385
set @arg00= 8, @arg01= 8.8, @arg02= 'a string', @arg03= 0.2e0;
386
create temporary table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3, @arg03 as c4;
387
show create table t1;
389
t1 CREATE TEMPORARY TABLE `t1` (
390
`c1` bigint DEFAULT NULL,
391
`c2` decimal(65,30) DEFAULT NULL,
393
`c4` double DEFAULT NULL
396
SET GLOBAL table_open_cache=-1;
398
Error 1292 Truncated incorrect table_open_cache value: '18446744073709551615'
399
SHOW VARIABLES LIKE 'table_open_cache';
402
SELECT * FROM DATA_DICTIONARY.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache';
403
VARIABLE_NAME VARIABLE_VALUE
405
SET GLOBAL table_open_cache=DEFAULT;
406
*** Various tests with LC_TIME_NAMES
407
*** LC_TIME_NAMES: testing case insensitivity
408
set @@lc_time_names='ru_ru';
409
select @@lc_time_names;
412
*** LC_TIME_NAMES: testing with a user variable
414
set @@lc_time_names=@lc;
415
select @@lc_time_names;
418
*** LC_TIME_NAMES: testing with string expressions
419
set lc_time_names=concat('de','_','DE');
420
select @@lc_time_names;
423
set lc_time_names=concat('de','+','DE');
424
ERROR HY000: Unknown locale: 'de+DE'
425
select @@lc_time_names;
428
LC_TIME_NAMES: testing with numeric expressions
429
set @@lc_time_names=1+2;
430
select @@lc_time_names;
433
set @@lc_time_names=1/0;
434
ERROR 42000: Incorrect argument type to variable 'lc_time_names'
435
select @@lc_time_names;
438
set lc_time_names=en_US;
439
LC_TIME_NAMES: testing NULL and a negative number:
440
set lc_time_names=NULL;
441
ERROR 42000: Variable 'lc_time_names' can't be set to the value of 'NULL'
442
set lc_time_names=-1;
443
ERROR HY000: Unknown locale: '-1'
444
select @@lc_time_names;
447
LC_TIME_NAMES: testing locale with the last ID:
448
set lc_time_names=108;
449
select @@lc_time_names;
452
LC_TIME_NAMES: testing a number beyond the valid ID range:
453
set lc_time_names=109;
454
ERROR HY000: Unknown locale: '109'
455
select @@lc_time_names;
458
LC_TIME_NAMES: testing that 0 is en_US:
460
select @@lc_time_names;
463
select @@global.lc_time_names, @@lc_time_names;
464
@@global.lc_time_names @@lc_time_names
466
set @@global.lc_time_names=fr_FR;
467
select @@global.lc_time_names, @@lc_time_names;
468
@@global.lc_time_names @@lc_time_names
471
select @@global.lc_time_names, @@lc_time_names;
472
@@global.lc_time_names @@lc_time_names
474
set @@lc_time_names=ru_RU;
475
select @@global.lc_time_names, @@lc_time_names;
476
@@global.lc_time_names @@lc_time_names
478
Returnung to default connection
479
select @@global.lc_time_names, @@lc_time_names;
480
@@global.lc_time_names @@lc_time_names
482
set lc_time_names=default;
483
select @@global.lc_time_names, @@lc_time_names;
484
@@global.lc_time_names @@lc_time_names
486
set @@global.lc_time_names=default;
487
select @@global.lc_time_names, @@lc_time_names;
488
@@global.lc_time_names @@lc_time_names
490
set @@lc_time_names=default;
491
select @@global.lc_time_names, @@lc_time_names;
492
@@global.lc_time_names @@lc_time_names
494
set @test = @@query_prealloc_size;
495
set @@query_prealloc_size = @test;
496
select @@query_prealloc_size = @test;
497
@@query_prealloc_size = @test
500
create temporary table t1 (a int);
501
select a into @x from t1;
503
Warning 1329 No data - zero rows fetched, selected, or processed
506
Warning 1329 No data - zero rows fetched, selected, or processed
508
set @@warning_count=1;
509
ERROR HY000: Variable 'warning_count' is a read only variable
510
set @@global.error_count=1;
511
ERROR HY000: Variable 'error_count' is a read only variable
512
select @@character_set_system;
513
ERROR HY000: Unknown system variable 'character_set_system'
514
set global character_set_system = utf8;
515
ERROR HY000: Unknown system variable 'character_set_system'
516
set @@global.version_compile_os='234';
517
ERROR HY000: Variable 'version_compile_os' is a read only variable
518
set @@global.character_set_filesystem=utf8;
519
ERROR HY000: Unknown system variable 'character_set_filesystem'
520
set character_set_filesystem=utf8;
521
ERROR HY000: Unknown system variable 'character_set_filesystem'
522
set @sql_big_selects = @@sql_big_selects;
523
set @@sql_big_selects = 1;
524
show variables like 'sql_big_selects';
527
set @@sql_big_selects = @sql_big_selects;
528
set @@sql_notes = 0, @@sql_warnings = 0;
529
show variables like 'sql_notes';
532
show variables like 'sql_warnings';
535
set @@sql_notes = 1, @@sql_warnings = 1;
536
show variables like 'sql_notes';
539
show variables like 'sql_warnings';
542
select @@version, @@version_comment, @@version_compile_machine,
543
@@version_compile_os;
544
@@version @@version_comment @@version_compile_machine @@version_compile_os
546
select @@basedir, @@datadir, @@tmpdir;
547
@@basedir @@datadir @@tmpdir
549
show variables like 'basedir';
552
show variables like 'datadir';
555
show variables like 'tmpdir';
559
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
561
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
563
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
567
set @@hostname= "anothername";
568
ERROR HY000: Variable 'hostname' is a read only variable
569
show variables like 'hostname';
573
set global flush_time =@my_flush_time;
574
ERROR HY000: Unknown system variable 'flush_time'
575
set global myisam_key_cache_size =@my_myisam_key_cache_size;
576
set global max_connect_errors =@my_max_connect_errors;
577
set global max_heap_table_size =@my_max_heap_table_size;
578
set global max_join_size =@my_max_join_size;
579
set global max_write_lock_count =default;
580
set global myisam_data_pointer_size =@my_myisam_data_pointer_size;
581
ERROR 42000: Incorrect argument type to variable 'myisam_data_pointer_size'
582
set global mysql_protocol_buffer_length= @my_mysql_protocol_buffer_length;
583
set global server_id =@my_server_id;
584
set global storage_engine =@my_storage_engine;
585
set global thread_cache_size =@my_thread_cache_size;
586
ERROR HY000: Unknown system variable 'thread_cache_size'
587
set global myisam_sort_buffer_size =@my_myisam_sort_buffer_size;
588
show global variables where variable_name='table_definition_cache' or Variable_name='table_lock_wait_timeout';
590
table_definition_cache #
591
table_lock_wait_timeout #