Skip to content

Commit 600da67

Browse files
committed
Add pg_conf_load_time() function to report when the Postgres configuration
files were last loaded. George Gensure
1 parent 45173ae commit 600da67

File tree

7 files changed

+54
-14
lines changed

7 files changed

+54
-14
lines changed

doc/src/sgml/func.sgml

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.434 2008/04/28 14:48:57 alvherre Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.435 2008/05/04 21:13:35 tgl Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -10891,6 +10891,12 @@ postgres=# select * from unnest2(array[[1,2],[3,4]]);
1089110891
<entry>server start time</entry>
1089210892
</row>
1089310893

10894+
<row>
10895+
<entry><literal><function>pg_conf_load_time</function>()</literal></entry>
10896+
<entry><type>timestamp with time zone</type></entry>
10897+
<entry>configuration load time</entry>
10898+
</row>
10899+
1089410900
<row>
1089510901
<entry><literal><function>session_user</function></literal></entry>
1089610902
<entry><type>name</type></entry>
@@ -11031,9 +11037,23 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
1103111037
</indexterm>
1103211038

1103311039
<para>
11034-
<function>pg_postmaster_start_time</function> returns the
11035-
<type>timestamp with time zone</type> when the
11036-
server started.
11040+
<function>pg_postmaster_start_time</function> returns the
11041+
<type>timestamp with time zone</type> when the
11042+
server started.
11043+
</para>
11044+
11045+
<indexterm>
11046+
<primary>pg_conf_load_time</primary>
11047+
</indexterm>
11048+
11049+
<para>
11050+
<function>pg_conf_load_time</function> returns the
11051+
<type>timestamp with time zone</type> when the
11052+
server configuration files were last loaded.
11053+
(If the current session was alive at the time, this will be the time
11054+
when the session itself re-read the configuration files, so the
11055+
reading will vary a little in different sessions. Otherwise it is
11056+
the time when the postmaster process re-read the configuration files.)
1103711057
</para>
1103811058

1103911059
<indexterm>

src/backend/postmaster/postmaster.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.556 2008/04/26 22:47:40 tgl Exp $
40+
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.557 2008/05/04 21:13:35 tgl Exp $
4141
*
4242
* NOTES
4343
*
@@ -390,6 +390,7 @@ typedef struct
390390
InheritableSocket pgStatSock;
391391
pid_t PostmasterPid;
392392
TimestampTz PgStartTime;
393+
TimestampTz PgReloadTime;
393394
bool redirection_done;
394395
#ifdef WIN32
395396
HANDLE PostmasterHandle;
@@ -4263,6 +4264,7 @@ save_backend_variables(BackendParameters * param, Port *port,
42634264

42644265
param->PostmasterPid = PostmasterPid;
42654266
param->PgStartTime = PgStartTime;
4267+
param->PgReloadTime = PgReloadTime;
42664268

42674269
param->redirection_done = redirection_done;
42684270

@@ -4468,6 +4470,7 @@ restore_backend_variables(BackendParameters * param, Port *port)
44684470

44694471
PostmasterPid = param->PostmasterPid;
44704472
PgStartTime = param->PgStartTime;
4473+
PgReloadTime = param->PgReloadTime;
44714474

44724475
redirection_done = param->redirection_done;
44734476

src/backend/utils/adt/timestamp.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.187 2008/03/25 22:42:44 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.188 2008/05/04 21:13:35 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -42,6 +42,8 @@
4242

4343
/* Set at postmaster start */
4444
TimestampTz PgStartTime;
45+
/* Set at configuration reload */
46+
TimestampTz PgReloadTime;
4547

4648

4749
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)
11571159
}
11581160

11591161
Datum
1160-
pgsql_postmaster_start_time(PG_FUNCTION_ARGS)
1162+
pg_postmaster_start_time(PG_FUNCTION_ARGS)
11611163
{
11621164
PG_RETURN_TIMESTAMPTZ(PgStartTime);
11631165
}
11641166

1167+
Datum
1168+
pg_conf_load_time(PG_FUNCTION_ARGS)
1169+
{
1170+
PG_RETURN_TIMESTAMPTZ(PgReloadTime);
1171+
}
1172+
11651173
/*
11661174
* GetCurrentTimestamp -- get the current operating system time
11671175
*

src/backend/utils/misc/guc-file.l

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
66
*
7-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.53 2008/01/01 19:45:54 momjian Exp $
7+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc-file.l,v 1.54 2008/05/04 21:13:35 tgl Exp $
88
*/
99

1010
%{
@@ -309,6 +309,9 @@ ProcessConfigFile(GucContext context)
309309
PGC_S_FILE, GUC_ACTION_SET, true);
310310
}
311311

312+
/* Remember when we last successfully loaded the config file. */
313+
PgReloadTime = GetCurrentTimestamp();
314+
312315
cleanup_list:
313316
free_name_value_list(head);
314317
if (cvc)

src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.453 2008/04/29 14:59:17 alvherre Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.454 2008/05/04 21:13:35 tgl Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 200804292
56+
#define CATALOG_VERSION_NO 200805041
5757

5858
#endif

src/include/catalog/pg_proc.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.494 2008/04/29 13:00:22 alvherre Exp $
10+
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.495 2008/05/04 21:13:36 tgl Exp $
1111
*
1212
* NOTES
1313
* The script catalog/genbki.sh reads this file and generates .bki
@@ -3922,8 +3922,11 @@ DATA(insert OID = 2559 ( lastval PGNSP PGUID 12 1 0 f f t f v 0 20 "" _null
39223922
DESCR("current value from last used sequence");
39233923

39243924
/* start time function */
3925-
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_ ));
3925+
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_ ));
39263926
DESCR("postmaster start time");
3927+
/* config reload time function */
3928+
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_ ));
3929+
DESCR("configuration load time");
39273930

39283931
/* new functions for Y-direction rtree opclasses */
39293932
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_ ));

src/include/utils/timestamp.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.76 2008/03/21 01:31:43 tgl Exp $
9+
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.77 2008/05/04 21:13:36 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -195,6 +195,8 @@ typedef struct
195195

196196
/* Set at postmaster start */
197197
extern TimestampTz PgStartTime;
198+
/* Set at configuration reload */
199+
extern TimestampTz PgReloadTime;
198200

199201

200202
/*
@@ -303,7 +305,8 @@ extern Datum now(PG_FUNCTION_ARGS);
303305
extern Datum statement_timestamp(PG_FUNCTION_ARGS);
304306
extern Datum clock_timestamp(PG_FUNCTION_ARGS);
305307

306-
extern Datum pgsql_postmaster_start_time(PG_FUNCTION_ARGS);
308+
extern Datum pg_postmaster_start_time(PG_FUNCTION_ARGS);
309+
extern Datum pg_conf_load_time(PG_FUNCTION_ARGS);
307310

308311
/* Internal routines (not fmgr-callable) */
309312

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy