1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
|
################# mysql-test\t\max_join_size_func.test ########################
# #
# Variable Name: max_join_size #
# Scope: GLOBAL | SESSION #
# Access Type: Dynamic #
# Data Type: numeric #
# Default Value: 4294967295 #
# Range: 1-4294967295 #
# #
# #
# Creation Date: 2008-03-07 #
# Author: Salman Rawala #
# #
# Description: Test Cases of Dynamic System Variable max_join_size #
# that checks the functionality of this variable #
# #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
# server-system-variables.html #
# #
###############################################################################
--disable_warnings
drop table if exists t1;
--enable_warnings
##############################
# Creating two new tables #
##############################
--echo ## Creating new table t1 ##
CREATE TABLE t1
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name VARCHAR(30)
);
--echo ## Creating another table t2 ##
CREATE TABLE t2
(
id INT NOT NULL auto_increment,
PRIMARY KEY (id),
name VARCHAR(30)
);
#########################################
# Inserting some data in both tables #
#########################################
--echo ## Inserting records in both the tables ##
INSERT INTO t1(name) VALUES('Record_1');
INSERT INTO t1(name) VALUES('Record_2');
INSERT INTO t1(name) VALUES('Record_3');
INSERT INTO t1(name) VALUES('Record_4');
INSERT INTO t1(name) VALUES('Record_5');
INSERT INTO t2(name) VALUES('Record_1_1');
INSERT INTO t2(name) VALUES('Record_2_1');
INSERT INTO t2(name) VALUES('Record_3_1');
INSERT INTO t2(name) VALUES('Record_4_1');
INSERT INTO t2(name) VALUES('Record_5_1');
--echo '#--------------------FN_DYNVARS_079_01-------------------------#'
#######################################################################
# Verifying case where max_join_size is greater than the join size #
#######################################################################
--echo ## Setting max_join size value to 10 ##
SET @@session.max_join_size=10;
--echo ## This should work ##
SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;
--echo '#--------------------FN_DYNVARS_079_02-------------------------#'
####################################################################
# Verifying case where max_join_size is less than the join size #
####################################################################
--echo ## Creating new connection test_con1 ##
connect (test_con1, localhost, root,,);
connection test_con1;
--echo ## Setting value of max_join_size ##
SET @@session.max_join_size=8;
--echo ## Since total joins are more than max_join_size value so error will occur ##
--Error ER_TOO_BIG_SELECT
SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;
--echo '#--------------------FN_DYNVARS_079_03-------------------------#'
##########################################################
# Verifying behavior of max_join_size on global scope #
##########################################################
--echo ## Setting global value of variable ##
SET @@global.max_join_size=8;
--echo ## Creating and switching to new connection test_con2 ##
connect (test_con2, localhost, root,,);
connection test_con2;
--echo ## Verifying value of max_join_size ##
SELECT @@global.max_join_size;
--echo ## Since total joins are more than max_join_size value so error will occur ##
--Error ER_TOO_BIG_SELECT
SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;
--echo ## Dropping both the tables ##
Drop table t1, t2;
--echo ## Restoring values ##
SET @@global.max_join_size = DEFAULT;
SET @@session.max_join_size = DEFAULT;
--echo ## Dropping connections ##
disconnect test_con1;
disconnect test_con2;
|