Skip to content

[Bug]: prefix-index length is missing from STATISTICS.SUB_PART and SHOW INDEX metadata #30935

Closed as not planned

Description

@Ariznawlll

Problem

For a supported prefix index, information_schema.STATISTICS.SUB_PART does not report the prefix length. It is always SQL NULL, although the index enforces the prefix and SHOW CREATE TABLE preserves it. SHOW INDEX also exposes Sub_part as the non-null text "NULL" instead of the actual integer length, so JDBC index introspection loses the prefix contract.

Environment and reproduction

  • MatrixOne official main d4c37f4d8722dd91b80f5f5547940004bf1b293f, locally built isolated two-CN cluster, SQL ports 6431/6432.
  • MySQL 8.3.0 private Unix-socket reference.
  • Three independent fresh MO tables/cases, 3/3; metadata checked from both CNs. The runner used a fresh temporary database/user/role and cleaned them afterwards.
CREATE TABLE p(id INT PRIMARY KEY, v VARCHAR(20), UNIQUE KEY ux(v(3)));
INSERT INTO p VALUES(1,'abc1');
INSERT INTO p VALUES(2,'abc2'); -- correctly rejected: same indexed prefix

SHOW CREATE TABLE p; -- retains UNIQUE KEY `ux` (`v`(3))
SELECT index_name, sub_part
FROM information_schema.statistics
WHERE table_schema=DATABASE() AND table_name='p'
ORDER BY index_name;
SHOW INDEX FROM p;

MatrixOne reports PRIMARY: NULL, ux: NULL from information_schema; MySQL reports PRIMARY: NULL, ux: 3. The SHOW INDEX protocol row for ux on MO has Sub_part text "NULL" with JDBC ResultSet.wasNull() == false, while the nonstandard Index_params column correctly contains {"prefix_lengths":"v:3"}. MySQL SHOW INDEX supplies integer 3 in Sub_part.

The same MO result reproduced for a TEXT prefix length 3 and a UTF-8 VARCHAR prefix length 1. MySQL independently reports SUB_PART 3 and 1 respectively. In each MO case, the second colliding insert was rejected, count remained one, SHOW CREATE TABLE retained the declared length, and a subsequent SELECT 1 worked. Thus this is metadata loss, not absent prefix enforcement.

White-box and duplicate check

pkg/util/sysview/predefined.go:825-854 defines information_schema.STATISTICS with the literal NULL AS SUB_PART, while index prefix lengths are retained in index parameters (observable in SHOW INDEX). This directly explains the information_schema half of the result. The additional text-NULL protocol behavior of SHOW INDEX is observed but its producer is not yet localized.

Searched open/closed issues for SUB_PART, SHOW INDEX Sub_part, and prefix-index metadata and checked the MySQL compatibility contract. Closed #27654 concerned missing/duplicate/hidden index metadata, not prefix length; open #30921 concerns prefix primary-key admission, not introspection. No matching known limitation found.

Evidence: PrefixIndexMetadata.java, /private/tmp/mo-explore-run-20261023/prepared_123645 (three passing, exact source count and catalog results), and the direct MySQL 8.3 comparison on the private reference instance.

Activity

  1. added this to the MO-202610 milestone on Oct 23, 2026
  2. added
    kind/bug
    on Oct 23, 2026
  3. added theissue type on Oct 23, 2026
  4. XuPeng-SH commented on Oct 24, 2026

    @XuPeng-SH
    Contributor

    Tracking consolidated into #30936. The canonical issue now includes this report's independent scope and acceptance criteria. This is administrative consolidation, not a claim that the defect is fixed; the original reproduction and discussion are preserved here.

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

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions