Skip to content

Support schema-qualified PL/pgSQL types without a catalog - #17

Open
pyramation wants to merge 1 commit into
18-latestfrom
devin/1795330000-upstream-plpgsql-qualified-schema-types
Open

pyramation wants to merge 1 commit into
18-latestfrom
devin/1795330000-upstream-plpgsql-qualified-schema-types

Conversation

@pyramation

@pyramation pyramation commented Nov 23, 2026 •

Copy link
Copy Markdown

Summary

Staging branch for the part of pganalyze#355 that Lukas said is good to go, rebuilt as one commit on current pganalyze/libpg_query 18-latest (fork 18-latest was fast-forwarded to it so this diff is just the change). Nothing is sent upstream until Dan signs off.

The LookupExplicitNamespace mock elog(ERROR)'d for any schema other than pg_catalog/public, so DECLARE v myschema.mytype; made pg_query_parse_plpgsql() return Not implemented (LookupExplicitNamespace ...) instead of JSON. Other schemas now resolve like public, which the GetSysCacheOid mock already maps to RECORDOID:

if (strcmp(nspname, "pg_catalog") == 0)
    return PG_CATALOG_NAMESPACE;
return PG_PUBLIC_NAMESPACE;   // was: public only, else elog(ERROR)

Edited in both scripts/mocks/LookupExplicitNamespace.c and the extracted src/postgres/src_backend_catalog_namespace.c, so it survives re-extraction. Adds a plpgsql_samples.sql case (qualified type, %ROWTYPE, %TYPE, pg_catalog.int4, public.mytype); the only golden change is that new line.

Left out on purpose:

make test passes locally; the expected JSON parses with json.load.


libpg-query and parser opened this PR for Dan
Implemented in session Rework upstream PL/pgSQL PR per Lukas's feedback
Review with Devin · Open in Devin Desktop


The LookupExplicitNamespace mock raised "Not implemented" for any schema other
than pg_catalog and public, so a PL/pgSQL variable typed as myschema.mytype made
pg_query_parse_plpgsql() return an error instead of JSON. Resolve other schemas
like public, which the GetSysCacheOid mock already maps to RECORDOID.

Adds a sample covering qualified types, %ROWTYPE, %TYPE, pg_catalog and public.
@devin-ai-integration

Copy link
Copy Markdown

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@luxor-code-review

luxor-code-review Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


The change makes the catalog-less parser mock accept any namespace name rather than erroring on unknown schemas, with the real upstream copy kept in sync and a new test exercising qualified schema types.

Files Change
scripts/mocks/LookupExplicitNamespace.c, src/postgres/src_backend_catalog_namespace.c Replace the elog(ERROR) for unknown namespaces with returning a sentinel so schema-qualified names resolve without a catalog
test/plpgsql_samples.sql, test/plpgsql_samples.expected.json Add a qualified_schema_types sample and its expected parse output to the fixture set

Reviewed commit: 493bd5b

@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5ec44e92-f758-4cc8-8070-593cd25231f5

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration

Copy link
Copy Markdown

Draft description for the upstream PR to pganalyze/libpg_query (written to be pasted as-is, no tool links):


Title: Support schema-qualified PL/pgSQL types without a catalog

This is the schema-qualified types part of pganalyze#355, split out as you suggested and rebased on current 18-latest. The promise datum fix already landed in pganalyze#384, and pganalyze#402 covers retvarno with a plain WRITE_INT_FIELD, so this PR is just the namespace change.

The LookupExplicitNamespace mock errors for any schema other than pg_catalog and public, so a declaration like v myschema.mytype; makes pg_query_parse_plpgsql() return Not implemented (LookupExplicitNamespace only supports pg_catalog and public) instead of a parse tree. Since there's no catalog, I resolve other schemas the same way as public, which the GetSysCacheOid mock already maps to RECORDOID. pg_catalog types still resolve to the builtins.

The change is in scripts/mocks/LookupExplicitNamespace.c and the extracted copy in src/postgres. I added a sample to test/plpgsql_samples.sql covering a qualified type, %ROWTYPE, %TYPE, pg_catalog.int4 and public.mytype. The only change in the expected output is the new sample.

Once this is in, I'll close pganalyze#355.

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