~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/query.h

  • Committer: Mats Kindahl
  • Date: 2008-08-26 07:32:59 UTC
  • mto: (489.1.2 codestyle)
  • mto: This revision was merged to the branch mainline in revision 491.
  • Revision ID: mats@mysql.com-20080826073259-9k4evtajgldgolli
Replaced use of thd_proc_info() macro with calls to
set_proc_info() and get_proc_info() internally.  Introduced
functions set_thd_proc_info() and get_thd_proc_info() for
external users, i.e., plug-ins.

The set_thd_proc_info() accepted callers info that can be used to
print debug output, but the information was not used. The return
value was changed to void and the old value is not fetched any
more. To be able to get the value of proc_info for external
users, the function get_thd_proc_info() was introduced.

The thd_proc_info() macro called set_thd_proc_info() but almost
never used the return value of set_thd_proc_info() so the macro
was replaced with a call of THD::set_proc_info().

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Drizzle Client & Protocol Library
3
 
 *
4
 
 * Copyright (C) 2008 Eric Day (eday@oddments.org)
5
 
 * All rights reserved.
6
 
 *
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
 
 *
35
 
 */
36
 
 
37
 
/**
38
 
 * @file
39
 
 * @brief Query Declarations
40
 
 */
41
 
 
42
 
#ifndef __DRIZZLE_QUERY_H
43
 
#define __DRIZZLE_QUERY_H
44
 
 
45
 
#ifdef __cplusplus
46
 
extern "C" {
47
 
#endif
48
 
 
49
 
/**
50
 
 * @addtogroup drizzle_query Query Declarations
51
 
 *
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.
56
 
 * @{
57
 
 */
58
 
 
59
 
/**
60
 
 * Send query to server. A \ref drizzle_result_st will be created for the
61
 
 * results.
62
 
 *
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.
71
 
 */
72
 
DRIZZLE_API
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);
76
 
 
77
 
/**
78
 
 * Send query to server, using strlen to get the size of query buffer..
79
 
 */
80
 
DRIZZLE_API
81
 
drizzle_result_st *drizzle_query_str(drizzle_con_st *con,
82
 
                                     drizzle_result_st *result,
83
 
                                     const char *query,
84
 
                                     drizzle_return_t *ret_ptr);
85
 
 
86
 
/**
87
 
 * Send query incrementally.
88
 
 */
89
 
DRIZZLE_API
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);
94
 
 
95
 
/**
96
 
 * Add a query to be run concurrently.
97
 
 */
98
 
DRIZZLE_API
99
 
drizzle_query_st *drizzle_query_add(drizzle_st *drizzle,
100
 
                                    drizzle_query_st *query,
101
 
                                    drizzle_con_st *con,
102
 
                                    drizzle_result_st *result,
103
 
                                    const char *query_string, size_t size,
104
 
                                    drizzle_query_options_t options,
105
 
                                    void *context);
106
 
 
107
 
/**
108
 
 * Initialize a query structure.
109
 
 */
110
 
DRIZZLE_API
111
 
drizzle_query_st *drizzle_query_create(drizzle_st *drizzle,
112
 
                                       drizzle_query_st *query);
113
 
 
114
 
/**
115
 
 * Free a query structure.
116
 
 */
117
 
DRIZZLE_API
118
 
void drizzle_query_free(drizzle_query_st *query);
119
 
 
120
 
/**
121
 
 * Free a query structure.
122
 
 */
123
 
DRIZZLE_API
124
 
void drizzle_query_free_all(drizzle_st *drizzle);
125
 
 
126
 
/**
127
 
 * Get connection struct for a query.
128
 
 */
129
 
DRIZZLE_API
130
 
drizzle_con_st *drizzle_query_con(drizzle_query_st *query);
131
 
 
132
 
/**
133
 
 * Set connection struct for a query.
134
 
 */
135
 
DRIZZLE_API
136
 
void drizzle_query_set_con(drizzle_query_st *query, drizzle_con_st *con);
137
 
 
138
 
/**
139
 
 * Get result struct for a query.
140
 
 */
141
 
DRIZZLE_API
142
 
drizzle_result_st *drizzle_query_result(drizzle_query_st *query);
143
 
 
144
 
/**
145
 
 * Set result struct for a query.
146
 
 */
147
 
DRIZZLE_API
148
 
void drizzle_query_set_result(drizzle_query_st *query,
149
 
                              drizzle_result_st *result);
150
 
 
151
 
/**
152
 
 * Get query string for a query.
153
 
 */
154
 
DRIZZLE_API
155
 
char *drizzle_query_string(drizzle_query_st *query, size_t *size);
156
 
 
157
 
/**
158
 
 * Set query string for a query.
159
 
 */
160
 
DRIZZLE_API
161
 
void drizzle_query_set_string(drizzle_query_st *query, const char *string,
162
 
                              size_t size);
163
 
 
164
 
/**
165
 
 * Get options for a query. 
166
 
 */
167
 
DRIZZLE_API
168
 
drizzle_query_options_t drizzle_query_options(drizzle_query_st *query);
169
 
 
170
 
/**
171
 
 * Set options for a query.
172
 
 */
173
 
DRIZZLE_API
174
 
void drizzle_query_set_options(drizzle_query_st *query,
175
 
                               drizzle_query_options_t options);
176
 
 
177
 
/**
178
 
 * Add options for a query.
179
 
 */
180
 
DRIZZLE_API
181
 
void drizzle_query_add_options(drizzle_query_st *query,
182
 
                               drizzle_query_options_t options);
183
 
 
184
 
/**
185
 
 * Remove options for a query.
186
 
 */
187
 
DRIZZLE_API
188
 
void drizzle_query_remove_options(drizzle_query_st *query,
189
 
                                  drizzle_query_options_t options);
190
 
 
191
 
/**
192
 
 * Get application context for a query.
193
 
 */
194
 
DRIZZLE_API
195
 
void *drizzle_query_context(drizzle_query_st *query);
196
 
 
197
 
/**
198
 
 * Set application context for a query.
199
 
 */
200
 
DRIZZLE_API
201
 
void drizzle_query_set_context(drizzle_query_st *query, void *context);
202
 
 
203
 
/**
204
 
 * Set callback function when the context pointer should be freed.
205
 
 */
206
 
DRIZZLE_API
207
 
void drizzle_query_set_context_free_fn(drizzle_query_st *query,
208
 
                                       drizzle_query_context_free_fn *function);
209
 
 
210
 
/**
211
 
 * Run queries concurrently, returning when one is complete.
212
 
 */
213
 
DRIZZLE_API
214
 
drizzle_query_st *drizzle_query_run(drizzle_st *drizzle,
215
 
                                    drizzle_return_t *ret_ptr);
216
 
 
217
 
/**
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.
222
 
 */
223
 
DRIZZLE_API
224
 
drizzle_return_t drizzle_query_run_all(drizzle_st *drizzle);
225
 
 
226
 
/*
227
 
 * Escape a string or encode a string in hexadecimal. The return value is the
228
 
 * size of the output string in to.
229
 
 */
230
 
DRIZZLE_API
231
 
size_t drizzle_escape_string(char *to, const char *from, size_t from_size);
232
 
DRIZZLE_API
233
 
size_t drizzle_hex_string(char *to, const char *from, size_t from_size);
234
 
DRIZZLE_API
235
 
void drizzle_mysql_password_hash(char *to, const char *from, size_t from_size);
236
 
 
237
 
/** @} */
238
 
 
239
 
#ifdef __cplusplus
240
 
}
241
 
#endif
242
 
 
243
 
#endif /* __DRIZZLE_QUERY_H */