db/db.c File Reference

Generic Database Interface. More...

#include "../dprint.h"
#include "../sr_module.h"
#include "../mem/mem.h"
#include "../ut.h"
#include "db_cap.h"
#include "db_id.h"
#include "db_pool.h"
#include "db.h"

Include dependency graph for db/db.c:

Go to the source code of this file.

Functions

int db_bind_mod (const str *mod, db_func_t *mydbf)
 fills mydbf with the corresponding db module callbacks
int db_check_api (db_func_t *dbf, char *mname)
int db_check_table_version (db_func_t *dbf, db_con_t *dbh, const str *table, const unsigned int version)
 Check the table version 0 means ok, -1 means an error occured.
void db_do_close (db_con_t *_h, void(*free_connection)())
 Shut down database module.
db_con_tdb_do_init (const str *url, void *(*new_connection)())
 Initialize database module.
int db_table_version (const db_func_t *dbf, db_con_t *connection, const str *table)
 Get version of a table.
int db_use_table (db_con_t *_h, const str *_t)
 Store name of table that will be used by subsequent database functions.

Variables

static unsigned int MAX_URL_LENGTH = 255


Detailed Description

Generic Database Interface.

Definition in file db/db.c.


Function Documentation

int db_bind_mod ( const str mod,
db_func_t mydbf 
)

int db_check_api ( db_func_t dbf,
char *  mname 
)

int db_check_table_version ( db_func_t dbf,
db_con_t dbh,
const str table,
const unsigned int  version 
)

Check the table version 0 means ok, -1 means an error occured.

Check the table version.

Definition at line 402 of file db/db.c.

References db_table_version(), _str::len, LM_ERR, and _str::s.

Referenced by auth_fixup(), carrierroute_db_init(), cpl_db_bind(), domain_db_ver(), init_addresses(), init_child_trusted(), init_db_data(), init_dlg_db(), init_trusted(), mod_init(), register_udomain(), and userblacklist_db_init().

void db_do_close ( db_con_t _h,
void(*)()  free_connection 
)

Shut down database module.

Helper for db_close function.

Note:
No function should be called after this

Definition at line 311 of file db/db.c.

References LM_ERR, pkg_free, pool_remove(), and db_con_t::tail.

Referenced by db_mysql_close(), db_oracle_close(), db_postgres_close(), and db_unixodbc_close().

db_con_t* db_do_init ( const str url,
void *(*)()  new_connection 
)

Initialize database module.

Helper for db_init function.

Note:
No function should be called before this

Definition at line 248 of file db/db.c.

References free_db_id(), id, _str::len, LM_DBG, LM_ERR, MAX_URL_LENGTH, new_db_id(), pkg_free, pkg_malloc, pool_get(), pool_insert(), _str::s, and db_con_t::tail.

Referenced by db_mysql_init(), db_oracle_init(), db_postgres_init(), and db_unixodbc_init().

int db_table_version ( const db_func_t dbf,
db_con_t connection,
const str table 
)

Get version of a table.

Get the version of a table.

Parameters:
dbf 
connection 
table 
Returns:
If there is no row for the given table, return version 0

Definition at line 337 of file db/db.c.

References DB_INT, DB_STR, db_func::free_result, _str::len, LM_CRIT, LM_DBG, LM_ERR, NULL, db_func::query, RES_ROW_N, RES_ROWS, ROW_VALUES, _str::s, str_init, TABLENAME_COLUMN, db_func::use_table, VAL_INT, VAL_NULL, VAL_STR, VAL_TYPE, version, VERSION_COLUMN, VERSION_TABLE, and ZSW.

Referenced by db_check_table_version(), domainpolicy_db_ver(), init_ds_db(), and uridb_db_ver().

int db_use_table ( db_con_t _h,
const str _t 
)

Store name of table that will be used by subsequent database functions.

Stores the name of a table.

Definition at line 419 of file db/db.c.

References CON_TABLE, LM_ERR, and _str::s.

Referenced by bdb_use_table(), db_mysql_use_table(), db_oracle_use_table(), db_postgres_use_table(), db_unixodbc_use_table(), and dbt_use_table().


Variable Documentation

unsigned int MAX_URL_LENGTH = 255 [static]

maximum length of a SQL URL

Definition at line 69 of file db/db.c.

Referenced by db_bind_mod(), and db_do_init().


Generated on Mon May 21 18:00:38 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6