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

Problems with a stored function EMPTY() on upgrade to 10.6

    XMLWordPrintable

Details

    Description

      This script:

      CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0;
      SELECT empty('1');
      

      used to work without any unexpected side effects prior to 10.6:

      MariaDB [test]> CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0;
      Query OK, 0 rows affected (0.007 sec)
       
      MariaDB [test]> SELECT empty('1');
      +------------+
      | empty('1') |
      +------------+
      |          0 |
      +------------+
      1 row in set (0.002 sec)
      

      Starting from 10.6, behavior changed:

      The CREATE statement now raises a warnings:

      CREATE OR REPLACE FUNCTION empty(a VARCHAR(128)) RETURNS int RETURN LENGTH(a)=0;
      SHOW WARNINGS;
      

      +-------+------+--------------------------------------------------------------+
      | Level | Code | Message                                                      |
      +-------+------+--------------------------------------------------------------+
      | Note  | 1585 | This function 'empty' has the same name as a native function |
      +-------+------+--------------------------------------------------------------+
      

      The warning is not correct. 'empty' is not a native function! It's only a new 10.6 non-reserved keyword. There should not be any warnings.

      The SELECT statement now raises a syntax error:

      SELECT empty('1');
      

      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '('1')' at line 1
      

      This is wrong. No errors expected.

      These behavior changes raise problems on upgrade.

      The problem was caused by MDEV-17399.

      Other keywords added in MDEV-17399 should also be checked for the same problem:

      +%token  <kwd> EMPTY_SYM                     /* SQL-2016-R */
      +%token  <rwd> JSON_TABLE_SYM
      +%token  <kwd> NESTED_SYM                    /* SQL-2003-N */
      +%token  <kwd> ORDINALITY_SYM                /* SQL-2003-N */
      +%token  <kwd> PATH_SYM                      /* SQL-2003-N */
      

      Attachments

        Issue Links

          Activity

            People

              holyfoot Alexey Botchkov
              bar Alexander Barkov
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

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