diff options
author | Aleksey Midenkov <midenok@gmail.com> | 2021-05-27 20:54:19 +0300 |
---|---|---|
committer | Aleksey Midenkov <midenok@gmail.com> | 2021-09-29 21:21:25 +0300 |
commit | 56a3e6557cfaaf9d90ca0755a46c1f8a4a485101 (patch) | |
tree | 86f511ecf3bdc39c5a7efe280b5f0745427893db /sql/sql_class.h | |
parent | 38dc726d268839a62e2beb45ef4330978418a57f (diff) | |
download | mariadb-git-MDEV-24176/10.3_old.tar.gz |
MDEV-24176 Server crashes after insert in the table with virtualbb-10.3-midenok-MDEV-24176MDEV-24176/10.3_old
column generated using date_format() and if()
When table is reopened from cache vcol_info contains stale
expression. We refresh expression via TABLE::vcol_fix_exprs() but
first we must prepare a proper context (Vcol_expr_context) and do some
preparations which meet some requirements:
1. fields must not be fixed, we unfix them with cleanup() via
cleanup_processor.
2. Item_ident must have cached_table cleared. Again, this is stale
data which was already freed. cached_table interferes with
find_field_in_tables().
We cannot clear cached_table directly in Item_ident::cleanup()
method. Lots of spaghetti logic depends on cached_table existence even
after cleanup() done.
3. If Item_ident has table_name non-NULL we trigger expr update. That
is done via Item_ident::check_vcol_func_processor() and
VCOL_TABLE_ALIAS flag.
(4-7) The below conditions are prepared by Vcol_expr_context and used in
both fix_session_expr_for_read() and TABLE::vcol_fix_exprs():
4. Any fix_expr() must be done on expr_arena as there may be new items
created. It was a bug in fix_session_expr_for_read(). It was just not
reproduced because there were no second refix. Now refix is done for
more cases so it does reproduce. Tests affected: vcol.binlog
5. Also name resolution context must be narrowed to the single table
with all crutches in place. Tests affected: vcol.update
6. sql_mode must be clean and not fail expr update.
sql_mode such as MODE_NO_BACKSLASH_ESCAPES, MODE_NO_ZERO_IN_DATE, etc
must not affect vcol expression update. If the table was created
successfully any further evaluation must not fail. Tests affected:
main.func_like
7. Warnings are disabled during expr update. It is assumed that these
warnings were printed before during initialization phase or later
during execution phase. Tests affected: vcol.wrong_arena
Dictionary: refresh, update and refix are the synonyms for
vcol_fix_exprs() or fix_session_expr_for_read() calls.
8. cleanup_excluding_fields_processor() removed. It was just a quick
hack to exclude wrongly working Item_field from processing. Now it
works due to correct execution environment (see next commit). Related
to MDEV-10355.
Diffstat (limited to 'sql/sql_class.h')
-rw-r--r-- | sql/sql_class.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index 133c0f6fec5..fe42909aa0a 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -1831,6 +1831,25 @@ private: }; +struct Silence_warnings : public Internal_error_handler +{ +public: + virtual bool handle_condition(THD *, + uint, + const char* sqlstate, + Sql_condition::enum_warning_level *level, + const char* msg, + Sql_condition ** cond_hdl) + { + *cond_hdl= NULL; + if (*level == Sql_condition::WARN_LEVEL_WARN) + return TRUE; + + return FALSE; + } +}; + + /** Internal error handler to process an error from MDL_context::upgrade_lock() and mysql_lock_tables(). Used by implementations of HANDLER READ and |