~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr-util/include/apr_dbd.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
 
2
 * applicable.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
/* Overview of what this is and does:
 
18
 * http://www.apache.org/~niq/dbd.html
 
19
 */
 
20
 
 
21
#ifndef APR_DBD_H
 
22
#define APR_DBD_H
 
23
 
 
24
#ifdef __cplusplus
 
25
extern "C" {
 
26
#endif
 
27
 
 
28
/**
 
29
 * @file apr_dbd.h
 
30
 * @brief APR-UTIL DBD library
 
31
 */
 
32
/**
 
33
 * @defgroup APR_Util_DBD DBD routines
 
34
 * @ingroup APR_Util
 
35
 * @{
 
36
 */
 
37
 
 
38
/* These are opaque structs.  Instantiation is up to each backend */
 
39
typedef struct apr_dbd_driver_t apr_dbd_driver_t;
 
40
typedef struct apr_dbd_t apr_dbd_t;
 
41
typedef struct apr_dbd_transaction_t apr_dbd_transaction_t;
 
42
typedef struct apr_dbd_results_t apr_dbd_results_t;
 
43
typedef struct apr_dbd_row_t apr_dbd_row_t;
 
44
typedef struct apr_dbd_prepared_t apr_dbd_prepared_t;
 
45
 
 
46
/** apr_dbd_init: perform once-only initialisation.  Call once only.
 
47
 *
 
48
 *  @param pool - pool to register any shutdown cleanups, etc
 
49
 */
 
50
APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool);
 
51
 
 
52
/** apr_dbd_get_driver: get the driver struct for a name
 
53
 *
 
54
 *  @param pool - (process) pool to register cleanup
 
55
 *  @param name - driver name
 
56
 *  @param driver - pointer to driver struct.
 
57
 *  @return APR_SUCCESS for success
 
58
 *  @return APR_ENOTIMPL for no driver (when DSO not enabled)
 
59
 *  @return APR_EDSOOPEN if DSO driver file can't be opened
 
60
 *  @return APR_ESYMNOTFOUND if the driver file doesn't contain a driver
 
61
 */
 
62
APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name,
 
63
                                             const apr_dbd_driver_t **driver);
 
64
 
 
65
/** apr_dbd_open: open a connection to a backend
 
66
 *
 
67
 *  @param ptmp - working pool
 
68
 *  @param params - arguments to driver (implementation-dependent)
 
69
 *  @param handle - pointer to handle to return
 
70
 *  @param driver - driver struct.
 
71
 *  @return APR_SUCCESS for success
 
72
 *  @return APR_EGENERAL if driver exists but connection failed
 
73
 */
 
74
APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver,
 
75
                                       apr_pool_t *ptmp, const char *params,
 
76
                                       apr_dbd_t **handle);
 
77
 
 
78
/** apr_dbd_close: close a connection to a backend.
 
79
 *  Only required for explicit close or
 
80
 *
 
81
 *  @param handle - handle to close
 
82
 *  @param driver - driver struct.
 
83
 *  @return APR_SUCCESS for success or error status
 
84
 */
 
85
APU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver,
 
86
                                        apr_dbd_t *handle);
 
87
 
 
88
/* apr-function-shaped versions of things */
 
89
 
 
90
/** apr_dbd_name: get the name of the driver
 
91
 *
 
92
 *  @param driver - the driver
 
93
 *  @return - name
 
94
 */
 
95
APU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver);
 
96
 
 
97
/** apr_dbd_native_handle: get native database handle of the underlying db
 
98
 *
 
99
 *  @param driver - the driver
 
100
 *  @param handle - apr_dbd handle
 
101
 *  @return - native handle
 
102
 */
 
103
APU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver,
 
104
                                         apr_dbd_t *handle);
 
105
 
 
106
/** check_conn: check status of a database connection
 
107
 *
 
108
 *  @param driver - the driver
 
109
 *  @param pool - working pool
 
110
 *  @param handle - the connection to check
 
111
 *  @return APR_SUCCESS or error
 
112
 */
 
113
APU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
114
                                    apr_dbd_t *handle);
 
115
 
 
116
/** apr_dbd_set_dbname: select database name.  May be a no-op if not supported.
 
117
 *
 
118
 *  @param driver - the driver
 
119
 *  @param pool - working pool
 
120
 *  @param handle - the connection
 
121
 *  @param name - the database to select
 
122
 *  @return 0 for success or error code
 
123
 */
 
