Bug #28256 Exception with readonly transaction and UNION of two parenthetical statements
Submitted: 5 May 2007 0:12 Modified: 8 Oct 2007 15:41
Reporter: Paul Benedict Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:5.0.27 OS:Microsoft Windows
Assigned to: CPU Architecture:Any

[5 May 2007 0:12] Paul Benedict
Description:
MySQL 5.0.27, Tomcat 6, JDK 6, mysql-connector-java-5.0.5.jar, Spring 2.0.4

My web application is connecting to MySQL under a read-only transaction. It can execute this query:

SELECT 1 UNION SELECT 2
but not this:
(SELECT 1) UNION (SELECT 2)

The latter causes an exception: "Connection is read-only. Queries leading to data modification are not allowed". 

How to repeat:
See description.
[5 May 2007 0:13] Paul Benedict
Fix misspelling of synopsis
[5 May 2007 1:38] Mark Matthews
This is actually a bug in the JDBC driver, in that it parses the query (but doesn't have a full-fledged SQL parser for obvious reasons) and is confused by the leading parenthesis.
[3 Oct 2007 18:54] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/34854
[3 Oct 2007 18:59] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/34855
[4 Oct 2007 20:41] Mark Matthews
Fixed for 5.0.8.
[5 Oct 2007 18:53] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35011
[8 Oct 2007 15:41] MC Brown
A note has been added to the 5.0.8 changelog: 

When a connection is in read-only mode, queries that are wrapped in parentheses were incorrectly identified DML statements.
[11 Oct 2007 20:11] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35407
[11 Oct 2007 20:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35410
[11 Oct 2007 20:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/35414
[19 Nov 2007 0:57] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38019
[19 Nov 2007 2:52] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/38024