Skip to content

feat(catalog): resolve CALL of procedures with output parameters - #937

Open
psteinroe wants to merge 1 commit into
feat/editor-best-effort-callfrom
feat/call-out-arguments
Open

psteinroe wants to merge 1 commit into
feat/editor-best-effort-callfrom
feat/call-out-arguments

Conversation

@psteinroe

Copy link
Copy Markdown
Collaborator

Stacked on #914.

#914 resolved CALL, but skipped procedures with OUT or INOUT parameters, and procedures created in the file never resolved at all.

create procedure move_point(x int, out moved int, inout y int) language plpgsql as $$ ... $$;
call move_point(1, null, 2);
-- before: no hints, no token, empty hover
-- after:  move_point(x: 1, moved: null, y: 2), a function token, hover on the procedure

What was wrong

  • Since Postgres 14, CALL passes an argument for every parameter of a procedure, OUT included (usually NULL). ParseFuncOrColumn looks the candidates up with include_out_arguments for a CALL (FuncnameGetCandidates, namespace.c#L1272 at REL_18_6), and transformCallStmt splits the output arguments off afterwards. Our signatures only had the input arguments, so the arguments didn't line up, and feat(catalog): keep editor features working after DO, CALL and unparsable statements; resolve CALL #914 skipped every procedure with output parameters.
  • Procedures created in the file had no return type, and select_function gives up without one, so CALL of a procedure from the same file never resolved.

What changed

  • FunctionArgumentMode::Out: the signature of a procedure now includes its OUT arguments, from the snapshot (base.rs) and from CREATE PROCEDURE in the file. min_args/max_args count them too. Functions are unchanged, and so is input_types, which DROP/ALTER matching uses.
  • CREATE PROCEDURE in the file rejects an OUT parameter after one with a default, like Postgres does, and the procedure returns record with output parameters and void without (CreateFunction, functioncmds.c#L1188).
  • resolve_procedure_call no longer skips procedures with output parameters.
  • Hover matches the snapshot function of a procedure including its OUT arguments.
  • The limitation is removed from the editor features docs.

Tests

  • pgls_catalog: CALL of procedures with OUT and INOUT parameters from the database and from the file; a call that leaves out the OUT argument matches nothing.
  • pgls_inlay_hints: hints for all three kinds of parameters.
  • pgls_hover: snapshot for hovering a procedure with an OUT parameter in CALL.
  • The Postgres regression suite and the analyser specs pass.

Not covered

  • For CALL, Postgres also includes the output arguments of functions with the same name when it picks a candidate (the call then fails because they aren't procedures). We don't, so a function and a procedure with the same name could resolve differently in rare overload cases. We only record a reference when the match is a procedure.
  • select proc(...) of a procedure with output parameters now gets an argument-count finding instead of none. Postgres rejects the statement either way ("is a procedure").

CALL passes an argument for the OUT parameters of a procedure too, so the
call signatures of procedures now include them, like Postgres does with
include_out_arguments. Procedures created in the file return record or
void, so their calls resolve too.

This branch has not been deployed

No deployments
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