maria-developers team mailing list archive
Mailing list archive
[MDEV-8554] Weird behavior of multi-table UPDATE and THD::save_prep_leaf_list
I was debugging https://mariadb.atlassian.net/browse/MDEV-8554
The patch is about save_prep_leaf_list is not being cleaned up by a statement.
I committed a patch that makes that bug go away. However, the way that
statements work with THD::save_prep_leaf_list look weird to me.
Since it was you who added save_prep_leaf_list, I wanted to ask you:
Consider an example:
CREATE TABLE t1 (a INT) ENGINE=MyISAM;
INSERT INTO t1 VALUES (1),(2); # Not necessary, the table can be empty
CREATE TABLE t2 (b INT) ENGINE=MyISAM;
INSERT INTO t2 VALUES (3),(4); # Not necessary, the table can be empty
CREATE TABLE t3 (c INT) ENGINE=MyISAM;
INSERT INTO t3 VALUES (5),(6); # Not necessary, the table can be empty
CREATE OR REPLACE ALGORITHM=MERGE VIEW v3 AS SELECT * FROM t3;
Now, let's debug how THD::save_prep_leaf_list changes and is used:
UPDATE t1, t2 SET a = 1 WHERE a IN ( SELECT 0 FROM v3 );
Breakpoint 4, THD::THD (this=0x59ff6f0) at /home/psergey/dev-git/10.0/sql/sql_class.cc:1062
Breakpoint 1, THD::reset_for_next_command (this=0x59ff6f0) at /home/psergey/dev-git/10.0/sql/sql_parse.cc:6272
^^^ I have added this line in my fix
Breakpoint 5, LEX::save_prep_leaf_tables (this=0x5a02f80) at /home/psergey/dev-git/10.0/sql/sql_lex.cc:4132
^^^ This is where save_prep_leaf_list is used.
Breakpoint 2, mysql_derived_merge (thd=0x59ff6f0, lex=0x5a02f80, derived=0x7fff68008618) at /home/psergey/dev-git/10.0/sql/sql_derived.cc:379
if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI ||
thd->lex->sql_command == SQLCOM_DELETE_MULTI)
^^^ this is where save_prep_leaf_list is changed by this statement.
5. (no break). The statement finished.
That is, the statement first checks save_prep_leaf_list, and then uses it.
This looks weird. Any thoughts?
Sergei Petrunia, Software Developer
MariaDB Corporation | Skype: sergefp | Blog: http://s.petrunia.net/blog