Thread
-
Re: Additional message in pg_terminate_backend
Kirill Reshke <reshkekirill@gmail.com> — 2025-12-20T10:32:34Z
On Sat, 20 Dec 2025 at 14:27, Roman Khapov <rkhapov@yandex-team.ru> wrote: > > > > On 17 Dec 2025, at 21:02, Daniel Gustafsson <daniel@yesql.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