1/*
2Copyright (c) 2007, Antony T Curtis
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are
7met:
8
9 * Redistributions of source code must retain the above copyright
10notice, this list of conditions and the following disclaimer.
11
12 * Neither the name of FederatedX nor the names of its
13contributors may be used to endorse or promote products derived from
14this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27*/
28
29
30/*#define MYSQL_SERVER 1*/
31#include <my_global.h>
32#include "sql_priv.h"
33
34#include "ha_federatedx.h"
35
36#include "m_string.h"
37
38#ifdef USE_PRAGMA_IMPLEMENTATION
39#pragma implementation // gcc: Class implementation
40#endif
41
42
43#define SAVEPOINT_REALIZED 1
44#define SAVEPOINT_RESTRICT 2
45#define SAVEPOINT_EMITTED 4
46
47
48typedef struct federatedx_savepoint
49{
50 ulong level;
51 uint flags;
52} SAVEPT;
53
54
55class federatedx_io_null :public federatedx_io
56{
57public:
58 federatedx_io_null(FEDERATEDX_SERVER *);
59 ~federatedx_io_null();
60
61 int query(const char *buffer, size_t length);
62 virtual FEDERATEDX_IO_RESULT *store_result();
63
64 virtual size_t max_query_size() const;
65
66 virtual my_ulonglong affected_rows() const;
67 virtual my_ulonglong last_insert_id() const;
68
69 virtual int error_code();
70 virtual const char *error_str();
71
72 void reset();
73 int commit();
74 int rollback();
75
76 int savepoint_set(ulong sp);
77 ulong savepoint_release(ulong sp);
78 ulong savepoint_rollback(ulong sp);
79 void savepoint_restrict(ulong sp);
80
81 ulong last_savepoint() const;
82 ulong actual_savepoint() const;
83 bool is_autocommit() const;
84
85 bool table_metadata(ha_statistics *stats, const char *table_name,
86 uint table_name_length, uint flag);
87
88 /* resultset operations */
89
90 virtual void free_result(FEDERATEDX_IO_RESULT *io_result);
91 virtual unsigned int get_num_fields(FEDERATEDX_IO_RESULT *io_result);
92 virtual my_ulonglong get_num_rows(FEDERATEDX_IO_RESULT *io_result);
93 virtual FEDERATEDX_IO_ROW *fetch_row(FEDERATEDX_IO_RESULT *io_result);
94 virtual ulong *fetch_lengths(FEDERATEDX_IO_RESULT *io_result);
95 virtual const char *get_column_data(FEDERATEDX_IO_ROW *row,
96 unsigned int column);
97 virtual bool is_column_null(const FEDERATEDX_IO_ROW *row,
98 unsigned int column) const;
99 virtual size_t get_ref_length() const;
100 virtual void mark_position(FEDERATEDX_IO_RESULT *io_result,
101 void *ref);
102 virtual int seek_position(FEDERATEDX_IO_RESULT **io_result,
103 const void *ref);
104};
105
106
107federatedx_io *instantiate_io_null(MEM_ROOT *server_root,
108 FEDERATEDX_SERVER *server)
109{
110 return new (server_root) federatedx_io_null(server);
111}
112
113
114federatedx_io_null::federatedx_io_null(FEDERATEDX_SERVER *aserver)
115 : federatedx_io(aserver)
116{
117}
118
119
120federatedx_io_null::~federatedx_io_null()
121{
122}
123
124
125void federatedx_io_null::reset()
126{
127}
128
129
130int federatedx_io_null::commit()
131{
132 return 0;
133}
134
135int federatedx_io_null::rollback()
136{
137 return 0;
138}
139
140
141ulong federatedx_io_null::last_savepoint() const
142{
143 return 0;
144}
145
146
147ulong federatedx_io_null::actual_savepoint() const
148{
149 return 0;
150}
151
152bool federatedx_io_null::is_autocommit() const
153{
154 return 0;
155}
156
157
158int federatedx_io_null::savepoint_set(ulong sp)
159{
160 return 0;
161}
162
163
164ulong federatedx_io_null::savepoint_release(ulong sp)
165{
166 return 0;
167}
168
169
170ulong federatedx_io_null::savepoint_rollback(ulong sp)
171{
172 return 0;
173}
174
175
176void federatedx_io_null::savepoint_restrict(ulong sp)
177{
178}
179
180
181int federatedx_io_null::query(const char *buffer, size_t length)
182{
183 return 0;
184}
185
186
187size_t federatedx_io_null::max_query_size() const
188{
189 return INT_MAX;
190}
191
192
193my_ulonglong federatedx_io_null::affected_rows() const
194{
195 return 0;
196}
197
198
199my_ulonglong federatedx_io_null::last_insert_id() const
200{
201 return 0;
202}
203
204
205int federatedx_io_null::error_code()
206{
207 return 0;
208}
209
210
211const char *federatedx_io_null::error_str()
212{
213 return "";
214}
215
216
217FEDERATEDX_IO_RESULT *federatedx_io_null::store_result()
218{
219 FEDERATEDX_IO_RESULT *result;
220 DBUG_ENTER("federatedx_io_null::store_result");
221
222 result= NULL;
223
224 DBUG_RETURN(result);
225}
226
227
228void federatedx_io_null::free_result(FEDERATEDX_IO_RESULT *)
229{
230}
231
232
233unsigned int federatedx_io_null::get_num_fields(FEDERATEDX_IO_RESULT *)
234{
235 return 0;
236}
237
238
239my_ulonglong federatedx_io_null::get_num_rows(FEDERATEDX_IO_RESULT *)
240{
241 return 0;
242}
243
244
245FEDERATEDX_IO_ROW *federatedx_io_null::fetch_row(FEDERATEDX_IO_RESULT *)
246{
247 return NULL;
248}
249
250
251ulong *federatedx_io_null::fetch_lengths(FEDERATEDX_IO_RESULT *)
252{
253 return NULL;
254}
255
256
257const char *federatedx_io_null::get_column_data(FEDERATEDX_IO_ROW *,
258 unsigned int)
259{
260 return "";
261}
262
263
264bool federatedx_io_null::is_column_null(const FEDERATEDX_IO_ROW *,
265 unsigned int) const
266{
267 return true;
268}
269
270bool federatedx_io_null::table_metadata(ha_statistics *stats,
271 const char *table_name,
272 uint table_name_length, uint flag)
273{
274 stats->records= (ha_rows) 0;
275 stats->mean_rec_length= (ulong) 0;
276 stats->data_file_length= 0;
277
278 stats->update_time= (time_t) 0;
279 stats->check_time= (time_t) 0;
280
281 return 0;
282}
283
284size_t federatedx_io_null::get_ref_length() const
285{
286 return sizeof(int);
287}
288
289
290void federatedx_io_null::mark_position(FEDERATEDX_IO_RESULT *io_result,
291 void *ref)
292{
293}
294
295int federatedx_io_null::seek_position(FEDERATEDX_IO_RESULT **io_result,
296 const void *ref)
297{
298 return 0;
299}
300