Re: pl/perl example in the doc no longer works in 9.1
Alexey Klyukin <alexk@commandprompt.com>
From: Alexey Klyukin <alexk@commandprompt.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Alex Hunsaker <badalex@gmail.com>, "David E. Wheeler" <david@kineticode.com>, Amit Khandekar <amit.khandekar@enterprisedb.com>, hackers@postgresql.org, Alvaro Herrera <alvherre@commandprompt.com>
Date: 2011-10-13T20:10:20Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Convert Postgres arrays to Perl arrays on PL/perl input arguments
- 87bb2ade2ce6 9.1.0 cited
On Oct 13, 2011, at 9:02 PM, Tom Lane wrote: > Alex Hunsaker <badalex@gmail.com> writes: >> On Wed, Oct 12, 2011 at 15:33, Alex Hunsaker <badalex@gmail.com> wrote: >>> On Wed, Oct 12, 2011 at 15:00, Tom Lane <tgl@sss.pgh.pa.us> wrote: >>>> The core of the problem seems to be that if SvROK(sv) then >>>> the code assumes that it must be intended to convert that to an array or >>>> composite, no matter whether the declared result type of the function is >>>> compatible with such a thing. > >> PFA my attempt at a fix. > >> This gets rid of of most of the if/else chain and the has_retval crap >> in plperl_handl_func(). Instead we let plperl_sv_to_datum() do most of >> the lifting. It also now handles VOIDOID and checks that the request >> result oid can be converted from the perl structure. For example if >> you passed in a hashref with a result oid that was not an rowtype it >> will error out with "PL/Perl cannot convert hash to non rowtype %s". >> Arrays behave similarly. > > I'm working through this patch now. Does anyone object to having the > array-to-non-array-result-type and hash-to-non-rowtype-result-type cases > throw errors, rather than returning the rather useless ARRAY(...) and > HASH(...) strings as pre-9.1 did? No objections here. -- Alexey Klyukin http://www.commandprompt.com The PostgreSQL Company – Command Prompt, Inc.