5
drop table if exists t1,t2;
9
# Bug #19263: variables.test doesn't clean up after itself (I/II -- save)
11
set @my_max_heap_table_size =@@global.max_heap_table_size;
12
set @my_max_join_size =@@global.max_join_size;
13
set @my_mysql_protocol_buffer_length =@@global.mysql_protocol_buffer_length;
14
set @my_server_id =@@global.server_id;
15
set @my_storage_engine =@@global.storage_engine;
16
set @my_myisam_sort_buffer_size =@@global.myisam_sort_buffer_size;
17
set @my_tx_isolation =@@global.tx_isolation;
19
# case insensitivity tests (new in 5.0)
21
select @test, @`test`, @TEST, @`TEST`, @"teSt";
23
select @test, @`test`, @TEST, @`TEST`, @"teSt";
25
select @test, @`test`, @TEST, @`TEST`, @"teSt";
27
select @test, @`test`, @TEST, @`TEST`, @"teSt";
29
select @test, @`test`, @TEST, @`TEST`, @"teSt";
31
set @select=2,@t5=1.23456;
32
select @`select`,@not_used;
33
set @test_int=10,@test_double=1e-10,@test_string="abcdeghi",@test_string2="abcdefghij",@select=NULL;
34
# Expected result "1e-10", windows returns "1e-010"
35
--replace_result 1e-010 1e-10
36
select @test_int,@test_double,@test_string,@test_string2,@select;
37
set @test_int="hello",@test_double="hello",@test_string="hello",@test_string2="hello";
38
select @test_int,@test_double,@test_string,@test_string2;
39
set @test_int="hellohello",@test_double="hellohello",@test_string="hellohello",@test_string2="hellohello";
40
select @test_int,@test_double,@test_string,@test_string2;
41
set @test_int=null,@test_double=null,@test_string=null,@test_string2=null;
42
select @test_int,@test_double,@test_string,@test_string2;
43
select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
44
explain extended select @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
48
# Test problem with WHERE and variables
51
CREATE TABLE t1 (c_id INT NOT NULL, c_name VARCHAR(250), c_country VARCHAR(250), PRIMARY KEY(c_id));
52
INSERT INTO t1 VALUES (1,'Bozo','USA'),(2,'Ronald','USA'),(3,'Kinko','IRE'),(4,'Mr. Floppy','GB');
53
SELECT @min_cid:=min(c_id), @max_cid:=max(c_id) from t1;
54
SELECT * FROM t1 WHERE c_id=@min_cid OR c_id=@max_cid;
55
SELECT * FROM t1 WHERE c_id=@min_cid OR c_id=@max_cid OR c_id=666;
56
ALTER TABLE t1 DROP PRIMARY KEY;
57
select * from t1 where c_id=@min_cid OR c_id=@max_cid;
61
# Test system variables
63
set GLOBAL max_join_size=10;
64
set max_join_size=100;
65
show variables like 'max_join_size';
66
select * from data_dictionary.session_variables where variable_name like 'max_join_size';
67
--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR
68
show global variables like 'max_join_size';
69
--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR
70
select * from data_dictionary.global_variables where variable_name like 'max_join_size';
71
set GLOBAL max_join_size=2000;
72
show global variables like 'max_join_size';
73
select * from data_dictionary.global_variables where variable_name like 'max_join_size';
74
set max_join_size=DEFAULT;
75
--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR
76
show variables like 'max_join_size';
77
--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR
78
select * from data_dictionary.session_variables where variable_name like 'max_join_size';
79
set GLOBAL max_join_size=DEFAULT;
80
--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR
81
show global variables like 'max_join_size';
82
--replace_result 18446744073709551615 HA_POS_ERROR 4294967295 HA_POS_ERROR
83
select * from data_dictionary.global_variables where variable_name like 'max_join_size';
84
set @@max_join_size=1000, @@global.max_join_size=2000;
85
select @@local.max_join_size, @@global.max_join_size;
86
select @@identity, length(@@version)>0;
87
select @@VERSION=version();
88
select last_insert_id(345);
89
explain extended select last_insert_id(345);
90
select @@IDENTITY,last_insert_id(), @@identity;
91
explain extended select @@IDENTITY,last_insert_id(), @@identity;
93
set global timed_mutexes=ON;
94
show variables like 'timed_mutexes';
95
select * from data_dictionary.session_variables where variable_name like 'timed_mutexes';
96
set global timed_mutexes=0;
97
show variables like 'timed_mutexes';
98
select * from data_dictionary.session_variables where variable_name like 'timed_mutexes';
100
set storage_engine=MYISAM, storage_engine="MEMORY";
101
show local variables like 'storage_engine';
102
select * from data_dictionary.session_variables where variable_name like 'storage_engine';
103
show global variables like 'storage_engine';
104
select * from data_dictionary.global_variables where variable_name like 'storage_engine';
106
set GLOBAL myisam_max_sort_file_size=2000000;
107
show global variables like 'myisam_max_sort_file_size';
108
select * from data_dictionary.global_variables where variable_name like 'myisam_max_sort_file_size';
109
set GLOBAL myisam_max_sort_file_size=default;
110
--replace_result 9223372036853727232 FILE_SIZE 2146435072 FILE_SIZE
111
show global variables like 'myisam_max_sort_file_size';
112
--replace_result 9223372036853727232 FILE_SIZE 2146435072 FILE_SIZE
113
select * from data_dictionary.global_variables where variable_name like 'myisam_max_sort_file_size';
115
set global mysql_protocol_buffer_length=1024;
116
show global variables like 'mysql_protocol_buffer_%';
117
select * from data_dictionary.global_variables where variable_name like 'mysql_protocol_buffer_%';
118
show global variables like 'mysql_protocol_buffer_%';
119
select * from data_dictionary.global_variables where variable_name like 'mysql_protocol_buffer_%';
120
set global mysql_protocol_buffer_length=1;
121
show variables like 'mysql_protocol_buffer_length';
123
set global mysql_protocol_buffer_length=2000000000;
124
show variables like 'mysql_protocol_buffer_length';
126
show variables like '%alloc%';
127
select * from data_dictionary.session_variables where variable_name like '%alloc%';
128
set @@range_alloc_block_size=1024*16;
129
set @@query_alloc_block_size=1024*17+2;
130
set @@query_prealloc_size=1024*18;
131
select @@query_alloc_block_size;
132
show variables like '%alloc%';
133
select * from data_dictionary.session_variables where variable_name like '%alloc%';
134
set @@range_alloc_block_size=default;
135
set @@query_alloc_block_size=default, @@query_prealloc_size=default;
136
show variables like '%alloc%';
137
select * from data_dictionary.session_variables where variable_name like '%alloc%';
140
# Bug #10904 Illegal mix of collations between
141
# a system variable and a constant
143
SELECT @@version LIKE 'non-existent';
144
SELECT @@version_compile_os LIKE 'non-existent';
146
# The following should give errors
148
--error ER_UNKNOWN_SYSTEM_VARIABLE
149
set unknown_variable=1;
150
--error ER_WRONG_TYPE_FOR_VAR
151
set max_join_size="hello";
152
--error ER_UNKNOWN_STORAGE_ENGINE
153
set storage_engine=UNKNOWN_TABLE_TYPE;
154
--error ER_NO_DEFAULT
155
set GLOBAL storage_engine=DEFAULT;
156
--error ER_LOCAL_VARIABLE
157
set global autocommit=1;
158
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
159
select @@global.timestamp;
160
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
162
--error ER_GLOBAL_VARIABLE
163
set myisam_max_sort_file_size=100;
164
--error ER_WRONG_VALUE_FOR_VAR
165
set @@SQL_WARNINGS=NULL;
167
# Test setting all variables
171
set bulk_insert_buffer_size=100;
172
set join_buffer_size=100;
173
set last_insert_id=1;
174
set max_allowed_packet=100;
175
set max_heap_table_size=100;
176
set max_join_size=100;
177
set max_sort_length=100;
178
set global max_write_lock_count=100;
179
set global myisam_sort_buffer_size=100;
180
set global mysql_protocol_buffer_length=100;
181
set read_buffer_size=100;
182
set read_rnd_buffer_size=100;
183
set global server_id=100;
184
set sort_buffer_size=100;
185
set sql_big_selects=1;
186
set sql_buffer_result=1;
187
set sql_select_limit=1;
188
# reset it, so later tests don't get confused
189
set sql_select_limit=default;
191
set global table_open_cache=100;
192
set storage_engine=myisam;
193
set timestamp=1, timestamp=default;
194
set tmp_table_size=100;
195
set tx_isolation="READ-COMMITTED";
197
# Bug#3754 SET GLOBAL myisam_max_sort_file_size doesn't work as
198
# expected: check that there is no overflow when 64-bit
201
set global myisam_max_sort_file_size=4294967296;
202
--replace_result 4294967296 MAX_FILE_SIZE 2146435072 MAX_FILE_SIZE
203
show global variables like 'myisam_max_sort_file_size';
204
--replace_result 4294967296 MAX_FILE_SIZE 2146435072 MAX_FILE_SIZE
205
select * from data_dictionary.global_variables where variable_name like 'myisam_max_sort_file_size';
206
set global myisam_max_sort_file_size=default;
211
#select @@global.myisam_max_sort_file_size,@@local.max_join_size;
212
#set @svc=@@global.myisam_max_sort_file_size, @svj=@@local.max_join_size;
213
#select @@global.myisam_max_sort_file_size,@@local.max_join_size;
214
#set @@global.myisam_max_sort_file_size=111,@@local.max_join_size=222;
215
#select @@global.myisam_max_sort_file_size,@@local.max_join_size;
216
#set @@global.myisam_max_sort_file_size=@@local.max_join_size,@@local.max_join_size=@@global.myisam_max_sort_file_size;
217
#select @@global.myisam_max_sort_file_size,@@local.max_join_size;
218
#set @@global.myisam_max_sort_file_size=@svc, @@local.max_join_size=@svj;
219
#select @@global.myisam_max_sort_file_size,@@local.max_join_size;
225
# BUG#4788 show create table provides incorrect statement
227
# What default width have numeric types?
228
create temporary table t1 (
234
show create table t1;
237
# What types and widths have variables?
238
set @arg00= 8, @arg01= 8.8, @arg02= 'a string', @arg03= 0.2e0;
239
create temporary table t1 as select @arg00 as c1, @arg01 as c2, @arg02 as c3, @arg03 as c4;
240
show create table t1;
244
# Bug #6958: negative arguments to integer options wrap around
247
SET GLOBAL table_open_cache=-1;
248
SHOW VARIABLES LIKE 'table_open_cache';
249
SELECT * FROM DATA_DICTIONARY.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache';
250
SET GLOBAL table_open_cache=DEFAULT;
253
# Tests for lc_time_names
254
# Note, when adding new locales, please fix ID accordingly:
255
# - to test the last ID (currently 108)
256
# - and the next after the last (currently 109)
258
--echo *** Various tests with LC_TIME_NAMES
259
--echo *** LC_TIME_NAMES: testing case insensitivity
260
set @@lc_time_names='ru_ru';
261
select @@lc_time_names;
262
--echo *** LC_TIME_NAMES: testing with a user variable
264
set @@lc_time_names=@lc;
265
select @@lc_time_names;
266
--echo *** LC_TIME_NAMES: testing with string expressions
267
set lc_time_names=concat('de','_','DE');
268
select @@lc_time_names;
269
--error ER_UNKNOWN_ERROR
270
set lc_time_names=concat('de','+','DE');
271
select @@lc_time_names;
272
--echo LC_TIME_NAMES: testing with numeric expressions
273
set @@lc_time_names=1+2;
274
select @@lc_time_names;
275
--error ER_WRONG_TYPE_FOR_VAR
276
set @@lc_time_names=1/0;
277
select @@lc_time_names;
278
set lc_time_names=en_US;
279
--echo LC_TIME_NAMES: testing NULL and a negative number:
280
--error ER_WRONG_VALUE_FOR_VAR
281
set lc_time_names=NULL;
282
--error ER_UNKNOWN_ERROR
283
set lc_time_names=-1;
284
select @@lc_time_names;
285
--echo LC_TIME_NAMES: testing locale with the last ID:
286
set lc_time_names=108;
287
select @@lc_time_names;
288
--echo LC_TIME_NAMES: testing a number beyond the valid ID range:
289
--error ER_UNKNOWN_ERROR
290
set lc_time_names=109;
291
select @@lc_time_names;
292
--echo LC_TIME_NAMES: testing that 0 is en_US:
294
select @@lc_time_names;
297
# Bug #22648 LC_TIME_NAMES: Setting GLOBAL has no effect
299
select @@global.lc_time_names, @@lc_time_names;
300
set @@global.lc_time_names=fr_FR;
301
select @@global.lc_time_names, @@lc_time_names;
302
--echo New connection
303
connect (con1,localhost,root,,);
305
select @@global.lc_time_names, @@lc_time_names;
306
set @@lc_time_names=ru_RU;
307
select @@global.lc_time_names, @@lc_time_names;
310
--echo Returnung to default connection
311
select @@global.lc_time_names, @@lc_time_names;
312
set lc_time_names=default;
313
select @@global.lc_time_names, @@lc_time_names;
314
set @@global.lc_time_names=default;
315
select @@global.lc_time_names, @@lc_time_names;
316
set @@lc_time_names=default;
317
select @@global.lc_time_names, @@lc_time_names;
321
# Bug #13334: query_prealloc_size default less than minimum
323
set @test = @@query_prealloc_size;
324
set @@query_prealloc_size = @test;
325
select @@query_prealloc_size = @test;
327
--echo End of 4.1 tests
330
# Bug#6282 Packet error with SELECT INTO
333
create temporary table t1 (a int);
334
select a into @x from t1;
339
# Bug #10339: read only variables.
342
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
343
set @@warning_count=1;
344
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
345
set @@global.error_count=1;
348
# Bug #10351: Setting ulong variable to > MAX_ULONG fails on 32-bit platform
351
select VARIABLE_VALUE from data_dictionary.GLOBAL_VARIABLES where VARIABLE_NAME like "VERSION_COMPILE_MACHINE" into @arch;
353
# We technically do not care about 32bit hardware. -Brian
354
#set @@max_heap_table_size= 4294967296;
355
#select @@max_heap_table_size > 0;
356
#set global max_heap_table_size= 4294967296;
357
#select @@max_heap_table_size > 0;
358
#set @@max_heap_table_size= 4294967296;
359
#select @@max_heap_table_size > 0;
362
# Bug #11775 Variable character_set_system does not exist (sometimes)
364
--error ER_UNKNOWN_SYSTEM_VARIABLE
365
select @@character_set_system;
366
--error ER_UNKNOWN_SYSTEM_VARIABLE
367
set global character_set_system = utf8;
368
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
369
set @@global.version_compile_os='234';
372
# Check character_set_filesystem variable invalid for Drizzle
374
--error ER_UNKNOWN_SYSTEM_VARIABLE
375
set @@global.character_set_filesystem=utf8;
376
--error ER_UNKNOWN_SYSTEM_VARIABLE
377
set character_set_filesystem=utf8;
380
# Bug #17849: Show sql_big_selects in SHOW VARIABLES
382
set @sql_big_selects = @@sql_big_selects;
383
set @@sql_big_selects = 1;
384
show variables like 'sql_big_selects';
385
# Bug 311025 Segmentation fault when accessing DATA_DICTIONARY
386
#select * from data_dictionary.session_variables where variable_name like 'sql_big_selects';
387
set @@sql_big_selects = @sql_big_selects;
390
# Bug #16195: SHOW VARIABLES doesn't report correctly sql_warnings and
393
set @@sql_notes = 0, @@sql_warnings = 0;
394
show variables like 'sql_notes';
395
# Bug 311025 Segmentation fault when accessing DATA_DICTIONARY
396
#select * from data_dictionary.session_variables where variable_name like 'sql_notes';
397
show variables like 'sql_warnings';
398
# Bug 311025 Segmentation fault when accessing DATA_DICTIONARY
399
#select * from data_dictionary.session_variables where variable_name like 'sql_warnings';
400
set @@sql_notes = 1, @@sql_warnings = 1;
401
show variables like 'sql_notes';
402
# Bug 311025 Segmentation fault when accessing DATA_DICTIONARY
403
#select * from data_dictionary.session_variables where variable_name like 'sql_notes';
404
show variables like 'sql_warnings';
405
# Bug 311025 Segmentation fault when accessing DATA_DICTIONARY
406
#select * from data_dictionary.session_variables where variable_name like 'sql_warnings';
409
# Bug #15684: system variables cannot be SELECTed (e.g. @@version_comment)
411
# Don't actually output, since it depends on the system
412
--replace_column 1 # 2 # 3 # 4 #
413
select @@version, @@version_comment, @@version_compile_machine,
414
@@version_compile_os;
417
# Bug #1039: make tmpdir and datadir available as @@variables (also included
420
# Don't actually output, since it depends on the system
421
--replace_column 1 # 2 # 3 #
422
select @@basedir, @@datadir, @@tmpdir;
424
show variables like 'basedir';
426
# Bug 311025 Segmentation fault when accessing DATA_DICTIONARY
427
#select * from data_dictionary.session_variables where variable_name like 'basedir';
429
show variables like 'datadir';
431
# Bug 311025 Segmentation fault when accessing DATA_DICTIONARY
432
#select * from data_dictionary.session_variables where variable_name like 'datadir';
434
show variables like 'tmpdir';
438
# Bug#20908: Crash if select @@""
440
--error ER_PARSE_ERROR
442
--error ER_PARSE_ERROR
444
--error ER_PARSE_ERROR
448
# Bug#20166 mysql-test-run.pl does not test system privilege tables creation
450
# Don't actually output, since it depends on the system
453
--error ER_INCORRECT_GLOBAL_LOCAL_VAR
454
set @@hostname= "anothername";
456
show variables like 'hostname';
458
--echo End of 5.0 tests
460
# This is at the very after the versioned tests, since it involves doing
463
# Bug #19263: variables.test doesn't clean up after itself (II/II --
466
--error ER_UNKNOWN_SYSTEM_VARIABLE
467
set global flush_time =@my_flush_time;
468
set global max_heap_table_size =@my_max_heap_table_size;
469
set global max_join_size =@my_max_join_size;
471
set global max_write_lock_count =default;
472
set global mysql_protocol_buffer_length= @my_mysql_protocol_buffer_length;
473
set global server_id =@my_server_id;
474
set global storage_engine =@my_storage_engine;
475
--error ER_UNKNOWN_SYSTEM_VARIABLE
476
set global thread_cache_size =@my_thread_cache_size;
477
set global myisam_sort_buffer_size =@my_myisam_sort_buffer_size;
479
SHOW GLOBAL VARIABLES LIKE 'max_join_size';
480
SHOW LOCAL VARIABLES LIKE 'max_join_size';
482
set GLOBAL bulk_insert_buffer_size=DEFAULT;
483
set GLOBAL join_buffer_size=DEFAULT;
484
set GLOBAL max_allowed_packet=DEFAULT;
485
set GLOBAL max_heap_table_size=DEFAULT;
486
set GLOBAL max_join_size=DEFAULT;
487
set GLOBAL max_sort_length=DEFAULT;
488
set GLOBAL max_write_lock_count=DEFAULT;
489
set GLOBAL myisam_sort_buffer_size=DEFAULT;
490
set GLOBAL mysql_protocol_buffer_length=DEFAULT;
491
set GLOBAL read_buffer_size=DEFAULT;
492
set GLOBAL read_rnd_buffer_size=DEFAULT;
493
set GLOBAL server_id=DEFAULT;
494
set GLOBAL sort_buffer_size=DEFAULT;
495
set GLOBAL table_open_cache=DEFAULT;
496
set GLOBAL storage_engine= @my_storage_engine;
497
set GLOBAL tmp_table_size=DEFAULT;
498
set GLOBAL tx_isolation= @my_tx_isolation;
500
set SESSION bulk_insert_buffer_size=DEFAULT;
501
set SESSION join_buffer_size=DEFAULT;
502
set SESSION max_allowed_packet=DEFAULT;
503
set SESSION max_heap_table_size=DEFAULT;
504
set SESSION max_join_size=DEFAULT;
505
set SESSION max_sort_length=DEFAULT;
506
set SESSION read_buffer_size=DEFAULT;
507
set SESSION read_rnd_buffer_size=DEFAULT;
508
set SESSION sort_buffer_size=DEFAULT;
509
set SESSION sql_big_selects=DEFAULT;
510
set SESSION sql_buffer_result=DEFAULT;
511
set SESSION sql_select_limit=DEFAULT;
512
set SESSION sql_warnings=DEFAULT;
513
set SESSION storage_engine= @my_storage_engine;
514
set SESSION tmp_table_size=DEFAULT;
515
set SESSION tx_isolation= @my_tx_isolation;
518
# Bug#28580 Repeatation of status variables
522
show global variables where variable_name='table_definition_cache' or Variable_name='table_lock_wait_timeout';