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

Inconsistency in handling empty comments in direct vs prepared execution

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.6, 10.11, 10.7(EOL), 10.8(EOL), 10.9(EOL), 11.0(EOL)
    • 10.6, 10.11
    • Parser

    Description

      There is an inconsistency in handling comments between direct execution and prepared execution.

      Direct execution in 10.3 and 10.11 works as follow:

      • a. Executable comment, condition=TRUE

        MariaDB [test]> /*M!50701 MariaDB-10.x does not ignore this */;
        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 'MariaDB-10.x does not ignore this */' at line 1
        

      • b. Executable comment, condition=FALSE

        MariaDB [test]> /*M!200101 MariaDB-10.x ignores this */;
        Query OK, 0 rows affected (0.000 sec)
        

      • c. Non-executable comment

        MariaDB [test]> /* */;
        ERROR: No query specified
        

      So far so good.

      Prepared execution (see below) works differently, which is not good.
      Moreover, there is an unintentional change in prepared execution (most likely happened in 10.6 by MDEV-16708) - prepared execution in 10.11 for a statement consisting only of a non-executable comment returns OK, which became not consistent with direct execution.

      Prepared execution in 10.3:

      • a. Executible comment, condition=TRUE

        MariaDB [test]> EXECUTE IMMEDIATE '/*M!50701 MariaDB:10.x does not ignore this*/';
        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 'MariaDB:10.x does not ignore this*/' at line 1
        

      • b. Executable comment, condition=FALSE

        MariaDB [test]> EXECUTE IMMEDIATE '/*M!200101 MariaDB-10.x ignores this */';
        ERROR 1295 (HY000): This command is not supported in the prepared statement protocol yet
        

      • c. Non-executable comment

        MariaDB [test]> EXECUTE IMMEDIATE '/* */';
        ERROR 1295 (HY000): This command is not supported in the prepared statement protocol yet
        

      Notice, (b) and (c) work differently comparing to direct execution.

      Prepared execution in 10.11:

      • a. Executible comment, condition=TRUE

        MariaDB [test]> EXECUTE IMMEDIATE '/*M!50701 MariaDB-10.x does not ignore this */';
        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 'MariaDB-10.x does not ignore this */' at line 1
        

      • b. Executable comment, condition=FALSE

        MariaDB [test]> EXECUTE IMMEDIATE '/*M!200101 MariaDB-10.x ignores this */';
        Query OK, 0 rows affected (0.001 sec)
        

      • c. Non-executable comment

        MariaDB [test]> EXECUTE IMMEDIATE '/* */';
        Query OK, 0 rows affected (0.001 sec)
        

      Notice:

      • (a) works in the same way in both 10.3 and 10.11, in both direct and prepared execution.
      • (b) prepared execution (in 10.11) has changed since 10.3. Now it works like direct execution, which should be good.
      • (c) prepared execution (in 10.11) has changed since 10.3. Now it returns OK. It used to return an error in 10.3. It should be fixed. The best choice would be to return an empty query error, like direct execution does.

      Attachments

        Issue Links

          Activity

            People

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