Re: BUG #6314: The like command does not handle a long string of special chars

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: d(dot)rericha(at)healthcareoss(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #6314: The like command does not handle a long string of special chars
Date: 2011-12-01 18:08:01
Message-ID: 8577.1322762881@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

d(dot)rericha(at)healthcareoss(dot)com writes:
> Simply set a varchar field in your db to the following string:
> !&quot;#$%&#39;()*+,-/:;=?(at)[\]^_`{|}~0000&amp;&lt;&gt;

> I know, I know, who would do this, right? Well, its for a certification.
> The like command works fine up with escapes up to:
> !&quot;#$%&#39;&#39;()*+,-/:;=?(at)[%

Doesn't match for me, rather unsurprisingly since this string contains
two occurrences of "&#39;" not one.

> Notice, I added the % to the end. However, if you go any further - no
> matches:
> !&quot;#$%&#39;&#39;()*+,-/:;=?(at)[\\%
> Strangely, this works and shouldn&#39;t:
> !&quot;#$%&#39;&#39;()*+,-/:;=?(at)[\%

It's hard to tell for sure, since you've presented a garbled
interpretation of what you did rather than showing us exactly what you
did, but I'm suspecting the problem boils down to forgetting that
backslash is an escape character in Postgres string literals, and
also for LIKE itself. You should reread the manual's discussion of
LIKE:
http://www.postgresql.org/docs/8.4/static/functions-matching.html

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message rep.dot.nop 2011-12-01 19:09:03 BUG #6315: FETCH NEXT :next ROWS ONLY fails
Previous Message Kevin Grittner 2011-12-01 18:05:19 Re: BUG #6314: The like command does not handle a long string of special chars