Re: BUG #6314: The like command does not handle a long string of special chars - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #6314: The like command does not handle a long string of special chars
Date
Msg-id 8577.1322762881@sss.pgh.pa.us
Whole thread Raw
In response to BUG #6314: The like command does not handle a long string of special chars  (d.rericha@healthcareoss.com)
Responses Re: BUG #6314: The like command does not handle a long string of special chars
List pgsql-bugs
d.rericha@healthcareoss.com writes:
> Simply set a varchar field in your db to the following string:
> !"#$%'()*+,-/:;=?@[\]^_`{|}~0000&<>

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

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

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

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

pgsql-bugs by date:

Previous
From: "Kevin Grittner"
Date:
Subject: Re: BUG #6314: The like command does not handle a long string of special chars
Next
From: rep.dot.nop@gmail.com
Date:
Subject: BUG #6315: FETCH NEXT :next ROWS ONLY fails