2
* Drizzle Client & Protocol Library
4
* Copyright (C) 2008 Eric Day (eday@oddments.org)
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are
11
* * Redistributions of source code must retain the above copyright
12
* notice, this list of conditions and the following disclaimer.
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
19
* * The names of its contributors may not be used to endorse or
20
* promote products derived from this software without specific prior
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.
39
* @brief Query Declarations
42
#ifndef __DRIZZLE_QUERY_H
43
#define __DRIZZLE_QUERY_H
50
* @addtogroup drizzle_query Query Declarations
52
* @ingroup drizzle_client_interface
53
* These functions are used to issue queries on a connection. Single queries are
54
* made using the drizzle_query function, or you can queue multiple queries and
55
* run them concurrently using the other query functions.
60
* Send query to server. A \ref drizzle_result_st will be created for the
63
* @param[in] con connection to use to send the query.
64
* @param[in,out] result pointer to an unused structure that will be used for
65
* the results, or NULL to allocate a new structure.
66
* @param[in] query query string to send.
67
* @param[in] size length of the query string in bytes.
68
* @param[out] ret_ptr pointer to the result code.
69
* @return result, a pointer to the newly allocated result structure, or NULL
70
* if the allocation failed.
73
drizzle_result_st *drizzle_query(drizzle_con_st *con, drizzle_result_st *result,
74
const char *query, size_t size,
75
drizzle_return_t *ret_ptr);
78
* Send query to server, using strlen to get the size of query buffer..
81
drizzle_result_st *drizzle_query_str(drizzle_con_st *con,
82
drizzle_result_st *result,
84
drizzle_return_t *ret_ptr);
87
* Send query incrementally.
90
drizzle_result_st *drizzle_query_inc(drizzle_con_st *con,
91
drizzle_result_st *result,
92
const char *query, size_t size,
93
size_t total, drizzle_return_t *ret_ptr);
96
* Add a query to be run concurrently.
99
drizzle_query_st *drizzle_query_add(drizzle_st *drizzle,
100
drizzle_query_st *query,
102
drizzle_result_st *result,
103
const char *query_string, size_t size,
104
drizzle_query_options_t options,
108
* Initialize a query structure.
111
drizzle_query_st *drizzle_query_create(drizzle_st *drizzle,
112
drizzle_query_st *query);
115
* Free a query structure.
118
void drizzle_query_free(drizzle_query_st *query);
121
* Free a query structure.
124
void drizzle_query_free_all(drizzle_st *drizzle);
127
* Get connection struct for a query.
130
drizzle_con_st *drizzle_query_con(drizzle_query_st *query);
133
* Set connection struct for a query.
136
void drizzle_query_set_con(drizzle_query_st *query, drizzle_con_st *con);
139
* Get result struct for a query.
142
drizzle_result_st *drizzle_query_result(drizzle_query_st *query);
145
* Set result struct for a query.
148
void drizzle_query_set_result(drizzle_query_st *query,
149
drizzle_result_st *result);
152
* Get query string for a query.
155
char *drizzle_query_string(drizzle_query_st *query, size_t *size);
158
* Set query string for a query.
161
void drizzle_query_set_string(drizzle_query_st *query, const char *string,
165
* Get options for a query.
168
int drizzle_query_options(drizzle_query_st *query);
171
* Set options for a query.
174
void drizzle_query_set_options(drizzle_query_st *query,
178
* Add options for a query.
181
void drizzle_query_add_options(drizzle_query_st *query,
185
* Remove options for a query.
188
void drizzle_query_remove_options(drizzle_query_st *query,
192
* Get application context for a query.
195
void *drizzle_query_context(drizzle_query_st *query);
198
* Set application context for a query.
201
void drizzle_query_set_context(drizzle_query_st *query, void *context);
204
* Set callback function when the context pointer should be freed.
207
void drizzle_query_set_context_free_fn(drizzle_query_st *query,
208
drizzle_query_context_free_fn *function);
211
* Run queries concurrently, returning when one is complete.
214
drizzle_query_st *drizzle_query_run(drizzle_st *drizzle,
215
drizzle_return_t *ret_ptr);
218
* Run queries until they are all complete. Returns \ref DRIZZLE_RETURN_OK if
219
* all queries complete, even if some return errors. This returns immediately
220
* if some other error occurs, leaving some queries unprocessed. You must call
221
* drizzle_result_error_code() to check if each query succeeded.
224
drizzle_return_t drizzle_query_run_all(drizzle_st *drizzle);
227
* Escape a string or encode a string in hexadecimal. The return value is the
228
* size of the output string in to.
231
size_t drizzle_escape_string(char *to, const char *from, size_t from_size);
233
ssize_t drizzle_safe_escape_string(char *to, size_t max_to_size, const char *from, size_t from_size);
235
size_t drizzle_hex_string(char *to, const char *from, size_t from_size);
237
void drizzle_mysql_password_hash(char *to, const char *from, size_t from_size);
245
#endif /* __DRIZZLE_QUERY_H */