1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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.
This commit is contained in:
ramil/ram@mysql.com/myoffice.izhnet.ru
2006-08-15 15:24:07 +05:00
parent 7ff64de172
commit 6660f98b64
6 changed files with 63 additions and 34 deletions

View File

@ -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)