fix(postgresql): include OUT params when matching CALL signatures#4427
Open
SAY-5 wants to merge 1 commit intosqlc-dev:mainfrom
Open
fix(postgresql): include OUT params when matching CALL signatures#4427SAY-5 wants to merge 1 commit intosqlc-dev:mainfrom
SAY-5 wants to merge 1 commit intosqlc-dev:mainfrom
Conversation
Resolves sqlc-dev#4216. PostgreSQL CALL requires positional placeholders for OUT parameters, but ResolveFuncCall used InArgs() which strips them, so the supplied arg count never matched the procedure's IN arity and analysis failed with "function ... does not exist". Add Function.CallArgs() and route ast.CallStmt through a new ResolveCallStmt path that matches against IN+OUT arguments.
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.
Fixes #4216.
PostgreSQL
CALLrequires positional placeholders forOUTparameters, butCatalog.ResolveFuncCallmatched the supplied arg count againstFunction.InArgs(), which stripsOUTandTABLEmodes. A procedure declared ascreate_todo(IN p_task text, OUT p_id int)therefore had effective arity 1, andCALL create_todo($1, NULL)(arity 2) was rejected withfunction create_todo(unknown, unknown) does not exist.This patch:
Function.CallArgs(), which is identical toInArgs()but keepsOUTparameters (still excludesTABLE).Catalog.ResolveCallStmt, sharing the existing matcher via a privateresolveFuncCall(call, isCallStmt bool)helper.funcCallVisitorininternal/sql/validate/func_call.goto intercept*ast.CallStmt, dispatch toResolveCallStmt, and skip the innerFuncCallwalk so it isn't re-validated against the stricter IN-only path.Plain
SELECTfunction calls continue to useInArgs()and are unaffected.Reproduction
A new endtoend fixture under
internal/endtoend/testdata/stored_procedures_pg_out_args/postgresql/pgx/v5mirrors the schema and queries in the issue (positionalnull, typedNULL::int, andsqlc.argfor the OUT slot). It fails onmainwith the issue's exact error and passes after the fix.Tests
go test ./internal/compiler/... ./internal/sql/...— passgo test ./internal/endtoend/...— pass (includingddl_create_procedureandsql_syntax_calling_funcsregression coverage)go test -race ./internal/sql/... ./internal/compiler/...— pass