apr_dbd.h revision 251876
10SN/A/* Licensed to the Apache Software Foundation (ASF) under one or more
26073SN/A * contributor license agreements.  See the NOTICE file distributed with
30SN/A * this work for additional information regarding copyright ownership.
40SN/A * The ASF licenses this file to You under the Apache License, Version 2.0
50SN/A * (the "License"); you may not use this file except in compliance with
60SN/A * the License.  You may obtain a copy of the License at
72362SN/A *
80SN/A *     http://www.apache.org/licenses/LICENSE-2.0
92362SN/A *
100SN/A * Unless required by applicable law or agreed to in writing, software
110SN/A * distributed under the License is distributed on an "AS IS" BASIS,
120SN/A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130SN/A * See the License for the specific language governing permissions and
140SN/A * limitations under the License.
150SN/A */
160SN/A
170SN/A/* Overview of what this is and does:
180SN/A * http://www.apache.org/~niq/dbd.html
190SN/A */
200SN/A
212362SN/A#ifndef APR_DBD_H
222362SN/A#define APR_DBD_H
232362SN/A
240SN/A#include "apu.h"
250SN/A#include "apr_pools.h"
264457SN/A
274457SN/A#ifdef __cplusplus
284457SN/Aextern "C" {
294457SN/A#endif
304457SN/A
314457SN/A/**
324457SN/A * @file apr_dbd.h
334457SN/A * @brief APR-UTIL DBD library
344457SN/A */
350SN/A/**
360SN/A * @defgroup APR_Util_DBD DBD routines
370SN/A * @ingroup APR_Util
380SN/A * @{
390SN/A */
400SN/A
410SN/A/**
420SN/A * Mapping of C to SQL types, used for prepared statements.
430SN/A * @remarks
440SN/A * For apr_dbd_p[v]query/select functions, in and out parameters are always
450SN/A * const char * (i.e. regular nul terminated strings). LOB types are passed
460SN/A * with four (4) arguments: payload, length, table and column, all as const
470SN/A * char *, where table and column are reserved for future use by Oracle.
480SN/A * @remarks
490SN/A * For apr_dbd_p[v]bquery/select functions, in and out parameters are
500SN/A * described next to each enumeration constant and are generally native binary
510SN/A * types or some APR data type. LOB types are passed with four (4) arguments:
520SN/A * payload (char*), length (apr_size_t*), table (char*) and column (char*).
530SN/A * Table and column are reserved for future use by Oracle.
540SN/A */
550SN/Atypedef enum {
560SN/A    APR_DBD_TYPE_NONE,
570SN/A    APR_DBD_TYPE_TINY,       /**< \%hhd : in, out: char* */
580SN/A    APR_DBD_TYPE_UTINY,      /**< \%hhu : in, out: unsigned char* */
590SN/A    APR_DBD_TYPE_SHORT,      /**< \%hd  : in, out: short* */
600SN/A    APR_DBD_TYPE_USHORT,     /**< \%hu  : in, out: unsigned short* */
610SN/A    APR_DBD_TYPE_INT,        /**< \%d   : in, out: int* */
620SN/A    APR_DBD_TYPE_UINT,       /**< \%u   : in, out: unsigned int* */
630SN/A    APR_DBD_TYPE_LONG,       /**< \%ld  : in, out: long* */
640SN/A    APR_DBD_TYPE_ULONG,      /**< \%lu  : in, out: unsigned long* */
650SN/A    APR_DBD_TYPE_LONGLONG,   /**< \%lld : in, out: apr_int64_t* */
660SN/A    APR_DBD_TYPE_ULONGLONG,  /**< \%llu : in, out: apr_uint64_t* */
670SN/A    APR_DBD_TYPE_FLOAT,      /**< \%f   : in, out: float* */
680SN/A    APR_DBD_TYPE_DOUBLE,     /**< \%lf  : in, out: double* */
690SN/A    APR_DBD_TYPE_STRING,     /**< \%s   : in: char*, out: char** */
700SN/A    APR_DBD_TYPE_TEXT,       /**< \%pDt : in: char*, out: char** */
710SN/A    APR_DBD_TYPE_TIME,       /**< \%pDi : in: char*, out: char** */
720SN/A    APR_DBD_TYPE_DATE,       /**< \%pDd : in: char*, out: char** */
730SN/A    APR_DBD_TYPE_DATETIME,   /**< \%pDa : in: char*, out: char** */
740SN/A    APR_DBD_TYPE_TIMESTAMP,  /**< \%pDs : in: char*, out: char** */
750SN/A    APR_DBD_TYPE_ZTIMESTAMP, /**< \%pDz : in: char*, out: char** */
760SN/A    APR_DBD_TYPE_BLOB,       /**< \%pDb : in: char* apr_size_t* char* char*, out: apr_bucket_brigade* */
770SN/A    APR_DBD_TYPE_CLOB,       /**< \%pDc : in: char* apr_size_t* char* char*, out: apr_bucket_brigade* */
780SN/A    APR_DBD_TYPE_NULL        /**< \%pDn : in: void*, out: void** */
790SN/A} apr_dbd_type_e;
800SN/A
810SN/A/* These are opaque structs.  Instantiation is up to each backend */
820SN/Atypedef struct apr_dbd_driver_t apr_dbd_driver_t;
830SN/Atypedef struct apr_dbd_t apr_dbd_t;
840SN/Atypedef struct apr_dbd_transaction_t apr_dbd_transaction_t;
850SN/Atypedef struct apr_dbd_results_t apr_dbd_results_t;
860SN/Atypedef struct apr_dbd_row_t apr_dbd_row_t;
870SN/Atypedef struct apr_dbd_prepared_t apr_dbd_prepared_t;
880SN/A
890SN/A/** apr_dbd_init: perform once-only initialisation.  Call once only.
900SN/A *
910SN/A *  @param pool - pool to register any shutdown cleanups, etc
920SN/A */
930SN/AAPU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool);
940SN/A
950SN/A/** apr_dbd_get_driver: get the driver struct for a name
960SN/A *
970SN/A *  @param pool - (process) pool to register cleanup
980SN/A *  @param name - driver name
990SN/A *  @param driver - pointer to driver struct.
1000SN/A *  @return APR_SUCCESS for success
1010SN/A *  @return APR_ENOTIMPL for no driver (when DSO not enabled)
1020SN/A *  @return APR_EDSOOPEN if DSO driver file can't be opened
1030SN/A *  @return APR_ESYMNOTFOUND if the driver file doesn't contain a driver
1040SN/A */
1050SN/AAPU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name,
1060SN/A                                             const apr_dbd_driver_t **driver);
1070SN/A
1080SN/A/** apr_dbd_open_ex: open a connection to a backend
1090SN/A *
1100SN/A *  @param pool - working pool
1110SN/A *  @param params - arguments to driver (implementation-dependent)
1120SN/A *  @param handle - pointer to handle to return
1130SN/A *  @param driver - driver struct.
1140SN/A *  @param error - descriptive error.
1150SN/A *  @return APR_SUCCESS for success
1160SN/A *  @return APR_EGENERAL if driver exists but connection failed
1170SN/A *  @remarks PostgreSQL: the params is passed directly to the PQconnectdb()
1180SN/A *  function (check PostgreSQL documentation for more details on the syntax).
1190SN/A *  @remarks SQLite2: the params is split on a colon, with the first part used
1200SN/A *  as the filename and second part converted to an integer and used as file
1210SN/A *  mode.
1220SN/A *  @remarks SQLite3: the params is passed directly to the sqlite3_open()
1230SN/A *  function as a filename to be opened (check SQLite3 documentation for more
1240SN/A *  details).
1250SN/A *  @remarks Oracle: the params can have "user", "pass", "dbname" and "server"
1260SN/A *  keys, each followed by an equal sign and a value. Such key/value pairs can
1270SN/A *  be delimited by space, CR, LF, tab, semicolon, vertical bar or comma.
1280SN/A *  @remarks MySQL: the params can have "host", "port", "user", "pass",
1290SN/A *  "dbname", "sock", "flags" "fldsz", "group" and "reconnect" keys, each
1300SN/A *  followed by an equal sign and a value. Such key/value pairs can be
1310SN/A *  delimited by space, CR, LF, tab, semicolon, vertical bar or comma. For
1320SN/A *  now, "flags" can only recognise CLIENT_FOUND_ROWS (check MySQL manual for
1330SN/A *  details). The value associated with "fldsz" determines maximum amount of
1340SN/A *  memory (in bytes) for each of the fields in the result set of prepared
1350SN/A *  statements. By default, this value is 1 MB. The value associated with
1360SN/A *  "group" determines which group from configuration file to use (see
1370SN/A *  MYSQL_READ_DEFAULT_GROUP option of mysql_options() in MySQL manual).
1380SN/A *  Reconnect is set to 1 by default (i.e. true).
1390SN/A *  @remarks FreeTDS: the params can have "username", "password", "appname",
1400SN/A *  "dbname", "host", "charset", "lang" and "server" keys, each followed by an
1410SN/A *  equal sign and a value.
1420SN/A */
1430SN/AAPU_DECLARE(apr_status_t) apr_dbd_open_ex(const apr_dbd_driver_t *driver,
1440SN/A                                          apr_pool_t *pool, const char *params,
1450SN/A                                          apr_dbd_t **handle,
1460SN/A                                          const char **error);
1470SN/A
1480SN/A/** apr_dbd_open: open a connection to a backend
1490SN/A *
1500SN/A *  @param pool - working pool
1510SN/A *  @param params - arguments to driver (implementation-dependent)
1520SN/A *  @param handle - pointer to handle to return
1530SN/A *  @param driver - driver struct.
1540SN/A *  @return APR_SUCCESS for success
1550SN/A *  @return APR_EGENERAL if driver exists but connection failed
1560SN/A *  @see apr_dbd_open_ex
1570SN/A */
1580SN/AAPU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver,
1590SN/A                                       apr_pool_t *pool, const char *params,
1600SN/A                                       apr_dbd_t **handle);
1610SN/A
1620SN/A/** apr_dbd_close: close a connection to a backend
1630SN/A *
1640SN/A *  @param handle - handle to close
1650SN/A *  @param driver - driver struct.
1660SN/A *  @return APR_SUCCESS for success or error status
1670SN/A */
1680SN/AAPU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver,
1690SN/A                                        apr_dbd_t *handle);
1700SN/A
1710SN/A/* apr-function-shaped versions of things */
1720SN/A
1730SN/A/** apr_dbd_name: get the name of the driver
1740SN/A *
1750SN/A *  @param driver - the driver
1760SN/A *  @return - name
1770SN/A */
1780SN/AAPU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver);
1790SN/A
1800SN/A/** apr_dbd_native_handle: get native database handle of the underlying db
1810SN/A *
1820SN/A *  @param driver - the driver
1830SN/A *  @param handle - apr_dbd handle
1840SN/A *  @return - native handle
1850SN/A */
1860SN/AAPU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver,
1870SN/A                                         apr_dbd_t *handle);
1880SN/A
1890SN/A/** check_conn: check status of a database connection
1900SN/A *
1910SN/A *  @param driver - the driver
1920SN/A *  @param pool - working pool
1930SN/A *  @param handle - the connection to check
1940SN/A *  @return APR_SUCCESS or error
1950SN/A */
1960SN/AAPU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool,
1970SN/A                                    apr_dbd_t *handle);
1980SN/A
1990SN/A/** apr_dbd_set_dbname: select database name.  May be a no-op if not supported.
2000SN/A *
2010SN/A *  @param driver - the driver
2020SN/A *  @param pool - working pool
2030SN/A *  @param handle - the connection
2040SN/A *  @param name - the database to select
2050SN/A *  @return 0 for success or error code
2060SN/A */
2070SN/AAPU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool,
2080SN/A                                    apr_dbd_t *handle, const char *name);
2090SN/A
2100SN/A/** apr_dbd_transaction_start: start a transaction.  May be a no-op.
2110SN/A *
2120SN/A *  @param driver - the driver
2130SN/A *  @param pool - a pool to use for error messages (if any).
2140SN/A *  @param handle - the db connection
2150SN/A *  @param trans - ptr to a transaction.  May be null on entry
2160SN/A *  @return 0 for success or error code
2170SN/A *  @remarks Note that transaction modes, set by calling
2180SN/A *  apr_dbd_transaction_mode_set(), will affect all query/select calls within
2190SN/A *  a transaction. By default, any error in query/select during a transaction
2200SN/A *  will cause the transaction to inherit the error code and any further
2210SN/A *  query/select calls will fail immediately. Put transaction in "ignore
2220SN/A *  errors" mode to avoid that. Use "rollback" mode to do explicit rollback.
2230SN/A */
2240SN/AAPU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver,
2250SN/A                                           apr_pool_t *pool,
2260SN/A                                           apr_dbd_t *handle,
2270SN/A                                           apr_dbd_transaction_t **trans);
2280SN/A
2290SN/A/** apr_dbd_transaction_end: end a transaction
2300SN/A *  (commit on success, rollback on error).
2310SN/A *  May be a no-op.
2320SN/A *
2330SN/A *  @param driver - the driver
2340SN/A *  @param handle - the db connection
2350SN/A *  @param trans - the transaction.
2360SN/A *  @return 0 for success or error code
2370SN/A */
2380SN/AAPU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver,
2390SN/A                                         apr_pool_t *pool,
2400SN/A                                         apr_dbd_transaction_t *trans);
2410SN/A
2420SN/A#define APR_DBD_TRANSACTION_COMMIT        0x00  /**< commit the transaction */
2430SN/A#define APR_DBD_TRANSACTION_ROLLBACK      0x01  /**< rollback the transaction */
2440SN/A#define APR_DBD_TRANSACTION_IGNORE_ERRORS 0x02  /**< ignore transaction errors */
2450SN/A
2460SN/A/** apr_dbd_transaction_mode_get: get the mode of transaction
2470SN/A *
2480SN/A *  @param driver - the driver
2490SN/A *  @param trans  - the transaction
2500SN/A *  @return mode of transaction
2510SN/A */
2520SN/AAPU_DECLARE(int) apr_dbd_transaction_mode_get(const apr_dbd_driver_t *driver,
2530SN/A                                              apr_dbd_transaction_t *trans);
2540SN/A
2550SN/A/** apr_dbd_transaction_mode_set: set the mode of transaction
2560SN/A *
2570SN/A *  @param driver - the driver
2580SN/A *  @param trans  - the transaction
2590SN/A *  @param mode   - new mode of the transaction
2600SN/A *  @return the mode of transaction in force after the call
2610SN/A */
2620SN/AAPU_DECLARE(int) apr_dbd_transaction_mode_set(const apr_dbd_driver_t *driver,
2630SN/A                                              apr_dbd_transaction_t *trans,
2640SN/A                                              int mode);
2650SN/A
2660SN/A/** apr_dbd_query: execute an SQL query that doesn't return a result set
2670SN/A *
2680SN/A *  @param driver - the driver
2690SN/A *  @param handle - the connection
2700SN/A *  @param nrows - number of rows affected.
2710SN/A *  @param statement - the SQL statement to execute
2720SN/A *  @return 0 for success or error code
2730SN/A */
2740SN/AAPU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle,
2750SN/A                               int *nrows, const char *statement);
2760SN/A
2770SN/A/** apr_dbd_select: execute an SQL query that returns a result set
2780SN/A *
2790SN/A *  @param driver - the driver
2800SN/A *  @param pool - pool to allocate the result set
2810SN/A *  @param handle - the connection
2820SN/A *  @param res - pointer to result set pointer.  May point to NULL on entry
2830SN/A *  @param statement - the SQL statement to execute
2840SN/A *  @param random - 1 to support random access to results (seek any row);
2850SN/A *                  0 to support only looping through results in order
2860SN/A *                    (async access - faster)
2870SN/A *  @return 0 for success or error code
2880SN/A */
2890SN/AAPU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool,
2900SN/A                                apr_dbd_t *handle, apr_dbd_results_t **res,
2910SN/A                                const char *statement, int random);
2920SN/A
2930SN/A/** apr_dbd_num_cols: get the number of columns in a results set
2940SN/A *
2950SN/A *  @param driver - the driver
2960SN/A *  @param res - result set.
2970SN/A *  @return number of columns
2980SN/A */
2990SN/AAPU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver,
3000SN/A                                  apr_dbd_results_t *res);
3010SN/A
3020SN/A/** apr_dbd_num_tuples: get the number of rows in a results set
3030SN/A *  of a synchronous select
3040SN/A *
3050SN/A *  @param driver - the driver
3060SN/A *  @param res - result set.
3070SN/A *  @return number of rows, or -1 if the results are asynchronous
3080SN/A */
3090SN/AAPU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver,
3100SN/A                                    apr_dbd_results_t *res);
3110SN/A
3120SN/A/** apr_dbd_get_row: get a row from a result set
3130SN/A *
3140SN/A *  @param driver - the driver
3150SN/A *  @param pool - pool to allocate the row
3160SN/A *  @param res - result set pointer
3170SN/A *  @param row - pointer to row pointer.  May point to NULL on entry
3180SN/A *  @param rownum - row number (counting from 1), or -1 for "next row".
3190SN/A *                  Ignored if random access is not supported.
3200SN/A *  @return 0 for success, -1 for rownum out of range or data finished
3210SN/A */
3220SN/AAPU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool,
3230SN/A                                 apr_dbd_results_t *res, apr_dbd_row_t **row,
3240SN/A                                 int rownum);
3250SN/A
3260SN/A/** apr_dbd_get_entry: get an entry from a row
3270SN/A *
3280SN/A *  @param driver - the driver
3290SN/A *  @param row - row pointer
3300SN/A *  @param col - entry number
3310SN/A *  @return value from the row, or NULL if col is out of bounds.
3320SN/A */
3330SN/AAPU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver,
3340SN/A                                           apr_dbd_row_t *row, int col);
3350SN/A
3360SN/A/** apr_dbd_get_name: get an entry name from a result set
3370SN/A *
3380SN/A *  @param driver - the driver
3390SN/A *  @param res - result set pointer
3400SN/A *  @param col - entry number
3410SN/A *  @return name of the entry, or NULL if col is out of bounds.
3420SN/A */
3430SN/AAPU_DECLARE(const char*) apr_dbd_get_name(const apr_dbd_driver_t *driver,
3440SN/A                                          apr_dbd_results_t *res, int col);
3450SN/A
3460SN/A
3470SN/A/** apr_dbd_error: get current error message (if any)
3480SN/A *
3490SN/A *  @param driver - the driver
3500SN/A *  @param handle - the connection
3510SN/A *  @param errnum - error code from operation that returned an error
3520SN/A *  @return the database current error message, or message for errnum
3530SN/A *          (implementation-dependent whether errnum is ignored)
3540SN/A */
3550SN/AAPU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver,
3560SN/A                                       apr_dbd_t *handle, int errnum);
3570SN/A
3580SN/A/** apr_dbd_escape: escape a string so it is safe for use in query/select
3590SN/A *
3600SN/A *  @param driver - the driver
3610SN/A *  @param pool - pool to alloc the result from
3620SN/A *  @param string - the string to escape
3630SN/A *  @param handle - the connection
3640SN/A *  @return the escaped, safe string
3650SN/A */
3660SN/AAPU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver,
3670SN/A                                        apr_pool_t *pool, const char *string,
3680SN/A                                        apr_dbd_t *handle);
3690SN/A
3700SN/A/** apr_dbd_prepare: prepare a statement
3710SN/A *
3720SN/A *  @param driver - the driver
3730SN/A *  @param pool - pool to alloc the result from
3740SN/A *  @param handle - the connection
3750SN/A *  @param query - the SQL query
3760SN/A *  @param label - A label for the prepared statement.
3770SN/A *                 use NULL for temporary prepared statements
3780SN/A *                 (eg within a Request in httpd)
3790SN/A *  @param statement - statement to prepare.  May point to null on entry.
3800SN/A *  @return 0 for success or error code
3810SN/A *  @remarks To specify parameters of the prepared query, use \%s, \%d etc.
3820SN/A *  (see below for full list) in place of database specific parameter syntax
3830SN/A *  (e.g.  for PostgreSQL, this would be $1, $2, for SQLite3 this would be ?
3840SN/A *  etc.).  For instance: "SELECT name FROM customers WHERE name=%s" would be
3850SN/A *  a query that this function understands.
3860SN/A *  @remarks Here is the full list of format specifiers that this function
3870SN/A *  understands and what they map to in SQL: \%hhd (TINY INT), \%hhu (UNSIGNED
3880SN/A *  TINY INT), \%hd (SHORT), \%hu (UNSIGNED SHORT), \%d (INT), \%u (UNSIGNED
3890SN/A *  INT), \%ld (LONG), \%lu (UNSIGNED LONG), \%lld (LONG LONG), \%llu
3900SN/A *  (UNSIGNED LONG LONG), \%f (FLOAT, REAL), \%lf (DOUBLE PRECISION), \%s
3910SN/A *  (VARCHAR), \%pDt (TEXT), \%pDi (TIME), \%pDd (DATE), \%pDa (DATETIME),
3920SN/A *  \%pDs (TIMESTAMP), \%pDz (TIMESTAMP WITH TIME ZONE), \%pDb (BLOB), \%pDc
3930SN/A *  (CLOB) and \%pDn (NULL). Not all databases have support for all these
3940SN/A *  types, so the underlying driver will attempt the "best match" where
3950SN/A *  possible. A \% followed by any letter not in the above list will be
3960SN/A *  interpreted as VARCHAR (i.e. \%s).
3970SN/A */
3980SN/AAPU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool,
3990SN/A                                 apr_dbd_t *handle, const char *query,
4000SN/A                                 const char *label,
4010SN/A                                 apr_dbd_prepared_t **statement);
4020SN/A
4030SN/A
4040SN/A/** apr_dbd_pquery: query using a prepared statement + args
4050SN/A *
4060SN/A *  @param driver - the driver
4070SN/A *  @param pool - working pool
4080SN/A *  @param handle - the connection
4090SN/A *  @param nrows - number of rows affected.
4100SN/A *  @param statement - the prepared statement to execute
4110SN/A *  @param nargs - ignored (for backward compatibility only)
4120SN/A *  @param args - args to prepared statement
4130SN/A *  @return 0 for success or error code
4140SN/A */
4150SN/AAPU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool,
4160SN/A                                apr_dbd_t *handle, int *nrows,
4170SN/A                                apr_dbd_prepared_t *statement, int nargs,
4180SN/A                                const char **args);
4190SN/A
4200SN/A/** apr_dbd_pselect: select using a prepared statement + args
4210SN/A *
4220SN/A *  @param driver - the driver
4230SN/A *  @param pool - working pool
4240SN/A *  @param handle - the connection
4250SN/A *  @param res - pointer to query results.  May point to NULL on entry
4260SN/A *  @param statement - the prepared statement to execute
4270SN/A *  @param random - Whether to support random-access to results
4280SN/A *  @param nargs - ignored (for backward compatibility only)
4290SN/A *  @param args - args to prepared statement
4300SN/A *  @return 0 for success or error code
4310SN/A */
4320SN/AAPU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool,
4330SN/A                                 apr_dbd_t *handle, apr_dbd_results_t **res,
4340SN/A                                 apr_dbd_prepared_t *statement, int random,
4350SN/A                                 int nargs, const char **args);
4360SN/A
4370SN/A/** apr_dbd_pvquery: query using a prepared statement + args
4380SN/A *
4390SN/A *  @param driver - the driver
4400SN/A *  @param pool - working pool
4410SN/A *  @param handle - the connection
4420SN/A *  @param nrows - number of rows affected.
4430SN/A *  @param statement - the prepared statement to execute
4440SN/A *  @param ... - varargs list
4450SN/A *  @return 0 for success or error code
4460SN/A */
4470SN/AAPU_DECLARE_NONSTD(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver,
4480SN/A                                        apr_pool_t *pool,
4490SN/A                                        apr_dbd_t *handle, int *nrows,
4500SN/A                                        apr_dbd_prepared_t *statement, ...);
4510SN/A
4520SN/A/** apr_dbd_pvselect: select using a prepared statement + args
4530SN/A *
4540SN/A *  @param driver - the driver
4550SN/A *  @param pool - working pool
4560SN/A *  @param handle - the connection
4570SN/A *  @param res - pointer to query results.  May point to NULL on entry
4580SN/A *  @param statement - the prepared statement to execute
4590SN/A *  @param random - Whether to support random-access to results
4600SN/A *  @param ... - varargs list
4610SN/A *  @return 0 for success or error code
4620SN/A */
4630SN/AAPU_DECLARE_NONSTD(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver,
4640SN/A                                         apr_pool_t *pool, apr_dbd_t *handle,
4650SN/A                                         apr_dbd_results_t **res,
4660SN/A                                         apr_dbd_prepared_t *statement,
4670SN/A                                         int random, ...);
4680SN/A
4690SN/A/** apr_dbd_pbquery: query using a prepared statement + binary args
4700SN/A *
4710SN/A *  @param driver - the driver
4720SN/A *  @param pool - working pool
4730SN/A *  @param handle - the connection
4740SN/A *  @param nrows - number of rows affected.
4750SN/A *  @param statement - the prepared statement to execute
4760SN/A *  @param args - binary args to prepared statement
4770SN/A *  @return 0 for success or error code
4780SN/A */
4790SN/AAPU_DECLARE(int) apr_dbd_pbquery(const apr_dbd_driver_t *driver,
4800SN/A                                 apr_pool_t *pool, apr_dbd_t *handle,
4810SN/A                                 int *nrows, apr_dbd_prepared_t *statement,
4820SN/A                                 const void **args);
4830SN/A
4840SN/A/** apr_dbd_pbselect: select using a prepared statement + binary args
4850SN/A *
4860SN/A *  @param driver - the driver
4870SN/A *  @param pool - working pool
4880SN/A *  @param handle - the connection
4890SN/A *  @param res - pointer to query results.  May point to NULL on entry
4900SN/A *  @param statement - the prepared statement to execute
4910SN/A *  @param random - Whether to support random-access to results
4920SN/A *  @param args - binary args to prepared statement
4930SN/A *  @return 0 for success or error code
4940SN/A */
4950SN/AAPU_DECLARE(int) apr_dbd_pbselect(const apr_dbd_driver_t *driver,
4960SN/A                                  apr_pool_t *pool,
4970SN/A                                  apr_dbd_t *handle, apr_dbd_results_t **res,
4980SN/A                                  apr_dbd_prepared_t *statement, int random,
4990SN/A                                  const void **args);
5000SN/A
5010SN/A/** apr_dbd_pvbquery: query using a prepared statement + binary args
5020SN/A *
5030SN/A *  @param driver - the driver
5040SN/A *  @param pool - working pool
5050SN/A *  @param handle - the connection
5060SN/A *  @param nrows - number of rows affected.
5070SN/A *  @param statement - the prepared statement to execute
5080SN/A *  @param ... - varargs list of binary args
5090SN/A *  @return 0 for success or error code
5100SN/A */
5110SN/AAPU_DECLARE_NONSTD(int) apr_dbd_pvbquery(const apr_dbd_driver_t *driver,
5120SN/A                                         apr_pool_t *pool,
5130SN/A                                         apr_dbd_t *handle, int *nrows,
5140SN/A                                         apr_dbd_prepared_t *statement, ...);
5150SN/A
5160SN/A/** apr_dbd_pvbselect: select using a prepared statement + binary args
5170SN/A *
5180SN/A *  @param driver - the driver
5190SN/A *  @param pool - working pool
5200SN/A *  @param handle - the connection
5210SN/A *  @param res - pointer to query results.  May point to NULL on entry
5220SN/A *  @param statement - the prepared statement to execute
5230SN/A *  @param random - Whether to support random-access to results
5240SN/A *  @param ... - varargs list of binary args
5250SN/A *  @return 0 for success or error code
5260SN/A */
5270SN/AAPU_DECLARE_NONSTD(int) apr_dbd_pvbselect(const apr_dbd_driver_t *driver,
5280SN/A                                          apr_pool_t *pool, apr_dbd_t *handle,
5290SN/A                                          apr_dbd_results_t **res,
5300SN/A                                          apr_dbd_prepared_t *statement,
5310SN/A                                          int random, ...);
5320SN/A
5330SN/A/** apr_dbd_datum_get: get a binary entry from a row
534 *
535 *  @param driver - the driver
536 *  @param row - row pointer
537 *  @param col - entry number
538 *  @param type - type of data to get
539 *  @param data - pointer to data, allocated by the caller
540 *  @return APR_SUCCESS on success, APR_ENOENT if data is NULL or APR_EGENERAL
541 */
542APU_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
546/** @} */
547
548#ifdef __cplusplus
549}
550#endif
551
552#endif
553