summaryrefslogtreecommitdiff
path: root/sql/sql_partition.cc
diff options
context:
space:
mode:
authorunknown <mattiasj@mattiasj-laptop.(none)>2007-10-23 22:04:09 +0200
committerunknown <mattiasj@mattiasj-laptop.(none)>2007-10-23 22:04:09 +0200
commitfe784fac00494c1d48f0c245d0d4c23bfb717680 (patch)
treeae6b358b3da64df8da7e63c711904dafb7200838 /sql/sql_partition.cc
parent82e6e6fb665e8f1c6d60559ebed0c9ecf115fecd (diff)
downloadmariadb-git-fe784fac00494c1d48f0c245d0d4c23bfb717680.tar.gz
Bug #30695: An apostrophe ' in the comment of the ADD PARTITION
causes the Server to crash. Accessing partitioned table with an apostrophe in partition options like DATA DIRECTORY, INDEX DIRECTORY or COMMENT causes server crash. Partition options were saved in .frm file without escaping. When accessing such table it is not possible to properly restore partition information. Crashed because there was no check for partition info parser failure. Fixed by escaping quoted text in the partition info when writing it to the frm-file and added a check that it was able to parse the partition info before using it NOTE: If the comment is written by an earlier version of the server, the corrupted frm-file is not fixed, but left corrupted, you have to manually drop the table and recreate it. mysql-test/r/partition.result: bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes the Server to crash. testresult mysql-test/t/partition.test: bug #30695: An apostrophe ' in the comment of the ADD PARTITION causes the Server to crash. testcase sql/sql_partition.cc: 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 options fixed by escaping quoted text before writing to the frm-file sql/table.cc: Bug #30695 An apostrophe ' in the comment of the ADD PARTITION causes the Server to crash problem was using a null poiter without check -> crash. added a check that the previus call succeded
Diffstat (limited to 'sql/sql_partition.cc')
-rw-r--r--sql/sql_partition.cc21
1 files changed, 17 insertions, 4 deletions
diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc
index 8a8a03cb4e4..3ad2cbfb284 100644
--- a/sql/sql_partition.cc
+++ b/sql/sql_partition.cc
@@ -1849,6 +1849,20 @@ static int add_uint(File fptr, ulonglong number)
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, const char *keyword,
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);
}