public inbox for [email protected]
help / color / mirror / Atom feedFrom: Fabien COELHO <[email protected]>
To: [email protected] <[email protected]>
Cc: [email protected] <[email protected]>
Subject: RE: psql - add SHOW_ALL_RESULTS option
Date: Wed, 7 Apr 2021 16:02:10 +0200 (CEST)
Message-ID: <alpine.DEB.2.22.394.2104071516470.2724014@pseudo> (raw)
In-Reply-To: <OSZPR01MB631017521EE6887ADC9492E8FD759@OSZPR01MB6310.jpnprd01.prod.outlook.com>
References: <[email protected]>
<[email protected]>
<20200201120136.fnlbfcrybgzk75pc@development>
<alpine.DEB.2.21.2002020906030.20752@pseudo>
<alpine.DEB.2.22.394.2006061622300.32228@pseudo>
<CA+hUKGJo1PYkW-oxzADaXDKoEUpoHonnSq4=1cUSNyOxc53Nmg@mail.gmail.com>
<alpine.DEB.2.22.394.2007200747040.2368970@pseudo>
<[email protected]>
<[email protected]>
<alpine.DEB.2.22.394.2103141046590.164573@pseudo>
<[email protected]>
<alpine.DEB.2.22.394.2104062323150.2555247@pseudo>
<OSZPR01MB631017521EE6887ADC9492E8FD759@OSZPR01MB6310.jpnprd01.prod.outlook.com>
Hello,
> I met a problem after commit 3a51306722.
>
> While executing a SQL statement with psql, I can't interrupt it by pressing ctrl+c.
>
> For example:
> postgres=# insert into test select generate_series(1,10000000);
> ^C^CINSERT 0 10000000
>
> Press ctrl+c before finishing INSERT, and psql still continuing to INSERT.
I can confirm this unexpected change of behavior on this commit. This is
indeed e bug.
> Is it the result expected?
Obviously not.
> And I think maybe it is better to allow users to interrupt by pressing
> ctrl+c.
Obviously yes.
The problem is that the cancellation stuff is cancelled too early after
sending an asynchronous request.
Attached a patch which attempts to fix this by moving the cancellation
cancelling request after processing results.
--
Fabien.
Attachments:
[text/x-diff] fix-cancel-1.patch (658B, ../alpine.DEB.2.22.394.2104071516470.2724014@pseudo/2-fix-cancel-1.patch)
download | inline diff:
diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c
index 028a357991..0482e57d45 100644
--- a/src/bin/psql/common.c
+++ b/src/bin/psql/common.c
@@ -1117,7 +1117,6 @@ SendQueryAndProcessResults(const char *query, double *pelapsed_msec, bool is_wat
INSTR_TIME_SET_CURRENT(before);
success = PQsendQuery(pset.db, query);
- ResetCancelConn();
if (!success)
{
@@ -1257,6 +1256,9 @@ SendQueryAndProcessResults(const char *query, double *pelapsed_msec, bool is_wat
if (!CheckConnection())
return -1;
+ /* all results are processed, nothing to cancel anymore */
+ ResetCancelConn();
+
return success ? 1 : -1;
}
view thread (104+ messages) latest in thread
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 using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: RE: psql - add SHOW_ALL_RESULTS option
In-Reply-To: <alpine.DEB.2.22.394.2104071516470.2724014@pseudo>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox