Re: Initial ugly reverse-translator

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
Cc: PgSQL General ML <pgsql-general(at)postgresql(dot)org>
Subject: Re: Initial ugly reverse-translator
Date: 2008-04-19 15:44:16
Message-ID: 9370.1208619856@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Craig Ringer <craig(at)postnewspapers(dot)com(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Craig Ringer 2008-04-19 16:04:22 Re: Initial ugly reverse-translator
Previous Message Craig Ringer 2008-04-19 15:17:05 Re: SQL error