Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id 5563B91453C for ; Thu, 1 Dec 2011 14:08:18 -0400 (AST) Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1RWB3Q-0000Sx-Gj for pgsql-bugs@postgresql.org; Thu, 01 Dec 2011 18:08:18 +0000 Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id pB1I811l008578; Thu, 1 Dec 2011 13:08:01 -0500 (EST) To: d.rericha@healthcareoss.com cc: pgsql-bugs@postgresql.org Subject: Re: BUG #6314: The like command does not handle a long string of special chars In-reply-to: References: Comments: In-reply-to d.rericha@healthcareoss.com message dated "Thu, 01 Dec 2011 17:40:24 +0000" Date: Thu, 01 Dec 2011 13:08:01 -0500 Message-ID: <8577.1322762881@sss.pgh.pa.us> From: Tom Lane X-Pg-Spam-Score: -3.1 (---) X-Archive-Number: 201112/11 X-Sequence-Number: 31822 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