[MDEV-16178] MariaDB client puts unnecessary backticks in show create table Created: 2018-05-15  Updated: 2018-05-16  Resolved: 2018-05-15

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.2.14
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Rick Pizzi Assignee: Sergei Golubchik
Resolution: Not a Bug Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-13089 identifier quoting in partitioning Closed

 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)*/



 Comments   
Comment by Sergei Golubchik [ 2018-05-15 ]

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.

Comment by Rick Pizzi [ 2018-05-15 ]

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

Comment by Rick Pizzi [ 2018-05-15 ]

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.

Comment by Sergei Golubchik [ 2018-05-16 ]

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.

Generated at Thu Feb 08 08:26:57 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.