Commit 7d0bef6c authored by Monty's avatar Monty Committed by Sergei Petrunia

Fixed bug in SQL_SELECT_LIMIT

We where comparing costs when we should be comparing number of rows
that will be examined
parent fc0c157a
......@@ -39,19 +39,19 @@ id name id name
connect test_con1, localhost, root,,;
connection test_con1;
## Setting value of max_join_size ##
SET @@session.max_join_size=8;
SET @@session.max_join_size=4;
## Since total joins are more than max_join_size value so error will occur ##
SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay
'#--------------------FN_DYNVARS_079_03-------------------------#'
## Setting global value of variable ##
SET @@global.max_join_size=8;
SET @@global.max_join_size=4;
connect test_con2, localhost, root,,;
connection test_con2;
## Verifying value of max_join_size ##
SELECT @@global.max_join_size;
@@global.max_join_size
8
4
## Since total joins are more than max_join_size value so error will occur ##
SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;
ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET MAX_JOIN_SIZE=# if the SELECT is okay
......
......@@ -3,7 +3,7 @@
SET @session_sql_big_selects = @@SESSION.sql_big_selects;
SET @session_max_join_size = @@SESSION.max_join_size;
SET @global_max_join_size = @@GLOBAL.max_join_size;
SET MAX_JOIN_SIZE=9;
SET MAX_JOIN_SIZE=21;
CREATE TEMPORARY TABLE t1(a varchar(20) not null, b varchar(20));
CREATE TEMPORARY TABLE t2(a varchar(20) null, b varchar(20));
INSERT INTO t1 VALUES('aa','bb');
......
......@@ -84,7 +84,7 @@ connect (test_con1, localhost, root,,);
connection test_con1;
--echo ## Setting value of max_join_size ##
SET @@session.max_join_size=8;
SET @@session.max_join_size=4;
--echo ## Since total joins are more than max_join_size value so error will occur ##
--Error ER_TOO_BIG_SELECT
......@@ -97,7 +97,7 @@ SELECT * FROM t1 INNER JOIN t2 ON t1.id = t2.id;
##########################################################
--echo ## Setting global value of variable ##
SET @@global.max_join_size=8;
SET @@global.max_join_size=4;
connect (test_con2, localhost, root,,);
connection test_con2;
......
......@@ -28,7 +28,7 @@
SET @session_sql_big_selects = @@SESSION.sql_big_selects;
SET @session_max_join_size = @@SESSION.max_join_size;
SET @global_max_join_size = @@GLOBAL.max_join_size;
SET MAX_JOIN_SIZE=9;
SET MAX_JOIN_SIZE=21;
#
# Create tables
......@@ -115,8 +115,6 @@ disconnect con_int2;
#
# Cleanup
#
SET @@SESSION.sql_big_selects = @session_sql_big_selects;
SET @@SESSION.max_join_size = @session_max_join_size;
SET @@GLOBAL.max_join_size = @global_max_join_size;
......
......@@ -2621,7 +2621,7 @@ int JOIN::optimize_stage2()
goto setup_subq_exit;
}
if (!(thd->variables.option_bits & OPTION_BIG_SELECTS) &&
best_read > (double) thd->variables.max_join_size &&
join_record_count > (double) thd->variables.max_join_size &&
!(select_options & SELECT_DESCRIBE))
{ /* purecov: inspected */
my_message(ER_TOO_BIG_SELECT, ER_THD(thd, ER_TOO_BIG_SELECT), MYF(0));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment