Commit aa713f5a authored by Igor Babaev's avatar Igor Babaev Committed by Sergei Golubchik

MDEV-31224 Crash with EXPLAIN EXTENDED for multi-table update of system table

EXPLAIN EXTENDED should always print the field item used in the left part
of an equality expression from the SET clause of an update statement as a
reference to table column.

Approved by Oleksandr Byelkin <sanja@mariadb.com>
parent 54324e54
......@@ -277,3 +277,22 @@ EXECUTE stmt;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
drop table t1,t2;
#
# MDEV-31224: EXPLAIN EXTENDED for multi-table update of system table
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3);
EXPLAIN EXTENDED UPDATE t1, t2 SET b = 4 WHERE a IN (6,2);
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 system NULL NULL NULL NULL 1 100.00
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 update `test`.`t1` set `test`.`t2`.`b` = 4 where `test`.`t1`.`a` in (6,2)
UPDATE t1, t2 SET b = 4 WHERE a IN (6,2);
SELECT * from t2;
b
4
DROP TABLE t1, t2;
# End of 10.4 tests
......@@ -250,3 +250,23 @@ PREPARE stmt FROM 'EXPLAIN INSERT INTO t1 SELECT * FROM t2';
EXECUTE stmt;
drop table t1,t2;
--echo #
--echo # MDEV-31224: EXPLAIN EXTENDED for multi-table update of system table
--echo #
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3);
let $q=
UPDATE t1, t2 SET b = 4 WHERE a IN (6,2);
eval EXPLAIN EXTENDED $q;
eval $q;
SELECT * from t2;
DROP TABLE t1, t2;
--echo # End of 10.4 tests
......@@ -2689,7 +2689,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 system NULL NULL NULL NULL 0 0.00 Const row not found
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00
Warnings:
Note 1003 update `test`.`t1` set NULL = 10
Note 1003 update `test`.`t1` set `test`.`t2`.`c2` = 10
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 7
......@@ -2734,7 +2734,7 @@ id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 system NULL NULL NULL NULL 0 0.00 Const row not found
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 100.00 Using where
Warnings:
Note 1003 update `test`.`t1` set NULL = 10 where `test`.`t1`.`c3` = 10
Note 1003 update `test`.`t1` set `test`.`t2`.`c2` = 10 where `test`.`t1`.`c3` = 10
# Status of EXPLAIN EXTENDED query
Variable_name Value
Handler_read_key 7
......
......@@ -28138,7 +28138,7 @@ void st_select_lex::print_set_clause(THD *thd, String *str,
else
str->append(',');
item->print(str, query_type);
item->print(str, (enum_query_type) (query_type | QT_NO_DATA_EXPANSION));
str->append(STRING_WITH_LEN(" = "));
val->print(str, query_type);
}
......
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