Email::Store::Attachment - my losing battle
Matt Lawrence
matt.lawrence at virgin.net
Wed Nov 29 17:47:20 GMT 2006
Jonathan Stowe wrote:
> On Wed, 2006-11-29 at 16:38 +0000, Chisel Wright wrote:
>
>> On Wed, Nov 29, 2006 at 11:12:42AM -0500, jesse wrote:
>>
>>> My pre-coffee guess is that it's not binding the column as a blob type
>>> before doing the insert. Postgres and DBD::Pg blob support used to suck
>>> rocks. (RT needed to Base64 binary attachments), but things have
>>> improved markedly in the past couple of years.
>>>
>> I knew MattL couldn't resist. I've got a bytea column for the payload
>> now, and a hacked Email::Store::Attachment that now has:
>>
>> my $payload = $_->bodyhandle->as_string;
>> $payload =~ s/([\x00-\x1f'\\\x7f-\xff])/'\\\\' . sprintf("%03o", ord($1))/eg;
>>
>> which does get successfully inserted.
>>
>
> Yeah. If you read the Postgres documentation about the bytea data type
> you will see that it does indeed say that certain non-printable
> characters need to be escaped like that. The same applies to other
> database systems.
>
>
Since writing that I've spotted this in the DBD::Pg docs:
$rv = $sth->bind_param($param_num, $bind_value,
{ pg_type => DBD::Pg::PG_BYTEA });
Which is a much cleaner way to do this. So I guess the next problem is
to get Class::DBI (or superclass) to handle that.
I can't see anything obvious in the Class::DBI docs to declare column types.
Matt
More information about the london.pm
mailing list