diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 23a758cd02..7e120bc862 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,4 +1,4 @@ - + Functions and Operators @@ -11848,6 +11848,9 @@ SELECT set_config('log_statement_stats', 'off', false); pg_cancel_backend + + pg_terminate_backend + pg_reload_conf @@ -11883,6 +11886,13 @@ SELECT set_config('log_statement_stats', 'off', false); boolean Cancel a backend's current query + + + pg_terminate_backend(pid int) + + boolean + Terminate a backend + pg_reload_conf() @@ -11907,9 +11917,10 @@ SELECT set_config('log_statement_stats', 'off', false); - pg_cancel_backend sends a query cancel - (SIGINT) signal to a backend process identified by - process ID. The process ID of an active backend can be found from + pg_cancel_backend and pg_terminate_backend + send signals (SIGINT or SIGTERM + respectively) to backend processes identified by process ID. + The process ID of an active backend can be found from the procpid column in the pg_stat_activity view, or by listing the postgres processes on the server with diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml index eb9b937a81..63259faff5 100644 --- a/doc/src/sgml/runtime.sgml +++ b/doc/src/sgml/runtime.sgml @@ -1,4 +1,4 @@ - + Operating System Environment @@ -1372,6 +1372,14 @@ $ kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid` + + + To terminate a session while allowing other sessions to continue, use + pg_terminate_backend() () or send a + SIGTERM signal to the child process associated with + the session. + diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 5542f87744..f99a07a999 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.61 2008/04/15 20:28:46 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.62 2008/04/17 20:56:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -128,6 +128,12 @@ pg_cancel_backend(PG_FUNCTION_ARGS) PG_RETURN_BOOL(pg_signal_backend(PG_GETARG_INT32(0), SIGINT)); } +Datum +pg_terminate_backend(PG_FUNCTION_ARGS) +{ + PG_RETURN_BOOL(pg_signal_backend(PG_GETARG_INT32(0), SIGTERM)); +} + Datum pg_reload_conf(PG_FUNCTION_ARGS) { @@ -169,17 +175,6 @@ pg_rotate_logfile(PG_FUNCTION_ARGS) PG_RETURN_BOOL(true); } -#ifdef NOT_USED - -/* Disabled in 8.0 due to reliability concerns; FIXME someday */ -Datum -pg_terminate_backend(PG_FUNCTION_ARGS) -{ - PG_RETURN_INT32(pg_signal_backend(PG_GETARG_INT32(0), SIGTERM)); -} -#endif - - /* Function to find out which databases make use of a tablespace */ typedef struct diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index cb2815ce6e..90b5503413 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.491 2008/04/15 20:28:46 momjian Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.492 2008/04/17 20:56:41 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -3157,6 +3157,8 @@ DESCR("is schema another session's temp schema?"); DATA(insert OID = 2171 ( pg_cancel_backend PGNSP PGUID 12 1 0 f f t f v 1 16 "23" _null_ _null_ _null_ pg_cancel_backend - _null_ _null_ )); DESCR("cancel a server process' current query"); +DATA(insert OID = 2096 ( pg_terminate_backend PGNSP PGUID 12 1 0 f f t f v 1 16 "23" _null_ _null_ _null_ pg_terminate_backend - _null_ _null_ )); +DESCR("terminate a server process"); DATA(insert OID = 2172 ( pg_start_backup PGNSP PGUID 12 1 0 f f t f v 1 25 "25" _null_ _null_ _null_ pg_start_backup - _null_ _null_ )); DESCR("prepare for taking an online backup"); DATA(insert OID = 2173 ( pg_stop_backup PGNSP PGUID 12 1 0 f f t f v 0 25 "" _null_ _null_ _null_ pg_stop_backup - _null_ _null_ )); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 8fcdb2c099..1a652c6de3 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.314 2008/04/15 20:28:47 momjian Exp $ + * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.315 2008/04/17 20:56:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -416,6 +416,7 @@ extern Datum nonnullvalue(PG_FUNCTION_ARGS); extern Datum current_database(PG_FUNCTION_ARGS); extern Datum current_query(PG_FUNCTION_ARGS); extern Datum pg_cancel_backend(PG_FUNCTION_ARGS); +extern Datum pg_terminate_backend(PG_FUNCTION_ARGS); extern Datum pg_reload_conf(PG_FUNCTION_ARGS); extern Datum pg_tablespace_databases(PG_FUNCTION_ARGS); extern Datum pg_rotate_logfile(PG_FUNCTION_ARGS);