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

Report disallowed subquery errors as such (instead of parse error)

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Blocker
    • Resolution: Fixed
    • 10.4.9
    • Parser
    • None

    Description

      Subqueries are not allowed in a number of clauses, e.g.:

      • EXECUTE IMMEDIATE expr
      • EXECUTE .. USING expr
      • PREPARE stmt FROM expr
      • SELECT .. PROCEDURE ANALYSE(expr, expr)
      • PURGE BINARY LOGS BEFORE expr
      • HANDLER t1 READ a=expr

      If a subquery appears in a disallowed context, a syntax error is reported:

      EXECUTE IMMEDIATE (SELECT 'SELECT 1');
      

      ERROR 42000: You have an error in your SQL syntax ... near 'SELECT 'SELECT 1')' at line 1
      

      The grammar uses remember_tok_start to remember the start position of a subquery, to use this position for error reporting:

      subselect:
                remember_tok_start
                query_expression
                {
                  if (!($$= Lex->parsed_subselect($2, $1)))
                    YYABORT;
                }
              ;
      

      Under terms of MDEV-19956 the grammar will be changed significantly. The remember_tok_start has to be removed to avoid shift/reduce and reduce/reduce conflicts.

      Let's change the error message from ER_SYNTAX_ERROR to ER_SUBQUERIES_NOT_SUPPORTED.
      So it will look as follows:

      EXECUTE IMMEDIATE (SELECT 'SELECT 1');
      

      ERROR 42000: EXECUTE IMMEDIATE does not support subqueries or stored functions
      

      Rationale:

      • Preserving the old messages is challenging
      • The proposed error message is more informative

      Attachments

        Issue Links

          Activity

            People

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