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

Incorrect behaviour of SET STATEMENT in case it is executed as a prepared statement

Details

    Description

      While working on the task MDEV-16708 (Unsupported commands for prepared statements)
      I hit the bug caused by incorrect handling of the ' SET STATEMENT' clause when the whole statement, containing the 'SET STATEMENT' clause, is executed in prepared statement mode.

      The following test case shows the incorrect behavior:

      PREPARE stmt FROM "SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR CREATE TABLE t1 AS SELECT CONCAT('abc') AS c1";
      EXECUTE stmt;
      DEALLOCATE PREPARE stmt;
      SHOW CREATE TABLE t1;
      Table	Create Table
      t1	CREATE TABLE `t1` (
        `c1` varchar(3) DEFAULT NULL
      ) ENGINE=MyISAM DEFAULT CHARSET=latin1
      DROP TABLE t1;
      

      It's expected that the output from the command SHOW CREATE TABLE t1 shows
      `c1` varchar(3) CHARACTER SET utf8 NOT NULL
      for the column c1 as it takes place in case this statement is run as a regular statement.

      Instead, SHOW CREATE TABLE t1 outputs the following data
      `c1` varchar(3) CHARACTER SET utf8 DEFAULT NULL
      as a definition of the column c1

      Attachments

        Issue Links

          Activity

            shulga Dmitry Shulga created issue -
            shulga Dmitry Shulga made changes -
            Field Original Value New Value
            Fix Version/s 10.2 [ 14601 ]
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            shulga Dmitry Shulga made changes -
            Status Open [ 1 ] In Progress [ 3 ]
            shulga Dmitry Shulga made changes -
            Assignee Dmitry Shulga [ JIRAUSER47315 ] Oleksandr Byelkin [ sanja ]
            Status In Progress [ 3 ] In Review [ 10002 ]
            shulga Dmitry Shulga made changes -
            sanja Oleksandr Byelkin made changes -
            Assignee Oleksandr Byelkin [ sanja ] Dmitry Shulga [ JIRAUSER47315 ]
            Status In Review [ 10002 ] Stalled [ 10000 ]
            serg Sergei Golubchik made changes -
            Description While working on the task MDEV-16708 (Unsupported commands for prepared statements)
            I hit the bug caused by incorrect handling of the ' SET STATEMENT' clause when the whole statement, containing the 'SET STATEMENT' clause, is executed in prepared statement mode.

            The following test case shows the incorrect behavior:

            PREPARE stmt FROM "SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR CREATE TABLE t1 AS SELECT CONCAT('abc') AS c1";
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
            SHOW CREATE TABLE t1;
            Table Create Table
            t1 CREATE TABLE `t1` (
              `c1` varchar(3) DEFAULT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1
            DROP TABLE t1;

            It's expected that the output from the command SHOW CREATE TABLE t1 shows
             `c1` varchar(3) CHARACTER SET utf8 NOT NULL
            for the column c1 as it takes place in case this statement is run as a regular statement.

            Instead, SHOW CREATE TABLE t1 outputs the following data
            `c1` varchar(3) CHARACTER SET utf8 DEFAULT NULL
            as a definition of the column c1

            While working on the task MDEV-16708 (Unsupported commands for prepared statements)
            I hit the bug caused by incorrect handling of the ' SET STATEMENT' clause when the whole statement, containing the 'SET STATEMENT' clause, is executed in prepared statement mode.

            The following test case shows the incorrect behavior:
            {code:sql}
            PREPARE stmt FROM "SET STATEMENT sql_mode = 'NO_ENGINE_SUBSTITUTION' FOR CREATE TABLE t1 AS SELECT CONCAT('abc') AS c1";
            EXECUTE stmt;
            DEALLOCATE PREPARE stmt;
            SHOW CREATE TABLE t1;
            Table Create Table
            t1 CREATE TABLE `t1` (
              `c1` varchar(3) DEFAULT NULL
            ) ENGINE=MyISAM DEFAULT CHARSET=latin1
            DROP TABLE t1;
            {code}
            It's expected that the output from the command SHOW CREATE TABLE t1 shows
             `c1` varchar(3) CHARACTER SET utf8 NOT NULL
            for the column c1 as it takes place in case this statement is run as a regular statement.

            Instead, SHOW CREATE TABLE t1 outputs the following data
            `c1` varchar(3) CHARACTER SET utf8 DEFAULT NULL
            as a definition of the column c1

            shulga Dmitry Shulga made changes -
            issue.field.resolutiondate 2021-02-25 07:42:09.0 2021-02-25 07:42:09.526
            shulga Dmitry Shulga made changes -
            Fix Version/s 10.2.38 [ 25207 ]
            Fix Version/s 10.3.29 [ 25206 ]
            Fix Version/s 10.4.19 [ 25205 ]
            Fix Version/s 10.5.10 [ 25204 ]
            Fix Version/s 10.6.0 [ 24431 ]
            Fix Version/s 10.2 [ 14601 ]
            Fix Version/s 10.3 [ 22126 ]
            Fix Version/s 10.4 [ 22408 ]
            Fix Version/s 10.5 [ 23123 ]
            Fix Version/s 10.6 [ 24028 ]
            Resolution Fixed [ 1 ]
            Status Stalled [ 10000 ] Closed [ 6 ]
            serg Sergei Golubchik made changes -
            Workflow MariaDB v3 [ 119146 ] MariaDB v4 [ 158895 ]
            serg Sergei Golubchik made changes -

            People

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