[sr-dev] git:master:5cdab87a: htable: accept both DB1_STR and DB1_STRING from database

Ovidiu Sas osas at voipembedded.com
Thu Mar 2 16:58:38 CET 2017


Module: kamailio
Branch: master
Commit: 5cdab87aa1093dd372fed624f0de33bd6c13e53a
URL: https://github.com/kamailio/kamailio/commit/5cdab87aa1093dd372fed624f0de33bd6c13e53a

Author: Ovidiu Sas <osas at voipembedded.com>
Committer: Ovidiu Sas <osas at 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/5cdab87aa1093dd372fed624f0de33bd6c13e53a.diff
Patch: https://github.com/kamailio/kamailio/commit/5cdab87aa1093dd372fed624f0de33bd6c13e53a.patch

---

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");




More information about the sr-dev mailing list