Bug #108195 | Connector/J rejects UNION with CTE | ||
---|---|---|---|
Submitted: | 19 Aug 2022 8:21 | Modified: | 20 Dec 2022 23:40 |
Reporter: | Tibor Varga | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S3 (Non-critical) |
Version: | 8.0.30 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[19 Aug 2022 8:21]
Tibor Varga
[19 Aug 2022 9:01]
MySQL Verification Team
Hello Tibor Varga, Thank you for the report and test case. regards, Umesh
[11 Nov 2022 20:38]
Filipe Silva
Thanks again for taking the time to report this. Until this is not fixed you can use this workaround: statement.execute("WITH cte AS (SELECT 0) (SELECT 1) UNION (SELECT 2)"); ResultSet results = statement.getResultSet();
[5 Dec 2022 7:31]
Lukas Eder
This also affects executino of such queries with third parties, see https://github.com/jOOQ/jOOQ/issues/14358 Another workaround seems to be to wrap the UNION query in a derived table as such: WITH cte AS (SELECT 0) SELECT * FROM ((SELECT 1) UNION (SELECT 2)) t
[7 Dec 2022 12:21]
MySQL Verification Team
Bug #109303 marked as duplicate of this one
[20 Dec 2022 23:40]
Daniel So
Posted by developer: Added the following entry to the Connector/J 8.0.32 changelog: "Before executing a query with Statement.executeQuery(query), Connector/J checks if the query is going to produce results and rejects it if it cannot. The check wrongly rejected queries that had a WITH clause using a common table expression and a UNION operator, and had the first SELECT statement put between parentheses."