Re: Additional message in pg_terminate_backend

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Roman Khapov <rkhapov(at)yandex-team(dot)ru>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: Additional message in pg_terminate_backend
Date: 2025-12-20 10:32:34
Message-ID: CALdSSPhU526xXqjsb=BPO689+qFJQDeimWrhOv=ehzveQsZJgw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 20 Dec 2025 at 14:27, Roman Khapov <rkhapov(at)yandex-team(dot)ru> wrote:
>
>
> > On 17 Dec 2025, at 21:02, Daniel Gustafsson <daniel(at)yesql(dot)se> wrote:
> >
> > Greenplum already has support for passing a message in the terminate command
> > doesnt it? Or at least it used to have but perhaps it was ripped out, my
> > memory is getting a bit fuzzy.
> >
> > https://github.com/greenplum-db/gpdb-archive/commit/fa6c2d43d675aa05e2d9f797e3008f6fe075ee2c
> >
>
> Well, seems like I missed that patch..
>
> Anyway, now I need same functionality in PostgreSQL, and your patch seems interesting,
> especially in part where you keep messages in separated shmem region.
>
> So I adopted your patch, maybe in that form it can be useful for PostgreSQL?
>

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

I don't think we need to create a function with a name other than
`pg_terminate_backend`. I also do not think we need
pg_terminate_backend_msg as a wrapper to another function - all of
this can be a single function, accepting different number of params,
exampli gratia "bt_index_check"

```
Datum
bt_index_check(PG_FUNCTION_ARGS)
{
Oid indrelid = PG_GETARG_OID(0);

...

if (PG_NARGS() >= 2)
args.heapallindexed = PG_GETARG_BOOL(1);
if (PG_NARGS() >= 3)
args.checkunique = PG_GETARG_BOOL(2);
....

PG_RETURN_VOID();
}

```

--
Best regards,
Kirill Reshke

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2025-12-20 10:41:39 Re: Add SPLIT PARTITION/MERGE PARTITIONS commands
Previous Message vignesh C 2025-12-20 09:47:11 Re: Proposal: Conflict log history table for Logical Replication