From: | Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us> |
---|---|
To: | Zalman Stern <zalman(at)netcom(dot)com> |
Cc: | herouth(at)oumail(dot)openu(dot)ac(dot)il, pgsql-sql(at)postgreSQL(dot)org |
Subject: | Re: [SQL] How match percent sign in SELECT using LIKE? |
Date: | 1999-05-10 00:47:25 |
Message-ID: | 199905100047.UAA04343@candle.pha.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Good ideas. Added to TODO list.
> Bruce Momjian wrote:
> > I agree we should allow ESC, but that would make LIKE a trinary
> > operation, rather than a binary. If you want really confusing, the code
> > for LIKE really does:
> >
> > | a_expr LIKE a_expr
> > { $$ = makeIndexable("~~", $1, $3); }
> >
> > so it maps LIKE to a binary operator "~~". How do we map that into a
> > trinary operator, which we don't support? Doesn't really seem worth it.
> >
> > I can add an item to the TODO list if you wish?
>
> 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.
>
> 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.
>
> -Z-
>
--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 1999-05-10 04:31:48 | Re: [SQL] Simple Optimization Problem |
Previous Message | Tom Lane | 1999-05-09 17:11:21 | Re: [SQL] keeping OID's when copying table |