diff --git a/mysql-test/main/tmp_space_usage.result b/mysql-test/main/tmp_space_usage.result index 8436ba9d10e..355979aa66f 100644 --- a/mysql-test/main/tmp_space_usage.result +++ b/mysql-test/main/tmp_space_usage.result @@ -150,4 +150,11 @@ INSERT INTO t1 VALUES UPDATE t1 SET a = '' LIMIT 100; ERROR HY000: Local temporary space limit reached DROP TABLE t1; +# +# MDEV-33680 Server hangs or assertion fails upon SELECT with limited +# max_tmp_space_usage +# +set max_tmp_session_space_usage = 1024*1024; +select count(distinct concat(seq,repeat('x',1000))) from seq_1_to_1000; +ERROR HY000: Global temporary space limit reached # End of 11.5 tests diff --git a/mysql-test/main/tmp_space_usage.test b/mysql-test/main/tmp_space_usage.test index 467dbd4c6f2..5c2a48681d6 100644 --- a/mysql-test/main/tmp_space_usage.test +++ b/mysql-test/main/tmp_space_usage.test @@ -200,4 +200,13 @@ UPDATE t1 SET a = '' LIMIT 100; DROP TABLE t1; +--echo # +--echo # MDEV-33680 Server hangs or assertion fails upon SELECT with limited +--echo # max_tmp_space_usage +--echo # + +set max_tmp_session_space_usage = 1024*1024; +--error 201 +select count(distinct concat(seq,repeat('x',1000))) from seq_1_to_1000; + --echo # End of 11.5 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 8900e937b81..053b9b4cb4a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -1026,7 +1026,10 @@ bool Aggregator_distinct::add() } if (unlikely((error= table->file->ha_write_tmp_row(table->record[0]))) && table->file->is_fatal_error(error, HA_CHECK_DUP)) + { + table->file->print_error(error, MYF(0)); return TRUE; + } return FALSE; } else diff --git a/sql/sql_expression_cache.cc b/sql/sql_expression_cache.cc index 9914433b7da..54377136aa1 100644 --- a/sql/sql_expression_cache.cc +++ b/sql/sql_expression_cache.cc @@ -307,7 +307,7 @@ my_bool Expression_cache_tmptable::put_value(Item *value) cache_table_param.start_recinfo, &cache_table_param.recinfo, error, 1, NULL)) - goto err; + goto err2; } } } @@ -318,6 +318,8 @@ my_bool Expression_cache_tmptable::put_value(Item *value) DBUG_RETURN(FALSE); err: + cache_table->file->print_error(error, MYF(0)); +err2: disable_cache(); DBUG_RETURN(TRUE); } diff --git a/sql/sql_select.cc b/sql/sql_select.cc index e79cb26c5b8..35b0513b162 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -22353,7 +22353,7 @@ bool open_tmp_table(TABLE *table) RETURN FALSE - OK - TRUE - Error + TRUE - Error. my_error() have been called */ @@ -22569,7 +22569,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *org_keyinfo, RETURN FALSE - OK - TRUE - Error + TRUE - Error ; my_error() has been called. */ /* Create internal MyISAM temporary table */ @@ -22709,6 +22709,8 @@ bool create_internal_tmp_table(TABLE *table, KEY *org_keyinfo, /* If a HEAP table gets full, create a internal table in MyISAM or Maria and copy all rows to this + + In case of error, my_error() or handler::print_error() will be called. */