Skip to content

fix(catalog): store reg* oid-alias columns as their display name, not the oid#385

Merged
sunng87 merged 2 commits into
masterfrom
fix/reg-alias-display-name-384
Jul 20, 2026
Merged

fix(catalog): store reg* oid-alias columns as their display name, not the oid#385
sunng87 merged 2 commits into
masterfrom
fix/reg-alias-display-name-384

Conversation

@sunng87

@sunng87 sunng87 commented Jul 20, 2026

Copy link
Copy Markdown
Member

Summary

PostgreSQL reg* columns (regproc, regtype, regclass, ...) display as the object name, not the integer oid — e.g. pg_type.typinput for the text type shows textin. Commit 0300310 had exported these as ::oid integers so the oid-coercion analyzer rule could resolve name/numeric string comparisons. That benefit is now mostly gone (the coercion analyzer was replaced by SQL rewrites in #380, and the implicit comparison it served is blacklisted), while the display regression it introduced remains: clients saw the raw oid where real Postgres returns the name (part of #384).

This reverts the reg* storage to the display name (string), keeping the pg.oid_alias=<kind> field metadata so the wire layer can still report the correct alias type. Genuine oid columns stay int32 (Postgres displays oid as the integer).

Changes

  • export_pg_catalog_arrow.sh (generates the committed feathers):
    • reg* family → pa.string(); dropped the ::oid SELECT cast in select_expr.
    • oid stays pa.int32(); pg.oid_alias metadata stamping unchanged.
    • POSTGRES_PORT is now env-overridable (the host-side publish is only for ad-hoc inspection; the export runs in-container).
  • pg_to_arrow.py (generic exporter): it already stored reg* as string (the OIDs fall through to the pa.string() default); only the now-stale docstrings claimed int32 — corrected.
  • Regenerated 10 feathers against the same postgres:17.6 (no version drift): pg_type, pg_proc, pg_aggregate, pg_operator, pg_am, pg_amproc, pg_conversion, pg_range, pg_ts_parser, pg_ts_template. Verified e.g. pg_type.typinput/typoutput/typreceive/typsend are now string + pg.oid_alias=regproc holding the name (textin, textout, ...); oid/typnamespace remain int32.
  • New end-to-end test pg_type_regproc_columns_display_as_names: selecting typinput/typoutput for oid = 25 returns textin/textout.

Verification

  • cargo test -p datafusion-pg-catalog46 passed (incl. the new test).

Trade-off

Numeric oid equality on reg* columns (WHERE typinput = 42) and an explicit col::regproc cast on a (now string) reg* column no longer take the int path. The common display/name-comparison forms — SELECT typinput, typinput::text, WHERE typinput = 'textin' — are restored.

Refs: #384

sunng87 added 2 commits July 20, 2026 17:56
… the oid

PostgreSQL `reg*` columns (regproc, regtype, regclass, ...) display as the
object NAME, not the integer oid -- e.g. `pg_type.typinput` for the `text`
type shows `textin`. Commit 0300310 had exported these as `::oid` integers so
the oid-coercion analyzer rule could resolve name/numeric string comparisons.
That benefit is now mostly gone (the coercion analyzer was replaced by SQL
rewrites in #380, and the implicit comparison it served is blacklisted), while
the display regression it introduced remains: clients saw `42` where real
Postgres returns `textin` (issue #384).

Revert the `reg*` storage to the display name (string), keeping the
`pg.oid_alias=<kind>` field metadata so the wire layer (arrow-pg, fixed
separately) still reports the correct alias type in RowDescription. Genuine
`oid` columns stay int32 (Postgres displays oid as the integer).

  export_pg_catalog_arrow.sh (generates the committed feathers):
    - reg* family -> pa.string(); drop the `::oid` SELECT cast (select_expr).
    - oid stays pa.int32(); metadata stamping unchanged.
    - POSTGRES_PORT is now env-overridable (host-side publish is only for
      ad-hoc inspection; the export runs in-container).
  pg_to_arrow.py (generic exporter): it already stored reg* as string (the
    OIDs fall through to the pa.string() default); only the now-stale
    docstrings claimed int32. Updated the docstrings.

Regenerated the 10 affected feathers against postgres:17.6 (unchanged version):
pg_type, pg_proc, pg_aggregate, pg_operator, pg_am, pg_amproc, pg_conversion,
pg_range, pg_ts_parser, pg_ts_template. Verified pg_type.typinput/typoutput/
typreceive/typsend are now `string` + `pg.oid_alias=regproc` holding the name
(`textin`, `textout`, ...); oid/typnamespace remain int32.

Added end-to-end test pg_type_regproc_columns_display_as_names: selecting
typinput/typoutput for oid=25 returns `textin`/`textout`.

Trade-off (documented in the issue/option choice): numeric oid equality on
reg* columns (`WHERE typinput = 42`) and an explicit `col::regproc` cast on a
(now string) reg* column no longer work the int path. The common display and
name-comparison forms -- `SELECT typinput`, `typinput::text`,
`WHERE typinput = 'textin'` -- are restored.

Refs: #384
@sunng87
sunng87 merged commit d849990 into master Jul 20, 2026
7 checks passed
@sunng87
sunng87 deleted the fix/reg-alias-display-name-384 branch July 20, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant