Re: SPI Interface to Call Procedure with Transaction Control Statements?

From: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>, Jack LIU <toliujiayi(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: SPI Interface to Call Procedure with Transaction Control Statements?
Date: 2019-01-15 11:06:48
Message-ID: 6c7e1b13-325c-5c7c-cf3b-d2f58a96336a@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15/01/2019 11:49, Andrew Gierth wrote:
>>>>>> "Jack" == Jack LIU <toliujiayi(at)gmail(dot)com> writes:
>
> Jack> Hi Andrew,
> Jack> This is my code to call the procedure with
> Jack> SPI_connect_ext(SPI_OPT_NONATOMIC).
>
> Ah. You need to take a look at exec_stmt_call in plpgsql, and do the
> same things it does with snapshot management (specifically, setting the
> no_snapshot flag on the plan that you're going to execute). SPI forces
> atomic mode if the normal snapshot management is in use, because
> otherwise a commit inside the procedure would warn about still having a
> snapshot open.

Yeah, eventually we might want to add a new SPI function to do
non-atomic calls, but right now you need to go the manual route.

--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2019-01-15 11:51:29 Re: FETCH FIRST clause WITH TIES option
Previous Message Andrew Gierth 2019-01-15 10:49:37 Re: SPI Interface to Call Procedure with Transaction Control Statements?