Skip to content

[Bug]: information_schema truncates valid generated-column expressions at 500 characters #30937

Closed as not planned

Description

@Ariznawlll

Problem

information_schema.COLUMNS.GENERATION_EXPRESSION silently truncates a valid stored generated-column expression to exactly 500 characters. The actual table definition and computed values retain the entire expression. The catalog field can end with an incomplete +, so schema-introspection/migration tools cannot reconstruct the column from that standard metadata.

Environment and reproduction

  • MatrixOne official main d4c37f4d8722dd91b80f5f5547940004bf1b293f, isolated locally built two-CN cluster on SQL ports 6431/6432.
  • MySQL Community Server 8.3.0, private Unix-socket reference.
  • Three fresh generated tables (200, 240, 280 additive terms) in a temporary MO database, read from both CNs, reproduced 3/3. The runner cleaned its temporary database/user/role.

Generate the exact 200-term DDL (then execute its output in the SQL client):

python3 -c 'print("CREATE TABLE t(id INT PRIMARY KEY,v INT,g INT GENERATED ALWAYS AS (" + "v" + " + 1"*200 + ") STORED);")'

Then run:

INSERT INTO t(id,v) VALUES(1,7);
SELECT g FROM t;
SHOW CREATE TABLE t;
SELECT LENGTH(generation_expression), RIGHT(generation_expression,20)
FROM information_schema.columns
WHERE table_schema=DATABASE() AND table_name='t' AND column_name='g';

On MO, the 200-, 240-, and 280-term variants calculate g=207, 247, and 287. SHOW CREATE TABLE retains every term (its DDL lengths are 950, 1110, and 1270), but GENERATION_EXPRESSION is 500 bytes in all three cases and ends with an unfinished +. Both CNs report the same truncation. A duplicate-PK write correctly fails and leaves the original row/value unchanged; subsequent queries work.

On MySQL 8.3, an otherwise identical 220-term table computes g=227, and its GENERATION_EXPRESSION is the complete 1323-character expression, including its final + 1 terms. No fixed 500-character cap was observed there.

White-box and duplicate check

pkg/util/sysview/predefined.go:593 constructs GENERATION_EXPRESSION with an inner CAST(... AS VARCHAR(500)) and an outer CAST(... AS VARCHAR(500)), irrespective of the stored generated-expression length. This directly matches the 500-character cutoff seen at runtime. The stored definition is still available in full through SHOW CREATE TABLE; the bug is specifically the standard catalog projection.

Searched open/closed issues for GENERATION_EXPRESSION, generated expression 500, and catalog truncation and checked mysql-compatibility-contract. No matching known limitation or issue found. Existing generated-column result/width issues address execution or materialization, not catalog-text truncation.

Evidence: GeneratedExpressionMetadata.java and /private/tmp/mo-explore-run-20261023/prepared_124311 (three independent passing verification rounds), plus the private MySQL 8.3 comparison. This report does not claim corruption of the stored generated value.

Activity

  1. added this to the MO-202610 milestone on Oct 23, 2026
  2. added theissue type on Oct 23, 2026
  3. 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