Details
-
New Feature
-
Status: Closed (View Workflow)
-
Critical
-
Resolution: Fixed
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.
Attachments
Issue Links
- blocks
-
MDEV-34323 Oracle compatibility project 3
-
- Open
-
- causes
-
MDEV-35925 OUT and INOUT parameters shouldn't expect a default value
-
- Closed
-
- is duplicated by
-
MDEV-20238 sql_mode="oracle" does not support "DEFAULT" parameters for functions/procedures
-
- Closed
-
- is part of
-
MDEV-35973 Oracle Compatibility Project 1 for 2025
-
- In Progress
-
- relates to
-
MDEV-524 Request: Variable number of arguments in Stored Routines
-
- Open
-
-
MDEV-34316 sql_mode=ORACLE: Ignore the NOCOPY keyword in stored routine parameters
-
- Closed
-
-
MDEV-34484 Overloading in package routines
-
- Open
-
-
MDEV-35965 Oracle: Named and Mixed notations for stored routine call parameters
-
- Open
-
I've completed my testing with the following test cases.
1. Default data types including JSON and VECTOR.
2. Expressions as default value
3. Other stored routines in default value expression
4. Out of range value
5. Invalid data type in default value
6. NULL value
7. IN, OUT, INOUT parameters in a stored procedure
8. Packages
9. User defined functions
10. Parameter positions with both allowed and not-allowed default values.
The test results are looking good. OK for push from QA.