Re: How to check for pending CancelRequest from C/C++ function

From: Stephen Woodbridge <woodbri(at)swoodbridge(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to check for pending CancelRequest from C/C++ function
Date: 2014-01-06 16:38:42
Message-ID: 52CADC12.2080204@swoodbridge.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 1/6/2014 10:32 AM, Tom Lane wrote:
> Stephen Woodbridge <woodbri(at)swoodbridge(dot)com> writes:
>> I writing some functions for postgresql extension in C/C++ and I would
>> like to be able to check for a pending CancelRequest from the frontend
>> so I can take appropriate action to honor this request.
>
> Put "CHECK_FOR_INTERRUPTS();" in some suitably safe place.

Thanks! Looking at this macro its doing

if (InterruptPending)
ProcessInterrupts();

Am I correct in assuming that ProcessInterrupts() may not return?

So if I need to clean up then I should check do something like:

if (InterruptPending) {
/* cleanup here */
ProcessInterrupts();
}

Similarly if I'm in C++ code I can probably include miscadmin.h as an
extern C to get access to this.

Thanks again,
-Steve

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2014-01-06 16:45:52 Re: WAL archive cleanup om master
Previous Message Keith Fiske 2014-01-06 16:33:28 Re: Planning error in dynamic string creation in plpgsql