1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
1 |
/*
|
2 |
* Drizzle Client & Protocol Library
|
|
3 |
*
|
|
4 |
* Copyright (C) 2008 Eric Day (eday@oddments.org)
|
|
5 |
* All rights reserved.
|
|
6 |
*
|
|
1971.2.1
by kalebral at gmail
update files that did not have license or had incorrect license structure |
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 |
*
|
|
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
35 |
*/
|
36 |
||
1971.2.1
by kalebral at gmail
update files that did not have license or had incorrect license structure |
37 |
|
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
38 |
/**
|
39 |
* @file
|
|
40 |
* @brief Column definitions
|
|
41 |
*/
|
|
42 |
||
2449.1.4
by Brian Aker
Complete update of libdrizzle |
43 |
#include <libdrizzle-1.0/common.h> |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
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 */ |
|
2187.3.5
by Monty Taylor
Getting closer. |
68 |
DRIZZLE_COLUMN_TYPE_DRIZZLE_BOOLEAN, |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
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 |
{
|
|
357 |
if (column == NULL) |
|
358 |
{
|
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
359 |
column= malloc(sizeof(drizzle_column_st)); |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
360 |
if (column == NULL) |
361 |
{
|
|
362 |
drizzle_set_error(result->con->drizzle, "drizzle_column_create", |
|
363 |
"malloc"); |
|
364 |
return NULL; |
|
365 |
}
|
|
366 |
||
1986.2.3
by Monty Taylor
Updated patch from Evan - which passes tests and also seems to be faster for |
367 |
column->result = result; |
368 |
/* SET BELOW: column->next */
|
|
369 |
column->prev = NULL; |
|
370 |
column->options= DRIZZLE_COLUMN_ALLOCATED; |
|
371 |
column->catalog[0] = '\0'; |
|
372 |
column->db[0] = '\0'; |
|
373 |
column->table[0] = '\0'; |
|
374 |
column->orig_table[0] = '\0'; |
|
375 |
column->name[0] = '\0'; |
|
376 |
column->orig_name[0] = '\0'; |
|
377 |
column->charset = 0; |
|
378 |
column->size = 0; |
|
379 |
column->max_size = 0; |
|
380 |
column->type = 0; |
|
381 |
column->flags = 0; |
|
382 |
column->decimals = 0; |
|
383 |
/* UNSET: column->default_value */
|
|
384 |
column->default_value_size = 0; |
|
1986.2.2
by Monty Taylor
Alternate option for clearing the drizzle_column_st. |
385 |
|
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
386 |
}
|
387 |
else
|
|
1986.2.1
by Evan Jones
This structure is HUGE (~6636 bytes): memset is too expensive |
388 |
{
|
1986.2.3
by Monty Taylor
Updated patch from Evan - which passes tests and also seems to be faster for |
389 |
column->result = result; |
390 |
/* SET BELOW: column->next */
|
|
391 |
column->prev = NULL; |
|
392 |
column->options= 0; |
|
393 |
column->catalog[0] = '\0'; |
|
394 |
column->db[0] = '\0'; |
|
395 |
column->table[0] = '\0'; |
|
396 |
column->orig_table[0] = '\0'; |
|
397 |
column->name[0] = '\0'; |
|
398 |
column->orig_name[0] = '\0'; |
|
399 |
column->charset = 0; |
|
400 |
column->size = 0; |
|
401 |
column->max_size = 0; |
|
402 |
column->type = 0; |
|
403 |
column->flags = 0; |
|
404 |
column->decimals = 0; |
|
405 |
/* UNSET: column->default_value */
|
|
406 |
column->default_value_size = 0; |
|
1986.2.1
by Evan Jones
This structure is HUGE (~6636 bytes): memset is too expensive |
407 |
}
|
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
408 |
|
409 |
column->result= result; |
|
410 |
||
411 |
if (result->column_list) |
|
412 |
result->column_list->prev= column; |
|
413 |
column->next= result->column_list; |
|
414 |
result->column_list= column; |
|
415 |
||
416 |
return column; |
|
417 |
}
|
|
418 |
||
419 |
void drizzle_column_free(drizzle_column_st *column) |
|
420 |
{
|
|
421 |
if (column->result->column_list == column) |
|
422 |
column->result->column_list= column->next; |
|
423 |
if (column->prev) |
|
424 |
column->prev->next= column->next; |
|
425 |
if (column->next) |
|
426 |
column->next->prev= column->prev; |
|
427 |
||
428 |
if (column->options & DRIZZLE_COLUMN_ALLOCATED) |
|
429 |
free(column); |
|
430 |
}
|
|
431 |
||
432 |
drizzle_result_st *drizzle_column_drizzle_result(drizzle_column_st *column) |
|
433 |
{
|
|
434 |
return column->result; |
|
435 |
}
|
|
436 |
||
437 |
const char *drizzle_column_catalog(drizzle_column_st *column) |
|
438 |
{
|
|
439 |
return column->catalog; |
|
440 |
}
|
|
441 |
||
442 |
const char *drizzle_column_db(drizzle_column_st *column) |
|
443 |
{
|
|
444 |
return column->db; |
|
445 |
}
|
|
446 |
||
447 |
const char *drizzle_column_table(drizzle_column_st *column) |
|
448 |
{
|
|
449 |
return column->table; |
|
450 |
}
|
|
451 |
||
452 |
const char *drizzle_column_orig_table(drizzle_column_st *column) |
|
453 |
{
|
|
454 |
return column->orig_table; |
|
455 |
}
|
|
456 |
||
457 |
const char *drizzle_column_name(drizzle_column_st *column) |
|
458 |
{
|
|
459 |
return column->name; |
|
460 |
}
|
|
461 |
||
462 |
const char *drizzle_column_orig_name(drizzle_column_st *column) |
|
463 |
{
|
|
464 |
return column->orig_name; |
|
465 |
}
|
|
466 |
||
467 |
drizzle_charset_t drizzle_column_charset(drizzle_column_st *column) |
|
468 |
{
|
|
469 |
return column->charset; |
|
470 |
}
|
|
471 |
||
472 |
uint32_t drizzle_column_size(drizzle_column_st *column) |
|
473 |
{
|
|
474 |
return column->size; |
|
475 |
}
|
|
476 |
||
477 |
size_t drizzle_column_max_size(drizzle_column_st *column) |
|
478 |
{
|
|
479 |
return column->max_size; |
|
480 |
}
|
|
481 |
||
482 |
void drizzle_column_set_max_size(drizzle_column_st *column, size_t size) |
|
483 |
{
|
|
484 |
column->max_size= size; |
|
485 |
}
|
|
486 |
||
487 |
drizzle_column_type_t drizzle_column_type(drizzle_column_st *column) |
|
488 |
{
|
|
489 |
return column->type; |
|
490 |
}
|
|
491 |
||
492 |
drizzle_column_type_drizzle_t
|
|
493 |
drizzle_column_type_drizzle(drizzle_column_st *column) |
|
494 |
{
|
|
495 |
return _column_type_drizzle_map_from[column->type]; |
|
496 |
}
|
|
497 |
||
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
498 |
drizzle_column_flags_t drizzle_column_flags(drizzle_column_st *column) |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
499 |
{
|
500 |
return column->flags; |
|
501 |
}
|
|
502 |
||
503 |
uint8_t drizzle_column_decimals(drizzle_column_st *column) |
|
504 |
{
|
|
505 |
return column->decimals; |
|
506 |
}
|
|
507 |
||
508 |
const uint8_t *drizzle_column_default_value(drizzle_column_st *column, |
|
509 |
size_t *size) |
|
510 |
{
|
|
511 |
*size= column->default_value_size; |
|
512 |
return column->default_value; |
|
513 |
}
|
|
514 |
||
515 |
/*
|
|
516 |
* Client definitions
|
|
517 |
*/
|
|
518 |
||
519 |
drizzle_return_t drizzle_column_skip(drizzle_result_st *result) |
|
520 |
{
|
|
2367.1.2
by Andrew Hutchings
Fixup drizzle_column_skip for Windows |
521 |
drizzle_return_t ret; |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
522 |
if (drizzle_state_none(result->con)) |
523 |
{
|
|
524 |
result->options|= DRIZZLE_RESULT_SKIP_COLUMN; |
|
525 |
||
526 |
drizzle_state_push(result->con, drizzle_state_column_read); |
|
527 |
drizzle_state_push(result->con, drizzle_state_packet_read); |
|
528 |
}
|
|
2367.1.2
by Andrew Hutchings
Fixup drizzle_column_skip for Windows |
529 |
ret= drizzle_state_loop(result->con); |
2367.1.1
by Andrew Hutchings
Push drizzle_column_skip fixes upstream |
530 |
result->options&= ~DRIZZLE_RESULT_SKIP_COLUMN; |
531 |
return ret; |
|
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
532 |
}
|
533 |
||
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
534 |
drizzle_return_t drizzle_column_skip_all(drizzle_result_st *result) |
535 |
{
|
|
536 |
drizzle_return_t ret; |
|
537 |
uint16_t it; |
|
538 |
||
539 |
for (it= 1; it <= result->column_count; it++) |
|
540 |
{
|
|
541 |
ret= drizzle_column_skip(result); |
|
542 |
if (ret != DRIZZLE_RETURN_OK) |
|
543 |
return ret; |
|
544 |
}
|
|
545 |
||
546 |
return DRIZZLE_RETURN_OK; |
|
547 |
}
|
|
548 |
||
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
549 |
drizzle_column_st *drizzle_column_read(drizzle_result_st *result, |
550 |
drizzle_column_st *column, |
|
551 |
drizzle_return_t *ret_ptr) |
|
552 |
{
|
|
553 |
if (drizzle_state_none(result->con)) |
|
554 |
{
|
|
555 |
result->column= column; |
|
556 |
||
557 |
drizzle_state_push(result->con, drizzle_state_column_read); |
|
558 |
drizzle_state_push(result->con, drizzle_state_packet_read); |
|
559 |
}
|
|
560 |
||
561 |
*ret_ptr= drizzle_state_loop(result->con); |
|
562 |
return result->column; |
|
563 |
}
|
|
564 |
||
565 |
drizzle_return_t drizzle_column_buffer(drizzle_result_st *result) |
|
566 |
{
|
|
567 |
drizzle_return_t ret; |
|
568 |
||
569 |
if (result->column_buffer == NULL) |
|
570 |
{
|
|
571 |
if (result->column_count == 0) |
|
572 |
{
|
|
573 |
result->options|= DRIZZLE_RESULT_BUFFER_COLUMN; |
|
574 |
return DRIZZLE_RETURN_OK; |
|
575 |
}
|
|
576 |
||
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
577 |
result->column_buffer= malloc(sizeof(drizzle_column_st) * |
578 |
result->column_count); |
|
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
579 |
if (result->column_buffer == NULL) |
580 |
{
|
|
581 |
drizzle_set_error(result->con->drizzle, "drizzle_column_buffer", |
|
582 |
"malloc"); |
|
583 |
return DRIZZLE_RETURN_MEMORY; |
|
584 |
}
|
|
585 |
}
|
|
586 |
||
587 |
/* No while body, just keep calling to buffer columns. */
|
|
588 |
while (drizzle_column_read(result, |
|
589 |
&(result->column_buffer[result->column_current]), |
|
590 |
&ret) != NULL && ret == DRIZZLE_RETURN_OK); |
|
591 |
if (ret == DRIZZLE_RETURN_OK) |
|
592 |
{
|
|
593 |
result->column_current= 0; |
|
594 |
result->options|= DRIZZLE_RESULT_BUFFER_COLUMN; |
|
595 |
}
|
|
596 |
||
597 |
return ret; |
|
598 |
}
|
|
599 |
||
600 |
drizzle_column_st *drizzle_column_next(drizzle_result_st *result) |
|
601 |
{
|
|
602 |
if (result->column_current == result->column_count) |
|
603 |
return NULL; |
|
604 |
||
605 |
result->column_current++; |
|
606 |
return &(result->column_buffer[result->column_current - 1]); |
|
607 |
}
|
|
608 |
||
609 |
drizzle_column_st *drizzle_column_prev(drizzle_result_st *result) |
|
610 |
{
|
|
611 |
if (result->column_current == 0) |
|
612 |
return NULL; |
|
613 |
||
614 |
result->column_current--; |
|
615 |
return &(result->column_buffer[result->column_current]); |
|
616 |
}
|
|
617 |
||
618 |
void drizzle_column_seek(drizzle_result_st *result, uint16_t column) |
|
619 |
{
|
|
620 |
if (column <= result->column_count) |
|
621 |
result->column_current= column; |
|
622 |
}
|
|
623 |
||
624 |
drizzle_column_st *drizzle_column_index(drizzle_result_st *result, |
|
625 |
uint16_t column) |
|
626 |
{
|
|
627 |
if (column >= result->column_count) |
|
628 |
return NULL; |
|
629 |
||
630 |
return &(result->column_buffer[column]); |
|
631 |
}
|
|
632 |
||
633 |
uint16_t drizzle_column_current(drizzle_result_st *result) |
|
634 |
{
|
|
635 |
return result->column_current; |
|
636 |
}
|
|
637 |
||
638 |
/*
|
|
639 |
* Server definitions
|
|
640 |
*/
|
|
641 |
||
642 |
drizzle_return_t drizzle_column_write(drizzle_result_st *result, |
|
643 |
drizzle_column_st *column) |
|
644 |
{
|
|
645 |
if (drizzle_state_none(result->con)) |
|
646 |
{
|
|
647 |
result->column= column; |
|
648 |
||
649 |
drizzle_state_push(result->con, drizzle_state_column_write); |
|
650 |
}
|
|
651 |
||
652 |
return drizzle_state_loop(result->con); |
|
653 |
}
|
|
654 |
||
655 |
void drizzle_column_set_catalog(drizzle_column_st *column, const char *catalog) |
|
656 |
{
|
|
657 |
if (catalog == NULL) |
|
658 |
column->catalog[0]= 0; |
|
659 |
else
|
|
660 |
{
|
|
661 |
strncpy(column->catalog, catalog, DRIZZLE_MAX_CATALOG_SIZE); |
|
662 |
column->catalog[DRIZZLE_MAX_CATALOG_SIZE - 1]= 0; |
|
663 |
}
|
|
664 |
}
|
|
665 |
||
666 |
void drizzle_column_set_db(drizzle_column_st *column, const char *db) |
|
667 |
{
|
|
668 |
if (db == NULL) |
|
669 |
column->db[0]= 0; |
|
670 |
else
|
|
671 |
{
|
|
672 |
strncpy(column->db, db, DRIZZLE_MAX_DB_SIZE); |
|
673 |
column->db[DRIZZLE_MAX_DB_SIZE - 1]= 0; |
|
674 |
}
|
|
675 |
}
|
|
676 |
||
677 |
void drizzle_column_set_table(drizzle_column_st *column, const char *table) |
|
678 |
{
|
|
679 |
if (table == NULL) |
|
680 |
column->table[0]= 0; |
|
681 |
else
|
|
682 |
{
|
|
683 |
strncpy(column->table, table, DRIZZLE_MAX_TABLE_SIZE); |
|
684 |
column->table[DRIZZLE_MAX_TABLE_SIZE - 1]= 0; |
|
685 |
}
|
|
686 |
}
|
|
687 |
||
688 |
void drizzle_column_set_orig_table(drizzle_column_st *column, |
|
689 |
const char *orig_table) |
|
690 |
{
|
|
691 |
if (orig_table == NULL) |
|
692 |
column->orig_table[0]= 0; |
|
693 |
else
|
|
694 |
{
|
|
695 |
strncpy(column->orig_table, orig_table, DRIZZLE_MAX_TABLE_SIZE); |
|
696 |
column->orig_table[DRIZZLE_MAX_TABLE_SIZE - 1]= 0; |
|
697 |
}
|
|
698 |
}
|
|
699 |
||
700 |
void drizzle_column_set_name(drizzle_column_st *column, const char *name) |
|
701 |
{
|
|
702 |
if (name == NULL) |
|
703 |
column->name[0]= 0; |
|
704 |
else
|
|
705 |
{
|
|
706 |
strncpy(column->name, name, DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
707 |
column->name[DRIZZLE_MAX_COLUMN_NAME_SIZE - 1]= 0; |
|
708 |
}
|
|
709 |
}
|
|
710 |
||
711 |
void drizzle_column_set_orig_name(drizzle_column_st *column, |
|
712 |
const char *orig_name) |
|
713 |
{
|
|
714 |
if (orig_name == NULL) |
|
715 |
column->orig_name[0]= 0; |
|
716 |
else
|
|
717 |
{
|
|
718 |
strncpy(column->orig_name, orig_name, DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
719 |
column->orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE - 1]= 0; |
|
720 |
}
|
|
721 |
}
|
|
722 |
||
723 |
void drizzle_column_set_charset(drizzle_column_st *column, |
|
724 |
drizzle_charset_t charset) |
|
725 |
{
|
|
726 |
column->charset= charset; |
|
727 |
}
|
|
728 |
||
729 |
void drizzle_column_set_size(drizzle_column_st *column, uint32_t size) |
|
730 |
{
|
|
731 |
column->size= size; |
|
732 |
}
|
|
733 |
||
734 |
void drizzle_column_set_type(drizzle_column_st *column, |
|
735 |
drizzle_column_type_t type) |
|
736 |
{
|
|
737 |
column->type= type; |
|
738 |
}
|
|
739 |
||
740 |
void drizzle_column_set_flags(drizzle_column_st *column, |
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
741 |
drizzle_column_flags_t flags) |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
742 |
{
|
743 |
column->flags= flags; |
|
744 |
}
|
|
745 |
||
746 |
void drizzle_column_set_decimals(drizzle_column_st *column, uint8_t decimals) |
|
747 |
{
|
|
748 |
column->decimals= decimals; |
|
749 |
}
|
|
750 |
||
751 |
void drizzle_column_set_default_value(drizzle_column_st *column, |
|
752 |
const uint8_t *default_value, |
|
753 |
size_t size) |
|
754 |
{
|
|
755 |
if (default_value == NULL) |
|
756 |
column->default_value[0]= 0; |
|
757 |
else
|
|
758 |
{
|
|
759 |
if (size < DRIZZLE_MAX_DEFAULT_VALUE_SIZE) |
|
760 |
{
|
|
761 |
memcpy(column->default_value, default_value, size); |
|
762 |
column->default_value[size]= 0; |
|
763 |
column->default_value_size= size; |
|
764 |
}
|
|
765 |
else
|
|
766 |
{
|
|
767 |
memcpy(column->default_value, default_value, |
|
768 |
DRIZZLE_MAX_DEFAULT_VALUE_SIZE - 1); |
|
769 |
column->default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE - 1]= 0; |
|
770 |
column->default_value_size= DRIZZLE_MAX_DEFAULT_VALUE_SIZE; |
|
771 |
}
|
|
772 |
}
|
|
773 |
}
|
|
774 |
||
775 |
/*
|
|
776 |
* Internal state functions.
|
|
777 |
*/
|
|
778 |
||
779 |
drizzle_return_t drizzle_state_column_read(drizzle_con_st *con) |
|
780 |
{
|
|
781 |
drizzle_column_st *column; |
|
782 |
drizzle_column_type_drizzle_t drizzle_type; |
|
783 |
||
784 |
drizzle_log_debug(con->drizzle, "drizzle_state_column_read"); |
|
785 |
||
786 |
/* Assume the entire column packet will fit in the buffer. */
|
|
787 |
if (con->buffer_size < con->packet_size) |
|
788 |
{
|
|
789 |
drizzle_state_push(con, drizzle_state_read); |
|
790 |
return DRIZZLE_RETURN_OK; |
|
791 |
}
|
|
792 |
||
793 |
if (con->packet_size == 5 && con->buffer_ptr[0] == 254) |
|
794 |
{
|
|
795 |
/* EOF packet marking end of columns. */
|
|
796 |
con->result->column= NULL; |
|
797 |
con->result->warning_count= drizzle_get_byte2(con->buffer_ptr + 1); |
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
798 |
con->status= drizzle_get_byte2(con->buffer_ptr + 3); |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
799 |
con->buffer_ptr+= 5; |
800 |
con->buffer_size-= 5; |
|
801 |
||
802 |
drizzle_state_pop(con); |
|
803 |
}
|
|
804 |
else if (con->result->options & DRIZZLE_RESULT_SKIP_COLUMN) |
|
805 |
{
|
|
806 |
con->buffer_ptr+= con->packet_size; |
|
807 |
con->buffer_size-= con->packet_size; |
|
808 |
con->packet_size= 0; |
|
2411.1.1
by Andrew Hutchings
Add function drizzle_column_skip_all |
809 |
con->result->column_current++; |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
810 |
|
2367.1.1
by Andrew Hutchings
Push drizzle_column_skip fixes upstream |
811 |
drizzle_state_pop(con); |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
812 |
}
|
813 |
else
|
|
814 |
{
|
|
815 |
column= drizzle_column_create(con->result, con->result->column); |
|
816 |
if (column == NULL) |
|
817 |
return DRIZZLE_RETURN_MEMORY; |
|
818 |
||
819 |
con->result->column= column; |
|
820 |
||
821 |
/* These functions can only fail if they need to read data, but we know we
|
|
822 |
buffered the entire packet, so ignore returns. */
|
|
823 |
(void)drizzle_unpack_string(con, column->catalog, DRIZZLE_MAX_CATALOG_SIZE); |
|
824 |
(void)drizzle_unpack_string(con, column->db, DRIZZLE_MAX_DB_SIZE); |
|
825 |
(void)drizzle_unpack_string(con, column->table, DRIZZLE_MAX_TABLE_SIZE); |
|
826 |
(void)drizzle_unpack_string(con, column->orig_table, |
|
827 |
DRIZZLE_MAX_TABLE_SIZE); |
|
828 |
(void)drizzle_unpack_string(con, column->name, |
|
829 |
DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
830 |
(void)drizzle_unpack_string(con, column->orig_name, |
|
831 |
DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
832 |
||
833 |
/* Skip one filler byte. */
|
|
834 |
column->charset= (drizzle_charset_t)drizzle_get_byte2(con->buffer_ptr + 1); |
|
835 |
column->size= drizzle_get_byte4(con->buffer_ptr + 3); |
|
836 |
||
837 |
if (con->options & DRIZZLE_CON_MYSQL) |
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
838 |
column->type= con->buffer_ptr[7]; |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
839 |
else
|
840 |
{
|
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
841 |
drizzle_type= con->buffer_ptr[7]; |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
842 |
if (drizzle_type >= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX) |
843 |
drizzle_type= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX; |
|
844 |
column->type= _column_type_drizzle_map_to[drizzle_type]; |
|
845 |
}
|
|
846 |
||
847 |
column->flags= drizzle_get_byte2(con->buffer_ptr + 8); |
|
848 |
if (column->type <= DRIZZLE_COLUMN_TYPE_INT24 && |
|
849 |
column->type != DRIZZLE_COLUMN_TYPE_TIMESTAMP) |
|
850 |
{
|
|
851 |
column->flags|= DRIZZLE_COLUMN_FLAGS_NUM; |
|
852 |
}
|
|
853 |
||
854 |
column->decimals= con->buffer_ptr[10]; |
|
855 |
/* Skip two reserved bytes. */
|
|
856 |
||
857 |
con->buffer_ptr+= 13; |
|
858 |
con->buffer_size-= 13; |
|
859 |
con->packet_size-= 13; |
|
860 |
||
861 |
if (con->packet_size > 0) |
|
862 |
{
|
|
863 |
drizzle_column_set_default_value(column, con->buffer_ptr, |
|
864 |
con->packet_size); |
|
865 |
||
866 |
con->buffer_ptr+= con->packet_size; |
|
867 |
con->buffer_size-= con->packet_size; |
|
868 |
}
|
|
869 |
else
|
|
870 |
column->default_value[0]= 0; |
|
871 |
||
872 |
con->result->column_current++; |
|
873 |
||
874 |
drizzle_state_pop(con); |
|
875 |
}
|
|
876 |
||
877 |
return DRIZZLE_RETURN_OK; |
|
878 |
}
|
|
879 |
||
880 |
drizzle_return_t drizzle_state_column_write(drizzle_con_st *con) |
|
881 |
{
|
|
882 |
uint8_t *start= con->buffer_ptr + con->buffer_size; |
|
883 |
uint8_t *ptr; |
|
884 |
drizzle_column_st *column= con->result->column; |
|
885 |
||
886 |
drizzle_log_debug(con->drizzle, "drizzle_state_column_write"); |
|
887 |
||
888 |
/* Calculate max packet size. */
|
|
889 |
con->packet_size= 9 + strlen(column->catalog) |
|
890 |
+ 9 + strlen(column->db) |
|
891 |
+ 9 + strlen(column->table) |
|
892 |
+ 9 + strlen(column->orig_table) |
|
893 |
+ 9 + strlen(column->name) |
|
894 |
+ 9 + strlen(column->orig_name) |
|
895 |
+ 1 /* Unused */ |
|
896 |
+ 2 /* Charset */ |
|
897 |
+ 4 /* Size */ |
|
898 |
+ 1 /* Type */ |
|
899 |
+ 2 /* Flags */ |
|
900 |
+ 1 /* Decimals */ |
|
901 |
+ 2 /* Unused */ |
|
902 |
+ column->default_value_size; |
|
903 |
||
904 |
/* Assume the entire column packet will fit in the buffer. */
|
|
905 |
if ((con->packet_size + 4) > DRIZZLE_MAX_BUFFER_SIZE) |
|
906 |
{
|
|
907 |
drizzle_set_error(con->drizzle, "drizzle_state_column_write", |
|
908 |
"buffer too small:%zu", con->packet_size + 4); |
|
909 |
return DRIZZLE_RETURN_INTERNAL_ERROR; |
|
910 |
}
|
|
911 |
||
912 |
/* Flush buffer if there is not enough room. */
|
|
913 |
if (((size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer)) < |
|
914 |
con->packet_size) |
|
915 |
{
|
|
916 |
drizzle_state_push(con, drizzle_state_write); |
|
917 |
return DRIZZLE_RETURN_OK; |
|
918 |
}
|
|
919 |
||
920 |
/* Store packet size at the end since it may change. */
|
|
921 |
ptr= start; |
|
922 |
ptr[3]= con->packet_number; |
|
923 |
con->packet_number++; |
|
924 |
ptr+= 4; |
|
925 |
||
926 |
ptr= drizzle_pack_string(column->catalog, ptr); |
|
927 |
ptr= drizzle_pack_string(column->db, ptr); |
|
928 |
ptr= drizzle_pack_string(column->table, ptr); |
|
929 |
ptr= drizzle_pack_string(column->orig_table, ptr); |
|
930 |
ptr= drizzle_pack_string(column->name, ptr); |
|
931 |
ptr= drizzle_pack_string(column->orig_name, ptr); |
|
932 |
||
933 |
/* This unused byte is set to 12 for some reason. */
|
|
934 |
ptr[0]= 12; |
|
935 |
ptr++; |
|
936 |
||
937 |
drizzle_set_byte2(ptr, column->charset); |
|
938 |
ptr+= 2; |
|
939 |
||
940 |
drizzle_set_byte4(ptr, column->size); |
|
941 |
ptr+= 4; |
|
942 |
||
943 |
if (con->options & DRIZZLE_CON_MYSQL) |
|
944 |
ptr[0]= column->type; |
|
945 |
else
|
|
946 |
ptr[0]= _column_type_drizzle_map_from[column->type]; |
|
947 |
ptr++; |
|
948 |
||
949 |
drizzle_set_byte2(ptr, column->flags); |
|
950 |
ptr+= 2; |
|
951 |
||
952 |
ptr[0]= column->decimals; |
|
953 |
ptr++; |
|
954 |
||
955 |
memset(ptr, 0, 2); |
|
956 |
ptr+= 2; |
|
957 |
||
958 |
if (column->default_value_size > 0) |
|
959 |
{
|
|
960 |
memcpy(ptr, column->default_value, column->default_value_size); |
|
961 |
ptr+= column->default_value_size; |
|
962 |
}
|
|
963 |
||
964 |
con->packet_size= ((size_t)(ptr - start) - 4); |
|
965 |
con->buffer_size+= (4 + con->packet_size); |
|
966 |
||
967 |
/* Store packet size now. */
|
|
968 |
drizzle_set_byte3(start, con->packet_size); |
|
969 |
||
970 |
con->result->column_current++; |
|
971 |
||
972 |
drizzle_state_pop(con); |
|
973 |
||
974 |
return DRIZZLE_RETURN_OK; |
|
975 |
}
|