Skip to content

[Bug]: missing column returns generic HY000/20301 instead of SQLSTATE 42S22 #27024

Closed

Description

@iamlinjunhong

Environment

  • MatrixOne main: 052b2fdcebce6d8d093624773c03ef3f92afeaef
  • MatrixOne ODBC main: b6a5a9dd plus only unrelated client-side defensive changes
  • Windows 11 x64, MatrixOne in WSL2

Minimal reproduction

DROP DATABASE IF EXISTS mo_schema_drift_probe;
CREATE DATABASE mo_schema_drift_probe;
CREATE TABLE mo_schema_drift_probe.t(id INT PRIMARY KEY, metric INT);
ALTER TABLE mo_schema_drift_probe.t DROP COLUMN metric;
SELECT metric FROM mo_schema_drift_probe.t;

Actual result

ERROR 20301 (HY000): invalid input: column metric does not exist

The same result is returned through ODBC after a prepared query's selected column is dropped:

SQLSTATE=HY000 native=20301
message=invalid input: column 'schema_drift.metric' does not exist

Expected result

A missing referenced column should use the MySQL/ODBC diagnostic for column not found, SQLSTATE 42S22 (or at minimum SQLSTATE class 42), rather than the generic HY000 class.

Power BI impact

Schema changes between Power BI refreshes are a normal unhappy-path scenario. Power Query and ODBC tooling classify and surface errors using SQLSTATE. Returning HY000 prevents the client from distinguishing a missing column/schema drift from an internal or generic driver/server failure, producing less actionable refresh diagnostics.

Additional validation

The test also verifies that after the expected failure the column can be added back, the ODBC statement can be prepared again, and the connection remains reusable. The recovery succeeds; only the error classification is incorrect.

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions