diff options
author | unknown <konstantin@mysql.com> | 2006-02-21 19:52:20 +0300 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2006-02-21 19:52:20 +0300 |
commit | 9cf3f255bded9642b6b6b23b4510514c08bcbe84 (patch) | |
tree | 94108427c4a6010330c5f629808e88a1ab43f158 /sql/sql_table.cc | |
parent | 1e686ae7702d297cc9fd261c42864653f4fdd7b3 (diff) | |
download | mariadb-git-9cf3f255bded9642b6b6b23b4510514c08bcbe84.tar.gz |
A fix and a test case for Bug#13134 "Length of VARCHAR() utf8
column is increasing when table is recreated with PS/SP":
make use of create_field::char_length more consistent in the code.
Reinit create_field::length from create_field::char_length
for every execution of a prepared statement (actually fixes the
bug).
mysql-test/r/ps.result:
Test results fixed (Bug#13134)
mysql-test/t/ps.test:
A test case for Bug#13134 "Length of VARCHAR() utf8 column is
increasing when table is recreated with PS/SP"
sql/field.cc:
Move initialization of create_field::char_length to the constructor
of create_field.
sql/field.h:
Rename chars_length to char_length (to be consistent with
how this term is used throughout the rest of the code).
sql/sql_parse.cc:
Initialize char_length in add_field_to_list. This function
effectively works as another create_field constructor.
sql/sql_table.cc:
Reinit length from char_length for every field in
mysql_prepare_table. This is not needed if we're executing
a statement for the first time, however, at subsequent executions
length contains the number of bytes, not characters (as it's expected
to).
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r-- | sql/sql_table.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 71cbc0be1e3..616db8b0424 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -488,6 +488,12 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, for (field_no=0; (sql_field=it++) ; field_no++) { + /* + Initialize length from its original value (number of characters), + which was set in the parser. This is necessary if we're + executing a prepared statement for the second time. + */ + sql_field->length= sql_field->char_length; if (!sql_field->charset) sql_field->charset= create_info->default_table_charset; /* @@ -665,7 +671,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->charset= (dup_field->charset ? dup_field->charset : create_info->default_table_charset); - sql_field->length= dup_field->chars_length; + sql_field->length= dup_field->char_length; sql_field->pack_length= dup_field->pack_length; sql_field->create_length_to_internal_length(); sql_field->decimals= dup_field->decimals; |