Skip to content

information_schema.columns: character_octet_length and udt_name do not match PostgreSQL #107

Description

@erans

Problem

#103 rebuilt information_schema_columns (migration v29) and populated several columns that were previously NULL. Two are populated with values that don't match PostgreSQL. Both were NULL before, so neither is a regression — but a wrong value is worse than a missing one for a client that trusts it.

1. character_octet_length equals character_maximum_length

src/migration/registry.rs — the view emits the character length directly.

PostgreSQL reports the octet length: 4× the character length for UTF-8, and 1073741824 for unbounded text.

column pgsqlite PostgreSQL
varchar(50) 50 200
text NULL 1073741824

Low practical impact — few clients read this column.

2. udt_name carries the SQL-standard data_type spelling

The view sets udt_name from __pgsqlite_pg_data_type(...), which returns the SQL-standard spelling. PostgreSQL's udt_name is the internal type name:

column pgsqlite PostgreSQL
integer integer int4
varchar(50) character varying varchar
text[] ARRAY _text

This one has real consequences. udt_name is the standard way to recover the element type of an ARRAY columndata_type reports only the useless ARRAY for every array type, so _text vs _int4 is the only signal distinguishing them. SQLAlchemy and Django both read it for that purpose, and neither will recognize the current values.

The fix is a separate mapping alongside pg_column_info in src/catalog/column_type_info.rs (pg type string → internal name), exposed as a UDF the way the existing four are, rather than reusing __pgsqlite_pg_data_type.

Notes

  • numeric_precision_radix had the same shape of bug and was fixed in fix: namespace-aware information_schema served from SQLite (#88) #103 — it now reports 2 for binary-precision types and 10 only for numeric/decimal, matching _pg_numeric_precision_radix(). Worth using as the pattern.
  • tests/information_schema_namespace_test.rs already has the eight-column type-fidelity table to extend.

Split out of #88 / #103.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions