Module: kamailio
Branch: master
Commit: c66bb0b5594def785edab0fe9a8101f1c126fdb1
URL:
https://github.com/kamailio/kamailio/commit/c66bb0b5594def785edab0fe9a8101f…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2018-09-28T15:22:03+02:00
db_redis: handle DB1_UINT and DB1_UBIGINT DB APIv1 types
---
Modified: src/modules/db_redis/redis_dbase.c
Modified: src/modules/db_redis/redis_table.c
---
Diff:
https://github.com/kamailio/kamailio/commit/c66bb0b5594def785edab0fe9a8101f…
Patch:
https://github.com/kamailio/kamailio/commit/c66bb0b5594def785edab0fe9a8101f…
---
diff --git a/src/modules/db_redis/redis_dbase.c b/src/modules/db_redis/redis_dbase.c
index 46bf38b7ee..c4cd696ead 100644
--- a/src/modules/db_redis/redis_dbase.c
+++ b/src/modules/db_redis/redis_dbase.c
@@ -96,6 +96,13 @@ static int db_redis_val2str(const db_val_t *v, str *_str) {
snprintf(_str->s, _str->len, "%d", VAL_INT(v));
_str->len = strlen(_str->s);
break;
+ case DB1_UINT:
+ LM_DBG("converting uint value %u to str\n", VAL_UINT(v));
+ _str->s = (char*)pkg_malloc(_str->len);
+ if (!_str->s) goto memerr;
+ snprintf(_str->s, _str->len, "%u", VAL_UINT(v));
+ _str->len = strlen(_str->s);
+ break;
case DB1_BIGINT:
LM_DBG("converting bigint value %lld to str\n", VAL_BIGINT(v));
_str->s = (char*)pkg_malloc(_str->len);
@@ -103,6 +110,13 @@ static int db_redis_val2str(const db_val_t *v, str *_str) {
snprintf(_str->s, _str->len, "%lld", VAL_BIGINT(v));
_str->len = strlen(_str->s);
break;
+ case DB1_UBIGINT:
+ LM_DBG("converting ubigint value %llu to str\n", VAL_UBIGINT(v));
+ _str->s = (char*)pkg_malloc(_str->len);
+ if (!_str->s) goto memerr;
+ snprintf(_str->s, _str->len, "%llu", VAL_UBIGINT(v));
+ _str->len = strlen(_str->s);
+ break;
case DB1_STRING:
s = VAL_STRING(v);
_str->len = strlen(s);
diff --git a/src/modules/db_redis/redis_table.c b/src/modules/db_redis/redis_table.c
index fb7c06cac0..e9db44458e 100644
--- a/src/modules/db_redis/redis_table.c
+++ b/src/modules/db_redis/redis_table.c
@@ -448,6 +448,15 @@ static struct str_hash_entry* db_redis_create_column(str *col, str
*type) {
case 'I':
e->u.n = DB1_INT;
break;
+ case 'u':
+ case 'U':
+ /* uint and ubigint */
+ if(type->len>1 && (type->s[1]=='b' ||
type->s[1]=='B')) {
+ e->u.n = DB1_UBIGINT;
+ } else {
+ e->u.n = DB1_UINT;
+ }
+ break;
case 't':
case 'T':
e->u.n = DB1_DATETIME;
@@ -458,7 +467,12 @@ static struct str_hash_entry* db_redis_create_column(str *col, str
*type) {
break;
case 'b':
case 'B':
- e->u.n = DB1_BLOB;
+ /* blob and bigint */
+ if(type->len>1 && (type->s[1]=='i' ||
type->s[1]=='I')) {
+ e->u.n = DB1_BIGINT;
+ } else {
+ e->u.n = DB1_BLOB;
+ }
break;
default:
LM_ERR("Invalid schema column type '%.*s', expecting one of
string, int, timestamp, double, blob\n",