44 #define SIGNAL_BACKEND_SUCCESS 0
45 #define SIGNAL_BACKEND_ERROR 1
46 #define SIGNAL_BACKEND_NOPERMISSION 2
47 #define SIGNAL_BACKEND_NOSUPERUSER 3
72 (
errmsg(
"PID %d is not a PostgreSQL backend process", pid)));
109 (
errmsg(
"could not send signal to process %d: %m", pid)));
128 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
129 errmsg(
"permission denied to cancel query"),
130 errdetail(
"Only roles with the %s attribute may cancel queries of roles with the %s attribute.",
131 "SUPERUSER",
"SUPERUSER")));
135 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
136 errmsg(
"permission denied to cancel query"),
137 errdetail(
"Only roles with privileges of the role whose query is being canceled or with privileges of the \"%s\" role may cancel this query.",
138 "pg_signal_backend")));
154 int64 waittime = 100;
159 int64 remainingtime = timeout;
169 if (remainingtime < waittime)
170 waittime = remainingtime;
172 if (
kill(pid, 0) == -1)
178 (
errcode(ERRCODE_INTERNAL_ERROR),
179 errmsg(
"could not check the existence of the backend with PID %d: %m",
189 WAIT_EVENT_BACKEND_TERMINATION);
193 remainingtime -= waittime;
194 }
while (remainingtime > 0);
197 (
errmsg_plural(
"backend with PID %d did not terminate within %lld millisecond",
198 "backend with PID %d did not terminate within %lld milliseconds",
200 pid, (
long long int) timeout)));
227 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
228 errmsg(
"\"timeout\" must not be negative")));
234 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
235 errmsg(
"permission denied to terminate process"),
236 errdetail(
"Only roles with the %s attribute may terminate processes of roles with the %s attribute.",
237 "SUPERUSER",
"SUPERUSER")));
241 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
242 errmsg(
"permission denied to terminate process"),
243 errdetail(
"Only roles with privileges of the role whose process is being terminated or with privileges of the \"%s\" role may terminate this process.",
244 "pg_signal_backend")));
265 (
errmsg(
"failed to send signal to postmaster: %m")));
283 (
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
284 errmsg(
"must be superuser to rotate log files with adminpack 1.0"),
286 errhint(
"Consider using %s, which is part of core, instead.",
287 "pg_logfile_rotate()")));
292 (
errmsg(
"rotation not possible because log collection not active")));
312 (
errmsg(
"rotation not possible because log collection not active")));
bool has_privs_of_role(Oid member, Oid role)
#define OidIsValid(objectId)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_GETARG_INT64(n)
#define PG_GETARG_INT32(n)
#define PG_RETURN_BOOL(x)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
#define WL_EXIT_ON_PM_DEATH
#define CHECK_FOR_INTERRUPTS()
void SendPostmasterSignal(PMSignalReason reason)
@ PMSIGNAL_ROTATE_LOGFILE
PGPROC * BackendPidGetProc(int pid)
static int pg_signal_backend(int pid, int sig)
Datum pg_cancel_backend(PG_FUNCTION_ARGS)
#define SIGNAL_BACKEND_SUCCESS
#define SIGNAL_BACKEND_NOPERMISSION
Datum pg_rotate_logfile_v2(PG_FUNCTION_ARGS)
Datum pg_rotate_logfile(PG_FUNCTION_ARGS)
#define SIGNAL_BACKEND_NOSUPERUSER
Datum pg_reload_conf(PG_FUNCTION_ARGS)
Datum pg_terminate_backend(PG_FUNCTION_ARGS)
#define SIGNAL_BACKEND_ERROR
static bool pg_wait_until_termination(int pid, int64 timeout)
bool superuser_arg(Oid roleid)