Bug #119245 Select into fix breaks queries with 'into' in them
Submitted: 27 Oct 2025 14:02 Modified: 5 Feb 16:22
Reporter: Kees Hoekzema Email Updates:
Status: Open Impact on me:
None 
Category:Connector / J Severity:S3 (Non-critical)
Version:9.5.0 OS:Any
Assigned to: Filipe Silva CPU Architecture:Any

[27 Oct 2025 14:02] Kees Hoekzema
Description:
In the commit "Fix for Bug#107543 (Bug#34464351), Cannot execute a SELECT statement that writes to an OUTFILE." you probably fixed 'select into' queries.

However, you broke queries that have 'into' *somewhere* in the query.

How to repeat:
For example 'select columnA, Mintopics ...' results in a java.sql.SQLException: Statement.executeQuery() cannot issue statements that do not produce result sets.

Escaping the columnname works as workaround: 'select columnA, `Mintopics` ..'
[30 Oct 2025 18:30] Filipe Silva
Thank you for your interest in MySQL Connector/J and for taking the time to report this issue.

Verified as described.
[13 Dec 2025 8:44] Milo van der Zee
Took me a couple of hours to figure out what the reason was that suddenly my queries where rejected. Ended up that the 'INTO' checking was wrong and luckily somebody already mentioned it. I can immagine that more developers are impacted. 

Seems like an easy fix. Just only search for sepcific words if theya are surrounded by non letters.

My workaround for now is to enable quoting in hibernate:
<!-- Make sure all identifiers are placed between quotes -->
<property name="hibernate.globally_quoted_identifiers" value="true"/>
<property name="hibernate.globally_quoted_identifiers_skip_column_definitions" value="true"/>
[16 Dec 2025 19:53] Filipe Silva
Sorry for the trouble. We are addressing this with high priority.

Thank you for the workaround in Hibernate.
[17 Dec 2025 7:30] Milo van der Zee
I also created a pull-request that make the 'INTO' detection less eager but can miss some situations.

See https://github.com/mysql/mysql-connector-j/pull/121
[9 Jan 17:01] OCA Admin
Contribution submitted via Github - bug 119245: fix the detection logic of the 'INTO' keyword 
(*) Contribution by Milo van der Zee (Github MilovdZee, mysql-connector-j/pull/121#issuecomment-3729304950): I confirm the code being submitted is offered under the terms of the OCA, and that I am authorized to contribute it.

Contribution: git_patch_3098600756.txt (text/plain), 41.73 KiB.

[14 Jan 21:27] Edward Gilmore
Posted by developer:
 
 Added the following note to the MySQL Connector/J 9.6.0 release notes:		
 
Queries containing the string INTO within valid tokens, such as table or column names, 
were not handled correctly. 
Errors were returned similar to the following:

        java.sql.SQLException: Statement.executeQuery() cannot issue
        statements that do not produce result sets
[3 Feb 12:03] Filipe Silva
Duplicated by Bug#119718, Bug#119645, Bug#119641 and Bug#119261.
[5 Feb 11:04] Nigel Riemis
I am still affected by this issue after the latest fix.
In 9.6.0 the issue still occurs when my select statement contains a field like 'lump_sum_into_annuity'.

This is probably because the new code checks for alphanumeric characters, which do not include underscore.
[5 Feb 16:22] Filipe Silva
Hi Nigel Riemis,
 
You are absolutely correct. Thank you for catching this.