Apache Portable Runtime Utility Library
include/private/apr_dbd_internal.h
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 /* Overview of what this is and does:
00018  * http://www.apache.org/~niq/dbd.html
00019  */
00020 
00021 #ifndef APR_DBD_INTERNAL_H
00022 #define APR_DBD_INTERNAL_H
00023 
00024 #include <stdarg.h>
00025 
00026 #include "apr_dbd.h"
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00032 #define TXN_IGNORE_ERRORS(t) \
00033   ((t) && ((t)->mode & APR_DBD_TRANSACTION_IGNORE_ERRORS))
00034 #define TXN_NOTICE_ERRORS(t) \
00035   ((t) && !((t)->mode & APR_DBD_TRANSACTION_IGNORE_ERRORS))
00036 
00037 #define TXN_DO_COMMIT(t)   (!((t)->mode & APR_DBD_TRANSACTION_ROLLBACK))
00038 #define TXN_DO_ROLLBACK(t) ((t)->mode & APR_DBD_TRANSACTION_ROLLBACK)
00039 
00040 #define TXN_MODE_BITS \
00041   (APR_DBD_TRANSACTION_ROLLBACK|APR_DBD_TRANSACTION_IGNORE_ERRORS)
00042 
00043 struct apr_dbd_driver_t {
00045     const char *name;
00046 
00050     void (*init)(apr_pool_t *pool);
00051 
00057     void *(*native_handle)(apr_dbd_t *handle);
00058 
00069     apr_dbd_t *(*open)(apr_pool_t *pool, const char *params,
00070                        const char **error);
00071 
00078     apr_status_t (*check_conn)(apr_pool_t *pool, apr_dbd_t *handle);
00079 
00085     apr_status_t (*close)(apr_dbd_t *handle);
00086 
00094     int (*set_dbname)(apr_pool_t* pool, apr_dbd_t *handle, const char *name);
00095 
00103     int (*start_transaction)(apr_pool_t *pool, apr_dbd_t *handle,
00104                              apr_dbd_transaction_t **trans);
00105 
00113     int (*end_transaction)(apr_dbd_transaction_t *trans);
00114 
00122     int (*query)(apr_dbd_t *handle, int *nrows, const char *statement);
00123 
00135     int (*select)(apr_pool_t *pool, apr_dbd_t *handle, apr_dbd_results_t **res,
00136                   const char *statement, int random);
00137 
00143     int (*num_cols)(apr_dbd_results_t *res);
00144 
00151     int (*num_tuples)(apr_dbd_results_t *res);
00152 
00162     int (*get_row)(apr_pool_t *pool, apr_dbd_results_t *res,
00163                    apr_dbd_row_t **row, int rownum);
00164   
00172     const char* (*get_entry)(const apr_dbd_row_t *row, int col);
00173   
00181     const char *(*error)(apr_dbd_t *handle, int errnum);
00182   
00190     const char *(*escape)(apr_pool_t *pool, const char *string,
00191                           apr_dbd_t *handle);
00192   
00207     int (*prepare)(apr_pool_t *pool, apr_dbd_t *handle, const char *query,
00208                    const char *label, int nargs, int nvals,
00209                    apr_dbd_type_e *types, apr_dbd_prepared_t **statement);
00210 
00220     int (*pvquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
00221                    apr_dbd_prepared_t *statement, va_list args);
00222 
00233     int (*pvselect)(apr_pool_t *pool, apr_dbd_t *handle,
00234                     apr_dbd_results_t **res,
00235                     apr_dbd_prepared_t *statement, int random, va_list args);
00236 
00246     int (*pquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
00247                   apr_dbd_prepared_t *statement, const char **args);
00248 
00259     int (*pselect)(apr_pool_t *pool, apr_dbd_t *handle,
00260                    apr_dbd_results_t **res, apr_dbd_prepared_t *statement,
00261                    int random, const char **args);
00262 
00263   
00270     const char* (*get_name)(const apr_dbd_results_t *res, int col);
00271 
00277     int (*transaction_mode_get)(apr_dbd_transaction_t *trans);
00278 
00285     int (*transaction_mode_set)(apr_dbd_transaction_t *trans, int mode);
00286 
00288     const char *pformat;
00289 
00299     int (*pvbquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
00300                     apr_dbd_prepared_t *statement, va_list args);
00301 
00312     int (*pvbselect)(apr_pool_t *pool, apr_dbd_t *handle,
00313                      apr_dbd_results_t **res,
00314                      apr_dbd_prepared_t *statement, int random, va_list args);
00315 
00325     int (*pbquery)(apr_pool_t *pool, apr_dbd_t *handle, int *nrows,
00326                    apr_dbd_prepared_t *statement,const void **args);
00327 
00338     int (*pbselect)(apr_pool_t *pool, apr_dbd_t *handle,
00339                     apr_dbd_results_t **res, apr_dbd_prepared_t *statement,
00340                     int random, const void **args);
00341   
00350     apr_status_t (*datum_get)(const apr_dbd_row_t *row, int col,
00351                               apr_dbd_type_e type, void *data);
00352 };
00353 
00354 /* Export mutex lock/unlock for drivers that need it 
00355  * deprecated; create a per-dbd mutex within the (*init) function
00356  * to avoid blocking other providers running on other threads
00357  */
00358 APU_DECLARE(apr_status_t) apr_dbd_mutex_lock(void);
00359 APU_DECLARE(apr_status_t) apr_dbd_mutex_unlock(void);
00360 
00361 #ifdef __cplusplus
00362 }
00363 #endif
00364 
00365 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines