Commit fc06433a authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Removed copying of parameters as this leads to memory leaks in embedded server.

Fixed 'not initialized' memory error.
parent 7d41cd44
......@@ -19,7 +19,7 @@ TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work
# Program Definitions
#--
PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11
PATH=/bin:/usr/bin:/usr/local/bin:/usr/bsd:/usr/X11R6/bin:/usr/openwin/bin:/usr/bin/X11:$PATH
MASTER_40_ARGS="--rpl-recovery-rank=1 --init-rpl-role=master"
# Standard functions
......@@ -47,13 +47,17 @@ which ()
sleep_until_file_deleted ()
{
file=$1
pid=$1;
file=$2
loop=$SLEEP_TIME_FOR_DELETE
while (test $loop -gt 0)
do
if [ ! -r $file ]
then
sleep $SLEEP_TIME_AFTER_RESTART
if test $pid != "0"
then
wait_for_pid $pid
fi
return
fi
sleep 1
......@@ -79,6 +83,13 @@ sleep_until_file_created ()
exit 1;
}
# For the future
wait_for_pid()
{
pid=$1
}
# No paths below as we can't be sure where the program is!
SED=sed
......@@ -152,6 +163,7 @@ TOT_TEST=0
USERT=0
SYST=0
REALT=0
FAST_START=""
MYSQL_TMP_DIR=$MYSQL_TEST_DIR/var/tmp
SLAVE_LOAD_TMPDIR=../../var/tmp #needs to be same length to test logging
RES_SPACE=" "
......@@ -314,7 +326,7 @@ while test $# -gt 0; do
VALGRIND="valgrind --alignment=8 --leak-check=yes"
EXTRA_MASTER_MYSQLD_OPT="$EXTRA_MASTER_MYSQLD_OPT --skip-safemalloc"
EXTRA_SLAVE_MYSQLD_OPT="$EXTRA_SLAVE_MYSQLD_OPT --skip-safemalloc"
SLEEP_TIME_AFTER_RESTART=120
#SLEEP_TIME_AFTER_RESTART=120
SLEEP_TIME_FOR_DELETE=120
;;
--valgrind-options=*)
......@@ -335,6 +347,9 @@ while test $# -gt 0; do
--debug=d:t:i:O,$MYSQL_TEST_DIR/var/log/slave.trace"
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT --debug"
;;
--fast)
FAST_START=1
;;
-- ) shift; break ;;
--* ) $ECHO "Unrecognized option: $1"; exit 1 ;;
* ) break ;;
......@@ -731,12 +746,19 @@ EOF
manager_term()
{
ident=$1
pid=$1
ident=$2
shift
if [ $USE_MANAGER = 0 ] ; then
$MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock -O \
connect_timeout=5 -O shutdown_timeout=20 shutdown >> $MYSQL_MANAGER_LOG 2>&1
return
$MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock --connect_timeout=5 --shutdown_timeout=20 shutdown >> $MYSQL_MANAGER_LOG 2>&1
res=$?
# Some systems require an extra connect
$MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock --connect_timeout=1 ping >> $MYSQL_MANAGER_LOG 2>&1
if test $res = 0
then
wait_for_pid $pid
fi
return $res
fi
$MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
--password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF
......@@ -978,12 +1000,13 @@ stop_slave ()
fi
if [ x$this_slave_running = x1 ]
then
manager_term $slave_ident
pid=`$CAT $slave_pid`
manager_term $pid $slave_ident
if [ $? != 0 ] && [ -f $slave_pid ]
then # try harder!
$ECHO "slave not cooperating with mysqladmin, will try manual kill"
kill `$CAT $slave_pid`
sleep_until_file_deleted $slave_pid
kill $pid
sleep_until_file_deleted $pid $slave_pid
if [ -f $slave_pid ] ; then
$ECHO "slave refused to die. Sending SIGKILL"
kill -9 `$CAT $slave_pid`
......@@ -1002,12 +1025,13 @@ stop_master ()
{
if [ x$MASTER_RUNNING = x1 ]
then
manager_term master
pid=`$CAT $MASTER_MYPID`
manager_term $pid master
if [ $? != 0 ] && [ -f $MASTER_MYPID ]
then # try harder!
$ECHO "master not cooperating with mysqladmin, will try manual kill"
kill `$CAT $MASTER_MYPID`
sleep_until_file_deleted $MASTER_MYPID
kill $pid
sleep_until_file_deleted $pid $MASTER_MYPID
if [ -f $MASTER_MYPID ] ; then
$ECHO "master refused to die. Sending SIGKILL"
kill -9 `$CAT $MASTER_MYPID`
......@@ -1228,14 +1252,19 @@ run_testcase ()
if [ -z "$USE_RUNNING_SERVER" ]
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=$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
if [ -z "$FAST_START" ]
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=$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 0 $MASTER_MYPID
sleep_until_file_deleted 0 $SLAVE_MYPID
else
rm $MASTER_MYPID $SLAVE_MYPID
fi
# Kill any running managers
if [ -f "$MANAGER_PID_FILE" ]
......
drop table if exists t1;
drop table if exists t1,t2;
create table t1 (
col1 int not null auto_increment primary key,
col2 varchar(30) not null,
......
......@@ -2,7 +2,7 @@
# Test of alter table
#
drop table if exists t1;
drop table if exists t1,t2;
create table t1 (
col1 int not null auto_increment primary key,
col2 varchar(30) not null,
......
......@@ -1491,12 +1491,14 @@ void Field_medium::sql_type(String &res) const
void Field_long::store(const char *from,uint len)
{
char *end;
while (len && isspace(*from))
{
len--; from++;
}
long tmp;
String tmp_str(from,len);
from= tmp_str.c_ptr(); // Add end null if needed
errno=0;
if (unsigned_flag)
{
......@@ -1506,11 +1508,13 @@ void Field_long::store(const char *from,uint len)
errno=ERANGE;
}
else
tmp=(long) strtoul(tmp_str.c_ptr(),NULL,10);
tmp=(long) strtoul(from, &end, 10);
}
else
tmp=strtol(tmp_str.c_ptr(),NULL,10);
if (errno || current_thd->count_cuted_fields && !test_if_int(from,len))
tmp=strtol(from, &end, 10);
if (errno ||
(from+len != end && current_thd->count_cuted_fields &&
!test_if_int(from,len)))
current_thd->cuted_fields++;
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
......@@ -1719,12 +1723,14 @@ void Field_long::sql_type(String &res) const
void Field_longlong::store(const char *from,uint len)
{
char *end;
while (len && isspace(*from))
{ // For easy error check
len--; from++;
}
longlong tmp;
String tmp_str(from,len);
from= tmp_str.c_ptr(); // Add end null if needed
errno=0;
if (unsigned_flag)
{
......@@ -1734,12 +1740,14 @@ void Field_longlong::store(const char *from,uint len)
errno=ERANGE;
}
else
tmp=(longlong) strtoull(tmp_str.c_ptr(),NULL,10);
tmp=(longlong) strtoull(from, &end, 10);
}
else
tmp=strtoll(tmp_str.c_ptr(),NULL,10);
if (errno || current_thd->count_cuted_fields && !test_if_int(from,len))
current_thd->cuted_fields++;
tmp=strtoll(from, &end, 10);
if (errno ||
(from+len != end && current_thd->count_cuted_fields &&
!test_if_int(from,len)))
current_thd->cuted_fields++;
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
{
......
......@@ -674,36 +674,6 @@ innobase_init(void)
/* Set InnoDB initialization parameters according to the values
read from MySQL .cnf file */
/* --------------------------------------------------*/
/* Make copies of all string-valued parameters, because after
C# calls server_init(), it may move the parameter strings around */
if (innobase_data_home_dir) {
innobase_data_home_dir = my_strdup(
innobase_data_home_dir,
MYF(MY_WME));
}
if (innobase_data_file_path) {
innobase_data_file_path = my_strdup(
innobase_data_file_path,
MYF(MY_WME));
}
if (innobase_log_group_home_dir) {
innobase_log_group_home_dir = my_strdup(
innobase_log_group_home_dir,
MYF(MY_WME));
}
if (innobase_log_arch_dir) {
innobase_log_arch_dir = my_strdup(
innobase_log_arch_dir,
MYF(MY_WME));
}
if (innobase_unix_file_flush_method) {
innobase_unix_file_flush_method = my_strdup(
innobase_unix_file_flush_method,
MYF(MY_WME));
}
/*--------------- Data files -------------------------*/
/* The default dir for data files is the datadir of MySQL */
......
......@@ -1053,40 +1053,44 @@ bool MYSQL_LOG::write(Log_event* event_info)
No check for auto events flag here - this write method should
never be called if auto-events are enabled
*/
if (thd && thd->last_insert_id_used)
if (thd)
{
Intvar_log_event e(thd,(uchar)LAST_INSERT_ID_EVENT,thd->last_insert_id);
e.set_log_pos(this);
if (thd->server_id)
e.server_id = thd->server_id;
if (e.write(file))
goto err;
}
if (thd && thd->insert_id_used)
{
Intvar_log_event e(thd,(uchar)INSERT_ID_EVENT,thd->last_insert_id);
e.set_log_pos(this);
if (thd->server_id)
e.server_id = thd->server_id;
if (e.write(file))
goto err;
}
if (thd && thd->rand_used)
{
Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
e.set_log_pos(this);
if (e.write(file))
goto err;
}
if (thd && thd->variables.convert_set)
{
char buf[1024] = "SET CHARACTER SET ";
char* p = strend(buf);
p = strmov(p, thd->variables.convert_set->name);
Query_log_event e(thd, buf, (ulong)(p - buf), 0);
e.set_log_pos(this);
if (e.write(file))
goto err;
if (thd->last_insert_id_used)
{
Intvar_log_event e(thd,(uchar) LAST_INSERT_ID_EVENT,
thd->last_insert_id);
e.set_log_pos(this);
if (thd->server_id)
e.server_id = thd->server_id;
if (e.write(file))
goto err;
}
if (thd->insert_id_used)
{
Intvar_log_event e(thd,(uchar) INSERT_ID_EVENT,thd->last_insert_id);
e.set_log_pos(this);
if (thd->server_id)
e.server_id = thd->server_id;
if (e.write(file))
goto err;
}
if (thd->rand_used)
{
Rand_log_event e(thd,thd->rand_saved_seed1,thd->rand_saved_seed2);
e.set_log_pos(this);
if (e.write(file))
goto err;
}
if (thd->variables.convert_set)
{
char buf[256], *p;
p= strmov(strmov(buf, "SET CHARACTER SET "),
thd->variables.convert_set->name);
Query_log_event e(thd, buf, (ulong) (p - buf), 0);
e.set_log_pos(this);
if (e.write(file))
goto err;
}
}
event_info->set_log_pos(this);
if (event_info->write(file) ||
......
......@@ -689,6 +689,7 @@ extern String empty_string;
extern SHOW_VAR init_vars[],status_vars[], internal_vars[];
extern struct system_variables global_system_variables;
extern struct system_variables max_system_variables;
extern struct rand_struct sql_rand;
/* optional things, have_* variables */
......
......@@ -32,6 +32,7 @@
#include <nisam.h>
#include <thr_alarm.h>
#include <ft_global.h>
#include <assert.h>
#ifndef DBUG_OFF
#define ONE_THREAD
......@@ -2091,6 +2092,7 @@ int main(int argc, char **argv)
(void) grant_init((THD*) 0);
init_max_user_conn();
init_update_queries();
DBUG_ASSERT(current_thd == 0);
#ifdef HAVE_DLOPEN
if (!opt_noacl)
......@@ -2099,6 +2101,7 @@ int main(int argc, char **argv)
/* init_slave() must be called after the thread keys are created */
init_slave();
DBUG_ASSERT(current_thd == 0);
if (opt_bin_log && !server_id)
{
server_id= !master_host ? 1 : 2;
......
......@@ -37,7 +37,6 @@
#include <mysys_err.h>
#include <assert.h>
extern struct rand_struct sql_rand;
/*****************************************************************************
** Instansiate templates
......@@ -159,7 +158,7 @@ THD::THD():user_time(0),fatal_error(0),last_insert_id_used(0),
pthread_mutex_lock(&LOCK_thread_count);
ulong tmp=(ulong) (rnd(&sql_rand) * 3000000);
pthread_mutex_unlock(&LOCK_thread_count);
randominit(&rand, tmp + (ulong) start_time, tmp + (ulong) thread_id);
randominit(&rand, tmp + (ulong) &rand, tmp + (ulong) ::query_id);
}
}
......
......@@ -202,6 +202,8 @@ void udf_init()
new_thd->version--; // Force close to free memory
close_thread_tables(new_thd);
delete new_thd;
/* Remember that we don't have a THD */
my_pthread_setspecific_ptr(THR_THD, 0);
DBUG_VOID_RETURN;
}
......
......@@ -103,6 +103,7 @@ function (const char *nptr,char **endptr,int base)
}
/* Check for a sign. */
negative= 0;
if (*s == '-')
{
negative = 1;
......@@ -110,11 +111,9 @@ function (const char *nptr,char **endptr,int base)
}
else if (*s == '+')
{
negative = 0;
++s;
}
else
negative = 0;
if (base == 16 && s[0] == '0' && toupper (s[1]) == 'X')
s += 2;
......
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