2
* Drizzle Client & Protocol Library
4
* Copyright (C) 2008 Eric Day (eday@oddments.org)
7
* Use and distribution licensed under the BSD license. See
8
* the COPYING file in this directory for full text.
13
* @brief Query Declarations
16
#ifndef __DRIZZLE_QUERY_H
17
#define __DRIZZLE_QUERY_H
24
* @addtogroup drizzle_query Query Declarations
26
* @ingroup drizzle_client_interface
27
* These functions are used to issue queries on a connection. Single queries are
28
* made using the drizzle_query function, or you can queue multiple queries and
29
* run them concurrently using the other query functions.
34
* Send query to server. A \ref drizzle_result_st will be created for the
37
* @param[in] con connection to use to send the query.
38
* @param[in,out] result pointer to an unused structure that will be used for
39
* the results, or NULL to allocate a new structure.
40
* @param[in] query query string to send.
41
* @param[in] size length of the query string in bytes.
42
* @param[out] ret_ptr pointer to the result code.
43
* @return result, a pointer to the newly allocated result structure, or NULL
44
* if the allocation failed.
47
drizzle_result_st *drizzle_query(drizzle_con_st *con, drizzle_result_st *result,
48
const char *query, size_t size,
49
drizzle_return_t *ret_ptr);
52
* Send query to server, using strlen to get the size of query buffer..
55
drizzle_result_st *drizzle_query_str(drizzle_con_st *con,
56
drizzle_result_st *result,
58
drizzle_return_t *ret_ptr);
61
* Send query incrementally.
64
drizzle_result_st *drizzle_query_inc(drizzle_con_st *con,
65
drizzle_result_st *result,
66
const char *query, size_t size,
67
size_t total, drizzle_return_t *ret_ptr);
70
* Add a query to be run concurrently.
73
drizzle_query_st *drizzle_query_add(drizzle_st *drizzle,
74
drizzle_query_st *query,
76
drizzle_result_st *result,
77
const char *query_string, size_t size,
78
drizzle_query_options_t options,
82
* Initialize a query structure.
85
drizzle_query_st *drizzle_query_create(drizzle_st *drizzle,
86
drizzle_query_st *query);
89
* Free a query structure.
92
void drizzle_query_free(drizzle_query_st *query);
95
* Free a query structure.
98
void drizzle_query_free_all(drizzle_st *drizzle);
101
* Get connection struct for a query.
104
drizzle_con_st *drizzle_query_con(drizzle_query_st *query);
107
* Set connection struct for a query.
110
void drizzle_query_set_con(drizzle_query_st *query, drizzle_con_st *con);
113
* Get result struct for a query.
116
drizzle_result_st *drizzle_query_result(drizzle_query_st *query);
119
* Set result struct for a query.
122
void drizzle_query_set_result(drizzle_query_st *query,
123
drizzle_result_st *result);
126
* Get query string for a query.
129
char *drizzle_query_string(drizzle_query_st *query, size_t *size);
132
* Set query string for a query.
135
void drizzle_query_set_string(drizzle_query_st *query, const char *string,
139
* Get options for a query.
142
drizzle_query_options_t drizzle_query_options(drizzle_query_st *query);
145
* Set options for a query.
148
void drizzle_query_set_options(drizzle_query_st *query,
149
drizzle_query_options_t options);
152
* Add options for a query.
155
void drizzle_query_add_options(drizzle_query_st *query,
156
drizzle_query_options_t options);
159
* Remove options for a query.
162
void drizzle_query_remove_options(drizzle_query_st *query,
163
drizzle_query_options_t options);
166
* Get application context for a query.
169
void *drizzle_query_context(drizzle_query_st *query);
172
* Set application context for a query.
175
void drizzle_query_set_context(drizzle_query_st *query, void *context);
178
* Set callback function when the context pointer should be freed.
181
void drizzle_query_set_context_free_fn(drizzle_query_st *query,
182
drizzle_query_context_free_fn *function);
185
* Run queries concurrently, returning when one is complete.
188
drizzle_query_st *drizzle_query_run(drizzle_st *drizzle,
189
drizzle_return_t *ret_ptr);
192
* Run queries until they are all complete. Returns \ref DRIZZLE_RETURN_OK if
193
* all queries complete, even if some return errors. This returns immediately
194
* if some other error occurs, leaving some queries unprocessed. You must call
195
* drizzle_result_error_code() to check if each query succeeded.
198
drizzle_return_t drizzle_query_run_all(drizzle_st *drizzle);
201
* Escape a string or encode a string in hexadecimal. The return value is the
202
* size of the output string in to.
205
size_t drizzle_escape_string(char *to, const char *from, size_t from_size);
207
size_t drizzle_hex_string(char *to, const char *from, size_t from_size);
209
void drizzle_mysql_password_hash(char *to, const char *from, size_t from_size);
217
#endif /* __DRIZZLE_QUERY_H */