Details
-
Bug
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
-
11.8.0
-
None
Description
Default value for OUT and INOUT parameters in a stored procedure is not supported. But when an OUT or INOUT parameter is supplied along with an IN parameter with a default value we error out expecting the same for OUT or INOUT parameter.
Repro:
11.8.0-opt>DELIMITER $$
|
11.8.0-opt>CREATE OR REPLACE PROCEDURE sp1(IN p1 INT DEFAULT 0, OUT p2 INT DEFAULT 5) BEGIN SET p2 = p2 + 1; END$$ |
ERROR 4032 (HY000): Default/ignore value is not supported for such parameter usage |
|
11.8.0-opt>CREATE OR REPLACE PROCEDURE sp1(IN p1 INT DEFAULT 0, OUT p2 INT) BEGIN SET p2 = p2 + 1; END$$ |
ERROR 1230 (42000): Variable 'p2' doesn't have a default value |
11.8.0-opt>
|
Expected behavior:
The following CREATE PROCEDURE should succeed.
CREATE OR REPLACE PROCEDURE sp1(IN p1 INT DEFAULT 0, OUT p2 INT) |
Attachments
Issue Links
- is caused by
-
MDEV-10862 Stored procedures: default values for parameters (optional parameters)
-
- Closed
-
Activity
Field | Original Value | New Value |
---|---|---|
Link |
This issue is caused by |
Assignee | Alexander Barkov [ bar ] |
issue.field.resolutiondate | 2025-01-28 09:24:04.0 | 2025-01-28 09:24:03.731 |
Fix Version/s | 11.8.1 [ 29961 ] | |
Fix Version/s | 11.8 [ 29921 ] | |
Resolution | Fixed [ 1 ] | |
Status | Open [ 1 ] | Closed [ 6 ] |
susil.behera, thanks for reporting.
You're right. For example, this script works fine in Oracle:
BEGIN
p2:= p1;
/
BEGIN
sp1(p2=>v);
DBMS_OUTPUT.PUT_LINE(v);
/
CALL sp2;
and produces "123" output.
MariaDB does not allow to pass routine parameters by name, using the arrow syntax like p2=>v.
Perhaps putting OUT parameters after IN-WITH-DEFAUT parameters should be implemented together with the arrow syntax.
Do you know any other use cases of this parameter combination other than calling with arrow syntax?