2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1 |
/*
|
2 |
* Drizzle Client & Protocol Library
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Eric Day (eday@oddments.org)
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
7 |
* Redistribution and use in source and binary forms, with or without
|
|
8 |
* modification, are permitted provided that the following conditions are
|
|
9 |
* met:
|
|
10 |
*
|
|
11 |
* * Redistributions of source code must retain the above copyright
|
|
12 |
* notice, this list of conditions and the following disclaimer.
|
|
13 |
*
|
|
14 |
* * Redistributions in binary form must reproduce the above
|
|
15 |
* copyright notice, this list of conditions and the following disclaimer
|
|
16 |
* in the documentation and/or other materials provided with the
|
|
17 |
* distribution.
|
|
18 |
*
|
|
19 |
* * The names of its contributors may not be used to endorse or
|
|
20 |
* promote products derived from this software without specific prior
|
|
21 |
* written permission.
|
|
22 |
*
|
|
23 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
24 |
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
25 |
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
26 |
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
27 |
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
28 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
29 |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
30 |
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
31 |
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
32 |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
33 |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
34 |
*
|
|
35 |
*/
|
|
36 |
||
37 |
||
38 |
/**
|
|
39 |
* @file
|
|
40 |
* @brief Column definitions
|
|
41 |
*/
|
|
42 |
||
2449.1.2
by Brian Aker
Additional fixes for libdrizzle. |
43 |
#include <libdrizzle-2.0/common.h> |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
44 |
|
45 |
/*
|
|
46 |
* Private variables.
|
|
47 |
*/
|
|
48 |
||
49 |
static drizzle_column_type_t _column_type_drizzle_map_to[]= |
|
50 |
{
|
|
51 |
DRIZZLE_COLUMN_TYPE_TINY, |
|
52 |
DRIZZLE_COLUMN_TYPE_LONG, |
|
53 |
DRIZZLE_COLUMN_TYPE_DOUBLE, |
|
54 |
DRIZZLE_COLUMN_TYPE_NULL, |
|
55 |
DRIZZLE_COLUMN_TYPE_TIMESTAMP, |
|
56 |
DRIZZLE_COLUMN_TYPE_LONGLONG, |
|
57 |
DRIZZLE_COLUMN_TYPE_DATETIME, |
|
58 |
DRIZZLE_COLUMN_TYPE_NEWDATE, |
|
59 |
DRIZZLE_COLUMN_TYPE_VARCHAR, |
|
60 |
DRIZZLE_COLUMN_TYPE_NEWDECIMAL, |
|
61 |
DRIZZLE_COLUMN_TYPE_ENUM, |
|
62 |
DRIZZLE_COLUMN_TYPE_BLOB
|
|
63 |
};
|
|
64 |
||
65 |
static drizzle_column_type_drizzle_t _column_type_drizzle_map_from[]= |
|
66 |
{
|
|
67 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 0 */ |
|
68 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN, |
|
69 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
70 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG, |
|
71 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
72 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE, |
|
73 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL, |
|
74 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP, |
|
75 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG, |
|
76 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
77 |
||
78 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 10 */ |
|
79 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
80 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME, |
|
81 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
82 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE, |
|
83 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR, |
|
84 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
85 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
86 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
87 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
88 |
||
89 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 20 */ |
|
90 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
91 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
92 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
93 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
94 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
95 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
96 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
97 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
98 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
99 |
||
100 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 30 */ |
|
101 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
102 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
103 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
104 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
105 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
106 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
107 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
108 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
109 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
110 |
||
111 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 40 */ |
|
112 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
113 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
114 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
115 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
116 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
117 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
118 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
119 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
120 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
121 |
||
122 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 50 */ |
|
123 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
124 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
125 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
126 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
127 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
128 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
129 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
130 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
131 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
132 |
||
133 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 60 */ |
|
134 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
135 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
136 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
137 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
138 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
139 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
140 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
141 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
142 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
143 |
||
144 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 70 */ |
|
145 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
146 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
147 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
148 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
149 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
150 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
151 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
152 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
153 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
154 |
||
155 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 80 */ |
|
156 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
157 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
158 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
159 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
160 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
161 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
162 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
163 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
164 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
165 |
||
166 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 90 */ |
|
167 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
168 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
169 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
170 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
171 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
172 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
173 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
174 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
175 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
176 |
||
177 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 100 */ |
|
178 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
179 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
180 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
181 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
182 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
183 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
184 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
185 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
186 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
187 |
||
188 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 110 */ |
|
189 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
190 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
191 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
192 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
193 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
194 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
195 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
196 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
197 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
198 |
||
199 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 120 */ |
|
200 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
201 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
202 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
203 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
204 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
205 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
206 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
207 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
208 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
209 |
||
210 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 130 */ |
|
211 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
212 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
213 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
214 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
215 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
216 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
217 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
218 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
219 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
220 |
||
221 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 140 */ |
|
222 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
223 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
224 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
225 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
226 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
227 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
228 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
229 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
230 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
231 |
||
232 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 150 */ |
|
233 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
234 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
235 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
236 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
237 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
238 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
239 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
240 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
241 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
242 |
||
243 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 160 */ |
|
244 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
245 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
246 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
247 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
248 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
249 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
250 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
251 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
252 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
253 |
||
254 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 170 */ |
|
255 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
256 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
257 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
258 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
259 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
260 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
261 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
262 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
263 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
264 |
||
265 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 180 */ |
|
266 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
267 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
268 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
269 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
270 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
271 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
272 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
273 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
274 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
275 |
||
276 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 190 */ |
|
277 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
278 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
279 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
280 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
281 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
282 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
283 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
284 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
285 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
286 |
||
287 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 200 */ |
|
288 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
289 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
290 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
291 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
292 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
293 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
294 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
295 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
296 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
297 |
||
298 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 210 */ |
|
299 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
300 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
301 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
302 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
303 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
304 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
305 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
306 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
307 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
308 |
||
309 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 220 */ |
|
310 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
311 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
312 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
313 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
314 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
315 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
316 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
317 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
318 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
319 |
||
320 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 230 */ |
|
321 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
322 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
323 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
324 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
325 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
326 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
327 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
328 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
329 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
330 |
||
331 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 240 */ |
|
332 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
333 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
334 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
335 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
336 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
337 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_NEWDECIMAL, |
|
338 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM, |
|
339 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
340 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
341 |
||
342 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, /* 250 */ |
|
343 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
344 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB, |
|
345 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
346 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX, |
|
347 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX
|
|
348 |
};
|
|
349 |
||
350 |
/*
|
|
351 |
* Common definitions
|
|
352 |
*/
|
|
353 |
||
354 |
drizzle_column_st *drizzle_column_create(drizzle_result_st *result, |
|
355 |
drizzle_column_st *column) |
|
356 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
357 |
if (result == NULL) |
358 |
{
|
|
359 |
return NULL; |
|
360 |
}
|
|
361 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
362 |
if (column == NULL) |
363 |
{
|
|
2461.1.2
by Brian Aker
Pass through refactoring. |
364 |
column= new (std::nothrow) drizzle_column_st; |
365 |
||
366 |
if (column == NULL) |
|
367 |
{
|
|
368 |
return NULL; |
|
369 |
}
|
|
370 |
||
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
371 |
column->result= result; |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
372 |
/* SET BELOW: column->next */
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
373 |
column->prev= NULL; |
2461.1.4
by Brian Aker
More updates to libdrizzle-2.0 |
374 |
column->options.is_allocated= true; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
375 |
column->catalog[0]= '\0'; |
376 |
column->schema[0]= '\0'; |
|
377 |
column->table[0]= '\0'; |
|
378 |
column->orig_table[0]= '\0'; |
|
379 |
column->name[0]= '\0'; |
|
380 |
column->orig_name[0]= '\0'; |
|
381 |
column->charset= 0; |
|
382 |
column->size= 0; |
|
383 |
column->max_size= 0; |
|
384 |
column->type= static_cast<drizzle_column_type_t>(0); |
|
385 |
column->flags= drizzle_column_flags_t(); |
|
386 |
column->decimals= 0; |
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
387 |
/* UNSET: column->default_value */
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
388 |
column->default_value_size= 0; |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
389 |
}
|
390 |
else
|
|
391 |
{
|
|
392 |
column->result = result; |
|
393 |
/* SET BELOW: column->next */
|
|
394 |
column->prev = NULL; |
|
2461.1.4
by Brian Aker
More updates to libdrizzle-2.0 |
395 |
column->options.is_allocated= false; |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
396 |
column->catalog[0] = '\0'; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
397 |
column->schema[0] = '\0'; |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
398 |
column->table[0] = '\0'; |
399 |
column->orig_table[0] = '\0'; |
|
400 |
column->name[0] = '\0'; |
|
401 |
column->orig_name[0] = '\0'; |
|
402 |
column->charset = 0; |
|
403 |
column->size = 0; |
|
404 |
column->max_size = 0; |
|
405 |
column->type = static_cast<drizzle_column_type_t>(0); |
|
2449.1.2
by Brian Aker
Additional fixes for libdrizzle. |
406 |
column->flags = drizzle_column_flags_t(); |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
407 |
column->decimals = 0; |
408 |
/* UNSET: column->default_value */
|
|
409 |
column->default_value_size = 0; |
|
410 |
}
|
|
411 |
||
412 |
column->result= result; |
|
413 |
||
414 |
if (result->column_list) |
|
415 |
result->column_list->prev= column; |
|
416 |
column->next= result->column_list; |
|
417 |
result->column_list= column; |
|
418 |
||
419 |
return column; |
|
420 |
}
|
|
421 |
||
422 |
void drizzle_column_free(drizzle_column_st *column) |
|
423 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
424 |
if (column == NULL) |
425 |
{
|
|
426 |
return; |
|
427 |
}
|
|
428 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
429 |
if (column->result->column_list == column) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
430 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
431 |
column->result->column_list= column->next; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
432 |
}
|
433 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
434 |
if (column->prev) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
435 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
436 |
column->prev->next= column->next; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
437 |
}
|
438 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
439 |
if (column->next) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
440 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
441 |
column->next->prev= column->prev; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
442 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
443 |
|
2461.1.4
by Brian Aker
More updates to libdrizzle-2.0 |
444 |
if (column->options.is_allocated) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
445 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
446 |
delete column; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
447 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
448 |
}
|
449 |
||
450 |
drizzle_result_st *drizzle_column_drizzle_result(drizzle_column_st *column) |
|
451 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
452 |
if (column == NULL) |
453 |
{
|
|
454 |
return NULL; |
|
455 |
}
|
|
456 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
457 |
return column->result; |
458 |
}
|
|
459 |
||
460 |
const char *drizzle_column_catalog(drizzle_column_st *column) |
|
461 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
462 |
if (column == NULL) |
463 |
{
|
|
464 |
return NULL; |
|
465 |
}
|
|
466 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
467 |
return column->catalog; |
468 |
}
|
|
469 |
||
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
470 |
const char *drizzle_column_shema(drizzle_column_st *column) |
471 |
{
|
|
472 |
if (column == NULL) |
|
473 |
{
|
|
474 |
return NULL; |
|
475 |
}
|
|
476 |
||
477 |
return column->schema; |
|
478 |
}
|
|
479 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
480 |
const char *drizzle_column_db(drizzle_column_st *column) |
481 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
482 |
return drizzle_column_shema(column); |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
483 |
}
|
484 |
||
485 |
const char *drizzle_column_table(drizzle_column_st *column) |
|
486 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
487 |
if (column == NULL) |
488 |
{
|
|
489 |
return NULL; |
|
490 |
}
|
|
491 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
492 |
return column->table; |
493 |
}
|
|
494 |
||
495 |
const char *drizzle_column_orig_table(drizzle_column_st *column) |
|
496 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
497 |
if (column == NULL) |
498 |
{
|
|
499 |
return NULL; |
|
500 |
}
|
|
501 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
502 |
return column->orig_table; |
503 |
}
|
|
504 |
||
505 |
const char *drizzle_column_name(drizzle_column_st *column) |
|
506 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
507 |
if (column == NULL) |
508 |
{
|
|
509 |
return NULL; |
|
510 |
}
|
|
511 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
512 |
return column->name; |
513 |
}
|
|
514 |
||
515 |
const char *drizzle_column_orig_name(drizzle_column_st *column) |
|
516 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
517 |
if (column == NULL) |
518 |
{
|
|
519 |
return NULL; |
|
520 |
}
|
|
521 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
522 |
return column->orig_name; |
523 |
}
|
|
524 |
||
525 |
drizzle_charset_t drizzle_column_charset(drizzle_column_st *column) |
|
526 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
527 |
if (column == NULL) |
528 |
{
|
|
529 |
return 0; |
|
530 |
}
|
|
531 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
532 |
return column->charset; |
533 |
}
|
|
534 |
||
535 |
uint32_t drizzle_column_size(drizzle_column_st *column) |
|
536 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
537 |
if (column == NULL) |
538 |
{
|
|
539 |
return 0; |
|
540 |
}
|
|
541 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
542 |
return column->size; |
543 |
}
|
|
544 |
||
545 |
size_t drizzle_column_max_size(drizzle_column_st *column) |
|
546 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
547 |
if (column == NULL) |
548 |
{
|
|
549 |
return 0; |
|
550 |
}
|
|
551 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
552 |
return column->max_size; |
553 |
}
|
|
554 |
||
555 |
void drizzle_column_set_max_size(drizzle_column_st *column, size_t size) |
|
556 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
557 |
if (column == NULL) |
558 |
{
|
|
559 |
return; |
|
560 |
}
|
|
561 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
562 |
column->max_size= size; |
563 |
}
|
|
564 |
||
565 |
drizzle_column_type_t drizzle_column_type(drizzle_column_st *column) |
|
566 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
567 |
if (column == NULL) |
568 |
{
|
|
569 |
return drizzle_column_type_t(); |
|
570 |
}
|
|
571 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
572 |
return column->type; |
573 |
}
|
|
574 |
||
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
575 |
drizzle_column_type_drizzle_t drizzle_column_type_drizzle(drizzle_column_st *column) |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
576 |
{
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
577 |
if (column == NULL) |
578 |
{
|
|
579 |
return drizzle_column_type_drizzle_t(); |
|
580 |
}
|
|
581 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
582 |
return _column_type_drizzle_map_from[column->type]; |
583 |
}
|
|
584 |
||
585 |
int drizzle_column_flags(drizzle_column_st *column) |
|
586 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
587 |
if (column == NULL) |
588 |
{
|
|
589 |
return 0; |
|
590 |
}
|
|
591 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
592 |
return column->flags; |
593 |
}
|
|
594 |
||
595 |
uint8_t drizzle_column_decimals(drizzle_column_st *column) |
|
596 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
597 |
if (column == NULL) |
598 |
{
|
|
599 |
return 0; |
|
600 |
}
|
|
601 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
602 |
return column->decimals; |
603 |
}
|
|
604 |
||
605 |
const uint8_t *drizzle_column_default_value(drizzle_column_st *column, |
|
606 |
size_t *size) |
|
607 |
{
|
|
608 |
*size= column->default_value_size; |
|
609 |
return column->default_value; |
|
610 |
}
|
|
611 |
||
612 |
/*
|
|
613 |
* Client definitions
|
|
614 |
*/
|
|
615 |
||
616 |
drizzle_return_t drizzle_column_skip(drizzle_result_st *result) |
|
617 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
618 |
if (result == NULL) |
619 |
{
|
|
620 |
return DRIZZLE_RETURN_INVALID_ARGUMENT; |
|
621 |
}
|
|
622 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
623 |
if (drizzle_state_none(result->con)) |
624 |
{
|
|
625 |
result->options|= DRIZZLE_RESULT_SKIP_COLUMN; |
|
626 |
||
627 |
drizzle_state_push(result->con, drizzle_state_column_read); |
|
628 |
drizzle_state_push(result->con, drizzle_state_packet_read); |
|
629 |
}
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
630 |
drizzle_return_t ret= drizzle_state_loop(result->con); |
2367.1.1
by Andrew Hutchings
Push drizzle_column_skip fixes upstream |
631 |
result->options&= ~DRIZZLE_RESULT_SKIP_COLUMN; |
632 |
return ret; |
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
633 |
}
|
634 |
||
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
635 |
drizzle_return_t drizzle_column_skip_all(drizzle_result_st *result) |
636 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
637 |
if (result == NULL) |
638 |
{
|
|
639 |
return DRIZZLE_RETURN_INVALID_ARGUMENT; |
|
640 |
}
|
|
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
641 |
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
642 |
for (uint16_t it= 1; it <= result->column_count; it++) |
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
643 |
{
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
644 |
drizzle_return_t ret= drizzle_column_skip(result); |
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
645 |
if (ret != DRIZZLE_RETURN_OK) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
646 |
{
|
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
647 |
return ret; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
648 |
}
|
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
649 |
}
|
650 |
||
651 |
return DRIZZLE_RETURN_OK; |
|
652 |
}
|
|
653 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
654 |
drizzle_column_st *drizzle_column_read(drizzle_result_st *result, |
655 |
drizzle_column_st *column, |
|
656 |
drizzle_return_t *ret_ptr) |
|
657 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
658 |
if (result == NULL) |
659 |
{
|
|
660 |
return NULL; |
|
661 |
}
|
|
662 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
663 |
if (drizzle_state_none(result->con)) |
664 |
{
|
|
665 |
result->column= column; |
|
666 |
||
667 |
drizzle_state_push(result->con, drizzle_state_column_read); |
|
668 |
drizzle_state_push(result->con, drizzle_state_packet_read); |
|
669 |
}
|
|
670 |
||
671 |
*ret_ptr= drizzle_state_loop(result->con); |
|
672 |
return result->column; |
|
673 |
}
|
|
674 |
||
675 |
drizzle_return_t drizzle_column_buffer(drizzle_result_st *result) |
|
676 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
677 |
if (result == NULL) |
678 |
{
|
|
679 |
return DRIZZLE_RETURN_INVALID_ARGUMENT; |
|
680 |
}
|
|
681 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
682 |
drizzle_return_t ret; |
683 |
||
684 |
if (result->column_buffer == NULL) |
|
685 |
{
|
|
686 |
if (result->column_count == 0) |
|
687 |
{
|
|
688 |
result->options|= DRIZZLE_RESULT_BUFFER_COLUMN; |
|
689 |
return DRIZZLE_RETURN_OK; |
|
690 |
}
|
|
691 |
||
2461.1.2
by Brian Aker
Pass through refactoring. |
692 |
result->column_buffer= new (std::nothrow) drizzle_column_st[result->column_count]; |
693 |
||
694 |
if (result->column_buffer == NULL) |
|
695 |
{
|
|
696 |
return DRIZZLE_RETURN_MEMORY; |
|
697 |
}
|
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
698 |
}
|
699 |
||
700 |
/* No while body, just keep calling to buffer columns. */
|
|
701 |
while (drizzle_column_read(result, |
|
702 |
&(result->column_buffer[result->column_current]), |
|
703 |
&ret) != NULL && ret == DRIZZLE_RETURN_OK) |
|
704 |
{ } |
|
705 |
||
706 |
if (ret == DRIZZLE_RETURN_OK) |
|
707 |
{
|
|
708 |
result->column_current= 0; |
|
709 |
result->options|= DRIZZLE_RESULT_BUFFER_COLUMN; |
|
710 |
}
|
|
711 |
||
712 |
return ret; |
|
713 |
}
|
|
714 |
||
715 |
drizzle_column_st *drizzle_column_next(drizzle_result_st *result) |
|
716 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
717 |
if (result == NULL) |
718 |
{
|
|
719 |
return NULL; |
|
720 |
}
|
|
721 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
722 |
if (result->column_current == result->column_count) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
723 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
724 |
return NULL; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
725 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
726 |
|
727 |
result->column_current++; |
|
728 |
return &(result->column_buffer[result->column_current - 1]); |
|
729 |
}
|
|
730 |
||
731 |
drizzle_column_st *drizzle_column_prev(drizzle_result_st *result) |
|
732 |
{
|
|
733 |
if (result->column_current == 0) |
|
734 |
return NULL; |
|
735 |
||
736 |
result->column_current--; |
|
737 |
return &(result->column_buffer[result->column_current]); |
|
738 |
}
|
|
739 |
||
740 |
void drizzle_column_seek(drizzle_result_st *result, uint16_t column) |
|
741 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
742 |
if (result == NULL) |
743 |
{
|
|
744 |
return; |
|
745 |
}
|
|
746 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
747 |
if (column <= result->column_count) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
748 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
749 |
result->column_current= column; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
750 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
751 |
}
|
752 |
||
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
753 |
drizzle_column_st *drizzle_column_index(drizzle_result_st *result, uint16_t column) |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
754 |
{
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
755 |
if (result == NULL) |
756 |
{
|
|
757 |
return NULL; |
|
758 |
}
|
|
759 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
760 |
if (column >= result->column_count) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
761 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
762 |
return NULL; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
763 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
764 |
|
765 |
return &(result->column_buffer[column]); |
|
766 |
}
|
|
767 |
||
768 |
uint16_t drizzle_column_current(drizzle_result_st *result) |
|
769 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
770 |
if (result == NULL) |
771 |
{
|
|
772 |
return 0; |
|
773 |
}
|
|
774 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
775 |
return result->column_current; |
776 |
}
|
|
777 |
||
778 |
/*
|
|
779 |
* Server definitions
|
|
780 |
*/
|
|
781 |
||
782 |
drizzle_return_t drizzle_column_write(drizzle_result_st *result, |
|
783 |
drizzle_column_st *column) |
|
784 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
785 |
if (result == NULL) |
786 |
{
|
|
787 |
return DRIZZLE_RETURN_INVALID_ARGUMENT; |
|
788 |
}
|
|
789 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
790 |
if (drizzle_state_none(result->con)) |
791 |
{
|
|
792 |
result->column= column; |
|
793 |
||
794 |
drizzle_state_push(result->con, drizzle_state_column_write); |
|
795 |
}
|
|
796 |
||
797 |
return drizzle_state_loop(result->con); |
|
798 |
}
|
|
799 |
||
800 |
void drizzle_column_set_catalog(drizzle_column_st *column, const char *catalog) |
|
801 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
802 |
if (column == NULL) |
803 |
{
|
|
804 |
return; |
|
805 |
}
|
|
806 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
807 |
if (catalog == NULL) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
808 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
809 |
column->catalog[0]= 0; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
810 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
811 |
else
|
812 |
{
|
|
813 |
strncpy(column->catalog, catalog, DRIZZLE_MAX_CATALOG_SIZE); |
|
814 |
column->catalog[DRIZZLE_MAX_CATALOG_SIZE - 1]= 0; |
|
815 |
}
|
|
816 |
}
|
|
817 |
||
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
818 |
void drizzle_column_set_schema(drizzle_column_st *column, const char *schema) |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
819 |
{
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
820 |
if (column == NULL) |
821 |
{
|
|
822 |
return; |
|
823 |
}
|
|
824 |
||
825 |
if (schema == NULL) |
|
826 |
{
|
|
827 |
column->schema[0]= 0; |
|
828 |
}
|
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
829 |
else
|
830 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
831 |
strncpy(column->schema, schema, DRIZZLE_MAX_DB_SIZE); |
832 |
column->schema[DRIZZLE_MAX_DB_SIZE - 1]= 0; |
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
833 |
}
|
834 |
}
|
|
835 |
||
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
836 |
void drizzle_column_set_db(drizzle_column_st *column, const char *schema) |
837 |
{
|
|
838 |
drizzle_column_set_schema(column, schema); |
|
839 |
}
|
|
840 |
||
841 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
842 |
void drizzle_column_set_table(drizzle_column_st *column, const char *table) |
843 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
844 |
if (column == NULL) |
845 |
{
|
|
846 |
return; |
|
847 |
}
|
|
848 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
849 |
if (table == NULL) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
850 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
851 |
column->table[0]= 0; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
852 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
853 |
else
|
854 |
{
|
|
855 |
strncpy(column->table, table, DRIZZLE_MAX_TABLE_SIZE); |
|
856 |
column->table[DRIZZLE_MAX_TABLE_SIZE - 1]= 0; |
|
857 |
}
|
|
858 |
}
|
|
859 |
||
860 |
void drizzle_column_set_orig_table(drizzle_column_st *column, |
|
861 |
const char *orig_table) |
|
862 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
863 |
if (column == NULL) |
864 |
{
|
|
865 |
return; |
|
866 |
}
|
|
867 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
868 |
if (orig_table == NULL) |
869 |
column->orig_table[0]= 0; |
|
870 |
else
|
|
871 |
{
|
|
872 |
strncpy(column->orig_table, orig_table, DRIZZLE_MAX_TABLE_SIZE); |
|
873 |
column->orig_table[DRIZZLE_MAX_TABLE_SIZE - 1]= 0; |
|
874 |
}
|
|
875 |
}
|
|
876 |
||
877 |
void drizzle_column_set_name(drizzle_column_st *column, const char *name) |
|
878 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
879 |
if (column == NULL) |
880 |
{
|
|
881 |
return; |
|
882 |
}
|
|
883 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
884 |
if (name == NULL) |
885 |
column->name[0]= 0; |
|
886 |
else
|
|
887 |
{
|
|
888 |
strncpy(column->name, name, DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
889 |
column->name[DRIZZLE_MAX_COLUMN_NAME_SIZE - 1]= 0; |
|
890 |
}
|
|
891 |
}
|
|
892 |
||
893 |
void drizzle_column_set_orig_name(drizzle_column_st *column, |
|
894 |
const char *orig_name) |
|
895 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
896 |
if (column == NULL) |
897 |
{
|
|
898 |
return; |
|
899 |
}
|
|
900 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
901 |
if (orig_name == NULL) |
902 |
column->orig_name[0]= 0; |
|
903 |
else
|
|
904 |
{
|
|
905 |
strncpy(column->orig_name, orig_name, DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
906 |
column->orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE - 1]= 0; |
|
907 |
}
|
|
908 |
}
|
|
909 |
||
910 |
void drizzle_column_set_charset(drizzle_column_st *column, |
|
911 |
drizzle_charset_t charset) |
|
912 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
913 |
if (column == NULL) |
914 |
{
|
|
915 |
return; |
|
916 |
}
|
|
917 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
918 |
column->charset= charset; |
919 |
}
|
|
920 |
||
921 |
void drizzle_column_set_size(drizzle_column_st *column, uint32_t size) |
|
922 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
923 |
if (column == NULL) |
924 |
{
|
|
925 |
return; |
|
926 |
}
|
|
927 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
928 |
column->size= size; |
929 |
}
|
|
930 |
||
931 |
void drizzle_column_set_type(drizzle_column_st *column, |
|
932 |
drizzle_column_type_t type) |
|
933 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
934 |
if (column == NULL) |
935 |
{
|
|
936 |
return; |
|
937 |
}
|
|
938 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
939 |
column->type= type; |
940 |
}
|
|
941 |
||
942 |
void drizzle_column_set_flags(drizzle_column_st *column, |
|
943 |
int flags) |
|
944 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
945 |
if (column == NULL) |
946 |
{
|
|
947 |
return; |
|
948 |
}
|
|
949 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
950 |
column->flags= flags; |
951 |
}
|
|
952 |
||
953 |
void drizzle_column_set_decimals(drizzle_column_st *column, uint8_t decimals) |
|
954 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
955 |
if (column == NULL) |
956 |
{
|
|
957 |
return; |
|
958 |
}
|
|
959 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
960 |
column->decimals= decimals; |
961 |
}
|
|
962 |
||
963 |
void drizzle_column_set_default_value(drizzle_column_st *column, |
|
964 |
const uint8_t *default_value, |
|
965 |
size_t size) |
|
966 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
967 |
if (column == NULL) |
968 |
{
|
|
969 |
return; |
|
970 |
}
|
|
971 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
972 |
if (default_value == NULL) |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
973 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
974 |
column->default_value[0]= 0; |
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
975 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
976 |
else
|
977 |
{
|
|
978 |
if (size < DRIZZLE_MAX_DEFAULT_VALUE_SIZE) |
|
979 |
{
|
|
980 |
memcpy(column->default_value, default_value, size); |
|
981 |
column->default_value[size]= 0; |
|
982 |
column->default_value_size= size; |
|
983 |
}
|
|
984 |
else
|
|
985 |
{
|
|
986 |
memcpy(column->default_value, default_value, |
|
987 |
DRIZZLE_MAX_DEFAULT_VALUE_SIZE - 1); |
|
988 |
column->default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE - 1]= 0; |
|
989 |
column->default_value_size= DRIZZLE_MAX_DEFAULT_VALUE_SIZE; |
|
990 |
}
|
|
991 |
}
|
|
992 |
}
|
|
993 |
||
994 |
/*
|
|
995 |
* Internal state functions.
|
|
996 |
*/
|
|
997 |
||
998 |
drizzle_return_t drizzle_state_column_read(drizzle_con_st *con) |
|
999 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
1000 |
if (con == NULL) |
1001 |
{
|
|
1002 |
return DRIZZLE_RETURN_INVALID_ARGUMENT; |
|
1003 |
}
|
|
1004 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1005 |
drizzle_column_st *column; |
1006 |
drizzle_column_type_drizzle_t drizzle_type; |
|
1007 |
||
1008 |
drizzle_log_debug(con->drizzle, "drizzle_state_column_read"); |
|
1009 |
||
1010 |
/* Assume the entire column packet will fit in the buffer. */
|
|
1011 |
if (con->buffer_size < con->packet_size) |
|
1012 |
{
|
|
1013 |
drizzle_state_push(con, drizzle_state_read); |
|
1014 |
return DRIZZLE_RETURN_OK; |
|
1015 |
}
|
|
1016 |
||
1017 |
if (con->packet_size == 5 && con->buffer_ptr[0] == 254) |
|
1018 |
{
|
|
1019 |
/* EOF packet marking end of columns. */
|
|
1020 |
con->result->column= NULL; |
|
1021 |
con->result->warning_count= drizzle_get_byte2(con->buffer_ptr + 1); |
|
1022 |
con->status= (drizzle_con_status_t)drizzle_get_byte2(con->buffer_ptr + 3); |
|
1023 |
con->buffer_ptr+= 5; |
|
1024 |
con->buffer_size-= 5; |
|
1025 |
||
1026 |
drizzle_state_pop(con); |
|
1027 |
}
|
|
1028 |
else if (con->result->options & DRIZZLE_RESULT_SKIP_COLUMN) |
|
1029 |
{
|
|
1030 |
con->buffer_ptr+= con->packet_size; |
|
1031 |
con->buffer_size-= con->packet_size; |
|
1032 |
con->packet_size= 0; |
|
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
1033 |
con->result->column_count++; |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1034 |
|
2367.1.1
by Andrew Hutchings
Push drizzle_column_skip fixes upstream |
1035 |
drizzle_state_pop(con); |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1036 |
}
|
1037 |
else
|
|
1038 |
{
|
|
1039 |
column= drizzle_column_create(con->result, con->result->column); |
|
1040 |
if (column == NULL) |
|
1041 |
return DRIZZLE_RETURN_MEMORY; |
|
1042 |
||
1043 |
con->result->column= column; |
|
1044 |
||
1045 |
/* These functions can only fail if they need to read data, but we know we
|
|
1046 |
buffered the entire packet, so ignore returns. */
|
|
1047 |
(void)drizzle_unpack_string(con, column->catalog, DRIZZLE_MAX_CATALOG_SIZE); |
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
1048 |
(void)drizzle_unpack_string(con, column->schema, DRIZZLE_MAX_DB_SIZE); |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1049 |
(void)drizzle_unpack_string(con, column->table, DRIZZLE_MAX_TABLE_SIZE); |
1050 |
(void)drizzle_unpack_string(con, column->orig_table, |
|
1051 |
DRIZZLE_MAX_TABLE_SIZE); |
|
1052 |
(void)drizzle_unpack_string(con, column->name, |
|
1053 |
DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
1054 |
(void)drizzle_unpack_string(con, column->orig_name, |
|
1055 |
DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
1056 |
||
1057 |
/* Skip one filler byte. */
|
|
1058 |
column->charset= (drizzle_charset_t)drizzle_get_byte2(con->buffer_ptr + 1); |
|
1059 |
column->size= drizzle_get_byte4(con->buffer_ptr + 3); |
|
1060 |
||
1061 |
if (con->options & DRIZZLE_CON_MYSQL) |
|
1062 |
column->type= (drizzle_column_type_t)con->buffer_ptr[7]; |
|
1063 |
else
|
|
1064 |
{
|
|
1065 |
drizzle_type= (drizzle_column_type_drizzle_t)con->buffer_ptr[7]; |
|
1066 |
if (drizzle_type >= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX) |
|
1067 |
drizzle_type= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX; |
|
1068 |
column->type= _column_type_drizzle_map_to[drizzle_type]; |
|
1069 |
}
|
|
1070 |
||
1071 |
column->flags= drizzle_get_byte2(con->buffer_ptr + 8); |
|
1072 |
if (column->type <= DRIZZLE_COLUMN_TYPE_INT24 && |
|
1073 |
column->type != DRIZZLE_COLUMN_TYPE_TIMESTAMP) |
|
1074 |
{
|
|
1075 |
column->flags|= DRIZZLE_COLUMN_FLAGS_NUM; |
|
1076 |
}
|
|
1077 |
||
1078 |
column->decimals= con->buffer_ptr[10]; |
|
1079 |
/* Skip two reserved bytes. */
|
|
1080 |
||
1081 |
con->buffer_ptr+= 13; |
|
1082 |
con->buffer_size-= 13; |
|
1083 |
con->packet_size-= 13; |
|
1084 |
||
1085 |
if (con->packet_size > 0) |
|
1086 |
{
|
|
1087 |
drizzle_column_set_default_value(column, con->buffer_ptr, |
|
1088 |
con->packet_size); |
|
1089 |
||
1090 |
con->buffer_ptr+= con->packet_size; |
|
1091 |
con->buffer_size-= con->packet_size; |
|
1092 |
}
|
|
1093 |
else
|
|
1094 |
column->default_value[0]= 0; |
|
1095 |
||
1096 |
con->result->column_current++; |
|
1097 |
||
1098 |
drizzle_state_pop(con); |
|
1099 |
}
|
|
1100 |
||
1101 |
return DRIZZLE_RETURN_OK; |
|
1102 |
}
|
|
1103 |
||
1104 |
drizzle_return_t drizzle_state_column_write(drizzle_con_st *con) |
|
1105 |
{
|
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
1106 |
if (con == NULL) |
1107 |
{
|
|
1108 |
return DRIZZLE_RETURN_INVALID_ARGUMENT; |
|
1109 |
}
|
|
1110 |
||
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1111 |
uint8_t *start= con->buffer_ptr + con->buffer_size; |
1112 |
uint8_t *ptr; |
|
1113 |
drizzle_column_st *column= con->result->column; |
|
1114 |
||
1115 |
drizzle_log_debug(con->drizzle, "drizzle_state_column_write"); |
|
1116 |
||
1117 |
/* Calculate max packet size. */
|
|
1118 |
con->packet_size= 9 + strlen(column->catalog) |
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
1119 |
+ 9 + strlen(column->schema) |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1120 |
+ 9 + strlen(column->table) |
1121 |
+ 9 + strlen(column->orig_table) |
|
1122 |
+ 9 + strlen(column->name) |
|
1123 |
+ 9 + strlen(column->orig_name) |
|
1124 |
+ 1 /* Unused */ |
|
1125 |
+ 2 /* Charset */ |
|
1126 |
+ 4 /* Size */ |
|
1127 |
+ 1 /* Type */ |
|
1128 |
+ 2 /* Flags */ |
|
1129 |
+ 1 /* Decimals */ |
|
1130 |
+ 2 /* Unused */ |
|
1131 |
+ column->default_value_size; |
|
1132 |
||
1133 |
/* Assume the entire column packet will fit in the buffer. */
|
|
1134 |
if ((con->packet_size + 4) > DRIZZLE_MAX_BUFFER_SIZE) |
|
1135 |
{
|
|
1136 |
drizzle_set_error(con->drizzle, "drizzle_state_column_write", |
|
1137 |
"buffer too small:%zu", con->packet_size + 4); |
|
1138 |
return DRIZZLE_RETURN_INTERNAL_ERROR; |
|
1139 |
}
|
|
1140 |
||
1141 |
/* Flush buffer if there is not enough room. */
|
|
1142 |
if (((size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer)) < |
|
1143 |
con->packet_size) |
|
1144 |
{
|
|
1145 |
drizzle_state_push(con, drizzle_state_write); |
|
1146 |
return DRIZZLE_RETURN_OK; |
|
1147 |
}
|
|
1148 |
||
1149 |
/* Store packet size at the end since it may change. */
|
|
1150 |
ptr= start; |
|
1151 |
ptr[3]= con->packet_number; |
|
1152 |
con->packet_number++; |
|
1153 |
ptr+= 4; |
|
1154 |
||
1155 |
ptr= drizzle_pack_string(column->catalog, ptr); |
|
2461.1.1
by Brian Aker
Fix safety issues around calling API with no check for NULL |
1156 |
ptr= drizzle_pack_string(column->schema, ptr); |
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1157 |
ptr= drizzle_pack_string(column->table, ptr); |
1158 |
ptr= drizzle_pack_string(column->orig_table, ptr); |
|
1159 |
ptr= drizzle_pack_string(column->name, ptr); |
|
1160 |
ptr= drizzle_pack_string(column->orig_name, ptr); |
|
1161 |
||
1162 |
/* This unused byte is set to 12 for some reason. */
|
|
1163 |
ptr[0]= 12; |
|
1164 |
ptr++; |
|
1165 |
||
1166 |
drizzle_set_byte2(ptr, column->charset); |
|
1167 |
ptr+= 2; |
|
1168 |
||
1169 |
drizzle_set_byte4(ptr, column->size); |
|
1170 |
ptr+= 4; |
|
1171 |
||
1172 |
if (con->options & DRIZZLE_CON_MYSQL) |
|
2461.1.3
by Brian Aker
Small correction to style. |
1173 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1174 |
ptr[0]= column->type; |
2461.1.3
by Brian Aker
Small correction to style. |
1175 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1176 |
else
|
2461.1.3
by Brian Aker
Small correction to style. |
1177 |
{
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1178 |
ptr[0]= _column_type_drizzle_map_from[column->type]; |
2461.1.3
by Brian Aker
Small correction to style. |
1179 |
}
|
2244.1.1
by Monty Taylor
Split libdrizzle into 1.0 and 2.0. Applied the C++ changes to 2.0 branch. |
1180 |
ptr++; |
1181 |
||
1182 |
drizzle_set_byte2(ptr, column->flags); |
|
1183 |
ptr+= 2; |
|
1184 |
||
1185 |
ptr[0]= column->decimals; |
|
1186 |
ptr++; |
|
1187 |
||
1188 |
memset(ptr, 0, 2); |
|
1189 |
ptr+= 2; |
|
1190 |
||
1191 |
if (column->default_value_size > 0) |
|
1192 |
{
|
|
1193 |
memcpy(ptr, column->default_value, column->default_value_size); |
|
1194 |
ptr+= column->default_value_size; |
|
1195 |
}
|
|
1196 |
||
1197 |
con->packet_size= ((size_t)(ptr - start) - 4); |
|
1198 |
con->buffer_size+= (4 + con->packet_size); |
|
1199 |
||
1200 |
/* Store packet size now. */
|
|
1201 |
drizzle_set_byte3(start, con->packet_size); |
|
1202 |
||
1203 |
con->result->column_current++; |
|
1204 |
||
1205 |
drizzle_state_pop(con); |
|
1206 |
||
1207 |
return DRIZZLE_RETURN_OK; |
|
1208 |
}
|