Module: kamailio Branch: 5.0 Commit: ba743dc62145d6d9e584e9f4ca150c8e334bdda2 URL: https://github.com/kamailio/kamailio/commit/ba743dc62145d6d9e584e9f4ca150c8e...
Author: Ovidiu Sas osas@voipembedded.com Committer: Ovidiu Sas osas@voipembedded.com Date: 2017-03-02T10:59:22-05:00
htable: accept both DB1_STR and DB1_STRING from database
(cherry picked from commit 5cdab87aa1093dd372fed624f0de33bd6c13e53a)
---
Modified: src/modules/htable/ht_db.c
---
Diff: https://github.com/kamailio/kamailio/commit/ba743dc62145d6d9e584e9f4ca150c8e... Patch: https://github.com/kamailio/kamailio/commit/ba743dc62145d6d9e584e9f4ca150c8e...
---
diff --git a/src/modules/htable/ht_db.c b/src/modules/htable/ht_db.c index fd692ca..6ce3fc9 100644 --- a/src/modules/htable/ht_db.c +++ b/src/modules/htable/ht_db.c @@ -271,19 +271,29 @@ int ht_db_load_table(ht_t *ht, str *dbtable, int mode) goto error; }
- if(RES_ROWS(db_res)[i].values[0].type!=DB1_STRING) { + switch(RES_ROWS(db_res)[i].values[0].type) { + case DB1_STR: + kname.s = (RES_ROWS(db_res)[i].values[0].val.str_val.s); + if(kname.s==NULL) { + LM_ERR("null key in row %d\n", i); + goto error; + } + kname.len = (RES_ROWS(db_res)[i].values[0].val.str_val.len); + break; + case DB1_STRING: + kname.s = (char*)(RES_ROWS(db_res)[i].values[0].val.string_val); + if(kname.s==NULL) { + LM_ERR("null key in row %d\n", i); + goto error; + } + kname.len = strlen(kname.s); + break; + default: LM_ERR("key type must be string (type=%d)\n", RES_ROWS(db_res)[i].values[0].type); goto error; }
- kname.s = (char*)(RES_ROWS(db_res)[i].values[0].val.string_val); - if(kname.s==NULL) { - LM_ERR("null key in row %d\n", i); - goto error; - } - kname.len = strlen(kname.s); - if(ht->ncols>0) { if(ht_pack_values(ht, db_res, i, ncols, &val.s)<0) { LM_ERR("Error packing values\n");