#include "db_key.h"
#include "db_val.h"


Go to the source code of this file.
Data Structures | |
| struct | db_res |
Defines | |
| #define | RES_COL_N(re) ((re)->col.n) |
| #define | RES_LAST_ROW(re) ((re)->last_row) |
| #define | RES_NAMES(re) ((re)->col.names) |
| #define | RES_NUM_ROWS(re) ((re)->res_rows) |
| #define | RES_ROW_N(re) ((re)->n) |
| #define | RES_ROWS(re) ((re)->rows) |
| #define | RES_TYPES(re) ((re)->col.types) |
Typedefs | |
| typedef struct db_res | db_res_t |
Functions | |
| int | db_allocate_columns (db_res_t *_r, const unsigned int cols) |
| int | db_allocate_rows (db_res_t *_res) |
| int | db_free_columns (db_res_t *_r) |
| int | db_free_result (db_res_t *_r) |
| int | db_free_rows (db_res_t *_r) |
| db_res_t * | db_new_result (void) |
Data structure that represents a result from a database query, it also provides some convenience macros and some memory management functions for result structures.
Definition in file db_res.h.
| #define RES_COL_N | ( | re | ) | ((re)->col.n) |
Return the number of columns
Definition at line 72 of file db_res.h.
Referenced by bdb_append_row(), bdb_convert_row(), bdb_get_columns(), convert_row(), db_allocate_row(), db_build_userbl_tree(), db_free_columns(), db_mysql_convert_row(), db_mysql_get_columns(), db_postgres_convert_rows(), db_postgres_get_columns(), db_query_avp(), db_reload_source(), db_unixodbc_convert_row(), db_unixodbc_get_columns(), dbt_convert_row(), dbt_get_columns(), get_columns(), and get_rows().
| #define RES_LAST_ROW | ( | re | ) | ((re)->last_row) |
Return the last row of the result
Definition at line 78 of file db_res.h.
Referenced by db_mysql_fetch_result(), db_postgres_convert_rows(), db_postgres_fetch_result(), and db_unixodbc_fetch_result().
| #define RES_NAMES | ( | re | ) | ((re)->col.names) |
Return the column names
Definition at line 68 of file db_res.h.
Referenced by bdb_append_row(), bdb_convert_row(), bdb_get_columns(), db_allocate_columns(), db_free_columns(), db_mysql_get_columns(), db_postgres_convert_rows(), db_postgres_get_columns(), db_unixodbc_get_columns(), dbt_get_columns(), and get_columns().
| #define RES_NUM_ROWS | ( | re | ) | ((re)->res_rows) |
Return the number of total result rows
Definition at line 80 of file db_res.h.
Referenced by bdb_get_columns(), db_mysql_fetch_result(), and db_postgres_fetch_result().
| #define RES_ROW_N | ( | re | ) | ((re)->n) |
Return the number of current result rows
Definition at line 76 of file db_res.h.
Referenced by _bdb_delete_cursor(), alias_db_lookup(), allow_trusted(), bdb_convert_row(), bdb_query(), check_rule(), check_username(), db_allocate_rows(), db_build_userbl_tree(), db_free_rows(), db_load_urecord(), db_mysql_convert_rows(), db_mysql_fetch_result(), db_postgres_convert_rows(), db_postgres_fetch_result(), db_postgres_get_columns(), db_query_avp(), db_reload_source(), db_table_version(), db_unixodbc_convert_rows(), db_unixodbc_fetch_result(), dbt_convert_rows(), does_uri_exist(), dp_load_db(), ds_load_db(), get_all_db_ucontacts(), get_ha1(), get_rows(), is_domain_local(), is_user_in(), load_carrier_map(), load_dialog_info_from_db(), load_domain_map(), load_re(), load_route_data_db(), load_user_carrier(), m_dump(), m_send_ontimer(), m_store(), match_res(), pdt_load_db(), preload_udomain(), reload_address_table(), reload_domain_table(), reload_gws_and_lcrs(), reload_trusted_table(), sd_lookup(), and xj_worker_process().
| #define RES_ROWS | ( | re | ) | ((re)->rows) |
Return the result rows
Definition at line 74 of file db_res.h.
Referenced by alias_db_lookup(), bdb_append_row(), bdb_convert_row(), bdb_query(), bdb_row_match(), check_rule(), db_allocate_rows(), db_build_userbl_tree(), db_free_rows(), db_load_urecord(), db_mysql_convert_rows(), db_mysql_fetch_result(), db_postgres_convert_rows(), db_postgres_fetch_result(), db_query_avp(), db_reload_source(), db_table_version(), db_unixodbc_convert_rows(), db_unixodbc_fetch_result(), dbt_convert_rows(), dp_load_db(), ds_load_db(), get_all_db_ucontacts(), get_ha1(), get_rows(), load_dialog_info_from_db(), load_route_data_db(), load_user_carrier(), m_dump(), m_send_ontimer(), match_res(), pdt_load_db(), preload_udomain(), reload_address_table(), reload_domain_table(), reload_gws_and_lcrs(), reload_trusted_table(), sd_lookup(), and xj_worker_process().
| #define RES_TYPES | ( | re | ) | ((re)->col.types) |
Return the column types
Definition at line 70 of file db_res.h.
Referenced by bdb_append_row(), bdb_convert_row(), bdb_get_columns(), convert_row(), db_allocate_columns(), db_free_columns(), db_mysql_convert_row(), db_mysql_get_columns(), db_postgres_convert_row(), db_postgres_get_columns(), db_unixodbc_convert_row(), db_unixodbc_get_columns(), dbt_convert_row(), dbt_get_columns(), and get_columns().
This type represents a result returned by db_query function (see below). The result can consist of zero or more rows (see db_row_t description).
Note: A variable of type db_res_t returned by db_query function uses dynamicaly allocated memory, don't forget to call db_free_result if you don't need the variable anymore. You will encounter memory leaks if you fail to do this!
In addition to zero or more rows, each db_res_t object contains also an array of db_key_t objects. The objects represent keys (names of columns). *
| int db_allocate_columns | ( | db_res_t * | _r, | |
| const unsigned int | cols | |||
| ) | [inline] |
Allocate storage for column names and type in existing result structure. If no more memory is available for the allocation of the types then the already allocated memory for the names is freed.
| _r | filled result set | |
| cols | number of columns |
Definition at line 144 of file db_res.c.
References LM_DBG, LM_ERR, pkg_free, pkg_malloc, RES_NAMES, and RES_TYPES.
Referenced by bdb_get_columns(), db_mysql_get_columns(), db_postgres_get_columns(), db_unixodbc_get_columns(), dbt_get_columns(), and get_columns().
| int db_allocate_rows | ( | db_res_t * | _res | ) | [inline] |
Allocate memory for rows.
| _res | result set |
Definition at line 174 of file db_res.c.
References len, LM_DBG, LM_ERR, pkg_malloc, RES_ROW_N, and RES_ROWS.
Referenced by db_mysql_convert_rows(), db_postgres_convert_rows(), db_unixodbc_convert_rows(), and dbt_convert_rows().
| int db_free_columns | ( | db_res_t * | _r | ) | [inline] |
Release memory used by columns. This methods assumes that the string values holding the column names are in memory allocated from the database driver, and thus must be not freed here.
| _r | the result that should be released |
Definition at line 71 of file db_res.c.
References LM_DBG, LM_ERR, NULL, pkg_free, RES_COL_N, RES_NAMES, and RES_TYPES.
Referenced by bdb_get_columns(), db_free_result(), db_mysql_convert_result(), db_mysql_get_columns(), db_oracle_store_result(), db_postgres_convert_result(), db_postgres_get_columns(), db_unixodbc_convert_result(), db_unixodbc_fetch_result(), db_unixodbc_get_columns(), dbt_convert_result(), dbt_get_columns(), and get_columns().
| int db_free_result | ( | db_res_t * | _r | ) | [inline] |
Release memory used by a result structure.
Definition at line 124 of file db_res.c.
References db_free_columns(), db_free_rows(), LM_DBG, LM_ERR, NULL, and pkg_free.
Referenced by _bdb_delete_cursor(), bdb_close(), bdb_free_query(), bdb_query(), db_mysql_fetch_result(), db_mysql_free_result(), db_mysql_store_result(), db_oracle_free_result(), db_postgres_delete(), db_postgres_fetch_result(), db_postgres_free_result(), db_postgres_insert(), db_postgres_store_result(), db_postgres_update(), db_unixodbc_fetch_result(), db_unixodbc_free_result(), and dbt_free_result().
| int db_free_rows | ( | db_res_t * | _r | ) | [inline] |
Release memory used by rows in a result structure.
| _r | the result that should be released |
Definition at line 44 of file db_res.c.
References db_free_row(), LM_DBG, LM_ERR, NULL, pkg_free, RES_ROW_N, and RES_ROWS.
Referenced by _bdb_delete_cursor(), db_free_result(), db_mysql_convert_rows(), db_mysql_fetch_result(), db_postgres_convert_rows(), db_postgres_fetch_result(), db_unixodbc_convert_rows(), db_unixodbc_fetch_result(), dbt_convert_rows(), and get_rows().
| db_res_t* db_new_result | ( | void | ) | [inline] |
Create a new result structure and initialize it.
Definition at line 107 of file db_res.c.
References LM_DBG, LM_ERR, NULL, and pkg_malloc.
Referenced by _bdb_delete_cursor(), bdb_query(), db_mysql_fetch_result(), db_mysql_store_result(), db_oracle_store_result(), db_postgres_fetch_result(), db_postgres_store_result(), db_unixodbc_fetch_result(), db_unixodbc_store_result(), and dbt_get_result().
1.5.6