GME  13
apr_dbd.h
Go to the documentation of this file.
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_H
00022 #define APR_DBD_H
00023 
00024 #include "apu.h"
00025 #include "apr_pools.h"
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00055 typedef enum {
00056     APR_DBD_TYPE_NONE,
00057     APR_DBD_TYPE_TINY,       
00058     APR_DBD_TYPE_UTINY,      
00059     APR_DBD_TYPE_SHORT,      
00060     APR_DBD_TYPE_USHORT,     
00061     APR_DBD_TYPE_INT,        
00062     APR_DBD_TYPE_UINT,       
00063     APR_DBD_TYPE_LONG,       
00064     APR_DBD_TYPE_ULONG,      
00065     APR_DBD_TYPE_LONGLONG,   
00066     APR_DBD_TYPE_ULONGLONG,  
00067     APR_DBD_TYPE_FLOAT,      
00068     APR_DBD_TYPE_DOUBLE,     
00069     APR_DBD_TYPE_STRING,     
00070     APR_DBD_TYPE_TEXT,       
00071     APR_DBD_TYPE_TIME,       
00072     APR_DBD_TYPE_DATE,       
00073     APR_DBD_TYPE_DATETIME,   
00074     APR_DBD_TYPE_TIMESTAMP,  
00075     APR_DBD_TYPE_ZTIMESTAMP, 
00076     APR_DBD_TYPE_BLOB,       
00077     APR_DBD_TYPE_CLOB,       
00078     APR_DBD_TYPE_NULL        
00079 } apr_dbd_type_e;
00080 
00081 /* These are opaque structs.  Instantiation is up to each backend */
00082 typedef struct apr_dbd_driver_t apr_dbd_driver_t;
00083 typedef struct apr_dbd_t apr_dbd_t;
00084 typedef struct apr_dbd_transaction_t apr_dbd_transaction_t;
00085 typedef struct apr_dbd_results_t apr_dbd_results_t;
00086 typedef struct apr_dbd_row_t apr_dbd_row_t;
00087 typedef struct apr_dbd_prepared_t apr_dbd_prepared_t;
00088 
00093 APU_DECLARE(apr_status_t) apr_dbd_init(apr_pool_t *pool);
00094 
00105 APU_DECLARE(apr_status_t) apr_dbd_get_driver(apr_pool_t *pool, const char *name,
00106                                              const apr_dbd_driver_t **driver);
00107 
00143 APU_DECLARE(apr_status_t) apr_dbd_open_ex(const apr_dbd_driver_t *driver,
00144                                           apr_pool_t *pool, const char *params,
00145                                           apr_dbd_t **handle,
00146                                           const char **error);
00147 
00158 APU_DECLARE(apr_status_t) apr_dbd_open(const apr_dbd_driver_t *driver,
00159                                        apr_pool_t *pool, const char *params,
00160                                        apr_dbd_t **handle);
00161 
00168 APU_DECLARE(apr_status_t) apr_dbd_close(const apr_dbd_driver_t *driver,
00169                                         apr_dbd_t *handle);
00170 
00171 /* apr-function-shaped versions of things */
00172 
00178 APU_DECLARE(const char*) apr_dbd_name(const apr_dbd_driver_t *driver);
00179 
00186 APU_DECLARE(void*) apr_dbd_native_handle(const apr_dbd_driver_t *driver,
00187                                          apr_dbd_t *handle);
00188 
00196 APU_DECLARE(int) apr_dbd_check_conn(const apr_dbd_driver_t *driver, apr_pool_t *pool,
00197                                     apr_dbd_t *handle);
00198 
00207 APU_DECLARE(int) apr_dbd_set_dbname(const apr_dbd_driver_t *driver, apr_pool_t *pool,
00208                                     apr_dbd_t *handle, const char *name);
00209 
00224 APU_DECLARE(int) apr_dbd_transaction_start(const apr_dbd_driver_t *driver,
00225                                            apr_pool_t *pool,
00226                                            apr_dbd_t *handle,
00227                                            apr_dbd_transaction_t **trans);
00228 
00238 APU_DECLARE(int) apr_dbd_transaction_end(const apr_dbd_driver_t *driver,
00239                                          apr_pool_t *pool,
00240                                          apr_dbd_transaction_t *trans);
00241 
00242 #define APR_DBD_TRANSACTION_COMMIT        0x00  
00243 #define APR_DBD_TRANSACTION_ROLLBACK      0x01  
00244 #define APR_DBD_TRANSACTION_IGNORE_ERRORS 0x02  
00252 APU_DECLARE(int) apr_dbd_transaction_mode_get(const apr_dbd_driver_t *driver,
00253                                               apr_dbd_transaction_t *trans);
00254 
00262 APU_DECLARE(int) apr_dbd_transaction_mode_set(const apr_dbd_driver_t *driver,
00263                                               apr_dbd_transaction_t *trans,
00264                                               int mode);
00265 
00274 APU_DECLARE(int) apr_dbd_query(const apr_dbd_driver_t *driver, apr_dbd_t *handle,
00275                                int *nrows, const char *statement);
00276 
00289 APU_DECLARE(int) apr_dbd_select(const apr_dbd_driver_t *driver, apr_pool_t *pool,
00290                                 apr_dbd_t *handle, apr_dbd_results_t **res,
00291                                 const char *statement, int random);
00292 
00299 APU_DECLARE(int) apr_dbd_num_cols(const apr_dbd_driver_t *driver,
00300                                   apr_dbd_results_t *res);
00301 
00309 APU_DECLARE(int) apr_dbd_num_tuples(const apr_dbd_driver_t *driver,
00310                                     apr_dbd_results_t *res);
00311 
00322 APU_DECLARE(int) apr_dbd_get_row(const apr_dbd_driver_t *driver, apr_pool_t *pool,
00323                                  apr_dbd_results_t *res, apr_dbd_row_t **row,
00324                                  int rownum);
00325 
00333 APU_DECLARE(const char*) apr_dbd_get_entry(const apr_dbd_driver_t *driver,
00334                                            apr_dbd_row_t *row, int col);
00335 
00343 APU_DECLARE(const char*) apr_dbd_get_name(const apr_dbd_driver_t *driver,
00344                                           apr_dbd_results_t *res, int col);
00345 
00346 
00355 APU_DECLARE(const char*) apr_dbd_error(const apr_dbd_driver_t *driver,
00356                                        apr_dbd_t *handle, int errnum);
00357 
00366 APU_DECLARE(const char*) apr_dbd_escape(const apr_dbd_driver_t *driver,
00367                                         apr_pool_t *pool, const char *string,
00368                                         apr_dbd_t *handle);
00369 
00398 APU_DECLARE(int) apr_dbd_prepare(const apr_dbd_driver_t *driver, apr_pool_t *pool,
00399                                  apr_dbd_t *handle, const char *query,
00400                                  const char *label,
00401                                  apr_dbd_prepared_t **statement);
00402 
00403 
00415 APU_DECLARE(int) apr_dbd_pquery(const apr_dbd_driver_t *driver, apr_pool_t *pool,
00416                                 apr_dbd_t *handle, int *nrows,
00417                                 apr_dbd_prepared_t *statement, int nargs,
00418                                 const char **args);
00419 
00432 APU_DECLARE(int) apr_dbd_pselect(const apr_dbd_driver_t *driver, apr_pool_t *pool,
00433                                  apr_dbd_t *handle, apr_dbd_results_t **res,
00434                                  apr_dbd_prepared_t *statement, int random,
00435                                  int nargs, const char **args);
00436 
00447 APU_DECLARE_NONSTD(int) apr_dbd_pvquery(const apr_dbd_driver_t *driver, 
00448                                         apr_pool_t *pool,
00449                                         apr_dbd_t *handle, int *nrows,
00450                                         apr_dbd_prepared_t *statement, ...);
00451 
00463 APU_DECLARE_NONSTD(int) apr_dbd_pvselect(const apr_dbd_driver_t *driver,
00464                                          apr_pool_t *pool, apr_dbd_t *handle,
00465                                          apr_dbd_results_t **res,
00466                                          apr_dbd_prepared_t *statement,
00467                                          int random, ...);
00468 
00479 APU_DECLARE(int) apr_dbd_pbquery(const apr_dbd_driver_t *driver,
00480                                  apr_pool_t *pool, apr_dbd_t *handle,
00481                                  int *nrows, apr_dbd_prepared_t *statement,
00482                                  const void **args);
00483 
00495 APU_DECLARE(int) apr_dbd_pbselect(const apr_dbd_driver_t *driver,
00496                                   apr_pool_t *pool,
00497                                   apr_dbd_t *handle, apr_dbd_results_t **res,
00498                                   apr_dbd_prepared_t *statement, int random,
00499                                   const void **args);
00500 
00511 APU_DECLARE_NONSTD(int) apr_dbd_pvbquery(const apr_dbd_driver_t *driver,
00512                                          apr_pool_t *pool,
00513                                          apr_dbd_t *handle, int *nrows,
00514                                          apr_dbd_prepared_t *statement, ...);
00515 
00527 APU_DECLARE_NONSTD(int) apr_dbd_pvbselect(const apr_dbd_driver_t *driver,
00528                                           apr_pool_t *pool, apr_dbd_t *handle,
00529                                           apr_dbd_results_t **res,
00530                                           apr_dbd_prepared_t *statement,
00531                                           int random, ...);
00532 
00542 APU_DECLARE(apr_status_t) apr_dbd_datum_get(const apr_dbd_driver_t *driver,
00543                                             apr_dbd_row_t *row, int col,
00544                                             apr_dbd_type_e type, void *data);
00545 
00548 #ifdef __cplusplus
00549 }
00550 #endif
00551 
00552 #endif