[Commits] c1ef4d3: MDEV-24242 Query returns wrong result while using big_tables=1
revision-id: c1ef4d36898f038702c2678f23dc6081b399ccf8 (mariadb-10.5.4-335-gc1ef4d3) parent(s): 33d41167c54fed9116cd8f0dfa01b43733988e6d author: Igor Babaev committer: Igor Babaev timestamp: 2020-11-24 20:05:54 -0800 message: MDEV-24242 Query returns wrong result while using big_tables=1 When executing set operations in a pipeline using only one temporary table additional scans of intermediate results may be needed. The scans are performed with usage of the rnd_next() handler function that might leave record buffers used for the temporary table not in a state that is good for following writes into the table. For example it happens for aria engine when the last call of rnd_next() encounters only deleted records. Thus a cleanup of record buffers is needed after each such scan of the temporary table. Approved by Oleksandr Byelkin <sanja@mariadb.com> --- mysql-test/main/set_operation.result | 34 ++++++++++++++++++++++++++++++++++ mysql-test/main/set_operation.test | 28 ++++++++++++++++++++++++++++ sql/sql_union.cc | 4 ++++ 3 files changed, 66 insertions(+) diff --git a/mysql-test/main/set_operation.result b/mysql-test/main/set_operation.result index a021033..24d2c7f 100644 --- a/mysql-test/main/set_operation.result +++ b/mysql-test/main/set_operation.result @@ -1155,3 +1155,37 @@ count(*) 319 drop table t1; drop table t2; +# +# MDEV-24242: set expression with empty intermediate result +# when tmp_memory_table_size is set to 0 +# +create table t1 (a int, b int) engine=MyISAM; +insert into t1 values (1,1), (2,2); +create table t2 (a int, b int) engine=MyISAM; +insert into t2 values (11,11), (12,12), (13,13); +select * from t1 +except all +select * from t1 +except +select * from t1 +union all +select * from t2; +a b +12 12 +11 11 +13 13 +set tmp_memory_table_size=0; +select * from t1 +except all +select * from t1 +except +select * from t1 +union all +select * from t2; +a b +12 12 +11 11 +13 13 +set tmp_memory_table_size=default; +drop table t1,t2; +# End of 10.4 tests diff --git a/mysql-test/main/set_operation.test b/mysql-test/main/set_operation.test index c43725c..c422042f 100644 --- a/mysql-test/main/set_operation.test +++ b/mysql-test/main/set_operation.test @@ -524,3 +524,31 @@ select count(*) from drop table t1; drop table t2; + +--echo # +--echo # MDEV-24242: set expression with empty intermediate result +--echo # when tmp_memory_table_size is set to 0 +--echo # + +create table t1 (a int, b int) engine=MyISAM; +insert into t1 values (1,1), (2,2); +create table t2 (a int, b int) engine=MyISAM; +insert into t2 values (11,11), (12,12), (13,13); + +let $q= +select * from t1 +except all +select * from t1 +except +select * from t1 +union all +select * from t2; + +eval $q; +set tmp_memory_table_size=0; +eval $q; +set tmp_memory_table_size=default; + +drop table t1,t2; + +--echo # End of 10.4 tests diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 021720f..9e51bb4 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -880,6 +880,10 @@ bool select_unit_ext::send_eof() table->file->ha_rnd_end(); } + /* Clean up table buffers for the next set operation from pipeline */ + if (next_sl) + restore_record(table,s->default_values); + if (unlikely(error)) table->file->print_error(error, MYF(0));
participants (1)
-
IgorBabaev