Apache Portable Runtime Utility Library
apr_dbd.h
Go to the documentation of this file.
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_H
22 #define APR_DBD_H
23 
24 #include "apu.h"
25 #include "apr_pools.h"
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
55 typedef enum {
56  APR_DBD_TYPE_NONE,
80 
81 /* These are opaque structs. Instantiation is up to each backend */
82 typedef struct apr_dbd_driver_t apr_dbd_driver_t;
83 typedef struct apr_dbd_t apr_dbd_t;
84 typedef struct apr_dbd_transaction_t apr_dbd_transaction_t;
85 typedef struct apr_dbd_results_t apr_dbd_results_t;
86 typedef struct apr_dbd_row_t apr_dbd_row_t;
87 typedef struct apr_dbd_prepared_t apr_dbd_prepared_t;
88 
93 APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool);
94 
105 APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name,
106  const apr_dbd_driver_t **driver);
107 
143 APU_DECLARE(apr_status_t) apr_dbd_open_ex(const apr_dbd_driver_t *driver,
144  apr_pool_t *pool, const char *params,
145  apr_dbd_t **handle,
146  const char **error);
147 
158 APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver,
159  apr_pool_t *pool, const char *params,
160  apr_dbd_t **handle);
161 
168 APU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver,
169  apr_dbd_t *handle);
170 
171 /* apr-function-shaped versions of things */
172 
178 APU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver);
179 
186 APU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver,
187  apr_dbd_t *handle);
188 
196 APU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool,
197  apr_dbd_t *handle);
198 
207 APU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool,
208  apr_dbd_t *handle, const char *name);
209 
224 APU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver,
225  apr_pool_t *pool,
226  apr_dbd_t *handle,
227  apr_dbd_transaction_t **trans);
228 
238 APU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver,
239  apr_pool_t *pool,
240  apr_dbd_transaction_t *trans);
241 
242 #define APR_DBD_TRANSACTION_COMMIT 0x00
243 #define APR_DBD_TRANSACTION_ROLLBACK 0x01
244 #define APR_DBD_TRANSACTION_IGNORE_ERRORS 0x02
252 APU_DECLARE(int) apr_dbd_transaction_mode_get(const apr_dbd_driver_t *driver,
253  apr_dbd_transaction_t *trans);
254 
262 APU_DECLARE(int) apr_dbd_transaction_mode_set(const apr_dbd_driver_t *driver,
263  apr_dbd_transaction_t *trans,
264  int mode);
265 
274 APU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle,
275  int *nrows, const char *statement);
276 
289 APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool,
290  apr_dbd_t *handle, apr_dbd_results_t **res,
291  const char *statement, int random);
292 
299 APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver,
300  apr_dbd_results_t *res);
301 
309 APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver,
310  apr_dbd_results_t *res);
311 
322 APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool,
323  apr_dbd_results_t *res, apr_dbd_row_t **row,
324  int rownum);
325 
333 APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver,
334  apr_dbd_row_t *row, int col);
335 
343 APU_DECLARE(const char*) apr_dbd_get_name(const apr_dbd_driver_t *driver,
344  apr_dbd_results_t *res, int col);
345 
346 
355 APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver,
356  apr_dbd_t *handle, int errnum);
357 
366 APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver,
367  apr_pool_t *pool, const char *string,
368  apr_dbd_t *handle);
369 
398 APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool,
399  apr_dbd_t *handle, const char *query,
400  const char *label,
401  apr_dbd_prepared_t **statement);
402 
403 
415 APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool,
416  apr_dbd_t *handle, int *nrows,
417  apr_dbd_prepared_t *statement, int nargs,
418  const char **args);
419 
432 APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool,
433  apr_dbd_t *handle, apr_dbd_results_t **res,
434  apr_dbd_prepared_t *statement, int random,
435  int nargs, const char **args);
436 
447 APU_DECLARE_NONSTD(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver,
448  apr_pool_t *pool,
449  apr_dbd_t *handle, int *nrows,
450  apr_dbd_prepared_t *statement, ...);
451 
463 APU_DECLARE_NONSTD(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver,
464  apr_pool_t *pool, apr_dbd_t *handle,
465  apr_dbd_results_t **res,
466  apr_dbd_prepared_t *statement,
467  int random, ...);
468 
479 APU_DECLARE(int) apr_dbd_pbquery(const apr_dbd_driver_t *driver,
480  apr_pool_t *pool, apr_dbd_t *handle,
481  int *nrows, apr_dbd_prepared_t *statement,
482  const void **args);
483 
495 APU_DECLARE(int) apr_dbd_pbselect(const apr_dbd_driver_t *driver,
496  apr_pool_t *pool,
497  apr_dbd_t *handle, apr_dbd_results_t **res,
498  apr_dbd_prepared_t *statement, int random,
499  const void **args);
500 
511 APU_DECLARE_NONSTD(int) apr_dbd_pvbquery(const apr_dbd_driver_t *driver,
512  apr_pool_t *pool,
513  apr_dbd_t *handle, int *nrows,
514  apr_dbd_prepared_t *statement, ...);
515 
527 APU_DECLARE_NONSTD(int) apr_dbd_pvbselect(const apr_dbd_driver_t *driver,
528  apr_pool_t *pool, apr_dbd_t *handle,
529  apr_dbd_results_t **res,
530  apr_dbd_prepared_t *statement,
531  int random, ...);
532 
542 APU_DECLARE(apr_status_t) apr_dbd_datum_get(const apr_dbd_driver_t *driver,
543  apr_dbd_row_t *row, int col,
544  apr_dbd_type_e type, void *data);
545 
548 #ifdef __cplusplus
549 }
550 #endif
551 
552 #endif
Definition: apr_dbd.h:59
Definition: apr_dbd.h:69
Definition: apr_dbd.h:65
Definition: apr_dbd.h:75
Definition: apr_dbd.h:60
const char * apr_dbd_error(const apr_dbd_driver_t *driver, apr_dbd_t *handle, int errnum)
Definition: apr_dbd.h:72
int apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, const char *name)
apr_status_t apr_dbd_datum_get(const apr_dbd_driver_t *driver, apr_dbd_row_t *row, int col, apr_dbd_type_e type, void *data)
int apr_dbd_pbquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, int *nrows, apr_dbd_prepared_t *statement, const void **args)
void * apr_dbd_native_handle(const apr_dbd_driver_t *driver, apr_dbd_t *handle)
int apr_dbd_pvquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, int *nrows, apr_dbd_prepared_t *statement,...)
int apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle, int *nrows, const char *statement)
int apr_dbd_pvbquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, int *nrows, apr_dbd_prepared_t *statement,...)
Definition: apr_dbd.h:74
int apr_dbd_num_cols(const apr_dbd_driver_t *driver, apr_dbd_results_t *res)
Definition: apr_dbd.h:58
int apr_dbd_pvbselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, apr_dbd_prepared_t *statement, int random,...)
apr_status_t apr_dbd_get_driver(apr_pool_t *pool, const char *name, const apr_dbd_driver_t **driver)
int apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, int *nrows, apr_dbd_prepared_t *statement, int nargs, const char **args)
int apr_dbd_transaction_mode_set(const apr_dbd_driver_t *driver, apr_dbd_transaction_t *trans, int mode)
const char * apr_dbd_get_entry(const apr_dbd_driver_t *driver, apr_dbd_row_t *row, int col)
apr_status_t apr_dbd_open_ex(const apr_dbd_driver_t *driver, apr_pool_t *pool, const char *params, apr_dbd_t **handle, const char **error)
apr_status_t apr_dbd_init(apr_pool_t *pool)
int apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_results_t *res, apr_dbd_row_t **row, int rownum)
Definition: apr_dbd.h:64
apr_dbd_type_e
Definition: apr_dbd.h:55
Definition: apr_dbd.h:77
Definition: apr_dbd.h:63
int apr_dbd_transaction_start(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_transaction_t **trans)
Definition: apr_dbd.h:67
int apr_dbd_transaction_end(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_transaction_t *trans)
Definition: apr_dbd.h:61
Definition: apr_dbd.h:78
Definition: apr_dbd.h:68
Definition: apr_dbd.h:57
const char * apr_dbd_name(const apr_dbd_driver_t *driver)
int apr_dbd_num_tuples(const apr_dbd_driver_t *driver, apr_dbd_results_t *res)
Definition: apr_dbd.h:66
Definition: apr_dbd.h:70
const char * apr_dbd_escape(const apr_dbd_driver_t *driver, apr_pool_t *pool, const char *string, apr_dbd_t *handle)
Definition: apr_dbd_internal.h:43
int apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, const char *query, const char *label, apr_dbd_prepared_t **statement)
int apr_dbd_pbselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, apr_dbd_prepared_t *statement, int random, const void **args)
Definition: apr_dbd.h:73
apr_status_t apr_dbd_open(const apr_dbd_driver_t *driver, apr_pool_t *pool, const char *params, apr_dbd_t **handle)
const char * apr_dbd_get_name(const apr_dbd_driver_t *driver, apr_dbd_results_t *res, int col)
int apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, const char *statement, int random)
int apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle)
int apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, apr_dbd_prepared_t *statement, int random, int nargs, const char **args)
Definition: apr_dbd.h:62
Definition: apr_dbd.h:76
Definition: apr_dbd.h:71
int apr_dbd_pvselect(const apr_dbd_driver_t *driver, apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res, apr_dbd_prepared_t *statement, int random,...)
apr_status_t apr_dbd_close(const apr_dbd_driver_t *driver, apr_dbd_t *handle)