Fixing that 3.23 API / clients do not disconnect if a large

packet is issued.
parent c6e42dfa
...@@ -456,6 +456,14 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, ...@@ -456,6 +456,14 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
length ? length : (ulong) strlen(arg))) length ? length : (ulong) strlen(arg)))
{ {
DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno)); DBUG_PRINT("error",("Can't send command to server. Error: %d",socket_errno));
if (net->last_errno == ER_NET_PACKET_TOO_LARGE)
{
net->last_errno=CR_NET_PACKET_TOO_LARGE;
strmov(net->last_error,ER(net->last_errno));
return(packet_error);
}
else
{
end_server(mysql); end_server(mysql);
if (mysql_reconnect(mysql) || if (mysql_reconnect(mysql) ||
net_write_command(net,(uchar) command,arg, net_write_command(net,(uchar) command,arg,
...@@ -466,6 +474,7 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg, ...@@ -466,6 +474,7 @@ simple_command(MYSQL *mysql,enum enum_server_command command, const char *arg,
goto end; goto end;
} }
} }
}
result=0; result=0;
if (!skipp_check) if (!skipp_check)
result= ((mysql->packet_length=net_safe_read(mysql)) == packet_error ? result= ((mysql->packet_length=net_safe_read(mysql)) == packet_error ?
......
This diff is collapsed.
...@@ -34,13 +34,18 @@ ...@@ -34,13 +34,18 @@
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef MYSQL_SERVER
#include <violite.h>
#endif
#define MAX_PACKET_LENGTH (256L*256L*256L-1)
#ifdef MYSQL_SERVER #ifdef MYSQL_SERVER
ulong max_allowed_packet=65536; ulong max_allowed_packet=65536;
extern ulong net_read_timeout,net_write_timeout; extern ulong net_read_timeout,net_write_timeout;
extern uint test_flags; extern uint test_flags;
#else #else
ulong max_allowed_packet=16*1024*1024L-1; ulong max_allowed_packet=MAX_PACKET_LENGTH;
ulong net_read_timeout= NET_READ_TIMEOUT; ulong net_read_timeout= NET_READ_TIMEOUT;
ulong net_write_timeout= NET_WRITE_TIMEOUT; ulong net_write_timeout= NET_WRITE_TIMEOUT;
#endif #endif
...@@ -226,6 +231,12 @@ int ...@@ -226,6 +231,12 @@ int
my_net_write(NET *net,const char *packet,ulong len) my_net_write(NET *net,const char *packet,ulong len)
{ {
uchar buff[NET_HEADER_SIZE]; uchar buff[NET_HEADER_SIZE];
if (len >= MAX_PACKET_LENGTH)
{
net->error=1;
net->last_errno=ER_NET_PACKET_TOO_LARGE;
return 1;
}
int3store(buff,len); int3store(buff,len);
buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE)) if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
...@@ -238,7 +249,12 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len) ...@@ -238,7 +249,12 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
{ {
uchar buff[NET_HEADER_SIZE+1]; uchar buff[NET_HEADER_SIZE+1];
uint length=len+1; /* 1 extra byte for command */ uint length=len+1; /* 1 extra byte for command */
if (length >= MAX_PACKET_LENGTH)
{
net->error=1;
net->last_errno=ER_NET_PACKET_TOO_LARGE;
return 1;
}
int3store(buff,length); int3store(buff,length);
buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++); buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
buff[4]=command; buff[4]=command;
...@@ -276,7 +292,7 @@ net_real_write(NET *net,const char *packet,ulong len) ...@@ -276,7 +292,7 @@ net_real_write(NET *net,const char *packet,ulong len)
int length; int length;
char *pos,*end; char *pos,*end;
thr_alarm_t alarmed; thr_alarm_t alarmed;
#if !defined(__WIN__) #if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
ALARM alarm_buff; ALARM alarm_buff;
#endif #endif
uint retry_count=0; uint retry_count=0;
......
...@@ -2328,8 +2328,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) ...@@ -2328,8 +2328,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
if ((tab->keys & ~ tab->const_keys && i > 0) || if ((tab->keys & ~ tab->const_keys && i > 0) ||
tab->const_keys && i == join->const_tables && tab->const_keys && i == join->const_tables &&
join->thd->select_limit < join->best_positions[i].records_read && join->thd->select_limit < join->best_positions[i].records_read)
join->tables > 1)
{ {
/* Join with outer join condition */ /* Join with outer join condition */
COND *orig_cond=sel->cond; COND *orig_cond=sel->cond;
......
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