[OpenSIPS-Devel] Understanding MySQL prepared statements: no "SET @variable = XXX" query?

Iñaki Baz Castillo ibc at aliax.net
Tue Sep 8 10:04:15 CEST 2009


Hi, when OpenSIPS uses prepared statements it generates queries as follows:

------------------------------------
259 Connect     sip at localhost on opensips
259 Query       delete from rls_watchers where expires<1252395816
259 Prepare     [1] delete from active_watchers where expires<?
259 Execute     [1] delete from active_watchers where expires<1252395816
------------------------------------


I expected that the above would be in the following way:

---------------------------------
259 Connect     sip at localhost on opensips
259 Query       PREPARE ps_name FROM "delete from active_watchers
where expires<?"
259 Prepare     [1] delete from active_watchers where expires<?
259 Query       SET @var = 1252395816
259 Query       EXECUTE ps_name USING @var
259 Execute     [1] delete from active_watchers where expires<1252395816
----------------------------------


This is, I expected to see a "SET" query as MySQL documentation about
prepared statements explains:
  http://dev.mysql.com/tech-resources/articles/4.1/prepared-statements.html

Could I know how it works without using "SET" query? Thanks a lot.

-- 
Iñaki Baz Castillo
<ibc at aliax.net>



More information about the Devel mailing list