summaryrefslogtreecommitdiff
path: root/sql/mini_client.cc
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-12-19 15:45:04 +0200
committerunknown <monty@hundin.mysql.fi>2001-12-19 15:45:04 +0200
commit9f57d97fb23d3ebd43bedbc83d24edc6d9a610dd (patch)
tree531ac8f5750d09e5dfdd3dea539e98c0c0a1ddec /sql/mini_client.cc
parent20038678cff13261f886b3fdb7e2f04fae1386b5 (diff)
downloadmariadb-git-9f57d97fb23d3ebd43bedbc83d24edc6d9a610dd.tar.gz
Fixed bug in FLUSH QUERY CACHE
Changed 'send_file_to_server' to use less stack (Fixed replication problem on OSF1). Docs/manual.texi: Changelog libmysql/libmysql.c: Changed 'send_file_to_server' to use less stack (Fixed some problems in threaded applications) mysql-test/mysql-test-run.sh: Fixed --sleep option sql/mini_client.cc: Changed 'send_file_to_server' to use less stack (Fixed replication problem on OSF1). sql/mysqld.cc: Destroy query cache properly sql/sql_cache.cc: Fixed bug in FLUSH QUERY CACHE
Diffstat (limited to 'sql/mini_client.cc')
-rw-r--r--sql/mini_client.cc54
1 files changed, 29 insertions, 25 deletions
diff --git a/sql/mini_client.cc b/sql/mini_client.cc
index 3da5edac37f..74073990d95 100644
--- a/sql/mini_client.cc
+++ b/sql/mini_client.cc
@@ -1047,7 +1047,7 @@ int STDCALL mc_mysql_query(MYSQL *mysql, const char *query, uint length)
DBUG_ENTER("mysql_real_query");
DBUG_PRINT("enter",("handle: %lx",mysql));
DBUG_PRINT("query",("Query = \"%s\"",query));
- if(!length)
+ if (!length)
length = strlen(query);
if (mc_simple_command(mysql,COM_QUERY,query,length,1))
DBUG_RETURN(-1);
@@ -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)
{
- int fd, readcount;
- char buf[IO_SIZE*15],*tmp_name;
+ int fd, readcount, result= -1;
+ uint packet_length=MY_ALIGN(mysql->net.max_packet-16,IO_SIZE);
+ char *buf, tmp_name[FN_REFLEN];
DBUG_ENTER("send_file_to_server");
- fn_format(buf,filename,"","",4); /* Convert to client format */
- if (!(tmp_name=my_strdup(buf,MYF(0))))
+ if (!(buf=my_malloc(packet_length,MYF(0))))
{
strmov(mysql->net.last_error, ER(mysql->net.last_errno=CR_OUT_OF_MEMORY));
DBUG_RETURN(-1);
}
+
+ fn_format(tmp_name,filename,"","",4); /* Convert to client format */
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;
- sprintf(buf,EE(mysql->net.last_errno),tmp_name,errno);
- strmake(mysql->net.last_error,buf,sizeof(mysql->net.last_error)-1);
- my_net_write(&mysql->net,"",0); net_flush(&mysql->net);
- my_free(tmp_name,MYF(0));
- DBUG_RETURN(-1);
+ snprintf(mysql->net.last_error,sizeof(mysql->net.last_error)-1,
+ EE(mysql->net.last_errno),tmp_name, errno);
+ goto err;
}
- 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))
{
+ DBUG_PRINT("error",("Lost connection to MySQL server during LOAD DATA of local file"));
mysql->net.last_errno=CR_SERVER_LOST;
strmov(mysql->net.last_error,ER(mysql->net.last_errno));
- DBUG_PRINT("error",("Lost connection to MySQL server during LOAD DATA of local file"));
- (void) my_close(fd,MYF(0));
- my_free(tmp_name,MYF(0));
- DBUG_RETURN(-1);
+ goto err;
}
}
- (void) my_close(fd,MYF(0));
/* Send empty packet to mark end of file */
if (my_net_write(&mysql->net,"",0) || net_flush(&mysql->net))
{
mysql->net.last_errno=CR_SERVER_LOST;
sprintf(mysql->net.last_error,ER(mysql->net.last_errno),errno);
- my_free(tmp_name,MYF(0));
- DBUG_RETURN(-1);
+ goto err;
}
if (readcount < 0)
{
mysql->net.last_errno=EE_READ; /* the errmsg for not entire file read */
- sprintf(buf,EE(mysql->net.last_errno),tmp_name,errno);
- strmake(mysql->net.last_error,buf,sizeof(mysql->net.last_error)-1);
- my_free(tmp_name,MYF(0));
- DBUG_RETURN(-1);
+ snprintf(mysql->net.last_error,sizeof(mysql->net.last_error)-1,
+ tmp_name,errno);
+ goto err;
}
- 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 */
static ulong mc_net_field_length(uchar **packet)
{
@@ -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)
DBUG_RETURN(0);
if (!(result=(MYSQL_DATA*) my_malloc(sizeof(MYSQL_DATA),
- MYF(MY_WME | MY_ZEROFILL))))
+ MYF(MY_ZEROFILL))))
{
net->last_errno=CR_OUT_OF_MEMORY;
strmov(net->last_error,ER(net->last_errno));
@@ -1374,7 +1378,7 @@ MYSQL_RES * STDCALL mc_mysql_store_result(MYSQL *mysql)
mysql->status=MYSQL_STATUS_READY; /* server is ready */
if (!(result=(MYSQL_RES*) my_malloc(sizeof(MYSQL_RES)+
sizeof(ulong)*mysql->field_count,
- MYF(MY_WME | MY_ZEROFILL))))
+ MYF(MY_ZEROFILL))))
{
mysql->net.last_errno=CR_OUT_OF_MEMORY;
strmov(mysql->net.last_error, ER(mysql->net.last_errno));