~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/protocol.h

  • Committer: Monty Taylor
  • Date: 2009-01-30 21:02:37 UTC
  • mto: (779.7.3 devel)
  • mto: This revision was merged to the branch mainline in revision 823.
  • Revision ID: mordred@inaugust.com-20090130210237-3n6ld8a9jc084jko
Commented out a test in subselect_sj - I think it might be a regression. Jay?

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2002-2006 MySQL AB
2
 
 
3
 
   This program is free software; you can redistribute it and/or modify
4
 
   it under the terms of the GNU General Public License as published by
5
 
   the Free Software Foundation; version 2 of the License.
6
 
 
7
 
   This program is distributed in the hope that it will be useful,
8
 
   but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10
 
   GNU General Public License for more details.
11
 
 
12
 
   You should have received a copy of the GNU General Public License
13
 
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
 
 
16
 
#ifdef USE_PRAGMA_INTERFACE
17
 
#pragma interface                       /* gcc class implementation */
18
 
#endif
19
 
 
20
 
 
 
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
 
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
 
3
 *
 
4
 *  Copyright (C) 2008 Sun Microsystems
 
5
 *
 
6
 *  This program is free software; you can redistribute it and/or modify
 
7
 *  it under the terms of the GNU General Public License as published by
 
8
 *  the Free Software Foundation; version 2 of the License.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
18
 */
 
19
 
 
20
#ifndef DRIZZLED_PROTOCOL_H
 
21
#define DRIZZLED_PROTOCOL_H
 
22
 
 
23
#include <drizzled/sql_list.h>
 
24
#include <drizzled/item.h>
 
25
 
 
26
class Field;
 
27
class String;
21
28
class i_string;
22
 
class THD;
 
29
class Session;
 
30
class my_decimal;
23
31
typedef struct st_drizzle_field DRIZZLE_FIELD;
24
32
typedef struct st_drizzle_rows DRIZZLE_ROWS;
 
33
typedef struct st_drizzle_time DRIZZLE_TIME;
25
34
 
