in reply to Perl and Postgresql: Invalid byte sequence for encoding "UTF8"

This issue was recently discussed in London-pm mailing list. See the thread here (give special attention to Matt Lawrence's last posts):

http://london.pm.org/pipermail/london.pm/Week-of-Mon-20061127/thread.html#5758

It had to do with some weirdness of the bytea data type and the fine/fast solution was to use:

$sth->bind_param($param_num, $bind_value, { pg_type => DBD::Pg::PG_BYTEA });
where $sth is a DBI statement over a DBD::Pg connection, $param_num is the position of your placeholder in the SQL statement, $bind_value is the content that is making DBD::Pg unhappy. There is more info at the mentioned thread: escaping the data, handling BLOBs in Postgresql, dealing with Class::DBI, etc.