From zalman@netcom.com Tue Mar 16 18:01:18 1999
Received: from renoir.op.net (root@renoir.op.net [209.152.193.4])
	by candle.pha.pa.us (8.9.0/8.9.0) with ESMTP id SAA24313
	for <maillist@candle.pha.pa.us>; Tue, 16 Mar 1999 18:01:17 -0500 (EST)
Received: from netcom15.netcom.com (zalman@netcom15.netcom.com [192.100.81.128]) by renoir.op.net (o1/$Revision: 1.1 $) with ESMTP id RAA15235 for <maillist@candle.pha.pa.us>; Tue, 16 Mar 1999 17:56:56 -0500 (EST)
Received: (from zalman@localhost)
	by netcom15.netcom.com (8.8.5-r-beta/8.8.5/(NETCOM v1.02)) id OAA28174;
	Tue, 16 Mar 1999 14:55:33 -0800 (PST)
From: Zalman Stern <zalman@netcom.com>
Message-Id: <199903162255.OAA28174@netcom15.netcom.com>
Subject: Re: [SQL] How match percent sign in SELECT using LIKE?
To: maillist@candle.pha.pa.us (Bruce Momjian)
Date: Tue, 16 Mar 1999 14:55:33 -0800 (PST)
Cc: zalman@netcom.com, herouth@oumail.openu.ac.il, pgsql-sql@postgreSQL.org
In-Reply-To: <199903162226.RAA20904@candle.pha.pa.us> from "Bruce Momjian" at Mar 16, 99 05:26:09 pm
X-Mailer: ELM [version 2.4 PL25]
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Status: ROr

Bruce Momjian wrote:
> That is also an excellent idea.  Just convert their escape to \ inside
> the parser.  Of course, they still have to use \\ to get a \, as in any
> string.  Great idea.

You can even make it fully compliant if you want. (There are of course
backward compatibility problems. I'm not sure what the Postgres policy is
on this.)

- If the escape character is backslash, do nothing.
- Otherwise, turn all backslashes in the string to double backslashes.
- If the escape character is not set, stop here.
- Turn all occurences of the escape character into a backslash except
  where the escape character is doubled, where it should be made into a
  single occurence.
(Optionally, if "\n" is just an 'n' character, you can handle double
occurences of the escape character by turning the first one into a
backslash.)

Probably the best bet for PostgreSQL programmers is to always code Like
clauses with an ESCAPE '\' (or however its written).

I really wish they'd chosen a character other than underscore for the
"match one" wildcard... Is there any standard practice for seperating words
in table names?

-Z-

