From d79f0973ce03e3bc25a2e2fa130cf129936d4bcd Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Feb 2007 10:28:50 +0100 Subject: [PATCH 1/7] Bug#25197 repeat function returns null when using table field directly as count - Return empty string also if count is unsigned and value is 0 mysql-test/r/func_str.result: Update test result mysql-test/t/func_str.test: Add test case for using an unsigned value as count parameter for REPEAT sql/item_strfunc.cc: The repeat function should return the emptystring if count is unsigned and equal to zero or count is signed and less than or equal to zero --- mysql-test/r/func_str.result | 14 ++++++++++++++ mysql-test/t/func_str.test | 22 ++++++++++++++++++++++ sql/item_strfunc.cc | 4 +++- 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/func_str.result b/mysql-test/r/func_str.result index 052451f8c54..e716a89132c 100644 --- a/mysql-test/r/func_str.result +++ b/mysql-test/r/func_str.result @@ -1940,4 +1940,18 @@ abcxx select lpad('abc', cast(5 as unsigned integer), 'x'); lpad('abc', cast(5 as unsigned integer), 'x') xxabc +DROP TABLE IF EXISTS t1; +CREATE TABLE `t1` ( +`id` varchar(20) NOT NULL, +`tire` tinyint(3) unsigned NOT NULL, +PRIMARY KEY (`id`) +); +INSERT INTO `t1` (`id`, `tire`) VALUES ('A', 0), ('B', 1),('C', 2); +SELECT REPEAT( '#', tire ) AS A, +REPEAT( '#', tire % 999 ) AS B, tire FROM `t1`; +A B tire + 0 +# # 1 +## ## 2 +DROP TABLE t1; End of 5.0 tests diff --git a/mysql-test/t/func_str.test b/mysql-test/t/func_str.test index 64b59025d44..7cf7ef2cab6 100644 --- a/mysql-test/t/func_str.test +++ b/mysql-test/t/func_str.test @@ -1008,4 +1008,26 @@ select repeat('a', cast(2 as unsigned int)); select rpad('abc', cast(5 as unsigned integer), 'x'); select lpad('abc', cast(5 as unsigned integer), 'x'); + +# +# Bug #25197 :repeat function returns null when using table field directly as count +# + +--disable_warnings +DROP TABLE IF EXISTS t1; +--enable_warnings + +CREATE TABLE `t1` ( + `id` varchar(20) NOT NULL, + `tire` tinyint(3) unsigned NOT NULL, + PRIMARY KEY (`id`) +); + +INSERT INTO `t1` (`id`, `tire`) VALUES ('A', 0), ('B', 1),('C', 2); + +SELECT REPEAT( '#', tire ) AS A, + REPEAT( '#', tire % 999 ) AS B, tire FROM `t1`; + +DROP TABLE t1; + --echo End of 5.0 tests diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 95cc32b5c8e..627751a1106 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -2251,8 +2251,10 @@ String *Item_func_repeat::val_str(String *str) if (args[0]->null_value || args[1]->null_value) goto err; // string and/or delim are null null_value= 0; - if ((count <= 0) && !args[1]->unsigned_flag) // For nicer SQL code + + if (count == 0 || count < 0 && !args[1]->unsigned_flag) return &my_empty_string; + /* Assumes that the maximum length of a String is < INT_MAX32. */ /* Bounds check on count: If this is triggered, we will error. */ if ((ulonglong) count > INT_MAX32) From f1476f439557384fae199af8e5652c7d13a8e47c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 27 Feb 2007 16:58:40 +0100 Subject: [PATCH 2/7] Bug#26536 func_time failure on vm-win2003-64-b, occurs every time - my_time_t is defined as long which means it will not always be the same size as time_t. See explanation in include/my_time.h sql/event_queue.cc: No need to require that "sizeof(time_t) == sizeof(my_time_t)" --- sql/event_queue.cc | 7 ------- 1 file changed, 7 deletions(-) diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 068abbe3408..e67eac4125c 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -153,13 +153,6 @@ Event_queue::init_queue(THD *thd, Event_db_repository *db_repo) goto err; } - if (sizeof(my_time_t) != sizeof(time_t)) - { - sql_print_error("SCHEDULER: sizeof(my_time_t) != sizeof(time_t) ." - "The scheduler may not work correctly. Stopping"); - goto err; - } - res= load_events_from_db(thd); UNLOCK_QUEUE_DATA(); if (res) From d59d5f18c43e3165a1cdb56870702e7202a0a2b0 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 09:10:38 +0100 Subject: [PATCH 3/7] Bug#19410 Test 'kill' fails on Windows + SCO - Use "mysql_stmt_field_count" to determine if there is a need to call "mysql_stmt_store_result" client/mysqltest.c: Only call 'mysql_stmt_store_result' if 'mysql_stmt_field_count' is greater than 0 indicating that this query has a result set. This change is mainly since if mysql_stmt_store_result fails the value returned by mysql_stmt_field_count will be reset. --- client/mysqltest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 99462d82f40..4a89299e836 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -5048,8 +5048,9 @@ void run_query_stmt(MYSQL *mysql, struct st_command *command, /* If we got here the statement succeeded and was expected to do so, get data. Note that this can still give errors found during execution! + Store the result of the query if if will return any fields */ - if (mysql_stmt_store_result(stmt)) + if (mysql_stmt_field_count(stmt) && mysql_stmt_store_result(stmt)) { handle_error(command, mysql_stmt_errno(stmt), mysql_stmt_error(stmt), mysql_stmt_sqlstate(stmt), ds); From 8c5a862569a75c175882544fff1de45be07e076b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 10:05:51 +0100 Subject: [PATCH 4/7] Use cygwin for --exec and --system in mysqltest for MySQL before 5.0 --- client/mysqltest.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/client/mysqltest.c b/client/mysqltest.c index 055577fc535..0300afd980c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -61,6 +61,11 @@ # endif #endif +/* Use cygwin for --exec and --system before 5.0 */ +#if MYSQL_VERSION_ID < 50000 +#define USE_CYGWIN +#endif + #define MAX_VAR_NAME_LENGTH 256 #define MAX_COLUMNS 256 #define MAX_EMBEDDED_SERVER_ARGS 64 From e40bcac08ed55c122b05bdbd04c273a665bea3b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 10:37:32 +0100 Subject: [PATCH 5/7] Bug#26686 mysql-test-run.pl aborts when waitpid returns -1 - Add error handling for waitpid returns -1 for "simple run of command" mysql-test/lib/mtr_process.pl: - Add error handling for waitpid returns -1 when a simple command is run. - Add missing return - Add mtr_errors where the program should never come - Remove an else to improve program readability - Change mtr_debug to mtr_warning for "Got EAGAIN from fork()..." --- mysql-test/lib/mtr_process.pl | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 9cf013d4e9d..20dca4b6980 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -125,19 +125,18 @@ sub spawn_impl ($$$$$$$$) { { if ( $! == $!{EAGAIN} ) # See "perldoc Errno" { - mtr_debug("Got EAGAIN from fork(), sleep 1 second and redo"); + mtr_warning("Got EAGAIN from fork(), sleep 1 second and redo"); sleep(1); redo FORK; } - else - { - mtr_error("$path ($pid) can't be forked"); - } + + mtr_error("$path ($pid) can't be forked, error: $!"); + } if ( $pid ) { - spawn_parent_impl($pid,$mode,$path); + return spawn_parent_impl($pid,$mode,$path); } else { @@ -202,8 +201,11 @@ sub spawn_impl ($$$$$$$$) { { mtr_child_error("failed to execute \"$path\": $!"); } + mtr_error("Should never come here 1!"); } + mtr_error("Should never come here 2!"); } + mtr_error("Should never come here 3!"); } @@ -216,12 +218,21 @@ sub spawn_parent_impl { { if ( $mode eq 'run' ) { - # Simple run of command, we wait for it to return + # Simple run of command, wait blocking for it to return my $ret_pid= waitpid($pid,0); if ( $ret_pid != $pid ) { - mtr_error("waitpid($pid, 0) returned $ret_pid " . - "when waiting for '$path'"); + # The "simple" waitpid has failed, print debug info + # and try to handle the error + mtr_warning("waitpid($pid, 0) returned $ret_pid " . + "when waiting for '$path', error: '$!'"); + if ( $ret_pid == -1 ) + { + # waitpid returned -1, that would indicate the process + # no longer exist and waitpid couldn't wait for it. + return 1; + } + mtr_error("Error handling failed"); } return mtr_process_exit_status($?); From 4d49015bf9dafab0f08adada3a9011b6aeecf31c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 10:52:51 +0100 Subject: [PATCH 6/7] Bug#26416 mysql-test-run exits with "Hangup" when piped to grep - Thanks to Christian for the patch! mysql-test/lib/mtr_process.pl: Avoid printout of "Hangup" when script exits by using POSIX::kill --- mysql-test/lib/mtr_process.pl | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/mysql-test/lib/mtr_process.pl b/mysql-test/lib/mtr_process.pl index 20dca4b6980..e9e0dcce1b8 100644 --- a/mysql-test/lib/mtr_process.pl +++ b/mysql-test/lib/mtr_process.pl @@ -8,7 +8,7 @@ use Socket; use Errno; use strict; -use POSIX 'WNOHANG'; +use POSIX qw(WNOHANG SIGHUP); sub mtr_run ($$$$$$;$); sub mtr_spawn ($$$$$$;$); @@ -1100,12 +1100,6 @@ sub mtr_kill_processes ($) { # ############################################################################## -# FIXME something is wrong, we sometimes terminate with "Hangup" written -# to tty, and no STDERR output telling us why. - -# FIXME for some reason, setting HUP to 'IGNORE' will cause exit() to -# write out "Hangup", and maybe loose some output. We insert a sleep... - sub mtr_exit ($) { my $code= shift; mtr_timer_stop_all($::glob_timers); @@ -1117,7 +1111,7 @@ sub mtr_exit ($) { # set ourselves as the group leader at startup (with # POSIX::setpgrp(0,0)), but then care must be needed to always do # proper child process cleanup. - kill('HUP', -$$) if !$::glob_win32_perl and $$ == getpgrp(); + POSIX::kill(SIGHUP, -$$) if !$::glob_win32_perl and $$ == getpgrp(); exit($code); } From 7624028419147d656646c95b2bc11ea72aa3e419 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 28 Feb 2007 13:47:41 +0100 Subject: [PATCH 7/7] When using a --mem= the memdir must be removed to assure afresh start --- mysql-test/mysql-test-run.pl | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index ed26204d7cb..21960d2bfcd 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2025,6 +2025,16 @@ sub remove_stale_vardir () { mtr_verbose("Removing $opt_vardir/"); rmtree("$opt_vardir/"); } + + if ( $opt_mem ) + { + # A symlink from var/ to $opt_mem will be set up + # remove the $opt_mem dir to assure the symlink + # won't point at an old directory + mtr_verbose("Removing $opt_mem"); + rmtree($opt_mem); + } + } else {