Fix cancellation check in ExecQueryAndProcessResults

From: Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Fix cancellation check in ExecQueryAndProcessResults
Date: 2024-03-08 05:24:12
Message-ID: 20240308142412.5eb394a64fcc6c88d9df3b5e@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While looking ExecQueryAndProcessResults, I found the following code.

/*
* If SIGINT is sent while the query is processing, the interrupt will be
* consumed. The user's intention, though, is to cancel the entire watch
* process, so detect a sent cancellation request and exit in this case.
*/
if (is_watch && cancel_pressed)
{
ClearOrSaveAllResults();
return 0;
}

I guess the intention is that when the query is cancelled during \watch process,
we want to exit early before handling the error. However, we cannot detect the
cancel at this timing because currently we use PQsendQuery which is asynchronous
and does not wait the result. We have to check cancel_pressed after PQgetResult
call. I'm also attached a patch for this, with some comments fix.

Regards,
Yugo Nagata

--
Yugo NAGATA <nagata(at)sraoss(dot)co(dot)jp>

Attachment Content-Type Size
fix_query_cancellation_error_in_psql_watch.patch text/x-diff 1.3 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2024-03-08 05:39:39 Re: meson: Specify -Wformat as a common warning flag for extensions
Previous Message Yugo NAGATA 2024-03-08 05:22:52 Re: Remove unnecessary code from psql's watch command