Commit 7d410b73 authored by monty@mashka.mysql.fi's avatar monty@mashka.mysql.fi

Merge work:/my/mysql-4.0 into mashka.mysql.fi:/home/my/mysql-4.0

parents 74a9fb24 6d5ad61a
...@@ -119,6 +119,7 @@ struct st_mysql_options { ...@@ -119,6 +119,7 @@ struct st_mysql_options {
char *ssl_ca; /* PEM CA file */ char *ssl_ca; /* PEM CA file */
char *ssl_capath; /* PEM directory of CA-s? */ char *ssl_capath; /* PEM directory of CA-s? */
char *ssl_cipher; /* cipher to use */ char *ssl_cipher; /* cipher to use */
unsigned long max_allowed_packet;
my_bool use_ssl; /* if to use SSL or not */ my_bool use_ssl; /* if to use SSL or not */
my_bool compress,named_pipe; my_bool compress,named_pipe;
/* /*
......
...@@ -34,14 +34,14 @@ ...@@ -34,14 +34,14 @@
#define MYSQL_SERVICENAME "MySql" #define MYSQL_SERVICENAME "MySql"
#endif /* __WIN__ */ #endif /* __WIN__ */
enum enum_server_command {COM_SLEEP,COM_QUIT,COM_INIT_DB,COM_QUERY, enum enum_server_command {
COM_FIELD_LIST,COM_CREATE_DB,COM_DROP_DB,COM_REFRESH, COM_SLEEP, COM_QUIT, COM_INIT_DB, COM_QUERY, COM_FIELD_LIST,
COM_SHUTDOWN,COM_STATISTICS, COM_CREATE_DB, COM_DROP_DB, COM_REFRESH, COM_SHUTDOWN, COM_STATISTICS,
COM_PROCESS_INFO,COM_CONNECT,COM_PROCESS_KILL, COM_PROCESS_INFO, COM_CONNECT, COM_PROCESS_KILL, COM_DEBUG, COM_PING,
COM_DEBUG,COM_PING,COM_TIME,COM_DELAYED_INSERT, COM_TIME, COM_DELAYED_INSERT, COM_CHANGE_USER, COM_BINLOG_DUMP,
COM_CHANGE_USER, COM_BINLOG_DUMP, COM_TABLE_DUMP, COM_CONNECT_OUT, COM_REGISTER_SLAVE,
COM_TABLE_DUMP, COM_CONNECT_OUT, COM_END /* Must be last! */
COM_REGISTER_SLAVE}; };
#define NOT_NULL_FLAG 1 /* Field can't be NULL */ #define NOT_NULL_FLAG 1 /* Field can't be NULL */
#define PRI_KEY_FLAG 2 /* Field is part of a primary key */ #define PRI_KEY_FLAG 2 /* Field is part of a primary key */
......
...@@ -60,7 +60,7 @@ static my_bool mysql_client_init=0; ...@@ -60,7 +60,7 @@ static my_bool mysql_client_init=0;
uint mysql_port=0; uint mysql_port=0;
my_string mysql_unix_port=0; my_string mysql_unix_port=0;
ulong net_buffer_length=8192; ulong net_buffer_length=8192;
ulong max_allowed_packet=16*1024*1024L; ulong max_allowed_packet= 1024L*1024L*1024L;
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;
...@@ -713,8 +713,8 @@ static const char *default_options[]= ...@@ -713,8 +713,8 @@ static const char *default_options[]=
"character-sets-dir", "default-character-set", "interactive-timeout", "character-sets-dir", "default-character-set", "interactive-timeout",
"connect-timeout", "local-infile", "disable-local-infile", "connect-timeout", "local-infile", "disable-local-infile",
"replication-probe", "enable-reads-from-master", "repl-parse-query", "replication-probe", "enable-reads-from-master", "repl-parse-query",
"ssl-cipher", "ssl-cipher", "max-allowed-packet",
NullS NullS
}; };
static TYPELIB option_types={array_elements(default_options)-1, static TYPELIB option_types={array_elements(default_options)-1,
...@@ -868,6 +868,9 @@ static void mysql_read_default_options(struct st_mysql_options *options, ...@@ -868,6 +868,9 @@ static void mysql_read_default_options(struct st_mysql_options *options,
case 25: /* repl-parse-query */ case 25: /* repl-parse-query */
options->rpl_parse= 1; options->rpl_parse= 1;
break; break;
case 27:
options->max_allowed_packet= atoi(opt_arg);
break;
default: default:
DBUG_PRINT("warning",("unknown option: %s",option[0])); DBUG_PRINT("warning",("unknown option: %s",option[0]));
} }
...@@ -1908,6 +1911,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1908,6 +1911,7 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
mysql->server_version,mysql->server_capabilities, mysql->server_version,mysql->server_capabilities,
mysql->server_status, client_flag)); mysql->server_status, client_flag));
/* This needs to be changed as it's not useful with big packets */
int3store(buff+2,max_allowed_packet); int3store(buff+2,max_allowed_packet);
if (user && user[0]) if (user && user[0])
strmake(buff+5,user,32); /* Max user name */ strmake(buff+5,user,32); /* Max user name */
...@@ -1935,6 +1939,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user, ...@@ -1935,6 +1939,8 @@ mysql_real_connect(MYSQL *mysql,const char *host, const char *user,
goto error; goto error;
if (client_flag & CLIENT_COMPRESS) /* We will use compression */ if (client_flag & CLIENT_COMPRESS) /* We will use compression */
net->compress=1; net->compress=1;
if (mysql->options.max_allowed_packet)
net->max_packet_size= mysql->options.max_allowed_packet;
if (db && mysql_select_db(mysql,db)) if (db && mysql_select_db(mysql,db))
goto error; goto error;
if (mysql->options.init_command) if (mysql->options.init_command)
...@@ -2302,7 +2308,7 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong length) ...@@ -2302,7 +2308,7 @@ mysql_real_query(MYSQL *mysql, const char *query, ulong 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 = '%-.4096s'",query));
if (mysql_send_query(mysql,query,length)) if (mysql_send_query(mysql,query,length))
DBUG_RETURN(-1); DBUG_RETURN(-1);
......
set global max_allowed_packet=100;
set max_allowed_packet=100;
set global net_buffer_length=100;
set net_buffer_length=100;
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
len
1024
select repeat('a',200);
repeat('a',200)
NULL
select @@net_buffer_length, @@max_allowed_packet;
@@net_buffer_length @@max_allowed_packet
1024 80
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
Got a packet bigger than 'max_allowed_packet'
set global max_allowed_packet=default;
set max_allowed_packet=default;
set global net_buffer_length=default;
set net_buffer_length=default;
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
len
100
select length(repeat('a',200));
length(repeat('a',200))
200
#
# Check protocol handling
#
connect (con1,localhost,root,,);
connection con1;
set global max_allowed_packet=100;
set max_allowed_packet=100;
set global net_buffer_length=100;
set net_buffer_length=100;
# Have to be > 1024 as min value of net_buffer_length is 1024
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
# Should return NULL as 200 is bigger than max_allowed_packet
select repeat('a',200);
#
# Connection 2 should get error for too big packets
#
connect (con2,localhost,root,,);
connection con2;
select @@net_buffer_length, @@max_allowed_packet;
--error 1153
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
set global max_allowed_packet=default;
set max_allowed_packet=default;
set global net_buffer_length=default;
set net_buffer_length=default;
SELECT length("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa") as len;
select length(repeat('a',200));
...@@ -32,24 +32,28 @@ ...@@ -32,24 +32,28 @@
my_bool my_compress(byte *packet, ulong *len, ulong *complen) my_bool my_compress(byte *packet, ulong *len, ulong *complen)
{ {
DBUG_ENTER("my_compress");
if (*len < MIN_COMPRESS_LENGTH) if (*len < MIN_COMPRESS_LENGTH)
{
*complen=0; *complen=0;
DBUG_PRINT("note",("Packet too short: Not compressed"));
}
else else
{ {
byte *compbuf=my_compress_alloc(packet,len,complen); byte *compbuf=my_compress_alloc(packet,len,complen);
if (!compbuf) if (!compbuf)
return *complen ? 0 : 1; DBUG_RETURN(*complen ? 0 : 1);
memcpy(packet,compbuf,*len); memcpy(packet,compbuf,*len);
my_free(compbuf,MYF(MY_WME)); } my_free(compbuf,MYF(MY_WME)); }
return 0; DBUG_RETURN(0);
} }
byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen) byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen)
{ {
byte *compbuf; byte *compbuf;
*complen = *len * 120 / 100 + 12; *complen= *len * 120 / 100 + 12;
if (!(compbuf = (byte *) my_malloc(*complen,MYF(MY_WME)))) if (!(compbuf= (byte *) my_malloc(*complen,MYF(MY_WME))))
return 0; /* Not enough memory */ return 0; /* Not enough memory */
if (compress((Bytef*) compbuf,(ulong *) complen, (Bytef*) packet, if (compress((Bytef*) compbuf,(ulong *) complen, (Bytef*) packet,
(uLong) *len ) != Z_OK) (uLong) *len ) != Z_OK)
...@@ -59,31 +63,36 @@ byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen) ...@@ -59,31 +63,36 @@ byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen)
} }
if (*complen >= *len) if (*complen >= *len)
{ {
*complen=0; *complen= 0;
my_free(compbuf,MYF(MY_WME)); my_free(compbuf, MYF(MY_WME));
DBUG_PRINT("note",("Packet got longer on compression; Not compressed"));
return 0; return 0;
} }
swap(ulong,*len,*complen); /* *len is now packet length */ swap(ulong, *len, *complen); /* *len is now packet length */
return compbuf; return compbuf;
} }
my_bool my_uncompress (byte *packet, ulong *len, ulong *complen) my_bool my_uncompress (byte *packet, ulong *len, ulong *complen)
{ {
DBUG_ENTER("my_uncompress");
if (*complen) /* If compressed */ if (*complen) /* If compressed */
{ {
byte *compbuf = (byte *) my_malloc (*complen,MYF(MY_WME)); byte *compbuf= (byte *) my_malloc(*complen,MYF(MY_WME));
int error;
if (!compbuf) if (!compbuf)
return 1; /* Not enough memory */ DBUG_RETURN(1); /* Not enough memory */
if (uncompress((Bytef*) compbuf, complen, (Bytef*) packet, *len) != Z_OK) if ((error=uncompress((Bytef*) compbuf, complen, (Bytef*) packet, *len))
!= Z_OK)
{ /* Probably wrong packet */ { /* Probably wrong packet */
my_free (compbuf,MYF(MY_WME)); DBUG_PRINT("error",("Can't uncompress packet, error: %d",error));
return 1; my_free(compbuf, MYF(MY_WME));
DBUG_RETURN(1);
} }
*len = *complen; *len= *complen;
memcpy(packet,compbuf,*len); memcpy(packet, compbuf, *len);
my_free(compbuf,MYF(MY_WME)); my_free(compbuf, MYF(MY_WME));
} }
return 0; DBUG_RETURN(0);
} }
#endif /* HAVE_COMPRESS */ #endif /* HAVE_COMPRESS */
...@@ -222,7 +222,7 @@ net_store_length(char *pkg, ulonglong length) ...@@ -222,7 +222,7 @@ net_store_length(char *pkg, ulonglong length)
} }
*packet++=254; *packet++=254;
int8store(packet,length); int8store(packet,length);
return (char*) packet+9; return (char*) packet+8;
} }
char * char *
......
This diff is collapsed.
...@@ -358,7 +358,7 @@ class THD :public ilink { ...@@ -358,7 +358,7 @@ class THD :public ilink {
uint client_capabilities; /* What the client supports */ uint client_capabilities; /* What the client supports */
/* Determines if which non-standard SQL behaviour should be enabled */ /* Determines if which non-standard SQL behaviour should be enabled */
uint sql_mode; uint sql_mode;
uint max_client_packet_length; ulong max_client_packet_length;
ulong master_access; /* Global privileges from mysql.user */ ulong master_access; /* Global privileges from mysql.user */
ulong db_access; /* Privileges for current db */ ulong db_access; /* Privileges for current db */
......
...@@ -75,7 +75,8 @@ const char *command_name[]={ ...@@ -75,7 +75,8 @@ const char *command_name[]={
"Sleep", "Quit", "Init DB", "Query", "Field List", "Create DB", "Sleep", "Quit", "Init DB", "Query", "Field List", "Create DB",
"Drop DB", "Refresh", "Shutdown", "Statistics", "Processlist", "Drop DB", "Refresh", "Shutdown", "Statistics", "Processlist",
"Connect","Kill","Debug","Ping","Time","Delayed_insert","Change user", "Connect","Kill","Debug","Ping","Time","Delayed_insert","Change user",
"Binlog Dump","Table Dump", "Connect Out", "Register Slave" "Binlog Dump","Table Dump", "Connect Out", "Register Slave",
"Error" // Last command number
}; };
bool volatile abort_slave = 0; bool volatile abort_slave = 0;
...@@ -209,7 +210,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user, ...@@ -209,7 +210,7 @@ static bool check_user(THD *thd,enum_server_command command, const char *user,
!(thd->client_capabilities & !(thd->client_capabilities &
CLIENT_LONG_PASSWORD),&ur); CLIENT_LONG_PASSWORD),&ur);
DBUG_PRINT("info", DBUG_PRINT("info",
("Capabilities: %d packet_length: %d Host: '%s' User: '%s' Using password: %s Access: %u db: '%s'", ("Capabilities: %d packet_length: %ld Host: '%s' User: '%s' Using password: %s Access: %u db: '%s'",
thd->client_capabilities, thd->max_client_packet_length, thd->client_capabilities, thd->max_client_packet_length,
thd->host_or_ip, thd->priv_user, thd->host_or_ip, thd->priv_user,
passwd[0] ? "yes": "no", passwd[0] ? "yes": "no",
...@@ -882,20 +883,22 @@ bool do_command(THD *thd) ...@@ -882,20 +883,22 @@ bool do_command(THD *thd)
net_new_transaction(net); net_new_transaction(net);
if ((packet_length=my_net_read(net)) == packet_error) if ((packet_length=my_net_read(net)) == packet_error)
{ {
DBUG_PRINT("info",("Got error reading command from socket %s", DBUG_PRINT("info",("Got error %d reading command from socket %s",
vio_description(net->vio) )); net->error,
return TRUE; vio_description(net->vio)));
} /* Check if we can continue without closing the connection */
else if (!packet_length) if (net->error != 3)
{ DBUG_RETURN(TRUE); // We have to close it.
send_error(net,net->last_errno,NullS); send_error(net,net->last_errno,NullS);
net->error=0; net->error= 0;
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
else else
{ {
packet=(char*) net->read_pos; packet=(char*) net->read_pos;
command = (enum enum_server_command) (uchar) packet[0]; command = (enum enum_server_command) (uchar) packet[0];
if (command >= COM_END)
command= COM_END; // Wrong command
DBUG_PRINT("info",("Command on %s = %d (%s)", DBUG_PRINT("info",("Command on %s = %d (%s)",
vio_description(net->vio), command, vio_description(net->vio), command,
command_name[command])); command_name[command]));
...@@ -1025,7 +1028,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1025,7 +1028,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
my_pthread_setprio(pthread_self(),QUERY_PRIOR); my_pthread_setprio(pthread_self(),QUERY_PRIOR);
mysql_log.write(thd,command,"%s",thd->query); mysql_log.write(thd,command,"%s",thd->query);
DBUG_PRINT("query",("%s",thd->query)); DBUG_PRINT("query",("%-.4096s",thd->query));
/* thd->query_length is set by mysql_parse() */ /* thd->query_length is set by mysql_parse() */
mysql_parse(thd,thd->query,packet_length); mysql_parse(thd,thd->query,packet_length);
if (!(specialflag & SPECIAL_NO_PRIOR)) if (!(specialflag & SPECIAL_NO_PRIOR))
...@@ -1223,6 +1226,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, ...@@ -1223,6 +1226,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd,
case COM_CONNECT: // Impossible here case COM_CONNECT: // Impossible here
case COM_TIME: // Impossible from client case COM_TIME: // Impossible from client
case COM_DELAYED_INSERT: case COM_DELAYED_INSERT:
case COM_END:
default: default:
send_error(net, ER_UNKNOWN_COM_ERROR); send_error(net, ER_UNKNOWN_COM_ERROR);
break; break;
......
#!/usr/bin/perl #!/usr/bin/perl
# This is a test with stores big records in a blob # This is a test with stores big records in a blob.
# Note that for the default test the mysql server should have been # Note that for the default test the mysql server should have been
# started with at least 'mysqld -O max_allowed_packet=200k' # started with at least 'mysqld -O max_allowed_packet=30M' and you should have
# at least 256M memory in your computer.
$host= shift || "";
$test_db="test";
$opt_user=$opt_password="";
use DBI; use DBI;
$|= 1; # Autoflush use Getopt::Long;
$opt_host="";
$opt_user=$opt_password="";
$opt_db="test";
$opt_rows=200; # Test of blobs up to ($rows-1)*100000+1 bytes
$opt_compress=0;
$opt_table="test_big_record";
$table="test_big_record"; GetOptions("host=s","db=s","user=s", "password=s", "table=s", "rows=i",
$rows=20; # Test of blobs up to ($rows-1)*10000+1 bytes "compress") || die "Aborted";
print "Connection to database $test_db\n"; print "Connection to database $test_db\n";
$dbh = DBI->connect("DBI:mysql:$test_db:$host",$opt_user,$opt_password) || die "Can't connect: $DBI::errstr\n"; $extra_options="";
$extra_options.=":mysql_compression=1" if ($opt_compress);
$dbh->do("drop table if exists $table"); $dbh = DBI->connect("DBI:mysql:$opt_db:$host$extra_options",$opt_user,$opt_password) || die "Can't connect: $DBI::errstr\n";
print "Creating table $table\n"; $dbh->do("drop table if exists $opt_table");
print "Creating table $opt_table\n";
($dbh->do("\ ($dbh->do("\
CREATE TABLE $table ( CREATE TABLE $opt_table (
auto int(5) unsigned NOT NULL DEFAULT '0' auto_increment, auto int(5) unsigned NOT NULL DEFAULT '0' auto_increment,
test mediumblob, test longblob,
PRIMARY KEY (auto))")) or die $DBI::errstr; PRIMARY KEY (auto))")) or die $DBI::errstr;
print "Inserting $rows records\n"; print "Inserting $opt_rows records\n";
$|=1; # Flush output to stdout to be able to monitor process
for ($i=0 ; $i < $rows ; $i++) for ($i=0 ; $i < $opt_rows ; $i++)
{ {
$tmp= chr(65+$i) x ($i*10000+1); $tmp= chr(65+($i % 16)) x ($i*100000+1);
print $i," ",length($tmp),"\n";
$tmp= $dbh->quote($tmp); $tmp= $dbh->quote($tmp);
$dbh->do("insert into $table (test) values ($tmp)") or die $DBI::errstr; $dbh->do("insert into $opt_table (test) values ($tmp)") or die $DBI::errstr;
} }
print "Testing records\n"; print "Reading records\n";
$sth=$dbh->prepare("select * from $opt_table", { "mysql_use_result" => 1}) or die $dbh->errstr;
$sth=$dbh->prepare("select * from $table") or die $dbh->errstr;
$sth->execute() or die $sth->errstr; $sth->execute() or die $sth->errstr;
$i=0; $i=0;
while (($row = $sth->fetchrow_arrayref)) while (($row = $sth->fetchrow_arrayref))
{ {
print $row->[0]," ",length($row->[1]),"\n"; print $row->[0]," ",length($row->[1]),"\n";
die "Record $i had wrong data in blob" if ($row->[1] ne (chr(65+$i)) x ($i*10000+1)); die "Record $i had wrong data in blob" if ($row->[1] ne (chr(65+($i % 16)) x ($i*100000+1)));
$i++; $i++;
} }
die "Didn't get all rows from server" if ($i != $rows); die "Didn't get all rows from server" if ($i != $opt_rows);
$dbh->do("drop table $table") or die $DBI::errstr; $dbh->do("drop table $opt_table") or die $DBI::errstr;
print "Test ok\n"; print "Test ok\n";
exit 0; exit 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