summaryrefslogtreecommitdiff
path: root/sql/field.cc
diff options
context:
space:
mode:
authorunknown <bar@bar.mysql.r18.ru>2003-08-11 18:18:34 +0500
committerunknown <bar@bar.mysql.r18.ru>2003-08-11 18:18:34 +0500
commit0960c3eb26861238d9102845d370f3eb66d91290 (patch)
tree3818f3663ab056711a4b873e3abb17725b1cb138 /sql/field.cc
parentf3f6e5e9b2ecfef9bf6c5e7558af2481e30385ad (diff)
downloadmariadb-git-0960c3eb26861238d9102845d370f3eb66d91290.tar.gz
Fix: create table t1 (a char(10) character set cp1251) SELECT _koi8r'blabla' as a
The above query created a field of koi8r charset, not cp1251 Change: CREATE TABLE a (a CHAR(1) CHARACTER SET utf8) Length now means character length, not byte length. The above creates a field that guarantees can store a multibyte value 1 character long. For utf8 the above creates a field that can store 3 bytes.
Diffstat (limited to 'sql/field.cc')
-rw-r--r--sql/field.cc24
1 files changed, 22 insertions, 2 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 2f89dd43c3f..c25f1170b00 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -4012,7 +4012,7 @@ void Field_string::sql_type(String &res) const
(table->db_options_in_use &
HA_OPTION_PACK_RECORD) ?
"varchar" : "char"),
- (int) field_length);
+ (int) field_length / charset()->mbmaxlen);
res.length(length);
}
@@ -4178,7 +4178,7 @@ void Field_varstring::sql_type(String &res) const
CHARSET_INFO *cs=res.charset();
ulong length= cs->cset->snprintf(cs,(char*) res.ptr(),
res.alloced_length(),"varchar(%u)",
- field_length);
+ field_length / charset()->mbmaxlen);
res.length(length);
}
@@ -5267,6 +5267,26 @@ bool Field_num::eq_def(Field *field)
** Handling of field and create_field
*****************************************************************************/
+void create_field::create_length_to_internal_length(void)
+{
+ switch (sql_type)
+ {
+ case MYSQL_TYPE_TINY_BLOB:
+ case MYSQL_TYPE_MEDIUM_BLOB:
+ case MYSQL_TYPE_LONG_BLOB:
+ case MYSQL_TYPE_BLOB:
+ case MYSQL_TYPE_VAR_STRING:
+ case MYSQL_TYPE_STRING:
+ length*= charset->mbmaxlen;
+ pack_length= calc_pack_length(sql_type == FIELD_TYPE_VAR_STRING ?
+ FIELD_TYPE_STRING : sql_type, length);
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+}
+
/*
Make a field from the .frm file info
*/