mysql / mysql/mysql-shell-plugins

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

Open
#88 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
96
Forks
22
PR merge metrics
No merged PRs in 30d

Description

Description

When opening a SQL Editor connection (gui.sqlEditor.openConnection) on a MySQL server that has ANSI_QUOTES enabled in @@sql_mode, the connection fails with MySQL Error (1054): Unknown column 'sys' in 'where clause', followed by a secondary TypeError crash in the error handling path.

Root Cause

In DbMySQLSessionSetupTasks.py, the HeatWaveCheckTask.on_connected() method executes:

result = self.execute("""
    SELECT ROUTINE_NAME
    FROM information_schema.routines
    WHERE ROUTINE_SCHEMA="sys"
    AND ROUTINE_NAME="mle_explain_error"
    AND ROUTINE_TYPE="PROCEDURE"
    """).fetch_all()

This query uses double quotes for string literals ("sys", "mle_explain_error", "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.

Fix: Replace double quotes with single quotes:

result = self.execute("""
    SELECT ROUTINE_NAME
    FROM information_schema.routines
    WHERE ROUTINE_SCHEMA='sys'
    AND ROUTINE_NAME='mle_explain_error'
    AND ROUTINE_TYPE='PROCEDURE'
    """).fetch_all()
Secondary Bug: TypeError in error handling

When the above error occurs, DbSession.terminate_thread() (DbSession.py line ~247) calls:

self._message_callback('ERROR', self.thread_error)

However, DbModuleSession.on_session_message() (DbModuleSession.py) expects 3 positional arguments plus an optional one:

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

The result argument is not passed by terminate_thread(), causing:

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

Fix: Either update terminate_thread() to pass a result argument:

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

Or make result optional in on_session_message():

def on_session_message(self, type, message, result=None, request_id=None):
Steps to Reproduce
  1. Configure MySQL server with ANSI_QUOTES in sql_mode:
    SET GLOBAL sql_mode = CONCAT(@@sql_mode, ',ANSI_QUOTES');
    
  2. Open VS Code with MySQL Shell for VS Code extension (v2026.2.0)
  3. Create a database connection and attempt to connect via the SQL Editor
Expected Behavior

Connection opens successfully regardless of the server's sql_mode setting.

Actual Behavior

Connection fails. Two errors are raised:

  1. MySQL Error (1054): Unknown column 'sys' in 'where clause'
  2. TypeError: DbModuleSession.on_session_message() missing 1 required positional argument: 'result'

The thread crashes and no useful error is returned to the user.

Stack Trace
ERROR: Thread ServiceSession-58220351-1d69-11f1-80e9-d03745fcfc48 exiting with code MySQL Error (1054): Unknown column 'sys' in 'where clause'

Exception in thread sql-ServiceSession-58220351-1d69-11f1-80e9-d03745fcfc48:
Traceback (most recent call last):
  File "...\threading.py", line 1043, in _bootstrap_inner
    self.run()
  File "...\DbSession.py", line 480, in run
    self.terminate_thread()
  File "...\DbSession.py", line 247, in terminate_thread
    self._message_callback('ERROR', self.thread_error)
TypeError: DbModuleSession.on_session_message() missing 1 required positional argument: 'result'
Environment
  • Extension: Oracle MySQL Shell for VS Code v2026.2.0 (win32-x64)
  • OS: Windows
  • MySQL sql_mode: includes ANSI_QUOTES
Affected Files
File Issue
gui/backend/gui_plugin/core/dbms/DbMySQLSessionSetupTasks.py Double quotes used as string delimiters in SQL — incompatible with ANSI_QUOTES
gui/backend/gui_plugin/core/dbms/DbSession.py (~L247) terminate_thread() calls _message_callback with wrong number of arguments
gui/backend/gui_plugin/core/modules/DbModuleSession.py on_session_message() requires result but caller doesn't provide it

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with HeatWaveCheckTask.on_connected() in gui/backend/gui_plugin/core/dbms/DbMySQLSessionSetupTasks.py, then trace terminate_thread() in DbSession.py and on_session_message() in DbModuleSession.py. Reproduce with MySQL ANSI_QUOTES enabled and verify that the SQL Editor connection succeeds without the secondary TypeError or loss of a useful error message.

Written by the indexing model from the issue text.

Assessment

Tech stack
mysql, python
Domain
backend, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.