These fixes were needed, but there's more to it than that. Since the file I was inserting wasn't as big as 64k, the loop didn't execute more than once and yet the data inserted using $dbh->quote was 2 bytes larger than it should've been. A hex dump shows the intruders are one single quote at the beginning and one at the end of the file.Ah yes. If those quotes aren't necessary for bytea, then that may be a bug. In theory, you should be able to call quote() with a second argument, SQL_BINARY, and it'll do the right thing, but that's not the way it works currently -- it assumes everything that needs escaping is ultimately a string. And that may be okay, technically. The DBI documentation says of quote():
Quote will probably not be able to deal with all pos-
sible input (such as binary data or data containing
newlines), and is not related in any way with escaping
or quoting shell meta-characters.
So quote() is not the thing to call for binary data, and you're better off using the approach Rudy suggested.
Which leads me to ask -- do we even need to bother to escape null characters and backslashes for PostgreSQL string fields? As I recall, those were originally added to support the bytea column type, but if escape() perhaps shouldn't be escaping binary data, do we need to escape anything other than single quotes?
Regards,
David
--
David Wheeler AIM: dwTheory
[EMAIL PROTECTED] ICQ: 15726394
http://david.wheeler.net/ Yahoo!: dew7e
Jabber: [EMAIL PROTECTED]
