Commit 1a4ac20b authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Fixed bug in FLUSH QUERY CACHE

Changed 'send_file_to_server' to use less stack (Fixed replication problem on OSF1).
parent 0048a58f
...@@ -19100,7 +19100,8 @@ queries that require MySQL to scan whole tables or you have ...@@ -19100,7 +19100,8 @@ queries that require MySQL to scan whole tables or you have
joins that don't use keys properly. joins that don't use keys properly.
@item @item
If @code{Threads_created} is big, you may want to increase the If @code{Threads_created} is big, you may want to increase the
@code{thread_cache_size} variable. @code{thread_cache_size} variable. The cache hit rate can be calculated
with @code{Threads_created}/@code{Connections}.
@item @item
If @code{Created_tmp_disk_tables} is big, you may want to increase the If @code{Created_tmp_disk_tables} is big, you may want to increase the
@code{tmp_table_size} variable to get the temporary tables memory based @code{tmp_table_size} variable to get the temporary tables memory based
...@@ -34021,8 +34022,8 @@ or ROW_FORMAT= @{ default | dynamic | fixed | compressed @} ...@@ -34021,8 +34022,8 @@ or ROW_FORMAT= @{ default | dynamic | fixed | compressed @}
or RAID_TYPE= @{1 | STRIPED | RAID0 @} RAID_CHUNKS=# RAID_CHUNKSIZE=# or RAID_TYPE= @{1 | STRIPED | RAID0 @} RAID_CHUNKS=# RAID_CHUNKSIZE=#
or UNION = (table_name,[table_name...]) or UNION = (table_name,[table_name...])
or INSERT_METHOD= @{NO | FIRST | LAST @} or INSERT_METHOD= @{NO | FIRST | LAST @}
or DATA DIRECTORY="directory" or DATA DIRECTORY="absolute path to directory"
or INDEX DIRECTORY="directory" or INDEX DIRECTORY="absolute path to directory"
select_statement: select_statement:
[IGNORE | REPLACE] SELECT ... (Some legal select statement) [IGNORE | REPLACE] SELECT ... (Some legal select statement)
...@@ -47812,6 +47813,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}. ...@@ -47812,6 +47813,8 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet @itemize @bullet
@item @item
Fixed stack overrun problem @code{LOAD DATA FROM MASTER} on OSF1.
@item
Fixed shutdown problem on HPUX. Fixed shutdown problem on HPUX.
@item @item
Added functions @code{des_encrypt()} and @code{des_decrypt()}. Added functions @code{des_encrypt()} and @code{des_decrypt()}.
...@@ -2208,56 +2208,59 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong length) ...@@ -2208,56 +2208,59 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong length)
static int static int
send_file_to_server(MYSQL *mysql, const char *filename) send_file_to_server(MYSQL *mysql, const char *filename)
{ {
int fd, readcount; int fd, readcount, result= -1;
char buf[IO_SIZE*15],*tmp_name; uint packet_length=MY_ALIGN(mysql->net.max_packet-16,IO_SIZE);
char *buf, tmp_name[FN_REFLEN];
DBUG_ENTER("send_file_to_server"); DBUG_ENTER("send_file_to_server");
fn_format(buf,filename,"","",4); /* Convert to client format */ if (!(buf=my_malloc(packet_length,MYF(0))))
if (!(tmp_name=my_strdup(buf,MYF(0))))
{ {
strmov(mysql->net.last_error, ER(mysql->net.last_errno=CR_OUT_OF_MEMORY)); strmov(mysql->net.last_error, ER(mysql->net.last_errno=CR_OUT_OF_MEMORY));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
fn_format(tmp_name,filename,"","",4); /* Convert to client format */
if ((fd = my_open(tmp_name,O_RDONLY, MYF(0))) < 0) if ((fd = my_open(tmp_name,O_RDONLY, MYF(0))) < 0)
{ {
my_net_write(&mysql->net,"",0); /* Server needs one packet */
net_flush(&mysql->net);
mysql->net.last_errno=EE_FILENOTFOUND; mysql->net.last_errno=EE_FILENOTFOUND;
sprintf(buf,EE(mysql->net.last_errno),tmp_name,errno); snprintf(mysql->net.last_error,sizeof(mysql->net.last_error)-1,
strmake(mysql->net.last_error,buf,sizeof(mysql->net.last_error)-1); EE(mysql->net.last_errno),tmp_name, errno);
my_net_write(&mysql->net,"",0); net_flush(&mysql->net); goto err;
my_free(tmp_name,MYF(0));
DBUG_RETURN(-1);
} }
while ((readcount = (int) my_read(fd,buf,sizeof(buf),MYF(0))) > 0) while ((readcount = (int) my_read(fd,(byte*) buf,packet_length,MYF(0))) > 0)
{ {
if (my_net_write(&mysql->net,buf,readcount)) if (my_net_write(&mysql->net,buf,readcount))
{ {
DBUG_PRINT("error",("Lost connection to MySQL server during LOAD DATA of local file"));
mysql->net.last_errno=CR_SERVER_LOST; mysql->net.last_errno=CR_SERVER_LOST;
strmov(mysql->net.last_error,ER(mysql->net.last_errno)); strmov(mysql->net.last_error,ER(mysql->net.last_errno));
DBUG_PRINT("error",("Lost connection to MySQL server during LOAD DATA of local file")); goto err;
(void) my_close(fd,MYF(0));
my_free(tmp_name,MYF(0));
DBUG_RETURN(-1);
} }
} }
(void) my_close(fd,MYF(0));
/* Send empty packet to mark end of file */ /* Send empty packet to mark end of file */
if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net)) if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net))
{ {
mysql->net.last_errno=CR_SERVER_LOST; mysql->net.last_errno=CR_SERVER_LOST;
sprintf(mysql->net.last_error,ER(mysql->net.last_errno),socket_errno); sprintf(mysql->net.last_error,ER(mysql->net.last_errno),errno);
my_free(tmp_name,MYF(0)); goto err;
DBUG_RETURN(-1);
} }
if (readcount < 0) if (readcount < 0)
{ {
mysql->net.last_errno=EE_READ; /* the errmsg for not entire file read */ mysql->net.last_errno=EE_READ; /* the errmsg for not entire file read */
sprintf(buf,EE(mysql->net.last_errno),tmp_name,errno); snprintf(mysql->net.last_error,sizeof(mysql->net.last_error)-1,
strmake(mysql->net.last_error,buf,sizeof(mysql->net.last_error)-1); tmp_name,errno);
my_free(tmp_name,MYF(0)); goto err;
DBUG_RETURN(-1);
} }
DBUG_RETURN(0); result=0; /* Ok */
err:
if (fd >= 0)
(void) my_close(fd,MYF(0));
my_free(buf,MYF(0));
DBUG_RETURN(result);
} }
......
...@@ -241,7 +241,7 @@ while test $# -gt 0; do ...@@ -241,7 +241,7 @@ while test $# -gt 0; do
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;; EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" ;;
--sleep=*) --sleep=*)
EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1" EXTRA_MYSQL_TEST_OPT="$EXTRA_MYSQL_TEST_OPT $1"
SLEEP_TIME_AFTER_RESTART="$1" SLEEP_TIME_AFTER_RESTART=`$ECHO "$1" | $SED -e "s;--sleep=;;"`
;; ;;
--mysqld=*) --mysqld=*)
TMP=`$ECHO "$1" | $SED -e "s;--mysqld=;;"` TMP=`$ECHO "$1" | $SED -e "s;--mysqld=;;"`
......
...@@ -1047,7 +1047,7 @@ int STDCALL mc_mysql_query(MYSQL *mysql, const char *query, uint length) ...@@ -1047,7 +1047,7 @@ int STDCALL mc_mysql_query(MYSQL *mysql, const char *query, uint length)
DBUG_ENTER("mysql_real_query"); DBUG_ENTER("mysql_real_query");
DBUG_PRINT("enter",("handle: %lx",mysql)); DBUG_PRINT("enter",("handle: %lx",mysql));
DBUG_PRINT("query",("Query = \"%s\"",query)); DBUG_PRINT("query",("Query = \"%s\"",query));
if(!length) if (!length)
length = strlen(query); length = strlen(query);
if (mc_simple_command(mysql,COM_QUERY,query,length,1)) if (mc_simple_command(mysql,COM_QUERY,query,length,1))
DBUG_RETURN(-1); DBUG_RETURN(-1);
...@@ -1056,58 +1056,62 @@ int STDCALL mc_mysql_query(MYSQL *mysql, const char *query, uint length) ...@@ -1056,58 +1056,62 @@ int STDCALL mc_mysql_query(MYSQL *mysql, const char *query, uint length)
static int mc_send_file_to_server(MYSQL *mysql, const char *filename) static int mc_send_file_to_server(MYSQL *mysql, const char *filename)
{ {
int fd, readcount; int fd, readcount, result= -1;
char buf[IO_SIZE*15],*tmp_name; uint packet_length=MY_ALIGN(mysql->net.max_packet-16,IO_SIZE);
char *buf, tmp_name[FN_REFLEN];
DBUG_ENTER("send_file_to_server"); DBUG_ENTER("send_file_to_server");
fn_format(buf,filename,"","",4); /* Convert to client format */ if (!(buf=my_malloc(packet_length,MYF(0))))
if (!(tmp_name=my_strdup(buf,MYF(0))))
{ {
strmov(mysql->net.last_error, ER(mysql->net.last_errno=CR_OUT_OF_MEMORY)); strmov(mysql->net.last_error, ER(mysql->net.last_errno=CR_OUT_OF_MEMORY));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
fn_format(tmp_name,filename,"","",4); /* Convert to client format */
if ((fd = my_open(tmp_name,O_RDONLY, MYF(0))) < 0) if ((fd = my_open(tmp_name,O_RDONLY, MYF(0))) < 0)
{ {
my_net_write(&mysql->net,"",0); // Server needs one packet
net_flush(&mysql->net);
mysql->net.last_errno=EE_FILENOTFOUND; mysql->net.last_errno=EE_FILENOTFOUND;
sprintf(buf,EE(mysql->net.last_errno),tmp_name,errno); snprintf(mysql->net.last_error,sizeof(mysql->net.last_error)-1,
strmake(mysql->net.last_error,buf,sizeof(mysql->net.last_error)-1); EE(mysql->net.last_errno),tmp_name, errno);
my_net_write(&mysql->net,"",0); net_flush(&mysql->net); goto err;
my_free(tmp_name,MYF(0));
DBUG_RETURN(-1);
} }
while ((readcount = (int) my_read(fd,(byte*) buf,sizeof(buf),MYF(0))) > 0) while ((readcount = (int) my_read(fd,(byte*) buf,packet_length,MYF(0))) > 0)
{ {
if (my_net_write(&mysql->net,buf,readcount)) if (my_net_write(&mysql->net,buf,readcount))
{ {
DBUG_PRINT("error",("Lost connection to MySQL server during LOAD DATA of local file"));
mysql->net.last_errno=CR_SERVER_LOST; mysql->net.last_errno=CR_SERVER_LOST;
strmov(mysql->net.last_error,ER(mysql->net.last_errno)); strmov(mysql->net.last_error,ER(mysql->net.last_errno));
DBUG_PRINT("error",("Lost connection to MySQL server during LOAD DATA of local file")); goto err;
(void) my_close(fd,MYF(0));
my_free(tmp_name,MYF(0));
DBUG_RETURN(-1);
} }
} }
(void) my_close(fd,MYF(0));
/* Send empty packet to mark end of file */ /* Send empty packet to mark end of file */
if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net)) if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net))
{ {
mysql->net.last_errno=CR_SERVER_LOST; mysql->net.last_errno=CR_SERVER_LOST;
sprintf(mysql->net.last_error,ER(mysql->net.last_errno),errno); sprintf(mysql->net.last_error,ER(mysql->net.last_errno),errno);
my_free(tmp_name,MYF(0)); goto err;
DBUG_RETURN(-1);
} }
if (readcount < 0) if (readcount < 0)
{ {
mysql->net.last_errno=EE_READ; /* the errmsg for not entire file read */ mysql->net.last_errno=EE_READ; /* the errmsg for not entire file read */
sprintf(buf,EE(mysql->net.last_errno),tmp_name,errno); snprintf(mysql->net.last_error,sizeof(mysql->net.last_error)-1,
strmake(mysql->net.last_error,buf,sizeof(mysql->net.last_error)-1); tmp_name,errno);
my_free(tmp_name,MYF(0)); goto err;
DBUG_RETURN(-1);
} }
DBUG_RETURN(0); result=0; // Ok
err:
if (fd >= 0)
(void) my_close(fd,MYF(0));
my_free(buf,MYF(0));
DBUG_RETURN(result);
} }
/* Get the length of next field. Change parameter to point at fieldstart */ /* Get the length of next field. Change parameter to point at fieldstart */
static ulong mc_net_field_length(uchar **packet) static ulong mc_net_field_length(uchar **packet)
{ {
...@@ -1187,7 +1191,7 @@ static MYSQL_DATA *mc_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields, ...@@ -1187,7 +1191,7 @@ static MYSQL_DATA *mc_read_rows(MYSQL *mysql,MYSQL_FIELD *mysql_fields,
if ((pkt_len=mc_net_safe_read(mysql)) == packet_error) if ((pkt_len=mc_net_safe_read(mysql)) == packet_error)
DBUG_RETURN(0); DBUG_RETURN(0);
if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA), if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
MYF(MY_WME | MY_ZEROFILL)))) MYF(MY_ZEROFILL))))
{ {
net->last_errno=CR_OUT_OF_MEMORY; net->last_errno=CR_OUT_OF_MEMORY;
strmov(net->last_error,ER(net->last_errno)); strmov(net->last_error,ER(net->last_errno));
...@@ -1374,7 +1378,7 @@ MYSQL_RES * STDCALL mc_mysql_store_result(MYSQL *mysql) ...@@ -1374,7 +1378,7 @@ MYSQL_RES * STDCALL mc_mysql_store_result(MYSQL *mysql)
mysql->status=MYSQL_STATUS_READY; /* server is ready */ mysql->status=MYSQL_STATUS_READY; /* server is ready */
if (!(result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+ if (!(result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
sizeof(ulong)*mysql->field_count, sizeof(ulong)*mysql->field_count,
MYF(MY_WME | MY_ZEROFILL)))) MYF(MY_ZEROFILL))))
{ {
mysql->net.last_errno=CR_OUT_OF_MEMORY; mysql->net.last_errno=CR_OUT_OF_MEMORY;
strmov(mysql->net.last_error, ER(mysql->net.last_errno)); strmov(mysql->net.last_error, ER(mysql->net.last_errno));
......
...@@ -752,7 +752,7 @@ void clean_up(bool print_message) ...@@ -752,7 +752,7 @@ void clean_up(bool print_message)
bitmap_free(&slave_error_mask); bitmap_free(&slave_error_mask);
acl_free(1); acl_free(1);
grant_free(); grant_free();
query_cache.resize(0); query_cache.destroy();
table_cache_free(); table_cache_free();
hostname_cache_free(); hostname_cache_free();
item_user_lock_free(); item_user_lock_free();
......
...@@ -2369,8 +2369,9 @@ void Query_cache::pack_cache() ...@@ -2369,8 +2369,9 @@ void Query_cache::pack_cache()
{ {
do do
{ {
Query_cache_block *next=block->pnext;
ok = move_by_type(&border, &before, &gap, block); ok = move_by_type(&border, &before, &gap, block);
block = block->pnext; block = next;
} while (ok && block != first_block); } while (ok && block != first_block);
if (border != 0) if (border != 0)
......
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