Skip to content

Commit

Permalink
acc: new parameter acc_extra_nullable
Browse files Browse the repository at this point in the history
- if set to 1, set NULL db values for varaibles that are $null
- GH #2531
  • Loading branch information
miconda committed Nov 3, 2020
1 parent e9eee1e commit 10ab5d4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/modules/acc/acc.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
2 changes: 2 additions & 0 deletions src/modules/acc/acc_mod.c
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 },
Expand Down

0 comments on commit 10ab5d4

Please sign in to comment.