Skip to content

Commit 48c22a6

Browse files
committed
MDEV-13089 identifier quoting in partitioning
remove ANSI_QUOTES when generating partition syntax for frm
1 parent e1093e2 commit 48c22a6

File tree

3 files changed

+49
-4
lines changed

3 files changed

+49
-4
lines changed

mysql-test/suite/parts/r/quoting.result

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,34 @@ t2 CREATE TABLE `t2` (
6060
) ENGINE=MyISAM DEFAULT CHARSET=latin1
6161
PARTITION BY RANGE (`f1`)
6262
(PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = MyISAM)
63+
flush tables;
64+
show create table t1;
65+
Table Create Table
66+
t1 CREATE TABLE `t1` (
67+
`select` int(11) DEFAULT NULL
68+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
69+
PARTITION BY RANGE (`select`)
70+
(PARTITION `select` VALUES LESS THAN MAXVALUE ENGINE = MyISAM)
71+
show create table t2;
72+
Table Create Table
73+
t2 CREATE TABLE `t2` (
74+
`f1` int(11) DEFAULT NULL
75+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
76+
PARTITION BY RANGE (`f1`)
77+
(PARTITION `p1` VALUES LESS THAN MAXVALUE ENGINE = MyISAM)
78+
set sql_mode=ansi_quotes;
79+
show create table t1;
80+
Table Create Table
81+
t1 CREATE TABLE "t1" (
82+
"select" int(11) DEFAULT NULL
83+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
84+
PARTITION BY RANGE ("select")
85+
(PARTITION "select" VALUES LESS THAN MAXVALUE ENGINE = MyISAM)
86+
show create table t2;
87+
Table Create Table
88+
t2 CREATE TABLE "t2" (
89+
"f1" int(11) DEFAULT NULL
90+
) ENGINE=MyISAM DEFAULT CHARSET=latin1
91+
PARTITION BY RANGE ("f1")
92+
(PARTITION "p1" VALUES LESS THAN MAXVALUE ENGINE = MyISAM)
6393
drop table t1, t2;

mysql-test/suite/parts/t/quoting.test

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,28 @@ source include/have_partition.inc;
55
set sql_mode=ansi_quotes;
66
create table t1 ("select" int) partition by range ("select") (partition "select" values less than maxvalue);
77
create table t2 (f1 int) partition by range (f1) (partition p1 values less than maxvalue);
8+
# "select", "f1", "p1"
89
show create table t1;
910
show create table t2;
1011
set sql_quote_show_create=0;
12+
# "select", f1, p1
1113
show create table t1;
1214
show create table t2;
1315
set sql_mode=default;
16+
# `select`, f1, p1
1417
show create table t1;
1518
show create table t2;
1619
set sql_quote_show_create=1;
20+
# `select`, `f1`, `p1`
21+
show create table t1;
22+
show create table t2;
23+
# re-parse
24+
flush tables;
25+
# `select`, `f1`, `p1`
26+
show create table t1;
27+
show create table t2;
28+
set sql_mode=ansi_quotes;
29+
# "select", "f1", "p1"
1730
show create table t1;
1831
show create table t2;
1932
drop table t1, t2;

sql/sql_table.cc

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4543,10 +4543,12 @@ handler *mysql_create_frm_image(THD *thd,
45434543
We reverse the partitioning parser and generate a standard format
45444544
for syntax stored in frm file.
45454545
*/
4546-
if (!(part_syntax_buf= generate_partition_syntax(thd, part_info,
4547-
&syntax_len, TRUE,
4548-
create_info,
4549-
alter_info)))
4546+
sql_mode_t old_mode= thd->variables.sql_mode;
4547+
thd->variables.sql_mode &= ~MODE_ANSI_QUOTES;
4548+
part_syntax_buf= generate_partition_syntax(thd, part_info, &syntax_len,
4549+
true, create_info, alter_info);
4550+
thd->variables.sql_mode= old_mode;
4551+
if (!part_syntax_buf)
45504552
goto err;
45514553
part_info->part_info_string= part_syntax_buf;
45524554
part_info->part_info_len= syntax_len;

0 commit comments

Comments
 (0)