diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-04-21 15:33:50 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-04-21 15:33:50 +0300 |
commit | 620c55e708b9ea94ef8ba309267a6f2f32ed8104 (patch) | |
tree | 434f8bbb36626d16e8438b82da1618bd8313f6a2 /sql/sql_base.cc | |
parent | fdec842fd7f82b6ed9aec54f82ac50b5eea925b3 (diff) | |
parent | aec856073df12e95b68667587bfd8e469b60e7d4 (diff) | |
download | mariadb-git-620c55e708b9ea94ef8ba309267a6f2f32ed8104.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 65 |
1 files changed, 13 insertions, 52 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 6354735c780..1dc76d3979e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1,5 +1,5 @@ /* Copyright (c) 2000, 2016, Oracle and/or its affiliates. - Copyright (c) 2010, 2021, MariaDB + Copyright (c) 2010, 2022, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -805,6 +805,9 @@ int close_thread_tables(THD *thd) DBUG_PRINT("tcache", ("table: '%s' query_id: %lu", table->s->table_name.str, (ulong) table->query_id)); + if (thd->locked_tables_mode) + table->vcol_cleanup_expr(thd); + /* Detach MERGE children after every statement. Even under LOCK TABLES. */ if (thd->locked_tables_mode <= LTM_LOCK_TABLES || table->query_id == thd->query_id) @@ -941,6 +944,8 @@ void close_thread_table(THD *thd, TABLE **table_ptr) table->s->db.str, table->s->table_name.str, MDL_SHARED)); + + table->vcol_cleanup_expr(thd); table->mdl_ticket= NULL; if (table->file) @@ -1668,6 +1673,7 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx) MDL_ticket *mdl_ticket; TABLE_SHARE *share; uint gts_flags; + bool from_share= false; #ifdef WITH_PARTITION_STORAGE_ENGINE int part_names_error=0; #endif @@ -2030,6 +2036,7 @@ retry_share: /* Add table to the share's used tables list. */ tc_add_table(thd, table); + from_share= true; } if (!(flags & MYSQL_OPEN_HAS_MDL_LOCK) && @@ -2121,6 +2128,9 @@ retry_share: table_list->updatable= 1; // It is not derived table nor non-updatable VIEW table_list->table= table; + if (!from_share && table->vcol_fix_expr(thd)) + DBUG_RETURN(true); + #ifdef WITH_PARTITION_STORAGE_ENGINE if (unlikely(table->part_info)) { @@ -5389,54 +5399,6 @@ static void mark_real_tables_as_free_for_reuse(TABLE_LIST *table_list) DBUG_VOID_RETURN; } -int TABLE::fix_vcol_exprs(THD *thd) -{ - for (Field **vf= vfield; vf && *vf; vf++) - if (fix_session_vcol_expr(thd, (*vf)->vcol_info)) - return 1; - - for (Field **df= default_field; df && *df; df++) - if ((*df)->default_value && - fix_session_vcol_expr(thd, (*df)->default_value)) - return 1; - - for (Virtual_column_info **cc= check_constraints; cc && *cc; cc++) - if (fix_session_vcol_expr(thd, (*cc))) - return 1; - - return 0; -} - - -static bool fix_all_session_vcol_exprs(THD *thd, TABLE_LIST *tables) -{ - Security_context *save_security_ctx= thd->security_ctx; - TABLE_LIST *first_not_own= thd->lex->first_not_own_table(); - DBUG_ENTER("fix_session_vcol_expr"); - - int error= 0; - for (TABLE_LIST *table= tables; table && table != first_not_own && !error; - table= table->next_global) - { - TABLE *t= table->table; - if (!table->placeholder() && t->s->vcols_need_refixing && - table->lock_type >= TL_WRITE_ALLOW_WRITE) - { - Query_arena *stmt_backup= thd->stmt_arena; - if (thd->stmt_arena->is_conventional()) - thd->stmt_arena= t->expr_arena; - if (table->security_ctx) - thd->security_ctx= table->security_ctx; - - error= t->fix_vcol_exprs(thd); - - thd->security_ctx= save_security_ctx; - thd->stmt_arena= stmt_backup; - } - } - DBUG_RETURN(error); -} - /** Lock all tables in a list. @@ -5611,9 +5573,8 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, uint flags) } } - bool res= fix_all_session_vcol_exprs(thd, tables); - if (!res && !(flags & MYSQL_OPEN_IGNORE_LOGGING_FORMAT)) - res= thd->decide_logging_format(tables); + const bool res= !(flags & MYSQL_OPEN_IGNORE_LOGGING_FORMAT) && + thd->decide_logging_format(tables); DBUG_RETURN(res); } |