Merge lp:~linuxjedi/libdrizzle/5.1-con-opts2 into lp:libdrizzle
- 5.1-con-opts2
- Merge into libdrizzle-redux
Proposed by
Andrew Hutchings
Status: | Merged |
---|---|
Approved by: | Andrew Hutchings |
Approved revision: | 97 |
Merged at revision: | 97 |
Proposed branch: | lp:~linuxjedi/libdrizzle/5.1-con-opts2 |
Merge into: | lp:libdrizzle |
Diff against target: |
678 lines (+237/-144) 11 files modified
libdrizzle-5.1/conn.h (+41/-42) libdrizzle-5.1/constants.h (+1/-23) libdrizzle-5.1/drizzle_client.h (+2/-2) libdrizzle/command.cc (+1/-2) libdrizzle/conn.cc (+127/-52) libdrizzle/drizzle.cc (+12/-6) libdrizzle/field.cc (+1/-1) libdrizzle/handshake.cc (+8/-6) libdrizzle/pack.cc (+2/-2) libdrizzle/statement.cc (+6/-6) libdrizzle/structs.h (+36/-2) |
To merge this branch: | bzr merge lp:~linuxjedi/libdrizzle/5.1-con-opts2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Drizzle Trunk | Pending | ||
Review via email: mp+145075@code.launchpad.net |
Commit message
Description of the change
Split out con options into state and options
To post a comment you must log in.
- 97. By Andrew Hutchings
-
Make con options safer
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'libdrizzle-5.1/conn.h' |
2 | --- libdrizzle-5.1/conn.h 2013-01-05 10:27:32 +0000 |
3 | +++ libdrizzle-5.1/conn.h 2013-01-26 23:33:19 +0000 |
4 | @@ -134,48 +134,47 @@ |
5 | DRIZZLE_API |
6 | const char *drizzle_sqlstate(const drizzle_st *con); |
7 | |
8 | -/** |
9 | - * Get options for a connection. |
10 | - * |
11 | - * @param[in] con Connection structure previously initialized with |
12 | - * drizzle_create(), drizzle_clone(), or related functions. |
13 | - * @return Options set for the connection structure. |
14 | - */ |
15 | -DRIZZLE_API |
16 | -drizzle_options_t drizzle_options(const drizzle_st *con); |
17 | - |
18 | -/** |
19 | - * Set options for a connection. |
20 | - * |
21 | - * @param[in] con Connection structure previously initialized with |
22 | - * drizzle_create(), drizzle_clone(), or related functions. |
23 | - * @param[in] options Available options for connection structure to set. |
24 | - */ |
25 | -DRIZZLE_API |
26 | -void drizzle_set_options(drizzle_st *con, |
27 | - drizzle_options_t options); |
28 | - |
29 | -/** |
30 | - * Add options for a connection. |
31 | - * |
32 | - * @param[in] con Connection structure previously initialized with |
33 | - * drizzle_create(), drizzle_clone(), or related functions. |
34 | - * @param[in] options Available options for connection structure to set. |
35 | - */ |
36 | -DRIZZLE_API |
37 | -void drizzle_add_options(drizzle_st *con, |
38 | - drizzle_options_t options); |
39 | - |
40 | -/** |
41 | - * Remove options for a connection. |
42 | - * |
43 | - * @param[in] con Connection structure previously initialized with |
44 | - * drizzle_create(), drizzle_clone(), or related functions. |
45 | - * @param[in] options Available options for connection structure to remove. |
46 | - */ |
47 | -DRIZZLE_API |
48 | -void drizzle_remove_options(drizzle_st *con, |
49 | - drizzle_options_t options); |
50 | +DRIZZLE_API |
51 | +drizzle_options_st *drizzle_options_create(void); |
52 | + |
53 | +DRIZZLE_API |
54 | +void drizzle_options_destroy(drizzle_options_st *options); |
55 | + |
56 | +DRIZZLE_API |
57 | +void drizzle_options_set_non_blocking(drizzle_options_st *options, bool state); |
58 | + |
59 | +DRIZZLE_API |
60 | +bool drizzle_options_get_non_blocking(drizzle_options_st *options); |
61 | + |
62 | +DRIZZLE_API |
63 | +void drizzle_options_set_raw_scramble(drizzle_options_st *options, bool state); |
64 | + |
65 | +DRIZZLE_API |
66 | +bool drizzle_options_get_raw_scramble(drizzle_options_st *options); |
67 | + |
68 | +DRIZZLE_API |
69 | +void drizzle_options_set_found_rows(drizzle_options_st *options, bool state); |
70 | + |
71 | +DRIZZLE_API |
72 | +bool drizzle_options_get_found_rows(drizzle_options_st *options); |
73 | + |
74 | +DRIZZLE_API |
75 | +void drizzle_options_set_interactive(drizzle_options_st *options, bool state); |
76 | + |
77 | +DRIZZLE_API |
78 | +bool drizzle_options_get_interactive(drizzle_options_st *option); |
79 | + |
80 | +DRIZZLE_API |
81 | +void drizzle_options_set_multi_statements(drizzle_options_st *options, bool state); |
82 | + |
83 | +DRIZZLE_API |
84 | +bool drizzle_options_get_multi_statements(drizzle_options_st *options); |
85 | + |
86 | +DRIZZLE_API |
87 | +void drizzle_options_set_auth_plugin(drizzle_options_st *options, bool state); |
88 | + |
89 | +DRIZZLE_API |
90 | +bool drizzle_options_get_auth_plugin(drizzle_options_st *options); |
91 | |
92 | /** |
93 | * Get TCP host for a connection. |
94 | |
95 | === modified file 'libdrizzle-5.1/constants.h' |
96 | --- libdrizzle-5.1/constants.h 2013-01-13 19:26:36 +0000 |
97 | +++ libdrizzle-5.1/constants.h 2013-01-26 23:33:19 +0000 |
98 | @@ -98,29 +98,6 @@ |
99 | |
100 | /** @} */ |
101 | |
102 | -/** |
103 | - * @ingroup drizzle_con |
104 | - * Options for drizzle_st. |
105 | - */ |
106 | -enum drizzle_options_t |
107 | -{ |
108 | - DRIZZLE_CON_NONE= 0, |
109 | - DRIZZLE_CON_OPTIONS_NON_BLOCKING= (1 << 0), |
110 | - DRIZZLE_CON_RAW_PACKET= (1 << 2), |
111 | - DRIZZLE_CON_RAW_SCRAMBLE= (1 << 3), |
112 | - DRIZZLE_CON_READY= (1 << 4), |
113 | - DRIZZLE_CON_NO_RESULT_READ= (1 << 5), |
114 | - DRIZZLE_CON_IO_READY= (1 << 6), |
115 | - DRIZZLE_CON_FOUND_ROWS= (1 << 9), |
116 | - DRIZZLE_CON_INTERACTIVE= (1 << 11), |
117 | - DRIZZLE_CON_MULTI_STATEMENTS= (1 << 12), |
118 | - DRIZZLE_CON_AUTH_PLUGIN= (1 << 13) |
119 | -}; |
120 | - |
121 | -#ifndef __cplusplus |
122 | -typedef enum drizzle_options_t drizzle_options_t; |
123 | -#endif |
124 | - |
125 | #ifndef __cplusplus |
126 | typedef enum drizzle_socket_t drizzle_socket_t; |
127 | #endif |
128 | @@ -583,6 +560,7 @@ |
129 | typedef struct drizzle_tcp_st drizzle_tcp_st; |
130 | typedef struct drizzle_uds_st drizzle_uds_st; |
131 | typedef struct drizzle_st drizzle_st; |
132 | +typedef struct drizzle_options_st drizzle_options_st; |
133 | typedef struct drizzle_result_st drizzle_result_st; |
134 | typedef struct drizzle_column_st drizzle_column_st; |
135 | typedef struct drizzle_binlog_st drizzle_binlog_st; |
136 | |
137 | === modified file 'libdrizzle-5.1/drizzle_client.h' |
138 | --- libdrizzle-5.1/drizzle_client.h 2013-01-05 15:46:05 +0000 |
139 | +++ libdrizzle-5.1/drizzle_client.h 2013-01-26 23:33:19 +0000 |
140 | @@ -98,7 +98,7 @@ |
141 | drizzle_st *drizzle_create_tcp(const char *host, in_port_t port, |
142 | const char *user, const char *password, |
143 | const char *db, |
144 | - drizzle_options_t options); |
145 | + drizzle_options_st *options); |
146 | |
147 | /** |
148 | * Add unix domain socket connection with common arguments. |
149 | @@ -113,7 +113,7 @@ |
150 | DRIZZLE_API |
151 | drizzle_st *drizzle_create_uds(const char *uds, const char *user, |
152 | const char *password, const char *db, |
153 | - drizzle_options_t options); |
154 | + drizzle_options_st *options); |
155 | |
156 | /** @} */ |
157 | |
158 | |
159 | === modified file 'libdrizzle/command.cc' |
160 | --- libdrizzle/command.cc 2013-01-13 18:54:59 +0000 |
161 | +++ libdrizzle/command.cc 2013-01-26 23:33:19 +0000 |
162 | @@ -157,8 +157,7 @@ |
163 | { |
164 | drizzle_state_pop(con); |
165 | |
166 | - if (!(con->options & (DRIZZLE_CON_RAW_PACKET | |
167 | - DRIZZLE_CON_NO_RESULT_READ)) && |
168 | + if (!(con->state.raw_packet || con->state.no_result_read) && |
169 | con->command != DRIZZLE_COMMAND_FIELD_LIST) |
170 | { |
171 | drizzle_state_push(con, drizzle_state_result_read); |
172 | |
173 | === modified file 'libdrizzle/conn.cc' |
174 | --- libdrizzle/conn.cc 2013-01-14 21:18:05 +0000 |
175 | +++ libdrizzle/conn.cc 2013-01-26 23:33:19 +0000 |
176 | @@ -220,7 +220,7 @@ |
177 | |
178 | __closesocket(con->fd); |
179 | |
180 | - con->options = (drizzle_options_t)((int)con->options & (int)~DRIZZLE_CON_READY); |
181 | + con->state.ready= false; |
182 | con->packet_number= 0; |
183 | con->buffer_ptr= con->buffer; |
184 | con->buffer_size= 0; |
185 | @@ -250,7 +250,7 @@ |
186 | } |
187 | |
188 | if (revents != 0) |
189 | - con->options = (drizzle_options_t)((int)con->options | (int)DRIZZLE_CON_IO_READY); |
190 | + con->state.io_ready= true; |
191 | |
192 | con->revents= revents; |
193 | |
194 | @@ -300,47 +300,122 @@ |
195 | return con->sqlstate; |
196 | } |
197 | |
198 | -drizzle_options_t drizzle_options(const drizzle_st *con) |
199 | -{ |
200 | - if (con == NULL) |
201 | - { |
202 | - return DRIZZLE_CON_NONE; |
203 | - } |
204 | - |
205 | - return drizzle_options_t(con->options); |
206 | -} |
207 | - |
208 | -void drizzle_set_options(drizzle_st *con, |
209 | - drizzle_options_t options) |
210 | -{ |
211 | - if (con == NULL) |
212 | - { |
213 | - return; |
214 | - } |
215 | - |
216 | - con->options= options; |
217 | -} |
218 | - |
219 | -void drizzle_add_options(drizzle_st *con, |
220 | - drizzle_options_t options) |
221 | -{ |
222 | - if (con == NULL) |
223 | - { |
224 | - return; |
225 | - } |
226 | - |
227 | - con->options = (drizzle_options_t)((int)con->options | (int)options); |
228 | -} |
229 | - |
230 | -void drizzle_remove_options(drizzle_st *con, |
231 | - drizzle_options_t options) |
232 | -{ |
233 | - if (con == NULL) |
234 | - { |
235 | - return; |
236 | - } |
237 | - |
238 | - con->options = (drizzle_options_t)((int) con->options & (int)~options); |
239 | +drizzle_options_st *drizzle_options_create(void) |
240 | +{ |
241 | + return new (std::nothrow) drizzle_options_st; |
242 | +} |
243 | + |
244 | +void drizzle_options_destroy(drizzle_options_st *options) |
245 | +{ |
246 | + delete options; |
247 | +} |
248 | + |
249 | +void drizzle_options_set_non_blocking(drizzle_options_st *options, bool state) |
250 | +{ |
251 | + if (options == NULL) |
252 | + { |
253 | + return; |
254 | + } |
255 | + options->non_blocking= state; |
256 | +} |
257 | + |
258 | +bool drizzle_options_get_non_blocking(drizzle_options_st *options) |
259 | +{ |
260 | + if (options == NULL) |
261 | + { |
262 | + return false; |
263 | + } |
264 | + return options->non_blocking; |
265 | +} |
266 | + |
267 | +void drizzle_options_set_raw_scramble(drizzle_options_st *options, bool state) |
268 | +{ |
269 | + if (options == NULL) |
270 | + { |
271 | + return; |
272 | + } |
273 | + options->raw_scramble= state; |
274 | +} |
275 | + |
276 | +bool drizzle_options_get_raw_scramble(drizzle_options_st *options) |
277 | +{ |
278 | + if (options == NULL) |
279 | + { |
280 | + return false; |
281 | + } |
282 | + return options->raw_scramble; |
283 | +} |
284 | + |
285 | +void drizzle_options_set_found_rows(drizzle_options_st *options, bool state) |
286 | +{ |
287 | + if (options == NULL) |
288 | + { |
289 | + return; |
290 | + } |
291 | + options->found_rows= state; |
292 | +} |
293 | + |
294 | +bool drizzle_options_get_found_rows(drizzle_options_st *options) |
295 | +{ |
296 | + if (options == NULL) |
297 | + { |
298 | + return false; |
299 | + } |
300 | + return options->found_rows; |
301 | +} |
302 | + |
303 | +void drizzle_options_set_interactive(drizzle_options_st *options, bool state) |
304 | +{ |
305 | + if (options == NULL) |
306 | + { |
307 | + return; |
308 | + } |
309 | + options->interactive= state; |
310 | +} |
311 | + |
312 | +bool drizzle_options_get_interactive(drizzle_options_st *options) |
313 | +{ |
314 | + if (options == NULL) |
315 | + { |
316 | + return false; |
317 | + } |
318 | + return options->interactive; |
319 | +} |
320 | + |
321 | +void drizzle_options_set_multi_statements(drizzle_options_st *options, bool state) |
322 | +{ |
323 | + if (options == NULL) |
324 | + { |
325 | + return; |
326 | + } |
327 | + options->multi_statements= state; |
328 | +} |
329 | + |
330 | +bool drizzle_options_get_multi_statements(drizzle_options_st *options) |
331 | +{ |
332 | + if (options == NULL) |
333 | + { |
334 | + return false; |
335 | + } |
336 | + return options->multi_statements; |
337 | +} |
338 | + |
339 | +void drizzle_options_set_auth_plugin(drizzle_options_st *options, bool state) |
340 | +{ |
341 | + if (options == NULL) |
342 | + { |
343 | + return; |
344 | + } |
345 | + options->auth_plugin= state; |
346 | +} |
347 | + |
348 | +bool drizzle_options_get_auth_plugin(drizzle_options_st *options) |
349 | +{ |
350 | + if (options == NULL) |
351 | + { |
352 | + return false; |
353 | + } |
354 | + return options->auth_plugin; |
355 | } |
356 | |
357 | const char *drizzle_host(const drizzle_st *con) |
358 | @@ -610,14 +685,14 @@ |
359 | return DRIZZLE_RETURN_INVALID_ARGUMENT; |
360 | } |
361 | |
362 | - if (con->options & DRIZZLE_CON_READY) |
363 | + if (con->state.ready) |
364 | { |
365 | return DRIZZLE_RETURN_OK; |
366 | } |
367 | |
368 | if (drizzle_state_none(con)) |
369 | { |
370 | - if (!(con->options & DRIZZLE_CON_RAW_PACKET)) |
371 | + if (con->state.raw_packet == false) |
372 | { |
373 | drizzle_state_push(con, drizzle_state_handshake_server_read); |
374 | drizzle_state_push(con, drizzle_state_packet_read); |
375 | @@ -721,9 +796,9 @@ |
376 | |
377 | drizzle_result_st *old_result; |
378 | |
379 | - if (!(con->options & DRIZZLE_CON_READY)) |
380 | + if (con->state.ready == false) |
381 | { |
382 | - if (con->options & DRIZZLE_CON_RAW_PACKET) |
383 | + if (con->state.raw_packet) |
384 | { |
385 | drizzle_set_error(con, "drizzle_command_write", |
386 | "connection not ready"); |
387 | @@ -740,7 +815,7 @@ |
388 | |
389 | if (drizzle_state_none(con)) |
390 | { |
391 | - if (con->options & (DRIZZLE_CON_RAW_PACKET | DRIZZLE_CON_NO_RESULT_READ)) |
392 | + if (con->state.raw_packet || con->state.no_result_read) |
393 | { |
394 | con->result= NULL; |
395 | } |
396 | @@ -1097,7 +1172,7 @@ |
397 | } |
398 | |
399 | ret= drizzle_set_events(con, POLLOUT); |
400 | - if (con->options & DRIZZLE_CON_OPTIONS_NON_BLOCKING) |
401 | + if (con->options.non_blocking) |
402 | { |
403 | return DRIZZLE_RETURN_IO_WAIT; |
404 | } |
405 | @@ -1133,7 +1208,7 @@ |
406 | } |
407 | |
408 | if ((con->revents & POLLIN) == 0 && |
409 | - (con->options & DRIZZLE_CON_OPTIONS_NON_BLOCKING)) |
410 | + (con->options.non_blocking)) |
411 | { |
412 | /* non-blocking mode: return IO_WAIT instead of attempting to read. This |
413 | * avoids reading immediately after writing a command, which typically |
414 | @@ -1225,7 +1300,7 @@ |
415 | return ret; |
416 | } |
417 | |
418 | - if (con->options & DRIZZLE_CON_OPTIONS_NON_BLOCKING) |
419 | + if (con->options.non_blocking) |
420 | { |
421 | return DRIZZLE_RETURN_IO_WAIT; |
422 | } |
423 | @@ -1332,7 +1407,7 @@ |
424 | return ret; |
425 | } |
426 | |
427 | - if (con->options & DRIZZLE_CON_OPTIONS_NON_BLOCKING) |
428 | + if (con->options.non_blocking) |
429 | { |
430 | return DRIZZLE_RETURN_IO_WAIT; |
431 | } |
432 | |
433 | === modified file 'libdrizzle/drizzle.cc' |
434 | --- libdrizzle/drizzle.cc 2013-01-13 19:26:36 +0000 |
435 | +++ libdrizzle/drizzle.cc 2013-01-26 23:33:19 +0000 |
436 | @@ -268,9 +268,9 @@ |
437 | /* We can't keep state between calls since connections may be removed during |
438 | processing. If this list ever gets big, we may want something faster. */ |
439 | |
440 | - if (con->options & DRIZZLE_CON_IO_READY) |
441 | + if (con->state.io_ready) |
442 | { |
443 | - con->options = (drizzle_options_t)((int)con->options & (int)~DRIZZLE_CON_IO_READY); |
444 | + con->state.io_ready= false; |
445 | return con; |
446 | } |
447 | |
448 | @@ -284,7 +284,7 @@ |
449 | drizzle_st *drizzle_create_tcp(const char *host, in_port_t port, |
450 | const char *user, const char *password, |
451 | const char *db, |
452 | - drizzle_options_t options) |
453 | + drizzle_options_st *options) |
454 | { |
455 | drizzle_st *con= drizzle_create(); |
456 | if (con == NULL) |
457 | @@ -295,14 +295,17 @@ |
458 | drizzle_set_tcp(con, host, port); |
459 | drizzle_set_auth(con, user, password); |
460 | drizzle_set_db(con, db); |
461 | - drizzle_add_options(con, options); |
462 | + if (options != NULL) |
463 | + { |
464 | + con->options= *options; |
465 | + } |
466 | |
467 | return con; |
468 | } |
469 | |
470 | drizzle_st *drizzle_create_uds(const char *uds, const char *user, |
471 | const char *password, const char *db, |
472 | - drizzle_options_t options) |
473 | + drizzle_options_st *options) |
474 | { |
475 | drizzle_st *con; |
476 | |
477 | @@ -315,7 +318,10 @@ |
478 | drizzle_set_uds(con, uds); |
479 | drizzle_set_auth(con, user, password); |
480 | drizzle_set_db(con, db); |
481 | - drizzle_add_options(con, options); |
482 | + if (options != NULL) |
483 | + { |
484 | + con->options= *options; |
485 | + } |
486 | |
487 | return con; |
488 | } |
489 | |
490 | === modified file 'libdrizzle/field.cc' |
491 | --- libdrizzle/field.cc 2013-01-15 13:37:21 +0000 |
492 | +++ libdrizzle/field.cc 2013-01-26 23:33:19 +0000 |
493 | @@ -257,7 +257,7 @@ |
494 | { |
495 | con->result->field_size= con->packet_size; |
496 | |
497 | - if (con->options & DRIZZLE_CON_RAW_PACKET) |
498 | + if (con->state.raw_packet) |
499 | { |
500 | con->result->options = (drizzle_result_options_t)((int)con->result->options | DRIZZLE_RESULT_ROW_BREAK); |
501 | } |
502 | |
503 | === modified file 'libdrizzle/handshake.cc' |
504 | --- libdrizzle/handshake.cc 2013-01-13 18:54:59 +0000 |
505 | +++ libdrizzle/handshake.cc 2013-01-26 23:33:19 +0000 |
506 | @@ -200,7 +200,7 @@ |
507 | |
508 | drizzle_state_pop(con); |
509 | |
510 | - if (!(con->options & DRIZZLE_CON_RAW_PACKET)) |
511 | + if (con->state.raw_packet == false) |
512 | { |
513 | drizzle_state_push(con, drizzle_state_handshake_result_read); |
514 | drizzle_state_push(con, drizzle_state_packet_read); |
515 | @@ -481,20 +481,22 @@ |
516 | con->capabilities = (drizzle_capabilities_t)((int)con->capabilities | (int)DRIZZLE_CAPABILITIES_PROTOCOL_41); |
517 | |
518 | capabilities= con->capabilities & DRIZZLE_CAPABILITIES_CLIENT; |
519 | - if (!(con->options & DRIZZLE_CON_FOUND_ROWS)) |
520 | + if (con->options.found_rows == false) |
521 | + { |
522 | capabilities&= ~DRIZZLE_CAPABILITIES_FOUND_ROWS; |
523 | + } |
524 | |
525 | - if (con->options & DRIZZLE_CON_INTERACTIVE) |
526 | + if (con->options.interactive) |
527 | { |
528 | capabilities|= DRIZZLE_CAPABILITIES_INTERACTIVE; |
529 | } |
530 | |
531 | - if (con->options & DRIZZLE_CON_MULTI_STATEMENTS) |
532 | + if (con->options.multi_statements) |
533 | { |
534 | capabilities|= DRIZZLE_CAPABILITIES_MULTI_STATEMENTS; |
535 | } |
536 | |
537 | - if (con->options & DRIZZLE_CON_AUTH_PLUGIN) |
538 | + if (con->options.auth_plugin) |
539 | { |
540 | capabilities|= DRIZZLE_CAPABILITIES_PLUGIN_AUTH; |
541 | } |
542 | @@ -664,7 +666,7 @@ |
543 | } |
544 | else |
545 | { |
546 | - con->options = (drizzle_options_t)((int)con->options | (int)DRIZZLE_CON_READY); |
547 | + con->state.ready= true; |
548 | } |
549 | } |
550 | } |
551 | |
552 | === modified file 'libdrizzle/pack.cc' |
553 | --- libdrizzle/pack.cc 2013-01-05 10:27:32 +0000 |
554 | +++ libdrizzle/pack.cc 2013-01-26 23:33:19 +0000 |
555 | @@ -356,7 +356,7 @@ |
556 | ptr[0]= 0; |
557 | ptr++; |
558 | |
559 | - if (con->options & DRIZZLE_CON_RAW_SCRAMBLE && con->scramble != NULL) |
560 | + if (con->options.raw_scramble && con->scramble != NULL) |
561 | { |
562 | ptr[0]= DRIZZLE_MAX_SCRAMBLE_SIZE; |
563 | ptr++; |
564 | @@ -375,7 +375,7 @@ |
565 | ptr[0]= DRIZZLE_MAX_SCRAMBLE_SIZE; |
566 | ptr++; |
567 | |
568 | - if (con->options & DRIZZLE_CON_AUTH_PLUGIN) |
569 | + if (con->options.auth_plugin) |
570 | { |
571 | snprintf((char *)ptr, DRIZZLE_MAX_SCRAMBLE_SIZE, "%s", con->password); |
572 | ptr[DRIZZLE_MAX_SCRAMBLE_SIZE-1]= 0; |
573 | |
574 | === modified file 'libdrizzle/statement.cc' |
575 | --- libdrizzle/statement.cc 2013-01-15 13:37:21 +0000 |
576 | +++ libdrizzle/statement.cc 2013-01-26 23:33:19 +0000 |
577 | @@ -334,10 +334,10 @@ |
578 | drizzle_set_byte2(&buffer[4], param_num); |
579 | memcpy(&buffer[6], data, len); |
580 | |
581 | - stmt->con->options= (drizzle_options_t)((uint8_t)stmt->con->options | (uint8_t)DRIZZLE_CON_NO_RESULT_READ); |
582 | + stmt->con->state.no_result_read= true; |
583 | drizzle_command_write(stmt->con, NULL, DRIZZLE_COMMAND_STMT_SEND_LONG_DATA, |
584 | buffer, len+6, len+6, &ret); |
585 | - stmt->con->options= (drizzle_options_t)((uint8_t)stmt->con->options & (uint8_t)~DRIZZLE_CON_NO_RESULT_READ); |
586 | + stmt->con->state.no_result_read= false; |
587 | stmt->query_params[param_num].options.is_long_data= true; |
588 | |
589 | delete[] buffer; |
590 | @@ -361,10 +361,10 @@ |
591 | } |
592 | |
593 | drizzle_set_byte4(buffer, stmt->id); |
594 | - stmt->con->options= (drizzle_options_t)((uint8_t)stmt->con->options | (uint8_t)DRIZZLE_CON_NO_RESULT_READ); |
595 | + stmt->con->state.no_result_read= true; |
596 | drizzle_command_write(stmt->con, NULL, DRIZZLE_COMMAND_STMT_RESET, buffer, 4, |
597 | 4, &ret); |
598 | - stmt->con->options= (drizzle_options_t)((uint8_t)stmt->con->options & (uint8_t)~DRIZZLE_CON_NO_RESULT_READ); |
599 | + stmt->con->state.no_result_read= false; |
600 | if (stmt->execute_result) |
601 | { |
602 | drizzle_result_free(stmt->execute_result); |
603 | @@ -570,10 +570,10 @@ |
604 | } |
605 | |
606 | drizzle_set_byte4(buffer, stmt->id); |
607 | - stmt->con->options= (drizzle_options_t)((uint8_t)stmt->con->options | (uint8_t)DRIZZLE_CON_NO_RESULT_READ); |
608 | + stmt->con->state.no_result_read= true; |
609 | drizzle_command_write(stmt->con, NULL, DRIZZLE_COMMAND_STMT_CLOSE, buffer, 4, |
610 | 4, &ret); |
611 | - stmt->con->options= (drizzle_options_t)((uint8_t)stmt->con->options & (uint8_t)~DRIZZLE_CON_NO_RESULT_READ); |
612 | + stmt->con->state.no_result_read= false; |
613 | delete stmt; |
614 | return ret; |
615 | } |
616 | |
617 | === modified file 'libdrizzle/structs.h' |
618 | --- libdrizzle/structs.h 2013-01-15 13:37:21 +0000 |
619 | +++ libdrizzle/structs.h 2013-01-26 23:33:19 +0000 |
620 | @@ -147,6 +147,26 @@ |
621 | /** |
622 | * @ingroup drizzle_con |
623 | */ |
624 | + |
625 | +struct drizzle_options_st |
626 | +{ |
627 | + bool non_blocking; |
628 | + bool raw_scramble; |
629 | + bool found_rows; |
630 | + bool interactive; |
631 | + bool multi_statements; |
632 | + bool auth_plugin; |
633 | + |
634 | + drizzle_options_st() : |
635 | + non_blocking(false), |
636 | + raw_scramble(false), |
637 | + found_rows(false), |
638 | + interactive(false), |
639 | + multi_statements(false), |
640 | + auth_plugin(false) |
641 | + { } |
642 | +}; |
643 | + |
644 | struct drizzle_st |
645 | { |
646 | struct flags_t{ |
647 | @@ -164,7 +184,22 @@ |
648 | drizzle_capabilities_t capabilities; |
649 | drizzle_charset_t charset; |
650 | drizzle_command_t command; |
651 | - drizzle_options_t options; |
652 | + struct state_t |
653 | + { |
654 | + bool ready; |
655 | + bool no_result_read; |
656 | + bool io_ready; |
657 | + bool raw_packet; |
658 | + |
659 | + state_t() : |
660 | + ready(false), |
661 | + no_result_read(false), |
662 | + io_ready(false), |
663 | + raw_packet(false) |
664 | + { } |
665 | + } state; |
666 | + |
667 | + drizzle_options_st options; |
668 | drizzle_socket_t socket_type; |
669 | drizzle_status_t status; |
670 | uint32_t max_packet_size; |
671 | @@ -228,7 +263,6 @@ |
672 | capabilities(DRIZZLE_CAPABILITIES_NONE), |
673 | charset(DRIZZLE_CHARSET_NONE), |
674 | command(DRIZZLE_COMMAND_SLEEP), |
675 | - options(DRIZZLE_CON_NONE), |
676 | socket_type(DRIZZLE_CON_SOCKET_TCP), |
677 | status(DRIZZLE_CON_STATUS_NONE), |
678 | max_packet_size(DRIZZLE_MAX_PACKET_SIZE), |