mirror of
https://github.com/postgres/postgres.git
synced 2025-07-31 22:04:40 +03:00
Fix query cancellation handling in psql
The refactoring done ina4fd3aa
for query cancellation has messed up with the logic in psql by mixing CancelRequested and cancel_pressed, breaking for example \watch. The former would be switched to true if a cancellation request has been attempted and that it actually succeeded, and the latter tracks if a cancellation attempt has been done. This commit brings back the code of psql to a state consistent to what it was beforea4fd3aa
, without giving up on the refactoring pieces introduced. It should be actually possible to merge more both flags as their concepts are close enough, however note that psql's --single-step mode relies on cancel_pressed to be always set, so this requires more careful analysis left for later. While on it, fix the declarations of CancelRequested (in cancel.c) and cancel_pressed (in psql) to be volatile sig_atomic_t. Previously, both were declared as booleans, which should be fine on modern platforms, but the C standard recommends the use of sig_atomic_t for variables used in signal handlers. Note that since its introduction ina1792320
, CancelRequested declaration was not volatile. Reported-by: Jeff Janes Author: Michael Paquier Discussion: https://postgr.es/m/CAMkU=1zpoUDGKqWKuMWkj7t-bOCaJDx0r=5te_-d0B2HVLABXg@mail.gmail.com
This commit is contained in:
@ -19,7 +19,6 @@
|
||||
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef WIN32
|
||||
@ -41,7 +40,7 @@
|
||||
* Note: print.c's general strategy for when to check cancel_pressed is to do
|
||||
* so at completion of each row of output.
|
||||
*/
|
||||
volatile bool cancel_pressed = false;
|
||||
volatile sig_atomic_t cancel_pressed = false;
|
||||
|
||||
static bool always_ignore_sigpipe = false;
|
||||
|
||||
|
Reference in New Issue
Block a user