Commit 7a7cbc7d authored by unknown's avatar unknown

Merge oak.local:/home/kostja/mysql/mysql-4.0-root

into oak.local:/home/kostja/mysql/mysql-4.0-1274
parents 3688a5d8 eb97617e
......@@ -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
......
......@@ -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];
......
......@@ -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);
......
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;
......@@ -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;
--set-variable=query_cache_size=1355776
......@@ -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;
......@@ -22,5 +22,3 @@ start slave;
sleep 3;
--replace_result $MASTER_MYPORT MASTER_PORT
show slave status;
connection master;
reset master;
......@@ -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;
}
/****************************************************************************
......
......@@ -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 @@ my_bool my_thread_init(void)
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 */
......
......@@ -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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
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