Module: sip-router Branch: master Commit: 16965c1cf58a3c740bd039878093679b07e2cc27 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=16965c1c...
Author: Alex Hermann alex@speakup.nl Committer: Alex Hermann alex@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) {