[OpenSIPS-Devel] [ opensips-Bugs-2557032 ] Bug: opensipsctl script with Postgres

SourceForge.net noreply at sourceforge.net
Wed Mar 18 16:45:04 CET 2009


Bugs item #2557032, was opened at 2009-02-02 15:56
Message generated for change (Settings changed) made by bogdan_iancu
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=2557032&group_id=232389

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: tools
Group: 1.4.x
Status: Open
Resolution: Accepted
Priority: 5
Private: No
Submitted By: David Roberge (xittel)
>Assigned to: Iulia Bublea (iulia_bublea)
Summary: Bug: opensipsctl script with Postgres

Initial Comment:
Hi, 
 
I am using OpenSIPS 1.4.4 with Postgres 8.3 and I am running into two problems with the opensipsctl script. 
 
1. It seems that Postgres does not support the CONCAT SQL function. I had to remove all CONCAT function calls from the script and replace them with || operators in order to use the script properly. 
 
2. I also encountered a problem when adding subscribers via the opensipsctl script. Before adding new subscriber, the script checks that no alias with the same name as the new subscriber exists in the DB. However, the script seems to be written with MySql in mind. The check_db_alias() function does not process the output of psql properly and thinks that an alias already exists. 
 
The script thinks that the last line of the output of psql contains the number of returned records. It thus set the $CNT variable to the value of the last line of the output. However, the last line is a blank line. Since the $CNT variable is set to blank, it is therefore != 0. The $ALIAS_DB_EXISTS variable is set to 1 and the script thinks that an alias exists even thought it does not. This prevents the addition of new subscribers into the DB. 
 
 
See below for the function code. 
 
---------------------------------------------- 
check_db_alias() { 
require_dbengine 
 
ALIAS_DB_EXISTS=0 
 
QUERY="select count(*) from $DA_TABLE where $DA_ALIAS_USER_COLUMN='$1' \ 
and $DA_ALIAS_DOMAIN_COLUMN='$2';" 
CNT=`$DBROCMD "$QUERY" | $EGREP -v ERROR | $LAST_LINE` 
mdbg "check_db_alias: alias counter=$CNT" 
if [ "$CNT" = "0" ] ; then 
ALIAS_DB_EXISTS=0 
else 
#ALIAS_DB_EXISTS=1 
ALIAS_DB_EXISTS=0 
fi 
} 
---------------------------------------------- 
 
 
and the actual output of the PSQL query: 
 
---------------------------------------------- 
count 
------- 
0 
(1 row) 
 
---------------------------------------------- 
 
I patched the script to force the $ALIAS_DB_EXISTS to 0 but the alias check is no more performed. 
 
Thanks. 
 
David


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=2557032&group_id=232389



More information about the Devel mailing list