[CONJ-664] SQLException when backslash (\), which doesn't escape any character, is used together with setParameter() Created: 2018-12-04  Updated: 2022-12-15  Resolved: 2018-12-14

Status: Closed
Project: MariaDB Connector/J
Component/s: protocol
Affects Version/s: 2.3.0, 2.2.6
Fix Version/s: 2.4.0

Type: Bug Priority: Major
Reporter: Leonid M. Assignee: Diego Dupin
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Blocks
blocks CONJ-618 Client preparestatement parsing error... Closed
Duplicate
is duplicated by CONJ-1034 Issue with escape character + questio... Closed
Problem/Incident
causes CONJ-740 client-side failure to parse Prepared... Closed
Relates
relates to CONJ-662 SQLException on PreparedStatement wit... Closed
relates to CONJ-668 Prepared Statement parser incorrectly... Closed

 Description   

In the following description it is not possible to write two backslashes after each other. That's why I wrote '\ \' with space between in meaning two following backslashes without space.

Commit https://github.com/MariaDB/mariadb-connector-j/commit/e9e8acc400d5935082b9d4d5255d5e735eae7a8f
causes problems if SELECT or WHERE contains backspace(s) without following ' or "
Simple Select doesn't work any more without ...?sessionVariables=sql_mode=NO_BACKSLASH_ESCAPES
getSession().createSQLQuery("SELECT CONCAT('\\\\', '') FROM (SELECT '') AS a WHERE :q = 1").setParameter("q", 1).list();

Caused by: java.sql.SQLException: Could not set parameter at position 1 (values was 1)
Query - conn:1180011(M) - "SELECT CONCAT('\ \', '') FROM (SELECT '') AS a WHERE ? = 1"
at org.mariadb.jdbc.internal.util.exceptions.ExceptionMapper.getSqlException(ExceptionMapper.java:211)
at org.mariadb.jdbc.MariaDbPreparedStatementClient.setParameter(MariaDbPreparedStatementClient.java:438)
at org.mariadb.jdbc.BasePrepareStatement.setInt(BasePrepareStatement.java:1436)
...


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