[MDEV-10862] Stored procedures: default values for parameters (optional parameters) Created: 2016-09-21  Updated: 2023-11-30

Status: Open
Project: MariaDB Server
Component/s: Data Definition - Procedure, Stored routines
Fix Version/s: None

Type: New Feature Priority: Major
Reporter: Karl Levik Assignee: Unassigned
Resolution: Unresolved Votes: 24
Labels: Compatibility

Issue Links:
Relates
relates to MDEV-524 Request: Variable number of arguments... Open

 Description   

It would be nice if stored procedures supported parameters with default values. This way, if I need to modify a stored procedure to add more parameters to it, my old code with calls to the SP can continue to work. Also, this missing feature could be a blocker for migrations from other SQL DBMSes to MariaDB.

To clarify, I would like to be able to do something like:

DELIMITER //
CREATE PROCEDURE sp(IN p1 INT DEFAULT 1) BEGIN SELECT p1; END //
DELIMITER ;
 
CALL sp();
+------+
| p1   |
+------+
|    1 |
+------+
1 row in set (0.00 sec)
Query OK, 0 rows affected (0.00 sec)

This feature exists e.g. in:
* MS-SQL Server
* PostgresSQL: for functions and for procedures
* SAP HANA. SAP HANA also supports named parameters
* Oracle 10g - note that the value can be an expression
* Sybase - note that the value can be an expression
* DB2
* MemSQL

Note that this is also a long-standing request for MySQL, and users continue to comment on the request to say how useful it would be, e.g. when converting from other DBMSes.

[25 Dec 2005 6:22] Valerii Kravchuk

Thank you for a useful feature request. By optional parameter you mean the one with default value, I believe... So, that the value for it can be ommited in the SP call. Oracle's PL/SQL also has this feature. I think it should be implemented as soon as possible to simplify migration from other RDBMS to MySQL 5.

https://bugs.mysql.com/bug.php?id=15975



 Comments   
Comment by Erkki Laaneoks [ 2020-02-18 ]

So an important feature is not implemented.

Comment by Tadas Balaišis [ 2020-08-30 ]

I think this issue is stalled because it's unassigned. I wait for it too long. Can someone argue why this feature is still unimplemented?

Comment by Karl Levik [ 2020-09-16 ]

I think this issue is stalled because it's unassigned. I wait for it too long. Can someone argue why this feature is still unimplemented?

Hi @Tadas Balaišis - I think it simply needs a bit more votes so that whoever decides the roadmap can see it's a popular feature request.

Generated at Thu Feb 08 07:45:30 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.