[OpenSIPS-Devel] [ opensips-Bugs-2654980 ] Unable to use alias_db_lookup() with two different tables

SourceForge.net noreply at sourceforge.net
Tue Mar 3 14:33:27 CET 2009


Bugs item #2654980, was opened at 2009-03-02 19:21
Message generated for change (Comment added) made by bogdan_iancu
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=1086410&aid=2654980&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: modules
Group: trunk
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Thomas Gelf (thomas_gelf)
Assigned to: Bogdan-Andrei Iancu (bogdan_iancu)
Summary: Unable to use alias_db_lookup() with two different tables

Initial Comment:
Writing a script like

> alias_db_lookup('dbaliases');
> alias_db_lookup('othertable');

doesn't work, OpenSIPS is reusing the very same prepared statement and executes all queries on the first DB ('dbaliases') in this case.

Summary of todays tests on IRC:

> I have MySQL query log enabled, there is only the first query
> (the first alias_db_lookup) arriving. If I comment out the first
> one, the second one is working correctly. If I switch their order
> in the script, the other one succeeds. So I think we can exclude
> script, param and MySQL errors.
>
> I did:
> > if (alias_db_lookup('tbl1')) { xlog(...) } else { xlog(...) }
> > if (alias_db_lookup('tbl2')) { xlog(...) } else { xlog(...) }
>
> xlog proves that both alias_db_lookup commands are executed each
> time.
>
> It seems that it is running both queries, but on the second call
> it is using the same table name as on the first one.  Could this
> be related to the prepared statements? Yeah, it IS running one
> Prepare and two Executes. And the second Execute get's as param
> the (already aliased) ruri, but table remains the same. If it
> doesn't find the alias it is just running the same query twice.

> Other way to prove it: just call alias_db_lookup() twice - if you
> write a wrong table name in the first call, you get:
>
> > ERROR:db_mysql:get_new_stmt_ctx: failed while mysql_stmt_prepare
>
> If you use a wrong table name with the second call
>
> > alias_db_lookup('no_such_table'))
>
> nothing happens.

Best regards,
Thomas Gelf


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

>Comment By: Bogdan-Andrei Iancu (bogdan_iancu)
Date: 2009-03-03 15:33

Message:
Fixes, it was a copy'n'paste error.

Thanks for report,
Bogdan

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

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



More information about the Devel mailing list