Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore
Date
Msg-id aea19cfb-0518-4485-b3d8-c7647d450186@iki.fi
Whole thread
In response to Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore  ("Jelte Fennema-Nio" <postgres@jeltef.nl>)
Responses Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore
List pgsql-hackers
On 04/07/2026 01:28, Jelte Fennema-Nio wrote:
>> psql has a global variable, 'cancel_pressed', which is set in the signal
>> handler callback. Is it redundant with 'CancelRequested' that's also set
>> in the signal handler?
> 
> I did some spelunking, and yes it is redundant. Fixed in 0001

Cool!

> 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.

Hmm, me neither. Michael, it was a long time ago, but would you happen 
to remember what your concern on that was?

That said, the behavior with --single-step and Ctrl-C isn't great, with 
or without this patch. Ctrl-C doesn't work while you're stopped on the 
confirmation prompt:

postgres=# \set SINGLESTEP 1
postgres=# select 1; select 2;
/**(Single step mode: verify 
command)******************************************/
select 1;
/**(press return to proceed or enter x and return to 
cancel)*******************/
^C^C^C^C^C

Hitting Ctrl-C doesn't get you out of that prompt. It does cause the 
query to not execute, but you still need to hit enter. I find that 
surprising and I bet most users would agree.

I started to dig into that, but it's a rabbit hole. I'll start a 
separate thread to not derail this patch. Patch 0001 looks good to me, 
unless Michael remembers something we're missing.

- Heikki




pgsql-hackers by date:

Previous
From: Andrey Borodin
Date:
Subject: Re: Missing FSM Update when Updating VM On-access
Next
From: Tom Lane
Date:
Subject: Re: Make \d tablename fast again, regression introduced by 85b7efa1cdd