| Bug #43080 | A cp932 table: 2 byte character comes in INSERT to a column of CHAR(1) | ||
|---|---|---|---|
| Submitted: | 21 Feb 2009 15:23 | Modified: | 22 Feb 2009 13:38 |
| Reporter: | Hiroyuki Nishimura | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Data Types | Severity: | S2 (Serious) |
| Version: | 5.1.29 | OS: | Windows (2003 Server) |
| Assigned to: | CPU Architecture: | Any | |
[22 Feb 2009 12:13]
Valeriy Kravchuk
Sorry, but this is not a bug. Please, read http://dev.mysql.com/doc/refman/5.1/en/char.html (and http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_char-length). CHAR(N) column accepts up to N chars, not bytes.
[22 Feb 2009 13:38]
Hiroyuki Nishimura
OK, I read ... http://dev.mysql.com/doc/refman/5.1/en/char.html http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_char-length http://dev.mysql.com/doc/refman/5.1/ja/storage-requirements.html >The CHAR and VARCHAR types are declared with a length that indicates > the maximum number of characters you want to store. For example, CHAR(30) > can hold up to 30 characters. Roger! I close it. # Are these specifications good by 4.1 recognition? # In cp932 environment, are NCHAR and CHAR that it is treated the same class? # When data migration from the duties system which is Japanese Legacy, these # specifications are severe. # # When there is CHAR(1 byte) or appointment such as CHAR(1 char) like Oracle, I # am glad.

Description: Though it is Length of column of 1 byte, at a table of cp932, 2 byte character comes in INSERT like CHAR(1). How to repeat: create table hoge (col1 char(1)) ENGINE=InnoDB DEFAULT CHARSET=cp932; insert into hoge (col1) values ('ア'); # 1byte char insert into hoge (col1) values ('1'); # 1byte char insert into hoge (col1) values ('あ'); # 2byte char insert into hoge (col1) values ('い'); # 2byte char The error does not happen, and all commands succeed. select length(col1) from hoge; col1 ------ 1 1 2 2 Suggested fix: The movement that I expect ... insert into hoge (col1) values ('1'); # 1byte char ok insert into hoge (col1) values ('あ'); # 2byte char error (...Because the reason is 2 bytes)