Re: Array of composite types returned from python - Mailing list pgsql-hackers

From Behn, Edward (EBEHN)
Subject Re: Array of composite types returned from python
Date
Msg-id 93F16B4BD93A7840AC75EB16E9494C7B153C0C83@EXANPMB2.arinc.com
Whole thread Raw
In response to Re: Array of composite types returned from python  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Just writing to check in.  

I haven't done anything to look into allowing arrays of composites for input
to PL/Python function.  I made the submitted modification for a specific
project that I'm working on that involves python code that returns data
structures. 

I also have no idea about a more efficient way to convert composite
elements.             -Ed 


-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Sent: Sunday, June 29, 2014 4:54 PM
To: Abhijit Menon-Sen
Cc: Sim Zacks; Behn, Edward (EBEHN); pgsql-hackers@postgresql.org; Peter
Eisentraut
Subject: Re: [HACKERS] Array of composite types returned from python

Abhijit Menon-Sen <ams@2ndQuadrant.com> writes:
>> 3) This is such a simple change with no new infrastructure code 
>> (PLyObject_ToComposite already exists). Can you think of a reason why 
>> this wasn't done until now? Was it a simple miss or purposefully 
>> excluded?

> This is not an authoritative answer: I think the infrastructure was 
> originally missing, but was later added in #bc411f25 for OUT parameters.
> Perhaps it was overlooked at the time that the same code would suffice 
> for this earlier-missing case. (I've Cc:ed Peter E. in case he has any
> comments.)

> I think the patch is ready for committer.

I took a quick look at this; not really a review either, but I have a couple
comments.

1. While I think the patch does what it intends to, it's a bit distressing
that it will invoke the information lookups in PLyObject_ToComposite over
again for *each element* of the array.  We probably ought to quantify that
overhead to see if it's bad enough that we need to do something about
improving caching, as speculated in the comment in PLyObject_ToComposite.

2. I wonder whether the no-composites restriction in plpy.prepare (see lines
133ff in plpy_spi.c) could be removed as easily.
        regards, tom lane

pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Escaping from blocked send() reprised.
Next
From: Robert Haas
Date:
Subject: Re: Spinlocks and compiler/memory barriers