pgsql: Fix up Perl-to-Postgres datatype conversions in pl/perl.

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Fix up Perl-to-Postgres datatype conversions in pl/perl.
Дата
Msg-id E1RETOa-0001Vv-16@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix up Perl-to-Postgres datatype conversions in pl/perl.

This patch restores the pre-9.1 behavior that pl/perl functions returning
VOID ignore the result value of their last Perl statement.  9.1.0
unintentionally threw an error if the last statement returned a reference,
as reported by Amit Khandekar.

Also, make sure it works to return a string value for a composite type,
so long as the string meets the type's input format.  We already allowed
the equivalent behavior for arrays, so it seems inconsistent to not allow
it for composites.

In addition, ensure we throw errors for attempts to return arrays or hashes
when the function's declared result type is not an array or composite type,
respectively.  Pre-9.1 versions rather uselessly returned strings like
ARRAY(0x221a9a0) or HASH(0x221aa90), while 9.1.0 threw an error for the
hash case and returned a garbage value for the array case.

Also, clean up assorted grotty coding in Perl array conversion, including
use of a session-lifespan memory context to accumulate the array value
(resulting in session-lifespan memory leak on error), failure to apply the
declared typmod if any, and failure to detect some cases of non-rectangular
multi-dimensional arrays.

Alex Hunsaker and Tom Lane

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/23610daf8af0f5b468b5c0d4774295cc02ad30a9

Modified Files
--------------
src/pl/plperl/expected/plperl.out       |   58 ++++++-
src/pl/plperl/expected/plperl_array.out |   10 +
src/pl/plperl/plperl.c                  |  297 ++++++++++++++++++-------------
src/pl/plperl/sql/plperl.sql            |   47 +++++
src/pl/plperl/sql/plperl_array.sql      |    7 +
5 files changed, 289 insertions(+), 130 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Fix up Perl-to-Postgres datatype conversions in pl/perl.
Следующее
От: Bruce Momjian
Дата:
Сообщение: pgsql: Remove all "traces" of trace_userlocks, because userlocks were r