definitions for dbms abstraction api More...
#include "common.h"
#include <stdarg.h>
#include <time.h>
#include "collection.h"
#include "hashtable.h"
#include "linked_list.h"
#include "vector.h"
#include "str.h"
Go to the source code of this file.
Data Structures | |
struct | _cp_timestampz |
struct | _cp_db_connection_parameters |
struct | _cp_db_connection |
struct | _cp_db_statement |
struct | _cp_result_set |
struct | _cp_db_actions |
struct | _cp_dbms_driver_descriptor |
struct | _cp_data_source |
struct | _cp_db_connection_pool |
Typedefs | |
typedef CPROPS_DLL struct _cp_timestampz | cp_timestampz |
typedef CPROPS_DLL struct _cp_db_connection_parameters | cp_db_connection_parameters |
wrapper for dbms specific connection parameter descriptor | |
typedef CPROPS_DLL struct _cp_db_connection | cp_db_connection |
wrapper for dbms specific connection structure | |
typedef CPROPS_DLL struct _cp_db_statement | cp_db_statement |
typedef CPROPS_DLL struct _cp_result_set | cp_result_set |
holder for SELECT query results | |
typedef cp_db_connection *(* | cp_db_open_fn )(struct _cp_data_source *) |
implementations must define a function to open connections | |
typedef cp_result_set *(* | cp_db_select_fn )(cp_db_connection *conn, char *query) |
implementations must define a function to perform SELECT queries | |
typedef int(* | cp_db_fetch_metadata_fn )(cp_result_set *rs) |
implementations may define a function to retrieve metadata for a query result | |
typedef int(* | cp_db_fetch_next_fn )(cp_result_set *rs) |
implementations may define a function to retrieve result rows by chunk | |
typedef int(* | cp_db_release_result_set_fn )(cp_result_set *rs) |
implementations may define a function to close an open result set | |
typedef int(* | cp_db_update_fn )(cp_db_connection *conn, char *query) |
implemetations must define a function to perform INSERT, UPDATE or DELETE queries | |
typedef int(* | cp_db_close_fn )(cp_db_connection *conn) |
implemetations must define a function to close database connections | |
typedef char *(* | cp_db_escape_string_fn )(cp_db_connection *conn, char *src, int len) |
implementations may define a function to escape strings for use in SQL queries | |
typedef char *(* | cp_db_escape_binary_fn )(cp_db_connection *conn, char *src, int src_len, int *res_len) |
implementations may define a function to escape binary data for use in SQL queries | |
typedef cp_string *(* | cp_db_unescape_binary_fn )(cp_db_connection *conn, char *src) |
implementation may define a function to unescape binary data returned by an SQL query | |
typedef cp_db_statement *(* | cp_db_prepare_statement_fn )(cp_db_connection *conn, int prm_count, cp_field_type *prm_types, char *query) |
implementations may define a function to create a prepared statement | |
typedef int(* | cp_db_execute_statement_fn )(cp_db_connection *conn, cp_db_statement *stmt, cp_result_set **results, int *lengths, void **prm) |
implementations may define a function to execute a prepared statement | |
typedef void(* | cp_db_release_statement_fn )(cp_db_statement *stmt) |
implementations may define a function to release implementation specific allocations made to instantiate a prepared statement | |
typedef void(* | cp_db_set_autocommit_fn )(cp_db_connection *conn, int state) |
implementations may define a function to set autocommit mode | |
typedef int(* | cp_db_commit_fn )(cp_db_connection *conn) |
implementations may define a function to perform a commit | |
typedef int(* | cp_db_rollback_fn )(cp_db_connection *conn) |
implementations may define a function to perform a rollback | |
typedef CPROPS_DLL struct _cp_db_actions | cp_db_actions |
holder for implementation specific dbms access functions | |
typedef struct _cp_data_source *(* | cp_db_get_data_source_fn )(char *host, int port, char *user, char *passwd, char *dbname) |
typedef struct _cp_data_source *(* | cp_db_get_data_source_prm_fn )(char *host, int port, char *user, char *passwd, char *dbname, cp_hashtable *prm) |
typedef CPROPS_DLL struct _cp_dbms_driver_descriptor | cp_dbms_driver_descriptor |
typedef CPROPS_DLL struct _cp_data_source | cp_data_source |
dbms driver abstraction | |
typedef CPROPS_DLL struct _cp_db_connection_pool | cp_db_connection_pool |
connection pool structure | |
Enumerations | |
enum | { CP_FIELD_TYPE_BOOLEAN, CP_FIELD_TYPE_CHAR, CP_FIELD_TYPE_SHORT, CP_FIELD_TYPE_INT, CP_FIELD_TYPE_LONG, CP_FIELD_TYPE_LONG_LONG, CP_FIELD_TYPE_FLOAT, CP_FIELD_TYPE_DOUBLE, CP_FIELD_TYPE_VARCHAR, CP_FIELD_TYPE_BLOB, CP_FIELD_TYPE_DATE, CP_FIELD_TYPE_TIME, CP_FIELD_TYPE_TIMESTAMP } |
Functions | |
CPROPS_DLL int | cp_db_init () |
initialize persistence framework | |
CPROPS_DLL int | cp_db_register_dbms (char *dbms_name, void(*shutdown_call)()) |
register a dbms driver with the persistence framework | |
CPROPS_DLL int | cp_db_shutdown () |
shutdown dbms framework | |
CPROPS_DLL cp_timestampz * | cp_timestampz_create (struct timeval *tm, int minuteswest) |
CPROPS_DLL cp_timestampz * | cp_timestampz_create_prm (int sec_since_epoch, int microsec, int minwest) |
CPROPS_DLL void | cp_timestampz_destroy (cp_timestampz *tm) |
CPROPS_DLL struct tm * | cp_timestampz_localtime (cp_timestampz *tm, struct tm *res) |
CPROPS_DLL void | cp_db_connection_parameters_destroy (cp_db_connection_parameters *prm) |
destroy connection parameter descriptor | |
CPROPS_DLL cp_db_statement * | cp_db_statement_instantiate (cp_db_connection *connection, int prm_count, cp_field_type *types, void *source) |
convenience function for driver implementations - do not call directly. | |
CPROPS_DLL void | cp_db_statement_set_binary (cp_db_statement *stmt, int binary) |
set binary = 1 to request results in binary format | |
CPROPS_DLL void | cp_db_statement_destroy (cp_db_statement *statement) |
internal function - do not call directly. | |
CPROPS_DLL cp_vector * | cp_result_set_get_headers (cp_result_set *result_set) |
get a vector with field headers | |
CPROPS_DLL cp_vector * | cp_result_set_get_field_types (cp_result_set *result_set) |
get a vector with field type codes - see cp_field_type | |
CPROPS_DLL int | cp_result_set_field_count (cp_result_set *result_set) |
get field count | |
CPROPS_DLL int | cp_result_set_row_count (cp_result_set *result_set) |
get number of rows | |
CPROPS_DLL char * | cp_result_set_get_header (cp_result_set *result_set, int column) |
get a vector with field headers | |
CPROPS_DLL cp_field_type | cp_result_set_get_field_type (cp_result_set *rs, int column) |
get the type of a column | |
CPROPS_DLL void | cp_result_set_autodispose (cp_result_set *rs, int mode) |
set auto disposal | |
CPROPS_DLL cp_vector * | cp_result_set_next (cp_result_set *result_set) |
get next row | |
CPROPS_DLL void | cp_result_set_destroy (cp_result_set *result_set) |
close result set | |
CPROPS_DLL void | cp_result_set_release_row (cp_result_set *result_set, cp_vector *row) |
free a row from a result set | |
CPROPS_DLL int | cp_result_set_is_binary (cp_result_set *result_set) |
check whether rows are in binary format | |
CPROPS_DLL cp_result_set * | cp_db_connection_select (cp_db_connection *connection, char *query) |
perform a SELECT query | |
CPROPS_DLL int | cp_db_connection_update (cp_db_connection *connection, char *query) |
perform an INSERT, UPDATE or DELETE query | |
CPROPS_DLL int | cp_db_connection_close (cp_db_connection *connection) |
close connection | |
CPROPS_DLL void | cp_db_connection_destroy (cp_db_connection *connection) |
deallocate connection wrapper | |
CPROPS_DLL void | cp_db_connection_set_fetch_metadata (cp_db_connection *connection, int mode) |
auto fetch metadata | |
CPROPS_DLL void | cp_db_connection_set_read_result_set_at_once (cp_db_connection *connection, int mode) |
fetch complete result set immediately | |
CPROPS_DLL void | cp_db_connection_set_fetch_size (cp_db_connection *connection, int fetch_size) |
number of rows to fetch at a time | |
CPROPS_DLL char * | cp_db_connection_escape_string (cp_db_connection *connection, char *src, int len) |
escape a string for use in an SQL query on this connection | |
CPROPS_DLL char * | cp_db_connection_escape_binary (cp_db_connection *connection, char *src, int src_len, int *res_len) |
escape binary data for use in an SQL query on this connection | |
CPROPS_DLL cp_string * | cp_db_connection_unescape_binary (cp_db_connection *connection, char *src) |
unescape binary data returned by an SQL query on this connection | |
CPROPS_DLL cp_db_statement * | cp_db_connection_prepare_statement (cp_db_connection *connection, int prm_count, cp_field_type *prm_types, char *query) |
create a prepared statement for use with a connection | |
CPROPS_DLL int | cp_db_connection_execute_statement (cp_db_connection *connection, cp_db_statement *statement, cp_vector *prm, cp_result_set **results) |
execute a prepared statement | |
CPROPS_DLL int | cp_db_connection_execute_statement_args (cp_db_connection *connection, cp_db_statement *statement, cp_result_set **results,...) |
execute a prepared statement | |
CPROPS_DLL void | cp_db_connection_close_statement (cp_db_connection *connection, cp_db_statement *statement) |
release a statement | |
CPROPS_DLL void | cp_db_connection_set_autocommit (cp_db_connection *conn, int state) |
set autocommit state | |
CPROPS_DLL int | cp_db_connection_commit (cp_db_connection *conn) |
perform a commit | |
CPROPS_DLL int | cp_db_connection_rollback (cp_db_connection *conn) |
perform a rollback | |
CPROPS_DLL cp_db_actions * | cp_db_actions_create (int dbms, char *dbms_lit, cp_db_open_fn open, cp_db_select_fn select, cp_db_fetch_metadata_fn fetch_metadata, cp_db_fetch_next_fn fetch_next, cp_db_release_result_set_fn release_result_set, cp_db_update_fn update, cp_db_close_fn close, cp_db_escape_string_fn escape_string, cp_db_escape_binary_fn escape_binary, cp_db_unescape_binary_fn unescape_binary, cp_db_prepare_statement_fn prepare_statement, cp_db_execute_statement_fn execute_statement, cp_db_release_statement_fn release_statement, cp_db_set_autocommit_fn set_autocommit, cp_db_commit_fn commit, cp_db_rollback_fn rollback) |
convenience method to create a new implementation method holder | |
CPROPS_DLL void | cp_db_actions_destroy (cp_db_actions *actions) |
deallocate an implementation method holder | |
CPROPS_DLL cp_data_source * | cp_dbms_get_data_source (char *driver, char *host, int port, char *user, char *passwd, char *dbname) |
CPROPS_DLL cp_data_source * | cp_dbms_get_data_source_prm (char *driver, char *host, int port, char *user, char *passwd, char *dbname, cp_hashtable *prm) |
CPROPS_DLL void | cp_data_source_destroy (cp_data_source *data_source) |
deallocate a cp_data_source structure | |
CPROPS_DLL cp_db_connection * | cp_data_source_get_connection (cp_data_source *data_source) |
open a connection with the set connection parameters | |
CPROPS_DLL cp_db_connection_pool * | cp_db_connection_pool_create (cp_data_source *data_source, int min_size, int max_size, int initial_size) |
create a new connection pool | |
CPROPS_DLL int | cp_db_connection_pool_shutdown (cp_db_connection_pool *pool) |
shut down a connection pool | |
CPROPS_DLL void | cp_db_connection_pool_destroy (cp_db_connection_pool *pool) |
deallocate a connection pool object | |
CPROPS_DLL void | cp_db_connection_pool_set_blocking (cp_db_connection_pool *pool, int block) |
set connection pool to block until a connection is available when retrieving connections if no connection is available | |
CPROPS_DLL cp_db_connection * | cp_db_connection_pool_get_connection (cp_db_connection_pool *pool) |
retrieve a connection from a connection pool | |
CPROPS_DLL void | cp_db_connection_pool_release_connection (cp_db_connection_pool *pool, cp_db_connection *connection) |
return a connection to the pool | |
Variables | |
__BEGIN_DECLS typedef CPROPS_DLL enum { ... } | cp_field_type |
definitions for dbms abstraction api