Skip to content

pg_type joined to pg_namespace is answered as a schema query, returning one fabricated all-NULL row and breaking JDBC DatabaseMetaData.getTypeInfo() #7224

Closed

Description

@ruispereira

Summary

pg_type was promoted in this window from a decorating relation to Family.TYPES, and TYPES sits at
the bottom of the family ranking on purpose. That reading is right for pg_class and pg_attribute
and wrong for pg_namespace: a query joining pg_type to pg_namespace is a question about
types, and it is answered as a question about schemas, returning one fabricated row whose
type columns are all NULL.

This breaks DatabaseMetaData.getTypeInfo() in the PostgreSQL JDBC driver.

Where (HEAD 471498d)

  • postgresw/.../PostgresCatalog.java:141 and :188 (relation registry)
  • :335-337 (family selection), :410-437 (mostSpecific / rank), :838-844 (Row.complete)

The ranking:

case SCHEMAS -> 1;
case TABLES, VIEWS -> 2;
case COLUMNS -> 3;
default -> 0;            // TYPES

with the stated rationale: "TYPES stays at the bottom on purpose: pg_type joined to pg_class or
pg_attribute is a question about tables or columns that happens to name the type of each."

That is correct for those two. But pg_namespace is registered as Family.SCHEMAS, rank 1, and a
query whose only other relation is pg_namespace is asking about types, joined to pg_namespace
purely to qualify each type's schema. mostSpecific picks SCHEMAS, so buildRows returns
List.of(schemaRow(context).complete()) - a single row.

Row.complete() then fills every column of every registered relation with null, so the pg_type
columns on that schema row resolve to NULL rather than to "no such column", and the projection
validates and is accepted. The caller gets a well-formed answer that is entirely fabricated.

Repro

DatabaseMetaData.getTypeInfo() sends:

SELECT t.typname,t.oid FROM pg_catalog.pg_type t
  JOIN pg_catalog.pg_namespace n ON (t.typnamespace = n.oid)
 WHERE n.nspname != 'pg_toast' AND (...)

Family resolves to SCHEMAS. The single schema row survives the filter, because its nspname is the
database name and the trailing scalar subquery makes the WHERE unreadable - which for a non-TYPES
family is tolerated and drops the filter entirely. The projection t.typname, t.oid yields
(NULL, NULL).

So getTypeInfo() returns one type whose name and OID are null, instead of the type list. Any tool
that populates a type picker or validates a column type against the catalog gets a single nameless
entry. Notably it does not error, so the failure is silent at the driver level.

Suggested fix

Rank by what the query is actually about rather than by relation alone. The distinction that matters
is whether the non-TYPES relation constrains the row set or merely qualifies it:

  • pg_class and pg_attribute joined to pg_type constrain it, so the current ranking is right.
  • pg_namespace joined to pg_type qualifies it, so TYPES should win.

The narrow version is to exclude pg_namespace from the relations that outrank TYPES, since it is
the only registered SCHEMAS relation and its role in a type query is always qualification. A
principled version is to give each relation a weight for "can be a lone subject" versus "only ever
decorates", and pick the highest subject present.

Separately worth hardening: Row.complete() filling foreign columns with NULL is what turns a
mis-routed query into a plausible answer instead of an error. A projection naming a column the chosen
family does not own could be rejected rather than nulled - that would have made this loud.

Scope / confidence

Confidence high on the mechanism; each step (the ranking, pg_namespace's family, mostSpecific,
and Row.complete's null fill) was read in the tree.

Related but filed separately: the two pg_type surfaces disagree on which columns exist.

Activity

  1. added this to the 26.10.1 milestone on Sep 7, 2026
  2. added
    in progress
    on Sep 7, 2026
  3. self-assigned this
    on Sep 7, 2026
  4. added 4 commits that reference this issue on Sep 7, 2026
  5. lvca commented on Sep 7, 2026

    @lvca
    Member

    Fixed in #7246, released in 26.10.1.

    Over the PostgreSQL wire protocol, DatabaseMetaData.getTypeInfo() returned a single type with a null name and null OID instead of the list of supported types. The query it sends joins pg_type to pg_namespace, and the catalog emulation read that as a question about schemas rather than about types — then filled the type columns with nulls, so the driver got a well-formed but entirely made-up answer, with no error to hint at it.

    Any tool that populates a type picker or validates a column type against the catalog got that one nameless entry.

    What changed

    A relation joined only to qualify each row (such as pg_namespace, which just names the schema of each type) no longer decides what the query is about. Relations that genuinely narrow the result — pg_class, pg_attribute — still do, so table and column metadata queries are unaffected.

    getTypeInfo() now returns the real type list. No client-side change is needed.


    ❤️ Thanks for helping make ArcadeDB better! ArcadeDB is free and open source, sustained by its community. If it's useful to you or your company, please consider becoming a sponsor to keep development going.

  6. removed
    in progress
    on Sep 7, 2026
  7. added a commit that references this issue on Sep 8, 2026
  8. added 2 commits that reference this issue on Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions