citext function overloads for text parameters

From: Shay Rojansky <roji(at)roji(dot)org>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: citext function overloads for text parameters
Date: 2018-05-06 06:26:14
Message-ID: CADT4RqBWiK_aoAi6C8dNuevnXAnGhyzkJCvW2XunWDo-AZrb3g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2018-05-06 06:42:02 Re: citext function overloads for text parameters
Previous Message Tom Lane 2018-05-05 17:50:22 Re: genbki.pl not quoting keywords in postgres.bki output