Functions

db_postgres/km_dbase.h File Reference

DB_POSTGRES :: CoreModule: DB_POSTGRES :: the PostgreSQL driver for Kamailio. More...

#include "../../lib/srdb1/db_con.h"
#include "../../lib/srdb1/db_res.h"
#include "../../lib/srdb1/db_key.h"
#include "../../lib/srdb1/db_op.h"
#include "../../lib/srdb1/db_val.h"
Include dependency graph for db_postgres/km_dbase.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions


Detailed Description

Definition in file db_postgres/km_dbase.h.


Function Documentation

int db_postgres_abort_transaction ( db1_con_t _h  ) 
Parameters:
_h database handle
Returns:
1 if there was something to rollback, 0 if not, negative on failure

Definition at line 714 of file db_postgres/km_dbase.c.

References db_postgres_free_result(), and db_postgres_raw_query().

Here is the call graph for this function:

int db_postgres_affected_rows ( const db1_con_t _h  ) 
Parameters:
_h database handle
Returns:
returns the affected rows as integer or -1 on error.

Definition at line 633 of file db_postgres/km_dbase.c.

Referenced by db_postgres_replace().

Here is the caller graph for this function:

void db_postgres_close ( db1_con_t _h  ) 
Parameters:
_h closed connection, as returned from db_postgres_init
Note:
free all memory and resources

Definition at line 152 of file db_postgres/km_dbase.c.

References db_do_close(), and db_postgres_free_connection().

Here is the call graph for this function:

int db_postgres_delete ( const db1_con_t _h,
const db_key_t _k,
const db_op_t _o,
const db_val_t _v,
const int  _n 
)
Parameters:
_h structure representing database connection
_k key names
_o operators
_v values of the keys that must match
_n number of key=value pairs
Returns:
0 on success, negative on failure

Definition at line 576 of file db_postgres/km_dbase.c.

References db_do_delete(), db_free_result(), db_postgres_store_result(), db_postgres_submit_query(), and db_postgres_val2str().

Here is the call graph for this function:

int db_postgres_end_transaction ( db1_con_t _h  ) 
Parameters:
_h database handle
Returns:
0 on success, negative on failure

Definition at line 679 of file db_postgres/km_dbase.c.

References db_postgres_free_result(), and db_postgres_raw_query().

Here is the call graph for this function:

int db_postgres_fetch_result ( const db1_con_t _con,
db1_res_t **  _res,
const int  nrows 
)

Gets a partial result set, fetch a number of rows from a database result. This function initialize the given result structure on the first run, and fetches the nrows number of rows. On subsequenting runs, it uses the existing result and fetches more rows, until it reaches the end of the result set. Because of this the result needs to be null in the first invocation of the function. If the number of wanted rows is zero, the function returns anything with a result of zero.

Parameters:
_con database connection
_res result set
nrows number of fetches rows
Returns:
0 on success, negative on failure

Definition at line 248 of file db_postgres/km_dbase.c.

References db_free_result(), db_free_rows(), db_new_result(), db_postgres_convert_rows(), db_postgres_get_columns(), RES_LAST_ROW, RES_NUM_ROWS, RES_ROW_N, and RES_ROWS.

Here is the call graph for this function:

int db_postgres_free_result ( db1_con_t _con,
db1_res_t _r 
)
Parameters:
_con database connection
_r result set
Returns:
0 on success, -1 on failure

Definition at line 392 of file db_postgres/km_dbase.c.

References db_free_result(), and db_postgres_free_query().

Referenced by db_postgres_abort_transaction(), db_postgres_end_transaction(), and db_postgres_start_transaction().

Here is the call graph for this function:

Here is the caller graph for this function:

db1_con_t* db_postgres_init ( const str _url  ) 
Parameters:
_url URL of the database that should be opened
Returns:
database connection on success, NULL on error
Note:
this function must be called prior to any database functions

Definition at line 131 of file db_postgres/km_dbase.c.

References db_do_init(), and db_postgres_new_connection().

Here is the call graph for this function:

db1_con_t* db_postgres_init2 ( const str _url,
db_pooling_t  pooling 
)
Parameters:
_url URL of the database that should be opened
Returns:
database connection on success, NULL on error
Note:
this function must be called prior to any database functions

Definition at line 142 of file db_postgres/km_dbase.c.

References db_do_init2(), and db_postgres_new_connection().

Here is the call graph for this function:

int db_postgres_insert ( const db1_con_t _h,
const db_key_t _k,
const db_val_t _v,
const int  _n 
)
Parameters:
_h structure representing database connection
_k key names
_v values of the keys
_n number of key=value pairs
Returns:
0 on success, negative on failure

