Below is the list of changes that have just been committed into a local
5.1 repository of mattiasj. When mattiasj does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2007-10-10 09:01:57+02:00, mattiasj@mattiasj-laptop.(none) +3 -0
Bug #30695: An apostrophe ' in the comment of the ADD PARTITION
causes the Server to crash.
Crashed because of the comment in the partition clause was saved in
the frm file without escaping, causing the server to crash when it was
read/parsed again.
Fixed by escaping quoted text in the partition info when writing it to
the frm-file
NOTE: If the comment is written by an earlier version of the server,
it will still crash.
Instead of adding code to allways handle this,
it would be better to drop the table and recreate it.
(If needed, edit the frm-file manually and
replace the apostrophe within the comment with a space)
mysql-test/r/partition.result@stripped, 2007-10-10 09:01:55+02:00,
mattiasj@mattiasj-laptop.(none) +17 -0
bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes
the Server to crash.
testresult
mysql-test/t/partition.test@stripped, 2007-10-10 09:01:55+02:00,
mattiasj@mattiasj-laptop.(none) +24 -0
bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes
the Server to crash.
testcase
sql/sql_partition.cc@stripped, 2007-10-10 09:01:55+02:00, mattiasj@mattiasj-laptop.(none)
+17 -4
Bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes
the Server to crash.
Crashes when there is an non escaped apostrophe in the partition comment
fixed by escaping quoted text before writing to the frm-file
diff -Nrup a/mysql-test/r/partition.result b/mysql-test/r/partition.result
--- a/mysql-test/r/partition.result 2007-07-02 20:11:52 +02:00
+++ b/mysql-test/r/partition.result 2007-10-10 09:01:55 +02:00
@@ -1,4 +1,21 @@
drop table if exists t1;
+CREATE TABLE t1 (
+d DATE NOT NULL
+)
+PARTITION BY RANGE( YEAR(d) ) (
+PARTITION p0 VALUES LESS THAN (1960),
+PARTITION p1 VALUES LESS THAN (1970),
+PARTITION p2 VALUES LESS THAN (1980),
+PARTITION p3 VALUES LESS THAN (1990)
+);
+ALTER TABLE t1 ADD PARTITION (
+PARTITION `p5` VALUES LESS THAN (2010)
+COMMENT 'START \' \\
+\' END'
+);
+SELECT * FROM t1 LIMIT 1;
+d
+DROP TABLE t1;
create table t1 (a int)
partition by key(a)
partitions 0.2+e1;
diff -Nrup a/mysql-test/t/partition.test b/mysql-test/t/partition.test
--- a/mysql-test/t/partition.test 2007-07-02 20:11:52 +02:00
+++ b/mysql-test/t/partition.test 2007-10-10 09:01:55 +02:00
@@ -10,6 +10,30 @@ drop table if exists t1;
--enable_warnings
#
+# Bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes the Server to
crash.
+#
+
+CREATE TABLE t1 (
+ d DATE NOT NULL
+)
+PARTITION BY RANGE( YEAR(d) ) (
+ PARTITION p0 VALUES LESS THAN (1960),
+ PARTITION p1 VALUES LESS THAN (1970),
+ PARTITION p2 VALUES LESS THAN (1980),
+ PARTITION p3 VALUES LESS THAN (1990)
+);
+
+ALTER TABLE t1 ADD PARTITION (
+PARTITION `p5` VALUES LESS THAN (2010)
+COMMENT 'START \' \\
+ \' END'
+);
+
+SELECT * FROM t1 LIMIT 1;
+
+DROP TABLE t1;
+
+#
# Bug 15890: Strange number of partitions accepted
#
-- error 1064
diff -Nrup a/sql/sql_partition.cc b/sql/sql_partition.cc
--- a/sql/sql_partition.cc 2007-09-14 12:17:40 +02:00
+++ b/sql/sql_partition.cc 2007-10-10 09:01:55 +02:00
@@ -1849,6 +1849,20 @@ static int add_uint(File fptr, ulonglong
return add_string(fptr, buff);
}
+/*
+ Must escape strings in partitioned tables frm-files,
+ parsing it later with mysql_unpack_partition will fail otherwise.
+*/
+static int add_quoted_string(File fptr, const char *quotestr)
+{
+ String orgstr(quotestr, system_charset_info);
+ String escapedstr;
+ int err= add_string(fptr, "'");
+ err+= append_escaped(&escapedstr, &orgstr);
+ err+= add_string(fptr, escapedstr.c_ptr());
+ return err + add_string(fptr, "'");
+}
+
static int add_keyword_string(File fptr, const char *keyword,
bool should_use_quotes,
const char *keystr)
@@ -1859,10 +1873,9 @@ static int add_keyword_string(File fptr,
err+= add_equal(fptr);
err+= add_space(fptr);
if (should_use_quotes)
- err+= add_string(fptr, "'");
- err+= add_string(fptr, keystr);
- if (should_use_quotes)
- err+= add_string(fptr, "'");
+ err+= add_quoted_string(fptr, keystr);
+ else
+ err+= add_string(fptr, keystr);
return err + add_space(fptr);
}
| Thread |
|---|
| • bk commit into 5.1 tree (mattiasj:1.2568) BUG#30695 | mattiasj | 10 Oct |