citext function overloads for text parameters - Mailing list pgsql-hackers

From Shay Rojansky
Subject citext function overloads for text parameters
Date
Msg-id CADT4RqBWiK_aoAi6C8dNuevnXAnGhyzkJCvW2XunWDo-AZrb3g@mail.gmail.com
Whole thread Raw
Responses Re: citext function overloads for text parameters  (Pavel Stehule <pavel.stehule@gmail.com>)
List pgsql-hackers
Hi hackers.

The following works well of course:

test=# select strpos('Aa'::citext, 'a');
 strpos 
--------
      1

However, if I pass a typed text parameter for the substring, I get case-sensitive behavior instead:

test=# select strpos('Aa'::citext, 'a'::text);
 strpos 
--------
      2

This seems like surprising behavior - my expectation was that the first parameter being citext would be enough to trigger case-insensitive behavior. The same may be happening with other string functions (e.g. regexp_matches). This is causing some difficulties in a real scenario where SQL and parameters are getting generated by an O/RM, and changing them isn't trivial.

Do the above seem like problematic behavior like it does to me, or is it the expected behavior?

Shay

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: genbki.pl not quoting keywords in postgres.bki output
Next
From: Pavel Stehule
Date:
Subject: Re: citext function overloads for text parameters