Repository navigation
catalog: Populate PostgreSQL type lengths - #39775
Merged
Merged
Conversation
sjwiesman
requested review from
jdonelson
and removed request for
a team and
jdonelson
October 12, 2026 21:29
sjwiesman
force-pushed
the
trino-compat
branch
from
October 12, 2026 21:33
44f9d99 to
1e66404
Compare
antiguru
approved these changes
Oct 13, 2026
antiguru
left a comment
Member
There was a problem hiding this comment.
Looks good, please update the PR body before merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
pg_type.typlenandpg_attribute.attlenare always NULL in Materialize. pgjdbc derivesDatabaseMetaData.getMaxColumnNameLength()andgetMaxTableNameLength()from thetyplenofname, so it reports-1instead of63. Trino's PostgreSQL connector treats a non-positive identifier limit as an error, which breaks join pushdown (and table creation) against Materialize.Description
mz_internal.mz_type_pg_metadatagains a nullabletyplencolumn, andpg_typereadstyplenfrom it instead ofNULL::int2.pg_attribute.attlenis derived frompg_type.typlen, so it is populated too.The value comes from resolving the catalog type to its
SqlScalarTypeand askingmz_pgrepr::Typefor its length. That is the same value pgwire already sends astype_leninRowDescription, so the catalog and the wire protocol agree.Type::from_oidwas not used because it does not knowname,aclitem,_record, and a few other built-ins.Types with no PostgreSQL counterpart keep a NULL
typlen: pseudo-types (anyelement, ...),_record, and Materialize-only types such asuint2andlist.mz_type_pg_metadatadescribes the PostgreSQL view of a type, so inventing lengths for types PostgreSQL does not have would misreport.Because
mz_type_pg_metadatais a builtin table with a new column, it gets areplacementbuiltin schema migration.Verification
test_compare_builtins_postgresnow also asserts that every built-in type with a PostgreSQL counterpart reports the sametyplenas PostgreSQL.pg_catalog_attribute.sltcheckstyplenfor a spread of fixed-length, variable-length, pseudo, and Materialize-only types, andattlenfor table columns.63for the maximum column and table name lengths.cockroach/orms.slt,catalog_server_explain.sltandmz_catalog_server_index_accounting.sltare updated for the populatedattlenand the changed view definition.Release notes
This release will report PostgreSQL type lengths in
pg_type.typlenandpg_attribute.attlen, which lets JDBC-based tools such as Trino read identifier length limits correctly.