Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions mysql-test/main/delete_multi_order_by.result
Original file line number Diff line number Diff line change
Expand Up @@ -423,5 +423,14 @@ COUNT(*)
0
DROP TABLE t1;
#
# MDEV-40573 Assertion `del_table == table_being_deleted' failed in
# multi_delete::send_data on DELETE w/ index hint + window function
#
CREATE TABLE t1 (c INT PRIMARY KEY);
INSERT INTO t1 (c) VALUES (1),(2),(3),(4);
DELETE FROM t1 USE KEY() WHERE 0
ORDER BY PERCENTILE_CONT(COUNT(*)) WITHIN GROUP(ORDER BY c) OVER();
DROP TABLE t1;
#
# End 11.8 tests
#
10 changes: 10 additions & 0 deletions mysql-test/main/delete_multi_order_by.test
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,16 @@ DELETE FROM a3,a1 USING t1 AS a1 JOIN t1 AS a2 JOIN t1 AS a3;
SELECT COUNT(*) from t1;
DROP TABLE t1;

--echo #
--echo # MDEV-40573 Assertion `del_table == table_being_deleted' failed in
--echo # multi_delete::send_data on DELETE w/ index hint + window function
--echo #
CREATE TABLE t1 (c INT PRIMARY KEY);
INSERT INTO t1 (c) VALUES (1),(2),(3),(4);
DELETE FROM t1 USE KEY() WHERE 0
ORDER BY PERCENTILE_CONT(COUNT(*)) WITHIN GROUP(ORDER BY c) OVER();
DROP TABLE t1;

--echo #
--echo # End 11.8 tests
--echo #
1 change: 1 addition & 0 deletions sql/sql_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -7717,6 +7717,7 @@ class multi_delete :public select_result_interceptor
/* True if at least one table we delete from is not transactional */
bool normal_tables;
bool delete_while_scanning;
bool tables_initialized;
/*
error handling (rollback and binlogging) can happen in send_eof()
so that afterward abort_result_set() needs to find out that.
Expand Down
5 changes: 5 additions & 0 deletions sql/sql_delete.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,7 @@ multi_delete::multi_delete(THD *thd_arg,
do_delete(0),
transactional_tables(0),
normal_tables(0),
tables_initialized(false),
error_handled(0)
{
tmp_tables = thd->calloc<TABLE*>(table_count);
Expand Down Expand Up @@ -1355,6 +1356,7 @@ multi_delete::initialize_tables(JOIN *join)
DBUG_RETURN(true);

join->tmp_table_keep_current_rowid= TRUE;
tables_initialized= true;
DBUG_RETURN(thd->is_fatal_error);
}

Expand Down Expand Up @@ -1386,6 +1388,9 @@ multi_delete::~multi_delete()

int multi_delete::send_data(List<Item> &values)
{
if (!tables_initialized)
return 0;

int secure_counter= delete_while_scanning ? -1 : 0;
TABLE_LIST *del_table;
DBUG_ENTER("multi_delete::send_data");
Expand Down