Skip to content

feat: add uuid and oid types to pg_type and pg_attribute catalog tables - #4960

Merged
olavloite merged 1 commit into
postgresql-dialectfrom
add-oid-and-uuid
Sep 28, 2026
Merged

olavloite merged 1 commit into
postgresql-dialectfrom
add-oid-and-uuid

Conversation

@olavloite

Copy link
Copy Markdown
Collaborator

Cloud Spanner PostgreSQL-dialect databases support the UUID and OID data types. This change adds support for discovering and inspecting these types through PGAdapter's virtual catalog tables:

  • Adds rows for oid (OID 26), _oid (OID 1028), uuid (OID 2950), and _uuid (OID 2951) to the virtual pg_catalog.pg_type table expression in PgCatalog, expanding the type count from 31 to 35.
  • Adds atttypid, column size, and precision mappings for oid, oid[], uuid, and uuid[] to pg_catalog.pg_attribute in PgCatalog and PgJdbcCatalog.
  • Updates RowDescriptionResponse.getOidTypeSize(int) to return the fixed wire protocol lengths for Oid.OID (4 bytes) and Oid.UUID (16 bytes) instead of -1 (variable length).
  • Updates test catalog table expectations and adds query translation and lookup test coverage for these types.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds support for 'oid' and 'uuid' data types (and their array variants) in PGAdapter's simulated PostgreSQL system catalogs, updating metadata queries, type size mappings, and consolidating test CTEs. The feedback recommends correcting the 'typcategory' of the 'oid' type from 'N' (Numeric) to 'O' (OID) to ensure proper type classification and compatibility with client drivers.

Comment thread src/main/java/com/google/cloud/spanner/pgadapter/statements/PgCatalog.java Outdated
Cloud Spanner PostgreSQL-dialect databases support the UUID and OID
data types. This change adds support for discovering and inspecting
these types through PGAdapter's virtual catalog tables:
- Adds rows for `oid` (OID 26), `_oid` (OID 1028), `uuid` (OID 2950),
  and `_uuid` (OID 2951) to the virtual `pg_catalog.pg_type` table
  expression in `PgCatalog`, expanding the type count from 31 to 35.
- Adds `atttypid`, column size, and precision mappings for `oid`, `oid[]`,
  `uuid`, and `uuid[]` to `pg_catalog.pg_attribute` in `PgCatalog` and
  `PgJdbcCatalog`.
- Updates `RowDescriptionResponse.getOidTypeSize(int)` to return the
  fixed wire protocol lengths for `Oid.OID` (4 bytes) and `Oid.UUID`
  (16 bytes) instead of -1 (variable length).
- Updates test catalog table expectations and adds query translation
  and lookup test coverage for these types.
@olavloite

Copy link
Copy Markdown
Collaborator Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for the oid and uuid data types, along with their array variants, within PGAdapter's catalog emulation. The changes update type mappings, column sizes, and OID sizes across PgCatalog, PgJdbcCatalog, and RowDescriptionResponse. Additionally, several mock server tests have been refactored to use the centralized PgCatalog.PgType.PG_TYPE_CTE constant to eliminate duplicate SQL definitions, and new unit and integration tests have been added to validate the new types. No review comments were provided, and the changes look solid and well-tested.

@olavloite
olavloite merged commit 3230801 into postgresql-dialect Sep 28, 2026
51 checks passed
@olavloite
olavloite deleted the add-oid-and-uuid branch September 28, 2026 13:15
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.

2 participants