Functions | Variables

lib/srdb1/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_query.h"
#include "db.h"
Include dependency graph for lib/srdb1/db.c:

Go to the source code of this file.

Functions

Variables


Detailed Description

Definition in file lib/srdb1/db.c.


Function Documentation

int db_api_init ( void   ) 

This function must be executed by DB connector modules at load time to initialize the internals of DB API library.

Returns:
returns 0 on successful initialization, -1 on error.

Definition at line 519 of file lib/srdb1/db.c.

References db_query_init().

Referenced by db_mysql_alloc_buffer().

Here is the call graph for this function:

Here is the caller graph for this function:

int db_bind_mod ( const str mod,
db_func_t mydbf 
)

Bind database module functions.

Parameters:
mod 
mydbf 
Returns:
returns 0 on success, -1 on error
Note:
on error mydbf will contain only 0s

Definition at line 158 of file lib/srdb1/db.c.

References _str::len, MAX_URL_LENGTH, and _str::s.

Referenced by carrierroute_db_init(), domainpolicy_db_bind(), group_db_bind(), init_ds_db(), matrix_db_init(), mod_init(), pl_init_db(), and userblacklist_db_init().

Here is the caller graph for this function:

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

Check the table version.

Definition at line 432 of file lib/srdb1/db.c.

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

Referenced by carrierroute_db_init(), matrix_db_init(), mod_init(), register_udomain(), and userblacklist_db_init().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Helper for db_close function.

Note:
No function should be called after this

Definition at line 342 of file lib/srdb1/db.c.

References pool_remove(), and db1_con_t::tail.

Referenced by db_mysql_close(), and db_postgres_close().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Helper for db_init function.

Note:
No function should be called before this

Definition at line 269 of file lib/srdb1/db.c.

References db_do_init2().

Referenced by db_mysql_init(), and db_postgres_init().

Here is the call graph for this function:

Here is the caller graph for this function:

db1_con_t* db_do_init2 ( const str url,
void *(*)()  new_connection,
db_pooling_t  pooling 
)

Helper for db_init2 function.

Note:
No function should be called before this

Definition at line 279 of file lib/srdb1/db.c.

References free_db_id(), _str::len, MAX_URL_LENGTH, new_db_id(), pool_get(), pool_insert(), _str::s, and db1_con_t::tail.

Referenced by db_do_init(), and db_postgres_init2().

Here is the call graph for this function:

Here is the caller graph for this function:

int db_load_bulk_data ( db_func_t binding,
db1_con_t handle,
str name,
db_key_t cols,
unsigned int  count,
unsigned int  strict,
db1_res_t res 
)

Generic query helper method for load bulk data, e.g. lcr tables

Parameters:
binding database module binding
handle database connection
name database table name
cols queried columns
count number of queried columns
strict if set to 1 an error is returned when no data could be loaded, otherwise just a warning is logged
res database result, unchanged on failure and if no data could be found
Returns:
0 if the query was run successful, -1 otherwise

Definition at line 474 of file lib/srdb1/db.c.

References _str::len, RES_ROW_N, and _str::s.

int db_table_version ( const db_func_t dbf,
db1_con_t connection,
const str 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 368 of file lib/srdb1/db.c.

References DB1_INT, _str::len, RES_ROW_N, RES_ROWS, ROW_VALUES, _str::s, TABLENAME_COLUMN, VAL_INT, VAL_NULL, VAL_STR, VAL_TYPE, VERSION_COLUMN, and VERSION_TABLE.

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

Here is the caller graph for this function:

int db_use_table ( db1_con_t _h,
const str _t 
)

Stores the name of a table.

Definition at line 449 of file lib/srdb1/db.c.

References CON_TABLE, and _str::s.

Referenced by db_mysql_use_table(), and db_postgres_use_table().

Here is the caller graph for this function: