Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore

From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, Michael Paquier <michael(at)paquier(dot)xyz>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com>
Subject: Re: Don't use the deprecated and insecure PQcancel in our frontend tools anymore
Date: 2026-07-04 19:11:54
Message-ID: aea19cfb-0518-4485-b3d8-c7647d450186@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-07-04 20:27:05 Re: Make \d tablename fast again, regression introduced by 85b7efa1cdd
Previous Message Andrey Borodin 2026-07-04 18:41:07 Re: Missing FSM Update when Updating VM On-access