~drizzle-trunk/drizzle/development

390.1.2 by Monty Taylor
Fixed copyright headers in drizzled/
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
 */
1 by brian
clean slate
19
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
20
#ifndef DRIZZLED_PROTOCOL_H
21
#define DRIZZLED_PROTOCOL_H
1 by brian
clean slate
22
584.1.14 by Monty Taylor
Removed field.h from common_includes.
23
#include <drizzled/sql_list.h>
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
24
#include <drizzled/item.h>
584.1.14 by Monty Taylor
Removed field.h from common_includes.
25
584.1.15 by Monty Taylor
The mega-patch from hell. Renamed sql_class to session (since that's what it is) and removed it and field and table from common_includes.
26
class Field;
584.1.14 by Monty Taylor
Removed field.h from common_includes.
27
class String;
1 by brian
clean slate
28
class i_string;
520.1.21 by Brian Aker
THD -> Session rename
29
class Session;
584.1.14 by Monty Taylor
Removed field.h from common_includes.
30
class my_decimal;
319.1.1 by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_
31
typedef struct st_drizzle_field DRIZZLE_FIELD;
32
typedef struct st_drizzle_rows DRIZZLE_ROWS;
584.1.14 by Monty Taylor
Removed field.h from common_includes.
33
typedef struct st_drizzle_time DRIZZLE_TIME;
1 by brian
clean slate
34
35
class Protocol
36
{
37
protected:
520.1.22 by Brian Aker
Second pass of thd cleanup
38
  Session	 *session;
1 by brian
clean slate
39
  String *packet;
40
  String *convert;
482 by Brian Aker
Remove uint.
41
  uint32_t field_pos;
42
  uint32_t field_count;
481 by Brian Aker
Remove all of uchar.
43
  bool net_store_data(const unsigned char *from, size_t length);
44
  bool net_store_data(const unsigned char *from, size_t length,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
45
                      const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
1 by brian
clean slate
46
  bool store_string_aux(const char *from, size_t length,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
47
                        const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
1 by brian
clean slate
48
public:
49
  Protocol() {}
520.1.22 by Brian Aker
Second pass of thd cleanup
50
  Protocol(Session *session_arg) { init(session_arg); }
1 by brian
clean slate
51
  virtual ~Protocol() {}
520.1.22 by Brian Aker
Second pass of thd cleanup
52
  void init(Session* session_arg);
1 by brian
clean slate
53
54
  enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
482 by Brian Aker
Remove uint.
55
  virtual bool send_fields(List<Item> *list, uint32_t flags);
1 by brian
clean slate
56
779.3.16 by Monty Taylor
Some Sun warning fixes.
57
  virtual bool store(I_List<i_string> *str_list);
58
  virtual bool store(const char *from, const CHARSET_INFO * const cs);
1 by brian
clean slate
59
  String *storage_packet() { return packet; }
584.1.14 by Monty Taylor
Removed field.h from common_includes.
60
  void free();
1 by brian
clean slate
61
  virtual bool write();
779.3.16 by Monty Taylor
Some Sun warning fixes.
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)
152 by Brian Aker
longlong replacement
67
  { return store_int64_t((int64_t) from, 0); }
779.3.16 by Monty Taylor
Some Sun warning fixes.
68
  virtual bool store(uint64_t from)
152 by Brian Aker
longlong replacement
69
  { return store_int64_t((int64_t) from, 1); }
779.3.16 by Monty Taylor
Some Sun warning fixes.
70
  virtual bool store(String *str);
1 by brian
clean slate
71
584.1.14 by Monty Taylor
Removed field.h from common_includes.
72
  virtual bool prepare_for_send(List<Item> *item_list)
1 by brian
clean slate
73
  {
74
    field_count=item_list->elements;
75
    return 0;
76
  }
77
  virtual bool flush();
78
  virtual void prepare_for_resend()=0;
79
80
  virtual bool store_null()=0;
152 by Brian Aker
longlong replacement
81
  virtual bool store_tiny(int64_t from)=0;
82
  virtual bool store_short(int64_t from)=0;
83
  virtual bool store_long(int64_t from)=0;
84
  virtual bool store_int64_t(int64_t from, bool unsigned_flag)=0;
584.1.14 by Monty Taylor
Removed field.h from common_includes.
85
  virtual bool store_decimal(const my_decimal * dec_value)=0;
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
86
  virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs)=0;
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
87
  virtual bool store(const char *from, size_t length,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
88
                     const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs)=0;
205 by Brian Aker
uint32 -> uin32_t
89
  virtual bool store(float from, uint32_t decimals, String *buffer)=0;
90
  virtual bool store(double from, uint32_t decimals, String *buffer)=0;
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
91
  virtual bool store(DRIZZLE_TIME *time)=0;
92
  virtual bool store_date(DRIZZLE_TIME *time)=0;
93
  virtual bool store_time(DRIZZLE_TIME *time)=0;
1 by brian
clean slate
94
  virtual bool store(Field *field)=0;
95
  void remove_last_row() {}
96
  enum enum_protocol_type
97
  {
98
    PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1
99
    /*
100
      before adding here or change the values, consider that it is cast to a
101
      bit in sql_cache.cc.
102
    */
103
  };
104
  virtual enum enum_protocol_type type()= 0;
105
};
106
107
108
/** Class used for the old (MySQL 4.0 protocol). */
109
110
class Protocol_text :public Protocol
111
{
112
public:
113
  Protocol_text() {}
520.1.22 by Brian Aker
Second pass of thd cleanup
114
  Protocol_text(Session *session_arg) :Protocol(session_arg) {}
1 by brian
clean slate
115
  virtual void prepare_for_resend();
779.3.16 by Monty Taylor
Some Sun warning fixes.
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
  }
1 by brian
clean slate
124
  virtual bool store_null();
152 by Brian Aker
longlong replacement
125
  virtual bool store_tiny(int64_t from);
126
  virtual bool store_short(int64_t from);
127
  virtual bool store_long(int64_t from);
128
  virtual bool store_int64_t(int64_t from, bool unsigned_flag);
1 by brian
clean slate
129
  virtual bool store_decimal(const my_decimal *);
779.3.16 by Monty Taylor
Some Sun warning fixes.
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
  }
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
142
  virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs);
1 by brian
clean slate
143
  virtual bool store(const char *from, size_t length,
264.2.6 by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code.
144
                     const CHARSET_INFO * const fromcs,  const CHARSET_INFO * const tocs);
236.1.24 by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME.
145
  virtual bool store(DRIZZLE_TIME *time);
146
  virtual bool store_date(DRIZZLE_TIME *time);
147
  virtual bool store_time(DRIZZLE_TIME *time);
205 by Brian Aker
uint32 -> uin32_t
148
  virtual bool store(float nr, uint32_t decimals, String *buffer);
149
  virtual bool store(double from, uint32_t decimals, String *buffer);
1 by brian
clean slate
150
  virtual bool store(Field *field);
151
  virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
152
};
153
520.1.22 by Brian Aker
Second pass of thd cleanup
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);
840.1.20 by Monty Taylor
Renamed non-prefixed things from libdrizzleclient to drizzleclient.
156
void drizzleclient_net_end_statement(Session *session);
481 by Brian Aker
Remove all of uchar.
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);
1 by brian
clean slate
160
575.1.6 by Monty Taylor
Cleaned up some headers for PCH.
161
#endif /* DRIZZLED_PROTOCOL_H */