pl/tcl function to detect when a request has been canceled

From: Peter Da Silva <peter(dot)dasilva(at)flightaware(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: pl/tcl function to detect when a request has been canceled
Date: 2018-06-08 18:08:14
Message-ID: 90F9A12C-2692-48C4-8910-6AA58C7E0137@flightaware.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

We have occasional need to run very long-running pl/tcl scripts. If the request is cancelled (say, by the user hitting ^c in psql) the server-side script still runs to completion.

There is a C-level variable QueryCancelPending that can be used to monitor for this case, but it’s not visible at the pl/tcl scripting level. This is a simple new command that returns the current state of this variable to Tcl.

We are currently maintaining a fork of pl/tcl at https://github.com/flightaware/pltcl that has this mod, but it would be useful to get the functionality into mainline PostgreSQL.

Attachment Content-Type Size
cancel_pending.diff application/octet-stream 1.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2018-06-08 18:10:09 Re: Performance regression with PostgreSQL 11 and partitioning
Previous Message Robert Haas 2018-06-08 18:06:46 Re: file cloning in pg_upgrade and CREATE DATABASE