From 191cae2d0ddeb475152c475a2227d1c385eaac83 Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Fri, 25 Jun 2021 04:23:27 +0300 Subject: MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE The problem is the same as in MDEV-18166: columns in virtual field expression are not marked for read, while the field itself does. field->register_field_in_read_map() should be called for read-marking all fields. The test is reproduced only in 10.4+, however the fix is applicable to 10.2+. --- mysql-test/suite/gcol/inc/gcol_view.inc | 9 +++++++++ mysql-test/suite/gcol/r/gcol_view_innodb.result | 9 +++++++++ mysql-test/suite/gcol/r/gcol_view_myisam.result | 9 +++++++++ sql/sql_admin.cc | 4 ++-- 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/gcol/inc/gcol_view.inc b/mysql-test/suite/gcol/inc/gcol_view.inc index 4aabd2429cd..6f9ce673199 100644 --- a/mysql-test/suite/gcol/inc/gcol_view.inc +++ b/mysql-test/suite/gcol/inc/gcol_view.inc @@ -267,3 +267,12 @@ DELETE FROM v1 ORDER BY v LIMIT 4; DROP TABLE t1; DROP VIEW v1; + +--echo # +--echo # MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE +--echo # + +create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual); +insert into t1 (c) values ('a'),('b'); +analyze table t1 persistent for columns (v) indexes (); + diff --git a/mysql-test/suite/gcol/r/gcol_view_innodb.result b/mysql-test/suite/gcol/r/gcol_view_innodb.result index 59e299f9d8c..03c4a15620a 100644 --- a/mysql-test/suite/gcol/r/gcol_view_innodb.result +++ b/mysql-test/suite/gcol/r/gcol_view_innodb.result @@ -303,6 +303,15 @@ INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456' DELETE FROM v1 ORDER BY v LIMIT 4; DROP TABLE t1; DROP VIEW v1; +# +# MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE +# +create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual); +insert into t1 (c) values ('a'),('b'); +analyze table t1 persistent for columns (v) indexes (); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK DROP VIEW IF EXISTS v1,v2; DROP TABLE IF EXISTS t1,t2,t3; DROP PROCEDURE IF EXISTS p1; diff --git a/mysql-test/suite/gcol/r/gcol_view_myisam.result b/mysql-test/suite/gcol/r/gcol_view_myisam.result index 17cc2135439..a030c73401c 100644 --- a/mysql-test/suite/gcol/r/gcol_view_myisam.result +++ b/mysql-test/suite/gcol/r/gcol_view_myisam.result @@ -303,6 +303,15 @@ INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456' DELETE FROM v1 ORDER BY v LIMIT 4; DROP TABLE t1; DROP VIEW v1; +# +# MDEV-18249 ASSERT_COLUMN_MARKED_FOR_READ failed in ANALYZE TABLE +# +create table t1 (c varchar(3) not null, v varchar(4) as (c) virtual); +insert into t1 (c) values ('a'),('b'); +analyze table t1 persistent for columns (v) indexes (); +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK DROP VIEW IF EXISTS v1,v2; DROP TABLE IF EXISTS t1,t2,t3; DROP PROCEDURE IF EXISTS p1; diff --git a/sql/sql_admin.cc b/sql/sql_admin.cc index 41af1e22de6..7942587cf02 100644 --- a/sql/sql_admin.cc +++ b/sql/sql_admin.cc @@ -838,7 +838,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, enum enum_field_types type= (*field_ptr)->type(); if (type < MYSQL_TYPE_MEDIUM_BLOB || type > MYSQL_TYPE_BLOB) - bitmap_set_bit(tab->read_set, fields); + tab->field[fields]->register_field_in_read_map(); else push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_NO_EIS_FOR_FIELD, @@ -866,7 +866,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, enum enum_field_types type= tab->field[pos]->type(); if (type < MYSQL_TYPE_MEDIUM_BLOB || type > MYSQL_TYPE_BLOB) - bitmap_set_bit(tab->read_set, pos); + tab->field[pos]->register_field_in_read_map(); else push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, ER_NO_EIS_FOR_FIELD, -- cgit v1.2.1