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 |
||
43 |
#include "common.h" |
|
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_TINY, |
|
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 |
{
|
|
521 |
if (drizzle_state_none(result->con)) |
|
522 |
{
|
|
523 |
result->options|= DRIZZLE_RESULT_SKIP_COLUMN; |
|
524 |
||
525 |
drizzle_state_push(result->con, drizzle_state_column_read); |
|
526 |
drizzle_state_push(result->con, drizzle_state_packet_read); |
|
527 |
}
|
|
528 |
||
529 |
return drizzle_state_loop(result->con); |
|
530 |
}
|
|
531 |
||
532 |
drizzle_column_st *drizzle_column_read(drizzle_result_st *result, |
|
533 |
drizzle_column_st *column, |
|
534 |
drizzle_return_t *ret_ptr) |
|
535 |
{
|
|
536 |
if (drizzle_state_none(result->con)) |
|
537 |
{
|
|
538 |
result->column= column; |
|
539 |
||
540 |
drizzle_state_push(result->con, drizzle_state_column_read); |
|
541 |
drizzle_state_push(result->con, drizzle_state_packet_read); |
|
542 |
}
|
|
543 |
||
544 |
*ret_ptr= drizzle_state_loop(result->con); |
|
545 |
return result->column; |
|
546 |
}
|
|
547 |
||
548 |
drizzle_return_t drizzle_column_buffer(drizzle_result_st *result) |
|
549 |
{
|
|
550 |
drizzle_return_t ret; |
|
551 |
||
552 |
if (result->column_buffer == NULL) |
|
553 |
{
|
|
554 |
if (result->column_count == 0) |
|
555 |
{
|
|
556 |
result->options|= DRIZZLE_RESULT_BUFFER_COLUMN; |
|
557 |
return DRIZZLE_RETURN_OK; |
|
558 |
}
|
|
559 |
||
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
560 |
result->column_buffer= malloc(sizeof(drizzle_column_st) * |
561 |
result->column_count); |
|
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
562 |
if (result->column_buffer == NULL) |
563 |
{
|
|
564 |
drizzle_set_error(result->con->drizzle, "drizzle_column_buffer", |
|
565 |
"malloc"); |
|
566 |
return DRIZZLE_RETURN_MEMORY; |
|
567 |
}
|
|
568 |
}
|
|
569 |
||
570 |
/* No while body, just keep calling to buffer columns. */
|
|
571 |
while (drizzle_column_read(result, |
|
572 |
&(result->column_buffer[result->column_current]), |
|
573 |
&ret) != NULL && ret == DRIZZLE_RETURN_OK); |
|
574 |
if (ret == DRIZZLE_RETURN_OK) |
|
575 |
{
|
|
576 |
result->column_current= 0; |
|
577 |
result->options|= DRIZZLE_RESULT_BUFFER_COLUMN; |
|
578 |
}
|
|
579 |
||
580 |
return ret; |
|
581 |
}
|
|
582 |
||
583 |
drizzle_column_st *drizzle_column_next(drizzle_result_st *result) |
|
584 |
{
|
|
585 |
if (result->column_current == result->column_count) |
|
586 |
return NULL; |
|
587 |
||
588 |
result->column_current++; |
|
589 |
return &(result->column_buffer[result->column_current - 1]); |
|
590 |
}
|
|
591 |
||
592 |
drizzle_column_st *drizzle_column_prev(drizzle_result_st *result) |
|
593 |
{
|
|
594 |
if (result->column_current == 0) |
|
595 |
return NULL; |
|
596 |
||
597 |
result->column_current--; |
|
598 |
return &(result->column_buffer[result->column_current]); |
|
599 |
}
|
|
600 |
||
601 |
void drizzle_column_seek(drizzle_result_st *result, uint16_t column) |
|
602 |
{
|
|
603 |
if (column <= result->column_count) |
|
604 |
result->column_current= column; |
|
605 |
}
|
|
606 |
||
607 |
drizzle_column_st *drizzle_column_index(drizzle_result_st *result, |
|
608 |
uint16_t column) |
|
609 |
{
|
|
610 |
if (column >= result->column_count) |
|
611 |
return NULL; |
|
612 |
||
613 |
return &(result->column_buffer[column]); |
|
614 |
}
|
|
615 |
||
616 |
uint16_t drizzle_column_current(drizzle_result_st *result) |
|
617 |
{
|
|
618 |
return result->column_current; |
|
619 |
}
|
|
620 |
||
621 |
/*
|
|
622 |
* Server definitions
|
|
623 |
*/
|
|
624 |
||
625 |
drizzle_return_t drizzle_column_write(drizzle_result_st *result, |
|
626 |
drizzle_column_st *column) |
|
627 |
{
|
|
628 |
if (drizzle_state_none(result->con)) |
|
629 |
{
|
|
630 |
result->column= column; |
|
631 |
||
632 |
drizzle_state_push(result->con, drizzle_state_column_write); |
|
633 |
}
|
|
634 |
||
635 |
return drizzle_state_loop(result->con); |
|
636 |
}
|
|
637 |
||
638 |
void drizzle_column_set_catalog(drizzle_column_st *column, const char *catalog) |
|
639 |
{
|
|
640 |
if (catalog == NULL) |
|
641 |
column->catalog[0]= 0; |
|
642 |
else
|
|
643 |
{
|
|
644 |
strncpy(column->catalog, catalog, DRIZZLE_MAX_CATALOG_SIZE); |
|
645 |
column->catalog[DRIZZLE_MAX_CATALOG_SIZE - 1]= 0; |
|
646 |
}
|
|
647 |
}
|
|
648 |
||
649 |
void drizzle_column_set_db(drizzle_column_st *column, const char *db) |
|
650 |
{
|
|
651 |
if (db == NULL) |
|
652 |
column->db[0]= 0; |
|
653 |
else
|
|
654 |
{
|
|
655 |
strncpy(column->db, db, DRIZZLE_MAX_DB_SIZE); |
|
656 |
column->db[DRIZZLE_MAX_DB_SIZE - 1]= 0; |
|
657 |
}
|
|
658 |
}
|
|
659 |
||
660 |
void drizzle_column_set_table(drizzle_column_st *column, const char *table) |
|
661 |
{
|
|
662 |
if (table == NULL) |
|
663 |
column->table[0]= 0; |
|
664 |
else
|
|
665 |
{
|
|
666 |
strncpy(column->table, table, DRIZZLE_MAX_TABLE_SIZE); |
|
667 |
column->table[DRIZZLE_MAX_TABLE_SIZE - 1]= 0; |
|
668 |
}
|
|
669 |
}
|
|
670 |
||
671 |
void drizzle_column_set_orig_table(drizzle_column_st *column, |
|
672 |
const char *orig_table) |
|
673 |
{
|
|
674 |
if (orig_table == NULL) |
|
675 |
column->orig_table[0]= 0; |
|
676 |
else
|
|
677 |
{
|
|
678 |
strncpy(column->orig_table, orig_table, DRIZZLE_MAX_TABLE_SIZE); |
|
679 |
column->orig_table[DRIZZLE_MAX_TABLE_SIZE - 1]= 0; |
|
680 |
}
|
|
681 |
}
|
|
682 |
||
683 |
void drizzle_column_set_name(drizzle_column_st *column, const char *name) |
|
684 |
{
|
|
685 |
if (name == NULL) |
|
686 |
column->name[0]= 0; |
|
687 |
else
|
|
688 |
{
|
|
689 |
strncpy(column->name, name, DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
690 |
column->name[DRIZZLE_MAX_COLUMN_NAME_SIZE - 1]= 0; |
|
691 |
}
|
|
692 |
}
|
|
693 |
||
694 |
void drizzle_column_set_orig_name(drizzle_column_st *column, |
|
695 |
const char *orig_name) |
|
696 |
{
|
|
697 |
if (orig_name == NULL) |
|
698 |
column->orig_name[0]= 0; |
|
699 |
else
|
|
700 |
{
|
|
701 |
strncpy(column->orig_name, orig_name, DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
702 |
column->orig_name[DRIZZLE_MAX_COLUMN_NAME_SIZE - 1]= 0; |
|
703 |
}
|
|
704 |
}
|
|
705 |
||
706 |
void drizzle_column_set_charset(drizzle_column_st *column, |
|
707 |
drizzle_charset_t charset) |
|
708 |
{
|
|
709 |
column->charset= charset; |
|
710 |
}
|
|
711 |
||
712 |
void drizzle_column_set_size(drizzle_column_st *column, uint32_t size) |
|
713 |
{
|
|
714 |
column->size= size; |
|
715 |
}
|
|
716 |
||
717 |
void drizzle_column_set_type(drizzle_column_st *column, |
|
718 |
drizzle_column_type_t type) |
|
719 |
{
|
|
720 |
column->type= type; |
|
721 |
}
|
|
722 |
||
723 |
void drizzle_column_set_flags(drizzle_column_st *column, |
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
724 |
drizzle_column_flags_t flags) |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
725 |
{
|
726 |
column->flags= flags; |
|
727 |
}
|
|
728 |
||
729 |
void drizzle_column_set_decimals(drizzle_column_st *column, uint8_t decimals) |
|
730 |
{
|
|
731 |
column->decimals= decimals; |
|
732 |
}
|
|
733 |
||
734 |
void drizzle_column_set_default_value(drizzle_column_st *column, |
|
735 |
const uint8_t *default_value, |
|
736 |
size_t size) |
|
737 |
{
|
|
738 |
if (default_value == NULL) |
|
739 |
column->default_value[0]= 0; |
|
740 |
else
|
|
741 |
{
|
|
742 |
if (size < DRIZZLE_MAX_DEFAULT_VALUE_SIZE) |
|
743 |
{
|
|
744 |
memcpy(column->default_value, default_value, size); |
|
745 |
column->default_value[size]= 0; |
|
746 |
column->default_value_size= size; |
|
747 |
}
|
|
748 |
else
|
|
749 |
{
|
|
750 |
memcpy(column->default_value, default_value, |
|
751 |
DRIZZLE_MAX_DEFAULT_VALUE_SIZE - 1); |
|
752 |
column->default_value[DRIZZLE_MAX_DEFAULT_VALUE_SIZE - 1]= 0; |
|
753 |
column->default_value_size= DRIZZLE_MAX_DEFAULT_VALUE_SIZE; |
|
754 |
}
|
|
755 |
}
|
|
756 |
}
|
|
757 |
||
758 |
/*
|
|
759 |
* Internal state functions.
|
|
760 |
*/
|
|
761 |
||
762 |
drizzle_return_t drizzle_state_column_read(drizzle_con_st *con) |
|
763 |
{
|
|
764 |
drizzle_column_st *column; |
|
765 |
drizzle_column_type_drizzle_t drizzle_type; |
|
766 |
||
767 |
drizzle_log_debug(con->drizzle, "drizzle_state_column_read"); |
|
768 |
||
769 |
/* Assume the entire column packet will fit in the buffer. */
|
|
770 |
if (con->buffer_size < con->packet_size) |
|
771 |
{
|
|
772 |
drizzle_state_push(con, drizzle_state_read); |
|
773 |
return DRIZZLE_RETURN_OK; |
|
774 |
}
|
|
775 |
||
776 |
if (con->packet_size == 5 && con->buffer_ptr[0] == 254) |
|
777 |
{
|
|
778 |
/* EOF packet marking end of columns. */
|
|
779 |
con->result->column= NULL; |
|
780 |
con->result->warning_count= drizzle_get_byte2(con->buffer_ptr + 1); |
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
781 |
con->status= drizzle_get_byte2(con->buffer_ptr + 3); |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
782 |
con->buffer_ptr+= 5; |
783 |
con->buffer_size-= 5; |
|
784 |
||
785 |
drizzle_state_pop(con); |
|
786 |
}
|
|
787 |
else if (con->result->options & DRIZZLE_RESULT_SKIP_COLUMN) |
|
788 |
{
|
|
789 |
con->buffer_ptr+= con->packet_size; |
|
790 |
con->buffer_size-= con->packet_size; |
|
791 |
con->packet_size= 0; |
|
792 |
||
793 |
drizzle_state_push(con, drizzle_state_packet_read); |
|
794 |
}
|
|
795 |
else
|
|
796 |
{
|
|
797 |
column= drizzle_column_create(con->result, con->result->column); |
|
798 |
if (column == NULL) |
|
799 |
return DRIZZLE_RETURN_MEMORY; |
|
800 |
||
801 |
con->result->column= column; |
|
802 |
||
803 |
/* These functions can only fail if they need to read data, but we know we
|
|
804 |
buffered the entire packet, so ignore returns. */
|
|
805 |
(void)drizzle_unpack_string(con, column->catalog, DRIZZLE_MAX_CATALOG_SIZE); |
|
806 |
(void)drizzle_unpack_string(con, column->db, DRIZZLE_MAX_DB_SIZE); |
|
807 |
(void)drizzle_unpack_string(con, column->table, DRIZZLE_MAX_TABLE_SIZE); |
|
808 |
(void)drizzle_unpack_string(con, column->orig_table, |
|
809 |
DRIZZLE_MAX_TABLE_SIZE); |
|
810 |
(void)drizzle_unpack_string(con, column->name, |
|
811 |
DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
812 |
(void)drizzle_unpack_string(con, column->orig_name, |
|
813 |
DRIZZLE_MAX_COLUMN_NAME_SIZE); |
|
814 |
||
815 |
/* Skip one filler byte. */
|
|
816 |
column->charset= (drizzle_charset_t)drizzle_get_byte2(con->buffer_ptr + 1); |
|
817 |
column->size= drizzle_get_byte4(con->buffer_ptr + 3); |
|
818 |
||
819 |
if (con->options & DRIZZLE_CON_MYSQL) |
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
820 |
column->type= con->buffer_ptr[7]; |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
821 |
else
|
822 |
{
|
|
1992.6.7
by Monty Taylor
Revert -Wc++-compat change. |
823 |
drizzle_type= con->buffer_ptr[7]; |
1712.1.1
by Monty Taylor
Merged libdrizzle directly into tree. |
824 |
if (drizzle_type >= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX) |
825 |
drizzle_type= DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX; |
|
826 |
column->type= _column_type_drizzle_map_to[drizzle_type]; |
|
827 |
}
|
|
828 |
||
829 |
column->flags= drizzle_get_byte2(con->buffer_ptr + 8); |
|
830 |
if (column->type <= DRIZZLE_COLUMN_TYPE_INT24 && |
|
831 |
column->type != DRIZZLE_COLUMN_TYPE_TIMESTAMP) |
|
832 |
{
|
|
833 |
column->flags|= DRIZZLE_COLUMN_FLAGS_NUM; |
|
834 |
}
|
|
835 |
||
836 |
column->decimals= con->buffer_ptr[10]; |
|
837 |
/* Skip two reserved bytes. */
|
|
838 |
||
839 |
con->buffer_ptr+= 13; |
|
840 |
con->buffer_size-= 13; |
|
841 |
con->packet_size-= 13; |
|
842 |
||
843 |
if (con->packet_size > 0) |
|
844 |
{
|
|
845 |
drizzle_column_set_default_value(column, con->buffer_ptr, |
|
846 |
con->packet_size); |
|
847 |
||
848 |
con->buffer_ptr+= con->packet_size; |
|
849 |
con->buffer_size-= con->packet_size; |
|
850 |
}
|
|
851 |
else
|
|
852 |
column->default_value[0]= 0; |
|
853 |
||
854 |
con->result->column_current++; |
|
855 |
||
856 |
drizzle_state_pop(con); |
|
857 |
}
|
|
858 |
||
859 |
return DRIZZLE_RETURN_OK; |
|
860 |
}
|
|
861 |
||
862 |
drizzle_return_t drizzle_state_column_write(drizzle_con_st *con) |
|
863 |
{
|
|
864 |
uint8_t *start= con->buffer_ptr + con->buffer_size; |
|
865 |
uint8_t *ptr; |
|
866 |
drizzle_column_st *column= con->result->column; |
|
867 |
||
868 |
drizzle_log_debug(con->drizzle, "drizzle_state_column_write"); |
|
869 |
||
870 |
/* Calculate max packet size. */
|
|
871 |
con->packet_size= 9 + strlen(column->catalog) |
|
872 |
+ 9 + strlen(column->db) |
|
873 |
+ 9 + strlen(column->table) |
|
874 |
+ 9 + strlen(column->orig_table) |
|
875 |
+ 9 + strlen(column->name) |
|
876 |
+ 9 + strlen(column->orig_name) |
|
877 |
+ 1 /* Unused */ |
|
878 |
+ 2 /* Charset */ |
|
879 |
+ 4 /* Size */ |
|
880 |
+ 1 /* Type */ |
|
881 |
+ 2 /* Flags */ |
|
882 |
+ 1 /* Decimals */ |
|
883 |
+ 2 /* Unused */ |
|
884 |
+ column->default_value_size; |
|
885 |
||
886 |
/* Assume the entire column packet will fit in the buffer. */
|
|
887 |
if ((con->packet_size + 4) > DRIZZLE_MAX_BUFFER_SIZE) |
|
888 |
{
|
|
889 |
drizzle_set_error(con->drizzle, "drizzle_state_column_write", |
|
890 |
"buffer too small:%zu", con->packet_size + 4); |
|
891 |
return DRIZZLE_RETURN_INTERNAL_ERROR; |
|
892 |
}
|
|
893 |
||
894 |
/* Flush buffer if there is not enough room. */
|
|
895 |
if (((size_t)DRIZZLE_MAX_BUFFER_SIZE - (size_t)(start - con->buffer)) < |
|
896 |
con->packet_size) |
|
897 |
{
|
|
898 |
drizzle_state_push(con, drizzle_state_write); |
|
899 |
return DRIZZLE_RETURN_OK; |
|
900 |
}
|
|
901 |
||
902 |
/* Store packet size at the end since it may change. */
|
|
903 |
ptr= start; |
|
904 |
ptr[3]= con->packet_number; |
|
905 |
con->packet_number++; |
|
906 |
ptr+= 4; |
|
907 |
||
908 |
ptr= drizzle_pack_string(column->catalog, ptr); |
|
909 |
ptr= drizzle_pack_string(column->db, ptr); |
|
910 |
ptr= drizzle_pack_string(column->table, ptr); |
|
911 |
ptr= drizzle_pack_string(column->orig_table, ptr); |
|
912 |
ptr= drizzle_pack_string(column->name, ptr); |
|
913 |
ptr= drizzle_pack_string(column->orig_name, ptr); |
|
914 |
||
915 |
/* This unused byte is set to 12 for some reason. */
|
|
916 |
ptr[0]= 12; |
|
917 |
ptr++; |
|
918 |
||
919 |
drizzle_set_byte2(ptr, column->charset); |
|
920 |
ptr+= 2; |
|
921 |
||
922 |
drizzle_set_byte4(ptr, column->size); |
|
923 |
ptr+= 4; |
|
924 |
||
925 |
if (con->options & DRIZZLE_CON_MYSQL) |
|
926 |
ptr[0]= column->type; |
|
927 |
else
|
|
928 |
ptr[0]= _column_type_drizzle_map_from[column->type]; |
|
929 |
ptr++; |
|
930 |
||
931 |
drizzle_set_byte2(ptr, column->flags); |
|
932 |
ptr+= 2; |
|
933 |
||
934 |
ptr[0]= column->decimals; |
|
935 |
ptr++; |
|
936 |
||
937 |
memset(ptr, 0, 2); |
|
938 |
ptr+= 2; |
|
939 |
||
940 |
if (column->default_value_size > 0) |
|
941 |
{
|
|
942 |
memcpy(ptr, column->default_value, column->default_value_size); |
|
943 |
ptr+= column->default_value_size; |
|
944 |
}
|
|
945 |
||
946 |
con->packet_size= ((size_t)(ptr - start) - 4); |
|
947 |
con->buffer_size+= (4 + con->packet_size); |
|
948 |
||
949 |
/* Store packet size now. */
|
|
950 |
drizzle_set_byte3(start, con->packet_size); |
|
951 |
||
952 |
con->result->column_current++; |
|
953 |
||
954 |
drizzle_state_pop(con); |
|
955 |
||
956 |
return DRIZZLE_RETURN_OK; |
|
957 |
}
|