mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Refactor query cancellation code into src/fe_utils/
Originally, this code was duplicated in src/bin/psql/ and src/bin/scripts/, but it can be useful for other frontend applications, like pgbench. This refactoring offers the possibility to setup a custom callback which would get called in the signal handler for SIGINT or when the interruption console events happen on Windows. Author: Fabien Coelho, with contributions from Michael Paquier Reviewed-by: Álvaro Herrera, Ibrar Ahmed Discussion: https://postgr.es/m/alpine.DEB.2.21.1910311939430.27369@lancre
This commit is contained in:
30
src/include/fe_utils/cancel.h
Normal file
30
src/include/fe_utils/cancel.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* Query cancellation support for frontend code
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/include/fe_utils/cancel.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef CANCEL_H
|
||||
#define CANCEL_H
|
||||
|
||||
#include "libpq-fe.h"
|
||||
|
||||
extern bool CancelRequested;
|
||||
|
||||
extern void SetCancelConn(PGconn *conn);
|
||||
extern void ResetCancelConn(void);
|
||||
|
||||
/*
|
||||
* A callback can be optionally set up to be called at cancellation
|
||||
* time.
|
||||
*/
|
||||
extern void setup_cancel_handler(void (*cancel_callback) (void));
|
||||
|
||||
#endif /* CANCEL_H */
|
Reference in New Issue
Block a user