diff options
author | unknown <ramil/ram@mysql.com/myoffice.izhnet.ru> | 2006-08-15 15:24:07 +0500 |
---|---|---|
committer | unknown <ramil/ram@mysql.com/myoffice.izhnet.ru> | 2006-08-15 15:24:07 +0500 |
commit | fe3dee0621a23136c33c6b7085a6846353b1f797 (patch) | |
tree | 9289acda2813d8ab3ca166135876433070eb4b32 /sql/sql_table.cc | |
parent | ef6019010da0a55f018e7f37a8d191236d9202ca (diff) | |
download | mariadb-git-fe3dee0621a23136c33c6b7085a6846353b1f797.tar.gz |
Fix for bug #20695: Charset introducer overrides charset definition for column.
- if there are two character set definitions in the column declaration,
we replace the first one with the second one as we store both in the LEX->charset
slot. Add a separate slot to the LEX structure to store underscore charset.
- convert default values to the column charset of STRING, VARSTRING fields
if necessary as well.
mysql-test/r/ctype_recoding.result:
Fix for bug #20695: Charset introducer overrides charset definition for column.
- test result.
mysql-test/t/ctype_recoding.test:
Fix for bug #20695: Charset introducer overrides charset definition for column.
- test case.
sql/sql_lex.cc:
Fix for bug #20695: Charset introducer overrides charset definition for column.
- LEX->underscore_charset introduced to store UNDERSCORE_CHARSET
sql/sql_lex.h:
Fix for bug #20695: Charset introducer overrides charset definition for column.
- LEX->underscore_charset introduced to store UNDERSCORE_CHARSET
sql/sql_table.cc:
Fix for bug #20695: Charset introducer overrides charset definition for column.
- convert default values to the column charset of VARSTRING, STRING, ENUM,
SET fields if necessary.
sql/sql_yacc.yy:
Fix for bug #20695: Charset introducer overrides charset definition for column.
- LEX->underscore_charset introduced to store UNDERSCORE_CHARSET
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 631d2d89bbb..a5cb0d45664 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -516,6 +516,40 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(-1); } + /* + Convert the default value character + set into the column character set if necessary. + */ + if (sql_field->def && + savecs != sql_field->def->collation.collation && + (sql_field->sql_type == FIELD_TYPE_VAR_STRING || + sql_field->sql_type == FIELD_TYPE_STRING || + sql_field->sql_type == FIELD_TYPE_SET || + sql_field->sql_type == FIELD_TYPE_ENUM)) + { + Item_arena backup_arena; + bool need_to_change_arena= + !thd->current_arena->is_conventional_execution(); + if (need_to_change_arena) + { + /* Assert that we don't do that at every PS execute */ + DBUG_ASSERT(thd->current_arena->is_first_stmt_execute()); + thd->set_n_backup_item_arena(thd->current_arena, &backup_arena); + } + + sql_field->def= sql_field->def->safe_charset_converter(savecs); + + if (need_to_change_arena) + thd->restore_backup_item_arena(thd->current_arena, &backup_arena); + + if (sql_field->def == NULL) + { + /* Could not convert */ + my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name); + DBUG_RETURN(-1); + } + } + if (sql_field->sql_type == FIELD_TYPE_SET || sql_field->sql_type == FIELD_TYPE_ENUM) { @@ -580,35 +614,6 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->interval_list.empty(); // Don't need interval_list anymore } - /* - Convert the default value from client character - set into the column character set if necessary. - */ - if (sql_field->def && cs != sql_field->def->collation.collation) - { - Item_arena backup_arena; - bool need_to_change_arena= - !thd->current_arena->is_conventional_execution(); - if (need_to_change_arena) - { - /* Asser that we don't do that at every PS execute */ - DBUG_ASSERT(thd->current_arena->is_first_stmt_execute()); - thd->set_n_backup_item_arena(thd->current_arena, &backup_arena); - } - - sql_field->def= sql_field->def->safe_charset_converter(cs); - - if (need_to_change_arena) - thd->restore_backup_item_arena(thd->current_arena, &backup_arena); - - if (sql_field->def == NULL) - { - /* Could not convert */ - my_error(ER_INVALID_DEFAULT, MYF(0), sql_field->field_name); - DBUG_RETURN(-1); - } - } - if (sql_field->sql_type == FIELD_TYPE_SET) { if (sql_field->def != NULL) |