summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <kostja@oak.local>2003-10-17 18:44:13 +0400
committerunknown <kostja@oak.local>2003-10-17 18:44:13 +0400
commit7a7cbc7db557cc8263622453fc8a52cd9f386647 (patch)
tree71ec5306ddcaf1a854ee277dbd6495edaa08aa3f
parent3688a5d81a7596c274c8c2c98b0b1890482ea552 (diff)
parenteb97617eecc7c41b7dd2356f87e6b985f24be530 (diff)
downloadmariadb-git-7a7cbc7db557cc8263622453fc8a52cd9f386647.tar.gz
Merge oak.local:/home/kostja/mysql/mysql-4.0-root
into oak.local:/home/kostja/mysql/mysql-4.0-1274
-rw-r--r--configure.in2
-rw-r--r--include/my_pthread.h1
-rw-r--r--libmysqld/lib_sql.cc5
-rw-r--r--mysql-test/r/query_cache.result43
-rw-r--r--mysql-test/r/rpl_trunc_binlog.result1
-rw-r--r--mysql-test/t/query_cache-master.opt1
-rw-r--r--mysql-test/t/query_cache.test55
-rw-r--r--mysql-test/t/rpl_trunc_binlog.test2
-rw-r--r--mysys/charset.c66
-rw-r--r--mysys/my_thr_init.c9
-rw-r--r--scripts/mysql_install_db.sh2
-rw-r--r--sql/slave.cc2
-rw-r--r--sql/sql_cache.cc26
-rw-r--r--sql/sql_test.cc4
14 files changed, 178 insertions, 41 deletions
diff --git a/configure.in b/configure.in
index f085d365ed2..8ce3a9aea67 100644
--- a/configure.in
+++ b/configure.in
@@ -733,7 +733,7 @@ AC_CHECK_HEADERS(fcntl.h float.h floatingpoint.h ieeefp.h limits.h \
strings.h string.h synch.h sys/mman.h sys/socket.h netinet/in.h arpa/inet.h \
sys/timeb.h sys/types.h sys/un.h sys/vadvise.h sys/wait.h term.h \
unistd.h utime.h sys/utime.h termio.h termios.h sched.h crypt.h alloca.h \
- sys/ioctl.h)
+ sys/ioctl.h malloc.h sys/malloc.h)
#--------------------------------------------------------------------
# Check for system libraries. Adds the library to $LIBS
diff --git a/include/my_pthread.h b/include/my_pthread.h
index 4247b951d82..16a14ac5038 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -637,6 +637,7 @@ struct st_my_thread_var
long id;
int cmp_length;
int volatile abort;
+ my_bool init;
#ifndef DBUG_OFF
gptr dbug;
char name[THREAD_NAME_SIZE+1];
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 52ff08b8787..d33f384f81e 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -621,11 +621,6 @@ void STDCALL mysql_server_end()
my_free((char*) copy_arguments_ptr, MYF(MY_ALLOW_ZERO_PTR));
copy_arguments_ptr=0;
clean_up(0);
-#ifdef THREAD
- /* Don't call my_thread_end() if the application is using MY_INIT() */
- if (!org_my_init_done)
- my_thread_end();
-#endif
/* If library called my_init(), free memory allocated by it */
if (!org_my_init_done)
my_end(0);
diff --git a/mysql-test/r/query_cache.result b/mysql-test/r/query_cache.result
index 0b86c79afbf..83d2e439fbc 100644
--- a/mysql-test/r/query_cache.result
+++ b/mysql-test/r/query_cache.result
@@ -1,8 +1,9 @@
+set GLOBAL query_cache_size=1355776;
flush query cache;
flush query cache;
reset query cache;
flush status;
-drop table if exists t1,t2,t3;
+drop table if exists t1,t2,t3,t4,t11,t21;
drop database if exists mysqltest;
create table t1 (a int not null);
insert into t1 values (1),(2),(3);
@@ -640,3 +641,43 @@ Variable_name Value
Qcache_queries_in_cache 2
SET OPTION SQL_SELECT_LIMIT=DEFAULT;
drop table t1;
+flush query cache;
+reset query cache;
+flush status;
+set GLOBAL query_cache_size=1048576;
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+create table t2 (a text not null);
+create table t3 (a text not null);
+insert into t3 values("1111111111111111111111111111111111111111111111111111");
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+drop table t2;
+create table t2 (a int not null);
+insert into t2 values (1),(2),(3);
+create table t4 (a int not null);
+insert into t4 values (1),(2),(3);
+select * from t4;
+select * from t2;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+select * from t2;
+select * from t4;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+select * from t2;
+select * from t4;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+delete from t2 where a=1;
+flush query cache;
+select * from t3;
+delete from t4 where a=1;
+flush query cache;
+drop table t1,t2,t3,t4;
+set GLOBAL query_cache_size=0;
diff --git a/mysql-test/r/rpl_trunc_binlog.result b/mysql-test/r/rpl_trunc_binlog.result
index a006437207a..eb5dcf7c593 100644
--- a/mysql-test/r/rpl_trunc_binlog.result
+++ b/mysql-test/r/rpl_trunc_binlog.result
@@ -11,4 +11,3 @@ start slave;
show slave status;
Master_Host Master_User Master_Port Connect_retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_do_db Replicate_ignore_db Last_errno Last_error Skip_counter Exec_master_log_pos Relay_log_space
127.0.0.1 root MASTER_PORT 1 master-bin.002 4 slave-relay-bin.002 161 master-bin.001 Yes No 0 Rolling back unfinished transaction (no COMMIT or ROLLBACK) from relay log. Probably cause is that the master died while writing the transaction to it's binary log. 0 79 317
-reset master;
diff --git a/mysql-test/t/query_cache-master.opt b/mysql-test/t/query_cache-master.opt
deleted file mode 100644
index cfdce628e74..00000000000
--- a/mysql-test/t/query_cache-master.opt
+++ /dev/null
@@ -1 +0,0 @@
---set-variable=query_cache_size=1355776
diff --git a/mysql-test/t/query_cache.test b/mysql-test/t/query_cache.test
index 9e1c22ac642..2ab5504f84b 100644
--- a/mysql-test/t/query_cache.test
+++ b/mysql-test/t/query_cache.test
@@ -3,6 +3,7 @@
#
# Tests with query cache
#
+set GLOBAL query_cache_size=1355776;
# Reset query cache variables.
@@ -10,7 +11,7 @@ flush query cache; # This crashed in some versions
flush query cache; # This crashed in some versions
reset query cache;
flush status;
-drop table if exists t1,t2,t3;
+drop table if exists t1,t2,t3,t4,t11,t21;
drop database if exists mysqltest;
#
@@ -450,3 +451,55 @@ select * from t1;
show status like "Qcache_queries_in_cache";
SET OPTION SQL_SELECT_LIMIT=DEFAULT;
drop table t1;
+
+
+#
+# query cache crash on using same table twice in one query test
+#
+flush query cache;
+reset query cache;
+flush status;
+set GLOBAL query_cache_size=1048576;
+
+
+create table t1 (a int not null);
+insert into t1 values (1),(2),(3);
+create table t2 (a text not null);
+create table t3 (a text not null);
+insert into t3 values("1111111111111111111111111111111111111111111111111111");
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+insert into t2 select * from t3;
+insert into t3 select * from t2;
+drop table t2;
+create table t2 (a int not null);
+insert into t2 values (1),(2),(3);
+create table t4 (a int not null);
+insert into t4 values (1),(2),(3);
+
+disable_result_log;
+select * from t4;
+select * from t2;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+select * from t2;
+select * from t4;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+select * from t2;
+select * from t4;
+select * from t1 as tt, t1 as ttt where tt.a=1 and ttt.a=2;
+
+delete from t2 where a=1;
+flush query cache;
+select * from t3;
+enable_result_log;
+delete from t4 where a=1;
+flush query cache;
+
+drop table t1,t2,t3,t4;
+set GLOBAL query_cache_size=0;
diff --git a/mysql-test/t/rpl_trunc_binlog.test b/mysql-test/t/rpl_trunc_binlog.test
index 11ec0026560..2c34b7a442f 100644
--- a/mysql-test/t/rpl_trunc_binlog.test
+++ b/mysql-test/t/rpl_trunc_binlog.test
@@ -22,5 +22,3 @@ start slave;
sleep 3;
--replace_result $MASTER_MYPORT MASTER_PORT
show slave status;
-connection master;
-reset master;
diff --git a/mysys/charset.c b/mysys/charset.c
index 6a64730571c..ba6733185e0 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -453,20 +453,37 @@ static my_bool charset_in_string(const char *name, DYNAMIC_STRING *s)
static void charset_append(DYNAMIC_STRING *s, const char *name)
{
- if (!charset_in_string(name, s)) {
+ if (!charset_in_string(name, s))
+ {
dynstr_append(s, name);
dynstr_append(s, " ");
}
}
-/* Returns a dynamically-allocated string listing the character sets
- requested. The caller is responsible for freeing the memory. */
+/*
+ Returns a dynamically-allocated string listing the character sets
+ requested.
+
+ SYNOPSIS
+ list_charsets()
+ want_flags Flags for which character sets to return:
+ MY_COMPILED_SETS: Return incompiled charsets
+ MY_INDEX_SETS:
+ MY_LOADED_SETS:
+
+ NOTES
+ The caller is responsible for freeing the memory.
+
+
+ RETURN
+ A string with available character sets separated by space
+*/
char * list_charsets(myf want_flags)
{
DYNAMIC_STRING s;
- char *p;
+ char *result;
(void)init_available_charsets(MYF(0));
init_dynamic_string(&s, NullS, 256, 1024);
@@ -483,42 +500,45 @@ char * list_charsets(myf want_flags)
if (want_flags & MY_CONFIG_SETS)
{
- CS_ID **c;
+ CS_ID **charset;
char buf[FN_REFLEN];
MY_STAT status;
- if((c=available_charsets))
- for (; *c; ++c)
- {
- if (charset_in_string((*c)->name, &s))
- continue;
- get_charset_conf_name((*c)->number, buf);
- if (!my_stat(buf, &status, MYF(0)))
- continue; /* conf file doesn't exist */
- dynstr_append(&s, (*c)->name);
- dynstr_append(&s, " ");
- }
+ if ((charset=available_charsets))
+ {
+ for (; *charset; charset++)
+ {
+ if (charset_in_string((*charset)->name, &s))
+ continue;
+ get_charset_conf_name((*charset)->number, buf);
+ if (!my_stat(buf, &status, MYF(0)))
+ continue; /* conf file doesn't exist */
+ dynstr_append(&s, (*charset)->name);
+ dynstr_append(&s, " ");
+ }
+ }
}
if (want_flags & MY_INDEX_SETS)
{
- CS_ID **c;
- for (c = available_charsets; *c; ++c)
- charset_append(&s, (*c)->name);
+ CS_ID **charset;
+ for (charset = available_charsets; *charset; charset++)
+ charset_append(&s, (*charset)->name);
}
if (want_flags & MY_LOADED_SETS)
{
uint i;
for (i = 0; i < cs_info_table.elements; i++)
- charset_append(&s,
+ charset_append(&s,
dynamic_element(&cs_info_table, i, CHARSET_INFO *)->name);
}
- s.str[s.length - 1] = '\0'; /* chop trailing space */
- p = my_strdup(s.str, MYF(MY_WME));
+ if (s.length)
+ s.length--; /* Remove end space */
+ result= my_strdup_with_length(s.str, s.length, MYF(MY_WME));
dynstr_free(&s);
- return p;
+ return result;
}
/****************************************************************************
diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c
index 59466083b28..9f64e9dcb60 100644
--- a/mysys/my_thr_init.c
+++ b/mysys/my_thr_init.c
@@ -159,6 +159,7 @@ my_bool my_thread_init(void)
tmp->id= ++thread_id;
pthread_mutex_init(&tmp->mutex,MY_MUTEX_INIT_FAST);
pthread_cond_init(&tmp->suspend, NULL);
+ tmp->init= 1;
end:
#if !defined(__WIN__) || defined(USE_TLS) || ! defined(SAFE_MUTEX)
@@ -170,12 +171,14 @@ end:
void my_thread_end(void)
{
- struct st_my_thread_var *tmp=my_thread_var;
+ struct st_my_thread_var *tmp;
+ tmp= my_pthread_getspecific(struct st_my_thread_var*,THR_KEY_mysys);
+
#ifdef EXTRA_DEBUG_THREADS
fprintf(stderr,"my_thread_end(): tmp=%p,thread_id=%ld\n",
tmp,pthread_self());
#endif
- if (tmp)
+ if (tmp && tmp->init)
{
#if !defined(DBUG_OFF)
/* tmp->dbug is allocated inside DBUG library */
@@ -191,6 +194,8 @@ void my_thread_end(void)
pthread_mutex_destroy(&tmp->mutex);
#if (!defined(__WIN__) && !defined(OS2)) || defined(USE_TLS)
free(tmp);
+#else
+ tmp->init= 0;
#endif
}
/* The following free has to be done, even if my_thread_var() is 0 */
diff --git a/scripts/mysql_install_db.sh b/scripts/mysql_install_db.sh
index 5a6b11fb19b..ba95ff3b5b9 100644
--- a/scripts/mysql_install_db.sh
+++ b/scripts/mysql_install_db.sh
@@ -136,7 +136,7 @@ then
fi
fi
-if test "$ip_only" ="1"
+if test "$ip_only" = "1"
then
ip=`echo "$resolved" | awk '/ /{print $6}'`
hostname=$ip
diff --git a/sql/slave.cc b/sql/slave.cc
index 9c380408291..b679ac2f6b8 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -1337,7 +1337,7 @@ file '%s', errno %d)", fname, my_errno);
if (init_relay_log_pos(rli,NullS,BIN_LOG_HEADER_SIZE,0 /* no data lock */,
&msg))
{
- sql_print_error("Failed to open the relay log 'FIRST' (relay_log_pos 4");
+ sql_print_error("Failed to open the relay log 'FIRST' (relay_log_pos 4)");
goto err;
}
rli->master_log_name[0]= 0;
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 97ec6033ad6..5d525c7be4e 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -2666,11 +2666,33 @@ my_bool Query_cache::move_by_type(byte **border,
relink(block, new_block, next, prev, pnext, pprev);
if (queries_blocks == block)
queries_blocks = new_block;
+ Query_cache_block_table *beg_of_table_table= block->table(0),
+ *end_of_table_table= block->table(n_tables);
+ byte *beg_of_new_table_table= (byte*) new_block->table(0);
+
for (TABLE_COUNTER_TYPE j=0; j < n_tables; j++)
{
Query_cache_block_table *block_table = new_block->table(j);
- block_table->next->prev = block_table;
- block_table->prev->next = block_table;
+
+ // use aligment from begining of table if 'next' is in same block
+ if ((beg_of_table_table <= block_table->next) &&
+ (block_table->next < end_of_table_table))
+ ((Query_cache_block_table *)(beg_of_new_table_table +
+ (((byte*)block_table->next) -
+ ((byte*)beg_of_table_table))))->prev=
+ block_table;
+ else
+ block_table->next->prev= block_table;
+
+ // use aligment from begining of table if 'prev' is in same block
+ if ((beg_of_table_table <= block_table->prev) &&
+ (block_table->prev < end_of_table_table))
+ ((Query_cache_block_table *)(beg_of_new_table_table +
+ (((byte*)block_table->prev) -
+ ((byte*)beg_of_table_table))))->next=
+ block_table;
+ else
+ block_table->prev->next = block_table;
}
DBUG_PRINT("qcache", ("after circle tt"));
*border += len;
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 6498a52cc09..a217d40246f 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -22,7 +22,11 @@
#include "sql_select.h"
#include <hash.h>
#include <thr_alarm.h>
+#if defined(HAVE_MALLINFO) && defined(HAVE_MALLOC_H)
#include <malloc.h>
+#elif defined(HAVE_MALLINFO) && defined(HAVE_SYS_MALLOC_H)
+#include <sys/malloc.h>
+#endif
/* Intern key cache variables */
extern "C" pthread_mutex_t THR_LOCK_keycache;