[Commits] fc80bc5e623: MDEV-19407: Assertion `field->table->stats_is_read' failed in is_eits_usable

Varun varunraiko1803 at gmail.com
Tue May 14 23:18:15 EEST 2019


revision-id: fc80bc5e623790f3b26b5dee54d4b47d3ee7753d (mariadb-10.1.38-185-gfc80bc5e623)
parent(s): 2647fd101db922b1e6c7363124adfc03e81ab8a0
author: Varun Gupta
committer: Varun Gupta
timestamp: 2019-05-15 01:44:16 +0530
message:

MDEV-19407: Assertion `field->table->stats_is_read' failed in is_eits_usable

Statistics were not read for a table when we had a CREATE TABLE query.
Enforce reading statistics for commands CREATE TABLE, SET and DO.

---
 mysql-test/r/stat_tables.result        | 19 +++++++++++++++++++
 mysql-test/r/stat_tables_innodb.result | 19 +++++++++++++++++++
 mysql-test/t/stat_tables.test          | 20 ++++++++++++++++++++
 sql/sql_statistics.cc                  |  3 +++
 4 files changed, 61 insertions(+)

diff --git a/mysql-test/r/stat_tables.result b/mysql-test/r/stat_tables.result
index 0a53a5ae99d..afb3e12a474 100644
--- a/mysql-test/r/stat_tables.result
+++ b/mysql-test/r/stat_tables.result
@@ -707,8 +707,27 @@ ERROR 42S02: Table 'test.x' doesn't exist
 select * from information_schema.tables where table_name='v';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	TABLE_TYPE	ENGINE	VERSION	ROW_FORMAT	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	AUTO_INCREMENT	CREATE_TIME	UPDATE_TIME	CHECK_TIME	TABLE_COLLATION	CHECKSUM	CREATE_OPTIONS	TABLE_COMMENT
 def	test	v	VIEW	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	VIEW
+set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
 drop table t1,t2;
 drop view v;
+#
+# MDEV-19407: Assertion `field->table->stats_is_read' failed in is_eits_usable
+#
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set @@optimizer_use_condition_selectivity= 1;
+set @@use_stat_tables='never';
+create table t1(pk int);
+insert into t1 values (4),(3);
+set @@optimizer_use_condition_selectivity= 4;
+set use_stat_tables='preferably';
+INSERT INTO t1 SELECT * FROM x;
+ERROR 42S02: Table 'test.x' doesn't exist
+CREATE TABLE t2 SELECT pk FROM t1 WHERE pk>2;
+select * from t2;
+pk
+4
+3
+drop table t1,t2;
 set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
 set @save_optimizer_switch=@@optimizer_switch;
 set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/r/stat_tables_innodb.result b/mysql-test/r/stat_tables_innodb.result
index 9a93b479664..643a7aa55ea 100644
--- a/mysql-test/r/stat_tables_innodb.result
+++ b/mysql-test/r/stat_tables_innodb.result
@@ -734,8 +734,27 @@ ERROR 42S02: Table 'test.x' doesn't exist
 select * from information_schema.tables where table_name='v';
 TABLE_CATALOG	TABLE_SCHEMA	TABLE_NAME	TABLE_TYPE	ENGINE	VERSION	ROW_FORMAT	TABLE_ROWS	AVG_ROW_LENGTH	DATA_LENGTH	MAX_DATA_LENGTH	INDEX_LENGTH	DATA_FREE	AUTO_INCREMENT	CREATE_TIME	UPDATE_TIME	CHECK_TIME	TABLE_COLLATION	CHECKSUM	CREATE_OPTIONS	TABLE_COMMENT
 def	test	v	VIEW	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	NULL	VIEW
+set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
 drop table t1,t2;
 drop view v;
+#
+# MDEV-19407: Assertion `field->table->stats_is_read' failed in is_eits_usable
+#
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set @@optimizer_use_condition_selectivity= 1;
+set @@use_stat_tables='never';
+create table t1(pk int);
+insert into t1 values (4),(3);
+set @@optimizer_use_condition_selectivity= 4;
+set use_stat_tables='preferably';
+INSERT INTO t1 SELECT * FROM x;
+ERROR 42S02: Table 'test.x' doesn't exist
+CREATE TABLE t2 SELECT pk FROM t1 WHERE pk>2;
+select * from t2;
+pk
+4
+3
+drop table t1,t2;
 set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
 set @save_optimizer_switch=@@optimizer_switch;
 set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/t/stat_tables.test b/mysql-test/t/stat_tables.test
index 2727f8d8bb1..1e4d261c3f3 100644
--- a/mysql-test/t/stat_tables.test
+++ b/mysql-test/t/stat_tables.test
@@ -469,9 +469,29 @@ CREATE VIEW v AS SELECT * FROM t1 JOIN t2;
 INSERT INTO t2 SELECT * FROM x;
 
 select * from information_schema.tables where table_name='v';
+set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
 
 drop table t1,t2;
 drop view v;
+
+--echo #
+--echo # MDEV-19407: Assertion `field->table->stats_is_read' failed in is_eits_usable
+--echo #
+
+set @save_optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set @@optimizer_use_condition_selectivity= 1;
+set @@use_stat_tables='never';
+create table t1(pk int);
+insert into t1 values (4),(3);
+set @@optimizer_use_condition_selectivity= 4;
+set use_stat_tables='preferably';
+
+--error ER_NO_SUCH_TABLE
+INSERT INTO t1 SELECT * FROM x;
+CREATE TABLE t2 SELECT pk FROM t1 WHERE pk>2;
+select * from t2;
+drop table t1,t2;
+
 set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
 
 set @save_optimizer_switch=@@optimizer_switch;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 81ab599ed64..37f73adccb3 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -2191,6 +2191,9 @@ inline bool statistics_for_command_is_needed(THD *thd)
   case SQLCOM_DELETE_MULTI:
   case SQLCOM_REPLACE:
   case SQLCOM_REPLACE_SELECT:
+  case SQLCOM_CREATE_TABLE:
+  case SQLCOM_SET_OPTION:
+  case SQLCOM_DO:
     break;
   default: 
     return FALSE;


More information about the commits mailing list