Skip to content
/ server Public

Comments

MDEV-38329: Named Parameters in Invocation of Stored Routines#4681

Draft
rajatmohan22 wants to merge 3 commits intoMariaDB:mainfrom
rajatmohan22:named-params-feature
Draft

MDEV-38329: Named Parameters in Invocation of Stored Routines#4681
rajatmohan22 wants to merge 3 commits intoMariaDB:mainfrom
rajatmohan22:named-params-feature

Conversation

@rajatmohan22
Copy link

MDEV-38329: Named Parameters in Invocation of Stored Routines

Description

This a draft PR begins implimentation of support for named parameters in stored routine invocation, for ex:

CALL proc(param3 => 10, param5 => 'foo');
SELECT func(param2 => 3.1415);

Current State

right now CALL arguments are parsed strictly as positional expressions -

  • CALLopt_sp_cparam_listsp_cparams
  • Each argument is parsed as expr
  • Arguments are pushed into Lex->value_list
  • Binding in sp_head::execute_procedure() is strictly positional

There is no syntax of argument names and no name-based resolution. This PR starts adding support for ident => expr syntax.


Current Commit (WIP)

Commit 1: Introduce CALL parameter structure

Adds a Call_param structure in LEX:
LEX_CSTRING name
Item *value
Adds List<Call_param> call_param_list

Clears call_param_list in call_statement_start()

No functional changes yet.
Parser and binding logic remain unchanged.

This commit prepares the LEX layer to store named arguments in addition to positional ones.


Planned Implementation Steps

The remaining work to follow in additional commits in this PR:

1. Extend grammar in sql/sql_yacc.yy to allow both expr and ident => expr inside routine argument lists.

2. Represent CALL arguments as structured entries instead of raw Item* only, e.g. { name, Item* } where name is empty for positional arguments.

3. Add a resolution step before calling sp_head::execute_procedure(thd, &args). This step will:

  • Resolve named arguments using sp_pcontext / sp_variable
  • Preserve positional arguments (positional first, then named)
  • Apply default values for omitted parameters
  • Error on unknown parameter names, duplicate parameters, and missing required parameters

4. Add MTR tests covering procedures, stored functions, mixed positional + named usage, and error cases.


Design Direction

Resolution will occur before invoking execute_procedure() so that the existing positional binding logic — adjust_formal_params_to_actual_params() and bind_input_param() — can remain largely unchanged.


This PR is opened as a draft for early feedback on approach before implementing grammar and resolution logic.

@CLAassistant
Copy link

CLAassistant commented Feb 22, 2026

CLA assistant check
All committers have signed the CLA.

@rajatmohan22 rajatmohan22 changed the title add lexer support MDEV-38329: Named Parameters in Invocation of Stored Routines Feb 22, 2026
@rajatmohan22
Copy link
Author

@abarkov @gkodinov hello,

I’ve pushed the initial groundwork for MDEV-38329 (introducing the Call_param structure in LEX and wiring it into call_statement_start(), no functional changes yet).

I’m currently continuing to research the execution and binding flow carefully before moving to the next step. I’d really appreciate your feedback when you have a moment and your help in keeping tabs on this PR so I stay aligned with the intended direction.

Thank you very much.

@gkodinov gkodinov added the External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements. label Feb 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

External Contribution All PRs from entities outside of MariaDB Foundation, Corporation, Codership agreements.

Development

Successfully merging this pull request may close these issues.

3 participants