diff options
author | Alexander Barkov <bar@mariadb.com> | 2022-05-17 12:52:23 +0400 |
---|---|---|
committer | Alexander Barkov <bar@mariadb.com> | 2022-05-24 09:36:15 +0400 |
commit | 208addf48444c0a36a2cc16cd2558ae694e905d5 (patch) | |
tree | c2aebdda04bcae22ff6924187fcecf7c5d653336 /sql/handler.h | |
parent | 89adedcb9f0a45483b9917e93310241a4976d4c2 (diff) | |
download | mariadb-git-208addf48444c0a36a2cc16cd2558ae694e905d5.tar.gz |
Main patch MDEV-27896 Wrong result upon `COLLATE latin1_bin CHARACTER SET latin1` on the table or the database level
Also fixes
MDEV-27782 Wrong columns when using table level `CHARACTER SET utf8mb4 COLLATE DEFAULT`
MDEV-28644 Unexpected error on ALTER TABLE t1 CONVERT TO CHARACTER SET utf8mb3, DEFAULT CHARACTER SET utf8mb4
Diffstat (limited to 'sql/handler.h')
-rw-r--r-- | sql/handler.h | 78 |
1 files changed, 51 insertions, 27 deletions
diff --git a/sql/handler.h b/sql/handler.h index 036c4917b94..60c6195e68e 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -2289,33 +2289,6 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, Schema_specification_st::init(); alter_info= NULL; } - bool check_conflicting_charset_declarations(CHARSET_INFO *cs); - bool add_table_option_default_charset(CHARSET_INFO *cs) - { - // cs can be NULL, e.g.: CREATE TABLE t1 (..) CHARACTER SET DEFAULT; - if (check_conflicting_charset_declarations(cs)) - return true; - default_table_charset= cs; - used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; - return false; - } - bool add_alter_list_item_convert_to_charset(CHARSET_INFO *cs) - { - /* - cs cannot be NULL, as sql_yacc.yy translates - CONVERT TO CHARACTER SET DEFAULT - to - CONVERT TO CHARACTER SET <character-set-of-the-current-database> - TODO: Shouldn't we postpone resolution of DEFAULT until the - character set of the table owner database is loaded from its db.opt? - */ - DBUG_ASSERT(cs); - if (check_conflicting_charset_declarations(cs)) - return true; - alter_table_convert_to_charset= default_table_charset= cs; - used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET); - return false; - } ulong table_options_with_row_type() { if (row_type == ROW_TYPE_DYNAMIC || row_type == ROW_TYPE_PAGE) @@ -2323,6 +2296,10 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, else return table_options; } + bool resolve_to_charset_collation_context(THD *thd, + const Lex_table_charset_collation_attrs_st &default_cscl, + const Lex_table_charset_collation_attrs_st &convert_cscl, + const Charset_collation_context &ctx); }; @@ -2333,16 +2310,23 @@ struct HA_CREATE_INFO: public Table_scope_and_contents_source_st, struct Table_specification_st: public HA_CREATE_INFO, public DDL_options_st { + Lex_table_charset_collation_attrs_st default_charset_collation; + Lex_table_charset_collation_attrs_st convert_charset_collation; + // Deep initialization void init() { HA_CREATE_INFO::init(); DDL_options_st::init(); + default_charset_collation.init(); + convert_charset_collation.init(); } void init(DDL_options_st::Options options_arg) { HA_CREATE_INFO::init(); DDL_options_st::init(options_arg); + default_charset_collation.init(); + convert_charset_collation.init(); } /* Quick initialization, for parser. @@ -2354,6 +2338,46 @@ struct Table_specification_st: public HA_CREATE_INFO, { HA_CREATE_INFO::options= 0; DDL_options_st::init(); + default_charset_collation.init(); + convert_charset_collation.init(); + } + + bool add_table_option_convert_charset(CHARSET_INFO *cs) + { + // cs can be NULL, e.g.: ALTER TABLE t1 CONVERT TO CHARACTER SET DEFAULT; + used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET); + return cs ? + convert_charset_collation.merge_exact_charset(Lex_exact_charset(cs)) : + convert_charset_collation.merge_charset_default(); + } + bool add_table_option_convert_collation(const Lex_extended_collation_st &cl) + { + used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET); + return convert_charset_collation.merge_collation(cl); + } + + bool add_table_option_default_charset(CHARSET_INFO *cs) + { + // cs can be NULL, e.g.: CREATE TABLE t1 (..) CHARACTER SET DEFAULT; + used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + return cs ? + default_charset_collation.merge_exact_charset(Lex_exact_charset(cs)) : + default_charset_collation.merge_charset_default(); + } + bool add_table_option_default_collation(const Lex_extended_collation_st &cl) + { + used_fields|= HA_CREATE_USED_DEFAULT_CHARSET; + return default_charset_collation.merge_collation(cl); + } + + bool resolve_to_charset_collation_context(THD *thd, + const Charset_collation_context &ctx) + { + return HA_CREATE_INFO:: + resolve_to_charset_collation_context(thd, + default_charset_collation, + convert_charset_collation, + ctx); } }; |