[Dbix-class] Found it: How do I set disable_sth_caching?
Tim Bunce
Tim.Bunce at pobox.com
Thu Nov 16 00:34:08 GMT 2006
On Wed, Nov 15, 2006 at 04:29:21PM +0100, Hermida, Leandro wrote:
>
> 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 });
Sadly prepare (and prepare_cached) aren't defined to accept handle
attributes in the '%attr parameter - an historical accident.
> The question is, does DBIx::Class allow you to set sth attributes??
DBD::Oracle needs a patch to be able to modify LongReadLen for an sth.
Meanwhile, when you change $dbh->{LongReadLen} you could iterate over
%{ $dbh->{CachedKids} } and delete any sth that might be affected.
Tim [skimming].
More information about the Dbix-class
mailing list