Module: kamailio
Branch: master
Commit: 10ab5d4343a102a504d5fba09003e43fd4f6027a
URL:
https://github.com/kamailio/kamailio/commit/10ab5d4343a102a504d5fba09003e43…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2020-11-03T14:55:45+01:00
acc: new parameter acc_extra_nullable
- if set to 1, set NULL db values for varaibles that are $null
- GH #2531
---
Modified: src/modules/acc/acc.c
Modified: src/modules/acc/acc_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/10ab5d4343a102a504d5fba09003e43…
Patch:
https://github.com/kamailio/kamailio/commit/10ab5d4343a102a504d5fba09003e43…
---
diff --git a/src/modules/acc/acc.c b/src/modules/acc/acc.c
index 500629cf73..81e27eb2c5 100644
--- a/src/modules/acc/acc.c
+++ b/src/modules/acc/acc.c
@@ -52,6 +52,7 @@ extern struct acc_extra *log_extra;
extern struct acc_extra *leg_info;
extern struct acc_enviroment acc_env;
extern char *acc_time_format;
+extern int acc_extra_nullable;
static db_func_t acc_dbf;
static db1_con_t* db_handle=0;
@@ -458,8 +459,13 @@ int acc_db_request( struct sip_msg *rq)
o = extra2strar( db_extra, rq, val_arr+m, int_arr+m, type_arr+m);
m += o;
- for( i++ ; i<m; i++)
- VAL_STR(db_vals+i) = val_arr[i];
+ for( i++ ; i<m; i++) {
+ if (acc_extra_nullable == 1 && type_arr[i] == TYPE_NULL) {
+ VAL_NULL(db_vals + i) = 1;
+ } else {
+ VAL_STR(db_vals+i) = val_arr[i];
+ }
+ }
if (acc_dbf.use_table(db_handle, &acc_env.text/*table*/) < 0) {
LM_ERR("error in use_table\n");
@@ -488,8 +494,13 @@ int acc_db_request( struct sip_msg *rq)
} else {
n = legs2strar(leg_info,rq,val_arr+m,int_arr+m,type_arr+m,1);
do {
- for (i=m; i<m+n; i++)
- VAL_STR(db_vals+i)=val_arr[i];
+ for (i=m; i<m+n; i++) {
+ if (acc_extra_nullable == 1 && type_arr[i] == TYPE_NULL) {
+ VAL_NULL(db_vals + i) = 1;
+ } else {
+ VAL_STR(db_vals+i)=val_arr[i];
+ }
+ }
if(acc_db_insert_mode==1 && acc_dbf.insert_delayed!=NULL) {
if(acc_dbf.insert_delayed(db_handle,db_keys,db_vals,m+n)<0) {
LM_ERR("failed to insert delayed into database\n");
diff --git a/src/modules/acc/acc_mod.c b/src/modules/acc/acc_mod.c
index 27feb847db..1ea8370bd4 100644
--- a/src/modules/acc/acc_mod.c
+++ b/src/modules/acc/acc_mod.c
@@ -83,6 +83,7 @@ int acc_prepare_always = 0; /* prepare the request always for later acc
*/
int acc_prepare_flag = -1; /*!< should the request be prepared for later acc */
char *acc_time_format = "%Y-%m-%d %H:%M:%S";
int reason_from_hf = 0; /*!< assign reason from reason hf if present */
+int acc_extra_nullable = 0;
/* ----- time mode variables ------- */
/*! \name AccTimeModeVariables Time Mode Variables */
@@ -199,6 +200,7 @@ static param_export_t params[] = {
{"acc_prepare_flag", INT_PARAM, &acc_prepare_flag },
{"acc_prepare_always", INT_PARAM, &acc_prepare_always },
{"reason_from_hf", INT_PARAM, &reason_from_hf },
+ {"acc_extra_nullable", INT_PARAM, &acc_extra_nullable },
/* syslog specific */
{"log_flag", INT_PARAM, &log_flag },
{"log_missed_flag", INT_PARAM, &log_missed_flag },