diff options
author | Monty <monty@mariadb.org> | 2021-10-06 12:34:54 +0300 |
---|---|---|
committer | Sergei Petrunia <sergey@mariadb.com> | 2023-01-30 15:24:15 +0200 |
commit | 7d0bef6cd7be6a2764be05071b4ea78729698f6b (patch) | |
tree | f406e8ee1ac8c50a5750734d4b440ecfea48fc4d | |
parent | fc0c157aaa0b1603a321890c6c43b4b6b5e3b2e3 (diff) | |
download | mariadb-git-bb-11.0-jan23-rebase-try2.tar.gz |
Fixed bug in SQL_SELECT_LIMITbb-11.0-jan23-rebase-try2
We where comparing costs when we should be comparing number of rows
that will be examined
-rw-r--r-- | mysql-test/suite/sys_vars/r/max_join_size_func.result | 6 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/r/sql_big_selects_func.result | 2 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/max_join_size_func.test | 4 | ||||
-rw-r--r-- | mysql-test/suite/sys_vars/t/sql_big_selects_func.test | 4 | ||||
-rw-r--r-- | sql/sql_select.cc | 2 |
5 files changed, 8 insertions, 10 deletions
diff --git a/mysql-test/suite/sys_vars/r/max_join_size_func.result b/mysql-test/suite/sys_vars/r/max_join_size_func.result index cacc918ea02..d46b89d1f44 100644 --- a/mysql-test/suite/sys_vars/r/max_join_size_func.result +++ b/mysql-test/suite/sys_vars/r/max_join_size_func.result @@ -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 diff --git a/mysql-test/suite/sys_vars/r/sql_big_selects_func.result b/mysql-test/suite/sys_vars/r/sql_big_selects_func.result index 609401c771c..104103f681e 100644 --- a/mysql-test/suite/sys_vars/r/sql_big_selects_func.result +++ b/mysql-test/suite/sys_vars/r/sql_big_selects_func.result @@ -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'); diff --git a/mysql-test/suite/sys_vars/t/max_join_size_func.test b/mysql-test/suite/sys_vars/t/max_join_size_func.test index c649c036565..5fc8ee5855b 100644 --- a/mysql-test/suite/sys_vars/t/max_join_size_func.test +++ b/mysql-test/suite/sys_vars/t/max_join_size_func.test @@ -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; diff --git a/mysql-test/suite/sys_vars/t/sql_big_selects_func.test b/mysql-test/suite/sys_vars/t/sql_big_selects_func.test index 59d8184861d..b8ff7c53f75 100644 --- a/mysql-test/suite/sys_vars/t/sql_big_selects_func.test +++ b/mysql-test/suite/sys_vars/t/sql_big_selects_func.test @@ -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; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 88a3c1e12de..13131ecf7f6 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -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)); |