You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Graham Leggett <mi...@sharp.fm> on 2008/04/05 01:56:31 UTC

Problems with mod_dbd and prepared statements

Hi all,

I am trying to debug a problem with mod_dbd, and the creation of 
prepared statements.

If I run the following three steps, the first adds the prepared 
statement, the second obtains a handle to the dbd functions, and the 
third statement retrieves the prepared statement.

For some reason, the third statement returns NULL, which doesn't make 
sense, as the prepared statement has just been added.

Are there any special requirements necessary before mod_dbd will 
successfully register a prepared statement?

     session_dbd_prepare_fn(r->server, query, label);

     dbd = session_dbd_acquire_fn(r);

     statement = apr_hash_get(dbd->prepared, label, APR_HASH_KEY_STRING);

Nothing is logged to the error log to suggest there is a problem.

Regards,
Graham
--

Re: Problems with mod_dbd and prepared statements

Posted by Chris Darroch <ch...@pearsoncmg.com>.
Graham Leggett wrote:

> Is that prior to or up to? If it's up to, it would help me a lot...

   So long as you ensure you run before mod_dbd's hook in the post_config
phase, you should be able to register statements to be prepared (I think).
Once mod_dbd's post_config hook runs, it has an internal set of hashes
that describe the query label-to-SQL mappings.  So if you put mod_dbd
in aszSucc when registering your post_config hook, I would think that
should work.

   Then, whenever a DB connection is opened (some will be opened
at child_init time, if DBDMin > 0, and others later as demand dictates)
these SQL statements will be prepared against the DB connection.
It's worth noting that they're not prepared during the config phases,
since no DB connections yet exist; connections are only made from within
child processes.

Chris.

-- 
GPG Key ID: 366A375B
GPG Key Fingerprint: 485E 5041 17E1 E2BB C263  E4DE C8E3 FA36 366A 375B


Re: Problems with mod_dbd and prepared statements

Posted by Graham Leggett <mi...@sharp.fm>.
Chris Darroch wrote:

>   You have to register statements to be prepared prior to the
> post_config phase ... that's the main one I can think of.  Does
> that help?

Is that prior to or up to? If it's up to, it would help me a lot...

Regards,
Graham
--

Re: Problems with mod_dbd and prepared statements

Posted by Chris Darroch <ch...@pearsoncmg.com>.
Graham Leggett wrote:

> Are there any special requirements necessary before mod_dbd will 
> successfully register a prepared statement?

   You have to register statements to be prepared prior to the
post_config phase ... that's the main one I can think of.  Does
that help?

Chris.

-- 
GPG Key ID: 366A375B
GPG Key Fingerprint: 485E 5041 17E1 E2BB C263  E4DE C8E3 FA36 366A 375B