From 511a166d559c37ca7a1f03234db2cbf11bf04a10 Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Sat, 5 Feb 2005 06:23:23 +0300 Subject: [PATCH 1/2] Fix for BUG#7519: Index statistics is not displayed after ANALYZE for temporary tables: Call file->extra() with HA_STATUS_CONST in mysqld_show_keys. The fix will not be merged into 4.1/5.0 because they don't have this problem already. --- mysql-test/r/show_check.result | 22 ++++++++++++++++++++++ mysql-test/t/show_check.test | 16 ++++++++++++++++ sql/sql_show.cc | 3 ++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result index f40b0693585..6d23dde1f1b 100644 --- a/mysql-test/r/show_check.result +++ b/mysql-test/r/show_check.result @@ -233,3 +233,25 @@ c decimal(4,3) YES NULL d double(4,3) YES NULL f float(4,3) YES NULL drop table t1; +CREATE TABLE t1 ( a VARCHAR(20) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +CREATE TEMPORARY TABLE t2 ( index (a(20)) ) SELECT a FROM t1 GROUP BY a; +SHOW INDEX FROM t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 X a X X X NULL X X X BTREE +ANALYZE TABLE t2; +Table Op Msg_type Msg_text +test.t2 analyze status OK +SHOW INDEX FROM t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 X a X X X 5 X X X BTREE +SHOW CREATE TABLE t2; +Table Create Table +t2 CREATE TEMPORARY TABLE `t2` ( + `a` varchar(20) default NULL, + KEY `a` (`a`) +) TYPE=MyISAM +SHOW INDEX FROM t2; +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment +t2 X a X X X 5 X X X BTREE +DROP TEMPORARY TABLE t2; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 2cd2012d109..e712ed77f04 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -131,3 +131,19 @@ drop table t1; create table t1 (c decimal(3,3), d double(3,3), f float(3,3)); show columns from t1; drop table t1; + +# Fix for BUG#7519: For temporary tables, SHOW INDEX doesn't display index +# cardinality after ANALYZE. +CREATE TABLE t1 ( a VARCHAR(20) ); +INSERT INTO t1 VALUES ('one'),('two'),('three'),('four'),('five'); +CREATE TEMPORARY TABLE t2 ( index (a(20)) ) SELECT a FROM t1 GROUP BY a; +--replace_column 2 X 4 X 5 X 6 X 8 X 9 X 10 X +SHOW INDEX FROM t2; +ANALYZE TABLE t2; +--replace_column 2 X 4 X 5 X 6 X 8 X 9 X 10 X +SHOW INDEX FROM t2; +SHOW CREATE TABLE t2; +--replace_column 2 X 4 X 5 X 6 X 8 X 9 X 10 X +SHOW INDEX FROM t2; +DROP TEMPORARY TABLE t2; + diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2506033cda5..27246729162 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -686,7 +686,8 @@ mysqld_show_keys(THD *thd, TABLE_LIST *table_list) String *packet= &thd->packet; KEY *key_info=table->key_info; - table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME); + table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK | HA_STATUS_TIME | + HA_STATUS_CONST); for (uint i=0 ; i < table->keys ; i++,key_info++) { KEY_PART_INFO *key_part= key_info->key_part; From a6ad8a4d0f6d405919c1968450ff64b1dbded38d Mon Sep 17 00:00:00 2001 From: "sergefp@mysql.com" <> Date: Mon, 28 Feb 2005 20:21:21 +0300 Subject: [PATCH 2/2] Fix for BUG#8726: In JOIN::optimize on ER_TOO_BIG_SELECT error set JOIN::error to -1 to cause the error to be sent to the client. --- mysql-test/r/select_safe.result | 15 +++++++++++++++ mysql-test/t/select_safe.test | 20 ++++++++++++++++++++ sql/sql_select.cc | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/select_safe.result b/mysql-test/r/select_safe.result index 766ee8c0e14..7a29db42dd9 100644 --- a/mysql-test/r/select_safe.result +++ b/mysql-test/r/select_safe.result @@ -78,4 +78,19 @@ id select_type table type possible_keys key key_len ref rows Extra 1 SIMPLE t2 ref b b 21 test.t1.b 6 Using where SET MAX_SEEKS_FOR_KEY=DEFAULT; drop table t1; +create table t1 (a int); +insert into t1 values (1),(2),(3),(4),(5); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; +set local max_join_size=8; +select * from (select * from t1) x; +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +set local max_join_size=1; +select * from (select * from t1 a, t1 b) x; +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +set local max_join_size=1; +select * from (select 1 union select 2 union select 3) x; +ERROR 42000: The SELECT would examine more than MAX_JOIN_SIZE rows; check your WHERE and use SET SQL_BIG_SELECTS=1 or SET SQL_MAX_JOIN_SIZE=# if the SELECT is okay +drop table t1; SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT; diff --git a/mysql-test/t/select_safe.test b/mysql-test/t/select_safe.test index 3cafd31a879..5b2dfb00bb7 100644 --- a/mysql-test/t/select_safe.test +++ b/mysql-test/t/select_safe.test @@ -66,4 +66,24 @@ SET MAX_SEEKS_FOR_KEY=DEFAULT; drop table t1; +# BUG#8726 +create table t1 (a int); +insert into t1 values (1),(2),(3),(4),(5); +insert into t1 select * from t1; +insert into t1 select * from t1; +insert into t1 select * from t1; + +set local max_join_size=8; +--error 1104 +select * from (select * from t1) x; + +set local max_join_size=1; +--error 1104 +select * from (select * from t1 a, t1 b) x; + +set local max_join_size=1; +--error 1104 +select * from (select 1 union select 2 union select 3) x; +drop table t1; + SET SQL_SAFE_UPDATES=0,SQL_SELECT_LIMIT=DEFAULT, SQL_MAX_JOIN_SIZE=DEFAULT; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index a210fbbbe02..d207d50e306 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -579,7 +579,7 @@ JOIN::optimize() !(select_options & SELECT_DESCRIBE)) { /* purecov: inspected */ my_message(ER_TOO_BIG_SELECT, ER(ER_TOO_BIG_SELECT), MYF(0)); - error= 1; /* purecov: inspected */ + error= -1; DBUG_RETURN(1); } if (const_tables && !thd->locked_tables &&