BUG #14349: Parse failure (?) when LIKE swapped out for ~~

From: its+postgres(at)csuhta(dot)com
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #14349: Parse failure (?) when LIKE swapped out for ~~
Date: 2016-10-03 06:09:24
Message-ID: 20161003060924.27236.38178@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 14349
Logged by: Corey Csuhta
Email address: its+postgres(at)csuhta(dot)com
PostgreSQL version: 9.5.4
Operating system: macOS
Description:

Here's this query:

SELECT 1 WHERE lower('ARTIST') LIKE '%'||'art'||'%';
Which selects:
1

But if you exchange ~~ for the LIKE statement here, Postgres does not
process it the same way:

SELECT 1 WHERE lower('ARTIST') ~~ '%'||'art'||'%';
Returns the error:
argument of WHERE must be type boolean, not type text
LINE 1: SELECT 1 WHERE lower('ARTIST') ~~ '%'||'art'||'%'

Is this expected? The documentation implies you can swap these operators and
get the same results.

I believe I have a minimum example above, the swap works if you do not use
|| or if you wrap the left and right side of the expression in parenthesis
to help the parser.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2016-10-03 08:14:06 Re: BUG #14349: Parse failure (?) when LIKE swapped out for ~~
Previous Message pippolone 2016-10-02 23:22:04 BUG #14348: 0 bytes for jdbc src tarball