diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-31 09:22:21 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-31 09:22:21 +0300 |
commit | 04647611260a77041186ace12f96b05d50bed4da (patch) | |
tree | 3f8efa00ae2fa2bc6be5165658c34c79c9437a3f /sql/sql_base.cc | |
parent | dc6bc85cd29586631d927036451d955c7013206c (diff) | |
parent | e835cc851e389770219a33037af65db8887cc9a8 (diff) | |
download | mariadb-git-04647611260a77041186ace12f96b05d50bed4da.tar.gz |
Merge 10.3 into 10.4
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 8408d8d31a4..0a351809c16 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4638,13 +4638,13 @@ bool table_already_fk_prelocked(TABLE_LIST *tl, LEX_CSTRING *db, } -static bool internal_table_exists(TABLE_LIST *global_list, - const char *table_name) +static TABLE_LIST *internal_table_exists(TABLE_LIST *global_list, + const char *table_name) { do { if (global_list->table_name.str == table_name) - return 1; + return global_list; } while ((global_list= global_list->next_global)); return 0; } @@ -4659,13 +4659,23 @@ add_internal_tables(THD *thd, Query_tables_list *prelocking_ctx, do { + TABLE_LIST *tmp __attribute__((unused)); DBUG_PRINT("info", ("table name: %s", tables->table_name.str)); /* Skip table if already in the list. Can happen with prepared statements */ - if (tables->next_local && - internal_table_exists(global_table_list, tables->table_name.str)) + if ((tmp= internal_table_exists(global_table_list, + tables->table_name.str))) + { + /* + Use the original value for the next local, used by the + original prepared statement. We cannot trust the original + next_local value as it may have been changed by a previous + statement using the same table. + */ + tables->next_local= tmp; continue; + } TABLE_LIST *tl= (TABLE_LIST *) thd->alloc(sizeof(TABLE_LIST)); if (!tl) |