124
APU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
125
                                    apr_dbd_t *handle, const char *name);
 
126
 
 
127
/** apr_dbd_transaction_start: start a transaction.  May be a no-op.
 
128
 *
 
129
 *  @param driver - the driver
 
130
 *  @param pool - a pool to use for error messages (if any).
 
131
 *  @param handle - the db connection
 
132
 *  @param transaction - ptr to a transaction.  May be null on entry
 
133
 *  @return 0 for success or error code
 
134
 */
 
135
APU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver,
 
136
                                           apr_pool_t *pool,
 
137
                                           apr_dbd_t *handle,
 
138
                                           apr_dbd_transaction_t **trans);
 
139
 
 
140
/** apr_dbd_transaction_end: end a transaction
 
141
 *  (commit on success, rollback on error).
 
142
 *  May be a no-op.
 
143
 *
 
144
 *  @param driver - the driver
 
145
 *  @param handle - the db connection
 
146
 *  @param transaction - the transaction.
 
147
 *  @return 0 for success or error code
 
148
 */
 
149
APU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver,
 
150
                                         apr_pool_t *pool,
 
151
                                         apr_dbd_transaction_t *trans);
 
152
 
 
153
/** apr_dbd_query: execute an SQL query that doesn't return a result set
 
154
 *
 
155
 *  @param driver - the driver
 
156
 *  @param handle - the connection
 
157
 *  @param nrows - number of rows affected.
 
158
 *  @param statement - the SQL statement to execute
 
159
 *  @return 0 for success or error code
 
160
 */
 
161
APU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle,
 
162
                               int *nrows, const char *statement);
 
163
 
 
164
/** apr_dbd_select: execute an SQL query that returns a result set
 
165
 *
 
166
 *  @param driver - the driver
 
167
 *  @param pool - pool to allocate the result set
 
168
 *  @param handle - the connection
 
169
 *  @param res - pointer to result set pointer.  May point to NULL on entry
 
170
 *  @param statement - the SQL statement to execute
 
171
 *  @param random - 1 to support random access to results (seek any row);
 
172
 *                  0 to support only looping through results in order
 
173
 *                    (async access - faster)
 
174
 *  @return 0 for success or error code
 
175
 */
 
176
APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
177
                                apr_dbd_t *handle, apr_dbd_results_t **res,
 
178
                                const char *statement, int random);
 
179
 
 
180
/** apr_dbd_num_cols: get the number of columns in a results set
 
181
 *
 
182
 *  @param driver - the driver
 
183
 *  @param res - result set.
 
184
 *  @return number of columns
 
185
 */
 
186
APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver,
 
187
                                  apr_dbd_results_t *res);
 
188
 
 
189
/** apr_dbd_num_tuples: get the number of rows in a results set
 
190
 *  of a synchronous select
 
191
 *
 
192
 *  @param driver - the driver
 
193
 *  @param res - result set.
 
194
 *  @return number of rows, or -1 if the results are asynchronous
 
195
 */
 
196
APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver,
 
197
                                    apr_dbd_results_t *res);
 
198
 
 
199
/** apr_dbd_get_row: get a row from a result set
 
200
 *
 
201
 *  @param driver - the driver
 
202
 *  @param pool - pool to allocate the row
 
203
 *  @param res - result set pointer
 
204
 *  @param row - pointer to row pointer.  May point to NULL on entry
 
205
 *  @param rownum - row number, or -1 for "next row".  Ignored if random
 
206
 *                  access is not supported.
 
207
 *  @return 0 for success, -1 for rownum out of range or data finished
 
208
 */
 
209
APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
210
                                 apr_dbd_results_t *res, apr_dbd_row_t **row,
 
211
                                 int rownum);
 
212
 
 
213
/** apr_dbd_get_entry: get an entry from a row
 
214
 *
 
215
 *  @param driver - the driver
 
216
 *  @param row - row pointer
 
217
 *  @param col - entry number
 
218
 *  @return value from the row, or NULL if col is out of bounds.
 
219
 */
 
220
APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver,
 
221
                                           apr_dbd_row_t *row, int col);
 
222
 
 
223
/** apr_dbd_error: get current error message (if any)
 
224
 *
 
225
 *  @param driver - the driver
 
226
 *  @param handle - the connection
 
227
 *  @param errnum - error code from operation that returned an error
 
228
 *  @return the database current error message, or message for errnum
 
229
 *          (implementation-dependent whether errnum is ignored)
 
230
 */
 
