[Dbix-class] Accessing $dbh for blobs/large-objects
Matt S Trout
dbix-class at trout.me.uk
Tue May 9 15:33:16 CEST 2006
Toby Corkindale wrote:
> Following on from discussion on IRC:
> * Answer: No, D::C doesn't have blob filehandle-alike operations.
>
> A crash-course in BLOBs for the uninitiated:
> * A BLOB is a "binary large object".
> * BLOBs can be arbitrarily large - eg. many gigabytes - so you don't really
> want to rely on using the normal accessor method (ie. $foo->column), as that
> could potentially return more data than you have RAM.
> * Therefore, databases (well, oracle and postgresql) provide functions to
> access this data like filehandles - open/seek/read/write etc.
>
> So, it sounds like I'm volunteering myself to write a D::C::...::BLOB::FH
> interface at some point, unless there's a better way to do this.. ;)
No, I think that's an ideal way to do this. Better still it should be
possible to encapsulate the database specific stuff behind a method on
Storage so that we can paper over the cracks between databases (and use
something like IO::String to emulate it for databases that aren't smart
enough to provide an interface like this so you can be cross-database
but still get the performance advantage if you're using/if you migrate
to one that is smart enough).
This sort of code is somewhat irritating to build, but we went through
this silliness for last_insert_id (and somebody's kindly contributed
patches that handle finding the appropriate storage type for ODBC and
code for auto-inc for DB2/400 over ODBC to -current) and it's *so* worth
it in terms of the ease of use once it's done.
More information about the Dbix-class
mailing list