[CDBI] Class::DBI vs DBIx::Class

Tim Bunce Tim.Bunce at pobox.com
Wed Jan 18 11:36:30 GMT 2006


On Tue, Jan 17, 2006 at 08:12:48PM -0500, John Siracusa wrote:
> On 1/17/06 7:56 PM, Tim Bunce wrote:
> > Class::DBI and DBIx::Class (and others) should probably be passing 3
> > for the $if_active parameter. Set it and forget it.
> 
> I explored that a while ago (Rose::DB::Object passes 3 as you suggest), but
> it still doesn't account for the situation where the db supports server-side
> prepared statements and the schema changes between calls.  I encountered
> this in my benchmark suite, which creates and drops indexes as part of its
> execution.  Any statement that was prepare_cache()d server-side when the
> indexes existed will fail if execute()d after the indexes are dropped.

That's a database-specific issue. What database were you using?

(SQLite has this problem. The author has said that it could simply
re-prepare the execution plan for the statement but currently it just
returns an error. Very annoying, but not common with other databases.)

> So, unfortunately, there's no way to totally remove the need to manually
> control the use of prepare_cached().

Manual control is useful. Control of the default $if_active is also useful.

It's also possible to $dbh->{CachedKids} = {} to clear out the cached
statement handles explicitly if desired. (Such as when you're using
SQLite and know the schema has changed.)

Tim.




More information about the ClassDBI mailing list