[rt-devel] RT 1.3.48

Alex Pilosov alex at pilosoft.com
Mon Mar 5 09:47:31 EST 2001


On Mon, 5 Mar 2001, ivan wrote:

> If we try to get bytea columns out of the database normally; the encoding
> is incorrect and lossy;  nulls are *returned* as ASCII '\000' instead of a
> zero byte. (s/\\000/\x00/g; ?  No.  Then you can't store the string
> '\000'.) 
No. String \000 will be stored in database as \\000, and it does differ
from \000 which is a representation for a null character. 

Here's how you must correctly decode data after getting them out of Pg:

sub unquote($) {
  $_=shift;
  s/(^|[^\\])\\(\d\d\d)/chr(oct($2))/ge;
  s/\\\\/\\/;
  return $_;
}

"A fair jaw-cracker dwarf-language must be".

> I disagree.  Base64-encoding has a space penalty, and a *small*
> performance penalty to encode/decode the data.  Sucking data out of the
> database with individual get_byte() SQL transactions would come at a heavy
> performance cost. 
Make it generic. Write a db_quote/db_unquote which would transform binary
into db-specific form. For Pg, it should use the functions above to do it.
For other dbs, do base64.





More information about the Rt-devel mailing list