Details
-
New Feature
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
None
-
None
Description
Support for polymorphic data types in stored functions would be useful. Postgres has ANY, ANYELEMENT, ANYNONARRAY for this: https://www.postgresql.org/docs/9.1/extend-type-system.html
Without this, it's not at the moment possible to create functions which use operators correctly, no matter which datatype was used at the call site. As MariaDB also does not support overloading of functions depending on the types, there's no way to currently fix this.
A non-sensical example illustrating what I want to achieve (vastly simplified):
CREATE OR REPLACE FUNCTION cmp( a, b) RETURNS BOOLEAN |
BEGIN
|
DECLARE tmp BOOLEAN; |
SELECT a < b INTO tmp; |
RETURN tmp; |
END |
No matter which data type I currently use in MariaDB for declaring the function, it will only work for the declared type. If declaring the above with type TEXT and calling with actual numeric types: select cmp(2,10);, parameters will be converted to TEXT first, leading to a text-like instead of numerical comparison. If I use a more specific type, the function will not work at all for the other types.
Attachments
Issue Links
- relates to
-
MDEV-34484 Overloading in package routines
- Open