Re-enable pg_terminate_backend() using SIGTERM. SIGTERM testing still
authorBruce Momjian <bruce@momjian.us>
Thu, 17 Apr 2008 20:56:41 +0000 (20:56 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 17 Apr 2008 20:56:41 +0000 (20:56 +0000)
needed.

doc/src/sgml/func.sgml
doc/src/sgml/runtime.sgml
src/backend/utils/adt/misc.c
src/include/catalog/pg_proc.h
src/include/utils/builtins.h

index b1edec5e36d3370eb8fd0e3ec768bdd299d88f0d..5341e7a5ff918fb40e86e0709599af517f3d80d2 100644 (file)
@@ -11848,6 +11848,9 @@ SELECT set_config('log_statement_stats', 'off', false);
    <indexterm>
     <primary>pg_cancel_backend</primary>
    </indexterm>
+   <indexterm>
+    <primary>pg_terminate_backend</primary>
+   </indexterm>
    <indexterm>
     <primary>pg_reload_conf</primary>
    </indexterm>
@@ -11883,6 +11886,13 @@ SELECT set_config('log_statement_stats', 'off', false);
        <entry><type>boolean</type></entry>
        <entry>Cancel a backend's current query</entry>
       </row>
+      <row>
+       <entry>
+        <literal><function>pg_terminate_backend</function>(<parameter>pid</parameter> <type>int</>)</literal>
+        </entry>
+       <entry><type>boolean</type></entry>
+       <entry>Terminate a backend</entry>
+      </row>
       <row>
        <entry>
         <literal><function>pg_reload_conf</function>()</literal>
@@ -11907,9 +11917,10 @@ SELECT set_config('log_statement_stats', 'off', false);
    </para>
 
    <para>
-    <function>pg_cancel_backend</> sends a query cancel
-    (<systemitem>SIGINT</>) signal to a backend process identified by
-    process ID.  The process ID of an active backend can be found from
+    <function>pg_cancel_backend</> and <function>pg_terminate_backend</>
+    send signals (<systemitem>SIGINT</> or <systemitem>SIGTERM</>
+    respectively) to backend processes identified by process ID.
+    The process ID of an active backend can be found from
     the <structfield>procpid</structfield> column in the
     <structname>pg_stat_activity</structname> view, or by listing the
     <command>postgres</command> processes on the server with
index a64c6f148aade559f786604008419825f73a5b1a..137d202fde93ae247055d05a3d57e794a9b6d751 100644 (file)
@@ -1372,6 +1372,14 @@ $ <userinput>kill -INT `head -1 /usr/local/pgsql/data/postmaster.pid`</userinput
     well.
    </para>
   </important>
+
+  <para>
+   To terminate a session while allowing other sessions to continue, use
+   <function>pg_terminate_backend()</> (<xref
+   linkend="functions-admin-signal-table">) or send a
+   <systemitem>SIGTERM</> signal to the child process associated with
+   the session.
+  </para>
  </sect1>
 
  <sect1 id="preventing-server-spoofing">
index 0d580539695b2241e514b0e3fd56a525ea242357..0d7828f23b4bd17471f317c3dfc4365b037d9764 100644 (file)
@@ -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
index b1c2f1c8b469afe0f64341f2be783bee14bf1384..e035a9b390685a9024f0cf945aadf585ae89cdf0 100644 (file)
@@ -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_ ));
index f9d425f7b98d53196b93bdc77fb996b157245c49..e6d478ddde11152a5be851857f7803cd4a8777e4 100644 (file)
@@ -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);