This is a Mikael's patch. Forwarning it to commits, to
register in the bug report.
# This is a BitKeeper generated diff -Nru style patch.
#
# ChangeSet
# 2006/04/10 13:48:58-04:00
mikael@stripped
# BUG#18750: Various problems with partition names, quotation marks
#
# sql/sql_yacc.yy
# 2006/04/10 13:48:53-04:00
mikael@stripped +1 -1
# Partition names should identifers and not ident_or_text
#
# sql/sql_show.cc
# 2006/04/10 13:48:53-04:00
mikael@stripped +5 -0
# require_quotes had a bug with identifiers that consisted of only
digits,
# these are allowed identifiers but must be quoted and require_quote
didn't
# tell this.
#
# sql/sql_partition.cc
# 2006/04/10 13:48:52-04:00
mikael@stripped +17 -2
# New method to add partition name strings, ignore
OPTION_SHOW_QUOTE_CREATE
#
#
# sql/share/errmsg.txt
# 2006/04/10 13:48:52-04:00
mikael@stripped +3 -0
# Added error code for wrong partition names
#
# sql/partition_info.cc
# 2006/04/10 13:48:52-04:00
mikael@stripped +12 -0
# Check partition names that they don't have trailing spaces
#
# mysql-test/t/partition.test
# 2006/04/10 13:48:52-04:00
mikael@stripped +24 -0
# Added new test cases
#
# mysql-test/r/partition.result
# 2006/04/10 13:48:51-04:00
mikael@stripped +17 -0
# Added new test cases
#
diff -Nru a/mysql-test/r/partition.result
b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result 2006-04-10 13:54:05 -04:00
+++ b/mysql-test/r/partition.result 2006-04-10 13:54:05 -04:00
@@ -839,4 +839,21 @@
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
End of 5.1 tests
diff -Nru a/mysql-test/t/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test 2006-04-10 13:54:05 -04:00
+++ b/mysql-test/t/partition.test 2006-04-10 13:54:05 -04:00
@@ -956,4 +956,28 @@
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 `));
+
--echo End of 5.1 tests
diff -Nru a/sql/partition_info.cc b/sql/partition_info.cc
--- a/sql/partition_info.cc 2006-04-10 13:54:05 -04:00
+++ b/sql/partition_info.cc 2006-04-10 13:54:05 -04:00
@@ -696,6 +696,12 @@
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 @@
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 -Nru a/sql/share/errmsg.txt b/sql/share/errmsg.txt
--- a/sql/share/errmsg.txt 2006-04-10 13:54:05 -04:00
+++ b/sql/share/errmsg.txt 2006-04-10 13:54:05 -04:00
@@ -5826,3 +5826,6 @@
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 -Nru a/sql/sql_partition.cc b/sql/sql_partition.cc
--- a/sql/sql_partition.cc 2006-04-10 13:54:05 -04:00
+++ b/sql/sql_partition.cc 2006-04-10 13:54:05 -04:00
@@ -1614,6 +1614,21 @@
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 @@
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 @@
{
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 -Nru a/sql/sql_show.cc b/sql/sql_show.cc
--- a/sql/sql_show.cc 2006-04-10 13:54:05 -04:00
+++ b/sql/sql_show.cc 2006-04-10 13:54:05 -04:00
@@ -753,6 +753,7 @@
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 @@
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 -Nru a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy 2006-04-10 13:54:05 -04:00
+++ b/sql/sql_yacc.yy 2006-04-10 13:54:05 -04:00
@@ -3639,7 +3639,7 @@
;
part_name:
- ident_or_text
+ ident
{
LEX *lex= Lex;
partition_info *part_info= lex->part_info;
Mikael Ronstrom, Senior Software Architect
MySQL AB, www.mysql.com
Jumpstart your cluster:
http://www.mysql.com/consulting/packaged/cluster.html
My blog:
http://mikaelronstrom.blogspot.com
| Thread |
|---|
| • bk commit - 5.1 tree (mikael:1.2307) BUG#18750 | Alexander Barkov | 11 Apr |