Received: from candle.pha.pa.us (maillist@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.2/8.9.1) with ESMTP id RAA75709 for ; Tue, 16 Mar 1999 17:30:35 -0500 (EST) (envelope-from maillist@candle.pha.pa.us) Received: (from maillist@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id RAA20904; Tue, 16 Mar 1999 17:26:09 -0500 (EST) From: Bruce Momjian Message-Id: <199903162226.RAA20904@candle.pha.pa.us> Subject: Re: [SQL] How match percent sign in SELECT using LIKE? In-Reply-To: <199903162051.MAA01651@netcom15.netcom.com> from Zalman Stern at "Mar 16, 1999 12:51:41 pm" To: zalman@netcom.com (Zalman Stern) Date: Tue, 16 Mar 1999 17:26:09 -0500 (EST) Cc: herouth@oumail.openu.ac.il, pgsql-sql@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL47 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > One useful and probably not too hard thing to do is to allow ESCAPE '\' on > the end of the LIKE clause. Any character other than '\' will be an error. > This allows Postgres users to write compliant SQL code that can be used > with other databases. This is an excellent idea, I will implement it. > > Another approach is to "rewrite" the match string at parse time. If it is a > known constant, you can do the whole job there. Otherwise, you'd insert an > extra node in the parse tree which does the rewrite just before calling hte > "~~" operator. (I am assuming the match string can be a general expression > and that you can add a function of two arguments which rewrites the first > argument using the second argument as the escape character. This is of > course not the utmost of micro efficiency, but I doubt it would matter > much.) > > But I don't have in depth knowledge of the Postgres SQL parser and > evaluator so I may be way off base. 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. -- Bruce Momjian | http://www.op.net/~candle maillist@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026