Re: BUG #4436: (E'\\' LIKE E'\\') => f - Mailing list pgsql-bugs

From Bruce Momjian
Subject Re: BUG #4436: (E'\\' LIKE E'\\') => f
Date
Msg-id 200809241607.m8OG76w23363@momjian.us
Whole thread Raw
In response to BUG #4436: (E'\\' LIKE E'\\') => f  ("Mathieu Fenniak" <hjoiiv@mathieu.fenniak.net>)
Responses Re: BUG #4436: (E'\\' LIKE E'\\') => f
List pgsql-bugs
Mathieu Fenniak wrote:
>
> The following bug has been logged online:
>
> Bug reference:      4436
> Logged by:          Mathieu Fenniak
> Email address:      hjoiiv@mathieu.fenniak.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@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

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

pgsql-bugs by date:

Previous
From: "Mathieu Fenniak"
Date:
Subject: BUG #4436: (E'\\' LIKE E'\\') => f
Next
From: Tom Lane
Date:
Subject: Re: Postgres won't start and doesn't generate any messages.