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

« back to all changes in this revision

Viewing changes to srclib/apr-util/include/private/apr_dbd_internal.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_INTERNAL_H
 
22
#define APR_DBD_INTERNAL_H
 
23
 
 
24
#include <stdarg.h>
 
25
 
 
26
#include "apr_dbd.h"
 
27
 
 
28
#ifdef __cplusplus
 
29
extern "C" {
 
30
#endif
 
31
 
 
32
struct apr_dbd_driver_t {
 
33
    /** name */
 
34
    const char *name;
 
35
 
 
36
    /** init: allow driver to perform once-only initialisation.
 
37
     *  Called once only.  May be NULL
 
38
     */
 
39
    void (*init)(apr_pool_t *pool);
 
40
 
 
41
    /** native_handle: return the native database handle of the underlying db
 
42
     *
 
43
     * @param handle - apr_dbd handle
 
44
     * @return - native handle
 
45
     */
 
46
    void *(*native_handle)(apr_dbd_t *handle);
 
47
 
 
48
    /** open: obtain a database connection from the server rec.
 
49
     *  Must be explicitly closed when you're finished with it.
 
50
     *  WARNING: only use this when you need a connection with
 
51
     *  a lifetime other than a request
 
52
     *
 
53
     *  @param pool - a pool to use for error messages (if any).
 
54
     *  @param s - server rec managing the underlying connection/pool.
 
55
     *  @return database handle, or NULL on error.
 
56
     */
 
57
    apr_dbd_t *(*open)(apr_pool_t *pool, const char *params);
 
58
 
 
59
    /** check_conn: check status of a database connection
 
60
     *
 
61
     *  @param pool - a pool to use for error messages (if any).
 
62
     *  @param handle - the connection to check
 
63
     *  @return APR_SUCCESS or error
 
64
     */
 
65
    apr_status_t (*check_conn)(apr_pool_t *pool, apr_dbd_t *handle);
 
66
 
 
67
    /** close: close/release a connection obtained from open()
 
68
     *
 
69
     *  @param handle - the connection to release
 
70
     *  @return APR_SUCCESS or error
 
71
     */
 
72
    apr_status_t (*close)(apr_dbd_t *handle);
 
73
 
 
74
    /** set_dbname: select database name.  May be a no-op if not supported.
 
75
     *
 
76
     *  @param pool - working pool
 
77
     *  @param handle - the connection
 
78
     *  @param name - the database to select
 
79
     *  @return 0 for success or error code
 
80
     */
 
81
    int (*set_dbname)(apr_pool_t* pool, apr_dbd_t *handle, const char *name);
 
82
 
 
83
    /** transaction: start a transaction.  May be a no-op.
 
84
     *
 
85
     *  @param pool - a pool to use for error messages (if any).
 
86
     *  @param handle - the connection
 
87
     *  @param transaction - ptr to a transaction.  May be null on entry
 
88
     *  @return 0 for success or error code
 
89
     */
 
90
    int (*start_transaction)(apr_pool_t *pool, apr_dbd_t *handle,
 
91
                             apr_dbd_transaction_t **trans);
 
92
 
 
93
    /** end_transaction: end a transaction
 
94
     *  (commit on success, rollback on error).
 
95
     *  May be a no-op.
 
96
     *
 
97
     *  @param transaction - the transaction.
 
98
     *  @return 0 for success or error code
 
99
     */
 
100
    int (*end_transaction)(apr_dbd_transaction_t *trans);
 
101
 
 
102
    /** query: execute an SQL query that doesn't return a result set
 
103
     *
 
104
     *  @param handle - the connection
 
105
     *  @param nrows - number of rows affected.
 
106
     *  @param statement - the SQL statement to execute
 
107
     *  @return 0 for success or error code
 
108
     */
 
109
    int (*query)(apr_dbd_t *handle, int *nrows, const char *statement);
 
110
 
 
111
    /** select: execute an SQL query that returns a result set
 
112
     *
 
113
     *  @param pool - pool to allocate the result set
 
114
     *  @param handle - the connection
 
115
     *  @param res - pointer to result set pointer.  May point to NULL on entry
 
116
     *  @param statement - the SQL statement to execute
 
117
     *  @param random - 1 to support random access to results (seek any row);
 
118
     *                  0 to support only looping through results in order
 
119
     *                    (async access - faster)
 
120
     *  @return 0 for success or error code
 
121
     */
 
122
    int (*select)(apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res,
 
123
                  const char *statement, int random);
 
124
 
 
125
    /** num_cols: get the number of columns in a results set
 
126
     *
 
127
     *  @param res - result set.
 
128
     *  @return number of columns
 
129
     */
 
130
    int (*num_cols)(apr_dbd_results_t *res);
 
131
 
 
132
    /** num_tuples: get the number of rows in a results set
 
133
     *  of a synchronous select
 
134
     *
 
135
     *  @param res - result set.
 
136
     *  @return number of rows, or -1 if the results are asynchronous
 
137
     */
 
138
    int (*num_tuples)(apr_dbd_results_t *res);
 
139
 
 
140
    /** get_row: get a row from a result set
 
141
     *
 
142
     *  @param pool - pool to allocate the row
 
143
     *  @param res - result set pointer
 
144
     *  @param row - pointer to row pointer.  May point to NULL on entry
 
145
     *  @param rownum - row number, or -1 for "next row".  Ignored if random
 
146
     *                  access is not supported.
 
147
     *  @return 0 for success, -1 for rownum out of range or data finished
 
148
     */
 
149
    int (*get_row)(apr_pool_t *pool, apr_dbd_results_t *res,
 
150
                   apr_dbd_row_t **row, int rownum);
 
151
  
 
152
    /** get_entry: get an entry from a row
 
153
     *
 
154
     *  @param row - row pointer
 
155
     *  @param col - entry number
 
156
     *  @param val - entry to fill
 
157
     *  @return 0 for success, -1 for no data, +1 for general error
 
158
     */
 
159
    const char* (*get_entry)(const apr_dbd_row_t *row, int col);
 
160
  
 
161
    /** error: get current error message (if any)
 
162
     *
 
163
     *  @param handle - the connection
 
164
     *  @param errnum - error code from operation that returned an error
 
165
     *  @return the database current error message, or message for errnum
 
166
     *          (implementation-dependent whether errnum is ignored)
 
167
     */
 
168
    const char *(*error)(apr_dbd_t *handle, int errnum);
 
169
  
 
170
    /** escape: escape a string so it is safe for use in query/select
 
171
     *
 
172
     *  @param pool - pool to alloc the result from
 
173
     *  @param string - the string to escape
 
174
     *  @param handle - the connection
 
175
     *  @return the escaped, safe string
 
176
     */
 
177
    const char *(*escape)(apr_pool_t *pool, const char *string,
 
178
                          apr_dbd_t *handle);
 
179
  
 
180
    /** prepare: prepare a statement
 
181
     *
 
182
     *  @param pool - pool to alloc the result from
 
183
     *  @param handle - the connection
 
184
     *  @param query - the SQL query
 
185
     *  @param label - A label for the prepared statement.
 
186
     *                 use NULL for temporary prepared statements
 
187
     *                 (eg within a Request in httpd)
 
188
     *  @param statement - statement to prepare.  May point to null on entry.
 
189
     *  @return 0 for success or error code
 
190
     */
 
191
    int (*prepare)(apr_pool_t *pool, apr_dbd_t *handle, const char *query,
 
192
                   const char *label, apr_dbd_prepared_t **statement);
 
193
 
 
194
    /** pvquery: query using a prepared statement + args
 
195
     *
 
196
     *  @param pool - working pool
 
197
     *  @param handle - the connection
 
198
     *  @param nrows - number of rows affected.
 
199
     *  @param statement - the prepared statement to execute
 
200
     *  @param args - args to prepared statement
 
201
     *  @return 0 for success or error code
 
202
     */
 
203
    int (*pvquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
 
204
                   apr_dbd_prepared_t *statement, va_list args);
 
205
 
 
206
    /** pvselect: select using a prepared statement + args
 
207
     *
 
208
     *  @param pool - working pool
 
209
     *  @param handle - the connection
 
210
     *  @param res - pointer to query results.  May point to NULL on entry
 
211
     *  @param statement - the prepared statement to execute
 
212
     *  @param random - Whether to support random-access to results
 
213
     *  @param args - args to prepared statement
 
214
     *  @return 0 for success or error code
 
215
     */
 
216
    int (*pvselect)(apr_pool_t *pool, apr_dbd_t *handle,
 
217
                    apr_dbd_results_t **res,
 
218
                    apr_dbd_prepared_t *statement, int random, va_list args);
 
219
 
 
220
    /** pquery: query using a prepared statement + args
 
221
     *
 
222
     *  @param pool - working pool
 
223
     *  @param handle - the connection
 
224
     *  @param nrows - number of rows affected.
 
225
     *  @param statement - the prepared statement to execute
 
226
     *  @param nargs - number of args to prepared statement
 
227
     *  @param args - args to prepared statement
 
228
     *  @return 0 for success or error code
 
229
     */
 
230
    int (*pquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
 
231
                  apr_dbd_prepared_t *statement, int nargs,
 
232
                  const char **args);
 
233
 
 
234
    /** pselect: select using a prepared statement + args
 
235
     *
 
236
     *  @param pool - working pool
 
237
     *  @param handle - the connection
 
238
     *  @param res - pointer to query results.  May point to NULL on entry
 
239
     *  @param statement - the prepared statement to execute
 
240
     *  @param random - Whether to support random-access to results
 
241
     *  @param nargs - number of args to prepared statement
 
242
     *  @param args - args to prepared statement
 
243
     *  @return 0 for success or error code
 
244
     */
 
245
    int (*pselect)(apr_pool_t *pool, apr_dbd_t *handle,
 
246
                   apr_dbd_results_t **res, apr_dbd_prepared_t *statement,
 
247
                   int random, int nargs, const char **args);
 
248
 
 
249
 
 
250
};
 
251
 
 
252
 
 
253
#ifdef __cplusplus
 
254
}
 
255
#endif
 
256
 
 
257
#endif