Skip to content

Fix PostgreSQL routine reader for functions with unnamed parameters - #66

Merged
pwelter34 merged 2 commits into
loresoft:mainfrom
DavidBoone:postgres-unnamed-param
Sep 5, 2026
Merged

Fix PostgreSQL routine reader for functions with unnamed parameters#66
pwelter34 merged 2 commits into
loresoft:mainfrom
DavidBoone:postgres-unnamed-param

Conversation

@DavidBoone

Copy link
Copy Markdown
Contributor

Reading the schema of any PostgreSQL database containing a user function with a mix of named and unnamed parameters aborts the entire read with A parameter name is required. Call WithName before Build. from ParameterBuilder.Build(). One such function anywhere in the database kills the whole read; the only caller workaround is turning routine reading off.

pg_proc.proargnames is NULL only when a function has no named parameters at all. As soon as any parameter is named — which PostgreSQL forces for every function with an OUT parameter or a RETURNS TABLE clause — unnamed inputs come back as empty strings, so they passed the parameter_name IS NOT NULL filter and reached the builder nameless.

create function demo.f(int, out result text) language sql as $$ select 'x' $$;
create function demo.g(int) returns table (id int) language sql as $$ select 1 $$;

The filter is dropped and unnamed arguments are named positionally as $n, matching PostgreSQL's own naming. Dropping them instead would silently corrupt the parameter list, so they are kept.

First commit adds the repro functions to the test scripts — every PostgreSQL schema reader test fails at that commit. Second commit has the reader fix plus tests asserting the $n naming. Full PostgreSQL test suite passes on the branch.

An unnamed input paired with a named OUT parameter, an unnamed input on a RETURNS TABLE function, and a function with no named parameters at all. Any one of these aborts the whole schema read, so every PostgreSQL schema reader test fails until the reader is fixed.
PostgreSQL stores unnamed arguments as empty strings in proargnames whenever any argument is named, which happens for every function with an OUT parameter or a RETURNS TABLE clause. Those empty names passed the IS NOT NULL filter and made ParameterBuilder.Build throw, aborting the entire schema read. Unnamed arguments are now named positionally as $n, and the new tests assert that naming.
@pwelter34
pwelter34 merged commit f2e8f67 into loresoft:main Sep 5, 2026
3 checks passed
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