From 48c22a68b1ea3c2004e31ace37d56fa8a515dba8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 28 Jun 2017 16:06:07 +0200 Subject: [PATCH] MDEV-13089 identifier quoting in partitioning remove ANSI_QUOTES when generating partition syntax for frm --- mysql-test/suite/parts/r/quoting.result | 30 +++++++++++++++++++++++++ mysql-test/suite/parts/t/quoting.test | 13 +++++++++++ sql/sql_table.cc | 10 +++++---- 3 files changed, 49 insertions(+), 4 deletions(-) diff --git a/mysql-test/suite/parts/r/quoting.result b/mysql-test/suite/parts/r/quoting.result index 9495d790805..66606832e77 100644 --- a/mysql-test/suite/parts/r/quoting.result +++ b/mysql-test/suite/parts/r/quoting.result @@ -60,4 +60,34 @@ t2 CREATE TABLE `t2` ( ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PARTITION BY RANGE (`f1`) (PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = MyISAM) +flush tables; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `select` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`select`) +(PARTITION `select` VALUES LESS THAN MAXVALUE ENGINE = MyISAM) +show create table t2; +Table Create Table +t2 CREATE TABLE `t2` ( + `f1` int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY RANGE (`f1`) +(PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = MyISAM) +set sql_mode=ansi_quotes; +show create table t1; +Table Create Table +t1 CREATE TABLE "t1" ( + "select" int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY RANGE ("select") +(PARTITION "select" VALUES LESS THAN MAXVALUE ENGINE = MyISAM) +show create table t2; +Table Create Table +t2 CREATE TABLE "t2" ( + "f1" int(11) DEFAULT NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 + PARTITION BY RANGE ("f1") +(PARTITION "p1" VALUES LESS THAN MAXVALUE ENGINE = MyISAM) drop table t1, t2; diff --git a/mysql-test/suite/parts/t/quoting.test b/mysql-test/suite/parts/t/quoting.test index 4fec9a4f319..61af8d2d345 100644 --- a/mysql-test/suite/parts/t/quoting.test +++ b/mysql-test/suite/parts/t/quoting.test @@ -5,15 +5,28 @@ source include/have_partition.inc; set sql_mode=ansi_quotes; create table t1 ("select" int) partition by range ("select") (partition "select" values less than maxvalue); create table t2 (f1 int) partition by range (f1) (partition p1 values less than maxvalue); +# "select", "f1", "p1" show create table t1; show create table t2; set sql_quote_show_create=0; +# "select", f1, p1 show create table t1; show create table t2; set sql_mode=default; +# `select`, f1, p1 show create table t1; show create table t2; set sql_quote_show_create=1; +# `select`, `f1`, `p1` +show create table t1; +show create table t2; +# re-parse +flush tables; +# `select`, `f1`, `p1` +show create table t1; +show create table t2; +set sql_mode=ansi_quotes; +# "select", "f1", "p1" show create table t1; show create table t2; drop table t1, t2; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 222b3182114..5e247915905 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -4543,10 +4543,12 @@ handler *mysql_create_frm_image(THD *thd, We reverse the partitioning parser and generate a standard format for syntax stored in frm file. */ - if (!(part_syntax_buf= generate_partition_syntax(thd, part_info, - &syntax_len, TRUE, - create_info, - alter_info))) + sql_mode_t old_mode= thd->variables.sql_mode; + thd->variables.sql_mode &= ~MODE_ANSI_QUOTES; + part_syntax_buf= generate_partition_syntax(thd, part_info, &syntax_len, + true, create_info, alter_info); + thd->variables.sql_mode= old_mode; + if (!part_syntax_buf) goto err; part_info->part_info_string= part_syntax_buf; part_info->part_info_len= syntax_len;