Details
-
Bug
-
Status: Closed (View Workflow)
-
Blocker
-
Resolution: Fixed
-
2.3.0
-
None
Description
If the prepared statement has two or more consecutive clauses with ESCAPE, the parsed statement will be only split into two parts instead of three in ClientPrepareResult#parameterParts.
An example Java code to reproduce the issue:
|
try (PreparedStatement preparedStatement = connection.prepareStatement("select * from my_db.my_table where my_db.my_table.id = ? and (my_db.my_table.username like lower(?) escape '\\\\' or my_db.my_table.firstname like lower(?) escape '\\\\');"))
|
{
|
preparedStatement.setString(1, "1");
|
preparedStatement.setString(2, "user%");
|
preparedStatement.setString(3, "user%");
|
ResultSet rs = preparedStatement.executeQuery();
|
}
|
catch (SQLException e)
|
{
|
e.printStackTrace();
|
}
|
Results with an exception:
java.sql.SQLException: Could not set parameter at position 3 (values was 'user%')
|
Query - conn:125(M) - "select * from my_db.my_table where my_db.my_table.id = ? and (my_db.my_table.username like lower(?) escape '\\' or my_db.my_table.firstname like lower(?) escape '\\');"
|
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getSqlException(ExceptionMapper.java:271)
|
at org.mariadb.jdbc.MariaDbPreparedStatementClient.setParameter(MariaDbPreparedStatementClient.java:480)
|
at org.mariadb.jdbc.BasePrepareStatement.setString(BasePrepareStatement.java:1533)
|
This is not reproduced on 2.0.1 version of the driver.
Attachments
Issue Links
- relates to
-
CONJ-664 SQLException when backslash (\), which doesn't escape any character, is used together with setParameter()
- Closed