Debian Codegraph @

mysql-test/suite/sys_vars/t/sql_big_selects_func.test

raw
1 ############# mysql-test\t\sql_big_selects_func.test ######################
2 # #
3 # Variable Name: sql_big_selects #
4 # Scope: SESSION #
5 # Access Type: Dynamic #
6 # Data Type: BOOLEAN #
7 # Default Value: 1 TRUE #
8 # Values: 1 TRUE, 0 FALSE #
9 # #
10 # #
11 # Creation Date: 2008-02-25 #
12 # Author: Sharique Abdullah #
13 # #
14 # Description: Test Cases of Dynamic System Variable "sql_big_selects" #
15 # that checks behavior of this variable in the following ways#
16 # * Functionality based on different values #
17 # #
18 # Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html #
19 # #
20 ###########################################################################
21 --source include/force_myisam_default.inc
22
23 # Skip the test if MyISAM is not available
24 --source include/have_myisam.inc
25
26 --echo ** Setup **
27 --echo
28 #
29 # Setup
30 #
31
32 SET @session_sql_big_selects = @@SESSION.sql_big_selects;
33 SET @session_max_join_size = @@SESSION.max_join_size;
34 SET @global_max_join_size = @@GLOBAL.max_join_size;
35 # The hash join below will read t1 and t2 once, so set it just small
36 # enough to let the query hit the limit.
37 SET MAX_JOIN_SIZE=9;
38
39 #
40 # Create tables
41 #
42
43 CREATE TEMPORARY TABLE t1(a varchar(20) not null, b varchar(20));
44 CREATE TEMPORARY TABLE t2(a varchar(20) null, b varchar(20));
45
46 INSERT INTO t1 VALUES('aa','bb');
47 INSERT INTO t1 VALUES('aa1','bb');
48 INSERT INTO t1 VALUES('aa2','bb');
49 INSERT INTO t1 VALUES('aa3','bb');
50 INSERT INTO t1 VALUES('aa4','bb');
51
52 INSERT INTO t2 VALUES('aa','bb');
53 INSERT INTO t2 VALUES('aa1','bb');
54 INSERT INTO t2 VALUES('aa2','bb');
55 INSERT INTO t2 VALUES('aa3','bb');
56 INSERT INTO t2 VALUES('aa4','bb');
57
58 ANALYZE TABLE t1, t2;
59
60 --echo '#--------------------FN_DYNVARS_154_01-------------------------#'
61 #
62 # Testing fail condition
63 #
64
65 --echo Expected error "Too big select"
66 --error ER_TOO_BIG_SELECT
67 SELECT * FROM t1 INNER JOIN t2 ON t1.a = t2.a;
68 --echo Expected error The SELECT would examine more than MAX_JOIN_SIZE rows.
69
70 --echo '#--------------------FN_DYNVARS_154_02-------------------------#'
71 #
72 # Testing pass conditions
73 #
74
75 SET SESSION SQL_BIG_SELECTS = 1;
76
77 SELECT * FROM t1 INNER JOIN t2 ON t1.a = t2.a;
78 --echo This should work
79
80 SET SESSION SQL_BIG_SELECTS = 0;
81
82 # Delete one row to make the join small enough to pass.
83 DELETE FROM t2 WHERE a = 'aa4';
84 ANALYZE TABLE t1, t2;
85 SELECT * FROM t1 INNER JOIN t2 ON t1.a = t2.a;
86 --echo This should work
87
88 --echo '#--------------------FN_DYNVARS_154_03-------------------------#'
89 #
90 # Session data integrity check
91 #
92
93 --echo ** Connecting con_int1 using root **
94 connect (con_int1,localhost,root,,);
95
96 --echo ** Connection con_int1 **
97 connection con_int1;
98
99 SELECT @@SESSION.sql_big_selects;
100 --echo 1 Expected
101 SET SESSION sql_big_selects = 0;
102
103 --echo ** Connecting con_int2 using root **
104 connect (con_int2,localhost,root,,);
105
106 --echo ** Connection con_int2 **
107 connection con_int2;
108
109 SELECT @@SESSION.sql_big_selects;
110 --echo 1 Expected
111
112 SET SESSION sql_big_selects = 1;
113
114 --echo ** Connection con_int1 **
115 connection con_int1;
116
117 SELECT @@SESSION.sql_big_selects;
118 --echo 0 Expected
119
120 --echo ** Connection con_int2 **
121 connection con_int2;
122
123 SELECT @@SESSION.sql_big_selects;
124 --echo 1 Expected
125
126 --echo ** Connection default **
127 connection default;
128
129 --echo Disconnecting Connections con_int1, con_int2
130 disconnect con_int1;
131 disconnect con_int2;
132
133 #
134 # Cleanup
135 #
136
137
138 SET @@SESSION.sql_big_selects = @session_sql_big_selects;
139 SET @@SESSION.max_join_size = @session_max_join_size;
140 SET @@GLOBAL.max_join_size = @global_max_join_size;
141
142 DROP TABLE t1;
143 DROP TABLE t2;