[Bug]: index on a missing column returns 20301 'column is not exist' instead of ER_KEY_COLUMN_DOES_NOT_EXIST 1072

Open Beginner friendly
#33,362 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, mysql
Domain
databases

Research direction

Start in the index builders in build_ddl.go and compare their missing-column handling with the existing moerr.NewErrKeyColumnDoesNotExist use for ALTER TABLE ADD PRIMARY KEY. Reproduce with one of the SQL statements in the issue, then check that the regular index cases return error 1072 with SQLSTATE 42000.

Written by the indexing model from the issue text.

Description

kind/bug
Is there an existing issue for the same bug?
  • I have checked the existing issues (searched is not exist, Key column, 1072).
Branch Name

main (9bf005bf)

Describe the bug

When a regular index (KEY / INDEX / UNIQUE, in CREATE TABLE, CREATE [UNIQUE] INDEX or ALTER TABLE ADD INDEX) names a column the table does not have, MO returns the generic error 20301 invalid input: column 'x' is not exist. MySQL returns ER_KEY_COLUMN_DOES_NOT_EXIST (1072, SQLSTATE 42000) Key column 'x' doesn't exist in table. Migration tools and ORMs that match on the error number cannot recognize the MO error.

MO already has moerr.NewErrKeyColumnDoesNotExist (used by ALTER TABLE ADD PRIMARY KEY). The index builders in build_ddl.go (unique, secondary, fulltext-type and spatial checks) still use NewInvalidInputf("column '%s' is not exist").

Steps to reproduce
CREATE TABLE t4 (a INT, b INT, KEY (c));
CREATE TABLE t5 (a INT PRIMARY KEY, UNIQUE KEY uk (col10));
CREATE TABLE t6 (col1 INT, col2 CHAR(15));
CREATE UNIQUE INDEX m3 ON t6 (col3);
Expected behavior (MySQL 8.4)
ERROR 1072 (42000): Key column 'c' doesn't exist in table
ERROR 1072 (42000): Key column 'col10' doesn't exist in table
ERROR 1072 (42000): Key column 'col3' doesn't exist in table
Actual behavior (MatrixOne main 9bf005bf)
ERROR 20301: invalid input: column 'c' is not exist
ERROR 20301: invalid input: column 'col10' is not exist
ERROR 20301: invalid input: column 'col3' is not exist
Additional information

Single-node mo-service -launch etc/launch/launch.toml. Vector index plugins (IVFFLAT/HNSW/…) are MO-specific and out of scope.

本操作由 LW 授权的 Grok Bot 智能体执行。

Dominant language
Go
Stars
1.9k
Forks
312
Avg merge
22h 59m
Merged PRs (30d)
736

Getting set up

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.

More from matrixorigin/matrixone

All issues in matrixorigin/matrixone

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.