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

MariaDB client puts unnecessary backticks in show create table

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 10.2.14
    • N/A
    • Scripts & Clients
    • None

    Description

      Starting with 10.2 (not sure which minor version) the mysql client is wrapping partition names and columns in partition functions inside backticks.

      This is not standard behaviour for the client and breaks partitioning scripts.

      10.1 output:

      MariaDB [test]> show create table actor\G
      *************************** 1. row ***************************
             Table: actor
      Create Table: CREATE TABLE `actor` (
        `actor_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
        `first_name` varchar(45) NOT NULL,
        `last_name` varchar(45) NOT NULL,
        `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
        PRIMARY KEY (`actor_id`,`last_update`),
        KEY `idx_actor_last_name` (`last_name`),
        KEY `last_update` (`last_update`)
      ) ENGINE=InnoDB AUTO_INCREMENT=201 DEFAULT CHARSET=utf8
      /*!50100 PARTITION BY RANGE (unix_timestamp(last_update))
      (PARTITION p0 VALUES LESS THAN (1522900800) ENGINE = InnoDB,
       PARTITION p1 VALUES LESS THAN (1522987200) ENGINE = InnoDB,
       PARTITION p2 VALUES LESS THAN (1523073600) ENGINE = InnoDB,
       PARTITION p3 VALUES LESS THAN (1523160000) ENGINE = InnoDB,
       PARTITION p4 VALUES LESS THAN (1523246400) ENGINE = InnoDB,
       PARTITION p5 VALUES LESS THAN (1523332800) ENGINE = InnoDB,
       PARTITION p6 VALUES LESS THAN (1523419200) ENGINE = InnoDB,
       PARTITION p7 VALUES LESS THAN (1523505600) ENGINE = InnoDB,
       PARTITION p8 VALUES LESS THAN (1523592000) ENGINE = InnoDB,
       PARTITION p9 VALUES LESS THAN (1523678400) ENGINE = InnoDB,
       PARTITION p10 VALUES LESS THAN (1523764800) ENGINE = InnoDB,
       PARTITION p11 VALUES LESS THAN (1523851200) ENGINE = InnoDB,
       PARTITION p12 VALUES LESS THAN (1523937600) ENGINE = InnoDB,
       PARTITION p13 VALUES LESS THAN (1524024000) ENGINE = InnoDB,
       PARTITION p14 VALUES LESS THAN (1524110400) ENGINE = InnoDB,
       PARTITION p15 VALUES LESS THAN (1524196800) ENGINE = InnoDB,
       PARTITION p16 VALUES LESS THAN (1524283200) ENGINE = InnoDB,
       PARTITION p17 VALUES LESS THAN (1524369600) ENGINE = InnoDB) */
      1 row in set (0.00 sec)
      

      10.2 output:

      MariaDB [test]> show create table actor\G
      *************************** 1. row ***************************
             Table: actor
      Create Table: CREATE TABLE `actor` (
        `actor_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,
        `first_name` varchar(45) NOT NULL,
        `last_name` varchar(45) NOT NULL,
        `last_update` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
        PRIMARY KEY (`actor_id`,`last_update`),
        KEY `idx_actor_last_name` (`last_name`),
        KEY `last_update` (`last_update`)
      ) ENGINE=InnoDB DEFAULT CHARSET=utf8
       PARTITION BY RANGE (unix_timestamp(`last_update`))
      (PARTITION `p0` VALUES LESS THAN (1522900800) ENGINE = InnoDB,
       PARTITION `p1` VALUES LESS THAN (1522987200) ENGINE = InnoDB,
       PARTITION `p2` VALUES LESS THAN (1523073600) ENGINE = InnoDB,
       PARTITION `p3` VALUES LESS THAN (1523160000) ENGINE = InnoDB,
       PARTITION `p4` VALUES LESS THAN (1523246400) ENGINE = InnoDB,
       PARTITION `p5` VALUES LESS THAN (1523332800) ENGINE = InnoDB,
       PARTITION `p6` VALUES LESS THAN (1523419200) ENGINE = InnoDB,
       PARTITION `p7` VALUES LESS THAN (1523505600) ENGINE = InnoDB,
       PARTITION `p8` VALUES LESS THAN (1523592000) ENGINE = InnoDB,
       PARTITION `p9` VALUES LESS THAN (1523678400) ENGINE = InnoDB,
       PARTITION `p10` VALUES LESS THAN (1523764800) ENGINE = InnoDB,
       PARTITION `p11` VALUES LESS THAN (1523851200) ENGINE = InnoDB,
       PARTITION `p12` VALUES LESS THAN (1523937600) ENGINE = InnoDB,
       PARTITION `p13` VALUES LESS THAN (1524024000) ENGINE = InnoDB,
       PARTITION `p14` VALUES LESS THAN (1524110400) ENGINE = InnoDB,
       PARTITION `p15` VALUES LESS THAN (1524196800) ENGINE = InnoDB,
       PARTITION `p16` VALUES LESS THAN (1524283200) ENGINE = InnoDB,
       PARTITION `p17` VALUES LESS THAN (1524369600) ENGINE = InnoDB)*/
      

      Attachments

        Issue Links

          Activity

            This was an intentional change, a bug fix for MDEV-13089.
            The standard behavior is to quote (or not) all identifiers, depending on sql_quote_show_create variable, and to use backticks or double quotes based on the sql_mode. Before MDEV-13089 was fixed, partitioning wasn't using this rule which made the output of SHOW CREATE TABLE unusable if partition names were reserved words or in the ANSI_QUOTES mode. And, depending on partition names and sql_mode you could've ended up with the corrupted table that could not be opened at all (because partition definition is saved as an excerpt from SHOW CREATE TABLE). The fix was to use quoting rules consistently for all identifiers in SHOW CREATE TABLE.

            serg Sergei Golubchik added a comment - This was an intentional change, a bug fix for MDEV-13089 . The standard behavior is to quote (or not) all identifiers, depending on sql_quote_show_create variable, and to use backticks or double quotes based on the sql_mode . Before MDEV-13089 was fixed, partitioning wasn't using this rule which made the output of SHOW CREATE TABLE unusable if partition names were reserved words or in the ANSI_QUOTES mode. And, depending on partition names and sql_mode you could've ended up with the corrupted table that could not be opened at all (because partition definition is saved as an excerpt from SHOW CREATE TABLE ). The fix was to use quoting rules consistently for all identifiers in SHOW CREATE TABLE .

            So, what can we do to revert to the so called "classic mode"?

            tried set global sql_quote_show_create = OFF and didn't change the output.

            Rick

            rpizzi Rick Pizzi (Inactive) added a comment - So, what can we do to revert to the so called "classic mode"? tried set global sql_quote_show_create = OFF and didn't change the output. Rick
            rpizzi Rick Pizzi (Inactive) added a comment - - edited

            Actually, I think the biggest problem is the content of information_schema.PARTITIONS table, which now contains backticks in the PARTITION_EXPRESSION.

            Again, this is breaking scripts that we use in prod, for no good reason IMHO.

            rpizzi Rick Pizzi (Inactive) added a comment - - edited Actually, I think the biggest problem is the content of information_schema.PARTITIONS table, which now contains backticks in the PARTITION_EXPRESSION. Again, this is breaking scripts that we use in prod, for no good reason IMHO.

            set global sql_quote_show_create = OFF didn't work, probably, because you've only changed the global value not the session value in the current connection.

            The "good reason" was making partitioned tables usable. Without MDEV-13089 fix one was able to create a table, successfully, that could not be opened afterwards —- that was clearly a bug.

            serg Sergei Golubchik added a comment - set global sql_quote_show_create = OFF didn't work, probably, because you've only changed the global value not the session value in the current connection. The "good reason" was making partitioned tables usable. Without MDEV-13089 fix one was able to create a table, successfully, that could not be opened afterwards —- that was clearly a bug.

            People

              serg Sergei Golubchik
              rpizzi Rick Pizzi (Inactive)
              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.