[CONJ-215] Batched statements with rewriteBatchedStatements that end with a semicolon fails Created: 2015-11-11  Updated: 2015-11-13  Resolved: 2015-11-13

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.2.3
Fix Version/s: 1.3.0

Type: Bug Priority: Minor
Reporter: Marcelo Tamassia Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows 2012 64-bit as well as Ubuntu


Issue Links:
Relates
relates to CONJ-142 Using a semicolon in a string with "r... Closed

 Description   

The code below will throw issues with any versions above 1.1.7, including 1.2.3 when rewriteBatchedStatements=true

public static void main(String[] args) throws SQLException {
        MariaDB db = new MariaDB();
        Connection conn = db.getConnection();
        Statement sqlInsert = conn.createStatement();
        for (int i = 0; i < 100; i++) {
            sqlInsert.addBatch("insert into prep (text) values ('This is a test"+ i +"');");
        }        
        sqlInsert.executeBatch();
        conn.commit();
    }



 Comments   
Comment by Marcelo Tamassia [ 2015-11-11 ]

If I remove the ";" from the end of the SQL command the issue does not occur.

Comment by Diego Dupin [ 2015-11-11 ]

Reproduced.
That's a problem solved with "deleteEndSemicolonPattern.matcher(sql).replaceAll("");" in other methods.
That a problem specific to rewriteStatement, and this specific case is not handled.
At the same time, a 'if(rewriteBatchedStatements)" before using this regex would be good, because a regex is 100 less performant than a if in case rewriteBatchStatement is false.

Generated at Thu Feb 08 03:14:01 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.