~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/protocol.h

  • Committer: Mark Atwood
  • Date: 2008-07-12 07:25:25 UTC
  • mto: This revision was merged to the branch mainline in revision 139.
  • Revision ID: me@mark.atwood.name-20080712072525-s1dq9mtwo5td7af7
more hackery to get plugin UDFs working

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
/* 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 */
19
15
 
20
16
#ifdef USE_PRAGMA_INTERFACE
21
17
#pragma interface                       /* gcc class implementation */
24
20
 
25
21
class i_string;
26
22
class THD;
27
 
typedef struct st_drizzle_field DRIZZLE_FIELD;
28
 
typedef struct st_drizzle_rows DRIZZLE_ROWS;
 
23
typedef struct st_mysql_field MYSQL_FIELD;
 
24
typedef struct st_mysql_rows MYSQL_ROWS;
29
25
 
30
26
class Protocol
31
27
{
33
29
  THD    *thd;
34
30
  String *packet;
35
31
  String *convert;
36
 
  uint32_t field_pos;
37
 
  uint32_t field_count;
38
 
  bool net_store_data(const unsigned char *from, size_t length);
39
 
  bool net_store_data(const unsigned char *from, size_t length,
40
 
                      const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
 
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,
 
36
                      CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
41
37
  bool store_string_aux(const char *from, size_t length,
42
 
                        const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs);
 
38
                        CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
43
39
public:
44
40
  Protocol() {}
45
41
  Protocol(THD *thd_arg) { init(thd_arg); }
47
43
  void init(THD* thd_arg);
48
44
 
49
45
  enum { SEND_NUM_ROWS= 1, SEND_DEFAULTS= 2, SEND_EOF= 4 };
50
 
  virtual bool send_fields(List<Item> *list, uint32_t flags);
 
46
  virtual bool send_fields(List<Item> *list, uint flags);
51
47
 
52
48
  bool store(I_List<i_string> *str_list);
53
 
  bool store(const char *from, const CHARSET_INFO * const cs);
 
49
  bool store(const char *from, CHARSET_INFO *cs);
54
50
  String *storage_packet() { return packet; }
55
51
  inline void free() { packet->free(); }
56
52
  virtual bool write();
57
53
  inline  bool store(int from)
58
 
  { return store_long((int64_t) from); }
59
 
  inline  bool store(uint32_t from)
60
 
  { return store_long((int64_t) from); }
61
 
  inline  bool store(int64_t from)
62
 
  { return store_int64_t((int64_t) from, 0); }
63
 
  inline  bool store(uint64_t from)
64
 
  { return store_int64_t((int64_t) from, 1); }
 
54
  { return store_long((longlong) from); }
 
55
  inline  bool store(uint32 from)
 
56
  { return store_long((longlong) from); }
 
57
  inline  bool store(longlong from)
 
58
  { return store_longlong((longlong) from, 0); }
 
59
  inline  bool store(ulonglong from)
 
60
  { return store_longlong((longlong) from, 1); }
65
61
  inline bool store(String *str)
66
62
  { return store((char*) str->ptr(), str->length(), str->charset()); }
67
63
 
75
71
  virtual void prepare_for_resend()=0;
76
72
 
77
73
  virtual bool store_null()=0;
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;
 
74
  virtual bool store_tiny(longlong from)=0;
 
75
  virtual bool store_short(longlong from)=0;
 
76
  virtual bool store_long(longlong from)=0;
 
77
  virtual bool store_longlong(longlong from, bool unsigned_flag)=0;
82
78
  virtual bool store_decimal(const my_decimal *)=0;
83
 
  virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs)=0;
 
79
  virtual bool store(const char *from, size_t length, CHARSET_INFO *cs)=0;
84
80
  virtual bool store(const char *from, size_t length, 
85
 
                     const CHARSET_INFO * const fromcs, const CHARSET_INFO * const tocs)=0;
86
 
  virtual bool store(float from, uint32_t decimals, String *buffer)=0;
87
 
  virtual bool store(double from, uint32_t decimals, String *buffer)=0;
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;
 
81
                     CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0;
 
82
  virtual bool store(float from, uint32 decimals, String *buffer)=0;
 
83
  virtual bool store(double from, uint32 decimals, String *buffer)=0;
 
84
  virtual bool store(MYSQL_TIME *time)=0;
 
85
  virtual bool store_date(MYSQL_TIME *time)=0;
 
86
  virtual bool store_time(MYSQL_TIME *time)=0;
91
87
  virtual bool store(Field *field)=0;
92
88
  void remove_last_row() {}
93
89
  enum enum_protocol_type
111
107
  Protocol_text(THD *thd_arg) :Protocol(thd_arg) {}
112
108
  virtual void prepare_for_resend();
113
109
  virtual bool store_null();
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);
 
110
  virtual bool store_tiny(longlong from);
 
111
  virtual bool store_short(longlong from);
 
112
  virtual bool store_long(longlong from);
 
113
  virtual bool store_longlong(longlong from, bool unsigned_flag);
118
114
  virtual bool store_decimal(const my_decimal *);
119
 
  virtual bool store(const char *from, size_t length, const CHARSET_INFO * const cs);
 
115
  virtual bool store(const char *from, size_t length, CHARSET_INFO *cs);
120
116
  virtual bool store(const char *from, size_t length,
121
 
                     const CHARSET_INFO * const fromcs,  const CHARSET_INFO * const tocs);
122
 
  virtual bool store(DRIZZLE_TIME *time);
123
 
  virtual bool store_date(DRIZZLE_TIME *time);
124
 
  virtual bool store_time(DRIZZLE_TIME *time);
125
 
  virtual bool store(float nr, uint32_t decimals, String *buffer);
126
 
  virtual bool store(double from, uint32_t decimals, String *buffer);
 
117
                     CHARSET_INFO *fromcs, CHARSET_INFO *tocs);
 
118
  virtual bool store(MYSQL_TIME *time);
 
119
  virtual bool store_date(MYSQL_TIME *time);
 
120
  virtual bool store_time(MYSQL_TIME *time);
 
121
  virtual bool store(float nr, uint32 decimals, String *buffer);
 
122
  virtual bool store(double from, uint32 decimals, String *buffer);
127
123
  virtual bool store(Field *field);
128
124
  virtual enum enum_protocol_type type() { return PROTOCOL_TEXT; };
129
125
};
130
126
 
131
 
void send_warning(THD *thd, uint32_t sql_errno, const char *err=0);
132
 
void net_send_error(THD *thd, uint32_t sql_errno=0, const char *err=0);
 
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);
133
129
void net_end_statement(THD *thd);
134
 
unsigned char *net_store_data(unsigned char *to,const unsigned char *from, size_t length);
135
 
unsigned char *net_store_data(unsigned char *to,int32_t from);
136
 
unsigned char *net_store_data(unsigned char *to,int64_t from);
 
130
uchar *net_store_data(uchar *to,const uchar *from, size_t length);
 
131
uchar *net_store_data(uchar *to,int32 from);
 
132
uchar *net_store_data(uchar *to,longlong from);
137
133