Re: [GENERAL] escaping wildcard chars

From: "Dan Wilson" <dan_wilson(at)geocities(dot)com>
To: "pgsql general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: [GENERAL] escaping wildcard chars
Date: 1999-07-27 04:42:01
Message-ID: 00b901bed7ea$69bf0cc0$9e05fea9@dwilson
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> Yes. Use '\\_%' instead. You see, a backslash is interpreted immediately
as
> "take the next char literally". This passes the underscore literally to
> LIKE. Which is the same as '_%'. If you put a double backslash, the first
> backslash takes the second one literally, thus passing '\_%' to LIKE. And
> then LIKE knows that it should treat the underscore as non-special.

I tried this and it didn't work either. I eventually got carried away and
did '\\\_%' and it worked. What a pain!

> I really hate those backslashes. They are blatantly incompatible with
SQL92
> and will cause standard SQL to fail on Postgres, (and of course, Postgres
> code to fail on other databases). There should be a setting, either in the
> backend or in a SET command, such as "BACKSLASH_BEHAVIOR", which will be
> either "literal" or "escape". It can default to the current behavior
> (namely "escape") so that current code won't fail, but will enable people
> to write sane standard code.

I totally agree here. There should be some way to turn it off so that those
who are starting out can write standard stuff.

-Dan

Browse pgsql-general by date

  From Date Subject
Next Message Dieter Roessing 1999-07-27 06:47:41 Problem Compiling C-functions
Previous Message Dan Wilson 1999-07-27 04:27:23 Re: [GENERAL] PHP and Postgresql 6.5.1