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

EXCEPTION reserved keyword in SQL_MODE=oracle but not in Oracle itself

Details

    • Bug
    • Status: Closed (View Workflow)
    • Minor
    • Resolution: Fixed
    • 10.3.1
    • 10.3.2
    • Parser
    • None

    Description

      "Exception" is not a reserved word in MariaDB usually, but it is when SQL_MODE is set to "Oracle". This is odd, as "exception" is not a SQL keyword in Oracle itself (tested with Oracle 11.2). When sql_mode is not set to Oracle, this is not the case.

      $ mysql -u root test
      Welcome to the MariaDB monitor.  Commands end with ; or \g.
      Your MariaDB connection id is 15
      Server version: 10.3.1-MariaDB MariaDB Server
       
      Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
       
      Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
       
      MariaDB [test]> create table tt1(c1 int);
      Query OK, 0 rows affected (0.021 sec)
       
      MariaDB [test]> create view v1 as select c1 exception from tt1;
      Query OK, 0 rows affected (0.003 sec)
       
      MariaDB [test]> drop view v1;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> set sql_mode=oracle;
      Query OK, 0 rows affected (0.000 sec)
       
      MariaDB [test]> create view v1 as select c1 exception from tt1;
      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 'exception from tt1' at line 1
      

      In SQLPlus:

      $ sqlplus anders/XXXXXXXX
       
      SQL*Plus: Release 11.2.0.2.0 Production on Thu Aug 31 10:28:27 2017
       
      Copyright (c) 1982, 2011, Oracle.  All rights reserved.
       
       
      Connected to:
      Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
       
      SQL> create table tt1(c1 int);
       
      Table created.
       
      SQL> create view v1 as select c1 exception from tt1;
       
      View created.
      

      Attachments

        Activity

          I couldn't find it in the standard (draft 2011) either.

          It was apparently added in the scope of MDEV-10411, somewhere here:

          commit 8fdc1f0147cd77d3191139247a4c54d1f1cbe189
          Author: Alexander Barkov <bar@mariadb.org>
          Date:   Thu Aug 11 14:12:14 2016 +0400
           
              MDEV-10411 Providing compatibility for basic PL/SQL constructs
              
              Part 9: EXCEPTION handlers
              
              - Adding exception handler syntax:
                WHEN exception_name THEN statement
              - Adding EXCEPTION section intoi the top BEGIN..END SP block.
                Note, currently EXCEPTION goes in the beginning of the top BEGIN..END
                SP block.
              
              TODO:
              - add EXCEPTION section into inner blocks
              - move EXCEPTION to the end of the block
          

          elenst Elena Stepanova added a comment - I couldn't find it in the standard (draft 2011) either. It was apparently added in the scope of MDEV-10411 , somewhere here: commit 8fdc1f0147cd77d3191139247a4c54d1f1cbe189 Author: Alexander Barkov <bar@mariadb.org> Date: Thu Aug 11 14:12:14 2016 +0400   MDEV-10411 Providing compatibility for basic PL/SQL constructs Part 9: EXCEPTION handlers - Adding exception handler syntax: WHEN exception_name THEN statement - Adding EXCEPTION section intoi the top BEGIN..END SP block. Note, currently EXCEPTION goes in the beginning of the top BEGIN..END SP block. TODO: - add EXCEPTION section into inner blocks - move EXCEPTION to the end of the block

          Pushed into bb-10.2-ext and 10.3.

          bar Alexander Barkov added a comment - Pushed into bb-10.2-ext and 10.3.

          People

            bar Alexander Barkov
            karlsson Anders Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            4 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.