Re: Initial ugly reverse-translator - Mailing list pgsql-general

From Tom Lane
Subject Re: Initial ugly reverse-translator
Date
Msg-id 9370.1208619856@sss.pgh.pa.us
Whole thread Raw
In response to Initial ugly reverse-translator  (Craig Ringer <craig@postnewspapers.com.au>)
Responses Re: Initial ugly reverse-translator  (Craig Ringer <craig@postnewspapers.com.au>)
List pgsql-general
Craig Ringer <craig@postnewspapers.com.au> writes:
> It's also useful for format-string based messages, but more thought is
> needed on how best to handle them. A LIKE query using the format-string
> message as the pattern (after converting the pattern syntax to SQL
> style) would be (a) slow and (b) very sensitive to formatting and other
> variation. I haven't spent any time on that bit yet, but if anybody has
> any ideas I'd be glad to hear them.

I don't really see the problem.  I assume from your reference to pg_trgm
that you're using trigram similarity as the prefilter for potential
matches, so a slow final LIKE match shouldn't be an issue really.
(And besides, speed doesn't seem like the be-all and end-all here.)

AFAICS you just need to translate %-string format escapes to %, quote
any other % or _, and away you go.

One thing that might be worth doing is avoiding spacing sensitivity,
since whitespace is frequently mangled in copy-and-paste.  Perhaps
strip all spaces from both strings before matching?

            regards, tom lane

pgsql-general by date:

Previous
From: Craig Ringer
Date:
Subject: Re: SQL error
Next
From: Craig Ringer
Date:
Subject: Re: Initial ugly reverse-translator