diff options
author | Nikita Malyavin <nikitamalyavin@gmail.com> | 2019-09-03 21:29:03 +0300 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2019-10-02 21:14:12 +1000 |
commit | 10d2a6f9464b9076db30f96375fd9ca70c0f52eb (patch) | |
tree | a27f72f52dbfc0172ba1c849ab7e8f4803908539 /sql/sql_base.cc | |
parent | 18e10e89bb7b60dc4fb0380c46e37ea4f64cab8c (diff) | |
download | mariadb-git-bb-10.5-nikita-expr-arena.tar.gz |
MDEV-16039 Crash when selecting virtual columns generated using functions with DAYNAME()bb-10.5-nikita-expr-arena
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.
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 43 |
1 files changed, 1 insertions, 42 deletions
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); } |