Module: sip-router
Branch: master
Commit: d2ca9a17add030a16645ddf17488555d044214bb
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d2ca9a1…
Author: pd <peter.dunkley(a)crocodile-rcs.com>
Committer: pd <peter.dunkley(a)crocodile-rcs.com>
Date: Fri Oct 21 15:51:32 2011 +0100
modules_k/presence, modules_k/pua, modules_k/rls: Fixed issues discovered while testing
with PostgreSQL 9.0
- Some of the fields in the DB have not null constraints that result
in errors when using PostgreSQL but not MySQL.
---
modules_k/presence/subscribe.c | 17 ++++++++++-------
modules_k/pua/pua.c | 17 +++++++----------
modules_k/pua/pua_db.c | 9 +++++++++
modules_k/rls/resource_notify.c | 14 +++++++++-----
4 files changed, 35 insertions(+), 22 deletions(-)
diff --git a/modules_k/presence/subscribe.c b/modules_k/presence/subscribe.c
index 9db947e..3227cc7 100644
--- a/modules_k/presence/subscribe.c
+++ b/modules_k/presence/subscribe.c
@@ -2211,15 +2211,18 @@ int insert_db_subs_auth(subs_t* subs)
db_vals[n_query_cols].nul = 0;
db_vals[n_query_cols].val.int_val= (int)time(NULL);
n_query_cols++;
-
+
+ db_keys[n_query_cols] =&str_reason_col;
+ db_vals[n_query_cols].type = DB1_STR;
+ db_vals[n_query_cols].nul = 0;
if(subs->reason.s && subs->reason.len)
- {
- db_keys[n_query_cols] =&str_reason_col;
- db_vals[n_query_cols].type = DB1_STR;
- db_vals[n_query_cols].nul = 0;
db_vals[n_query_cols].val.str_val = subs->reason;
- n_query_cols++;
- }
+ else
+ {
+ db_vals[n_query_cols].val.str_val.s = "";
+ db_vals[n_query_cols].val.str_val.len = 0;
+ }
+ n_query_cols++;
if (pa_dbf.use_table(pa_db, &watchers_table) < 0)
{
diff --git a/modules_k/pua/pua.c b/modules_k/pua/pua.c
index e8ce882..eea341a 100644
--- a/modules_k/pua/pua.c
+++ b/modules_k/pua/pua.c
@@ -171,9 +171,6 @@ static int mod_init(void)
LM_DBG("db_url=%s/%d/%p\n", ZSW(db_url.s), db_url.len, db_url.s);
db_table.len = db_table.s ? strlen(db_table.s) : 0;
- if (dbmode==PUA_DB_ONLY)
- LM_ERR( "DB ONLY MODE ACTIVE\n" );
-
/* binding to database module */
if (db_bind_mod(&db_url, &pua_dbf))
{
@@ -780,7 +777,7 @@ static void db_update(unsigned int ticks,void *param)
db_key_t db_cols[5];
db_val_t q_vals[20], db_vals[5];
db_op_t db_ops[1] ;
- int n_query_cols= 0, n_query_update= 0, n_actual_query_cols= 0;
+ int n_query_cols= 0, n_query_update= 0;
int n_update_cols= 0;
int i;
int puri_col,pid_col,expires_col,flag_col,etag_col,tuple_col,event_col;
@@ -1101,14 +1098,14 @@ static void db_update(unsigned int ticks,void *param)
}
if(p->extra_headers)
- {
- n_actual_query_cols = n_query_cols;
q_vals[extra_headers_col].val.str_val = *(p->extra_headers);
- }
else
- n_actual_query_cols = n_query_cols - 1;
-
- if(pua_dbf.insert(pua_db, q_cols, q_vals,n_actual_query_cols )<0)
+ {
+ q_vals[extra_headers_col].val.str_val.s = "";
+ q_vals[extra_headers_col].val.str_val.len = 0;
+ }
+
+ if(pua_dbf.insert(pua_db, q_cols, q_vals,n_query_cols )<0)
{
LM_ERR("while inserting in db table pua\n");
if(!no_lock)
diff --git a/modules_k/pua/pua_db.c b/modules_k/pua/pua_db.c
index cd7ec4c..407eca7 100644
--- a/modules_k/pua/pua_db.c
+++ b/modules_k/pua/pua_db.c
@@ -1634,6 +1634,15 @@ void insert_puadb(ua_pres_t* pres)
db_vals[n_cols].val.str_val.len = pres->extra_headers->len;
n_cols++;
}
+ else
+ {
+ db_cols[n_cols] = &str_extra_headers_col;
+ db_vals[n_cols].type = DB1_STR;
+ db_vals[n_cols].nul = 0;
+ db_vals[n_cols].val.str_val.s = "";
+ db_vals[n_cols].val.str_val.len = 0;
+ n_cols++;
+ }
if(pua_db == NULL)
diff --git a/modules_k/rls/resource_notify.c b/modules_k/rls/resource_notify.c
index 8fd49f2..af64522 100644
--- a/modules_k/rls/resource_notify.c
+++ b/modules_k/rls/resource_notify.c
@@ -730,14 +730,18 @@ int rls_handle_notify(struct sip_msg* msg, char* c1, char* c2)
query_vals[n_query_cols].val.int_val= auth_flag;
n_query_cols++;
+ query_cols[n_query_cols]= &str_reason_col;
+ query_vals[n_query_cols].type = DB1_STR;
+ query_vals[n_query_cols].nul = 0;
if(reason)
- {
- query_cols[n_query_cols]= &str_reason_col;
- query_vals[n_query_cols].type = DB1_STR;
- query_vals[n_query_cols].nul = 0;
query_vals[n_query_cols].val.str_val= *reason;
- n_query_cols++;
+ else
+ {
+ query_vals[n_query_cols].val.str_val.s = "";
+ query_vals[n_query_cols].val.str_val.len = 0;
}
+ n_query_cols++;
+
query_cols[n_query_cols]= &str_content_type_col;
query_vals[n_query_cols].type = DB1_STR;
query_vals[n_query_cols].nul = 0;