| Bug #18041 | DataTruncation exceptions are not thrown for prepared statements | ||
|---|---|---|---|
| Submitted: | 7 Mar 2006 16:23 | Modified: | 10 Mar 2006 20:30 |
| Reporter: | Jason Gloudon | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | Connector / J | Severity: | S3 (Non-critical) |
| Version: | 3.1.12/5.00 | OS: | Linux (Linux) |
| Assigned to: | CPU Architecture: | Any | |
[7 Mar 2006 20:01]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/3555
[9 Mar 2006 20:50]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/3664
[10 Mar 2006 20:30]
Mark Matthews
Fix will be available in 5.0.1 and 3.1.13. You can try a nightly snapshot from http://downloads.mysql.com/snapshots.php#connector-j if you want to test the fix before it's officially released. Thanks for the bug report.

Description: With jdbcCompliantTruncation set to true, executing a server-side PreparedStatement that produces a data truncation warning does not throw a DataTruncation exception. Executing the same sql using a Statement does throw the DataTruncation exception. How to repeat: Using a table like this: mysql> show create table t1; +-------+------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------+------------------------------------------------------------------------------------------------------------------+ | t1 | CREATE TABLE `t1` ( `a` tinyint(4) NOT NULL, `b` char(4) default NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1 | +-------+------------------------------------------------------------------------------------------------------------------+ the following does not throw an exception with ?jdbcCompliantTruncation=true. PreparedStatement stm = connection.prepareStatement( "insert into t1 values (?,?)" ); stm.setInt( 1, 1000 ); stm.setString( 2, "nnnnnnnnnnnnnnnnnnnnnnnnnnnnnn" ); stm.executeUpdate(); Suggested fix: This appears to be due to ServerPreparedStatement.serverExecute not calling convertShowWarningsToSQLWarnings if the warning count is non-zero, as is done in MyssqlIO by sqlQueryDirect().