Skip to content

information_schema character metadata is empty or inconsistent, breaking Unicode ODBC SQLColumns classification #26688

Closed

Description

@iamlinjunhong

MatrixOne version

  • Server: 8.0.30-MatrixOne-v25908
  • Commit: 35252ddec751e82f5a7209c6e242ed247626f3d6
  • Client: MatrixOne ODBC based on MySQL Connector/ODBC 9.7.0

Reproduction

create database if not exists mo_odbc_deep;
create table mo_odbc_deep.charset_repro (
  c_char char(8),
  c_varchar varchar(128),
  c_text text
);

select count(*) from information_schema.character_sets;

select c.data_type, c.character_set_name,
       c.character_maximum_length, c.character_octet_length, cs.maxlen
from information_schema.columns c
left join information_schema.character_sets cs
  on c.character_set_name = cs.character_set_name
where c.table_schema = 'mo_odbc_deep'
  and c.table_name = 'charset_repro';

Observed:

information_schema.character_sets count: 0

CHAR     utf8   8     192    NULL
VARCHAR  utf8   128   3072   NULL
TEXT     utf8   0     0      NULL

Expected behavior

  • information_schema.character_sets should contain the supported character sets and their MAXLEN values.
  • Character columns should reference rows that can be joined by CHARACTER_SET_NAME.
  • CHARACTER_OCTET_LENGTH should reflect the declared character length multiplied by the character sets actual maximum encoded width, rather than the current factor of 24 for utf8.

ODBC impact

Connector/ODBC implements SQLColumns by joining information_schema.columns to information_schema.character_sets. It uses MAXLEN > 1 to classify Unicode-driver character columns as SQL_WCHAR, SQL_WVARCHAR, and SQL_WLONGVARCHAR. Because MatrixOne returns no matching row, MAXLEN is NULL and the Unicode driver incorrectly reports VARCHAR as ANSI SQL_VARCHAR (12) instead of SQL_WVARCHAR (-9). The upstream t_bug34355094_sqlcolumns_wchar regression fails for CHAR, VARCHAR, and TEXT.

Power BI consumes SQLColumns for schema discovery, so both the wrong wide/ANSI classification and inflated octet lengths can affect Unicode schema inference and buffer sizing.

A small driver fallback can avoid the type-classification symptom when CHARACTER_SET_NAME is non-NULL, but it cannot make the server metadata internally consistent; the information schema should be fixed at the source.

Activity

  1. added
    ai-easy
    on Aug 5, 2026
  2. Repository owner unassigned on Aug 5, 2026
  3. iamlinjunhong commented on Aug 12, 2026

    @iamlinjunhong
    ContributorAuthor

    Follow-up analysis on latest main:

    PR #26695 addressed two separate parts of the problem, but the Aug 5 reproduction still failed for two independent reasons:

    1. Existing tenants already at 4.0.6 did not execute the new offset upgrade handler because the old tenant-upgrade path treated a same-version 4.0.6 -> 4.0.6 transition as a no-op. PR fix: lowercase information_schema columns data types #26712 later fixed same-version offset upgrades. This explains why information_schema.character_sets could remain empty on an upgraded tenant even though the seed SQL had been added.
    2. TEXT still reported 0/0 because an ordinary MatrixOne TEXT column is persisted as T_text with Width=0, and the internal information-schema functions returned that marker literally. The CHAR/VARCHAR character-vs-octet calculation from fix(metadata): correct character set metadata #26695 was already working.

    I prepared the remaining fix on branch m2-26688:

    • ordinary TEXT now exposes MySQL-compatible metadata 65535 characters / 65535 octets;
    • TINYTEXT exposes 255 / 255, preserving the fact that TEXT-family limits are byte bounds;
    • CHAR/VARCHAR remain declared character length and UTF-8 maximum octet length (4x);
    • the charset/collation BVT now covers CHAR, VARCHAR, TINYTEXT, TEXT, and the character_sets MAXLEN join used by ODBC SQLColumns.

    Verification:

    • pkg/sql/plan/function unit test: PASS
    • go test ./pkg/sql/plan/function: PASS
    • go build ./pkg/sql/plan/function: PASS
    • go vet ./pkg/sql/plan/function: PASS
    • mo-tester charset_collation_basic.sql against a freshly built local service: 275/275 statements passed, 0 failed, 100% success rate.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

ai-easyarea/compatibilitykind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions