Below is the list of changes that have just been committed into a local
4.1 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2006-08-15 15:24:07+05:00, ramil@stripped +6 -0
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@stripped, 2006-08-15 15:24:03+05:00, ramil@stripped +11
-0
Fix for bug #20695: Charset introducer overrides charset definition for column.
- test result.
mysql-test/t/ctype_recoding.test@stripped, 2006-08-15 15:24:03+05:00, ramil@stripped +12 -0
Fix for bug #20695: Charset introducer overrides charset definition for column.
- test case.
sql/sql_lex.cc@stripped, 2006-08-15 15:24:03+05:00, ramil@stripped +3 -2
Fix for bug #20695: Charset introducer overrides charset definition for column.
- LEX->underscore_charset introduced to store UNDERSCORE_CHARSET
sql/sql_lex.h@stripped, 2006-08-15 15:24:03+05:00, ramil@stripped +1 -1
Fix for bug #20695: Charset introducer overrides charset definition for column.
- LEX->underscore_charset introduced to store UNDERSCORE_CHARSET
sql/sql_table.cc@stripped, 2006-08-15 15:24:03+05:00, ramil@stripped +34 -29
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@stripped, 2006-08-15 15:24:03+05:00, ramil@stripped +2 -2
Fix for bug #20695: Charset introducer overrides charset definition for column.
- LEX->underscore_charset introduced to store UNDERSCORE_CHARSET
# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: ramil
# Host: myoffice.izhnet.ru
# Root: /usr/home/ram/work/4.1.b20695
--- 1.154/sql/sql_lex.cc 2006-08-15 15:24:13 +05:00
+++ 1.155/sql/sql_lex.cc 2006-08-15 15:24:13 +05:00
@@ -643,8 +643,9 @@
*/
if ((yylval->lex_str.str[0]=='_') &&
- (lex->charset=get_charset_by_csname(yylval->lex_str.str+1,
- MY_CS_PRIMARY,MYF(0))))
+ (lex->underscore_charset=
+ get_charset_by_csname(yylval->lex_str.str + 1,
+ MY_CS_PRIMARY,MYF(0))))
return(UNDERSCORE_CHARSET);
return(result_state); // IDENT or IDENT_QUOTED
--- 1.189/sql/sql_lex.h 2006-08-15 15:24:13 +05:00
+++ 1.190/sql/sql_lex.h 2006-08-15 15:24:13 +05:00
@@ -613,7 +613,7 @@
LEX_USER *grant_user;
gptr yacc_yyss,yacc_yyvs;
THD *thd;
- CHARSET_INFO *charset;
+ CHARSET_INFO *charset, *underscore_charset;
List<key_part_spec> col_list;
List<key_part_spec> ref_list;
--- 1.307/sql/sql_table.cc 2006-08-15 15:24:13 +05:00
+++ 1.308/sql/sql_table.cc 2006-08-15 15:24:13 +05:00
@@ -516,6 +516,40 @@
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)
{
@@ -578,35 +612,6 @@
}
}
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)
--- 1.398/sql/sql_yacc.yy 2006-08-15 15:24:13 +05:00
+++ 1.399/sql/sql_yacc.yy 2006-08-15 15:24:13 +05:00
@@ -4896,7 +4896,7 @@
| NCHAR_STRING
{ $$= new Item_string($1.str,$1.length,national_charset_info); }
| UNDERSCORE_CHARSET TEXT_STRING
- { $$ = new Item_string($2.str,$2.length,Lex->charset); }
+ { $$ = new Item_string($2.str,$2.length,Lex->underscore_charset); }
| text_literal TEXT_STRING_literal
{ ((Item_string*) $1)->append($2.str,$2.length); }
;
@@ -4963,7 +4963,7 @@
(String*) 0;
$$= new Item_string(str ? str->ptr() : "",
str ? str->length() : 0,
- Lex->charset);
+ Lex->underscore_charset);
}
| DATE_SYM text_literal { $$ = $2; }
| TIME_SYM text_literal { $$ = $2; }
--- 1.25/mysql-test/r/ctype_recoding.result 2006-08-15 15:24:13 +05:00
+++ 1.26/mysql-test/r/ctype_recoding.result 2006-08-15 15:24:13 +05:00
@@ -247,3 +247,14 @@
select rpad(c1,3,'ö'), rpad('ö',3,c1) from t1;
rpad(c1,3,'ö') rpad('ö',3,c1)
ßöö ößß
+drop table t1;
+set names koi8r;
+create table t1(a char character set cp1251 default _koi8r 0xFF);
+show create table t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `a` char(1) character set cp1251 default 'ÿ'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+drop table t1;
+create table t1(a char character set latin1 default _cp1251 0xFF);
+ERROR 42000: Invalid default value for 'a'
--- 1.21/mysql-test/t/ctype_recoding.test 2006-08-15 15:24:13 +05:00
+++ 1.22/mysql-test/t/ctype_recoding.test 2006-08-15 15:24:13 +05:00
@@ -186,5 +186,17 @@
# TODO
#select case c1 when 'ß' then 'ß' when 'ö' then 'ö' else 'c' end from t1;
#select export_set(5,c1,'ö'), export_set(5,'ö',c1) from t1;
+drop table t1;
+
+#
+# Bug 20695: problem with field default value's character set
+#
+
+set names koi8r;
+create table t1(a char character set cp1251 default _koi8r 0xFF);
+show create table t1;
+drop table t1;
+--error 1067
+create table t1(a char character set latin1 default _cp1251 0xFF);
# End of 4.1 tests
| Thread |
|---|
| • bk commit into 4.1 tree (ramil:1.2530) BUG#20695 | ramil | 15 Aug |