summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc63
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)