Skip to content

Missing table uses parser error 1064 instead of MySQL error 1146, preventing ODBC SQLSTATE 42S02 #26684

Closed

Description

@iamlinjunhong

MatrixOne version

  • Server: 8.0.30-MatrixOne-v25908
  • Commit: 35252ddec751e82f5a7209c6e242ed247626f3d6
  • MatrixOne ODBC baseline: MySQL Connector/ODBC 9.7.0

Reproduction

mysql --protocol=tcp -h 127.0.0.1 -P 6001 -u root test \
  -e "select * from mo_odbc_missing_state"

Observed:

ERROR 1064 (HY000): SQL parser error: table "mo_odbc_missing_state" does not exist

Through Connector/ODBC, native error 1064 maps to SQLSTATE 42000 for ODBC 3 and 37000 for ODBC 2. The upstream ODBC diagnostic tests therefore fail:

ODBC 3: actual 42000, expected 42S02
ODBC 2: actual 37000, expected S0002

Expected behavior

A missing base table should use the MySQL-compatible native error code 1146 (ER_NO_SUCH_TABLE). Connector/ODBC maps that code to the standard ODBC SQLSTATE 42S02 (Base table or view not found), or S0002 for an ODBC 2 environment.

For comparison, MatrixOne already emits native error 1050 for an existing table, allowing the driver to map duplicate-table errors to 42S01.

Impact

ODBC clients including Power BI classify failures by SQLSTATE to distinguish missing objects from SQL syntax errors. Returning 1064 makes an object-lifecycle error look like invalid SQL, weakens retry/schema-refresh diagnostics, and makes the fault appear to be in generated SQL rather than catalog state.

Regression coverage

The MatrixOne-specific ODBC suite checks syntax, missing-table, and duplicate-object diagnostics. The missing-table assertion should require exact SQLSTATE 42S02 once the server returns native error 1146.

Activity

  1. self-assigned this
    on Aug 4, 2026
  2. added
    ai-easy
    on Aug 5, 2026
  3. iamlinjunhong commented on Aug 5, 2026

    @iamlinjunhong
    ContributorAuthor

    Verified fixed on MatrixOne main e31ee06, via 4b62e3e (fix(plan): return MySQL 1146 for missing tables, #26708).

    Evidence:

    • native MySQL protocol now returns error 1146 for a missing table
    • MatrixOne ODBC maps it to SQLSTATE 42S02
    • mo_odbc_deep now passes the SQLSTATE case for both Unicode and ANSI drivers
    • upstream my_error improved from 16/20 to 18/20; both ODBC 2 and ODBC 3 missing-table cases pass

    The remaining two my_error failures are unrelated MySQL-only account/password-expiration and stored-procedure behavior.

  4. daviszhen commented on Oct 16, 2026

    @daviszhen
    Contributor

    v4.2.5 release-specific reproduction (arm64)

    Independent replay on the official matrixorigin/matrixone:latest image — arm64/linux, VERSION() = 8.0.30-MatrixOne-v4.2.5, single-node standalone, Apple M5 host, mysql 8.4 CLI. This comment does not assert anything about current main; it only records that the behaviour is still present in this release image.

    Still reproducible, both signatures:

    case MO v4.2.5 MySQL 8.0.46
    SELECT * FROM not_exist_tbl ERROR 1064 (42000) "table ... does not exist" ERROR 1146 (42S02)
    SELECT no_col FROM t ERROR 20301 (HY000) ERROR 1054 (42S22)

    Error-driven fallbacks (ODBC/SQLSTATE handling, data-source detection, retry logic keyed on "table missing") do not work against these codes.

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

Metadata

Metadata

Assignees

Labels

ai-easyarea/compatibilitykind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions