Skip to content

[Bug]: information_schema gaps break schema-migration tooling #25103

Closed

Description

@dengn

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Branch Name

v4.0.0-rc3

Commit ID

8.0.30-MatrixOne-v4.0.0-rc3

Other Environment Information

  • Hardware parameters: N/A
  • OS type: N/A
  • Others: Reproduced via cross-language ORM compatibility testing (PHP / Python / Java / Node.js) over the MySQL 8.0.30 wire protocol. The minimal repro below uses raw SQL so it is driver-independent.

Actual Behavior

Two related problems block every schema-introspection / migration tool tested:

  1. Missing tables: information_schema.collation_character_set_applicability and information_schema.check_constraints do not exist.
    -- Doctrine DBAL listTables()/introspectTable(), CakePHP describe():
    1064 SQL parser error: table "collation_character_set_applicability" does not exist
    1064 SQL parser error: table "check_constraints" does not exist
    
  2. ONLY_FULL_GROUP_BY rejection on a tables introspection query that the MySQL planner accepts:
    -- Hibernate hbm2ddl=update/validate, Flyway, Liquibase:
    1149 SQL syntax error: column "tables.TABLE_TYPE" must appear in the GROUP BY clause
    

Single-table column metadata is also inaccurate: varchar CHARACTER_MAXIMUM_LENGTH and decimal NUMERIC_PRECISION/SCALE come back NULL, DATA_TYPE is upper-cased, TEXT CHARACTER_MAXIMUM_LENGTH = 0, and foreign keys are not exposed via JDBC getImportedKeys / DBAL listTableForeignKeys.

Expected Behavior

These information_schema tables/columns exist and behave as in MySQL 8.0, and the introspection queries above succeed.

Steps to Reproduce

SELECT * FROM information_schema.collation_character_set_applicability LIMIT 1;  -- 1064 table does not exist
SELECT * FROM information_schema.check_constraints LIMIT 1;                      -- 1064 table does not exist

Additional information

Impact: Doctrine Migrations, CakePHP ORM reflection, Hibernate auto-DDL, Flyway and Liquibase all fail — i.e. the standard migration path for Symfony, Laravel (CakePHP), and Spring Boot apps. Liquibase is 0/9 in the suite.

Background: dengn/php-tester#3, dengn/php-tester#6 (and CakePHP in dengn/php-tester#1).

Activity

  1. changed the title [-][introspection] `information_schema` gaps break schema-migration tooling[/-] [+][Bug]: information_schema gaps break schema-migration tooling[/+] on Jun 23, 2026
  2. added
    kind/bug
    on Jun 23, 2026
  3. added
    severity/s1
    on Jun 30, 2026
  4. added this to the MO-202607 milestone on Jun 30, 2026
  5. gouhongshen commented on Jul 12, 2026

    @gouhongshen
    Contributor

    拿到了。Keycloak 26.6.4 内置的 mysql-connector-j 9.6.0 执行的是下面这条预编译 SQL:

    SELECT
    TABLE_SCHEMA AS TABLE_CAT,
    NULL AS TABLE_SCHEM,
    TABLE_NAME,
    CASE
    WHEN TABLE_TYPE = 'BASE TABLE' THEN
    CASE
    WHEN TABLE_SCHEMA = 'mysql'
    OR TABLE_SCHEMA = 'performance_schema'
    OR TABLE_SCHEMA = 'sys'
    THEN 'SYSTEM TABLE'
    ELSE 'TABLE'
    END
    WHEN TABLE_TYPE = 'TEMPORARY' THEN 'LOCAL_TEMPORARY'
    ELSE TABLE_TYPE
    END AS TABLE_TYPE,
    TABLE_COMMENT AS REMARKS,
    NULL AS TYPE_CAT,
    NULL AS TYPE_SCHEM,
    NULL AS TYPE_NAME,
    NULL AS SELF_REFERENCING_COL_NAME,
    NULL AS REF_GENERATION
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = ?
    AND TABLE_NAME = ?
    HAVING TABLE_TYPE IN (?, ?, ?, ?, ?)
    ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME;

    这次 Liquibase 初始化大致绑定为:

    TABLE_SCHEMA = keycloak_groupby_repro
    TABLE_NAME = DATABASECHANGELOG
    TABLE_TYPE = TABLE

    剩余类型参数为 NULL。

    关键点是:原始 SQL 本身没有 GROUP BY,但使用了:

    HAVING TABLE_TYPE IN (...)

    这里的 TABLE_TYPE 又是 CASE ... END AS TABLE_TYPE 的别名。MatrixOne 在处理 HAVING/别名和
    information_schema.tables 时进入聚合校验,最终错误里显示成:

    column "tables.TABLE_TYPE" must appear in the GROUP BY clause

    所以不兼容点已经比较明确:MySQL Connector/J 的 getTables() 元数据查询使用 HAVING TABLE_TYPE,而 MatrixOne 不
    能按 MySQL 语义执行它。

  6. removed
    severity/s1
    on Aug 6, 2026
  7. aqqi666 commented on Aug 9, 2026

    @aqqi666

    补充:4.1.x 复测与 Keycloak 影响

    版本复测

    在 8.0.30-MatrixOne-v4.1.2 上,MySQL Connector/J DatabaseMetaData.getTables() 形态 SQL 仍失败:

    SELECT
        TABLE_SCHEMA AS TABLE_CAT,
        NULL AS TABLE_SCHEM,
        TABLE_NAME,
        CASE
            WHEN TABLE_TYPE = 'BASE TABLE' THEN
                CASE
                    WHEN TABLE_SCHEMA = 'mysql'
                      OR TABLE_SCHEMA = 'performance_schema'
                      OR TABLE_SCHEMA = 'sys'
                    THEN 'SYSTEM TABLE'
                    ELSE 'TABLE'
                END
            WHEN TABLE_TYPE = 'TEMPORARY' THEN 'LOCAL_TEMPORARY'
            ELSE TABLE_TYPE
        END AS TABLE_TYPE,
        TABLE_COMMENT AS REMARKS,
        NULL AS TYPE_CAT,
        NULL AS TYPE_SCHEM,
        NULL AS TYPE_NAME,
        NULL AS SELF_REFERENCING_COL_NAME,
        NULL AS REF_GENERATION
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = 'keycloak_groupby_repro'
      AND TABLE_NAME = 'DATABASECHANGELOG'
    HAVING TABLE_TYPE IN ('TABLE', 'VIEW', 'SYSTEM TABLE', 'SYSTEM VIEW', 'LOCAL TEMPORARY')
    ORDER BY TABLE_TYPE, TABLE_SCHEMA, TABLE_NAME;

    错误(与 issue 描述一致):

    ERROR 1149 (HY000): column "tables.TABLE_TYPE" must appear in the GROUP BY clause or be used in an aggregate function
    

    更简形态同样失败:

    SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_TYPE
    FROM INFORMATION_SCHEMA.TABLES
    WHERE TABLE_SCHEMA = 'keycloak_groupby_repro'
    HAVING TABLE_TYPE IN ('BASE TABLE');

    4.1.3 / 4.1.4

    查阅 v4.1.3、v4.1.4 release notes:均无 HAVING / GROUP BY / INFORMATION_SCHEMA.TABLES / JDBC getTables 相关修复(4.1.4 仅 lock wait timeout + CTAS quoted alias)。无证据表明 4.1.4 已解决本问题。

    产品影响(moi-uc / Keycloak)

    • Keycloak 26.x + 内置 mysql-connector-j 9.x 在 Liquibase 初始化时会调用 getTables() 探测 DATABASECHANGELOG。
    • 上述 SQL 失败会导致 无法把 Keycloak 库落到 MatrixOne。
    • 当前私有化交付结论不变:Keycloak 必须使用独立 MySQL(uc-keycloak-mysql),uc-server 业务库才用 MatrixOne uc。

    请将本 issue 视为 4.1 线仍 open 的兼容缺口;若已在更新分支修复,请标注目标版本。

  8. aqqi666 commented on Aug 10, 2026

    @aqqi666

    UC 侧跟踪 issue:matrixorigin/matrixflow#14803 — Keycloak 因 information_schema 兼容性问题无法使用 MatrixOne 作为持久化库,当前 GitOps 通过独立 uc-keycloak-mysql 规避。

  9. Ariznawlll commented on Aug 14, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • commit:a2f89230085a0f6650ec7bb7017ba6b8a97c9efc
    • 部署方式:本地隔离单 LOG、TN、CN
    • 测试日期:2026-08-14

    原问题验证

    使用 MySQL Connector/J 8.0.15 和 8.0.33 分别独立执行 3 次:创建临时表后调用 DatabaseMetaData.getTables(null, null, "t", new String[]{"TABLE"})。

    两种驱动均 3/3 失败,错误稳定为:

    ERROR 1149 (HY000): column "tables.TABLE_TYPE" must appear in the GROUP BY clause or be used in an aggregate function

    Happy Path 覆盖

    1. getTables(null, null, "t", null) 每次均能返回目标表。
    2. getColumns 与 getPrimaryKeys 每次均能返回对应元数据。
    3. 每轮结束后均删除临时数据库,未观察到崩溃或卡死。

    Unhappy Path 覆盖

    无额外非法参数场景;本次失败的 types={"TABLE"} 是 JDBC 的正常元数据调用,不作为非法输入。

    白盒验证

    不适用:本次为最新主线 JDBC 兼容性复测,未包含产品修复。

    回归测试

    未新增仓库用例;建议在 JDBC 集成回归中固定 getTables(..., new String[]{"TABLE"}) 与无 types 对照。

    测试证据

    8.0.15: passed=9, failed=3;8.0.33: passed=9, failed=3。每个失败均为带 TABLE 类型筛选的 getTables 调用,其余三个元数据对照通过。

    测试结论

    测试不通过。

  10. daviszhen commented on Aug 17, 2026

    @daviszhen
    Contributor
  11. 47 remaining items

  12. Ariznawlll commented on Sep 20, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • 分支:main
    • commit:56f7d1eae392b5f3de33e1ea43c916956c50b833
    • 部署方式:嵌入式隔离 MatrixOne 集群;真实 MySQL Connector/J jar
    • 测试日期:2026-09-20

    验证范围

    本次只复验 DatabaseMetaData.getImportedKeys() 在两个 schema 存在同名 parent、child 和 fk_parent 时的跨 schema 重复问题,并按照升级 Connector/J 的处理策略验收;不把 Connector/J 8.0.33 的已知驱动缺陷归因于 MatrixOne。

    原问题验证

    每轮均新建 target/decoy 两个 schema。两个 schema 的表名和外键名相同,但 decoy FK 使用不同的父键及删除规则,以便识别错误跨 schema JOIN。连接启用 useInformationSchema=true&nullDatabaseMeansCurrent=true,每个版本独立执行 3 轮并在每轮结束后删除两个测试 schema。

    Connector/J getImportedKeys(target, null, "child") getImportedKeys(null, null, "child") 结果
    8.0.33 2 2 旧驱动仍因缺少 CONSTRAINT_SCHEMA 的 JOIN 返回重复元数据
    8.4.0 1 1 正确
    9.7.0 1 1 正确

    8.4.0 与 9.7.0 的实际 JDBC API 都能正确限定到 target schema;8.0.33 的重复结果与官方 Connector/J 8.4.0 release note 所述 getImportedKeys() 错误 JOIN 一致:https://dev.mysql.com/doc/relnotes/connector-j/en/news-8-4-0.html。

    覆盖范围

    1. 显式 catalog 与 current-catalog(null catalog)调用。
    2. 跨 schema 同名表、同名 FK 和不同 FK 属性的干扰场景。
    3. JDBC 返回行数,而非仅验证 information_schema SQL。
    4. 每轮的 schema 创建、查询、删除与后续重建。

    边界与异常路径

    1. Connector/J 8.0.33 作为兼容性对照,连续 3 轮稳定返回重复记录;该结果不作为 MatrixOne 服务端失败。
    2. 测试对象在每轮后均成功删除,未观察到 DDL 残留、服务异常或连接泄漏。

    现有自动化回归

    在同一 commit 上执行:

    go test ./pkg/tests/issues -run '^TestIssue25103InformationSchemaMetadata$' -count=3
    

    结果为 ok github.com/matrixorigin/matrixone/pkg/tests/issues。该已有 Go 回归覆盖 information_schema 列元数据及包含 CONSTRAINT_SCHEMA 的外键 JOIN;本次真实 JDBC 版本矩阵为补充验收,不写入依赖本机 Java jar 的仓库用例。

    测试结论

    Connector/J 升级至 8.4.0+ 后,getImportedKeys() 跨 schema 重复问题不再出现;8.0.33 属于驱动已知问题,不作为 MatrixOne 修复要求。

    测试通过。

  13. daviszhen commented on Sep 23, 2026

    @daviszhen
    Contributor

    补充线上应用场景验证证据(2026-09-23):erupt 和 favorites-web 的 Hibernate 启动 metadata 查询均因 TABLE_TYPE must appear in the GROUP BY clause 失败,导致应用 readiness 不通过。这两个应用复现了本 issue 中 information_schema / ONLY_FULL_GROUP_BY 兼容性问题。

  14. daviszhen commented on Oct 16, 2026

    @daviszhen
    Contributor

    v4.2.5 arm64: JDBC-level signature, plus a silent-failure trap

    Replayed on matrixorigin/matrixone:latest (arm64/linux, VERSION() = 8.0.30-MatrixOne-v4.2.5), Connector/J 8.0.33, MySQL 8.0.46 as baseline. Two additions to this issue:

    1. Exact JDBC signature. With a default connection, DatabaseMetaData.getTables() throws before returning anything:

    SQLSyntaxErrorException: SQL syntax error:
    column "tables.TABLE_TYPE" must appear in the GROUP BY clause or be used in an aggregate function
    

    Sweeping 19 commonly used DatabaseMetaData methods on the same release, 18/19 work — the single failure is getTables. getColumns, getIndexInfo, getPrimaryKeys, getImportedKeys, getExportedKeys, getSchemas, getCatalogs, getTableTypes, getTypeInfo, getProcedures, getBestRowIdentifier, getVersionColumns etc. all return rows. Since getTables() is the entry point for ORM dialect init, code generators and schema tooling, this is a startup-level risk even though the rest of the metadata surface is fine.

    2. A silent-failure trap worth documenting. Removing ONLY_FULL_GROUP_BY from the session sql_mode makes the exception disappear — but getTables() then silently returns 0 tables:

    connection configuration getTables() information_schema.columns / statistics
    default (useInformationSchema=true) throws SQLSyntaxErrorException 1658 / 217
    sql_mode without ONLY_FULL_GROUP_BY no error, 0 tables returned ❌ 1658 / 217 (still populated)
    useInformationSchema=false 3 tables, correct ✅ 1658 / 217

    The middle row is worse than the failure it "fixes": tools see an empty schema and may conclude the database has no tables, while the metadata tables themselves are perfectly populated.

    Working workaround: add useInformationSchema=false to the JDBC URL, which makes Connector/J take the SHOW-based fallback path. With that parameter all 19/19 metadata methods return correct results. It would help to document this (and to warn explicitly against using sql_mode to work around getTables()), because the natural first reaction is to change sql_mode.

  15. daviszhen commented on Oct 17, 2026

    @daviszhen
    Contributor

    Follow-up: the getTables() failure is driver-version dependent

    Running the same JDBC call against MatrixOne v4.2.5 (arm64) with three Connector/J versions changed the picture in a way that is relevant to the impact assessment in this issue:

    DatabaseMetaData.getTables(catalog, null, "%", new String[]{"TABLE"})   // row count
    driver MatrixOne v4.2.5 MySQL 8.0.46
    5.1.49 9 tables — works, no error 10 tables
    8.0.33 throws SQLSyntaxErrorException: column "tables.TABLE_TYPE" must appear in the GROUP BY clause... 10 tables
    8.4.0 same exception 10 tables

    So the failure is confined to the 8.x Connector/J code paths: 5.1.x does not build the information_schema query that trips the strict ONLY_FULL_GROUP_BY check, and therefore never hits this. Applications pinned to the legacy driver — which is common in older Java stacks — are unaffected; anything on 8.x hits it and needs the useInformationSchema=false workaround (verified: with that parameter all 19 metadata methods return correct results on 8.0.33/8.4.0).

    Everything else in the matrix was consistent across all three drivers on MatrixOne: full-type setObject writes, getObject/getString round-trips (except the legacy driver's own datetime formatting, mentioned in #29904), single-row generated keys, and the SSL / allowPublicKeyRetrieval parameters.

  16. Ariznawlll commented on Oct 19, 2026

    @Ariznawlll
    Collaborator

    测试版本

    • MatrixOne 官方 main:873282742714436bff407dfcdbbe879147162bd3(执行前核对远端 refs/heads/main 与隔离工作树一致)。
    • 本地隔离 1 CN / 1 TN / 1 LogService,MySQL 协议端口 6001;真实 MySQL Connector/J 8.0.33、8.4.0;每个驱动各 3 轮、每轮独立重建数据库。

    原问题验证

    原报告的 information_schema.collation_character_set_applicability 和 check_constraints 在当前 main 均存在,计数分别为 8 和 0;后者为 0 行是本轮未建立 CHECK 约束的内容结果,并非缺表。原 Connector/J getTables 的 CASE ... AS TABLE_TYPE、HAVING TABLE_TYPE IN (...) 查询形态直接执行成功,能返回目标元数据,不再报 TABLE_TYPE must appear in GROUP BY。

    通过真实 JDBC API,8.0.33 和 8.4.0 的 DatabaseMetaData.getTables(schema,null,"child",{"TABLE"}) 各 3/3 返回 1 条目标表;同一轮的 getImportedKeys(schema,null,"child") 各 3/3 返回 1 条目标外键。测试使用 useInformationSchema=true,没有借助 SHOW fallback 或移除 ONLY_FULL_GROUP_BY 来规避原路径。

    Happy Path 覆盖

    1. 两个元数据表存在;collation_character_set_applicability 返回 8 行,check_constraints 可正常查询。
    2. 原 JDBC 8.x getTables 类型筛选和 getImportedKeys 各版本各 3/3,实际计数都是 1。
    3. 独立的完整 Connector/J getTables 形态 SQL 对照返回目标行;已有 Go 回归验证字符长度、DECIMAL 精度/scale、时间精度、FLOAT 的 NULL/值,以及带 schema 限定的外键 JOIN。

    Unhappy Path 覆盖

    • 对照旧版失败形态:启用 useInformationSchema=true 且传 types={"TABLE"};在两个 Connector/J 8.x 版本中均未出现 1149 错误或空表静默返回。同库 parent→child 外键也未丢失;本轮未重复测试跨 schema 同名外键干扰。
    • 每轮删除并重建专用数据库,结束后清理成功;未观察到 DDL 残留或服务异常。

    白盒验证

    当前 main 现有 pkg/tests/issues/issue_25103_test.go 的 TestIssue25103InformationSchemaMetadata 覆盖上述列类型/NULL 元数据和外键完整 schema JOIN。本轮未修改产品代码;以该现有 Go 用例和真实 JDBC 协议调用双重核对现行 main 行为。旧 v4.2.5 镜像此前的失败证据不等同于这次 main 的结果。

    回归测试

    在同一 main SHA 上运行现有 Go 回归:mo-cgo-test -count=3 -run '^TestIssue25103InformationSchemaMetadata$' ./pkg/tests/issues,结果 PASS。按本轮“现有 Go 回归已覆盖即可”的验收口径,没有重复新增 MOTR 用例。完整 Go suite、MOTR suite、集成 CI,以及 Keycloak/Hibernate/Liquibase 整应用启动本次未运行。

    测试证据

    • JDBC 8.0.33:3/3 轮 tables=1 importedKeys=1。
    • JDBC 8.4.0:3/3 轮 tables=1 importedKeys=1。
    • information_schema 两表 SQL 查询成功;原 CASE/HAVING 元数据形态返回 1 条目标行。
    • Go 回归:ok github.com/matrixorigin/matrixone/pkg/tests/issues(-count=3)。
    • 测试使用独立数据库,完成后已删除;用户主工作目录未改动。

    测试结论

    测试通过。

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

Metadata

Metadata

Assignees

Labels

benchbasekind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions