Fix PostgreSQL routine reader for functions with unnamed parameters - #66
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.fromParameterBuilder.Build(). One such function anywhere in the database kills the whole read; the only caller workaround is turning routine reading off.pg_proc.proargnamesis 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 aRETURNS TABLEclause — unnamed inputs come back as empty strings, so they passed theparameter_name IS NOT NULLfilter and reached the builder nameless.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
$nnaming. Full PostgreSQL test suite passes on the branch.