Re: Performance problems testing with Spamassassin 3.1.0

From: Matthew Schumacher <matt(dot)s(at)aptalaska(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Parker <parkerm(at)pobox(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Performance problems testing with Spamassassin 3.1.0
Date: 2005-08-01 17:08:48
Message-ID: 42EE5720.2020306@aptalaska.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Tom Lane wrote:
> Michael Parker <parkerm(at)pobox(dot)com> writes:
>
>>sub bytea_esc {
>> my ($str) = @_;
>> my $buf = "";
>> foreach my $char (split(//,$str)) {
>> if (ord($char) == 0) { $buf .= "\\\\000"; }
>> elsif (ord($char) == 39) { $buf .= "\\\\047"; }
>> elsif (ord($char) == 92) { $buf .= "\\\\134"; }
>> else { $buf .= $char; }
>> }
>> return $buf;
>>}
>
>
> Oh, I see the problem: you forgot to convert " to a backslash sequence.
>
> It would probably also be wise to convert anything >= 128 to a backslash
> sequence, so as to avoid any possible problems with multibyte character
> encodings. You wouldn't see this issue in a SQL_ASCII database, but I
> suspect it would rise up to bite you with other encoding settings.
>
> regards, tom lane

Here is some code that applies Toms Suggestions:

38c39,41
< if (ord($char) == 0) { $buf .= "\\\\000"; }
---
> if (ord($char) >= 128) { $buf .= "\\\\" . sprintf ("%lo",
ord($char)); }
> elsif (ord($char) == 0) { $buf .= "\\\\000"; }
> elsif (ord($char) == 34) { $buf .= "\\\\042"; }

But this begs the question, why not escape everything?

schu

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Alon Goldshuv 2005-08-01 19:48:35 Re: [PATCHES] COPY FROM performance improvements
Previous Message Tom Lane 2005-08-01 16:32:34 Re: [PATCHES] COPY FROM performance improvements