Re: Additional message in pg_terminate_backend

From: Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>
To: Roman Khapov <rkhapov(at)yandex-team(dot)ru>, Andrey Borodin <x4mmm(at)yandex-team(dot)ru>
Cc: Kirill Reshke <reshkekirill(at)gmail(dot)com>, Daniel Gustafsson <daniel(at)yesql(dot)se>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Additional message in pg_terminate_backend
Date: 2026-02-03 18:22:16
Message-ID: 76e0edf2-4be3-458a-86e4-35b9dd836f31@uni-muenster.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Roman

On 03/02/2026 13:28, Roman Khapov wrote:
> Thanks for another round on review, updated the patch according to comments.
>
> Also, fix `make check` by updating pg_proc.data with new functions,
> similar to uuid7 way: defining _msg versions of the functions

Why did you decide to revert the pg_proc.dat and system_functions.sql
changes from v3? In v3 I thought that adding a msg DEFAULT '' to the
corresponding function in system_functions.sql ...

--- a/src/backend/catalog/system_functions.sql
+++ b/src/backend/catalog/system_functions.sql
@@ -400,7 +400,12 @@ CREATE OR REPLACE FUNCTION
PARALLEL SAFE;

CREATE OR REPLACE FUNCTION
- pg_terminate_backend(pid integer, timeout int8 DEFAULT 0)
+ pg_cancel_backend(pid integer, msg text DEFAULT '')
+ RETURNS boolean STRICT VOLATILE LANGUAGE INTERNAL AS 'pg_cancel_backend'
+ PARALLEL SAFE;
+
+CREATE OR REPLACE FUNCTION
+ pg_terminate_backend(pid integer, timeout int8 DEFAULT 0, msg text
DEFAULT '')
RETURNS boolean STRICT VOLATILE LANGUAGE INTERNAL AS
'pg_terminate_backend'
PARALLEL SAFE;

... and updating pg_proc.dat accordingly would do the trick

diff --git a/src/include/catalog/pg_proc.dat
b/src/include/catalog/pg_proc.dat
index 5e5e33f64f..47aa30d716 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -6724,10 +6724,11 @@

{ oid => '2171', descr => 'cancel a server process\' current query',
proname => 'pg_cancel_backend', provolatile => 'v', prorettype => 'bool',
- proargtypes => 'int4', prosrc => 'pg_cancel_backend' },
+ proargtypes => 'int4 text', proargnames => '{pid,msg}',
+ prosrc => 'pg_cancel_backend' },
{ oid => '2096', descr => 'terminate a server process',
proname => 'pg_terminate_backend', provolatile => 'v', prorettype =>
'bool',
- proargtypes => 'int4 int8', proargnames => '{pid,timeout}',
+ proargtypes => 'int4 int8 text', proargnames => '{pid,timeout,msg}',
prosrc => 'pg_terminate_backend' },
{ oid => '2172', descr => 'prepare for taking an online backup',
proname => 'pg_backup_start', provolatile => 'v', proparallel => 'r',

My rationale is based on the header in system_function.sql:

...
* src/backend/catalog/system_functions.sql
*
* This file redefines certain built-in functions that are impractical
* to fully define in pg_proc.dat. In most cases that's because they use
* SQL-standard function bodies and/or default expressions...

Am I missing something?

Thanks

Best, Jim

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Álvaro Herrera 2026-02-03 18:37:34 Re: Docs pg_restore: Shouldn't there be a note about -n ?
Previous Message Bertrand Drouvot 2026-02-03 17:58:37 Re: Flush some statistics within running transactions