pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: psql: Replace cancel_pressed with CancelRequested
Date: Thu, 19 Nov 2026 14:16:38 +0000
Message-ID: <E1xU2wH-00000000OLx-2BQT@gemulon.postgresql.org> (raw)

psql: Replace cancel_pressed with CancelRequested

In a4fd3aa7 src/fe_utils/cancel.c was introduced which added the
CancelRequested variable. This new variable was used in psql to
replace the cancel_pressed variable, but that quickly got reverted in
5d43c3c54. The reason was that cancel_pressed had not been fully
replaced by CancelRequested everywhere in the code, and the mixed
usage caused issues (e.g. with \watch).

This now does that original refactor correctly by using
CancelRequested everywhere and completely getting rid of
cancel_pressed.

5d43c3c54 mentions the --single-step flag as something that required
further analysis. I tried --single-step with and without this commit,
and Ctrl+C behaves the same in both. I also cannot think of a reason
why it would behave any differently.

CancelRequested is set by the signal handler before psql's callback
runs, so also before any longjmp out of waiting for input. That
matches the behavior of cancel_pressed since commit 8b529705d15, so
this refactor should not cause any behavioral changes.

Author: Jelte Fennema-Nio <postgres@jeltef.nl>
Discussion: https://www.postgresql.org/message-id/flat/DEY0N7FS8NCU.1F7QXGG37MQ09@jeltef.nl

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5aa40dc6793a70d0cd5308dd3a5651c38d21851d

Modified Files
--------------
src/bin/psql/command.c       |  10 ++---
src/bin/psql/common.c        |  25 ++++-------
src/bin/psql/describe.c      |   9 ++--
src/bin/psql/mainloop.c      |   7 +--
src/bin/psql/variables.c     |   3 +-
src/fe_utils/print.c         | 103 ++++++++++++++++++++-----------------------
src/include/fe_utils/print.h |   4 --
7 files changed, 74 insertions(+), 87 deletions(-)



Message-ID: <E1xU2wH-00000000OLx-2BQT@gemulon.postgresql.org>
Permalink:  ../E1xU2wH-00000000OLx-2BQT@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xU2wH-00000000OLx-2BQT@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org
  Subject: Re: pgsql: psql: Replace cancel_pressed with CancelRequested
  In-Reply-To: <E1xU2wH-00000000OLx-2BQT@gemulon.postgresql.org>
  References: <E1xU2wH-00000000OLx-2BQT@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox