Commit 191cae2d authored by Nikita Malyavin's avatar Nikita Malyavin

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+.
parent f64a4f67
...@@ -267,3 +267,12 @@ DELETE FROM v1 ORDER BY v LIMIT 4; ...@@ -267,3 +267,12 @@ DELETE FROM v1 ORDER BY v LIMIT 4;
DROP TABLE t1; DROP TABLE t1;
DROP VIEW v1; 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 ();
...@@ -303,6 +303,15 @@ INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456' ...@@ -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; DELETE FROM v1 ORDER BY v LIMIT 4;
DROP TABLE t1; DROP TABLE t1;
DROP VIEW v1; 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 VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1; DROP PROCEDURE IF EXISTS p1;
......
...@@ -303,6 +303,15 @@ INSERT INTO t1 (d) VALUES ('2004-04-19 15:37:39.123'),('1985-12-24 10:15:08.456' ...@@ -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; DELETE FROM v1 ORDER BY v LIMIT 4;
DROP TABLE t1; DROP TABLE t1;
DROP VIEW v1; 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 VIEW IF EXISTS v1,v2;
DROP TABLE IF EXISTS t1,t2,t3; DROP TABLE IF EXISTS t1,t2,t3;
DROP PROCEDURE IF EXISTS p1; DROP PROCEDURE IF EXISTS p1;
......
...@@ -838,7 +838,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -838,7 +838,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
enum enum_field_types type= (*field_ptr)->type(); enum enum_field_types type= (*field_ptr)->type();
if (type < MYSQL_TYPE_MEDIUM_BLOB || if (type < MYSQL_TYPE_MEDIUM_BLOB ||
type > MYSQL_TYPE_BLOB) type > MYSQL_TYPE_BLOB)
bitmap_set_bit(tab->read_set, fields); tab->field[fields]->register_field_in_read_map();
else else
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_EIS_FOR_FIELD, ER_NO_EIS_FOR_FIELD,
...@@ -866,7 +866,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, ...@@ -866,7 +866,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables,
enum enum_field_types type= tab->field[pos]->type(); enum enum_field_types type= tab->field[pos]->type();
if (type < MYSQL_TYPE_MEDIUM_BLOB || if (type < MYSQL_TYPE_MEDIUM_BLOB ||
type > MYSQL_TYPE_BLOB) type > MYSQL_TYPE_BLOB)
bitmap_set_bit(tab->read_set, pos); tab->field[pos]->register_field_in_read_map();
else else
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
ER_NO_EIS_FOR_FIELD, ER_NO_EIS_FOR_FIELD,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment