diff options
| author | Jan Lindström <jan.lindstrom@mariadb.com> | 2021-02-16 08:46:14 +0200 |
|---|---|---|
| committer | Jan Lindström <jan.lindstrom@mariadb.com> | 2021-02-16 08:46:14 +0200 |
| commit | a5bcec727b096f634e43f9031440cc1dc9e302c2 (patch) | |
| tree | c1005cdf624719b0e97e318b0d11cd5ec81bfc52 /sql/sql_truncate.cc | |
| parent | d0defd1ea2af80a360332fd8c1e60a34e2289213 (diff) | |
| download | mariadb-git-a5bcec727b096f634e43f9031440cc1dc9e302c2.tar.gz | |
MDEV-24865 : Server crashes when truncate mysql user tablebb-10.4-MDEV-24865
For truncate we try to find out possible foreign key tables
using open_tables. However, table_list was not cleaned up
properly and there was no error handling. Fixed by cleaning
table_list and adding proper error handling.
Diffstat (limited to 'sql/sql_truncate.cc')
| -rw-r--r-- | sql/sql_truncate.cc | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/sql/sql_truncate.cc b/sql/sql_truncate.cc index c3d347307a2..e7ecdda958e 100644 --- a/sql/sql_truncate.cc +++ b/sql/sql_truncate.cc @@ -416,20 +416,23 @@ bool Sql_cmd_truncate_table::truncate_table(THD *thd, TABLE_LIST *table_ref) bool hton_can_recreate; #ifdef WITH_WSREP - if (WSREP(thd)) + if (WSREP(thd) && wsrep_thd_is_local(thd)) { wsrep::key_array keys; - wsrep_append_fk_parent_table(thd, table_ref, &keys); - if (keys.empty()) + /* Do not start TOI if table is not found */ + if (!wsrep_append_fk_parent_table(thd, table_ref, &keys)) { - WSREP_TO_ISOLATION_BEGIN_IF(table_ref->db.str, table_ref->table_name.str, NULL) + if (keys.empty()) { - DBUG_RETURN(TRUE); - } - } else { - WSREP_TO_ISOLATION_BEGIN_FK_TABLES(NULL, NULL, table_ref, &keys) - { - DBUG_RETURN(TRUE); + WSREP_TO_ISOLATION_BEGIN_IF(table_ref->db.str, table_ref->table_name.str, NULL) + { + DBUG_RETURN(TRUE); + } + } else { + WSREP_TO_ISOLATION_BEGIN_FK_TABLES(NULL, NULL, table_ref, &keys) + { + DBUG_RETURN(TRUE); + } } } } |
