Re: Array of composite types returned from python

From: "Behn, Edward (EBEHN)" <EBEHN(at)arinc(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)com>
Cc: Sim Zacks <sim(at)compulab(dot)co(dot)il>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: Array of composite types returned from python
Date: 2014-06-30 15:37:20
Message-ID: 93F16B4BD93A7840AC75EB16E9494C7B153C0C83@EXANPMB2.arinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)sss(dot)pgh(dot)pa(dot)us]
Sent: Sunday, June 29, 2014 4:54 PM
To: Abhijit Menon-Sen
Cc: Sim Zacks; Behn, Edward (EBEHN); pgsql-hackers(at)postgresql(dot)org; Peter
Eisentraut
Subject: Re: [HACKERS] Array of composite types returned from python

Abhijit Menon-Sen <ams(at)2ndQuadrant(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2014-06-30 15:38:31 Re: Spinlocks and compiler/memory barriers
Previous Message Robert Haas 2014-06-30 15:27:47 Re: Escaping from blocked send() reprised.