[Commits] a0164e04f7e: MDEV-19334: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed.

Varun varunraiko1803 at gmail.com
Thu Apr 25 16:35:51 EEST 2019


revision-id: a0164e04f7e9c83c9162fdcb76f4f3629ce83f8a (mariadb-10.1.38-134-ga0164e04f7e)
parent(s): caa9023c9ed101acbcf6b9bd821a09daeb8271ee
author: Varun Gupta
committer: Varun Gupta
timestamp: 2019-04-25 18:18:26 +0530
message:

MDEV-19334: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed.

Fixed the assert by making sure that not to use EITS if the column statistics was not allocated

---
 mysql-test/r/statistics.result | 14 ++++++++++++++
 mysql-test/t/statistics.test   | 15 +++++++++++++++
 sql/sql_statistics.cc          | 15 +++++++++++----
 3 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/mysql-test/r/statistics.result b/mysql-test/r/statistics.result
index 295a9b34e49..135a0806bc3 100644
--- a/mysql-test/r/statistics.result
+++ b/mysql-test/r/statistics.result
@@ -1735,4 +1735,18 @@ rename table t1 to t2, t3 to t4;
 ERROR 42S02: Table 'test.t3' doesn't exist
 drop table t1, mysql.table_stats;
 rename table test.table_stats to mysql.table_stats;
+#
+# MDEV-19334: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed.
+#
+create temporary table t1(a int);
+insert into t1 values (1),(2),(3);
+set use_stat_tables=preferably;
+set @optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set optimizer_use_condition_selectivity=4;
+select * from t1 where a >= 2;
+a
+2
+3
+drop table t1;
+set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
 set use_stat_tables=@save_use_stat_tables;
diff --git a/mysql-test/t/statistics.test b/mysql-test/t/statistics.test
index e4f9870a622..7d2e7e898d3 100644
--- a/mysql-test/t/statistics.test
+++ b/mysql-test/t/statistics.test
@@ -809,4 +809,19 @@ rename table t1 to t2, t3 to t4;
 drop table t1, mysql.table_stats;
 rename table test.table_stats to mysql.table_stats;
 
+--echo #
+--echo # MDEV-19334: bool is_eits_usable(Field*): Assertion `field->table->stats_is_read' failed.
+--echo #
+
+create temporary table t1(a int);
+insert into t1 values (1),(2),(3);
+ 
+set use_stat_tables=preferably;
+set @optimizer_use_condition_selectivity= @@optimizer_use_condition_selectivity;
+set optimizer_use_condition_selectivity=4;
+ 
+select * from t1 where a >= 2;
+drop table t1;
+set @@optimizer_use_condition_selectivity= @save_optimizer_use_condition_selectivity;
+
 set use_stat_tables=@save_use_stat_tables;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index b435971a4d6..061622a2cd6 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -4067,6 +4067,14 @@ bool is_stat_table(const char *db, const char *table)
 
 bool is_eits_usable(Field *field)
 {
+  Column_statistics* col_stats= field->read_stats;
+  
+  // check if column_statistics was allocated for this field
+  if (!col_stats)
+    return false;
+
+  DBUG_ASSERT(field->table->stats_is_read);
+
   /*
     (1): checks if we have EITS statistics for a particular column
     (2): Don't use EITS for GEOMETRY columns
@@ -4074,10 +4082,9 @@ bool is_eits_usable(Field *field)
          partition list of a table. We assume the selecticivity for
          such columns would be handled during partition pruning.
   */
-  DBUG_ASSERT(field->table->stats_is_read);
-  Column_statistics* col_stats= field->read_stats;
-  return col_stats && !col_stats->no_stat_values_provided() &&        //(1)
-    field->type() != MYSQL_TYPE_GEOMETRY &&                           //(2)
+
+  return !col_stats->no_stat_values_provided() &&        //(1)
+    field->type() != MYSQL_TYPE_GEOMETRY &&              //(2)
 #ifdef WITH_PARTITION_STORAGE_ENGINE
     (!field->table->part_info ||
      !field->table->part_info->field_in_partition_expr(field)) &&     //(3)


More information about the commits mailing list