diff options
author | Annamalai Gurusami <annamalai.gurusami@oracle.com> | 2013-03-21 11:40:43 +0530 |
---|---|---|
committer | Annamalai Gurusami <annamalai.gurusami@oracle.com> | 2013-03-21 11:40:43 +0530 |
commit | b6bd1998502ca53a33f0d28a9f5df0c5cbc0b5f1 (patch) | |
tree | 2e2e6a09a6c54960a037e4d1ff4331b3ae2b70e1 /unittest | |
parent | ab16f35c23e872f9cde0f0f4bbaee9aaafc5b2d6 (diff) | |
download | mariadb-git-b6bd1998502ca53a33f0d28a9f5df0c5cbc0b5f1.tar.gz |
Bug #16051728 SERVER CRASHES IN ADD_IDENTIFIER ON CONCURRENT ALTER TABLE AND
SHOW ENGINE INNOD
Problem:
The purpose of explain_filename() is to provide useful additional
information regarding the partitions given the filename. This function
was returning an error when it was not able to parse the given filename.
For example, within InnoDB, temporary files are created with #sql-
prefix. But this function was not able to parse it correctly.
Solution:
It is not an error, if explain_filename() could not parse the given
filename. If there is no partition information to explain, then silently
return from the function.
rb#1940 approved by mattiasj
Diffstat (limited to 'unittest')
-rw-r--r-- | unittest/mysys/CMakeLists.txt | 11 | ||||
-rw-r--r-- | unittest/mysys/explain_filename-t.cc | 163 |
2 files changed, 173 insertions, 1 deletions
diff --git a/unittest/mysys/CMakeLists.txt b/unittest/mysys/CMakeLists.txt index 7bf046162c5..8d729fae8b5 100644 --- a/unittest/mysys/CMakeLists.txt +++ b/unittest/mysys/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,3 +30,12 @@ ENDMACRO() FOREACH(testname bitmap base64 my_vsnprintf my_atomic my_rdtsc lf my_malloc) MY_ADD_TEST(${testname}) ENDFOREACH() + +IF(WIN32) + ADD_EXECUTABLE(explain_filename-t explain_filename-t.cc + ../../sql/nt_servc.cc) +ELSE() + ADD_EXECUTABLE(explain_filename-t explain_filename-t.cc) +ENDIF() +TARGET_LINK_LIBRARIES(explain_filename-t sql mytap) +ADD_TEST(explain_filename explain_filename-t) diff --git a/unittest/mysys/explain_filename-t.cc b/unittest/mysys/explain_filename-t.cc new file mode 100644 index 00000000000..09ebe1768df --- /dev/null +++ b/unittest/mysys/explain_filename-t.cc @@ -0,0 +1,163 @@ +/* + Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 of the License. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/** Unit test case for the function explain_filename(). */ + +#include <tap.h> +#include <mysqld_error.h> +#include <sql_class.h> +#include <sql_table.h> + +#define BUFLEN 1000 +char to[BUFLEN]; +char from[BUFLEN]; + +const char *error_messages[1000]; + +int setup() +{ + system_charset_info = &my_charset_utf8_bin; + my_default_lc_messages = &my_locale_en_US; + + /* Populate the necessary error messages */ + error_messages[ER_DATABASE_NAME - ER_ERROR_FIRST] = "Database"; + error_messages[ER_TABLE_NAME - ER_ERROR_FIRST] = "Table"; + error_messages[ER_PARTITION_NAME - ER_ERROR_FIRST] = "Partition"; + error_messages[ER_SUBPARTITION_NAME - ER_ERROR_FIRST] = "Subpartition"; + error_messages[ER_TEMPORARY_NAME - ER_ERROR_FIRST] = "Temporary"; + error_messages[ER_RENAMED_NAME - ER_ERROR_FIRST] = "Renamed"; + + my_default_lc_messages->errmsgs->errmsgs = error_messages; + + return 0; +} + +void test_1(const char *in, const char *exp, enum_explain_filename_mode mode) +{ + char out[BUFLEN]; + + uint len1 = explain_filename(0, in, out, BUFLEN, mode); + + /* expected output and actual output must be same */ + bool pass = (strcmp(exp, out) == 0); + + /* length returned by explain_filename is fine */ + bool length = (len1 == strlen(exp)); + + ok( (pass && length) , "(%d): %s => %s\n", mode, in, out); +} + +int main() +{ + setup(); + plan(NO_PLAN); + + test_1("test/t1.ibd", + "Database \"test\", Table \"t1.ibd\"", + EXPLAIN_ALL_VERBOSE); + + test_1("test/t1.ibd", + "\"test\".\"t1.ibd\"", + EXPLAIN_PARTITIONS_VERBOSE); + + test_1("test/t1.ibd", + "\"test\".\"t1.ibd\"", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/t1#TMP#", + "Database \"test\", Table \"t1#TMP#\"", + EXPLAIN_ALL_VERBOSE); + + test_1("test/#sql-2882.ibd", + "Database \"test\", Table \"#sql-2882.ibd\"", + EXPLAIN_ALL_VERBOSE); + + test_1("test/t1#REN#", + "Database \"test\", Table \"t1#REN#\"", + EXPLAIN_ALL_VERBOSE); + + test_1("test/t1@0023REN@0023", + "Database \"test\", Table \"t1#REN#\"", + EXPLAIN_ALL_VERBOSE); + + test_1("test/t1#p#p1", + "Database \"test\", Table \"t1\", Partition \"p1\"", + EXPLAIN_ALL_VERBOSE); + + test_1("test/t1#P#p1", + "\"test\".\"t1\" /* Partition \"p1\" */", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/t1#P#p1@00231", + "\"test\".\"t1\" /* Partition \"p1#1\" */", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/t1#P#p1#SP#sp1", + "\"test\".\"t1\" /* Partition \"p1\", Subpartition \"sp1\" */", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/t1#p1#SP#sp1", + "\"test\".\"t1#p1#SP#sp1\"", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/t1#p#p1@00232#SP#sp1@00231#REN#", + "\"test\".\"t1\" /* Renamed Partition \"p1#2\", Subpartition \"sp1#1\" */", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/t1#p#p1#SP#sp1#TMP#", + "\"test\".\"t1\" /* Temporary Partition \"p1\", Subpartition \"sp1\" */", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/#sql-t1#P#p1#SP#sp1#TMP#", + "\"test\".\"#sql-t1#P#p1#SP#sp1#TMP#\" /* Temporary Partition \"p1\", Subpartition \"sp1\" */", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/#sql-t1#P#p1#SP#sp1", + "\"test\".\"#sql-t1#P#p1#SP#sp1\" /* Partition \"p1\", Subpartition \"sp1\" */", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/#sqlx-33", + "\"test\".\"#sqlx-33\"", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/#mysql50#t", + "\"test\".\"#mysql50#t\"", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("#mysql50#t", + "\"#mysql50#t\"", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("@0023t", + "\"#t\"", + EXPLAIN_PARTITIONS_AS_COMMENT); + + test_1("test/t@0023", + "\"test\".\"t#\"", + EXPLAIN_PARTITIONS_AS_COMMENT); + + /* + If a character not allowed in my_charset_filename is encountered, + then it will not be converted to system_charset_info! + */ + test_1("test/t@0023#", + "\"test\".\"t@0023#\"", + EXPLAIN_PARTITIONS_AS_COMMENT); + + return 0; +} + |