From 1c1f0a62e1f68fd39ae7440042699faaffaaf7fe Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Apr 2008 02:53:12 +0400 Subject: [PATCH 01/13] BUG#36139 "float, zerofill, crash with subquery" - Make convert_zerofill_number_to_string() take into account that the constant it is converting may evaluate to NULL. mysql-test/r/subselect.result: BUG#36139 "float, zerofill, crash with subquery" - Testcase mysql-test/t/subselect.test: BUG#36139 "float, zerofill, crash with subquery" - Testcase --- mysql-test/r/subselect.result | 7 +++++++ mysql-test/t/subselect.test | 12 ++++++++++++ sql/item.cc | 11 ++++++++--- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 2de2589fc92..349b874cbb9 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4374,4 +4374,11 @@ a4 f3 a6 1 NULL NULL 2 NULL NULL DROP TABLE t1, t2, t3, t4; +create table t1 (a float(5,4) zerofill); +create table t2 (a float(5,4),b float(2,0)); +select t1.a from t1 where +t1.a= (select b from t2 limit 1) and not +t1.a= (select a from t2 limit 1) ; +a +drop table t1; End of 5.0 tests. diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index c5edd5414e3..a60159381e1 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3259,5 +3259,17 @@ GROUP BY a4; DROP TABLE t1, t2, t3, t4; +# +# BUG#36139 "float, zerofill, crash with subquery" +# +create table t1 (a float(5,4) zerofill); +create table t2 (a float(5,4),b float(2,0)); + +select t1.a from t1 where + t1.a= (select b from t2 limit 1) and not + t1.a= (select a from t2 limit 1) ; + +drop table t1; + --echo End of 5.0 tests. diff --git a/sql/item.cc b/sql/item.cc index 553ba1b152c..9ff1f8c0084 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -4156,9 +4156,14 @@ static void convert_zerofill_number_to_string(Item **item, Field_num *field) String tmp(buff,sizeof(buff), field->charset()), *res; res= (*item)->val_str(&tmp); - field->prepend_zeros(res); - pos= (char *) sql_strmake (res->ptr(), res->length()); - *item= new Item_string(pos, res->length(), field->charset()); + if ((*item)->is_null()) + *item= new Item_null(); + else + { + field->prepend_zeros(res); + pos= (char *) sql_strmake (res->ptr(), res->length()); + *item= new Item_string(pos, res->length(), field->charset()); + } } From d8ebf276396252fc37169d108a993bf8b6b38157 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Apr 2008 02:14:58 +0500 Subject: [PATCH 02/13] Fixed bug #35993: memory corruption and crash with multibyte conversion. Grouping or ordering of long values in not indexed BLOB/TEXT columns with GBK or BIG5 charsets crashes the server. MySQL server uses sorting (the filesort procedure) in the temporary table to evaluate the GROUP BY clause in case of lack of suitable index. That procedure takes into account only first @max_sort_length bytes (system variable, usually 1024) of TEXT/BLOB sorting key string. The my_strnxfrm_gbk and my_strnxfrm_big5 fill temporary keys with data of whole blob length instead of @max_sort_length bytes length. That buffer overrun has been fixed. mysql-test/r/ctype_gbk.result: Added test case for bug #35993. mysql-test/t/ctype_gbk.test: Added test case for bug #35993. strings/ctype-big5.c: Fixed bug #35993: memory corruption and crash with multibyte conversion. Buffer overrun has been fixed in the my_strnxfrm_big5 function. strings/ctype-gbk.c: Fixed bug #35993: memory corruption and crash with multibyte conversion. Buffer overrun has been fixed in the my_strnxfrm_gbk function. --- mysql-test/r/ctype_gbk.result | 7 +++++++ mysql-test/t/ctype_gbk.test | 14 ++++++++++++++ strings/ctype-big5.c | 6 ++++-- strings/ctype-gbk.c | 6 ++++-- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/mysql-test/r/ctype_gbk.result b/mysql-test/r/ctype_gbk.result index 6066246a2ef..1b425134095 100644 --- a/mysql-test/r/ctype_gbk.result +++ b/mysql-test/r/ctype_gbk.result @@ -247,4 +247,11 @@ t1 CREATE TABLE `t1` ( `c2` text NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=gbk drop table t1; +CREATE TABLE t1(a MEDIUMTEXT CHARACTER SET gbk, +b MEDIUMTEXT CHARACTER SET big5); +INSERT INTO t1 VALUES +(REPEAT(0x1125,200000), REPEAT(0x1125,200000)), ('', ''), ('', ''); +SELECT a FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +DROP TABLES t1; End of 5.0 tests diff --git a/mysql-test/t/ctype_gbk.test b/mysql-test/t/ctype_gbk.test index 3ea696338dc..91fe50d89b9 100644 --- a/mysql-test/t/ctype_gbk.test +++ b/mysql-test/t/ctype_gbk.test @@ -53,4 +53,18 @@ alter table t1 change c1 c1 mediumtext character set gbk not null; show create table t1; drop table t1; +# +# Bug#35993: severe memory corruption and crash with multibyte conversion +# + +CREATE TABLE t1(a MEDIUMTEXT CHARACTER SET gbk, + b MEDIUMTEXT CHARACTER SET big5); +INSERT INTO t1 VALUES + (REPEAT(0x1125,200000), REPEAT(0x1125,200000)), ('', ''), ('', ''); + +SELECT a FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; +SELECT b FROM t1 GROUP BY 1 LIMIT 1 INTO @nullll; + +DROP TABLES t1; + --echo End of 5.0 tests diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index 44b9951657d..c73247db404 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -307,15 +307,17 @@ static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), { uint16 e; uint dstlen= len; + uchar *dest_end= dest + dstlen; len = srclen; - while (len--) + while (len-- && dest < dest_end) { if ((len > 0) && isbig5code(*src, *(src+1))) { e = big5strokexfrm((uint16) big5code(*src, *(src+1))); *dest++ = big5head(e); - *dest++ = big5tail(e); + if (dest < dest_end) + *dest++ = big5tail(e); src +=2; len--; } else diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index 8ac7d62c9da..d0ba33aa3cc 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2668,15 +2668,17 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), { uint16 e; uint dstlen= len; + uchar *dest_end= dest + dstlen; len = srclen; - while (len--) + while (len-- && dest < dest_end) { if ((len > 0) && isgbkcode(*src, *(src+1))) { e = gbksortorder((uint16) gbkcode(*src, *(src+1))); *dest++ = gbkhead(e); - *dest++ = gbktail(e); + if (dest < dest_end) + *dest++ = gbktail(e); src+=2; len--; } else From 73f7de59c2739a66dcf1a7d1d4c89a1e19fddcd1 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Apr 2008 02:27:23 +0500 Subject: [PATCH 03/13] Fixed bug#36005: server crashes inside NOT IN clause subquery with impossible WHERE/HAVING clause (subselect_single_select_engine::exec). Allocation and initialization of joined table list t1, t2... of subqueries like: NOT IN (SELECT ... FROM t1,t2,... WHERE 0) is optimized out, however server tries to traverse this list. mysql-test/r/subselect3.result: Added test case for bug#36005. mysql-test/t/subselect3.test: Added test case for bug#36005. sql/sql_select.cc: Fixed bug#36005. 1. JOIN::prepare initializes JOIN::table counter (actually a size of the JOIN::join_tab array) and sets it to a number of joined tables. 2. The make_join_statistics function (when called from JOIN::optimize) allocates and fills the JOIN::join_tab array. However, when optimizing subselect has impossible (definite false) WHERE or HAVING clause, optimizer skips call to make_join_statistics and leaves JOIN::join_tab == NULL. 3. subselect_single_select_engine::exec does traversal of the JOIN::join_tab array and the server dies because array is not allocated but array counter is greater than 0. The JOIN::optimize method has been modified to reset the JOIN::table counter to 0 in cause of impossible WHERE/HAVING clause. --- mysql-test/r/subselect3.result | 9 +++++++++ mysql-test/t/subselect3.test | 13 +++++++++++++ sql/sql_select.cc | 1 + 3 files changed, 23 insertions(+) diff --git a/mysql-test/r/subselect3.result b/mysql-test/r/subselect3.result index c194ba33756..5221fa09744 100644 --- a/mysql-test/r/subselect3.result +++ b/mysql-test/r/subselect3.result @@ -770,4 +770,13 @@ SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a; ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) 1 DROP TABLE t1, t2; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 SELECT * FROM t1; +SELECT 1 FROM t1 WHERE t1.a NOT IN (SELECT 1 FROM t1, t2 WHERE 0); +1 +1 +1 +1 +DROP TABLE t1, t2; End of 5.0 tests diff --git a/mysql-test/t/subselect3.test b/mysql-test/t/subselect3.test index cfbde8c29cd..d7bb1f7186a 100644 --- a/mysql-test/t/subselect3.test +++ b/mysql-test/t/subselect3.test @@ -605,4 +605,17 @@ SELECT ROW(1, 2) IN (SELECT t1.a, 2 FROM t2) FROM t1 GROUP BY t1.a; DROP TABLE t1, t2; +# +# Bug #36005: crash in subselect with single row +# (subselect_single_select_engine::exec) +# + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2),(3); +CREATE TABLE t2 SELECT * FROM t1; + +SELECT 1 FROM t1 WHERE t1.a NOT IN (SELECT 1 FROM t1, t2 WHERE 0); + +DROP TABLE t1, t2; + --echo End of 5.0 tests diff --git a/sql/sql_select.cc b/sql/sql_select.cc index 976d7322f56..11062998e6a 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -832,6 +832,7 @@ JOIN::optimize() "Impossible HAVING" : "Impossible WHERE")); zero_result_cause= having_value == Item::COND_FALSE ? "Impossible HAVING" : "Impossible WHERE"; + tables= 0; error= 0; DBUG_RETURN(0); } From 415112a9406c689fa4f3ec27c1c8135d2825b14c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 23 Apr 2008 14:22:49 +0500 Subject: [PATCH 04/13] subselect.test, subselect.result: Post-commit minor cleanup of testcase (bug#36139). mysql-test/r/subselect.result: Post-commit minor cleanup of testcase (bug#36139). mysql-test/t/subselect.test: Post-commit minor cleanup of testcase (bug#36139). --- mysql-test/r/subselect.result | 2 +- mysql-test/t/subselect.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/subselect.result b/mysql-test/r/subselect.result index 349b874cbb9..e56c2f07d80 100644 --- a/mysql-test/r/subselect.result +++ b/mysql-test/r/subselect.result @@ -4380,5 +4380,5 @@ select t1.a from t1 where t1.a= (select b from t2 limit 1) and not t1.a= (select a from t2 limit 1) ; a -drop table t1; +drop table t1, t2; End of 5.0 tests. diff --git a/mysql-test/t/subselect.test b/mysql-test/t/subselect.test index a60159381e1..527bd528f79 100644 --- a/mysql-test/t/subselect.test +++ b/mysql-test/t/subselect.test @@ -3269,7 +3269,7 @@ select t1.a from t1 where t1.a= (select b from t2 limit 1) and not t1.a= (select a from t2 limit 1) ; -drop table t1; +drop table t1, t2; --echo End of 5.0 tests. From 89b866e7bfc8965046626844ee22ecd5b4e5a774 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 25 Apr 2008 00:39:37 +0400 Subject: [PATCH 05/13] Bug#36023: Incorrect handling of zero length caused an assertion to fail. When a zero length is provided to the my_decimal_length_to_precision function along with unsigned_flag set to false it returns a negative value. For queries that employs temporary tables may cause failed assertion or excessive memory consumption while temporary table creation. Now the my_decimal_length_to_precision and the my_decimal_precision_to_length functions take unsigned_flag into account only if the length/precision argument is non-zero. mysql-test/t/type_decimal.test: Added a test case for the bug#36023: Incorrect handling of zero length caused an assertion to fail. mysql-test/r/type_decimal.result: Added a test case for the bug#36023: Incorrect handling of zero length caused an assertion to fail. sql/my_decimal.h: Bug#36023: Incorrect handling of zero length caused an assertion to fail. Now the my_decimal_length_to_precision and the my_decimal_precision_to_length functions take unsigned_flag into account only if the length/precision argument is non-zero. --- mysql-test/r/type_decimal.result | 7 +++++++ mysql-test/t/type_decimal.test | 8 ++++++++ sql/my_decimal.h | 13 +++++++++++-- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result index 2afd42f702e..03fbc898cc5 100644 --- a/mysql-test/r/type_decimal.result +++ b/mysql-test/r/type_decimal.result @@ -946,4 +946,11 @@ SELECT ROUND(20061108085411.000002); ROUND(20061108085411.000002) 20061108085411 DROP TABLE t1, t2, t3, t4, t5, t6; +create table t1(`c` decimal(9,2)); +insert into t1 values (300),(201.11); +select max(case 1 when 1 then c else null end) from t1 group by c; +max(case 1 when 1 then c else null end) +201.11 +300.00 +drop table t1; End of 5.0 tests diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test index 6841b3cdd68..8a81908296f 100644 --- a/mysql-test/t/type_decimal.test +++ b/mysql-test/t/type_decimal.test @@ -521,4 +521,12 @@ SELECT ROUND(20061108085411.000002); DROP TABLE t1, t2, t3, t4, t5, t6; +# +# Bug#36023: Incorrect handling of zero length caused an assertion to fail. +# +create table t1(`c` decimal(9,2)); +insert into t1 values (300),(201.11); +select max(case 1 when 1 then c else null end) from t1 group by c; +drop table t1; + --echo End of 5.0 tests diff --git a/sql/my_decimal.h b/sql/my_decimal.h index c661579ea66..6a0d05921ec 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -164,14 +164,23 @@ inline int check_result_and_overflow(uint mask, int result, my_decimal *val) inline uint my_decimal_length_to_precision(uint length, uint scale, bool unsigned_flag) { - return (uint) (length - (scale>0 ? 1:0) - (unsigned_flag ? 0:1)); + /* Precision can't be negative thus ignore unsigned_flag when length is 0. */ + DBUG_ASSERT(length || !scale); + return (uint) (length - (scale>0 ? 1:0) - + (unsigned_flag || !length ? 0:1)); } inline uint32 my_decimal_precision_to_length(uint precision, uint8 scale, bool unsigned_flag) { + /* + When precision is 0 it means that original length was also 0. Thus + unsigned_flag is ignored in this case. + */ + DBUG_ASSERT(precision || !scale); set_if_smaller(precision, DECIMAL_MAX_PRECISION); - return (uint32)(precision + (scale>0 ? 1:0) + (unsigned_flag ? 0:1)); + return (uint32)(precision + (scale>0 ? 1:0) + + (unsigned_flag || !precision ? 0:1)); } inline From 8def2e0993e8b0acbff48b6f345d20ba033de21b Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Apr 2008 13:41:12 -0400 Subject: [PATCH 06/13] Avoid compilation problem on AIX. --- mysys/thr_alarm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index d11883a4ea4..94ef309097a 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -14,8 +14,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* To avoid problems with alarms in debug code, we disable DBUG here */ -#undef DBUG_OFF -#define DBUG_OFF +#define FORCE_DBUG_OFF #include #if defined(THREAD) && !defined(DONT_USE_THR_ALARM) From 57036d8a7193936682f4fe737683f965182d993c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 28 Apr 2008 14:58:32 -0400 Subject: [PATCH 07/13] Correct failing build. --- include/my_global.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/my_global.h b/include/my_global.h index b0a26e67d9b..e474b620d27 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -533,8 +533,12 @@ C_MODE_END #undef DBUG_OFF #endif -#if defined(_lint) && !defined(DBUG_OFF) -#define DBUG_OFF +/* We might be forced to turn debug off, if not turned off already */ +#if (defined(FORCE_DBUG_OFF) || defined(_lint)) && !defined(DBUG_OFF) +# define DBUG_OFF +# ifdef DBUG_ON +# undef DBUG_ON +# endif #endif #include From 1a68ec2809726e12f148a07cf3771c3d73d9983e Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 May 2008 13:49:26 +0300 Subject: [PATCH 08/13] Fix for bug #35298: GROUP_CONCAT with DISTINCT can crash the server The bug is a regression introduced by the patch for bug32798. The code in Item_func_group_concat::clear() relied on the 'distinct' variable to check if 'unique_filter' was initialized. That, however, is not always valid because Item_func_group_concat::setup() can do shortcuts in some cases w/o initializing 'unique_filter'. Fixed by checking the value of 'unique_filter' instead of 'distinct' before dereferencing. mysql-test/r/func_gconcat.result: Added test cases for bugs #35298 and #36024. mysql-test/t/func_gconcat.test: Added test cases for bugs #35298 and #36024. sql/item_sum.cc: Check if unique_filter != NULL before dereferencing it. Non-zero value of distinct does not always mean that unique_filter is initialized because Item_func_group_concat::setup() can do shortcuts is some cases --- mysql-test/r/func_gconcat.result | 26 +++++++++++++++++++++++ mysql-test/t/func_gconcat.test | 36 ++++++++++++++++++++++++++++++++ sql/item_sum.cc | 2 +- 3 files changed, 63 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_gconcat.result b/mysql-test/r/func_gconcat.result index 77d11831842..4dddc35e8a8 100644 --- a/mysql-test/r/func_gconcat.result +++ b/mysql-test/r/func_gconcat.result @@ -946,4 +946,30 @@ GROUP BY 1 d1 NULL DROP TABLE t1; +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); +INSERT INTO t1 VALUES(1); +SELECT GROUP_CONCAT(DISTINCT t2.a) FROM t1 LEFT JOIN t2 ON t2.a = t1.a GROUP BY t1.a; +GROUP_CONCAT(DISTINCT t2.a) +NULL +DROP TABLE t1, t2; +CREATE TABLE t1 (a INT, KEY(a)); +CREATE TABLE t2 (b INT); +INSERT INTO t1 VALUES (NULL), (8), (2); +INSERT INTO t2 VALUES (4), (10); +SELECT 1 FROM t1 WHERE t1.a NOT IN +( +SELECT GROUP_CONCAT(DISTINCT t1.a) +FROM t1 WHERE t1.a IN +( +SELECT b FROM t2 +) +AND NOT t1.a >= (SELECT t1.a FROM t1 LIMIT 1) +GROUP BY t1.a +); +1 +1 +1 +1 +DROP TABLE t1, t2; End of 5.0 tests diff --git a/mysql-test/t/func_gconcat.test b/mysql-test/t/func_gconcat.test index 87632fbdbb8..816ac9c2959 100644 --- a/mysql-test/t/func_gconcat.test +++ b/mysql-test/t/func_gconcat.test @@ -657,4 +657,40 @@ SELECT s1.d1 FROM ) AS s1; DROP TABLE t1; +# +# Bug #35298: GROUP_CONCAT with DISTINCT can crash the server +# + +CREATE TABLE t1 (a INT); +CREATE TABLE t2 (a INT); + +INSERT INTO t1 VALUES(1); + +SELECT GROUP_CONCAT(DISTINCT t2.a) FROM t1 LEFT JOIN t2 ON t2.a = t1.a GROUP BY t1.a; + +DROP TABLE t1, t2; + +# +# Bug #36024: group_concat distinct in subquery crash +# + +CREATE TABLE t1 (a INT, KEY(a)); +CREATE TABLE t2 (b INT); + +INSERT INTO t1 VALUES (NULL), (8), (2); +INSERT INTO t2 VALUES (4), (10); + +SELECT 1 FROM t1 WHERE t1.a NOT IN +( + SELECT GROUP_CONCAT(DISTINCT t1.a) + FROM t1 WHERE t1.a IN + ( + SELECT b FROM t2 + ) + AND NOT t1.a >= (SELECT t1.a FROM t1 LIMIT 1) + GROUP BY t1.a +); + +DROP TABLE t1, t2; + --echo End of 5.0 tests diff --git a/sql/item_sum.cc b/sql/item_sum.cc index 91f9889b03f..91320d6b56b 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -3222,7 +3222,7 @@ void Item_func_group_concat::clear() no_appended= TRUE; if (tree) reset_tree(tree); - if (distinct) + if (unique_filter) unique_filter->reset(); /* No need to reset the table as we never call write_row */ } From 38c28141a88c1aac5642ef8ad444e12850582697 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 May 2008 11:36:03 -0400 Subject: [PATCH 09/13] Bug#36026 - Test funcs_1._trig_03 failing on Windows Bug#36028 - Test funcs_1._trig_03e failing on Windows Bug#36029 - Test funcs_1._trig_0407 failing on Windows Bug#36030 - Test funcs_1._trig_08 failing on Windows Adding $MASTER_MYSOCK to init_win_path() When path names are short, master.sock ends up in MYSQL_TMP_DIR, but with longer path names, master.sock ends up in /tmp// and these tests will fail due to path delimiter difference. New changeset to start with 5.0 -- Not all of these tests are present in 5.0, but want to keep mysqltest the same --- client/mysqltest.c | 1 + 1 file changed, 1 insertion(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index 1d85e777e48..a75debd2ca5 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -5464,6 +5464,7 @@ void init_win_path_patterns() const char* paths[] = { "$MYSQL_TEST_DIR", "$MYSQL_TMP_DIR", "$MYSQLTEST_VARDIR", + "$MASTER_MYSOCK", "./test/" }; int num_paths= sizeof(paths)/sizeof(char*); int i; From 9018c56ac419a404a9656361cc6a3135549a3bb3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 May 2008 09:13:43 +0200 Subject: [PATCH 10/13] Bug#36463 mysql-test-run.pl should always use the --tmpdi mysql-test/mysql-test-run.pl: Use the requested tmpdir in 'collect_mysqld_features', create it if it does not already exists --- mysql-test/mysql-test-run.pl | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 7c4677b8274..829941545cd 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1367,7 +1367,15 @@ sub datadir_list_setup () { sub collect_mysqld_features () { my $found_variable_list_start= 0; - my $tmpdir= tempdir(CLEANUP => 0); # Directory removed by this function + my $tmpdir; + if ( $opt_tmpdir ) { + # Use the requested tmpdir + mkpath($opt_tmpdir) if (! -d $opt_tmpdir); + $tmpdir= $opt_tmpdir; + } + else { + $tmpdir= tempdir(CLEANUP => 0); # Directory removed by this function + } # # Execute "mysqld --no-defaults --help --verbose" to get a @@ -1428,7 +1436,7 @@ sub collect_mysqld_features () { } } } - rmtree($tmpdir); + rmtree($tmpdir) if (!$opt_tmpdir); mtr_error("Could not find version of MySQL") unless $mysql_version_id; mtr_error("Could not find variabes list") unless $found_variable_list_start; From cde8f109b90aa5d6344a598bd2d14348a03c36d5 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 May 2008 11:22:10 +0200 Subject: [PATCH 11/13] Bug#36465 mysqltest should always use the --tmpdir client/mysqltest.c: Use the --tmpdir location to create temporary files --- client/mysqltest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 1d85e777e48..a04f18750ef 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1536,7 +1536,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) DBUG_ENTER("dyn_string_cmp"); DBUG_PRINT("enter", ("fname: %s", fname)); - if ((fd= create_temp_file(temp_file_path, NULL, + if ((fd= create_temp_file(temp_file_path, TMPDIR, "tmp", O_CREAT | O_SHARE | O_RDWR, MYF(MY_WME))) < 0) die("Failed to create temporary file for ds"); From 7f5119d3e574134f952b612843bbd374f9bba2e3 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 May 2008 12:49:31 +0200 Subject: [PATCH 12/13] Bug#35986 valgrind warning in DbugParse for empty string in SET GLOBAL DEBUG="" - Code in DbugParse was reading from beyond end of the control string dbug/dbug.c: Don't try to parse control strings that hasn't got any tokens or is zero size --- dbug/dbug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dbug/dbug.c b/dbug/dbug.c index 09515dc329c..baf080f5e27 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -493,7 +493,7 @@ static void DbugParse(CODE_STATE *cs, const char *control) } end= DbugStrTok(control); - while (1) + while (control < end) { int c, sign= (*control == '+') ? 1 : (*control == '-') ? -1 : 0; if (sign) control++; From 6add5be771fc955d2f22b1eb0f14596a5bac1ca0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 2 May 2008 14:41:19 +0200 Subject: [PATCH 13/13] Bug#36469 mysql_upgrade does not use --tmpdir client/mysql_upgrade.c: Add --tmpdir option to mysql_upgrade and use it when creating temporary files. mysql-test/mysql-test-run.pl: Pass --tmpdir to mysql_upgrade --- client/mysql_upgrade.c | 11 ++++++++++- mysql-test/mysql-test-run.pl | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 02829cd2178..ded9d465d3a 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -40,6 +40,8 @@ static DYNAMIC_STRING ds_args; static char *opt_password= 0; static my_bool tty_password= 0; +static char opt_tmpdir[FN_REFLEN]; + #ifndef DBUG_OFF static char *default_dbug_option= (char*) "d:t:O,/tmp/mysql_upgrade.trace"; #endif @@ -105,6 +107,8 @@ static struct my_option my_long_options[]= #endif {"socket", 'S', "Socket file to use for connection.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"tmpdir", 't', "Directory for temporary files", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"user", 'u', "User for login if not current user.", (gptr*) &opt_user, (gptr*) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include @@ -229,6 +233,11 @@ get_one_option(int optid, const struct my_option *opt, } break; + case 't': + strnmov(opt_tmpdir, argument, sizeof(opt_tmpdir)); + add_option= FALSE; + break; + case 'b': /* --basedir */ case 'v': /* --verbose */ case 'd': /* --datadir */ @@ -449,7 +458,7 @@ static int run_query(const char *query, DYNAMIC_STRING *ds_res, char query_file_path[FN_REFLEN]; DBUG_ENTER("run_query"); DBUG_PRINT("enter", ("query: %s", query)); - if ((fd= create_temp_file(query_file_path, NULL, + if ((fd= create_temp_file(query_file_path, opt_tmpdir, "sql", O_CREAT | O_SHARE | O_RDWR, MYF(MY_WME))) < 0) die("Failed to create temporary file for defaults"); diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 829941545cd..d123fa03201 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -1745,6 +1745,7 @@ sub mysql_upgrade_arguments() mtr_add_arg($args, "--socket=$master->[0]->{'path_sock'}"); mtr_add_arg($args, "--datadir=$master->[0]->{'path_myddir'}"); mtr_add_arg($args, "--basedir=$glob_basedir"); + mtr_add_arg($args, "--tmpdir=$opt_tmpdir"); if ( $opt_debug ) {