[sr-dev] git:alexh/master: modules_k/sqlops: Add BIGINT support to sql_query()

Alex Hermann alex at speakup.nl
Tue Mar 29 18:29:11 CEST 2011


Module: sip-router
Branch: alexh/master
Commit: e28127faaedc684b8702a5e8852414e2571e134d
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=e28127faaedc684b8702a5e8852414e2571e134d

Author: Alex Hermann <alex at speakup.nl>
Committer: Alex Hermann <alex at speakup.nl>
Date:   Mon Mar 14 14:48:28 2011 +0100

modules_k/sqlops: Add BIGINT support to sql_query()

As sqlresult has no support for longlongs, convert the BIGINT to a string value.

---

 modules_k/sqlops/sql_api.c |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/modules_k/sqlops/sql_api.c b/modules_k/sqlops/sql_api.c
index aca782d..9149f5c 100644
--- a/modules_k/sqlops/sql_api.c
+++ b/modules_k/sqlops/sql_api.c
@@ -32,6 +32,7 @@
 #include "../../dprint.h"
 #include "../../lib/kcore/hash_func.h"
 #include "../../ut.h"
+#include "../../lib/srdb1/db_ut.h"
 #ifdef WITH_XAVP
 #include "../../xavp.h"
 #endif
@@ -319,10 +320,22 @@ int sql_do_query(sql_con_t *con, str *query, sql_result_t *res)
 					res->vals[i][j].value.n
 						= (int)RES_ROWS(db_res)[i].values[j].val.bitmap_val;
 				break;
+				case DB1_BIGINT:
+					res->vals[i][j].flags = PV_VAL_STR;
+					res->vals[i][j].value.s.len = 21*sizeof(char);
+					res->vals[i][j].value.s.s
+						= (char*)pkg_malloc(res->vals[i][j].value.s.len);
+					if(res->vals[i][j].value.s.s==NULL)
+					{
+						LM_ERR("no more memory\n");
+						goto error;
+					}
+					db_longlong2str(RES_ROWS(db_res)[i].values[j].val.ll_val, res->vals[i][j].value.s.s, &res->vals[i][j].value.s.len);
+				break;
 				default:
 					res->vals[i][j].flags = PV_VAL_NULL;
 			}
-			if(res->vals[i][j].flags == PV_VAL_STR)
+			if(res->vals[i][j].flags == PV_VAL_STR && sv.s)
 			{
 				if(sv.len==0)
 				{




More information about the sr-dev mailing list