Bug #9473 Compatibility with operating server in ANSI/ISO standard backslash mode.
Submitted: 30 Mar 2005 4:30 Modified: 30 Mar 2005 18:32
Reporter: Ken Johanson Email Updates:
Status: Duplicate Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:Any OS:Any (Any)
Assigned to: CPU Architecture:Any

[30 Mar 2005 4:30] Ken Johanson
Description:
I haven't verified all the places that this is an issue (due to number of test vectors and my incomplete-literacy with the JDBC spec), but at least for PreparedStatments, backslasshes are being unnessarily escaped (in the old C-style way) by the drivers quote handling, when the new NO_BACKSLASH_ESCAPE server option is enabled.

See:
http://bugs.mysql.com/bug.php?id=6368

Example server config option - NO_BACKSLASH_ESCAPE is the new option. Available starting on server version 5.0.3.
set-variable=sql-mode=PIPES_AS_CONCAT,ANSI_QUOTES,NO_BACKSLASH_ESCAPE

Using this option, executeQuery(String) SELECT 'a\\\"b' new yields (correctly) a\\\"b, instead of 'a\"b'

Users who attempt to use this option in conjunction with PS (at least) will experience data corruption.

How to repeat:
-Install server version 5.0.3
-Add "set-variable=sql-mode=PIPES_AS_CONCAT,ANSI_QUOTES,NO_BACKSLASH_ESCAPE" to my.ini/my.cnf, restart

Suggested fix:
The good news is, this new feature is a change in the right direction. The old backslash behavior was an interop issue. :-)
[30 Mar 2005 15:33] Ken Johanson
(fixing typo in subject...)
[30 Mar 2005 16:27] Mark Matthews
This is a duplicate of BUG#7374.

We're trying a fix in Connector/J 3.2 and are currently testing it, if it's successful, we'll consider backporting it to 3.1 if it's not too disruptive.
[30 Mar 2005 17:20] Ken Johanson
The latest build I tried (mysql-connector-java-3.1-nightly-20050330-bin), and when I try this one, 

''\\ (two single apostrpohes)

yeilds:
''\

Is some config I need to do?
[30 Mar 2005 18:32] Mark Matthews
Notice I said _3.2_ :)

The change is not in Connector/J 3.1.x yet, it's in the latest sources for Connector/J 3.2.

I've been working with the web team to get Connector/J 3.2. nightly snapshots available on the downloads.mysql.com site, but they're not there yet.