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 |
|
20 |
#ifdef USE_PRAGMA_INTERFACE
|
|
21 |
#pragma interface /* gcc class implementation */ |
|
22 |
#endif
|
|
23 |
||
24 |
||
25 |
class i_string; |
|
26 |
class THD; |
|
319.1.1
by Grant Limberg
renamed all instances of MYSQL_ to DRIZZLE_ |
27 |
typedef struct st_drizzle_field DRIZZLE_FIELD; |
28 |
typedef struct st_drizzle_rows DRIZZLE_ROWS; |
|
1
by brian
clean slate |
29 |
|
30 |
class Protocol |
|
31 |
{
|
|
32 |
protected: |
|
33 |
THD *thd; |
|
34 |
String *packet; |
|
35 |
String *convert; |
|
36 |
uint field_pos; |
|
37 |
uint field_count; |
|
38 |
bool net_store_data(const uchar *from, size_t length); |
|
39 |
bool net_store_data(const uchar *from, size_t length, |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
40 |
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
41 |
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. |
42 |
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs); |
1
by brian
clean slate |
43 |
public: |
44 |
Protocol() {} |
|
45 |
Protocol(THD *thd_arg) { init(thd_arg); } |
|
46 |
virtual ~Protocol() {} |
|
47 |
void init(THD* thd_arg); |
|
48 |
||
49 |
enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 }; |
|
50 |
virtual bool send_fields(List<Item> *list, uint flags); |
|
51 |
||
52 |
bool store(I_List<i_string> *str_list); |
|
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
53 |
bool store(const char *from, const CHARSET_INFO * const cs); |
1
by brian
clean slate |
54 |
String *storage_packet() { return packet; } |
55 |
inline void free() { packet->free(); } |
|
56 |
virtual bool write(); |
|
57 |
inline bool store(int from) |
|
152
by Brian Aker
longlong replacement |
58 |
{ return store_long((int64_t) from); } |
205
by Brian Aker
uint32 -> uin32_t |
59 |
inline bool store(uint32_t from) |
152
by Brian Aker
longlong replacement |
60 |
{ return store_long((int64_t) from); } |
61 |
inline bool store(int64_t from) |
|
62 |
{ return store_int64_t((int64_t) from, 0); } |
|
151
by Brian Aker
Ulonglong to uint64_t |
63 |
inline bool store(uint64_t from) |
152
by Brian Aker
longlong replacement |
64 |
{ return store_int64_t((int64_t) from, 1); } |
1
by brian
clean slate |
65 |
inline bool store(String *str) |
66 |
{ return store((char*) str->ptr(), str->length(), str->charset()); } |
|
67 |
||
68 |
virtual bool prepare_for_send(List<Item> *item_list) |
|
69 |
{
|
|
70 |
field_count=item_list->elements; |
|
71 |
return 0; |
|
72 |
}
|
|
73 |
virtual bool flush(); |
|
74 |
virtual void end_partial_result_set(THD *thd); |
|
75 |
virtual void prepare_for_resend()=0; |
|
76 |
||
77 |
virtual bool store_null()=0; |
|
152
by Brian Aker
longlong replacement |
78 |
virtual bool store_tiny(int64_t from)=0; |
79 |
virtual bool store_short(int64_t from)=0; |
|
80 |
virtual bool store_long(int64_t from)=0; |
|
81 |
virtual bool store_int64_t(int64_t from, bool unsigned_flag)=0; |
|
1
by brian
clean slate |
82 |
virtual bool store_decimal(const my_decimal *)=0; |
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
83 |
virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs)=0; |
1
by brian
clean slate |
84 |
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. |
85 |
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs)=0; |
205
by Brian Aker
uint32 -> uin32_t |
86 |
virtual bool store(float from, uint32_t decimals, String *buffer)=0; |
87 |
virtual bool store(double from, uint32_t decimals, String *buffer)=0; |
|
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
88 |
virtual bool store(DRIZZLE_TIME *time)=0; |
89 |
virtual bool store_date(DRIZZLE_TIME *time)=0; |
|
90 |
virtual bool store_time(DRIZZLE_TIME *time)=0; |
|
1
by brian
clean slate |
91 |
virtual bool store(Field *field)=0; |
92 |
void remove_last_row() {} |
|
93 |
enum enum_protocol_type |
|
94 |
{
|
|
95 |
PROTOCOL_TEXT= 0, PROTOCOL_BINARY= 1 |
|
96 |
/*
|
|
97 |
before adding here or change the values, consider that it is cast to a
|
|
98 |
bit in sql_cache.cc.
|
|
99 |
*/
|
|
100 |
};
|
|
101 |
virtual enum enum_protocol_type type()= 0; |
|
102 |
};
|
|
103 |
||
104 |
||
105 |
/** Class used for the old (MySQL 4.0 protocol). */
|
|
106 |
||
107 |
class Protocol_text :public Protocol |
|
108 |
{
|
|
109 |
public: |
|
110 |
Protocol_text() {} |
|
111 |
Protocol_text(THD *thd_arg) :Protocol(thd_arg) {} |
|
112 |
virtual void prepare_for_resend(); |
|
113 |
virtual bool store_null(); |
|
152
by Brian Aker
longlong replacement |
114 |
virtual bool store_tiny(int64_t from); |
115 |
virtual bool store_short(int64_t from); |
|
116 |
virtual bool store_long(int64_t from); |
|
117 |
virtual bool store_int64_t(int64_t from, bool unsigned_flag); |
|
1
by brian
clean slate |
118 |
virtual bool store_decimal(const my_decimal *); |
264.2.6
by Andrey Hristov
Constify the usage of CHARSET_INFO almost to the last place in the code. |
119 |
virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs); |
1
by brian
clean slate |
120 |
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. |
121 |
const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs); |
236.1.24
by Monty Taylor
Renamed MYSQL_TIME to DRIZZLE_TIME. |
122 |
virtual bool store(DRIZZLE_TIME *time); |
123 |
virtual bool store_date(DRIZZLE_TIME *time); |
|
124 |
virtual bool store_time(DRIZZLE_TIME *time); |
|
205
by Brian Aker
uint32 -> uin32_t |
125 |
virtual bool store(float nr, uint32_t decimals, String *buffer); |
126 |
virtual bool store(double from, uint32_t decimals, String *buffer); |
|
1
by brian
clean slate |
127 |
virtual bool store(Field *field); |
128 |
virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; }; |
|
129 |
};
|
|
130 |
||
131 |
void send_warning(THD *thd, uint sql_errno, const char *err=0); |
|
132 |
void net_send_error(THD *thd, uint sql_errno=0, const char *err=0); |
|
133 |
void net_end_statement(THD *thd); |
|
134 |
uchar *net_store_data(uchar *to,const uchar *from, size_t length); |
|
205
by Brian Aker
uint32 -> uin32_t |
135 |
uchar *net_store_data(uchar *to,int32_t from); |
152
by Brian Aker
longlong replacement |
136 |
uchar *net_store_data(uchar *to,int64_t from); |
1
by brian
clean slate |
137 |