Skip site navigation (1) Skip section navigation (2)

Re: BUG #4436: (E'\\' LIKE E'\\') => f

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Mathieu Fenniak <hjoiiv(at)mathieu(dot)fenniak(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4436: (E'\\' LIKE E'\\') => f
Date: 2008-09-24 16:07:06
Message-ID: 200809241607.m8OG76w23363@momjian.us (view raw or flat)
Thread:
Lists: pgsql-bugs
Mathieu Fenniak wrote:
> 
> The following bug has been logged online:
> 
> Bug reference:      4436
> Logged by:          Mathieu Fenniak
> Email address:      hjoiiv(at)mathieu(dot)fenniak(dot)net
> PostgreSQL version: 8.3.3
> Operating system:   Linux x86-64
> Description:        (E'\\' LIKE E'\\') => f
> Details: 
> 
> I noticed that (SELECT E'\\' LIKE E'\\') returns false, where I would expect
> it to return true.  I asked on the #postgresql/freenode IRC channel, and
> nobody had a good explanation for this return value, suggesting it may be a
> minor bug.

I believe this is caused because backslash is the default escape
character for LIKE, so you need:
	
	test=> SELECT E'\\' LIKE E'\\\\';
	 ?column?
	----------
	 t
	(1 row)
	
or change the escape character:
	
	test=> SELECT E'\\' LIKE E'\\' escape 'a';
	 ?column?
	----------
	 t
	(1 row)

-- 
  Bruce Momjian  <bruce(at)momjian(dot)us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +

In response to

Responses

pgsql-bugs by date

Next:From: Tom LaneDate: 2008-09-24 17:34:14
Subject: Re: Postgres won't start and doesn't generate any messages.
Previous:From: Mathieu FenniakDate: 2008-09-24 16:00:52
Subject: BUG #4436: (E'\\' LIKE E'\\') => f

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group