Re: Array of composite types returned from python

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: "Behn, Edward (EBEHN)" <EBEHN(at)arinc(dot)com>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Array of composite types returned from python
Date: 2014-03-21 14:07:31
Message-ID: CAHyXU0yAziY8cWa-9vn0AG92CCpCa2p_=v_vkEpZwOVq=BWJFw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Mar 20, 2014 at 4:54 PM, Behn, Edward (EBEHN) <EBEHN(at)arinc(dot)com> wrote:
>
> I've endeavored to enable the return of arrays of composite types from code written in PL/Python. It seems that this can be accomplished though a very minor change to the code:
>
> On line 401 in the file src/pl/plpython/plpy_typeio.c, remove the error report "PL/Python functions cannot return type..." and replace it with the command
>
> arg->func = PLyObject_ToComposite;
>
> From all that I can see, this does exactly what I want. A python list of tuples is converted to an array of composite types in SQL.
>
> I ran the main and python regression suites for both python2 and python3 with assert enabled. The only discrepancies I got were ones that were due to the output expecting an error. When I altered the .out files to the expected behavior, it matched just fine.
>
> Am I missing anything, (ie memory leak, undesirable behavior elsewhere)?

Don't know, but I'd definitely submit that patch to the next open
fest. That's a very useful gain for such a small change.

merlin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kohei KaiGai 2014-03-21 14:10:29 Re: Creating tables for columns
Previous Message Rajashree Mandaogane 2014-03-21 13:57:54 Creating tables for columns