[CONJ-1028] Connector implicitly switching noBackslashEscapes flag from false to true in protocol Created: 2022-11-24  Updated: 2023-11-06

Status: Needs Feedback
Project: MariaDB Connector/J
Component/s: None
Affects Version/s: 2.7.6, 3.1.0
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Cloud Ops Assignee: Diego Dupin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

When connector runs a prepared statement which contains backslash in where clause parameter.

e.g.

EntityManager em = EntityManagerUtil.getEntityManager(persistenceUnit);
String name = "Test\\name";
String sql = "select * from test_table t where HEX(LCASE(t.name)) LIKE HEX(LCASE(:name))";
Query query = em.createNativeQuery(sql, TestTable.class);
query.setParameter("name", name);
List<TestTable> objects = (List<TestTable>) query.getResultList();

It works fine for sometime till noBackslashEscapes flag is false in connector protocol. But then noBackslashEscapes flag implicitly changed to true and connector stopped escaping backslash character in query. When query is executed on server it takes the backslash character as escape character and doesn't return the expected result.

Note: The NO_BACKSLASH_ESCAPES mode is disabled on MariaDB server.



 Comments   
Comment by Diego Dupin [ 2022-12-23 ]

I don't understand why NO_BACKSLASH_ESCAPES would be set to true unexpectedly, connector use server flag to set/change value.
I've tryed to reproduced this case without success.
can you share some specifics about your configuration ( i.e. server version/if using maxscale/engine other than innodb, ....?)

Comment by Cloud Ops [ 2023-01-16 ]

Hi Diego,
We are using innodb with MariaDB server version 10.5.16.

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