[MDEV-18951] Polymorphic Data Types for Functions Created: 2019-03-17 Updated: 2019-03-22 |
|
| Status: | Open |
| Project: | MariaDB Server |
| Component/s: | Stored routines |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major |
| Reporter: | Markus Peter | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 2 |
| Labels: | 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):
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. |