231
APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver,
 
232
                                       apr_dbd_t *handle, int errnum);
 
233
 
 
234
/** apr_dbd_escape: escape a string so it is safe for use in query/select
 
235
 *
 
236
 *  @param driver - the driver
 
237
 *  @param pool - pool to alloc the result from
 
238
 *  @param string - the string to escape
 
239
 *  @param handle - the connection
 
240
 *  @return the escaped, safe string
 
241
 */
 
242
APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver,
 
243
                                        apr_pool_t *pool, const char *string,
 
244
                                        apr_dbd_t *handle);
 
245
 
 
246
/** apr_dbd_prepare: prepare a statement
 
247
 *
 
248
 *  @param driver - the driver
 
249
 *  @param pool - pool to alloc the result from
 
250
 *  @param handle - the connection
 
251
 *  @param query - the SQL query
 
252
 *  @param label - A label for the prepared statement.
 
253
 *                 use NULL for temporary prepared statements
 
254
 *                 (eg within a Request in httpd)
 
255
 *  @param statement - statement to prepare.  May point to null on entry.
 
256
 *  @return 0 for success or error code
 
257
 */
 
258
APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
259
                                 apr_dbd_t *handle, const char *query,
 
260
                                 const char *label,
 
261
                                 apr_dbd_prepared_t **statement);
 
262
 
 
263
 
 
264
/** apr_dbd_pquery: query using a prepared statement + args
 
265
 *
 
266
 *  @param driver - the driver
 
267
 *  @param pool - working pool
 
268
 *  @param handle - the connection
 
269
 *  @param nrows - number of rows affected.
 
270
 *  @param statement - the prepared statement to execute
 
271
 *  @param nargs - number of args to prepared statement
 
272
 *  @param args - args to prepared statement
 
273
 *  @return 0 for success or error code
 
274
 */
 
275
APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
276
                                apr_dbd_t *handle, int *nrows,
 
277
                                apr_dbd_prepared_t *statement, int nargs,
 
278
                                const char **args);
 
279
 
 
280
/** apr_dbd_pselect: select using a prepared statement + args
 
281
 *
 
282
 *  @param driver - the driver
 
283
 *  @param pool - working pool
 
284
 *  @param handle - the connection
 
285
 *  @param res - pointer to query results.  May point to NULL on entry
 
286
 *  @param statement - the prepared statement to execute
 
287
 *  @param random - Whether to support random-access to results
 
288
 *  @param nargs - number of args to prepared statement
 
289
 *  @param args - args to prepared statement
 
290
 *  @return 0 for success or error code
 
291
 */
 
292
APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
293
                                 apr_dbd_t *handle, apr_dbd_results_t **res,
 
294
                                 apr_dbd_prepared_t *statement, int random,
 
295
                                 int nargs, const char **args);
 
296
 
 
297
/** apr_dbd_pvquery: query using a prepared statement + args
 
298
 *
 
299
 *  @param driver - the driver
 
300
 *  @param pool - working pool
 
301
 *  @param handle - the connection
 
302
 *  @param nrows - number of rows affected.
 
303
 *  @param statement - the prepared statement to execute
 
304
 *  @param ... - varargs list
 
305
 *  @return 0 for success or error code
 
306
 */
 
307
APU_DECLARE(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
308
                                 apr_dbd_t *handle, int *nrows,
 
309
                                 apr_dbd_prepared_t *statement, ...);
 
310
 
 
311
/** apr_dbd_pvselect: select using a prepared statement + args
 
312
 *
 
313
 *  @param driver - the driver
 
314
 *  @param pool - working pool
 
315
 *  @param handle - the connection
 
316
 *  @param res - pointer to query results.  May point to NULL on entry
 
317
 *  @param statement - the prepared statement to execute
 
318
 *  @param random - Whether to support random-access to results
 
319
 *  @param ... - varargs list
 
320
 *  @return 0 for success or error code
 
321
 */
 
322
APU_DECLARE(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver, apr_pool_t *pool,
 
323
                                  apr_dbd_t *handle, apr_dbd_results_t **res,
 
324
                                  apr_dbd_prepared_t *statement, int random,
 
325
                                  ...);
 
326
 
 
327
/** @} */
 
328
 
 
329
#ifdef __cplusplus
 
330
}
 
331
#endif
 
332
 
 
333
#endif