summaryrefslogtreecommitdiff
path: root/sql/net_serv.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2012-09-27 20:09:46 +0200
committerSergei Golubchik <sergii@pisem.net>2012-09-27 20:09:46 +0200
commit474fe6d9d9e0b4d8803bdf439dd017ba0c729729 (patch)
tree6b088655217934bf0cbb6cdf85df0a217ef1d939 /sql/net_serv.cc
parentcd9f773020c6ddfc1ea39e9037e4258b8bc32a08 (diff)
downloadmariadb-git-474fe6d9d9e0b4d8803bdf439dd017ba0c729729.tar.gz
fixes for test failures
and small collateral changes mysql-test/lib/My/Test.pm: somehow with "print" we get truncated writes sometimes mysql-test/suite/perfschema/r/digest_table_full.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/dml_handler.result: host table is not ported over yet mysql-test/suite/perfschema/r/information_schema.result: host table is not ported over yet mysql-test/suite/perfschema/r/nesting.result: this differs, because we don't rewrite general log queries, and multi-statement packets are logged as a one entry. this result file is identical to what mysql-5.6.5 produces with the --log-raw option. mysql-test/suite/perfschema/r/relaylog.result: MariaDB modifies the binlog index file directly, while MySQL 5.6 has a feature "crash-safe binlog index" and modifies a special "crash-safe" shadow copy of the index file and then moves it over. That's why this test shows "NONE" index file writes in MySQL and "MANY" in MariaDB. mysql-test/suite/perfschema/r/server_init.result: MariaDB initializes the "manager" resources from the "manager" thread, and starts this thread only when --flush-time is not 0. MySQL 5.6 initializes "manager" resources unconditionally on server startup. mysql-test/suite/perfschema/r/stage_mdl_global.result: this differs, because MariaDB disables query cache when query_cache_size=0. MySQL does not do that, and this causes useless mutex locks and waits. mysql-test/suite/perfschema/r/statement_digest.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/statement_digest_consumers.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/perfschema/r/statement_digest_long_query.result: md5 hashes of statement digests differ, because yacc token codes are different in mariadb mysql-test/suite/rpl/r/rpl_mixed_drop_create_temp_table.result: will be updated to match 5.6 when alfranio.correia@oracle.com-20110512172919-c1b5kmum4h52g0ni and anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y are merged mysql-test/suite/rpl/r/rpl_non_direct_mixed_mixing_engines.result: will be updated to match 5.6 when anders.song@greatopensource.com-20110105052107-zoab0bsf5a6xxk2y is merged
Diffstat (limited to 'sql/net_serv.cc')
-rw-r--r--sql/net_serv.cc67
1 files changed, 53 insertions, 14 deletions
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index fc60df27689..7e9425f51f2 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -1,5 +1,5 @@
/* Copyright (c) 2000, 2011, Oracle and/or its affiliates.
- Copyright (c) 2012, Monty Program Ab
+ Copyright (c) 2010, 2012, Monty Program Ab.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
/**
@file
@@ -112,11 +112,15 @@ extern void query_cache_insert(const char *packet, ulong length,
#define update_statistics(A)
#endif
+#ifdef MYSQL_SERVER
+/* Additional instrumentation hooks for the server */
+#include "mysql_com_server.h"
+#endif
+
#define TEST_BLOCKING 8
#define MAX_PACKET_LENGTH (256L*256L*256L-1)
-static my_bool net_write_buff(NET *net,const uchar *packet,ulong len);
-
+static my_bool net_write_buff(NET *, const uchar *, ulong);
/** Init with packet info. */
@@ -139,10 +143,14 @@ my_bool my_net_init(NET *net, Vio* vio)
net->net_skip_rest_factor= 0;
net->last_errno=0;
net->unused= 0;
+#ifdef MYSQL_SERVER
+ net->extension= NULL;
+#endif
- if (vio != 0) /* If real connection */
+ if (vio)
{
- net->fd = vio_fd(vio); /* For perl DBI/DBD */
+ /* For perl DBI/DBD. */
+ net->fd= vio_fd(vio);
#if defined(MYSQL_SERVER) && !defined(__WIN__)
if (!(test_flags & TEST_BLOCKING))
{
@@ -262,7 +270,10 @@ static int net_data_is_ready(my_socket sd)
#endif /* EMBEDDED_LIBRARY */
/**
- Intialize NET handler for new reads:
+ Clear (reinitialize) the NET structure for a new command.
+
+ @remark Performs debug checking of the socket buffer to
+ ensure that the protocol sequence is correct.
- Read from socket until there is nothing more to read. Discard
what is read.
@@ -347,7 +358,7 @@ my_bool net_flush(NET *net)
{
error=test(net_real_write(net, net->buff,
(size_t) (net->write_pos - net->buff)));
- net->write_pos=net->buff;
+ net->write_pos= net->buff;
}
/* Sync packet number if using compression */
if (net->compress)
@@ -363,15 +374,13 @@ my_bool net_flush(NET *net)
/**
Write a logical packet with packet header.
- Format: Packet length (3 bytes), packet number(1 byte)
- When compression is used a 3 byte compression length is added
+ Format: Packet length (3 bytes), packet number (1 byte)
+ When compression is used, a 3 byte compression length is added.
- @note
- If compression is used the original package is modified!
+ @note If compression is used, the original packet is modified!
*/
-my_bool
-my_net_write(NET *net,const uchar *packet,size_t len)
+my_bool my_net_write(NET *net, const uchar *packet, size_t len)
{
uchar buff[NET_HEADER_SIZE];
int rc;
@@ -416,6 +425,7 @@ my_net_write(NET *net,const uchar *packet,size_t len)
return rc;
}
+
/**
Send a command to the server.
@@ -820,6 +830,19 @@ my_real_read(NET *net, size_t *complen)
my_bool net_blocking=vio_is_blocking(net->vio);
uint32 remain= (net->compress ? NET_HEADER_SIZE+COMP_HEADER_SIZE :
NET_HEADER_SIZE);
+#ifdef MYSQL_SERVER
+ size_t count= remain;
+ struct st_net_server *server_extension;
+ server_extension= static_cast<st_net_server*> (net->extension);
+ if (server_extension != NULL)
+ {
+ void *user_data= server_extension->m_user_data;
+ DBUG_ASSERT(server_extension->m_before_header != NULL);
+ DBUG_ASSERT(server_extension->m_after_header != NULL);
+ server_extension->m_before_header(net, user_data, count);
+ }
+#endif
+
*complen = 0;
net->reading_or_writing=1;
@@ -976,6 +999,14 @@ my_real_read(NET *net, size_t *complen)
}
pos=net->buff + net->where_b;
remain = (uint32) len;
+#ifdef MYSQL_SERVER
+ if (server_extension != NULL)
+ {
+ void *user_data= server_extension->m_user_data;
+ server_extension->m_after_header(net, user_data, count, 0);
+ server_extension= NULL;
+ }
+#endif
}
}
@@ -992,6 +1023,14 @@ end:
if (len != packet_error)
DBUG_DUMP("data", net->buff+net->where_b, len);
#endif
+#ifdef MYSQL_SERVER
+ if (server_extension != NULL)
+ {
+ void *user_data= server_extension->m_user_data;
+ server_extension->m_after_header(net, user_data, count, 1);
+ DBUG_ASSERT(len == packet_error || len == 0);
+ }
+#endif
return(len);
}