Skip to content

[Bug]: information_schema constraint/index metadata omits keys, duplicates rows, and exposes internal index tables #27654

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

main

Commit ID

a53f5a3

Other Environment Information

  • Deployment: local multi-CN (launch-multi-cn), verified through both CNs
  • Server: 8.0.30-MatrixOne-v20260826
  • JDBC controls: MySQL Connector/J 8.0.33, 8.4.0, and 9.7.0

Actual Behavior

Standard schema introspection returns missing, duplicate, and internal metadata:

  1. information_schema.KEY_COLUMN_USAGE contains only foreign keys. PRIMARY and UNIQUE key columns are absent.
  2. information_schema.TABLE_CONSTRAINTS omits FOREIGN KEY constraints, includes ordinary non-constraint indexes as MULTIPLE, and returns one row per index column/internal index part rather than one row per constraint.
  3. information_schema.COLUMNS exposes __mo_index_* internal table columns. It also reports a column covered only by a non-unique index as COLUMN_KEY='UNI' instead of MUL.
  4. information_schema.STATISTICS and Connector/J getIndexInfo() return three identical rows for one logical IVF index.

Three fresh-schema runs produced the same compact result:

run  kcu_actual  tc_actual  hidden_columns  ivf_rows  indexed_column_key
1    1           11         15              3         UNI
2    1           11         15              3         UNI
3    1           11         15              3         UNI

Connector/J 8.0.33, 8.4.0, and 9.7.0 all returned 22 hidden index-column rows for the larger fixture and three vidx rows.

Expected Behavior

  • KEY_COLUMN_USAGE contains PRIMARY, UNIQUE, and FOREIGN KEY columns with correct ordinals.
  • TABLE_CONSTRAINTS contains one row per PRIMARY/UNIQUE/FOREIGN KEY/CHECK constraint and excludes ordinary, full-text, and vector indexes.
  • Internal __mo_index_* tables are not exposed through information_schema.COLUMNS or JDBC metadata.
  • Non-unique indexed columns report COLUMN_KEY='MUL'.
  • One logical single-column IVF index produces one STATISTICS/getIndexInfo() row.

Steps to Reproduce

DROP DATABASE IF EXISTS metadata_repro;
CREATE DATABASE metadata_repro;
USE metadata_repro;

CREATE TABLE parent(
  id INT PRIMARY KEY,
  code VARCHAR(20),
  UNIQUE KEY uq_code(code)
);
CREATE TABLE child(
  id INT PRIMARY KEY,
  pid INT,
  a INT,
  b INT,
  UNIQUE KEY uq_ab(a,b),
  KEY idx_b(b),
  CONSTRAINT fk_pid FOREIGN KEY(pid) REFERENCES parent(id)
);
CREATE TABLE vec(id INT PRIMARY KEY, embedding VECF32(3));
CREATE INDEX vidx USING IVFFLAT ON vec(embedding)
  LISTS=2 OP_TYPE 'vector_l2_ops';

SELECT * FROM information_schema.KEY_COLUMN_USAGE
WHERE TABLE_SCHEMA='metadata_repro';

SELECT TABLE_NAME,CONSTRAINT_NAME,CONSTRAINT_TYPE
FROM information_schema.TABLE_CONSTRAINTS
WHERE TABLE_SCHEMA='metadata_repro';

SELECT TABLE_NAME,COLUMN_NAME,COLUMN_KEY
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA='metadata_repro';

SELECT TABLE_NAME,INDEX_NAME,SEQ_IN_INDEX,COLUMN_NAME,INDEX_TYPE
FROM information_schema.STATISTICS
WHERE TABLE_SCHEMA='metadata_repro';

Additional information

The behavior follows directly from the current view definitions in pkg/util/sysview/predefined.go: KEY_COLUMN_USAGE selects only mo_foreign_keys; TABLE_CONSTRAINTS selects raw mo_indexes rows without logical-constraint grouping; COLUMNS does not filter the index-table prefix; and STATISTICS exposes all IVF internal index parts. Existing BVT covers individual FK/index queries but does not assert cross-view completeness, uniqueness, or hidden-object filtering.

Activity

  1. added this to the MO-202608 milestone on Aug 26, 2026
  2. added
    kind/bug
    on Aug 26, 2026
  3. added theissue type on Aug 26, 2026
  4. assigned and unassigned on Aug 28, 2026
  5. Ariznawlll commented on Aug 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    最新 main 复测 3/3:KEY_COLUMN_USAGE、TABLE_CONSTRAINTS、STATISTICS(含向量索引)均无重复/幽灵条目;隐藏列数为 0,普通索引标识正确。现有 information_schema / foreign-key BVT 覆盖此类元数据契约。无需 big-data、PITR/snapshot、stability 或 chaos。结论:关闭。

  6. Ariznawlll commented on Aug 28, 2026

    @Ariznawlll
    CollaboratorAuthor

    更正补充:验证基线为 MatrixOne main 28769ff。连续三轮确认 KCU、TC、STATISTICS 均无重复或内部表泄漏。

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

Metadata

Metadata

Assignees

Labels

kind/bug

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions