From 10d2a6f9464b9076db30f96375fd9ca70c0f52eb Mon Sep 17 00:00:00 2001 From: Nikita Malyavin Date: Tue, 3 Sep 2019 21:29:03 +0300 Subject: MDEV-16039 Crash when selecting virtual columns generated using functions with DAYNAME() Due to collation specifics an Item tree could change while fixing. Virtual fields. 1. This should be done on the correct query arena, which is table->expr_arena. 2. Doing it once per table open is enough. Furthermore, fixing virtual exprs after open sets the collation to the one definde by `SET NAMES`, which is incorrect: only the native table collation should be used, and it shouldn't be changed after the table is created. --- sql/sql_base.cc | 43 +------------------------------------------ 1 file changed, 1 insertion(+), 42 deletions(-) (limited to 'sql/sql_base.cc') diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 7ac0dcad596..ff9575bb478 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5388,45 +5388,6 @@ static void mark_real_tables_as_free_for_reuse(TABLE_LIST *table_list) } -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"); - - for (TABLE_LIST *table= tables; table && table != first_not_own; - table= table->next_global) - { - TABLE *t= table->table; - if (!table->placeholder() && t->s->vcols_need_refixing && - table->lock_type >= TL_WRITE_ALLOW_WRITE) - { - if (table->security_ctx) - thd->security_ctx= table->security_ctx; - - for (Field **vf= t->vfield; vf && *vf; vf++) - if (fix_session_vcol_expr(thd, (*vf)->vcol_info)) - goto err; - - for (Field **df= t->default_field; df && *df; df++) - if ((*df)->default_value && - fix_session_vcol_expr(thd, (*df)->default_value)) - goto err; - - for (Virtual_column_info **cc= t->check_constraints; cc && *cc; cc++) - if (fix_session_vcol_expr(thd, (*cc))) - goto err; - - thd->security_ctx= save_security_ctx; - } - } - DBUG_RETURN(0); -err: - thd->security_ctx= save_security_ctx; - DBUG_RETURN(1); -} - - /** Lock all tables in a list. @@ -5587,9 +5548,7 @@ bool lock_tables(THD *thd, TABLE_LIST *tables, uint count, uint flags) } } - bool res= fix_all_session_vcol_exprs(thd, tables); - if (!res) - res= thd->decide_logging_format(tables); + bool res= thd->decide_logging_format(tables); DBUG_RETURN(res); } -- cgit v1.2.1