Add pg_conf_load_time() function to report when the Postgres configuration
authorTom Lane <tgl@sss.pgh.pa.us>
Sun, 4 May 2008 21:13:36 +0000 (21:13 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Sun, 4 May 2008 21:13:36 +0000 (21:13 +0000)
files were last loaded.

George Gensure

doc/src/sgml/func.sgml
src/backend/postmaster/postmaster.c
src/backend/utils/adt/timestamp.c
src/backend/utils/misc/guc-file.l
src/include/catalog/catversion.h
src/include/catalog/pg_proc.h
src/include/utils/timestamp.h

index 42451d2ec019dfeed7580cec36a7dd27285d811c..41826a678e782ad5711d30eb7fcd404adf446d09 100644 (file)
@@ -10891,6 +10891,12 @@ postgres=# select * from unnest2(array[[1,2],[3,4]]);
        <entry>server start time</entry>
       </row>
 
+      <row>
+       <entry><literal><function>pg_conf_load_time</function>()</literal></entry>
+       <entry><type>timestamp with time zone</type></entry>
+       <entry>configuration load time</entry>
+      </row>
+
       <row>
        <entry><literal><function>session_user</function></literal></entry>
        <entry><type>name</type></entry>
@@ -11031,9 +11037,23 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
    </indexterm>
 
    <para>
-     <function>pg_postmaster_start_time</function> returns the
-     <type>timestamp with time zone</type> when the
-     server started.
+    <function>pg_postmaster_start_time</function> returns the
+    <type>timestamp with time zone</type> when the
+    server started.
+   </para>
+
+   <indexterm>
+    <primary>pg_conf_load_time</primary>
+   </indexterm>
+
+   <para>
+    <function>pg_conf_load_time</function> returns the
+    <type>timestamp with time zone</type> when the
+    server configuration files were last loaded.
+    (If the current session was alive at the time, this will be the time
+    when the session itself re-read the configuration files, so the
+    reading will vary a little in different sessions.  Otherwise it is
+    the time when the postmaster process re-read the configuration files.)
    </para>
 
    <indexterm>
index 5e4b5904990344d219116aa2f7a40a1348609bbf..469a79efd6b2a7f44d637e886d3e2859429fc504 100644 (file)
@@ -390,6 +390,7 @@ typedef struct
        InheritableSocket pgStatSock;
        pid_t           PostmasterPid;
        TimestampTz PgStartTime;
+       TimestampTz PgReloadTime;
        bool            redirection_done;
 #ifdef WIN32
        HANDLE          PostmasterHandle;
@@ -4263,6 +4264,7 @@ save_backend_variables(BackendParameters * param, Port *port,
 
        param->PostmasterPid = PostmasterPid;
        param->PgStartTime = PgStartTime;
+       param->PgReloadTime = PgReloadTime;
 
        param->redirection_done = redirection_done;
 
@@ -4468,6 +4470,7 @@ restore_backend_variables(BackendParameters * param, Port *port)
 
        PostmasterPid = param->PostmasterPid;
        PgStartTime = param->PgStartTime;
+       PgReloadTime = param->PgReloadTime;
 
        redirection_done = param->redirection_done;
 
index e1b7cf5c9e380ec05cb7d56106bed030aa7c48aa..fcd6c36be1f692aac5a3877b6319fe58753fe0e7 100644 (file)
@@ -42,6 +42,8 @@
 
 /* Set at postmaster start */
 TimestampTz PgStartTime;
+/* Set at configuration reload */
+TimestampTz PgReloadTime;
 
 
 static TimeOffset time2t(const int hour, const int min, const int sec, const fsec_t fsec);
@@ -1157,11 +1159,17 @@ clock_timestamp(PG_FUNCTION_ARGS)
 }
 
 Datum
-pgsql_postmaster_start_time(PG_FUNCTION_ARGS)
+pg_postmaster_start_time(PG_FUNCTION_ARGS)
 {
        PG_RETURN_TIMESTAMPTZ(PgStartTime);
 }
 
+Datum
+pg_conf_load_time(PG_FUNCTION_ARGS)
+{
+       PG_RETURN_TIMESTAMPTZ(PgReloadTime);
+}
+
 /*
  * GetCurrentTimestamp -- get the current operating system time
  *
index f083f04db6ea56ab0c55678e7702ddbe333ff442..3a4b63b08cdd72200adfa10056a8d25309644438 100644 (file)
@@ -309,6 +309,9 @@ ProcessConfigFile(GucContext context)
                                                  PGC_S_FILE, GUC_ACTION_SET, true);
        }
 
+       /* Remember when we last successfully loaded the config file. */
+       PgReloadTime = GetCurrentTimestamp();
+
  cleanup_list:
        free_name_value_list(head);
        if (cvc)
index e787c52632edb60b31f6b5aa335c440f2c3fa016..c5da648e8d0b23251df38dce17c0ed9a26f703ae 100644 (file)
@@ -53,6 +53,6 @@
  */
 
 /*                                                     yyyymmddN */
-#define CATALOG_VERSION_NO     200804292
+#define CATALOG_VERSION_NO     200805041
 
 #endif
index a1e5f828d72293a0356310f7c9dd6fec7af621eb..927d532d93d043961fecd480582164e93e923c1f 100644 (file)
@@ -3922,8 +3922,11 @@ DATA(insert OID = 2559 ( lastval                    PGNSP PGUID 12 1 0 f f t f v 0 20 "" _null
 DESCR("current value from last used sequence");
 
 /* start time function */
-DATA(insert OID = 2560 (  pg_postmaster_start_time PGNSP PGUID 12 1 0 f f t f s 0 1184 "" _null_ _null_ _null_ pgsql_postmaster_start_time - _null_ _null_ ));
+DATA(insert OID = 2560 (  pg_postmaster_start_time     PGNSP PGUID 12 1 0 f f t f s 0 1184 "" _null_ _null_ _null_ pg_postmaster_start_time - _null_ _null_ ));
 DESCR("postmaster start time");
+/* config reload time function */
+DATA(insert OID = 2034 (  pg_conf_load_time                    PGNSP PGUID 12 1 0 f f t f s 0 1184 "" _null_ _null_ _null_ pg_conf_load_time - _null_ _null_ ));
+DESCR("configuration load time");
 
 /* new functions for Y-direction rtree opclasses */
 DATA(insert OID = 2562 (  box_below               PGNSP PGUID 12 1 0 f f t f i 2 16 "603 603" _null_ _null_ _null_ box_below - _null_ _null_ ));
index 45418e3605e0079df478964ea052ade647260ef3..455ce75983d728e1c18ec1f395a4da131a1e7fa7 100644 (file)
@@ -195,6 +195,8 @@ typedef struct
 
 /* Set at postmaster start */
 extern TimestampTz PgStartTime;
+/* Set at configuration reload */
+extern TimestampTz PgReloadTime;
 
 
 /*
@@ -303,7 +305,8 @@ extern Datum now(PG_FUNCTION_ARGS);
 extern Datum statement_timestamp(PG_FUNCTION_ARGS);
 extern Datum clock_timestamp(PG_FUNCTION_ARGS);
 
-extern Datum pgsql_postmaster_start_time(PG_FUNCTION_ARGS);
+extern Datum pg_postmaster_start_time(PG_FUNCTION_ARGS);
+extern Datum pg_conf_load_time(PG_FUNCTION_ARGS);
 
 /* Internal routines (not fmgr-callable) */