~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.cc

Moved more drizzleclient/NET specific code to Protocol class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include <drizzled/protocol.h>
27
27
#include <drizzled/session.h>
28
28
 
 
29
/*
 
30
  Function called by drizzleclient_net_init() to set some check variables
 
31
*/
 
32
 
 
33
extern "C" {
 
34
  void drizzleclient_net_local_init(NET *net)
 
35
  {
 
36
    net->max_packet= (uint32_t) global_system_variables.net_buffer_length;
 
37
 
 
38
    drizzleclient_net_set_read_timeout(net,
 
39
                            (uint32_t)global_system_variables.net_read_timeout);
 
40
    drizzleclient_net_set_write_timeout(net,
 
41
                           (uint32_t)global_system_variables.net_write_timeout);
 
42
 
 
43
    net->retry_count=  (uint32_t) global_system_variables.net_retry_count;
 
44
    net->max_packet_size= cmax(global_system_variables.net_buffer_length,
 
45
                               global_system_variables.max_allowed_packet);
 
46
  }
 
47
}
 
48
 
29
49
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
30
50
/* Declared non-static only because of the embedded library. */
31
51
static void net_send_error_packet(Session *session, uint32_t sql_errno, const char *err);
32
52
static void write_eof_packet(Session *session, NET *net,
33
53
                             uint32_t server_status, uint32_t total_warn_count);
34
54
 
 
55
bool Protocol::io_ok()
 
56
{
 
57
  return session->net.vio != 0;
 
58
}
 
59
 
 
60
void Protocol::set_read_timeout(uint32_t timeout)
 
61
{
 
62
  drizzleclient_net_set_read_timeout(&session->net, timeout);
 
63
}
 
64
 
 
65
void Protocol::set_write_timeout(uint32_t timeout)
 
66
{
 
67
  drizzleclient_net_set_write_timeout(&session->net, timeout);
 
68
}
 
69
 
 
70
void Protocol::set_retry_count(uint32_t count)
 
71
{
 
72
  session->net.retry_count=count;
 
73
}
 
74
 
 
75
void Protocol::set_error(char error)
 
76
{
 
77
  session->net.error= error;
 
78
}
 
79
 
 
80
bool Protocol::have_error(void)
 
81
{
 
82
  return session->net.error || session->net.vio == 0;
 
83
}
 
84
 
 
85
bool Protocol::have_compression(void)
 
86
{
 
87
  return session->net.compress;
 
88
}
 
89
 
 
90
/*
 
91
 * To disable results we set session->net.vio to 0.
 
92
 */
 
93
 
 
94
void Protocol::disable_results(void)
 
95
{
 
96
  save_vio= session->net.vio;
 
97
  session->net.vio= 0;
 
98
}
 
99
 
 
100
void Protocol::enable_results(void)
 
101
{
 
102
  session->net.vio= save_vio;
 
103
}
 
104
 
 
105
 
35
106
bool Protocol::net_store_data(const unsigned char *from, size_t length)
36
107
{
37
108
  size_t packet_length= packet->length();
362
433
          Diagnostics_area::is_sent is set for debugging purposes only.
363
434
*/
364
435
 
365
 
void drizzleclient_net_end_statement(Session *session)
 
436
void Protocol::end_statement()
366
437
{
367
438
  assert(! session->main_da.is_sent);
368
439