Module: kamailio
Branch: master
Commit: 5cdab87aa1093dd372fed624f0de33bd6c13e53a
URL:
https://github.com/kamailio/kamailio/commit/5cdab87aa1093dd372fed624f0de33b…
Author: Ovidiu Sas <osas(a)voipembedded.com>
Committer: Ovidiu Sas <osas(a)voipembedded.com>
Date: 2017-03-02T10:57:39-05:00
htable: accept both DB1_STR and DB1_STRING from database
---
Modified: src/modules/htable/ht_db.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5cdab87aa1093dd372fed624f0de33b…
Patch:
https://github.com/kamailio/kamailio/commit/5cdab87aa1093dd372fed624f0de33b…
---
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");