diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-31 13:03:09 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-31 13:03:09 +0300 |
commit | 9f779d34a13139d405b1c2cb9f2fcec95abc1fea (patch) | |
tree | c4244e32df98cce499978e241ac951d566212657 /sql | |
parent | e5b16cf8dec403a576078bbf9f1b3eaf392fae2e (diff) | |
parent | e94172c2a07f21118d26e4cde0c48a2fd536cf06 (diff) | |
download | mariadb-git-bb-10.6-MDEV-25919.tar.gz |
Merge 10.6bb-10.6-MDEV-25919
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_base.cc | 20 | ||||
-rw-r--r-- | sql/sql_class.h | 5 |
2 files changed, 16 insertions, 9 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 55c2b6db7e7..1e8c6321f85 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -4583,13 +4583,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; } @@ -4604,13 +4604,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) diff --git a/sql/sql_class.h b/sql/sql_class.h index 714d18b6297..b5874d2435a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -4663,11 +4663,8 @@ public: for any CTE references. */ if (!lex->with_cte_resolution) - { my_message(ER_NO_DB_ERROR, ER(ER_NO_DB_ERROR), MYF(0)); - return TRUE; - } - return FALSE; + return TRUE; } to->str= strmake(db.str, db.length); |