~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.h

  • Committer: Brian Aker
  • Date: 2009-04-05 19:53:29 UTC
  • mfrom: (971.3.11 eday-dev)
  • Revision ID: brian@tangent.org-20090405195329-k2vpiwhlri9oaedq
MergeĀ fromĀ Eric.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <drizzled/sql_list.h>
24
24
#include <drizzled/item.h>
 
25
#include <libdrizzleclient/net_serv.h>
 
26
#include <libdrizzleclient/password.h>
25
27
 
26
28
class Field;
27
29
class String;
 
30
class Session;
28
31
class i_string;
29
 
class Session;
30
32
class my_decimal;
 
33
typedef struct st_vio Vio;
31
34
typedef struct st_drizzle_field DRIZZLE_FIELD;
32
35
typedef struct st_drizzle_rows DRIZZLE_ROWS;
33
36
typedef struct st_drizzle_time DRIZZLE_TIME;
35
38
class Protocol
36
39
{
37
40
protected:
38
 
  Session        *session;
 
41
  Session *session;
 
42
  NET net;
39
43
  String *packet;
40
44
  String *convert;
41
45
  uint32_t field_pos;
42
46
  uint32_t field_count;
 
47
  Vio* save_vio;
43
48
  bool net_store_data(const unsigned char *from, size_t length);
44
49
  bool net_store_data(const unsigned char *from, size_t length,
45
50
                      const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
51
56
  virtual ~Protocol() {}
52
57
  void init(Session* session_arg);
53
58
 
 
59
  bool io_ok();
 
60
  void end_statement(void);
 
61
  void set_read_timeout(uint32_t timeout);
 
62
  void set_write_timeout(uint32_t timeout);
 
63
  void set_retry_count(uint32_t count);
 
64
  void set_error(char error);
 
65
  bool have_error(void);
 
66
  bool was_aborted(void);
 
67
  bool have_compression(void);
 
68
  void enable_compression(void);
 
69
  bool have_more_data(void);
 
70
  bool is_reading(void);
 
71
  bool is_writing(void);
 
72
  void disable_results(void);
 
73
  void enable_results(void);
 
74
 
 
75
  virtual bool init_file_descriptor(int fd)=0;
 
76
  virtual int file_descriptor(void)=0;
 
77
  virtual void init_random(uint64_t, uint64_t) {};
 
78
  virtual bool authenticate(void)=0;
 
79
  virtual bool read_command(char **packet, uint32_t *packet_length)=0;
 
80
  virtual void send_error(uint32_t sql_errno, const char *err)=0;
 
81
  virtual void send_error_packet(uint32_t sql_errno, const char *err)=0;
 
82
  virtual void close(void) {};
 
83
 
54
84
  enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
55
85
  virtual bool send_fields(List<Item> *list, uint32_t flags);
56
86
 
75
105
    return 0;
76
106
  }
77
107
  virtual bool flush();
 
108
 
78
109
  virtual void prepare_for_resend()=0;
79
110
 
80
111
  virtual bool store_null()=0;
109
140
 
110
141
class Protocol_text :public Protocol
111
142
{
 
143
private:
 
144
  struct rand_struct _rand;
 
145
  char _scramble[SCRAMBLE_LENGTH+1];
 
146
 
 
147
  /**
 
148
   * Performs handshake with client and authorizes user.
 
149
   *
 
150
   * Returns true is the connection is valid and the
 
151
   * user is authorized, otherwise false.
 
152
   */  
 
153
  bool _check_connection(void);
 
154
 
112
155
public:
113
 
  Protocol_text() {}
 
156
  Protocol_text() { _scramble[0]= 0; }
114
157
  Protocol_text(Session *session_arg) :Protocol(session_arg) {}
 
158
  virtual bool init_file_descriptor(int fd);
 
159
  virtual int file_descriptor(void);
 
160
  virtual void init_random(uint64_t seed1, uint64_t seed2);
 
161
  virtual bool authenticate(void);
 
162
  virtual bool read_command(char **packet, uint32_t *packet_length);
 
163
  virtual void send_error(uint32_t sql_errno, const char *err);
 
164
  virtual void send_error_packet(uint32_t sql_errno, const char *err);
 
165
  virtual void close(void);
115
166
  virtual void prepare_for_resend();
116
167
  virtual bool store(I_List<i_string> *str_list)
117
168
  {
151
202
  virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
152
203
};
153
204
 
154
 
void send_warning(Session *session, uint32_t sql_errno, const char *err=0);
155
 
void net_send_error(Session *session, uint32_t sql_errno=0, const char *err=0);
156
 
void drizzleclient_net_end_statement(Session *session);
157
 
unsigned char *net_store_data(unsigned char *to,const unsigned char *from, size_t length);
158
 
unsigned char *net_store_data(unsigned char *to,int32_t from);
159
 
unsigned char *net_store_data(unsigned char *to,int64_t from);
160
 
 
161
205
#endif /* DRIZZLED_PROTOCOL_H */