Module: DB_POSTGRES :: the PostgreSQL driver for Kamailio. More...
#include <string.h>
#include <stdio.h>
#include "../../dprint.h"
#include "../../mem/mem.h"
#include "../../db/db.h"
#include "../../db/db_ut.h"
#include "../../db/db_query.h"
#include "dbase.h"
#include "pg_con.h"
#include "val.h"
#include "res.h"

Go to the source code of this file.
Defines | |
| #define | MAXCOLUMNS 512 |
Functions | |
| void | db_postgres_close (db_con_t *_h) |
| Close database when the database is no longer needed. | |
| int | db_postgres_delete (const db_con_t *_h, const db_key_t *_k, const db_op_t *_o, const db_val_t *_v, const int _n) |
| Delete a row from the specified table. | |
| int | db_postgres_fetch_result (const db_con_t *_con, db_res_t **_res, const int nrows) |
| Gets a partial result set, fetch rows from a result. | |
| static void | db_postgres_free_query (const db_con_t *_con) |
| Free database and any old query results. | |
| int | db_postgres_free_result (db_con_t *_con, db_res_t *_r) |
| Free the query and the result memory in the core. | |
| db_con_t * | db_postgres_init (const str *_url) |
| Initialize database for future queries. | |
| int | db_postgres_insert (const db_con_t *_h, const db_key_t *_k, const db_val_t *_v, const int _n) |
| Insert a row into specified table. | |
| int | db_postgres_query (const db_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, db_res_t **_r) |
| Query table for specified rows. | |
| int | db_postgres_raw_query (const db_con_t *_h, const str *_s, db_res_t **_r) |
| int | db_postgres_store_result (const db_con_t *_con, db_res_t **_r) |
| Retrieve result set. | |
| static int | db_postgres_submit_query (const db_con_t *_con, const str *_s) |
| Submit_query, run a query. | |
| int | db_postgres_update (const db_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) |
| int | db_postgres_use_table (db_con_t *_con, const str *_t) |
Module: DB_POSTGRES :: the PostgreSQL driver for Kamailio.
Definition in file db_postgres/dbase.c.
| #define MAXCOLUMNS 512 |
maximum number of columns
Definition at line 68 of file db_postgres/dbase.c.
| void db_postgres_close | ( | db_con_t * | _h | ) |
Close database when the database is no longer needed.
| _h | closed connection, as returned from db_postgres_init |
Definition at line 102 of file db_postgres/dbase.c.
References db_do_close(), and db_postgres_free_connection().
Referenced by db_postgres_bind_api().
| int db_postgres_delete | ( | const db_con_t * | _h, | |
| const db_key_t * | _k, | |||
| const db_op_t * | _o, | |||
| const db_val_t * | _v, | |||
| const int | _n | |||
| ) |
Delete a row from the specified table.
| _h | structure representing database connection | |
| _k | key names | |
| _o | operators | |
| _v | values of the keys that must match | |
| _n | number of key=value pairs |
Definition at line 491 of file db_postgres/dbase.c.
References db_do_delete(), db_free_result(), db_postgres_store_result(), db_postgres_submit_query(), db_postgres_val2str(), LM_WARN, and NULL.
Referenced by db_postgres_bind_api().
Gets a partial result set, fetch rows from a result.
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.
| _con | database connection | |
| _res | result set | |
| nrows | number of fetches rows |
Definition at line 175 of file db_postgres/dbase.c.
References CON_CONNECTION, CON_RESULT, db_free_result(), db_free_rows(), db_new_result(), db_postgres_convert_rows(), db_postgres_get_columns(), LM_DBG, LM_ERR, NULL, RES_LAST_ROW, RES_NUM_ROWS, RES_ROW_N, and RES_ROWS.
Referenced by db_postgres_bind_api().
| static void db_postgres_free_query | ( | const db_con_t * | _con | ) | [static] |
Free database and any old query results.
| _con | database connection |
Definition at line 298 of file db_postgres/dbase.c.
References CON_RESULT, and LM_DBG.
Referenced by db_postgres_free_result(), db_postgres_store_result(), and db_postgres_submit_query().
Free the query and the result memory in the core.
| _con | database connection | |
| _r | result set |
Definition at line 315 of file db_postgres/dbase.c.
References db_free_result(), db_postgres_free_query(), and LM_ERR.
Referenced by db_postgres_bind_api().
Initialize database for future queries.
| _url | URL of the database that should be opened |
Definition at line 91 of file db_postgres/dbase.c.
References db_do_init(), and db_postgres_new_connection().
Referenced by db_postgres_bind_api().
| int db_postgres_insert | ( | const db_con_t * | _h, | |
| const db_key_t * | _k, | |||
| const db_val_t * | _v, | |||
| const int | _n | |||
| ) |
Insert a row into specified table.
| _h | structure representing database connection | |
| _k | key names | |
| _v | values of the keys | |
| _n | number of key=value pairs |
Definition at line 465 of file db_postgres/dbase.c.
References db_do_insert(), db_free_result(), db_postgres_store_result(), db_postgres_submit_query(), db_postgres_val2str(), LM_WARN, and NULL.
Referenced by db_postgres_bind_api().
| int db_postgres_query | ( | const db_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, | |||
| db_res_t ** | _r | |||
| ) |
Query table for specified rows.
| _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 |
Definition at line 343 of file db_postgres/dbase.c.
References db_do_query(), db_postgres_store_result(), db_postgres_submit_query(), and db_postgres_val2str().
Referenced by db_postgres_bind_api().
Execute a raw SQL query
| _h | database connection | |
| _s | raw query string | |
| _r | result set |
Definition at line 359 of file db_postgres/dbase.c.
References db_do_raw_query(), db_postgres_store_result(), and db_postgres_submit_query().
Referenced by db_postgres_bind_api().
Retrieve result set.
| _con | structure representing the database connection | |
| _r | pointer to a structure represending the result set |
Definition at line 379 of file db_postgres/dbase.c.
References CON_CONNECTION, CON_RESULT, db_free_result(), db_new_result(), db_postgres_convert_result(), db_postgres_free_query(), LM_DBG, LM_ERR, NULL, and pkg_free.
Referenced by db_postgres_delete(), db_postgres_insert(), db_postgres_query(), db_postgres_raw_query(), and db_postgres_update().
Submit_query, run a query.
| _con | database connection | |
| _s | query string |
Definition at line 114 of file db_postgres/dbase.c.
References CON_CONNECTION, db_postgres_free_query(), _str::len, LM_DBG, LM_ERR, and _str::s.
Referenced by db_postgres_delete(), db_postgres_insert(), db_postgres_query(), db_postgres_raw_query(), and db_postgres_update().
| int db_postgres_update | ( | const db_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 | |||
| ) |
Update some rows in the specified table
| _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 |
Definition at line 520 of file db_postgres/dbase.c.
References db_do_update(), db_free_result(), db_postgres_store_result(), db_postgres_submit_query(), db_postgres_val2str(), LM_WARN, and NULL.
Referenced by db_postgres_bind_api().
Store name of table that will be used by subsequent database functions
| _con | database connection | |
| _t | table name |
Definition at line 544 of file db_postgres/dbase.c.
References db_use_table().
Referenced by db_postgres_bind_api().
1.5.6