Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-18951

Polymorphic Data Types for Functions

    XMLWordPrintable

Details

    • New Feature
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • Stored routines
    • 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

          Activity

            People

              Unassigned Unassigned
              warp Markus Peter
              Votes:
              2 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.