On 01/02/2026 01:08, Jim Jones wrote:
> As pointed out by Kirill, there is no reason to create
> pg_terminate_backend_msg or pg_cancel_backend_msg. You can simply use
> the existing functions and expand them to use one extra parameter

Since the message's size is limited to BACKEND_MSG_MAX_LEN, shouldn't
you use it to limit msg at pg_terminate_backend[_msg]()? Something like:

Datum pg_terminate_backend(PG_FUNCTION_ARGS)
{
  int pid;
  int timeout; /* milliseconds */
  char msg[BACKEND_MSG_MAX_LEN];

  pid = PG_GETARG_INT32(0);
  timeout = PG_GETARG_INT64(1);
  text_to_cstring_buffer(PG_GETARG_TEXT_PP(2), msg, sizeof(msg));

  return pg_terminate_backend_internal(pid, timeout, msg);
}




Reply via email to