[CONJ-283] MariaDbClientPreparedStatement - syntax error on insert values Created: 2016-04-18  Updated: 2016-04-25  Resolved: 2016-04-22

Status: Closed
Project: MariaDB Connector/J
Component/s: Other
Affects Version/s: 1.4.0, 1.3.7, 1.4.1, 1.4.2
Fix Version/s: 1.4.3

Type: Bug Priority: Major
Reporter: or gerson Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows\linux connecting to MySQL 5.5.X


Issue Links:
Duplicate
is duplicated by CONJ-277 Incorrect error when dealing with typ... Closed
is duplicated by CONJ-287 Invalid query generated on prepared s... Closed

 Description   

When either by configuration of "useServerPrepStmts=false"
Or when MariaDbServerPreparedStatement.prepare has failed (the reason here does not matter , probably because of high load)
and the MariaDbConnection fallback is MariaDbClientPreparedStatement.

a query such as "INSERT INTO mytable VALUES (?,?) , (?,?)"
is broken down to the following query parts (using function createRewritableParts):
[0] INSERT INTO mytable VALUES
[1] (
[2] ,
[3] )
[4] ,(
[5] ,
[6] )

this results in the final query to be sent as:
INSERT INTO mytable VALUES ( param[0],param[1])param[3],(param[4],)

results in syntax error.

i have checked the older code of version 1.1.8 (before 1.3.0, and 1.1.8 is the version i used before)

in that version in class MySQLParameterizedQuery the createQueryParts
breaks down the query like this:

[0] INSERT INTO mytable VALUES (
[1] ,
[2] ),(
[3] ,
[4] )

and then the query is sent correctly to the DB



 Comments   
Comment by Christian Ciach [ 2016-04-21 ]

The same happens with a statement like this:

INSERT INTO mytable (key, value) VALUES (?,?) ON DUPLICATE KEY UPDATE value = ?

If called with the parameters "1,2,3" the resulting query will look like this:

INSERT INTO mytable (key, value) VALUES (1,2)3 ON DUPLICATE KEY UPDATE value =

Comment by Diego Dupin [ 2016-04-22 ]

correction done in commits:

Correction release 1.4.3 will be done shortly and available on maven central tomorrow (due to replication time).

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