Re: PL/Python: Add cursor and execute methods to plan object

From: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>
To: David Steele <david(at)pgmasters(dot)net>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Subject: Re: PL/Python: Add cursor and execute methods to plan object
Date: 2017-03-22 15:46:28
Message-ID: bb783e49-0aae-f202-3c1a-4f3799dedae9@2ndQuadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/21/2017 06:27 PM, Andrew Dunstan wrote:
> On 03/16/2017 05:32 PM, David Steele wrote:
>> On 2/25/17 1:27 PM, Peter Eisentraut wrote:
>>> Something that has been bothering me in PL/Python for a long time is the
>>> non-object-oriented way in which plans are prepared and executed:
>>>
>>> plan = plpy.prepare(...)
>>> res = plpy.execute(plan, ...)
>>>
>>> where plpy.execute() takes either a plan or a query string.
>>>
>>> I think a better style would be
>>>
>>> plan = plpy.prepare(...)
>>> res = plan.execute(...)
>>>
>>> so that the "plan" is more like a statement handle that one finds in
>>> other APIs.
>>>
>>> This ended up being very easy to implement, so I'm proposing to allow
>>> this new syntax as an alternative.
>>>
>>> I came across this again as I was developing the background sessions API
>>> for PL/Python. So I'm also wondering here which style people prefer so
>>> I can implement it there.
>> This patch applies cleanly at cccbdde.
>>
>> Any Python folks out there who would like to take a crack at reviewing this?
>>
>>
> I'm not particularly a Python folk, but I've done enough over the years
> with PLs, including PLPython, that I think I can review this :-)
>

This is a very simple patch that does what it advertises. It applies
cleanly and provides tests for both the new methods (plan.cursor and
plan.execute).

Marking Ready For Committer.

cheers

andrew

--
Andrew Dunstan https://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2017-03-22 15:49:41 Re: Logical decoding on standby
Previous Message Dave Page 2017-03-22 15:46:18 Re: Monitoring roles patch