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

Re: BUG #5737: LIKE and ILIKE strange behaviour

From: John R Pierce <pierce(at)hogranch(dot)com>
To: Radu Ilies <ilies(dot)radu(at)gmail(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5737: LIKE and ILIKE strange behaviour
Date: 2010-11-01 04:00:50
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On 10/31/10 12:28 PM, Radu Ilies wrote:
> id, char[25]
> name, text
> The first row is:
> id='radu'
> name='Radu Ilies'
> The following queries does not find any result (fail):
> SELECT * FROM my_table WHERE id LIKE 'radu'
> SELECT * FROM my_table WHERE id ILIKE 'radu'

'radu'::char[25] ==>  'radu_____________________'     (21 spaces).

the = equality coerces the 'radu'::text to 'radu                  
'::char[25] before doing the comparision.
LIKE/ILIKE doesn't think 'radu_____________________' is LIKE 'radu'

use TEXT for character types unless you have a very specific requirement 
to limit them to a maximum length.

In response to

pgsql-bugs by date

Next:From: spcheDate: 2010-11-01 10:18:02
Subject: BUG #5738: btree index search bug
Previous:From: Jon NelsonDate: 2010-11-01 01:48:32
Subject: Re: [PERFORM] typoed column name, but postgres didn't grump

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