Definition at line 546 of file db_postgres/km_dbase.c.

References db_do_insert(), db_free_result(), db_postgres_store_result(), db_postgres_submit_query(), and db_postgres_val2str().

Referenced by db_postgres_replace().

Here is the call graph for this function:

Here is the caller graph for this function:

int db_postgres_query ( const db1_con_t _h,
const db_key_t _k,
const db_op_t _op,
const db_val_t _v,
const db_key_t _c,
const int  _n,
const int  _nc,
const db_key_t  _o,
db1_res_t **  _r 
)
Parameters:
_h structure representing database connection
_k key names
_op operators
_v values of the keys that must match
_c column names to return
_n nmber of key=values pairs to compare
_nc number of columns to return
_o order by the specified column
_r result set
Returns:
0 on success, negative on failure

Definition at line 420 of file db_postgres/km_dbase.c.

References db_do_query(), db_postgres_store_result(), db_postgres_submit_query(), and db_postgres_val2str().

Here is the call graph for this function:

int db_postgres_raw_query ( const db1_con_t _h,
const str _s,
db1_res_t **  _r 
)
Parameters:
_h database connection
_s raw query string
_r result set
Returns:
0 on success, negative on failure

Definition at line 436 of file db_postgres/km_dbase.c.

References db_do_raw_query(), db_postgres_store_result(), and db_postgres_submit_query().

Referenced by db_postgres_abort_transaction(), db_postgres_end_transaction(), and db_postgres_start_transaction().

Here is the call graph for this function:

Here is the caller graph for this function:

int db_postgres_replace ( const db1_con_t _h,
const db_key_t _k,
const db_val_t _v,
const int  _n,
const int  _un,
const int  _m 
)
Parameters:
_h structure representing database connection
_k key names
_v values of the keys
_n number of key=value pairs
_un number of keys to build the unique key, starting from first
_m mode - first update, then insert, or first insert, then update
Returns:
0 on success, negative on failure

Definition at line 766 of file db_postgres/km_dbase.c.

References DB1_INT, DB1_STR, DB1_STRING, db_postgres_affected_rows(), db_postgres_insert(), db_postgres_update(), VAL_NULL, VAL_STR, VAL_STRING, VAL_TYPE, and VAL_UINT.

Here is the call graph for this function:

int db_postgres_start_transaction ( db1_con_t _h  ) 
Parameters:
_h database handle
Returns:
0 on success, negative on failure

Definition at line 647 of file db_postgres/km_dbase.c.

References db_postgres_free_result(), and db_postgres_raw_query().

Here is the call graph for this function:

int db_postgres_store_result ( const db1_con_t _con,
db1_res_t **  _r 
)
Parameters:
_con structure representing the database connection
_r pointer to a structure represending the result set
Returns:
0 If the status of the last command produced a result set and, If the result set contains data or the convert_result() routine completed successfully. Negative if the status of the last command was not handled or if the convert_result() returned an error.
Note:
A new result structure is allocated on every call to this routine. If this routine returns 0, it is the callers responsbility to free the result structure. If this routine returns < 0, then the result structure is freed before returning to the caller.

Definition at line 456 of file db_postgres/km_dbase.c.

References db_free_result(), db_new_result(), db_postgres_convert_result(), and db_postgres_free_query().

Referenced by db_postgres_delete(), db_postgres_insert(), db_postgres_query(), db_postgres_raw_query(), and db_postgres_update().

Here is the call graph for this function:

Here is the caller graph for this function:

int db_postgres_update ( const db1_con_t _h,
const db_key_t _k,
const db_op_t _o,
const db_val_t _v,
const db_key_t _uk,
const db_val_t _uv,
const int  _n,
const int  _un 
)
Parameters:
_h structure representing database connection
_k key names
_o operators
_v values of the keys that must match
_uk updated columns
_uv updated values of the columns
_n number of key=value pairs
_un number of columns to update
Returns:
0 on success, negative on failure

Definition at line 608 of file db_postgres/km_dbase.c.

References db_do_update(), db_free_result(), db_postgres_store_result(), db_postgres_submit_query(), and db_postgres_val2str().

Referenced by db_postgres_replace().

Here is the call graph for this function:

Here is the caller graph for this function:

int db_postgres_use_table ( db1_con_t _con,
const str _t 
)
Parameters:
_con database connection
_t table name
Returns:
0 on success, negative on error

Definition at line 750 of file db_postgres/km_dbase.c.

References db_use_table().

Here is the call graph for this function: