Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Fixed
-
1.1.7
-
None
-
None
Description
How to reproduce:
Run the attached VendorCodeExeceptionTest.java and especially the method testNoSuchTableBatchUpdate()
Pseudo code:
- Think out a good table name
- Don’t create a table (drop it to make sure it does not exist)
- Create a PreparedStatement to insert data in the non-existing table
- Add a batch to PreparedStatement
- Execute the batch
Actual:
java.lang.AssertionError: expected:<1146> but was:<0>
|
at org.mariadb.jdbc.VendorCodeExeceptionTest.testNoSuchTableBatchUpdate(VendorCodeExeceptionTest.java:78)
|
The vendor code is 0. In other words it is not set.
Expected:
The vendor code should be propagated up to the parent exception to make it easier for the program (and perhaps also to be more compatible with Mysql JDBC).
Compare with the test case testNoSuchTable(). In this case the error could should be 1146 as described at http://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
Analysis and suggested fix:
The bug is in MySQLPreparedStatement.executeBatch() and the catch clause. Every parameter except the vendorCode is passed to the constructor of BatchUpdateException. My suggestion is to add the vendorCode as a parameter.
Feel free to add my test class to the MariaDB source code.