Added some missing DBUG_RETURN

Fixed that --valgrind works again with mysql-test-run.sh
Extended error messages when loosing connection during mysql_real_connect()
parent 306b871d
......@@ -2203,7 +2203,7 @@ static void dump_table(char *table, char *db)
The "table" could be a view. If so, we don't do anything here.
*/
if (strcmp (table_type, "VIEW") == 0)
return;
DBUG_VOID_RETURN;
/* Check --no-data flag */
if (opt_no_data)
......@@ -2869,7 +2869,7 @@ static int dump_all_tables_in_db(char *database)
*afterdot++= '.';
if (init_dumping(database, init_dumping_tables))
return 1;
DBUG_RETURN(1);
if (opt_xml)
print_xml_tag(md_result_file, "", "\n", "database", "name=", database, NullS);
if (lock_tables)
......@@ -2923,7 +2923,7 @@ static int dump_all_tables_in_db(char *database)
fprintf(md_result_file,"\n--\n-- Flush Grant Tables \n--\n");
fprintf(md_result_file,"\n/*! FLUSH PRIVILEGES */;\n");
}
return 0;
DBUG_RETURN(0);
} /* dump_all_tables_in_db */
......
......@@ -97,6 +97,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. */
......@@ -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
......
......@@ -2047,7 +2047,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);
}
......@@ -2995,14 +2995,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;
......
......@@ -123,7 +123,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!
......@@ -2087,7 +2087,7 @@ then
# Remove files that can cause problems
$RM -rf $MYSQL_TEST_DIR/var/ndbcluster
$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.*
......
......@@ -753,6 +753,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
*/
......@@ -850,6 +873,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)
{
......@@ -862,6 +886,7 @@ void end_server(MYSQL *mysql)
}
net_end(&mysql->net);
free_old_query(mysql);
errno= save_errno;
DBUG_VOID_RETURN;
}
......@@ -2031,7 +2056,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;
}
......@@ -2040,8 +2068,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];
......@@ -2175,7 +2209,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;
}
......@@ -2254,7 +2291,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;
}
......@@ -2264,7 +2304,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)
......@@ -2276,12 +2323,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 */
......@@ -2292,8 +2349,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)
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment