[Dbix-class] Found it: How do I set disable_sth_caching?

Hermida, Leandro Leandro.Hermida at fmi.ch
Wed Nov 15 15:29:21 GMT 2006


Hello,

> As Matt said, we'd be really curious as to why you need sth caching
disabled.  I've got one known use-case for disable_sth_caching that
involves PostgreSQL table inheritance, but I haven't heard of any others
that are really good.

I have a use case where I might need to turn off sth caching for
DBD::Oracle.  When selecting BLOB, CLOB, LONG, etc data from an Oracle
table you need to set the DBI attribute LongReadLen to be at least the
size of the LOB you are going to select otherwise it will truncate it or
raise and error (depending how you set LongTruncOk).  The LongReadLen
DBI attribute exists at the dbh and sth levels.  If you are using
prepare_cached then you must set the sth level LongReadLen attribute
because changing the dbh LongReadLen and then calling prepare_cached
again with the same SQL will still give you the old cached sth.

For example:

$dbh->{LongReadLen} = 10000;
$sth = $dbh->prepare_cached('SELECT blob_col FROM table');
...
$dbh->{LongReadLen} = 11000;
$sth = $dbh->prepare_cached('SELECT blob_col FROM table');

The second $sth is still the cached sth from before, not a new one and
therefore has a LongReadLen of 10000, not 11000.  One would need to:

$sth = $dbh->prepare_cached('SELECT blob_col FROM table', { LongReadLen
=> 10000 });
...
$sth = $dbh->prepare_cached('SELECT blob_col FROM table', { LongReadLen
=> 11000 });

The question is, does DBIx::Class allow you to set sth attributes??

Sincerely,

Leandro Hermida





More information about the Dbix-class mailing list