summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-12-20 06:14:11 +0200
committerunknown <monty@hundin.mysql.fi>2001-12-20 06:14:11 +0200
commitc23e5a830cd9d7fe5a14e6e971fddd32cd0fad69 (patch)
tree6238391b82cf68076a5dea6dd2e3c8c5c27473cd
parent7a8ce131289d31e8541e3e4f9085aefd7257b81d (diff)
downloadmariadb-git-c23e5a830cd9d7fe5a14e6e971fddd32cd0fad69.tar.gz
Fix insert delated + query cache.
Fix pthread_mutex_trylock on HPUX (needed for query cache). include/my_pthread.h: Fixed mutex problem with pthread_mutex_trylock on HPUX. mysql-test/mysql-test-run.sh: Wait for .pid file instead of .sock, because .pid is created later. mysql-test/r/query_cache.result: Test insert delated + query cache mysql-test/t/query_cache.test: Test insert delated + query cache mysys/my_pthread.c: Fixed mutex problem with pthread_mutex_trylock on HPUX. sql/repl_failsafe.cc: Safety sql/sql_insert.cc: Fix insert delated + query cache
-rw-r--r--include/my_pthread.h2
-rw-r--r--mysql-test/mysql-test-run.sh10
-rw-r--r--mysql-test/r/query_cache.result31
-rw-r--r--mysql-test/t/query_cache.test20
-rw-r--r--mysys/my_pthread.c14
-rw-r--r--sql/repl_failsafe.cc10
-rw-r--r--sql/sql_insert.cc2
7 files changed, 80 insertions, 9 deletions
diff --git a/include/my_pthread.h b/include/my_pthread.h
index e6cd039c80e..4ca42339897 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -448,8 +448,10 @@ struct hostent *my_gethostbyname_r(const char *name,
#if defined(HPUX) && !defined(DONT_REMAP_PTHREAD_FUNCTIONS)
#define pthread_cond_timedwait(a,b,c) my_pthread_cond_timedwait((a),(b),(c))
+#define pthread_mutex_trylock(a) my_pthread_mutex_trylock((a))
int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
struct timespec *abstime);
+int my_pthread_mutex_trylock(pthread_mutex_t *mutex);
#endif
/* safe_mutex adds checking to mutex for easier debugging */
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index dbd7f9b8c92..627668f67b1 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -674,9 +674,9 @@ manager_term()
ident=$1
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 >/dev/null 2>&1
- return
+ $MYSQLADMIN --no-defaults -uroot --socket=$MYSQL_TMP_DIR/$ident.sock -O \
+ connect_timeout=5 -O shutdown_timeout=20 shutdown >/dev/null 2>&1
+ return
fi
$MYSQL_MANAGER_CLIENT $MANAGER_QUIET_OPT --user=$MYSQL_MANAGER_USER \
--password=$MYSQL_MANAGER_PW --port=$MYSQL_MANAGER_PORT <<EOF
@@ -774,7 +774,7 @@ EOF
else
manager_launch master $MYSQLD $master_args
fi
- sleep_until_file_exists $MASTER_MYSOCK $wait_for_master
+ sleep_until_file_exists $MASTER_MYPID $wait_for_master
wait_for_master=$SLEEP_TIME_FOR_SECOND_MASTER
MASTER_RUNNING=1
}
@@ -874,7 +874,7 @@ start_slave()
manager_launch $slave_ident $SLAVE_MYSQLD $slave_args
fi
eval "SLAVE$1_RUNNING=1"
- sleep_until_file_exists $slave_sock $wait_for_slave
+ sleep_until_file_exists $slave_pid $wait_for_slave
wait_for_slave=$SLEEP_TIME_FOR_SECOND_SLAVE
}
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index bae492b0b50..9ed7e44ba2a 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -376,3 +376,34 @@ show status like "Qcache_queries_in_cache";
Variable_name Value
Qcache_queries_in_cache 2
drop table t1;
+flush query cache;
+reset query cache;
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+select * from t1;
+a
+1
+2
+3
+select * from t1;
+a
+1
+2
+3
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+insert delayed into t1 values (4);
+select a from t1;
+a
+1
+2
+3
+4
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 1
+drop table t1;
+show status like "Qcache_queries_in_cache";
+Variable_name Value
+Qcache_queries_in_cache 0
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 5f67ea2b59a..b22814f2fd9 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -247,6 +247,7 @@ select * from foo.t1;
show status like "Qcache_queries_in_cache";
drop database foo;
show status like "Qcache_queries_in_cache";
+
#
# Charset convertion (cp1251_koi8 always present)
#
@@ -263,3 +264,22 @@ drop table t1;
# machines :(
#show variables like "query_cache_size";
#show status like "Qcache_free_memory";
+
+#
+# Test insert delayed
+#
+
+flush query cache;
+reset query cache;
+
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+select * from t1;
+select * from t1;
+show status like "Qcache_queries_in_cache";
+insert delayed into t1 values (4);
+--sleep 5 # Wait for insert delayed to be executed.
+select a from t1;
+show status like "Qcache_queries_in_cache";
+drop table t1;
+show status like "Qcache_queries_in_cache";
diff --git a/mysys/my_pthread.c b/mysys/my_pthread.c
index 161e4faaff6..37c18a32451 100644
--- a/mysys/my_pthread.c
+++ b/mysys/my_pthread.c
@@ -471,6 +471,8 @@ struct hostent *my_gethostbyname_r(const char *name,
this has to be added here.
*****************************************************************************/
+#ifdef HPUX
+
int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
struct timespec *abstime)
{
@@ -483,6 +485,18 @@ int my_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
}
+int my_pthread_mutex_trylock(pthread_mutex_t *mutex)
+{
+ int error=pthread_mutex_trylock(mutex);
+ if (error == 1) /* Safety if the lib is fixed */
+ return 0; /* Mutex was locked */
+ if (error == -1) /* Safety if the lib is fixed */
+ error=errno;
+ return error;
+}
+
+#endif
+
/* Some help functions */
int pthread_no_free(void *not_used __attribute__((unused)))
diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc
index 6b15bd92ac6..edb5c28ed99 100644
--- a/sql/repl_failsafe.cc
+++ b/sql/repl_failsafe.cc
@@ -191,10 +191,12 @@ void init_slave_list()
void end_slave_list()
{
- pthread_mutex_lock(&LOCK_slave_list);
- hash_free(&slave_list);
- pthread_mutex_unlock(&LOCK_slave_list);
- pthread_mutex_destroy(&LOCK_slave_list);
+ /* No protection by a mutex needed as we are only called at shutdown */
+ if (hash_inited(&slave_list))
+ {
+ hash_free(&slave_list);
+ pthread_mutex_destroy(&LOCK_slave_list);
+ }
}
static int find_target_pos(LEX_MASTER_INFO* mi, IO_CACHE* log, char* errmsg)
diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc
index 526bd86bb58..06a1818b50d 100644
--- a/sql/sql_insert.cc
+++ b/sql/sql_insert.cc
@@ -1227,6 +1227,7 @@ bool delayed_insert::handle_inserts(void)
sql_print_error("%s",thd.net.last_error);
goto err;
}
+ query_cache.invalidate(table);
if (thr_reschedule_write_lock(*thd.lock->locks))
{
/* This should never happen */
@@ -1251,6 +1252,7 @@ bool delayed_insert::handle_inserts(void)
sql_print_error("%s",thd.net.last_error);
goto err;
}
+ query_cache.invalidate(table);
pthread_mutex_lock(&mutex);
DBUG_RETURN(0);