Bug #12400 | Truncation in TEXT colums when using utf8 | ||
---|---|---|---|
Submitted: | 5 Aug 2005 14:59 | Modified: | 8 Aug 2005 10:52 |
Reporter: | eric cournarie | Email Updates: | |
Status: | Duplicate | Impact on me: | |
Category: | Connector / J | Severity: | S1 (Critical) |
Version: | 3.10 | OS: | Windows (Windows) |
Assigned to: | CPU Architecture: | Any |
[5 Aug 2005 14:59]
eric cournarie
[5 Aug 2005 15:12]
eric cournarie
sorry , you should server version 4.1.11 , not 1.11 here is also my mySQL variables values character_set_client | utf8 character_set_connection | utf8 character_set_database | utf8 character_set_results | utf8 character_set_server | utf8 character_set_system | utf8
[5 Aug 2005 21:21]
Aleksey Kishkin
eric, we need repeatable testcase in order to find the cause of this bug. Could you please give us example of such string?
[8 Aug 2005 8:56]
eric cournarie
create a table like this: create table testtable { a TEXT }; program to test; String nonAsciiChars = "\u0167\u0167\u0167\u0167\u0167\u0167\u0167\u0167\u0167\u0167"; String endMarker = "This should appear at the end of this string."; // max size of a string in utf8 int maxCount = (65536 / 3); StringBuffer myData = new StringBuffer (); for (int i =0; i < (maxCount - nonAsciiChars.length() - endMarker.length()); i++) myData.append ("*"); // just for filling the string // add non ascii characters myData.append(nonAsciiChars); // add the end marker of the string myData.append(endMarker); String value = myData.toString(); // just for checking System.out.println("Inserting a string of size " + value.length()); String sqlInsert = "INSERT INTO testtable VALUES ( ? )"; PreparedStatement ps = connexion.prepareStatement(sqlInsert); ps.setCharacterStream (1, new StringReader (value), value.length()); ps.execute(); String sqlGet = "SELECT * FROM testtable"; ps = connexion.prepareStatement(sqlGet); ResultSet rs = ps.executeQuery(); rs.next(); int dataColumnId = rs.findColumn("a"); Clob clob = rs.getClob (dataColumnId); String v = clob.getSubString(1L, (int) clob.length()); System.out.println(" end read : " + v.substring(v.length() -50)); the output gives me Inserting a string of size 21845 end read : *****??????????This should appear at the end of th the string appear truncated . by doing a select * in MySQL directly, the same appear. so I think it's really at the time we write the data. note also that when you add more non-ascii chars in nonAsciiChars , the truncation grows..
[8 Aug 2005 10:52]
Aleksey Kishkin
Hi! it looks like a duplicate of http://bugs.mysql.com/bug.php?id=11614