Lionel MARTIN wrote:

> Basically, this old code, for each request, was using Apache::DBI to
> retrieve DB connection
> handles, but was storing prepared statement handles in package variables.
> Then, during later calls, they assumed that if the current DB handle was
> the
> same as the previous one (i.e. same address), then, the stored statement
> handle could be reused wihout being prepared again.
> 
> So,according to what you are telling me, in rare situations, I think this
> could lead to bugs.

Yes, in rare (it's actually just a guess as to how rare this might be) cases it
could lead to bugs where the statement handle is not the correct object. But
it's probably much more common that other bugs will occur. See below:

> I had a quick look at Apache::DBI::connect code, and basically, what it
> does, when you ask for a DB connection handle (with the same attributes
> as previous calls), is first of all testing the current cached DB
> connection handle (via a ping call) and in case pinging fails, it calls
> DBI::connect to get a new connection. So, in case DBI::connect returns
> the same address for the DB handle (but with a new connection), using an
> already prepared statement would fail...

Exactly right. I think this would be the much more common type of bug to occur
when you try caching statement handles on their own. They don't exist
independent of their db connections which might change or go away.

-- 
Michael Peters
Developer
Plus Three, LP

Reply via email to