From 7c2c8f07e43a5ce3998473bef6565e9e60ac533f Mon Sep 17 00:00:00 2001 From: "dkatz@damien-katzs-computer.local" <> Date: Fri, 27 Jul 2007 16:26:26 -0400 Subject: [PATCH 01/11] Bug #29419 "Specifying a join_buffer > 4GB on 64 bit machines not possible." Use size_t instead of uint when calculating join buffer size, because uint can be overflown on 64-bit platforms and join_buffer_size > 4 GB. The test case for this bug is a part of the test suite for bug #5731. --- sql/sql_select.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/sql_select.cc b/sql/sql_select.cc index d8bf8466f58..89bdd22a3de 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -13014,7 +13014,8 @@ static int join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) { reg1 uint i; - uint length,blobs,size; + uint length, blobs; + size_t size; CACHE_FIELD *copy,**blob_ptr; JOIN_CACHE *cache; JOIN_TAB *join_tab; @@ -13130,7 +13131,7 @@ store_record_in_cache(JOIN_CACHE *cache) length=cache->length; if (cache->blobs) length+=used_blob_length(cache->blob_ptr); - if ((last_record=(length+cache->length > (uint) (cache->end - pos)))) + if ((last_record= (length + cache->length > (size_t) (cache->end - pos)))) cache->ptr_record=cache->records; /* @@ -13176,7 +13177,7 @@ store_record_in_cache(JOIN_CACHE *cache) } } cache->pos=pos; - return last_record || (uint) (cache->end -pos) < cache->length; + return last_record || (size_t) (cache->end - pos) < cache->length; } From d8e67d455665e06e607fdd43f3e81e3668f76b2e Mon Sep 17 00:00:00 2001 From: "dkatz@damien-katzs-computer.local" <> Date: Wed, 5 Sep 2007 15:06:10 -0400 Subject: [PATCH 02/11] Bug #29804 UDF parameters don't contain correct string length Previously, UDF *_init functions were passed constant strings with erroneous lengths. The length came from the containing variable's size, not the length of the value itself. Now the *_init functions get the constant as a null terminated string with the correct length supplied too. --- mysql-test/r/udf.result | 24 ++++++++++++++++++++++++ mysql-test/t/udf.test | 36 ++++++++++++++++++++++++++++++++++++ sql/item_func.cc | 3 ++- sql/udf_example.c | 35 +++++++++++++++++++++++++++++++++++ sql/udf_example.def | 2 ++ 5 files changed, 99 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/udf.result b/mysql-test/r/udf.result index 2e9cf217ed6..885f5f8078e 100644 --- a/mysql-test/r/udf.result +++ b/mysql-test/r/udf.result @@ -296,4 +296,28 @@ Qcache_queries_in_cache 0 drop table t1; drop function metaphon; set GLOBAL query_cache_size=default; +CREATE TABLE const_len_bug ( +str_const varchar(4000), +result1 varchar(4000), +result2 varchar(4000) +); +CREATE TRIGGER check_const_len_trigger BEFORE INSERT ON const_len_bug FOR EACH ROW BEGIN +set NEW.str_const = 'bar'; +set NEW.result2 = check_const_len(NEW.str_const); +END | +CREATE PROCEDURE check_const_len_sp (IN str_const VARCHAR(4000)) +BEGIN +DECLARE result VARCHAR(4000); +SET result = check_const_len(str_const); +insert into const_len_bug values(str_const, result, ""); +END | +CREATE FUNCTION check_const_len RETURNS string SONAME "UDF_EXAMPLE_LIB"; +CALL check_const_len_sp("foo"); +SELECT * from const_len_bug; +str_const result1 result2 +bar Correct length Correct length +DROP FUNCTION check_const_len; +DROP PROCEDURE check_const_len_sp; +DROP TRIGGER check_const_len_trigger; +DROP TABLE const_len_bug; End of 5.0 tests. diff --git a/mysql-test/t/udf.test b/mysql-test/t/udf.test index 75af1f4be4b..beb18206a2e 100644 --- a/mysql-test/t/udf.test +++ b/mysql-test/t/udf.test @@ -312,4 +312,40 @@ drop function metaphon; set GLOBAL query_cache_size=default; +# +# Bug #29804 UDF parameters don't contain correct string length +# + +CREATE TABLE const_len_bug ( + str_const varchar(4000), + result1 varchar(4000), + result2 varchar(4000) +); + +DELIMITER |; +CREATE TRIGGER check_const_len_trigger BEFORE INSERT ON const_len_bug FOR EACH ROW BEGIN + set NEW.str_const = 'bar'; + set NEW.result2 = check_const_len(NEW.str_const); +END | + +CREATE PROCEDURE check_const_len_sp (IN str_const VARCHAR(4000)) +BEGIN +DECLARE result VARCHAR(4000); +SET result = check_const_len(str_const); +insert into const_len_bug values(str_const, result, ""); +END | +DELIMITER ;| + +--replace_result $UDF_EXAMPLE_LIB UDF_EXAMPLE_LIB +eval CREATE FUNCTION check_const_len RETURNS string SONAME "$UDF_EXAMPLE_LIB"; + +CALL check_const_len_sp("foo"); + +SELECT * from const_len_bug; + +DROP FUNCTION check_const_len; +DROP PROCEDURE check_const_len_sp; +DROP TRIGGER check_const_len_trigger; +DROP TABLE const_len_bug; + --echo End of 5.0 tests. diff --git a/sql/item_func.cc b/sql/item_func.cc index c70cfa1ce2a..21579763635 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -2924,7 +2924,8 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, String *res= arguments[i]->val_str(&buffers[i]); if (arguments[i]->null_value) continue; - f_args.args[i]= (char*) res->ptr(); + f_args.args[i]= (char*) res->c_ptr(); + f_args.lengths[i]= res->length(); break; } case INT_RESULT: diff --git a/sql/udf_example.c b/sql/udf_example.c index 0f28c2a14b0..df3a69755ad 100644 --- a/sql/udf_example.c +++ b/sql/udf_example.c @@ -1106,4 +1106,39 @@ char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)), } + +my_bool check_const_len_init(UDF_INIT *initid, UDF_ARGS *args, char *message) +{ + if (args->arg_count != 1) + { + strmov(message, "CHECK_CONST_LEN accepts only one argument"); + return 1; + } + if (args->args[0] == 0) + { + initid->ptr= (char*)"Not constant"; + } + else if(strlen(args->args[0]) == args->lengths[0]) + { + initid->ptr= (char*)"Correct length"; + } + else + { + initid->ptr= (char*)"Wrong length"; + } + initid->max_length = 100; + return 0; +} + +char * check_const_len(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)), + char *result, unsigned long *length, + char *is_null, char *error __attribute__((unused))) +{ + strmov(result, initid->ptr); + *length= strlen(result); + *is_null= 0; + return result; +} + + #endif /* HAVE_DLOPEN */ diff --git a/sql/udf_example.def b/sql/udf_example.def index 7a87147d7b6..3d569941cc8 100644 --- a/sql/udf_example.def +++ b/sql/udf_example.def @@ -23,3 +23,5 @@ EXPORTS avgcost is_const is_const_init + check_const_len + check_const_len_init From f26d69e01a6ffbae92c202c800981e1b102e0eda Mon Sep 17 00:00:00 2001 From: "msvensson@pilot.(none)" <> Date: Tue, 11 Sep 2007 15:00:52 +0200 Subject: [PATCH 03/11] Add support for specifying suites not located in mysql-test/suite/ Example otions that will all run binlog_stm_binlog.test in suite/binlog: --suite=binlog binlog.binlog_stm_binlog --suite=binlog binlog_stm_binlog binlog_stm_binlog --suite=suite/binlog binlog.binlog_stm_binlog --suite=suite/binlog binlog_stm_binlog --- mysql-test/lib/mtr_cases.pl | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/mysql-test/lib/mtr_cases.pl b/mysql-test/lib/mtr_cases.pl index ba7fcb8ce10..9ba7d737b9e 100644 --- a/mysql-test/lib/mtr_cases.pl +++ b/mysql-test/lib/mtr_cases.pl @@ -151,19 +151,16 @@ sub collect_one_suite($$) mtr_verbose("Collecting: $suite"); - my $testdir; - my $resdir; + my $suitedir= "$::glob_mysql_test_dir"; # Default + if ( $suite ne "main" ) + { + $suitedir= mtr_path_exists("$suitedir/suite/$suite", + "$suitedir/$suite"); + mtr_verbose("suitedir: $suitedir"); + } - if ( $suite eq "main" ) - { - $testdir= "$::glob_mysql_test_dir/t"; - $resdir= "$::glob_mysql_test_dir/r"; - } - else - { - $testdir= "$::glob_mysql_test_dir/suite/$suite/t"; - $resdir= "$::glob_mysql_test_dir/suite/$suite/r"; - } + my $testdir= "$suitedir/t"; + my $resdir= "$suitedir/r"; # ---------------------------------------------------------------------- # Build a hash of disabled testcases for this suite @@ -205,7 +202,7 @@ sub collect_one_suite($$) $tname = basename($tname); # Get rid of suite part - $tname =~ s/^$suite\.//; + $tname =~ s/^(.*)\.//; # Check if the extenstion has been specified. @@ -333,7 +330,7 @@ sub collect_one_test_case($$$$$$$$$) { my $tinfo= {}; - $tinfo->{'name'}= "$suite.$tname"; + $tinfo->{'name'}= basename($suite) . ".$tname"; $tinfo->{'result_file'}= "$resdir/$tname.result"; $tinfo->{'component_id'} = $component_id; push(@$cases, $tinfo); From 3c6ca8d6edf55764df93a831f61dc3855e82d91c Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/sin.intern.azundris.com" <> Date: Thu, 13 Sep 2007 16:19:46 +0200 Subject: [PATCH 04/11] Bug #15327: configure: --with-tcp-port option being partially ignored make sure that if builder configured with a non-standard (!= 3306) default TCP port that value actually gets used throughout. if they didn't configure a value, assume "use a sensible default", which will be read from /etc/services or, failing that, from the factory default. That makes the order of preference - command-line option - my.cnf, where applicable - $MYSQL_TCP_PORT environment variable - /etc/services (unless configured --with-tcp-port) - default port (--with-tcp-port=... or factory default) --- client/mysql.cc | 11 +++++++--- client/mysql_upgrade.c | 9 +++++++-- client/mysqladmin.cc | 8 +++++++- client/mysqlbinlog.cc | 11 +++++++--- client/mysqlcheck.c | 8 +++++++- client/mysqldump.c | 8 +++++++- client/mysqlimport.c | 8 +++++++- client/mysqlmanagerc.c | 7 ++++++- client/mysqlshow.c | 8 +++++++- client/mysqltest.c | 8 +++++++- configure.in | 29 ++++++++++++++++++++++++++- include/mysql_version.h.in | 1 + libmysql/libmysql.c | 21 +++++++++++++++---- mysql-test/Makefile.am | 1 + mysql-test/mysql-test-run-shell.sh | 11 +++++++++- netware/mysql_test_run.c | 3 ++- netware/mysqld_safe.c | 2 +- scripts/Makefile.am | 1 + scripts/mysql_config.sh | 7 ++++++- scripts/mysql_fix_privilege_tables.sh | 1 + scripts/mysqld_safe-watch.sh | 2 +- server-tools/instance-manager/priv.h | 2 +- sql/mysqld.cc | 21 ++++++++++++++++++- tests/mysql_client_test.c | 8 +++++++- tests/ssl_test.c | 2 +- tests/thread_test.c | 8 +++++++- 26 files changed, 176 insertions(+), 30 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index 368fce30d67..4f045e21cbd 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -673,9 +673,14 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, - (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, - 0}, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, + (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"prompt", OPT_PROMPT, "Set the mysql prompt to this value.", (gptr*) ¤t_prompt, (gptr*) ¤t_prompt, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 64de3d19882..f2bd4a3fa35 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -88,8 +88,13 @@ static struct my_option my_long_options[]= {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", 0, - 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index c7033f6914f..54f67c5df2d 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -159,7 +159,13 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &tcp_port, (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index a371981e24d..3d06a21c243 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -687,9 +687,14 @@ static struct my_option my_long_options[] = 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to connect to remote server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Use port to connect to the remote server.", - (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, - 0, 0, 0}, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, + 0, 0, 0, 0, 0, 0}, {"position", 'j', "Deprecated. Use --start-position instead.", (gptr*) &start_position, (gptr*) &start_position, 0, GET_ULL, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index b69e9201a28..8205a83fdf4 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -123,7 +123,13 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", diff --git a/client/mysqldump.c b/client/mysqldump.c index 1a024a923f5..1a809ca8b6c 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -361,7 +361,13 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", diff --git a/client/mysqlimport.c b/client/mysqlimport.c index e7bf1cfd889..066e892f78a 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -119,7 +119,13 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", diff --git a/client/mysqlmanagerc.c b/client/mysqlmanagerc.c index 1fdedab97fb..b4cc6320047 100644 --- a/client/mysqlmanagerc.c +++ b/client/mysqlmanagerc.c @@ -49,7 +49,12 @@ static struct my_option my_long_options[] = GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", (gptr*) &port, (gptr*) &port, 0, GET_UINT, REQUIRED_ARG, MYSQL_MANAGER_PORT, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 5be01cc5a52..7b1835055f5 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -188,7 +188,13 @@ static struct my_option my_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_mysql_port, (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __WIN__ diff --git a/client/mysqltest.c b/client/mysqltest.c index d1ec753b54b..ff45f80d914 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -4512,7 +4512,13 @@ static struct my_option my_long_options[] = GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &opt_port, (gptr*) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ps-protocol", OPT_PS_PROTOCOL, "Use prepared statements protocol for communication", (gptr*) &ps_protocol, (gptr*) &ps_protocol, 0, diff --git a/configure.in b/configure.in index 1da39ac1aa3..2e66b5eb333 100644 --- a/configure.in +++ b/configure.in @@ -710,7 +710,34 @@ AC_ARG_WITH(tcp-port, [ --with-tcp-port=port-number Which port to use for MySQL services (default 3306)], [ MYSQL_TCP_PORT=$withval ], - [ MYSQL_TCP_PORT=$MYSQL_TCP_PORT_DEFAULT ] + [ MYSQL_TCP_PORT=$MYSQL_TCP_PORT_DEFAULT + # if we actually defaulted (as opposed to the pathological case of + # --with-tcp-port= which might in theory + # happen if whole batch of servers was built from a script), set + # the default to zero to indicate that; we don't lose information + # that way, because 0 obviously indicates that we can get the + # default value from MYSQL_TCP_PORT. this seems really evil, but + # testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a + # a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not + # intend it to mean "use the default, in fact, look up a good default + # from /etc/services if you can", but really, really meant 3306 when + # they passed in 3306. When they pass in a specific value, let them + # have it; don't second guess user and think we know better, this will + # just make people cross. this makes the the logic work like this + # (which is complicated enough): + # + # - if a port was set during build, use that as a default. + # + # - otherwise, try to look up a port in /etc/services; if that fails, + # use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306) + # + # - allow the MYSQL_TCP_PORT environment variable to override that. + # + # - allow command-line parameters to override all of the above. + # + # the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js, + # so don't mess with that. + MYSQL_TCP_PORT_DEFAULT=0 ] ) AC_SUBST(MYSQL_TCP_PORT) # We might want to document the assigned port in the manual. diff --git a/include/mysql_version.h.in b/include/mysql_version.h.in index dac7ca661d1..04a43f2c968 100644 --- a/include/mysql_version.h.in +++ b/include/mysql_version.h.in @@ -15,6 +15,7 @@ #define FRM_VER @DOT_FRM_VERSION@ #define MYSQL_VERSION_ID @MYSQL_VERSION_ID@ #define MYSQL_PORT @MYSQL_TCP_PORT@ +#define MYSQL_PORT_DEFAULT @MYSQL_TCP_PORT_DEFAULT@ #define MYSQL_UNIX_ADDR "@MYSQL_UNIX_ADDR@" #define MYSQL_CONFIG_NAME "my" #define MYSQL_COMPILATION_COMMENT "@COMPILATION_COMMENT@" diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 72bc4445d83..5388aa07b9d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -133,10 +133,23 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)), { struct servent *serv_ptr; char *env; - if ((serv_ptr = getservbyname("mysql", "tcp"))) - mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); - if ((env = getenv("MYSQL_TCP_PORT"))) - mysql_port =(uint) atoi(env); + + /* + if builder specifically requested a default port, use that + (even if it coincides with our factory default). + only if they didn't do we check /etc/services (and, failing + on that, fall back to the factory default of 3306). + either default can be overridden by the environment variable + MYSQL_TCP_PORT, which in turn can be overridden with command + line options. + */ + +#if MYSQL_PORT_DEFAULT == 0 + if ((serv_ptr = getservbyname("mysql", "tcp"))) + mysql_port = (uint) ntohs((ushort) serv_ptr->s_port); +#endif + if ((env = getenv("MYSQL_TCP_PORT"))) + mysql_port =(uint) atoi(env); } #endif } diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am index ebc2bbb83e8..a764d1e851d 100644 --- a/mysql-test/Makefile.am +++ b/mysql-test/Makefile.am @@ -147,6 +147,7 @@ SUFFIXES = .sh -e 's!@''PERL''@!@PERL@!' \ -e 's!@''VERSION''@!@VERSION@!' \ -e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \ + -e 's!@''MYSQL_TCP_PORT_DEFAULT''@!@MYSQL_TCP_PORT_DEFAULT@!' \ -e 's!@''MYSQL_BASE_VERSION''@!@MYSQL_BASE_VERSION@!' \ -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \ -e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \ diff --git a/mysql-test/mysql-test-run-shell.sh b/mysql-test/mysql-test-run-shell.sh index a81a3b8b607..c0ff3d3d88e 100644 --- a/mysql-test/mysql-test-run-shell.sh +++ b/mysql-test/mysql-test-run-shell.sh @@ -17,7 +17,16 @@ USE_MANAGER=0 MY_TZ=GMT-3 TZ=$MY_TZ; export TZ # for UNIX_TIMESTAMP tests to work LOCAL_SOCKET=@MYSQL_UNIX_ADDR@ -MYSQL_TCP_PORT=@MYSQL_TCP_PORT@ + +if [ -z "$MYSQL_TCP_PORT" ]; then + MYSQL_TCP_PORT=@MYSQL_TCP_PORT@ + if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then + ESP=`getent services mysql/tcp` + if [ $? -eq 0 ]; then + MYSQL_TCP_PORT=`echo "$ESP"|sed -e's-^[a-z]*[ ]*\([0-9]*\)/[a-z]*$-\1-g'` + fi + fi +fi umask 022 diff --git a/netware/mysql_test_run.c b/netware/mysql_test_run.c index 6bab2f0149c..a62de9013f9 100644 --- a/netware/mysql_test_run.c +++ b/netware/mysql_test_run.c @@ -1170,7 +1170,8 @@ void setup(char *file) setenv("MYSQL_BINLOG", file_path, 1); setenv("MASTER_MYPORT", "9306", 1); setenv("SLAVE_MYPORT", "9307", 1); - setenv("MYSQL_TCP_PORT", "3306", 1); + snprintf(file_path, PATH_MAX*2, "%d", MYSQL_PORT); + setenv("MYSQL_TCP_PORT", file_path, 1); snprintf(file_path, PATH_MAX*2, "%s/mysql_client_test --no-defaults --testcase--user=root --port=%u ", bin_dir, master_port); setenv("MYSQL_CLIENT_TEST",file_path,1); snprintf(file_path, PATH_MAX*2, "%s/mysql --no-defaults --user=root --port=%u ", bin_dir, master_port); diff --git a/netware/mysqld_safe.c b/netware/mysqld_safe.c index 9db8a441ca3..00e7d1bcd51 100644 --- a/netware/mysqld_safe.c +++ b/netware/mysqld_safe.c @@ -189,7 +189,7 @@ void start_defaults(int argc, char *argv[]) snprintf(address, PATH_MAX, "0.0.0.0"); // port - snprintf(port, PATH_MAX, "3306"); + snprintf(port, PATH_MAX, "%d", MYSQL_PORT); // default option default_option[0]= NULL; diff --git a/scripts/Makefile.am b/scripts/Makefile.am index d4944962884..2b6870717ba 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -174,6 +174,7 @@ SUFFIXES = .sh -e 's!@''MYSQLD_DEFAULT_SWITCHES''@!@MYSQLD_DEFAULT_SWITCHES@!' \ -e 's!@''MYSQL_UNIX_ADDR''@!@MYSQL_UNIX_ADDR@!' \ -e 's!@''MYSQL_TCP_PORT''@!@MYSQL_TCP_PORT@!' \ + -e 's!@''MYSQL_TCP_PORT_DEFAULT''@!@MYSQL_TCP_PORT_DEFAULT@!' \ -e 's!@''TARGET_LINUX''@!@TARGET_LINUX@!' \ -e "s!@""CONF_COMMAND""@!@CONF_COMMAND@!" \ -e 's!@''MYSQLD_USER''@!@MYSQLD_USER@!' \ diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index f094cb060b7..ab58c512aac 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -92,9 +92,14 @@ fix_path pkgincludedir include/mysql include version='@VERSION@' socket='@MYSQL_UNIX_ADDR@' -port='@MYSQL_TCP_PORT@' ldflags='@LDFLAGS@' +if [ @MYSQL_TCP_PORT_DEFAULT@ -eq 0 ]; then + port=0 +else + port=@MYSQL_TCP_PORT@ +fi + # Create options # We intentionally add a space to the beginning and end of lib strings, simplifies replace later libs=" $ldflags -L$pkglibdir -lmysqlclient @ZLIB_DEPS@ @NON_THREADED_LIBS@" diff --git a/scripts/mysql_fix_privilege_tables.sh b/scripts/mysql_fix_privilege_tables.sh index a353273dc28..3b179957932 100644 --- a/scripts/mysql_fix_privilege_tables.sh +++ b/scripts/mysql_fix_privilege_tables.sh @@ -25,6 +25,7 @@ sql_only=0 basedir="@prefix@" verbose=0 args="" +# no elaborate fallback here; with no argument, it will happen in "mysql" port="" socket="" database="mysql" diff --git a/scripts/mysqld_safe-watch.sh b/scripts/mysqld_safe-watch.sh index c837ba9a118..f853741c87b 100644 --- a/scripts/mysqld_safe-watch.sh +++ b/scripts/mysqld_safe-watch.sh @@ -66,7 +66,7 @@ fi echo "Starting mysqld demon with databases from $DATADIR" #Default communication ports -#MYSQL_TCP_PORT=3306 +#MYSQL_TCP_PORT=@MYSQL_TCP_PORT@ if test -z "$MYSQL_UNIX_PORT" then MYSQL_UNIX_PORT="/tmp/mysql.sock" diff --git a/server-tools/instance-manager/priv.h b/server-tools/instance-manager/priv.h index a746288f28b..2e55e0ac8e6 100644 --- a/server-tools/instance-manager/priv.h +++ b/server-tools/instance-manager/priv.h @@ -25,7 +25,7 @@ #include "my_pthread.h" /* IM-wide platform-independent defines */ -#define SERVER_DEFAULT_PORT 3306 +#define SERVER_DEFAULT_PORT MYSQL_PORT #define DEFAULT_MONITORING_INTERVAL 20 #define DEFAULT_PORT 2273 /* three-week timeout should be enough */ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 61980fa1887..7e0c8c7e775 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -1300,8 +1300,21 @@ static void set_ports() { // Get port if not from commandline struct servent *serv_ptr; mysqld_port= MYSQL_PORT; + + /* + if builder specifically requested a default port, use that + (even if it coincides with our factory default). + only if they didn't do we check /etc/services (and, failing + on that, fall back to the factory default of 3306). + either default can be overridden by the environment variable + MYSQL_TCP_PORT, which in turn can be overridden with command + line options. + */ + +#if MYSQL_PORT_DEFAULT == 0 if ((serv_ptr= getservbyname("mysql", "tcp"))) mysqld_port= ntohs((u_short) serv_ptr->s_port); /* purecov: inspected */ +#endif if ((env = getenv("MYSQL_TCP_PORT"))) mysqld_port= (uint) atoi(env); /* purecov: inspected */ } @@ -5399,7 +5412,13 @@ Disable with --skip-ndbcluster (will save memory).", {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.", (gptr*) &pidfile_name_ptr, (gptr*) &pidfile_name_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &mysqld_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &mysqld_port, (gptr*) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT, "Maximum time in seconds to wait for the port to become free. " diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 75c86902972..4a1941a2cf8 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -15759,7 +15759,13 @@ static struct my_option client_test_long_options[] = {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection", (char **) &opt_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (char **) &opt_port, (char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-arg", 'A', "Send embedded server this as a parameter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/tests/ssl_test.c b/tests/ssl_test.c index 136f0a83cbe..ad6bc925cc6 100644 --- a/tests/ssl_test.c +++ b/tests/ssl_test.c @@ -44,7 +44,7 @@ int main(int argc, char **argv) "../SSL/MySQL-client-cert.pem", "../SSL/MySQL-ca-cert.pem", 0, 0); #endif - if (!(sock = mysql_real_connect(&mysql,"127.0.0.1",0,0,argv[1],3306,NULL,0))) + if (!(sock = mysql_real_connect(&mysql,"127.0.0.1",0,0,argv[1],MYSQL_PORT,NULL,0))) { fprintf(stderr,"Couldn't connect to engine!\n%s\n\n",mysql_error(&mysql)); perror(""); diff --git a/tests/thread_test.c b/tests/thread_test.c index 0ad446282c2..0ba03694893 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -103,7 +103,13 @@ static struct my_option my_long_options[] = (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"query", 'Q', "Query to execute in each threads", (gptr*) &query, (gptr*) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection", (gptr*) &tcp_port, + {"port", 'P', "Port number to use for connection or 0 for default to, in " + "order of preference, my.cnf, $MYSQL_TCP_PORT, " +#if MYSQL_PORT_DEFAULT == 0 + "/etc/services, " +#endif + "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", + (gptr*) &tcp_port, (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection", (gptr*) &unix_socket, (gptr*) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, From cc3f0af2e199487c8b2cebd6c7b525168ad5a7a7 Mon Sep 17 00:00:00 2001 From: "tnurnberg@mysql.com/sin.intern.azundris.com" <> Date: Sat, 15 Sep 2007 04:59:46 +0200 Subject: [PATCH 05/11] Bug #15327: configure: --with-tcp-port option being partially ignored after merge fix :-/ --- client/mysqlbinlog.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index f848a98e5a6..2110f27d887 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -762,7 +762,6 @@ static struct my_option my_long_options[] = "built-in default (" STRINGIFY_ARG(MYSQL_PORT) ").", (uchar**) &port, (uchar**) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - 0, 0, 0}, {"position", 'j', "Deprecated. Use --start-position instead.", (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, From e41434fb950e5bd29d400c371b33038cb87b7446 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 21 Sep 2007 09:48:30 +0200 Subject: [PATCH 06/11] Bug#30843 Bad Test addition to t/archive.test - Add extra insert --- mysql-test/r/archive.result | 4 +++- mysql-test/t/archive.test | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index b6a313ddf1a..a1c11417bd0 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -11124,9 +11124,10 @@ SELECT COUNT(auto) FROM t2; COUNT(auto) 1213 INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +INSERT INTO t2 VALUES (5,000001,00,'after','delayed','insert',''); SELECT COUNT(auto) FROM t2; COUNT(auto) -1214 +1215 ALTER TABLE t2 DROP COLUMN fld6; SHOW CREATE TABLE t2; Table Create Table @@ -12354,6 +12355,7 @@ auto fld1 companynr fld3 fld4 fld5 3 011402 37 Romans scholastics jarring 4 011403 37 intercepted audiology tinily 4 011403 37 intercepted audiology tinily +5 000001 00 after delayed insert drop table t1, t2, t4; create table t1 (i int) engine=archive; insert into t1 values (1); diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index 61033fca3f7..d1c45a259c6 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1348,7 +1348,15 @@ SELECT * FROM t2; # Test INSERT DELAYED and wait until the table has one more record SELECT COUNT(auto) FROM t2; INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); -while (`SELECT COUNT(auto)!=1214 FROM t2`) + +# Insert another record since in Archive delayed values are only +# guaranteed to materialize based on either: +# 1) A new row showing up from a normal insert +# 2) A flush table has occurred. +INSERT INTO t2 VALUES (5,000001,00,'after','delayed','insert',''); + +# Wait for the delayed insert to appear +while (`SELECT COUNT(auto)!=1215 FROM t2`) { sleep 0.1; } From 10816b3a08647abdf4e621e0f707cb674c03cda3 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 21 Sep 2007 17:10:45 +0200 Subject: [PATCH 07/11] Bug#28359 Intermitted lost connection at 'reading authorization packet' errors - Increase default 'connect_timeout' value to 10 seconds --- sql/mysql_priv.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 44eb5590a28..1d944f196ed 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -245,8 +245,13 @@ MY_LOCALE *my_locale_by_number(uint number); #define PRECISION_FOR_DOUBLE 53 #define PRECISION_FOR_FLOAT 24 +/* + Default time to wait before aborting a new client connection + that does not respond to "initial server greeting" timely +*/ +#define CONNECT_TIMEOUT 10 + /* The following can also be changed from the command line */ -#define CONNECT_TIMEOUT 5 // Do not wait long for connect #define DEFAULT_CONCURRENCY 10 #define DELAYED_LIMIT 100 /* pause after xxx inserts */ #define DELAYED_QUEUE_SIZE 1000 From 9c9c82e04ecd23e4aa5f44ecfb63a86f8f97b9d3 Mon Sep 17 00:00:00 2001 From: "iggy@alf.(none)" <> Date: Fri, 21 Sep 2007 11:38:23 -0400 Subject: [PATCH 08/11] Bug #15327: configure: --with-tcp-port option being partially ignored make sure that if builder configured with a non-standard (!= 3306) default TCP port that value actually gets used throughout. --- win/configure.js | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/win/configure.js b/win/configure.js index a2502d96b80..38ca11f0439 100755 --- a/win/configure.js +++ b/win/configure.js @@ -31,6 +31,7 @@ try configureInTS.Close(); var default_comment = "Source distribution"; var default_port = GetValue(configureIn, "MYSQL_TCP_PORT_DEFAULT"); + var actual_port = 0; var configfile = fso.CreateTextFile("win\\configure.data", true); for (i=0; i < args.Count(); i++) @@ -58,10 +59,41 @@ try default_comment = parts[1]; break; case "MYSQL_TCP_PORT": - default_port = parts[1]; + actual_port = parts[1]; break; } } + if (actual_port == 0) + { + // if we actually defaulted (as opposed to the pathological case of + // --with-tcp-port= which might in theory + // happen if whole batch of servers was built from a script), set + // the default to zero to indicate that; we don't lose information + // that way, because 0 obviously indicates that we can get the + // default value from MYSQL_TCP_PORT. this seems really evil, but + // testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a + // a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not + // intend it to mean "use the default, in fact, look up a good default + // from /etc/services if you can", but really, really meant 3306 when + // they passed in 3306. When they pass in a specific value, let them + // have it; don't second guess user and think we know better, this will + // just make people cross. this makes the the logic work like this + // (which is complicated enough): + // + // - if a port was set during build, use that as a default. + // + // - otherwise, try to look up a port in /etc/services; if that fails, + // use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306) + // + // - allow the MYSQL_TCP_PORT environment variable to override that. + // + // - allow command-line parameters to override all of the above. + // + // the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js, + // so don't mess with that. + actual_port = default_port; + default_port = 0; + } configfile.WriteLine("SET (COMPILATION_COMMENT \"" + default_comment + "\")"); @@ -70,7 +102,8 @@ try GetValue(configureIn, "PROTOCOL_VERSION") + "\")"); configfile.WriteLine("SET (DOT_FRM_VERSION \"" + GetValue(configureIn, "DOT_FRM_VERSION") + "\")"); - configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT_DEFAULT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + actual_port + "\")"); configfile.WriteLine("SET (MYSQL_UNIX_ADDR \"" + GetValue(configureIn, "MYSQL_UNIX_ADDR_DEFAULT") + "\")"); var version = GetVersion(configureIn); From ed055965bf2e4f04be61372bb81f67d51231ae33 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Fri, 21 Sep 2007 17:52:02 +0200 Subject: [PATCH 09/11] - Increase default connect_timeout to avoid intermittent disconnects when test servers are put under load --- mysql-test/mysql-test-run.pl | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 06447b9e69d..ad507440bb7 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -3708,6 +3708,11 @@ sub mysqld_arguments ($$$$) { mtr_add_arg($args, "%s--language=%s", $prefix, $path_language); mtr_add_arg($args, "%s--tmpdir=$opt_tmpdir", $prefix); + # Increase default connect_timeout to avoid intermittent + # disconnects when test servers are put under load + # see BUG#28359 + mtr_add_arg($args, "%s--connect-timeout=60", $prefix); + if ( $opt_valgrind_mysqld ) { mtr_add_arg($args, "%s--skip-safemalloc", $prefix); From ac026cfeb6d8d3ded34db5c222f4d5b6dfb5262b Mon Sep 17 00:00:00 2001 From: "iggy@alf.(none)" <> Date: Fri, 21 Sep 2007 12:05:54 -0400 Subject: [PATCH 10/11] Bug #15327: configure: --with-tcp-port option being partially ignored make sure that if builder configured with a non-standard (!= 3306) default TCP port that value actually gets used throughout. --- win/configure.js | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/win/configure.js b/win/configure.js index 7e10ac34697..c86ec0cf47c 100644 --- a/win/configure.js +++ b/win/configure.js @@ -31,6 +31,7 @@ try configureInTS.Close(); var default_comment = "Source distribution"; var default_port = GetValue(configureIn, "MYSQL_TCP_PORT_DEFAULT"); + var actual_port = 0; var configfile = fso.CreateTextFile("win\\configure.data", true); for (i=0; i < args.Count(); i++) @@ -59,10 +60,41 @@ try default_comment = parts[1]; break; case "MYSQL_TCP_PORT": - default_port = parts[1]; + actual_port = parts[1]; break; } } + if (actual_port == 0) + { + // if we actually defaulted (as opposed to the pathological case of + // --with-tcp-port= which might in theory + // happen if whole batch of servers was built from a script), set + // the default to zero to indicate that; we don't lose information + // that way, because 0 obviously indicates that we can get the + // default value from MYSQL_TCP_PORT. this seems really evil, but + // testing for MYSQL_TCP_PORT==MYSQL_TCP_PORT_DEFAULT would make a + // a port of MYSQL_TCP_PORT_DEFAULT magic even if the builder did not + // intend it to mean "use the default, in fact, look up a good default + // from /etc/services if you can", but really, really meant 3306 when + // they passed in 3306. When they pass in a specific value, let them + // have it; don't second guess user and think we know better, this will + // just make people cross. this makes the the logic work like this + // (which is complicated enough): + // + // - if a port was set during build, use that as a default. + // + // - otherwise, try to look up a port in /etc/services; if that fails, + // use MYSQL_TCP_PORT_DEFAULT (at the time of this writing 3306) + // + // - allow the MYSQL_TCP_PORT environment variable to override that. + // + // - allow command-line parameters to override all of the above. + // + // the top-most MYSQL_TCP_PORT_DEFAULT is read from win/configure.js, + // so don't mess with that. + actual_port = default_port; + default_port = 0; + } configfile.WriteLine("SET (COMPILATION_COMMENT \"" + default_comment + "\")"); @@ -71,7 +103,8 @@ try GetValue(configureIn, "PROTOCOL_VERSION") + "\")"); configfile.WriteLine("SET (DOT_FRM_VERSION \"" + GetValue(configureIn, "DOT_FRM_VERSION") + "\")"); - configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT_DEFAULT \"" + default_port + "\")"); + configfile.WriteLine("SET (MYSQL_TCP_PORT \"" + actual_port + "\")"); configfile.WriteLine("SET (MYSQL_UNIX_ADDR \"" + GetValue(configureIn, "MYSQL_UNIX_ADDR_DEFAULT") + "\")"); var version = GetVersion(configureIn); From d8fd59a42300122a3e4a04ae5db16e63d4b26df4 Mon Sep 17 00:00:00 2001 From: "msvensson@shellback.(none)" <> Date: Sat, 22 Sep 2007 12:17:14 +0200 Subject: [PATCH 11/11] Bug#30843 Bad Test addition to t/archive.test --- mysql-test/r/archive.result | 9 ++++----- mysql-test/t/archive.test | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mysql-test/r/archive.result b/mysql-test/r/archive.result index a1c11417bd0..a0b13b14b17 100644 --- a/mysql-test/r/archive.result +++ b/mysql-test/r/archive.result @@ -11123,8 +11123,8 @@ auto fld1 companynr fld3 fld4 fld5 fld6 SELECT COUNT(auto) FROM t2; COUNT(auto) 1213 -INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); -INSERT INTO t2 VALUES (5,000001,00,'after','delayed','insert',''); +INSERT DELAYED INTO t2 VALUES (99999,011403,37,'the','delayed','insert',''); +INSERT INTO t2 VALUES (100000,000001,00,'after','delayed','insert',''); SELECT COUNT(auto) FROM t2; COUNT(auto) 1215 @@ -11139,7 +11139,7 @@ t2 CREATE TABLE `t2` ( `fld4` char(35) NOT NULL default '', `fld5` char(35) NOT NULL default '' ) ENGINE=ARCHIVE DEFAULT CHARSET=latin1 -SELECT * from t2; +SELECT * from t2 WHERE auto != 100000; auto fld1 companynr fld3 fld4 fld5 1 000001 00 Omaha teethe neat 2 011401 37 breaking dreaded Steinberg @@ -12354,8 +12354,7 @@ auto fld1 companynr fld3 fld4 fld5 2 011401 37 breaking dreaded Steinberg 3 011402 37 Romans scholastics jarring 4 011403 37 intercepted audiology tinily -4 011403 37 intercepted audiology tinily -5 000001 00 after delayed insert +99999 011403 37 the delayed insert drop table t1, t2, t4; create table t1 (i int) engine=archive; insert into t1 values (1); diff --git a/mysql-test/t/archive.test b/mysql-test/t/archive.test index d1c45a259c6..2d29cab041d 100644 --- a/mysql-test/t/archive.test +++ b/mysql-test/t/archive.test @@ -1347,13 +1347,13 @@ SELECT * FROM t2; # Test INSERT DELAYED and wait until the table has one more record SELECT COUNT(auto) FROM t2; -INSERT DELAYED INTO t2 VALUES (4,011403,37,'intercepted','audiology','tinily',''); +INSERT DELAYED INTO t2 VALUES (99999,011403,37,'the','delayed','insert',''); # Insert another record since in Archive delayed values are only # guaranteed to materialize based on either: # 1) A new row showing up from a normal insert # 2) A flush table has occurred. -INSERT INTO t2 VALUES (5,000001,00,'after','delayed','insert',''); +INSERT INTO t2 VALUES (100000,000001,00,'after','delayed','insert',''); # Wait for the delayed insert to appear while (`SELECT COUNT(auto)!=1215 FROM t2`) @@ -1365,7 +1365,7 @@ SELECT COUNT(auto) FROM t2; # Adding test for alter table ALTER TABLE t2 DROP COLUMN fld6; SHOW CREATE TABLE t2; -SELECT * from t2; +SELECT * from t2 WHERE auto != 100000; # # Cleanup, test is over #