[Commits] 038b234: MDEV-23778 Derived table handler looses data on conversion from HEAP to Aria
revision-id: 038b2347f003e53fd6a72b213b206835729c5ed2 (mariadb-10.4.11-396-g038b234) parent(s): 61df98f9642c1616f872d61808ce6d010fe35b44 author: Igor Babaev committer: Igor Babaev timestamp: 2020-09-26 10:07:28 -0700 message: MDEV-23778 Derived table handler looses data on conversion from HEAP to Aria This bug happened when the HEAP temporary table used for the derived table created for a derived handler of a remote engine of the federated type became full and was converted to an Area table. For this conversion the tmp_table_param parameter must be always taken from the select_unit object created for the result of the derived table. --- .../federated/federatedx_create_handlers.result | 44 +++++++++++++++++ .../federated/federatedx_create_handlers.test | 57 ++++++++++++++++++++++ sql/derived_handler.cc | 4 +- 3 files changed, 102 insertions(+), 3 deletions(-) diff --git a/mysql-test/suite/federated/federatedx_create_handlers.result b/mysql-test/suite/federated/federatedx_create_handlers.result index 63e56bf..b115cc7 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.result +++ b/mysql-test/suite/federated/federatedx_create_handlers.result @@ -376,6 +376,50 @@ DROP TABLE federated.t1, federated.t2, federated.t3, federated.t4; connection slave; DROP TABLE federated.t1, federated.t2; connection default; +# +# MDEV-23778: Derived handler used for big derived tables +# +connection slave; +CREATE TABLE federated.t1 ( +a varchar(100) NOT NULL default '123' +) +DEFAULT CHARSET=latin1; +CREATE TABLE federated.t2 LIKE federated.t1; +BEGIN NOT ATOMIC +DECLARE i INT DEFAULT 0; +START TRANSACTION; +WHILE i < 70000 DO +INSERT INTO federated.t1 VALUES (i); +SET i = i + 1; +END WHILE; +COMMIT; +END +$$ +connection master; +CREATE TABLE federated.t1 ( +a varchar(100) NOT NULL default '123' +) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'; +CREATE TABLE federated.t2 ( +a varchar(100) NOT NULL default '123' +) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:SLAVE_PORT/federated/t2'; +SELECT COUNT(DISTINCT a) FROM federated.t1; +COUNT(DISTINCT a) +70000 +INSERT INTO federated.t2 +SELECT * FROM (SELECT * FROM federated.t1 LIMIT 100) dt; +SELECT COUNT(DISTINCT a) FROM federated.t2; +COUNT(DISTINCT a) +100 +TRUNCATE TABLE federated.t2; +INSERT INTO federated.t2 +SELECT * FROM (SELECT * FROM federated.t1 LIMIT 70000) dt; +SELECT COUNT(DISTINCT a) FROM federated.t2; +COUNT(DISTINCT a) +70000 set global federated_pushdown=0; connection master; DROP TABLE IF EXISTS federated.t1; diff --git a/mysql-test/suite/federated/federatedx_create_handlers.test b/mysql-test/suite/federated/federatedx_create_handlers.test index d765588..4b5789e 100644 --- a/mysql-test/suite/federated/federatedx_create_handlers.test +++ b/mysql-test/suite/federated/federatedx_create_handlers.test @@ -208,6 +208,63 @@ DROP TABLE federated.t1, federated.t2; connection default; +--echo # +--echo # MDEV-23778: Derived handler used for big derived tables +--echo # + +connection slave; + +CREATE TABLE federated.t1 ( + a varchar(100) NOT NULL default '123' +) +DEFAULT CHARSET=latin1; + +CREATE TABLE federated.t2 LIKE federated.t1; + +DELIMITER $$; +BEGIN NOT ATOMIC + DECLARE i INT DEFAULT 0; + START TRANSACTION; + WHILE i < 70000 DO + INSERT INTO federated.t1 VALUES (i); + SET i = i + 1; + END WHILE; + COMMIT; +END +$$ + +DELIMITER ;$$ + +connection master; + +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval +CREATE TABLE federated.t1 ( + a varchar(100) NOT NULL default '123' +) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'; + + +--replace_result $SLAVE_MYPORT SLAVE_PORT +eval +CREATE TABLE federated.t2 ( + a varchar(100) NOT NULL default '123' +) +ENGINE="FEDERATED" DEFAULT CHARSET=latin1 +CONNECTION='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t2'; + +SELECT COUNT(DISTINCT a) FROM federated.t1; + +INSERT INTO federated.t2 + SELECT * FROM (SELECT * FROM federated.t1 LIMIT 100) dt; +SELECT COUNT(DISTINCT a) FROM federated.t2; + +TRUNCATE TABLE federated.t2; +INSERT INTO federated.t2 + SELECT * FROM (SELECT * FROM federated.t1 LIMIT 70000) dt; +SELECT COUNT(DISTINCT a) FROM federated.t2; + set global federated_pushdown=0; source include/federated_cleanup.inc; diff --git a/sql/derived_handler.cc b/sql/derived_handler.cc index 76fd736..f48b95c 100644 --- a/sql/derived_handler.cc +++ b/sql/derived_handler.cc @@ -120,8 +120,6 @@ void derived_handler::set_derived(TABLE_LIST *tbl) table= tbl->table; unit= tbl->derived; select= unit->first_select(); - tmp_table_param= select->next_select() ? - ((select_unit *)(unit->result))->get_tmp_table_param() : - &select->join->tmp_table_param; + tmp_table_param= ((select_unit *)(unit->result))->get_tmp_table_param(); }
participants (1)
-
IgorBabaev