@@ -2040,6 +2040,9 @@ bool open_table(THD *thd, TABLE_LIST *table_list, Open_table_context *ot_ctx)
20402040 table_list->updatable = 1 ; // It is not derived table nor non-updatable VIEW
20412041 table_list->table = table;
20422042
2043+ if (table->vcol_fix_exprs (thd))
2044+ goto err_lock;
2045+
20432046#ifdef WITH_PARTITION_STORAGE_ENGINE
20442047 if (unlikely (table->part_info ))
20452048 {
@@ -5290,52 +5293,44 @@ static void mark_real_tables_as_free_for_reuse(TABLE_LIST *table_list)
52905293 }
52915294}
52925295
5293- int TABLE::fix_vcol_exprs (THD *thd)
5296+ bool TABLE::vcol_fix_exprs (THD *thd)
52945297{
5298+ if (pos_in_table_list->placeholder () || !s->vcols_need_refixing ||
5299+ pos_in_table_list->lock_type < TL_WRITE_ALLOW_WRITE)
5300+ return false ;
5301+
5302+ DBUG_ASSERT (pos_in_table_list != thd->lex ->first_not_own_table ());
5303+
5304+ bool result= true ;
5305+ Security_context *save_security_ctx= thd->security_ctx ;
5306+ Query_arena *stmt_backup= thd->stmt_arena ;
5307+ if (thd->stmt_arena ->is_conventional ())
5308+ thd->stmt_arena = expr_arena;
5309+
5310+ if (pos_in_table_list->security_ctx )
5311+ thd->security_ctx = pos_in_table_list->security_ctx ;
5312+
5313+
52955314 for (Field **vf= vfield; vf && *vf; vf++)
5296- if (fix_session_vcol_expr (thd, ( *vf)->vcol_info ))
5297- return 1 ;
5315+ if (( *vf)->vcol_info -> fix_session_expr (thd ))
5316+ goto end ;
52985317
52995318 for (Field **df= default_field; df && *df; df++)
53005319 if ((*df)->default_value &&
5301- fix_session_vcol_expr (thd, ( *df)->default_value ))
5302- return 1 ;
5320+ ( *df)->default_value -> fix_session_expr (thd ))
5321+ goto end ;
53035322
53045323 for (Virtual_column_info **cc= check_constraints; cc && *cc; cc++)
5305- if (fix_session_vcol_expr (thd, (*cc)))
5306- return 1 ;
5307-
5308- return 0 ;
5309- }
5310-
5311-
5312- static bool fix_all_session_vcol_exprs (THD *thd, TABLE_LIST *tables)
5313- {
5314- Security_context *save_security_ctx= thd->security_ctx ;
5315- TABLE_LIST *first_not_own= thd->lex ->first_not_own_table ();
5316- DBUG_ENTER (" fix_session_vcol_expr" );
5324+ if ((*cc)->fix_session_expr (thd))
5325+ goto end;
53175326
5318- int error= 0 ;
5319- for (TABLE_LIST *table= tables; table && table != first_not_own && !error;
5320- table= table->next_global )
5321- {
5322- TABLE *t= table->table ;
5323- if (!table->placeholder () && t->s ->vcols_need_refixing &&
5324- table->lock_type >= TL_WRITE_ALLOW_WRITE)
5325- {
5326- Query_arena *stmt_backup= thd->stmt_arena ;
5327- if (thd->stmt_arena ->is_conventional ())
5328- thd->stmt_arena = t->expr_arena ;
5329- if (table->security_ctx )
5330- thd->security_ctx = table->security_ctx ;
5327+ result= false ;
53315328
5332- error= t->fix_vcol_exprs (thd);
5329+ end:
5330+ thd->security_ctx = save_security_ctx;
5331+ thd->stmt_arena = stmt_backup;
53335332
5334- thd->security_ctx = save_security_ctx;
5335- thd->stmt_arena = stmt_backup;
5336- }
5337- }
5338- DBUG_RETURN (error);
5333+ return result;
53395334}
53405335
53415336
@@ -5500,9 +5495,7 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count,
55005495 }
55015496 }
55025497
5503- bool res= fix_all_session_vcol_exprs (thd, tables);
5504- if (!res)
5505- res= thd->decide_logging_format (tables);
5498+ const bool res= thd->decide_logging_format (tables);
55065499
55075500 DBUG_RETURN (res);
55085501}
0 commit comments