Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
f5835b4b
Commit
f5835b4b
authored
Jun 14, 2005
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add pg_postmaster_start_time() function.
Euler Taveira de Oliveira Matthias Schmidt
parent
b5e65c83
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
65 additions
and
6 deletions
+65
-6
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+16
-1
src/backend/postmaster/postmaster.c
src/backend/postmaster/postmaster.c
+16
-1
src/backend/tcop/postgres.c
src/backend/tcop/postgres.c
+16
-1
src/backend/utils/adt/timestamp.c
src/backend/utils/adt/timestamp.c
+7
-1
src/include/catalog/pg_proc.h
src/include/catalog/pg_proc.h
+5
-1
src/include/utils/timestamp.h
src/include/utils/timestamp.h
+5
-1
No files found.
doc/src/sgml/func.sgml
View file @
f5835b4b
<!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.25
4 2005/06/13 02:40:04 neilc
Exp $
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.25
5 2005/06/14 21:04:38 momjian
Exp $
PostgreSQL documentation
-->
...
...
@@ -8119,6 +8119,12 @@ select current_date + s.a as dates from generate_series(0,14,7) as s(a);
<entry>session user name</entry>
</row>
<row>
<entry><function>pg_postmaster_start_time()</function></entry>
<entry><type>timestamp with time zone</type></entry>
<entry><command>postmaster</> start time</entry>
</row>
<row>
<entry><function>user</function></entry>
<entry><type>name</type></entry>
...
...
@@ -8216,6 +8222,15 @@ SET search_path TO <replaceable>schema</> <optional>, <replaceable>schema</>, ..
Unix-domain socket.
</para>
<indexterm zone="functions-info">
<primary>pg_postmaster_start_time</primary>
</indexterm>
<para>
<function>pg_postmaster_start_time()</function> returns the timestamp with time zone
when the <command>postmaster</> started.
</para>
<indexterm zone="functions-info">
<primary>version</primary>
</indexterm>
...
...
src/backend/postmaster/postmaster.c
View file @
f5835b4b
...
...
@@ -37,7 +37,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.45
2 2005/06/09 22:01:12 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.45
3 2005/06/14 21:04:39 momjian
Exp $
*
* NOTES
*
...
...
@@ -222,6 +222,9 @@ static bool FatalError = false; /* T if recovering from backend crash */
bool
ClientAuthInProgress
=
false
;
/* T during new-client
* authentication */
/* Backend startup time */
TimestampTz
StartTime
;
/*
* State for assigning random salts and cancel keys.
* Also, the global MyCancelKey passes the cancel key assigned to a given
...
...
@@ -330,6 +333,7 @@ typedef struct
InheritableSocket
pgStatPipe0
;
InheritableSocket
pgStatPipe1
;
pid_t
PostmasterPid
;
TimestampTz
StartTime
;
#ifdef WIN32
HANDLE
PostmasterHandle
;
HANDLE
initial_signal_pipe
;
...
...
@@ -372,6 +376,9 @@ PostmasterMain(int argc, char *argv[])
char
*
userDoption
=
NULL
;
int
i
;
AbsoluteTime
StartTimeSec
;
/* integer part */
int
StartTimeUSec
;
/* microsecond part */
/* This will call exit() if strdup() fails. */
progname
=
get_progname
(
argv
[
0
]);
...
...
@@ -914,6 +921,12 @@ PostmasterMain(int argc, char *argv[])
*/
StartupPID
=
StartupDataBase
();
/*
* Get start up time
*/
StartTimeSec
=
GetCurrentAbsoluteTimeUsec
(
&
StartTimeUSec
);
StartTime
=
AbsoluteTimeUsecToTimestampTz
(
StartTimeSec
,
StartTimeUSec
);
status
=
ServerLoop
();
/*
...
...
@@ -3603,6 +3616,7 @@ save_backend_variables(BackendParameters *param, Port *port,
write_inheritable_socket
(
&
param
->
pgStatPipe1
,
pgStatPipe
[
1
],
childPid
);
param
->
PostmasterPid
=
PostmasterPid
;
param
->
StartTime
=
StartTime
;
#ifdef WIN32
param
->
PostmasterHandle
=
PostmasterHandle
;
...
...
@@ -3805,6 +3819,7 @@ restore_backend_variables(BackendParameters *param, Port *port)
read_inheritable_socket
(
&
pgStatPipe
[
1
],
&
param
->
pgStatPipe1
);
PostmasterPid
=
param
->
PostmasterPid
;
StartTime
=
param
->
StartTime
;
#ifdef WIN32
PostmasterHandle
=
param
->
PostmasterHandle
;
...
...
src/backend/tcop/postgres.c
View file @
f5835b4b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.44
7 2005/06/03 23:05:29 tgl
Exp $
* $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.44
8 2005/06/14 21:04:40 momjian
Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
...
...
@@ -149,6 +149,9 @@ static int UseNewLine = 0; /* Use EOF as query delimiters */
#endif
/* TCOP_DONTUSENEWLINE */
/* Backend startup time */
TimestampTz
StartTime
;
/* ----------------------------------------------------------------
* decls for routines only used in this file
* ----------------------------------------------------------------
...
...
@@ -2380,6 +2383,9 @@ PostgresMain(int argc, char *argv[], const char *username)
sigjmp_buf
local_sigjmp_buf
;
volatile
bool
send_rfq
=
true
;
AbsoluteTime
StartTimeSec
;
/* integer part */
int
StartTimeUSec
;
/* microsecond part */
#define PendingConfigOption(name,val) \
(guc_names = lappend(guc_names, pstrdup(name)), \
guc_values = lappend(guc_values, pstrdup(val)))
...
...
@@ -2969,6 +2975,15 @@ PostgresMain(int argc, char *argv[], const char *username)
*/
pgstat_bestart
();
/*
* Get stand-alone backend startup time
*/
if
(
!
IsUnderPostmaster
)
{
StartTimeSec
=
GetCurrentAbsoluteTimeUsec
(
&
StartTimeUSec
);
StartTime
=
AbsoluteTimeUsecToTimestampTz
(
StartTimeSec
,
StartTimeUSec
);
}
/*
* POSTGRES main processing loop begins here
*
...
...
src/backend/utils/adt/timestamp.c
View file @
f5835b4b
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.12
4 2005/05/26 02:04:13 neilc
Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/timestamp.c,v 1.12
5 2005/06/14 21:04:40 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -938,6 +938,12 @@ now(PG_FUNCTION_ARGS)
PG_RETURN_TIMESTAMPTZ
(
result
);
}
Datum
pgsql_postmaster_start_time
(
PG_FUNCTION_ARGS
)
{
PG_RETURN_TIMESTAMPTZ
(
StartTime
);
}
void
dt2time
(
Timestamp
jd
,
int
*
hour
,
int
*
min
,
int
*
sec
,
fsec_t
*
fsec
)
{
...
...
src/include/catalog/pg_proc.h
View file @
f5835b4b
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.36
6 2005/06/13 02:26:50 tgl
Exp $
* $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.36
7 2005/06/14 21:04:41 momjian
Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
...
...
@@ -3651,6 +3651,10 @@ DESCR("convert boolean to int4");
DATA
(
insert
OID
=
2559
(
lastval
PGNSP
PGUID
12
f
f
t
f
v
0
20
""
_null_
_null_
_null_
lastval
-
_null_
));
DESCR
(
"current value from last used sequence"
);
/* start time function */
DATA
(
insert
OID
=
2560
(
pg_postmaster_start_time
PGNSP
PGUID
12
f
f
t
f
s
0
1184
""
_null_
_null_
_null_
pgsql_postmaster_start_time
-
_null_
));
DESCR
(
"postmaster start time"
);
/*
* Symbolic values for provolatile column: these indicate whether the result
...
...
src/include/utils/timestamp.h
View file @
f5835b4b
...
...
@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.4
3 2005/05/25 21:40
:42 momjian Exp $
* $PostgreSQL: pgsql/src/include/utils/timestamp.h,v 1.4
4 2005/06/14 21:04
:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -256,6 +256,10 @@ extern Datum timestamptz_part(PG_FUNCTION_ARGS);
extern
Datum
now
(
PG_FUNCTION_ARGS
);
extern
Datum
pgsql_postmaster_start_time
(
PG_FUNCTION_ARGS
);
extern
TimestampTz
StartTime
;
/* Internal routines (not fmgr-callable) */
extern
int
tm2timestamp
(
struct
pg_tm
*
tm
,
fsec_t
fsec
,
int
*
tzp
,
Timestamp
*
dt
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment