Re: BUG #5356: citext not acting like case insensitive search

Lists: pgsql-bugs
From: "Michael Gould" <mgould(at)intermodalsoftwaresolutions(dot)net>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #5356: citext not acting like case insensitive search
Date: 2010-03-01 17:15:25
Message-ID: 201003011715.o21HFP5d074237@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 5356
Logged by: Michael Gould
Email address: mgould(at)intermodalsoftwaresolutions(dot)net
PostgreSQL version: 8.4.2
Operating system: Windows 2008 R2 Server, Windows 7 x64
Description: citext not acting like case insensitive search
Details:

When we run the following query, we return no results.

Select citystateinfoid from iss.citystateinfo where cityname =
'JACKSONVILLE' and statecode = 'FL';

However this does work

Select citystateinfoid from iss.citystateinfo where cityname =
'Jacksonville' and statecode = 'FL'

The second query is how the data is actually stored. I've already forwarded
our ddl to david wheeler.


From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: "Michael Gould" <mgould(at)intermodalsoftwaresolutions(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5356: citext not acting like case insensitive search
Date: 2010-03-01 17:18:09
Message-ID: 1ADFCB4A-3F79-41D6-9250-350AA4FBB8A2@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mar 1, 2010, at 9:15 AM, Michael Gould wrote:

>
> The following bug has been logged online:
>
> Bug reference: 5356
> Logged by: Michael Gould
> Email address: mgould(at)intermodalsoftwaresolutions(dot)net
> PostgreSQL version: 8.4.2
> Operating system: Windows 2008 R2 Server, Windows 7 x64
> Description: citext not acting like case insensitive search
> Details:
>
> When we run the following query, we return no results.
>
> Select citystateinfoid from iss.citystateinfo where cityname =
> 'JACKSONVILLE' and statecode = 'FL';
>
> However this does work
>
> Select citystateinfoid from iss.citystateinfo where cityname =
> 'Jacksonville' and statecode = 'FL'
>
> The second query is how the data is actually stored. I've already forwarded
> our ddl to david wheeler.

Michael managed to fix this issue by moving citext to the "public" schema. The question is, why would citext operators work in the public schema but not when they're in some other schema? Is `=` resolving to `TEXT = TEXT` if the "iss" schema isn't in the search path?

Michael, does this work?

Select citystateinfoid from iss.citystateinfo where cityname iss.=
'JACKSONVILLE' and statecode iss.= 'FL';

Best,

David


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: "Michael Gould" <mgould(at)intermodalsoftwaresolutions(dot)net>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5356: citext not acting like case insensitive search
Date: 2010-03-01 18:17:08
Message-ID: 20693.1267467428@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"David E. Wheeler" <david(at)kineticode(dot)com> writes:
> Michael managed to fix this issue by moving citext to the "public"
> schema. The question is, why would citext operators work in the public
> schema but not when they're in some other schema?

Are they in the search path?

> Michael, does this work?

> Select citystateinfoid from iss.citystateinfo where cityname iss.=
> 'JACKSONVILLE' and statecode iss.= 'FL';

The syntax is OPERATOR(iss.=) not just iss.= ...

regards, tom lane


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
Cc: "Michael Gould" <mgould(at)intermodalsoftwaresolutions(dot)net>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5356: citext not acting like case insensitive search
Date: 2010-03-01 18:25:28
Message-ID: 20854.1267467928@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

"David E. Wheeler" <david(at)kineticode(dot)com> writes:
> Michael managed to fix this issue by moving citext to the "public"
> schema. The question is, why would citext operators work in the public
> schema but not when they're in some other schema? Is `=` resolving to
> `TEXT = TEXT` if the "iss" schema isn't in the search path?

Now that I think a bit, not having the operators in the search path
would cause exactly that. The parser will be faced with
citext = unknown_literal
and the only operator that it can find that is relevant at all is
text = text, which can be applied by using the implicit cast from
citext to text. So that's what it will do.

Not sure if there is anything we can do to make this much nicer.
Removing the implicit cast seems like a cure worse than the disease,
particularly because it would result in throwing a "no such operator"
error rather than actually doing what Michael would like.

regards, tom lane


From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Michael Gould" <mgould(at)intermodalsoftwaresolutions(dot)net>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5356: citext not acting like case insensitive search
Date: 2010-03-01 18:39:03
Message-ID: B209E4B2-6696-4054-B321-409446E8BDC6@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-bugs

On Mar 1, 2010, at 10:25 AM, Tom Lane wrote:

> Not sure if there is anything we can do to make this much nicer.
> Removing the implicit cast seems like a cure worse than the disease,
> particularly because it would result in throwing a "no such operator"
> error rather than actually doing what Michael would like.

Yes, I suspect that he can solve his problem by adding the iss schema to search_path.

Best,

David