tomazos has asked for the wisdom of the Perl Monks concerning the following question:

I have a global hash %SESH localized and tied to an Apache::Session::MySQL using a global $dbh from Apache::DBI.

I've been using items from %SESH as bind values all over the place for $dbh->selectrow_array's, seemingly with no problem.

I just went to use a %SESH item as a bind value for a $dbh->do(insert), and it ended up as a NULL in the database even though I was sure that it had a valid value.

After an hour of fuddling I tried setting it to a my $value = $SESH{'value'} and then using $value in the insert rather than the $SESH{'value'} on the insert.

It worked. There must be some kind of conflict with the locking mechanism, given that %SESH is tied to the same database handle that I am doing the insert on.

My question is, is this expected behaviour? That it will work only as a bind value for selects and not inserts? And it will silently fail? Or should I be avoiding using %SESH as a bind value in any database activity?

-Andrew.


Andrew Tomazos  |  andrew@tomazos.com  |  www.tomazos.com
  • Comment on Weird Apache::Session::MySQL and DBI conflict

Replies are listed 'Best First'.
Re: Weird Apache::Session::MySQL and DBI conflict
by perrin (Chancellor) on Aug 08, 2005 at 13:46 UTC
    You shouldn't put an Apache::Session object in a global. If it fails to go out of scope, it will never release locks. However, the problem you're having does not sound like a locking issue. I suspect you just have some kind of minor bug in your code somewhere. If you try to reduce it to a small failing example, you might find the problem.