From bc902a2bfc46add0708896c07621e3707f66d95f Mon Sep 17 00:00:00 2001 From: Alexander Barkov Date: Fri, 13 Mar 2015 16:12:54 +0400 Subject: MDEV-7387 [PATCH] Alter table xxx CHARACTER SET utf8, CONVERT TO CHARACTER SET latin1 should fail A contribution from Daniel Black, with minor additional enhancements. --- sql/handler.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'sql/handler.h') diff --git a/sql/handler.h b/sql/handler.h index 4222270e9c4..2e219d5f3cc 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -1637,6 +1637,33 @@ struct HA_CREATE_INFO bool table_was_deleted; bool tmp_table() { return options & HA_LEX_CREATE_TMP_TABLE; } + 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 + TODO: Should'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; + table_charset= default_table_charset= cs; + used_fields|= (HA_CREATE_USED_CHARSET | HA_CREATE_USED_DEFAULT_CHARSET); + return false; + } }; -- cgit v1.2.1