pgsql: Fix collation handling in plpgsql functions.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Fix collation handling in plpgsql functions.
Date: 2011-03-25 19:06:51
Message-ID: E1Q3CLT-0003gt-35@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix collation handling in plpgsql functions.

Make plpgsql treat the input collation as a polymorphism variable, so
that we cache separate plans for each input collation that's used in a
particular session, as per recent discussion. Propagate the input
collation to all collatable input parameters.

I chose to also propagate the input collation to all declared variables of
collatable types, which is a bit more debatable but seems to be necessary
for non-astonishing behavior. (Copying a parameter into a separate local
variable shouldn't result in a change of behavior, for example.) There is
enough infrastructure here to support declaring a collation for each local
variable to override that default, but I thought we should wait to see what
the field demand is before adding such a feature.

In passing, remove exec_get_rec_fieldtype(), which wasn't used anywhere.

Documentation patch to follow.

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/a4425e3200f2c2578bdf94bb6234169115746c9f

Modified Files
--------------
src/pl/plpgsql/src/gram.y | 21 ++++--
src/pl/plpgsql/src/pl_comp.c | 98 ++++++++++++++++------
src/pl/plpgsql/src/pl_exec.c | 79 ++++++++++++-----
src/pl/plpgsql/src/plpgsql.h | 18 +++-
src/test/regress/expected/collate.linux.utf8.out | 82 ++++++++++---------
src/test/regress/sql/collate.linux.utf8.sql | 11 ++-
6 files changed, 207 insertions(+), 102 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2011-03-25 22:21:42 pgsql: Document collation handling in SQL and plpgsql functions.
Previous Message Michael Meskes 2011-03-25 18:15:06 Re: pgsql: Documented some ecpg command line options that were missing: