56
56
drizzle_return_t *ret_ptr)
63
size_t size= strlen(query);
62
65
return drizzle_con_command_write(con, result, DRIZZLE_COMMAND_QUERY,
63
66
(uint8_t *)query, size, size, ret_ptr);
80
83
drizzle_query_options_t options,
83
91
query= drizzle_query_create(drizzle, query);
87
97
drizzle_query_set_con(query, con);
88
98
drizzle_query_set_result(query, result);
126
143
void drizzle_query_free(drizzle_query_st *query)
128
150
if (query->context != NULL && query->context_free_fn != NULL)
129
151
query->context_free_fn(query, query->context);
131
153
if (query->drizzle->query_list == query)
132
154
query->drizzle->query_list= query->next;
134
157
query->prev->next= query->next;
136
160
query->next->prev= query->prev;
137
161
query->drizzle->query_count--;
153
182
drizzle_con_st *drizzle_query_con(drizzle_query_st *query)
155
189
return query->con;
158
192
void drizzle_query_set_con(drizzle_query_st *query, drizzle_con_st *con)
163
202
drizzle_result_st *drizzle_query_result(drizzle_query_st *query)
165
209
return query->result;
168
212
void drizzle_query_set_result(drizzle_query_st *query,
169
213
drizzle_result_st *result)
171
220
query->result= result;
174
223
char *drizzle_query_string(drizzle_query_st *query, size_t *size)
177
235
return (char *)(query->string);
180
238
void drizzle_query_set_string(drizzle_query_st *query, const char *string,
183
246
query->string= string;
184
247
query->size= size;
187
250
drizzle_query_options_t drizzle_query_options(drizzle_query_st *query)
254
return drizzle_query_options_t();
189
257
return drizzle_query_options_t(query->options);
192
260
void drizzle_query_set_options(drizzle_query_st *query,
193
261
drizzle_query_options_t options)
195
268
query->options= options;
198
271
void drizzle_query_add_options(drizzle_query_st *query,
199
272
drizzle_query_options_t options)
201
279
query->options|= options;
204
282
void drizzle_query_remove_options(drizzle_query_st *query,
205
283
drizzle_query_options_t options)
207
290
query->options&= ~options;
210
293
void *drizzle_query_context(drizzle_query_st *query)
212
300
return query->context;
215
303
void drizzle_query_set_context(drizzle_query_st *query, void *context)
217
310
query->context= context;
220
313
void drizzle_query_set_context_free_fn(drizzle_query_st *query,
221
314
drizzle_query_context_free_fn *function)
223
321
query->context_free_fn= function;
226
324
static void drizzle_query_run_state(drizzle_query_st* query,
227
325
drizzle_return_t* ret_ptr)
327
drizzle_return_t unused_ret;
330
ret_ptr= &unused_ret;
335
*ret_ptr= DRIZZLE_RETURN_INVALID_ARGUMENT;
229
339
switch (query->state)
231
341
case DRIZZLE_QUERY_STATE_INIT:
264
374
drizzle_query_st *drizzle_query_run(drizzle_st *drizzle,
265
375
drizzle_return_t *ret_ptr)
377
drizzle_return_t unused_ret;
380
ret_ptr= &unused_ret;
385
*ret_ptr= DRIZZLE_RETURN_INVALID_ARGUMENT;
268
390
drizzle_query_st *query;
269
391
drizzle_con_st *con;
342
464
drizzle_return_t drizzle_query_run_all(drizzle_st *drizzle)
344
drizzle_return_t ret;
468
return DRIZZLE_RETURN_INVALID_ARGUMENT;
346
471
while (drizzle->query_new > 0 || drizzle->query_running > 0)
473
drizzle_return_t ret;
348
475
(void)drizzle_query_run(drizzle, &ret);
349
476
if (ret != DRIZZLE_RETURN_OK && ret != DRIZZLE_RETURN_ERROR_CODE)