Skip to content

fix: use single quotes in SQL query to support ANSI_QUOTES mode#92

Open
prathamesh04 wants to merge 1 commit into
mysql:mainfrom
prathamesh04:fix/ansi-quotes-crash
Open

fix: use single quotes in SQL query to support ANSI_QUOTES mode#92
prathamesh04 wants to merge 1 commit into
mysql:mainfrom
prathamesh04:fix/ansi-quotes-crash

Conversation

@prathamesh04

Copy link
Copy Markdown

Description

This PR fixes two bugs in the MySQL Shell for VS Code plugin that cause connection failures when ANSI_QUOTES is enabled in sql_mode.

Bug 1: SQL Query Uses Double Quotes (Error 1054)

In DbMySQLSessionSetupTasks.py, the HeatWaveCheckTask.on_connected() method executes a SQL query to check if the sys.EXPLAIN_ERROR procedure is available. The query uses double quotes for string literals:

WHERE ROUTINE_SCHEMA="sys"
  AND ROUTINE_NAME="mle_explain_error"
  AND ROUTINE_TYPE="PROCEDURE"

When ANSI_QUOTES is enabled in sql_mode, MySQL interprets double-quoted values as identifiers (column names) rather than string literals, causing Error 1054: Unknown column 'sys' in 'where clause'.

Fix: Changed double quotes to single quotes:

WHERE ROUTINE_SCHEMA='sys'
  AND ROUTINE_NAME='mle_explain_error'
  AND ROUTINE_TYPE='PROCEDURE'

Bug 2: TypeError in Error Handling

When the above error occurs, DbSession.terminate_thread() calls self._message_callback("ERROR", self.thread_error). However, DbModuleSession.on_session_message() expects 3 positional arguments:

def on_session_message(self, type, message, result, request_id=None):

The result argument is not passed, causing:

TypeError: DbModuleSession.on_session_message() missing 1 required positional argument: 'result'

Fix: Added None as the result parameter:

self._message_callback("ERROR", self.thread_error, None)

Related Issue

Closes #88

Changes

  • gui/backend/gui_plugin/core/dbms/DbMySQLSessionSetupTasks.py: Changed double quotes to single quotes in SQL query
  • gui/backend/gui_plugin/core/dbms/DbSession.py: Added missing result parameter in terminate_thread()

The SQL query in HeatWaveCheckTask.on_connected() used double quotes for
string literals, which causes Error 1054 when ANSI_QUOTES is enabled in
sql_mode. Changed to single quotes which work in all sql_mode settings.

Also fixed a secondary TypeError in DbSession.terminate_thread() where
_message_callback was called with 2 arguments but on_session_message
expects 3 positional arguments. Added None as the result parameter.

Closes mysql#88
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error 1054: Unknown column 'sys' in 'where clause' when connecting with ANSI_QUOTES sql_mode — crashes thread with TypeError

1 participant