Apache Portable Runtime Utility Library
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
apr_dbd_internal.h
1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2  * contributor license agreements. See the NOTICE file distributed with
3  * this work for additional information regarding copyright ownership.
4  * The ASF licenses this file to You under the Apache License, Version 2.0
5  * (the "License"); you may not use this file except in compliance with
6  * the License. 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 #define TXN_IGNORE_ERRORS(t) \
33  ((t) && ((t)->mode & APR_DBD_TRANSACTION_IGNORE_ERRORS))
34 #define TXN_NOTICE_ERRORS(t) \
35  ((t) && !((t)->mode & APR_DBD_TRANSACTION_IGNORE_ERRORS))
36 
37 #define TXN_DO_COMMIT(t) (!((t)->mode & APR_DBD_TRANSACTION_ROLLBACK))
38 #define TXN_DO_ROLLBACK(t) ((t)->mode & APR_DBD_TRANSACTION_ROLLBACK)
39 
40 #define TXN_MODE_BITS \
41  (APR_DBD_TRANSACTION_ROLLBACK|APR_DBD_TRANSACTION_IGNORE_ERRORS)
42 
45  const char *name;
46 
50  void (*init)(apr_pool_t *pool);
51 
57  void *(*native_handle)(apr_dbd_t *handle);
58 
69  apr_dbd_t *(*open)(apr_pool_t *pool, const char *params,
70  const char **error);
71 
78  apr_status_t (*check_conn)(apr_pool_t *pool, apr_dbd_t *handle);
79 
85  apr_status_t (*close)(apr_dbd_t *handle);
86 
94  int (*set_dbname)(apr_pool_t* pool, apr_dbd_t *handle, const char *name);
95 
103  int (*start_transaction)(apr_pool_t *pool, apr_dbd_t *handle,
104  apr_dbd_transaction_t **trans);
105 
113  int (*end_transaction)(apr_dbd_transaction_t *trans);
114 
122  int (*query)(apr_dbd_t *handle, int *nrows, const char *statement);
123 
135  int (*select)(apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res,
136  const char *statement, int random);
137 
143  int (*num_cols)(apr_dbd_results_t *res);
144 
151  int (*num_tuples)(apr_dbd_results_t *res);
152 
162  int (*get_row)(apr_pool_t *pool, apr_dbd_results_t *res,
163  apr_dbd_row_t **row, int rownum);
164 
172  const char* (*get_entry)(const apr_dbd_row_t *row, int col);
173 
181  const char *(*error)(apr_dbd_t *handle, int errnum);
182 
190  const char *(*escape)(apr_pool_t *pool, const char *string,
191  apr_dbd_t *handle);
192 
207  int (*prepare)(apr_pool_t *pool, apr_dbd_t *handle, const char *query,
208  const char *label, int nargs, int nvals,
209  apr_dbd_type_e *types, apr_dbd_prepared_t **statement);
210 
220  int (*pvquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
221  apr_dbd_prepared_t *statement, va_list args);
222 
233  int (*pvselect)(apr_pool_t *pool, apr_dbd_t *handle,
234  apr_dbd_results_t **res,
235  apr_dbd_prepared_t *statement, int random, va_list args);
236 
246  int (*pquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
247  apr_dbd_prepared_t *statement, const char **args);
248 
259  int (*pselect)(apr_pool_t *pool, apr_dbd_t *handle,
260  apr_dbd_results_t **res, apr_dbd_prepared_t *statement,
261  int random, const char **args);
262 
263 
270  const char* (*get_name)(const apr_dbd_results_t *res, int col);
271 
277  int (*transaction_mode_get)(apr_dbd_transaction_t *trans);
278 
285  int (*transaction_mode_set)(apr_dbd_transaction_t *trans, int mode);
286 
288  const char *pformat;
289 
299  int (*pvbquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
300  apr_dbd_prepared_t *statement, va_list args);
301 
312  int (*pvbselect)(apr_pool_t *pool, apr_dbd_t *handle,
313  apr_dbd_results_t **res,
314  apr_dbd_prepared_t *statement, int random, va_list args);
315 
325  int (*pbquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
326  apr_dbd_prepared_t *statement,const void **args);
327 
338  int (*pbselect)(apr_pool_t *pool, apr_dbd_t *handle,
339  apr_dbd_results_t **res, apr_dbd_prepared_t *statement,
340  int random, const void **args);
341 
350  apr_status_t (*datum_get)(const apr_dbd_row_t *row, int col,
351  apr_dbd_type_e type, void *data);
352 };
353 
354 /* Export mutex lock/unlock for drivers that need it
355  * deprecated; create a per-dbd mutex within the (*init) function
356  * to avoid blocking other providers running on other threads
357  */
358 APU_DECLARE(apr_status_t) apr_dbd_mutex_lock(void);
359 APU_DECLARE(apr_status_t) apr_dbd_mutex_unlock(void);
360 
361 #ifdef __cplusplus
362 }
363 #endif
364 
365 #endif