From 24341a06cd18ed32f4d818729122e154e7db520f Mon Sep 17 00:00:00 2001 From: ionutrazvanionita Date: Thu, 16 Apr 2015 20:05:00 +0300 Subject: [PATCH] fix extension loading; fix bigint separate case --- modules/db_sqlite/db_sqlite.c | 13 ++++++++++- modules/db_sqlite/my_con.c | 44 +---------------------------------- modules/db_sqlite/res.c | 3 ++- modules/db_sqlite/row.c | 6 +++++ 4 files changed, 21 insertions(+), 45 deletions(-) diff --git a/modules/db_sqlite/db_sqlite.c b/modules/db_sqlite/db_sqlite.c index 74f86720441..21d4ae628cd 100644 --- a/modules/db_sqlite/db_sqlite.c +++ b/modules/db_sqlite/db_sqlite.c @@ -41,6 +41,7 @@ int db_sqlite_alloc_limit=ALLOC_LIMIT; static int sqlite_mod_init(void); +static void sqlite_mod_destroy(void); static int db_sqlite_add_extension(modparam_t type, void *val); struct db_sqlite_extension_list *extension_list=0; @@ -78,7 +79,7 @@ struct module_exports exports = { 0, /* extra processes */ sqlite_mod_init, /* module initialization function */ 0, /* response function*/ - 0, /* destroy function */ + sqlite_mod_destroy, /* destroy function */ 0 /* per-child init function */ }; @@ -87,6 +88,16 @@ static int sqlite_mod_init(void) return 0; } +static void sqlite_mod_destroy(void) +{ + struct db_sqlite_extension_list *foo=NULL; + while (extension_list) { + foo=extension_list; + extension_list=extension_list->next; + pkg_free(foo); + } +} + int db_sqlite_bind_api(const str* mod, db_func_t *dbb) { diff --git a/modules/db_sqlite/my_con.c b/modules/db_sqlite/my_con.c index f04cde63a7a..e764d76640b 100644 --- a/modules/db_sqlite/my_con.c +++ b/modules/db_sqlite/my_con.c @@ -81,7 +81,7 @@ int db_sqlite_connect(struct my_con* ptr) errmsg); goto out_free; } - LM_INFO("Extension [%s] loaded!\n", iter->ldpath); + LM_DBG("Extension [%s] loaded!\n", iter->ldpath); } if (sqlite3_enable_load_extension(con, 0)) { @@ -141,40 +141,6 @@ struct my_con* db_sqlite_new_connection(const struct db_id* id) return 0; } -/* - * Actually free prep_stmt structure -*/ -static void db_sqlite_free_pq(struct prep_stmt *pq_ptr) -{ - struct my_stmt_ctx *ctx; - struct my_stmt_ctx *ctx2; - - if ( pq_ptr == NULL ) - return; - - for(ctx=pq_ptr->stmt_list ; ctx ; ) { - ctx2 = ctx; - ctx = ctx->next; - if (ctx2->stmt) - sqlite3_finalize(ctx2->stmt); - pkg_free(ctx2); - } - - - /* free in part and the struct */ - pkg_free(pq_ptr); -} - - -/* -** Free all allocated prep_stmt structures - */ -void db_sqlite_free_stmt_list(struct prep_stmt *head) -{ - if (head) - db_sqlite_free_pq(head); -} - /** * Close the connection and release memory */ @@ -184,15 +150,7 @@ void db_sqlite_free_connection(struct pool_con* con) struct my_con * _c; _c = (struct my_con*) con; - struct db_sqlite_extension_list *foo=NULL; - - while (extension_list) { - foo=extension_list; - extension_list=extension_list->next; - pkg_free(foo); - } - if (_c->ps_list) db_sqlite_free_stmt_list(_c->ps_list); if (_c->id) free_db_id(_c->id); if (_c->con) { sqlite3_close(_c->con); diff --git a/modules/db_sqlite/res.c b/modules/db_sqlite/res.c index a130ab75173..f1b0ae1b9ff 100644 --- a/modules/db_sqlite/res.c +++ b/modules/db_sqlite/res.c @@ -99,7 +99,6 @@ static db_type_t get_type_from_decltype(const char *decltype) case TINY: case SMAL: case MEDI: - case BIGI: case UNSI: case INT2: case INT8: @@ -107,6 +106,8 @@ static db_type_t get_type_from_decltype(const char *decltype) case BOOL: case DECI: return DB_INT; + case BIGI: + return DB_BIGINT; case CHAR: case VARC: case VARY: diff --git a/modules/db_sqlite/row.c b/modules/db_sqlite/row.c index b9ad01ab033..5f904c879ac 100644 --- a/modules/db_sqlite/row.c +++ b/modules/db_sqlite/row.c @@ -69,6 +69,12 @@ int db_sqlite_convert_row(const db_con_t* _h, db_res_t* _res, db_row_t* _r) case DB_INT: VAL_INT(_v) = sqlite3_column_int(CON_SQLITE_PS(_h), col); VAL_TYPE(_v) = DB_INT; + + break; + case DB_BIGINT: + VAL_BIGINT(_v) = sqlite3_column_int64(CON_SQLITE_PS(_h), col); + VAL_TYPE(_v) = DB_BIGINT; + break; case DB_DATETIME: VAL_INT(_v) = sqlite3_column_int(CON_SQLITE_PS(_h), col);