summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <jimw@mysql.com>2006-04-11 16:03:49 -0700
committerunknown <jimw@mysql.com>2006-04-11 16:03:49 -0700
commit087cae1a1e5c5681886955c44726bddec2c5d94a (patch)
treec57af63df9a5aecdf66e4d16d537232274422cc0
parent16002370c62a5576f7fccb66cdfeaac7957f8090 (diff)
parenta3fb0021778d5fe9968119ff78150dede2f7157b (diff)
downloadmariadb-git-087cae1a1e5c5681886955c44726bddec2c5d94a.tar.gz
Merge bk-internal:/home/bk/mysql-5.1-new
into mysql.com:/home/jimw/my/mysql-5.1-clean
-rw-r--r--mysql-test/r/partition.result17
-rw-r--r--mysql-test/t/partition.test24
-rw-r--r--sql/partition_info.cc12
-rw-r--r--sql/share/errmsg.txt3
-rw-r--r--sql/sql_partition.cc19
-rw-r--r--sql/sql_show.cc5
-rw-r--r--sql/sql_yacc.yy2
7 files changed, 79 insertions, 3 deletions
diff --git a/mysql-test/r/partition.result b/mysql-test/r/partition.result
index ec8bbc16a41..e5b1d443f56 100644
--- a/mysql-test/r/partition.result
+++ b/mysql-test/r/partition.result
@@ -839,6 +839,23 @@ SHOW TABLE STATUS;
Name Engine Version Row_format Rows Avg_row_length Data_length Max_data_length Index_length Data_free Auto_increment Create_time Update_time Check_time Collation Checksum Create_options Comment
t1 MyISAM 10 Dynamic 0 0 0 0 0 0 NULL NULL NULL NULL latin1_swedish_ci NULL partitioned
DROP TABLE t1;
+create table t1 (a int)
+partition by list (a)
+(partition `s1 s2` values in (0));
+drop table t1;
+create table t1 (a int)
+partition by list (a)
+(partition `7` values in (0));
+drop table t1;
+create table t1 (a int)
+partition by list (a)
+(partition `s1 s2 ` values in (0));
+ERROR HY000: Incorrect partition name
+create table t1 (a int)
+partition by list (a)
+subpartition by hash (a)
+(partition p1 values in (0) (subpartition `p1 p2 `));
+ERROR HY000: Incorrect partition name
CREATE TABLE t1 (a int)
PARTITION BY LIST (a)
(PARTITION p0 VALUES IN (NULL));
diff --git a/mysql-test/t/partition.test b/mysql-test/t/partition.test
index c3f1cc6da6d..536ab68a694 100644
--- a/mysql-test/t/partition.test
+++ b/mysql-test/t/partition.test
@@ -957,6 +957,30 @@ SHOW TABLE STATUS;
DROP TABLE t1;
#
+#BUG 18750 Problems with partition names
+#
+create table t1 (a int)
+partition by list (a)
+(partition `s1 s2` values in (0));
+drop table t1;
+
+create table t1 (a int)
+partition by list (a)
+(partition `7` values in (0));
+drop table t1;
+
+--error ER_WRONG_PARTITION_NAME
+create table t1 (a int)
+partition by list (a)
+(partition `s1 s2 ` values in (0));
+
+--error ER_WRONG_PARTITION_NAME
+create table t1 (a int)
+partition by list (a)
+subpartition by hash (a)
+(partition p1 values in (0) (subpartition `p1 p2 `));
+
+#
# BUG 18752 SHOW CREATE TABLE doesn't show NULL value in SHOW CREATE TABLE
#
CREATE TABLE t1 (a int)
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index ad0aa053ae2..e2bf37d6ef3 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -696,6 +696,12 @@ bool partition_info::check_partition_info(handlerton **eng_type,
partition_element *part_elem= part_it++;
if (!is_sub_partitioned())
{
+ if (check_table_name(part_elem->partition_name,
+ strlen(part_elem->partition_name)))
+ {
+ my_error(ER_WRONG_PARTITION_NAME, MYF(0));
+ goto end;
+ }
if (part_elem->engine_type == NULL)
part_elem->engine_type= default_engine_type;
DBUG_PRINT("info", ("engine = %d",
@@ -709,6 +715,12 @@ bool partition_info::check_partition_info(handlerton **eng_type,
do
{
part_elem= sub_it++;
+ if (check_table_name(part_elem->partition_name,
+ strlen(part_elem->partition_name)))
+ {
+ my_error(ER_WRONG_PARTITION_NAME, MYF(0));
+ goto end;
+ }
if (part_elem->engine_type == NULL)
part_elem->engine_type= default_engine_type;
DBUG_PRINT("info", ("engine = %u",
diff --git a/sql/share/errmsg.txt b/sql/share/errmsg.txt
index e8766b3d882..0d3ba97f8e9 100644
--- a/sql/share/errmsg.txt
+++ b/sql/share/errmsg.txt
@@ -5826,3 +5826,6 @@ ER_NDB_CANT_SWITCH_BINLOG_FORMAT
eng "The NDB cluster engine does not support changing the binlog format on the fly yet"
ER_PARTITION_NO_TEMPORARY
eng "Cannot create temporary table with partitions"
+ER_WRONG_PARTITION_NAME
+ eng "Incorrect partition name"
+ swe "Felaktigt partitionsnamn"
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 5cae38f2773..aae80f07b71 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1614,6 +1614,21 @@ static int add_key_partition(File fptr, List<char> field_list)
return err;
}
+static int add_name_string(File fptr, const char *name)
+{
+ int err;
+ String name_string("", 0, system_charset_info);
+ THD *thd= current_thd;
+ ulonglong save_options= thd->options;
+
+ thd->options= 0;
+ append_identifier(thd, &name_string, name,
+ strlen(name));
+ thd->options= save_options;
+ err= add_string_object(fptr, &name_string);
+ return err;
+}
+
static int add_int(File fptr, longlong number)
{
llstr(number, buff);
@@ -1912,7 +1927,7 @@ char *generate_partition_syntax(partition_info *part_info,
part_info->part_state_len= part_state_id+1;
}
err+= add_partition(fptr);
- err+= add_string(fptr, part_elem->partition_name);
+ err+= add_name_string(fptr, part_elem->partition_name);
err+= add_space(fptr);
err+= add_partition_values(fptr, part_info, part_elem);
if (!part_info->is_sub_partitioned())
@@ -1928,7 +1943,7 @@ char *generate_partition_syntax(partition_info *part_info,
{
part_elem= sub_it++;
err+= add_subpartition(fptr);
- err+= add_string(fptr, part_elem->partition_name);
+ err+= add_name_string(fptr, part_elem->partition_name);
err+= add_space(fptr);
err+= add_partition_options(fptr, part_elem);
if (j != (no_subparts-1))
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 19535f3182a..95433828a1e 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -753,6 +753,7 @@ mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd)
static const char *require_quotes(const char *name, uint name_length)
{
uint length;
+ bool pure_digit= TRUE;
const char *end= name + name_length;
for (; name < end ; name++)
@@ -761,7 +762,11 @@ static const char *require_quotes(const char *name, uint name_length)
length= my_mbcharlen(system_charset_info, chr);
if (length == 1 && !system_charset_info->ident_map[chr])
return name;
+ if (length == 1 && (chr < '0' || chr > '9'))
+ pure_digit= FALSE;
}
+ if (pure_digit)
+ return name;
return 0;
}
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index e48748bcfa5..f570cbcd782 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -3639,7 +3639,7 @@ part_definition:
;
part_name:
- ident_or_text
+ ident
{
LEX *lex= Lex;
partition_info *part_info= lex->part_info;