Skip to content

Commit

Permalink
fix extension loading; fix bigint separate case
Browse files Browse the repository at this point in the history
  • Loading branch information
ionutrazvanionita committed Apr 16, 2015
1 parent 7366daa commit 24341a0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 45 deletions.
13 changes: 12 additions & 1 deletion modules/db_sqlite/db_sqlite.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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 */
};

Expand All @@ -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)
{
Expand Down
44 changes: 1 addition & 43 deletions modules/db_sqlite/my_con.c
Expand Up @@ -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)) {
Expand Down Expand Up @@ -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
*/
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion modules/db_sqlite/res.c
Expand Up @@ -99,14 +99,15 @@ 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:
case NUME:
case BOOL:
case DECI:
return DB_INT;
case BIGI:
return DB_BIGINT;
case CHAR:
case VARC:
case VARY:
Expand Down
6 changes: 6 additions & 0 deletions modules/db_sqlite/row.c
Expand Up @@ -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);
Expand Down

0 comments on commit 24341a0

Please sign in to comment.