26
35
class Protocol
27
36
{
28
37
protected:
29
 
  THD    *thd;
 
38
  Session        *session;
30
39
  String *packet;
31
40
  String *convert;
32
 
  uint field_pos;
33
 
  uint field_count;
34
 
  bool net_store_data(const uchar *from, size_t length);
35
 
  bool net_store_data(const uchar *from, size_t length,
 
41
  uint32_t field_pos;
 
42
  uint32_t field_count;
 
43
  bool net_store_data(const unsigned char *from, size_t length);
 
44
  bool net_store_data(const unsigned char *from, size_t length,
36
45
                      const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
37
46
  bool store_string_aux(const char *from, size_t length,
38
47
                        const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
39
48
public:
40
49
  Protocol() {}
41
 
  Protocol(THD *thd_arg) { init(thd_arg); }
 
50
  Protocol(Session *session_arg) { init(session_arg); }
42
51
  virtual ~Protocol() {}
43
 
  void init(THD* thd_arg);
 
52
  void init(Session* session_arg);
44
53
 
45
54
  enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
46
 
  virtual bool send_fields(List<Item> *list, uint flags);
 
55
  virtual bool send_fields(List<Item> *list, uint32_t flags);
47
56
 
48
 
  bool store(I_List<i_string> *str_list);
49
 
  bool store(const char *from, const CHARSET_INFO * const cs);
 
57
  virtual bool store(I_List<i_string> *str_list);
 
58
  virtual bool store(const char *from, const CHARSET_INFO * const cs);
50
59
  String *storage_packet() { return packet; }
51
 
  inline void free() { packet->free(); }
 
60
  void free();
52
61
  virtual bool write();
53
 
  inline  bool store(int from)
54
 
  { return store_long((int64_t) from); }
55
 
  inline  bool store(uint32_t from)
56
 
  { return store_long((int64_t) from); }
57
 
  inline  bool store(int64_t from)
 
62
  virtual bool store(int from)
 
63
  { return store_long((int64_t) from); }
 
64
  virtual  bool store(uint32_t from)
 
65
  { return store_long((int64_t) from); }
 
66
  virtual bool store(int64_t from)
58
67
  { return store_int64_t((int64_t) from, 0); }
59
 
  inline  bool store(uint64_t from)
 
68
  virtual bool store(uint64_t from)
60
69
  { return store_int64_t((int64_t) from, 1); }
61
 
  inline bool store(String *str)
62
 
  { return store((char*) str->ptr(), str->length(), str->charset()); }
 
70
  virtual bool store(String *str);
63
71
 
64
 
  virtual bool prepare_for_send(List<Item> *item_list) 
 
72
  virtual bool prepare_for_send(List<Item> *item_list)
65
73
  {
66
74
    field_count=item_list->elements;
67
75
    return 0;
68
76
  }
69
77
  virtual bool flush();
70
 
  virtual void end_partial_result_set(THD *thd);
71
78
  virtual void prepare_for_resend()=0;
72
79
 
73
80
  virtual bool store_null()=0;
75
82
  virtual bool store_short(int64_t from)=0;
76
83
  virtual bool store_long(int64_t from)=0;
77
84
  virtual bool store_int64_t(int64_t from, bool unsigned_flag)=0;
78
 
  virtual bool store_decimal(const my_decimal *)=0;
 
85
  virtual bool store_decimal(const my_decimal * dec_value)=0;
79
86
  virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs)=0;
80
 
  virtual bool store(const char *from, size_t length, 
 
87
  virtual bool store(const char *from, size_t length,
81
88
                     const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs)=0;
82
89
  virtual bool store(float from, uint32_t decimals, String *buffer)=0;
83
90
  virtual bool store(double from, uint32_t decimals, String *buffer)=0;
104
111
{
105
112
public:
106
113
  Protocol_text() {}
107
 
  Protocol_text(THD *thd_arg) :Protocol(thd_arg) {}
 
114
  Protocol_text(Session *session_arg) :Protocol(session_arg) {}
108
115
  virtual void prepare_for_resend();
 
116
  virtual bool store(I_List<i_string> *str_list)
 
117
  {
 
118
    return Protocol::store(str_list);
 
119
  }
 
120
  virtual bool store(const char *from, const CHARSET_INFO * const cs)
 
121
  {
 
122
    return Protocol::store(from, cs);
 
123
  }
109
124
  virtual bool store_null();
110
125
  virtual bool store_tiny(int64_t from);
111
126
  virtual bool store_short(int64_t from);
112
127
  virtual bool store_long(int64_t from);
113
128
  virtual bool store_int64_t(int64_t from, bool unsigned_flag);
114
129
  virtual bool store_decimal(const my_decimal *);
 
130
  virtual bool store(int from)
 
131
  { return store_long((int64_t) from); }
 
132
  virtual  bool store(uint32_t from)
 
133
  { return store_long((int64_t) from); }
 
134
  virtual bool store(int64_t from)
 
135
  { return store_int64_t((int64_t) from, 0); }
 
136
  virtual bool store(uint64_t from)
 
137
  { return store_int64_t((int64_t) from, 1); }
 
138
  virtual bool store(String *str)
 
139
  {
 
140
    return Protocol::store(str);
 
141
  }
115
142
  virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs);
116
143
  virtual bool store(const char *from, size_t length,
117
144
                     const CHARSET_INFO * const fromcs,  const CHARSET_INFO * const tocs);
124
151
  virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
125
152
};
126
153
 
127
 
void send_warning(THD *thd, uint sql_errno, const char *err=0);
128
 
void net_send_error(THD *thd, uint sql_errno=0, const char *err=0);
129
 
void net_end_statement(THD *thd);
130
 
uchar *net_store_data(uchar *to,const uchar *from, size_t length);
131
 
uchar *net_store_data(uchar *to,int32_t from);
132
 
uchar *net_store_data(uchar *to,int64_t from);
 
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 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);
133
160
 
 
161
#endif /* DRIZZLED_PROTOCOL_H */