Commit 865ef0f5 authored by Monty's avatar Monty Committed by Sergei Golubchik

MDEV-33680 Server hangs or assertion fails upon SELECT with limited max_tmp_space_usage

The bug was that Aggregator_distinct::add() did not properly handle
write errors. (Old bug exposed by the new code).
parent b9f57931
...@@ -150,4 +150,11 @@ INSERT INTO t1 VALUES ...@@ -150,4 +150,11 @@ INSERT INTO t1 VALUES
UPDATE t1 SET a = '' LIMIT 100; UPDATE t1 SET a = '' LIMIT 100;
ERROR HY000: Local temporary space limit reached ERROR HY000: Local temporary space limit reached
DROP TABLE t1; 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 # End of 11.5 tests
...@@ -200,4 +200,13 @@ UPDATE t1 SET a = '' LIMIT 100; ...@@ -200,4 +200,13 @@ UPDATE t1 SET a = '' LIMIT 100;
DROP TABLE t1; 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 --echo # End of 11.5 tests
...@@ -1026,7 +1026,10 @@ bool Aggregator_distinct::add() ...@@ -1026,7 +1026,10 @@ bool Aggregator_distinct::add()
} }
if (unlikely((error= table->file->ha_write_tmp_row(table->record[0]))) && if (unlikely((error= table->file->ha_write_tmp_row(table->record[0]))) &&
table->file->is_fatal_error(error, HA_CHECK_DUP)) table->file->is_fatal_error(error, HA_CHECK_DUP))
{
table->file->print_error(error, MYF(0));
return TRUE; return TRUE;
}
return FALSE; return FALSE;
} }
else else
......
...@@ -307,7 +307,7 @@ my_bool Expression_cache_tmptable::put_value(Item *value) ...@@ -307,7 +307,7 @@ my_bool Expression_cache_tmptable::put_value(Item *value)
cache_table_param.start_recinfo, cache_table_param.start_recinfo,
&cache_table_param.recinfo, &cache_table_param.recinfo,
error, 1, NULL)) error, 1, NULL))
goto err; goto err2;
} }
} }
} }
...@@ -318,6 +318,8 @@ my_bool Expression_cache_tmptable::put_value(Item *value) ...@@ -318,6 +318,8 @@ my_bool Expression_cache_tmptable::put_value(Item *value)
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
err: err:
cache_table->file->print_error(error, MYF(0));
err2:
disable_cache(); disable_cache();
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
......
...@@ -22353,7 +22353,7 @@ bool open_tmp_table(TABLE *table) ...@@ -22353,7 +22353,7 @@ bool open_tmp_table(TABLE *table)
RETURN RETURN
FALSE - OK 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, ...@@ -22569,7 +22569,7 @@ bool create_internal_tmp_table(TABLE *table, KEY *org_keyinfo,
RETURN RETURN
FALSE - OK FALSE - OK
TRUE - Error TRUE - Error ; my_error() has been called.
*/ */
/* Create internal MyISAM temporary table */ /* Create internal MyISAM temporary table */
...@@ -22709,6 +22709,8 @@ bool create_internal_tmp_table(TABLE *table, KEY *org_keyinfo, ...@@ -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 If a HEAP table gets full, create a internal table in MyISAM or Maria
and copy all rows to this and copy all rows to this
In case of error, my_error() or handler::print_error() will be called.
*/ */
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