Commit 315b8991 authored by unknown's avatar unknown

Portability fixes.

Changed mysql-test-run.sh to test for files to get shorter, more reliable timeouts.


Docs/manual.texi:
  Cleaned up SET PASSWORD stuff
client/mysqltest.c:
  Do more retrys
mysql-test/mysql-test-run.sh:
  Test for files to get shorter timeouts
mysql-test/r/query_cache.result:
  Portability fix
mysql-test/t/query_cache.test:
  Portability fix
sql/sql_cache.cc:
  Safety fix
parent f939a6b6
...@@ -13636,7 +13636,6 @@ connection between a MySQL server and a MySQL client. ...@@ -13636,7 +13636,6 @@ connection between a MySQL server and a MySQL client.
If you are using MySQL 4.0, you can also use internal openssl support. If you are using MySQL 4.0, you can also use internal openssl support.
@xref{Secure connections}. @xref{Secure connections}.
To make a MySQL system secure, you should strongly consider the To make a MySQL system secure, you should strongly consider the
following suggestions: following suggestions:
...@@ -13652,8 +13651,7 @@ this: ...@@ -13652,8 +13651,7 @@ this:
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('new_password') mysql> UPDATE user SET Password=PASSWORD('new_password') WHERE user='root';
WHERE user='root';
mysql> FLUSH PRIVILEGES; mysql> FLUSH PRIVILEGES;
@end example @end example
...@@ -15395,17 +15393,17 @@ password using the @code{PASSWORD()} function): ...@@ -15395,17 +15393,17 @@ password using the @code{PASSWORD()} function):
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> UPDATE user SET Password=PASSWORD('new_password') mysql> SET PASSWORD FOR root@@localhost=PASSWORD('new_password');
WHERE user='root';
mysql> FLUSH PRIVILEGES;
@end example @end example
You can, in MySQL Version 3.22 and above, use the @code{SET PASSWORD} If you know what you are doing, you can also directly manipulate the
statement: privilege tables:
@example @example
shell> mysql -u root mysql shell> mysql -u root mysql
mysql> SET PASSWORD FOR root=PASSWORD('new_password'); mysql> UPDATE user SET Password=PASSWORD('new_password')
WHERE user='root';
mysql> FLUSH PRIVILEGES;
@end example @end example
Another way to set the password is by using the @code{mysqladmin} command: Another way to set the password is by using the @code{mysqladmin} command:
...@@ -75,15 +75,19 @@ ...@@ -75,15 +75,19 @@
#define MAX_EXPECTED_ERRORS 10 #define MAX_EXPECTED_ERRORS 10
#define QUERY_SEND 1 #define QUERY_SEND 1
#define QUERY_REAP 2 #define QUERY_REAP 2
#define CON_RETRY_SLEEP 1 /* how long to sleep before trying to connect again*/
#define MAX_CON_TRIES 2 /* sometimes in a test the client starts before
* the server - to solve the problem, we try again
* after some sleep if connection fails the first
* time */
#ifndef MYSQL_MANAGER_PORT #ifndef MYSQL_MANAGER_PORT
#define MYSQL_MANAGER_PORT 23546 #define MYSQL_MANAGER_PORT 23546
#endif #endif
/*
Sometimes in a test the client starts before
the server - to solve the problem, we try again
after some sleep if connection fails the first
time
*/
#define CON_RETRY_SLEEP 2
#define MAX_CON_TRIES 5
enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD,
OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT}; OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT};
......
...@@ -43,6 +43,39 @@ which () ...@@ -43,6 +43,39 @@ which ()
} }
sleep_until_file_deleted ()
{
file=$1
loop=$SLEEP_TIME
while (test $loop -gt 0)
do
sleep 1
if [ ! -f $file ]
then
return
fi
loop=`expr $loop - 1`
done
}
sleep_until_file_exists ()
{
file=$1
loop=60 # Should be long enough enough for all cases
while (test $loop -gt 0)
do
sleep 1
if [ -f $file ]
then
return
fi
loop=`expr $loop - 1`
done
echo "ERROR: $file was not created in 60 seconds; Aborting"
exit 1;
}
# No paths below as we can't be sure where the program is! # No paths below as we can't be sure where the program is!
BASENAME=`which basename | head -1` BASENAME=`which basename | head -1`
...@@ -139,7 +172,7 @@ DO_GCOV="" ...@@ -139,7 +172,7 @@ DO_GCOV=""
DO_GDB="" DO_GDB=""
DO_DDD="" DO_DDD=""
DO_CLIENT_GDB="" DO_CLIENT_GDB=""
SLEEP_TIME=2 SLEEP_TIME=10
CHARACTER_SET=latin1 CHARACTER_SET=latin1
DBUSER="" DBUSER=""
START_WAIT_TIMEOUT=3 START_WAIT_TIMEOUT=3
...@@ -503,19 +536,17 @@ mysql_install_db () { ...@@ -503,19 +536,17 @@ mysql_install_db () {
for slave_num in 1 2 ; for slave_num in 1 2 ;
do do
rm -rf var/slave$slave_num-data/ $RM -rf var/slave$slave_num-data/
mkdir -p var/slave$slave_num-data/mysql mkdir -p var/slave$slave_num-data/mysql
mkdir -p var/slave$slave_num-data/test mkdir -p var/slave$slave_num-data/test
cp var/slave-data/mysql/* var/slave$slave_num-data/mysql cp var/slave-data/mysql/* var/slave$slave_num-data/mysql
done done
# Give mysqld some time to die.
sleep $SLEEP_TIME
return 0 return 0
} }
gprof_prepare () gprof_prepare ()
{ {
rm -rf $GPROF_DIR $RM -rf $GPROF_DIR
mkdir -p $GPROF_DIR mkdir -p $GPROF_DIR
} }
...@@ -575,7 +606,7 @@ start_manager() ...@@ -575,7 +606,7 @@ start_manager()
fi fi
fi fi
rm -f $MANAGER_PID_FILE $RM -f $MANAGER_PID_FILE
MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -u $MYSQL_MANAGER_USER \ MYSQL_MANAGER_PW=`$MYSQL_MANAGER_PWGEN -u $MYSQL_MANAGER_USER \
-o $MYSQL_MANAGER_PW_FILE` -o $MYSQL_MANAGER_PW_FILE`
$MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \ $MYSQL_MANAGER --log=$MYSQL_MANAGER_LOG --port=$MYSQL_MANAGER_PORT \
...@@ -653,7 +684,9 @@ start_master() ...@@ -653,7 +684,9 @@ start_master()
$RM -f $MASTER_MYDDIR/log.* $RM -f $MASTER_MYDDIR/log.*
# Remove stale binary logs # Remove stale binary logs
$RM -f $MYSQL_TEST_DIR/var/log/master-bin.* $RM -f $MYSQL_TEST_DIR/var/log/master-bin.*
#run master initialization shell script if one exists #run master initialization shell script if one exists
if [ -f "$master_init_script" ] ; if [ -f "$master_init_script" ] ;
then then
/bin/sh $master_init_script /bin/sh $master_init_script
...@@ -722,6 +755,7 @@ EOF ...@@ -722,6 +755,7 @@ EOF
else else
manager_launch master $MYSQLD $master_args manager_launch master $MYSQLD $master_args
fi fi
sleep_until_file_exists $MASTER_MYPID
MASTER_RUNNING=1 MASTER_RUNNING=1
} }
...@@ -813,9 +847,11 @@ start_slave() ...@@ -813,9 +847,11 @@ start_slave()
manager_launch $slave_ident $SLAVE_MYSQLD $slave_args manager_launch $slave_ident $SLAVE_MYSQLD $slave_args
fi fi
eval "SLAVE$1_RUNNING=1" eval "SLAVE$1_RUNNING=1"
sleep_until_file_exists $slave_pid
} }
mysql_start () { mysql_start ()
{
$ECHO "Starting MySQL daemon" $ECHO "Starting MySQL daemon"
start_master start_master
start_slave start_slave
...@@ -840,8 +876,8 @@ stop_slave () ...@@ -840,8 +876,8 @@ stop_slave ()
then # try harder! then # try harder!
$ECHO "slave not cooperating with mysqladmin, will try manual kill" $ECHO "slave not cooperating with mysqladmin, will try manual kill"
kill `$CAT $slave_pid` kill `$CAT $slave_pid`
sleep $SLEEP_TIME sleep_until_file_deleted $slave_pid
if [ -f $SLAVE_MYPID ] ; then if [ -f $slave_pid ] ; then
$ECHO "slave refused to die. Sending SIGKILL" $ECHO "slave refused to die. Sending SIGKILL"
kill -9 `$CAT $slave_pid` kill -9 `$CAT $slave_pid`
$RM -f $slave_pid $RM -f $slave_pid
...@@ -862,7 +898,7 @@ stop_master () ...@@ -862,7 +898,7 @@ stop_master ()
then # try harder! then # try harder!
$ECHO "master not cooperating with mysqladmin, will try manual kill" $ECHO "master not cooperating with mysqladmin, will try manual kill"
kill `$CAT $MASTER_MYPID` kill `$CAT $MASTER_MYPID`
sleep $SLEEP_TIME sleep_until_file_deleted $MASTER_MYPID
if [ -f $MASTER_MYPID ] ; then if [ -f $MASTER_MYPID ] ; then
$ECHO "master refused to die. Sending SIGKILL" $ECHO "master refused to die. Sending SIGKILL"
kill -9 `$CAT $MASTER_MYPID` kill -9 `$CAT $MASTER_MYPID`
...@@ -890,11 +926,10 @@ mysql_stop () ...@@ -890,11 +926,10 @@ mysql_stop ()
return 1 return 1
} }
mysql_restart () { mysql_restart ()
{
mysql_stop mysql_stop
mysql_start mysql_start
return 1 return 1
} }
...@@ -1073,7 +1108,6 @@ run_testcase () ...@@ -1073,7 +1108,6 @@ run_testcase ()
fi fi
} }
###################################################################### ######################################################################
# Main script starts here # Main script starts here
###################################################################### ######################################################################
...@@ -1083,16 +1117,38 @@ run_testcase () ...@@ -1083,16 +1117,38 @@ run_testcase ()
[ "$DO_GCOV" ] && gcov_prepare [ "$DO_GCOV" ] && gcov_prepare
[ "$DO_GPROF" ] && gprof_prepare [ "$DO_GPROF" ] && gprof_prepare
# Ensure that no old mysqld test servers are running
if [ -z "$USE_RUNNING_SERVER" ] if [ -z "$USE_RUNNING_SERVER" ]
then then
# Ensure that no old mysqld test servers are running
$MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --socket=$MASTER_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1 $MYSQLADMIN --no-defaults --socket=$SLAVE_MYSOCK -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --host=$hostname --port=$MASTER_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --host=$hostname --port=$SLAVE_MYPORT -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
$MYSQLADMIN --no-defaults --host=$hostname --port=`expr $SLAVE_MYPORT + 1` -u root -O connect_timeout=5 -O shutdown_timeout=20 shutdown > /dev/null 2>&1
sleep_until_file_deleted $MASTER_MYPID
sleep_until_file_deleted $SLAVE_MYPID
# Kill any running managers
if [ -f "$MANAGER_PID_FILE" ]
then
kill `cat $MANAGER_PID_FILE`
sleep 1
if [ -f "$MANAGER_PID_FILE" ]
then
kill -9 `cat $MANAGER_PID_FILE`
sleep 1
fi
fi
# Remove files that can cause problems
$RM -f $MYSQL_TEST_DIR/var/run/* $MYSQL_TEST_DIR/var/tmp/*
$ECHO "Installing Test Databases" $ECHO "Installing Test Databases"
mysql_install_db mysql_install_db
start_manager start_manager
#do not automagically start deamons if we are in gdb or running only one test
#case # Do not automagically start deamons if we are in gdb or running only one test
# case
if [ -z "$DO_GDB" ] && [ -z "$DO_DDD" ] if [ -z "$DO_GDB" ] && [ -z "$DO_DDD" ]
then then
mysql_start mysql_start
......
...@@ -291,10 +291,4 @@ show status like "Qcache_queries_in_cache"; ...@@ -291,10 +291,4 @@ show status like "Qcache_queries_in_cache";
Variable_name Value Variable_name Value
Qcache_queries_in_cache 2 Qcache_queries_in_cache 2
reset query cache; reset query cache;
show variables like "query_cache_size";
Variable_name Value
query_cache_size 1039700
show status like "Qcache_free_memory";
Variable_name Value
Qcache_free_memory 1039700
drop table t1; drop table t1;
...@@ -178,6 +178,9 @@ enable_result_log; ...@@ -178,6 +178,9 @@ enable_result_log;
show status like "Qcache_hits"; show status like "Qcache_hits";
show status like "Qcache_queries_in_cache"; show status like "Qcache_queries_in_cache";
reset query cache; reset query cache;
show variables like "query_cache_size";
show status like "Qcache_free_memory";
drop table t1; drop table t1;
# The following tests can't be done as the values differen on 32 and 64 bit
# machines :(
#show variables like "query_cache_size";
#show status like "Qcache_free_memory";
...@@ -2672,6 +2672,7 @@ uint Query_cache::filename_2_table_key (char *key, const char *path) ...@@ -2672,6 +2672,7 @@ uint Query_cache::filename_2_table_key (char *key, const char *path)
void Query_cache::wreck(uint line, const char *message) void Query_cache::wreck(uint line, const char *message)
{ {
THD *thd=current_thd;
DBUG_ENTER("Query_cache::wreck"); DBUG_ENTER("Query_cache::wreck");
query_cache_size = 0; query_cache_size = 0;
if (*message) if (*message)
...@@ -2679,7 +2680,8 @@ void Query_cache::wreck(uint line, const char *message) ...@@ -2679,7 +2680,8 @@ void Query_cache::wreck(uint line, const char *message)
DBUG_PRINT("warning", ("==================================")); DBUG_PRINT("warning", ("=================================="));
DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line)); DBUG_PRINT("warning", ("%5d QUERY CACHE WRECK => DISABLED",line));
DBUG_PRINT("warning", ("==================================")); DBUG_PRINT("warning", ("=================================="));
current_thd->killed = 1; if (thd)
thd->killed = 1;
bins_dump(); bins_dump();
cache_dump(); cache_dump();
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
......
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