summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@nosik.monty.fi>2006-11-27 01:51:50 +0200
committerunknown <monty@nosik.monty.fi>2006-11-27 01:51:50 +0200
commitf700408717ea7d51132c150a9afaddcb73071b49 (patch)
tree49d6dd88d75f1d6a0d8e481cb8ae015f6f2b91f6
parent788ad30f081bc55ff97ceed78ec7ff545e25ed99 (diff)
parent52fc261bcab0becc9d23f8d1e511760413a6d85d (diff)
downloadmariadb-git-f700408717ea7d51132c150a9afaddcb73071b49.tar.gz
Merge mysql.com:/home/my/mysql-5.0
into mysql.com:/home/my/mysql-5.1 client/mysqldump.c: Auto merged include/errmsg.h: Auto merged mysql-test/mysql-test-run.pl: Auto merged sql-common/client.c: Auto merged mysql-test/mysql-test-run-shell.sh: SCCS merged
-rw-r--r--include/errmsg.h3
-rw-r--r--libmysql/errmsg.c3
-rw-r--r--mysql-test/mysql-test-run-shell.sh4
-rwxr-xr-xmysql-test/mysql-test-run.pl106
-rwxr-xr-xmysql-test/t/wait_for_socket.sh2
-rw-r--r--sql-common/client.c76
6 files changed, 145 insertions, 49 deletions
diff --git a/include/errmsg.h b/include/errmsg.h
index dc7adb3b501..f24ea2bf396 100644
--- a/include/errmsg.h
+++ b/include/errmsg.h
@@ -95,6 +95,7 @@ extern const char *client_errors[]; /* Error messages */
#define CR_NO_STMT_METADATA 2052
#define CR_NO_RESULT_SET 2053
#define CR_NOT_IMPLEMENTED 2054
-#define CR_ERROR_LAST /*Copy last error nr:*/ 2054
+#define CR_SERVER_LOST_EXTENDED 2055
+#define CR_ERROR_LAST /*Copy last error nr:*/ 2055
/* Add error numbers before CR_ERROR_LAST and change it accordingly. */
diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c
index 9e1d70a47df..59089d5ec18 100644
--- a/libmysql/errmsg.c
+++ b/libmysql/errmsg.c
@@ -82,6 +82,7 @@ const char *client_errors[]=
"Prepared statement contains no metadata",
"Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet",
+ "Lost connection to MySQL server at '%s', system error: %d",
""
};
@@ -145,6 +146,7 @@ const char *client_errors[]=
"Prepared statement contains no metadata",
"Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet",
+ "Lost connection to MySQL server at '%s', system error: %d",
""
};
@@ -206,6 +208,7 @@ const char *client_errors[]=
"Prepared statement contains no metadata",
"Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet",
+ "Lost connection to MySQL server at '%s', system error: %d",
""
};
#endif
diff --git a/mysql-test/mysql-test-run-shell.sh b/mysql-test/mysql-test-run-shell.sh
index 366884a635a..c6da525c159 100644
--- a/mysql-test/mysql-test-run-shell.sh
+++ b/mysql-test/mysql-test-run-shell.sh
@@ -129,7 +129,7 @@ find_valgrind()
fi
# >=2.1.2 requires the --tool option, some versions write to stdout, some to stderr
valgrind --help 2>&1 | grep "\-\-tool" > /dev/null && FIND_VALGRIND="$FIND_VALGRIND --tool=memcheck"
- FIND_VALGRIND="$FIND_VALGRIND --alignment=8 --leak-check=yes --num-callers=16 --suppressions=$CWD/valgrind.supp"
+ FIND_VALGRIND="$FIND_VALGRIND --alignment=8 --leak-check=yes --num-callers=16 --suppressions=$MYSQL_TEST_DIR/valgrind.supp"
}
# No paths below as we can't be sure where the program is!
@@ -2177,7 +2177,7 @@ then
# Remove files that can cause problems
$RM -rf $MYSQL_TEST_DIR/var/ndbcluster
$RM -rf $MYSQL_TEST_DIR/var/tmp/snapshot*
- $RM -f $MYSQL_TEST_DIR/var/run/* $MYSQL_TEST_DIR/var/tmp/*
+ $RM -rf $MYSQL_TEST_DIR/var/run/* $MYSQL_TEST_DIR/var/tmp/*
# Remove old berkeley db log files that can confuse the server
$RM -f $MASTER_MYDDIR/log.*
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index 809d9d9d168..cec3b4a3225 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -199,6 +199,7 @@ our $opt_client_ddd;
our $opt_manual_gdb;
our $opt_manual_ddd;
our $opt_manual_debug;
+our $opt_mtr_build_thread=0;
our $opt_debugger;
our $opt_client_debugger;
@@ -213,6 +214,11 @@ our $clusters;
our $instance_manager;
+our $opt_master_myport;
+our $opt_slave_myport;
+our $im_port;
+our $im_mysqld1_port;
+our $im_mysqld2_port;
our $opt_ndbcluster_port;
our $opt_ndbconnectstring;
our $opt_ndbcluster_port_slave;
@@ -313,6 +319,7 @@ our %mysqld_variables;
sub main ();
sub initial_setup ();
sub command_line_setup ();
+sub set_mtr_build_thread_ports($);
sub datadir_setup ();
sub executable_setup ();
sub environment_setup ();
@@ -455,45 +462,17 @@ sub command_line_setup () {
$opt_suite= "main"; # Special default suite
my $opt_comment;
- my $opt_master_myport= 9306;
- my $opt_slave_myport= 9308;
+ $opt_master_myport= 9306;
+ $opt_slave_myport= 9308;
$opt_ndbcluster_port= 9310;
$opt_ndbcluster_port_slave= 9311;
- my $im_port= 9312;
- my $im_mysqld1_port= 9313;
- my $im_mysqld2_port= 9314;
+ $im_port= 9312;
+ $im_mysqld1_port= 9313;
+ $im_mysqld2_port= 9314;
- #
- # To make it easier for different devs to work on the same host,
- # an environment variable can be used to control all ports. A small
- # number is to be used, 0 - 16 or similar.
- #
- # Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x
- # versions of this script, else a 4.0 test run might conflict with a
- # 5.1 test run, even if different MTR_BUILD_THREAD is used. This means
- # all port numbers might not be used in this version of the script.
- #
- # Also note the limiteation of ports we are allowed to hand out. This
- # differs between operating systems and configuration, see
- # http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html
- # But a fairly safe range seems to be 5001 - 32767
if ( $ENV{'MTR_BUILD_THREAD'} )
{
- # Up to two masters, up to three slaves
- $opt_master_myport= $ENV{'MTR_BUILD_THREAD'} * 10 + 10000; # and 1
- $opt_slave_myport= $opt_master_myport + 2; # and 3 4
- $opt_ndbcluster_port= $opt_master_myport + 5;
- $opt_ndbcluster_port_slave= $opt_master_myport + 6;
- $im_port= $opt_master_myport + 7;
- $im_mysqld1_port= $opt_master_myport + 8;
- $im_mysqld2_port= $opt_master_myport + 9;
- }
-
- if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
- {
- mtr_error("MTR_BUILD_THREAD number results in a port",
- "outside 5001 - 32767",
- "($opt_master_myport - $opt_master_myport + 10)");
+ set_mtr_build_thread_ports($ENV{'MTR_BUILD_THREAD'});
}
# This is needed for test log evaluation in "gen-build-status-page"
@@ -545,6 +524,7 @@ sub command_line_setup () {
'im-port=i' => \$im_port, # Instance Manager port.
'im-mysqld1-port=i' => \$im_mysqld1_port, # Port of mysqld, controlled by IM
'im-mysqld2-port=i' => \$im_mysqld2_port, # Port of mysqld, controlled by IM
+ 'mtr-build-thread=i' => \$opt_mtr_build_thread,
# Test case authoring
'record' => \$opt_record,
@@ -627,6 +607,15 @@ sub command_line_setup () {
$glob_scriptname= basename($0);
+ if ($opt_mtr_build_thread != 0)
+ {
+ set_mtr_build_thread_ports($opt_mtr_build_thread)
+ }
+ elsif ($ENV{'MTR_BUILD_THREAD'})
+ {
+ $opt_mtr_build_thread= $ENV{'MTR_BUILD_THREAD'};
+ }
+
# We require that we are in the "mysql-test" directory
# to run mysql-test-run
if (! -f $glob_scriptname)
@@ -775,7 +764,7 @@ sub command_line_setup () {
{
mtr_report("Using tmpfs in $fs");
$opt_mem= "$fs/var";
- $opt_mem .= $ENV{'MTR_BUILD_THREAD'} if $ENV{'MTR_BUILD_THREAD'};
+ $opt_mem .= $opt_mtr_build_thread if $opt_mtr_build_thread;
last;
}
}
@@ -1230,6 +1219,43 @@ sub command_line_setup () {
$path_snapshot= "$opt_tmpdir/snapshot_$opt_master_myport/";
}
+#
+# To make it easier for different devs to work on the same host,
+# an environment variable can be used to control all ports. A small
+# number is to be used, 0 - 16 or similar.
+#
+# Note the MASTER_MYPORT has to be set the same in all 4.x and 5.x
+# versions of this script, else a 4.0 test run might conflict with a
+# 5.1 test run, even if different MTR_BUILD_THREAD is used. This means
+# all port numbers might not be used in this version of the script.
+#
+# Also note the limitation of ports we are allowed to hand out. This
+# differs between operating systems and configuration, see
+# http://www.ncftp.com/ncftpd/doc/misc/ephemeral_ports.html
+# But a fairly safe range seems to be 5001 - 32767
+#
+
+sub set_mtr_build_thread_ports() {
+ my $mtr_build_thread= shift;
+
+ # Up to two masters, up to three slaves
+ $opt_master_myport= $mtr_build_thread * 10 + 10000; # and 1
+ $opt_slave_myport= $opt_master_myport + 2; # and 3 4
+ $opt_ndbcluster_port= $opt_master_myport + 5;
+ $opt_ndbcluster_port_slave= $opt_master_myport + 6;
+ $im_port= $opt_master_myport + 7;
+ $im_mysqld1_port= $opt_master_myport + 8;
+ $im_mysqld2_port= $opt_master_myport + 9;
+
+ if ( $opt_master_myport < 5001 or $opt_master_myport + 10 >= 32767 )
+ {
+ mtr_error("MTR_BUILD_THREAD number results in a port",
+ "outside 5001 - 32767",
+ "($opt_master_myport - $opt_master_myport + 10)");
+ }
+}
+
+
sub datadir_setup () {
# Make a list of all data_dirs
@@ -1648,7 +1674,7 @@ sub environment_setup () {
$ENV{'IM_PATH_SOCK'}= $instance_manager->{path_sock};
$ENV{'IM_USERNAME'}= $instance_manager->{admin_login};
$ENV{'IM_PASSWORD'}= $instance_manager->{admin_password};
- $ENV{MTR_BUILD_THREAD}= 0 unless $ENV{MTR_BUILD_THREAD}; # Set if not set
+ $ENV{MTR_BUILD_THREAD}= $opt_mtr_build_thread;
$ENV{'EXE_MYSQL'}= $exe_mysql;
@@ -2048,7 +2074,7 @@ sub cleanup_stale_files () {
}
# Remove old log files
- foreach my $name (glob("r/*.reject r/*.progress r/*.log r/*.warnings"))
+ foreach my $name (glob("r/*.progress r/*.log r/*.warnings"))
{
unlink($name);
}
@@ -3000,14 +3026,14 @@ sub find_testcase_skipped_reason($)
{
my ($tinfo)= @_;
- # Open mysqltest.log
+ # Open mysqltest-time
my $F= IO::File->new($path_timefile) or
mtr_error("can't open file \"$path_timefile\": $!");
my $reason;
while ( my $line= <$F> )
{
- # Look for "reason: <reason fo skiping test>"
+ # Look for "reason: <reason for skipping test>"
if ( $line =~ /reason: (.*)/ )
{
$reason= $1;
@@ -4762,6 +4788,8 @@ Options that specify ports
slave_port=PORT Specify the port number used by the first slave
ndbcluster-port=PORT Specify the port number used by cluster
ndbcluster-port-slave=PORT Specify the port number used by slave cluster
+ mtr-build-thread=# Specify unique collection of ports. Can also be set by
+ setting the environment variable MTR_BUILD_THREAD.
Options for test case authoring
diff --git a/mysql-test/t/wait_for_socket.sh b/mysql-test/t/wait_for_socket.sh
index 3b900fa2208..b6526b7d19c 100755
--- a/mysql-test/t/wait_for_socket.sh
+++ b/mysql-test/t/wait_for_socket.sh
@@ -33,7 +33,7 @@ fi
###########################################################################
-client_args="--silent --socket=$socket_path "
+client_args="--silent --socket=$socket_path --connect_timeout=1 "
[ -n "$username" ] && client_args="$client_args --user=$username "
[ -n "$password" ] && client_args="$client_args --password=$password "
diff --git a/sql-common/client.c b/sql-common/client.c
index 09cece40c94..4ca62e0649a 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -748,6 +748,29 @@ void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate)
DBUG_VOID_RETURN;
}
+
+static void set_mysql_extended_error(MYSQL *mysql, int errcode,
+ const char *sqlstate,
+ const char *format, ...)
+{
+ NET *net;
+ va_list args;
+ DBUG_ENTER("set_mysql_extended_error");
+ DBUG_PRINT("enter", ("error :%d '%s'", errcode, format));
+ DBUG_ASSERT(mysql != 0);
+
+ net= &mysql->net;
+ net->last_errno= errcode;
+ va_start(args, format);
+ my_vsnprintf(net->last_error, sizeof(net->last_error)-1,
+ format, args);
+ va_end(args);
+ strmov(net->sqlstate, sqlstate);
+
+ DBUG_VOID_RETURN;
+}
+
+
/*
Flush result set sent from server
*/
@@ -845,6 +868,7 @@ static int check_license(MYSQL *mysql)
void end_server(MYSQL *mysql)
{
+ int save_errno= errno;
DBUG_ENTER("end_server");
if (mysql->net.vio != 0)
{
@@ -857,6 +881,7 @@ void end_server(MYSQL *mysql)
}
net_end(&mysql->net);
free_old_query(mysql);
+ errno= save_errno;
DBUG_VOID_RETURN;
}
@@ -2026,7 +2051,10 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
if (mysql->options.connect_timeout &&
vio_poll_read(net->vio, mysql->options.connect_timeout))
{
- set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate);
+ set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
+ ER(CR_SERVER_LOST_EXTENDED),
+ "waiting for initial communication packet",
+ errno);
goto error;
}
@@ -2035,8 +2063,14 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
*/
if ((pkt_length=cli_safe_read(mysql)) == packet_error)
+ {
+ if (mysql->net.last_errno == CR_SERVER_LOST)
+ set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
+ ER(CR_SERVER_LOST_EXTENDED),
+ "reading initial communication packet",
+ errno);
goto error;
-
+ }
/* Check if version of protocol matches current one */
mysql->protocol_version= net->read_pos[0];
@@ -2170,7 +2204,10 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
*/
if (my_net_write(net,buff,(uint) (end-buff)) || net_flush(net))
{
- set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate);
+ set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
+ ER(CR_SERVER_LOST_EXTENDED),
+ "sending connection information to server",
+ errno);
goto error;
}
@@ -2249,7 +2286,10 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
/* Write authentication package */
if (my_net_write(net,buff,(ulong) (end-buff)) || net_flush(net))
{
- set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate);
+ set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
+ ER(CR_SERVER_LOST_EXTENDED),
+ "sending authentication information",
+ errno);
goto error;
}
@@ -2259,7 +2299,14 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
*/
if ((pkt_length=cli_safe_read(mysql)) == packet_error)
+ {
+ if (mysql->net.last_errno == CR_SERVER_LOST)
+ set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
+ ER(CR_SERVER_LOST_EXTENDED),
+ "reading authorization packet",
+ errno);
goto error;
+ }
if (pkt_length == 1 && net->read_pos[0] == 254 &&
mysql->server_capabilities & CLIENT_SECURE_CONNECTION)
@@ -2271,12 +2318,22 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
scramble_323(buff, mysql->scramble, passwd);
if (my_net_write(net, buff, SCRAMBLE_LENGTH_323 + 1) || net_flush(net))
{
- set_mysql_error(mysql, CR_SERVER_LOST, unknown_sqlstate);
+ set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
+ ER(CR_SERVER_LOST_EXTENDED),
+ "sending password information",
+ errno);
goto error;
}
/* Read what server thinks about out new auth message report */
if (cli_safe_read(mysql) == packet_error)
+ {
+ if (mysql->net.last_errno == CR_SERVER_LOST)
+ set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
+ ER(CR_SERVER_LOST_EXTENDED),
+ "reading final connect information",
+ errno);
goto error;
+ }
}
if (client_flag & CLIENT_COMPRESS) /* We will use compression */
@@ -2287,8 +2344,15 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
goto error;
#endif
- if (db && mysql_select_db(mysql,db))
+ if (db && mysql_select_db(mysql, db))
+ {
+ if (mysql->net.last_errno == CR_SERVER_LOST)
+ set_mysql_extended_error(mysql, CR_SERVER_LOST, unknown_sqlstate,
+ ER(CR_SERVER_LOST_EXTENDED),
+ "Setting intital database",
+ errno);
goto error;
+ }
if (mysql->options.init_commands)
{