pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #6314: The like command does not handle a long string of special chars
4+ messages / 4 participants
[nested] [flat]
* BUG #6314: The like command does not handle a long string of special chars
@ 2011-12-01 17:40 d.rericha@healthcareoss.com
0 siblings, 2 replies; 4+ messages in thread
From: d.rericha@healthcareoss.com @ 2011-12-01 17:40 UTC (permalink / raw)
To: pgsql-bugs
The following bug has been logged on the website:
Bug reference: 6314
Logged by: David Rericha
Email address: d.rericha@healthcareoss.com
PostgreSQL version: 8.4.5
Operating system: OpenSuSE 11.4 64-bit
Description:
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:
!"#$%''()*+,-/:;=?@[%
Notice, I added the % to the end. However, if you go any further - no
matches:
!"#$%''()*+,-/:;=?@[\\%
Strangely, this works and shouldn't:
!"#$%''()*+,-/:;=?@[\%
Thanks.
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #6314: The like command does not handle a long string of special chars
@ 2011-12-01 18:05 Kevin Grittner <Kevin.Grittner@wicourts.gov>
parent: d.rericha@healthcareoss.com
1 sibling, 0 replies; 4+ messages in thread
From: Kevin Grittner @ 2011-12-01 18:05 UTC (permalink / raw)
To: d.rericha@healthcareoss.com; pgsql-bugs
<d.rericha@healthcareoss.com> wrote:
> Simply set a varchar field in your db to the following string:
> !"#$%'()*+,-/:;=?@[\]^_`{|}~0000&<>
Do you have standard_conforming_strings = on?
> The like command works fine up with escapes up to:
> !"#$%''()*+,-/:;=?@[%
> Notice, I added the % to the end. However, if you go any further -
> no matches:
> !"#$%''()*+,-/:;=?@[\\%
> Strangely, this works and shouldn't:
> !"#$%''()*+,-/:;=?@[\%
It is always better to include a self-contained test case. For
example:
test=# set standard_conforming_strings = on;
SET
test=# create table t (v text not null);
CREATE TABLE
test=# insert into t values
('!"#$%'()*+,-/:;=?@[\]^_`{|}~0000&<>');
INSERT 0 1
test=# select * from t where v like
'!"#$\%'()*+,-/:;=?@[\\]^_`{|}~0000&<>%'
escape '\';
v
--------------------------------------------------------
!"#$%'()*+,-/:;=?@[\]^_`{|}~0000&<>
(1 row)
So this is not a bug on HEAD. What do you get when you run it?
-Kevin
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #6314: The like command does not handle a long string of special chars
@ 2011-12-01 18:08 Tom Lane <tgl@sss.pgh.pa.us>
parent: d.rericha@healthcareoss.com
1 sibling, 1 reply; 4+ messages in thread
From: Tom Lane @ 2011-12-01 18:08 UTC (permalink / raw)
To: d.rericha@healthcareoss.com; +Cc: 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
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: BUG #6314: The like command does not handle a long string of special chars
@ 2011-12-02 15:41 Magnus Hagander <magnus@hagander.net>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 4+ messages in thread
From: Magnus Hagander @ 2011-12-02 15:41 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: d.rericha@healthcareoss.com <d.rericha@healthcareoss.com>; pgsql-bugs
On Thursday, December 1, 2011, Tom Lane wrote:
> d.rericha@healthcareoss.com <javascript:;> 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
>
A fair amount of that garbling is unfortunately the fault of a bug in the
new website code that applied HTML escapes to plaintext emails, which in
the end caused double escaping. I've just pushed a fix for this, so from
now on bugreports won't do that.
--
Magnus Hagander
Me: http://www.hagander.net/
Work: http://www.redpill-linpro.com/
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2011-12-02 15:41 UTC | newest]
Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-12-01 17:40 BUG #6314: The like command does not handle a long string of special chars d.rericha@healthcareoss.com
2011-12-01 18:05 ` Kevin Grittner <Kevin.Grittner@wicourts.gov>
2011-12-01 18:08 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-12-02 15:41 ` Magnus Hagander <magnus@hagander.net>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox