Skip to content

Commit f071662

Browse files
committed
updated postgres_info.sql
1 parent 87457e3 commit f071662

File tree

1 file changed

+66
-66
lines changed

1 file changed

+66
-66
lines changed

postgres_info.sql

Lines changed: 66 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@
3232
-- version() returns a long human readable string, hence we split from others SELECTs eg.
3333
-- PostgreSQL 12.3 (Debian 12.3-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
3434
SELECT
35-
version(),
36-
current_setting('server_version') AS "server_version",
37-
current_setting('server_version_num') AS "server_version_num";
35+
version(),
36+
current_setting('server_version') AS "server_version",
37+
current_setting('server_version_num') AS "server_version_num";
3838

3939
-- ========================================================================== --
4040
-- S e r v e r D e t a i l s
@@ -44,18 +44,18 @@ SELECT
4444
--\pset title 'PostgreSQL Server Details'
4545

4646
SELECT
47-
pg_postmaster_start_time(),
48-
pg_conf_load_time(),
49-
current_setting('logging_collector') AS "logging_collector",
50-
current_setting('log_destination') AS "log_destination",
51-
-- not available in Postgres 9
52-
-- doesn't work because it still checks if pg_current_logfile() is valid and neither eval or execute seem to work around this
53-
-- CASE WHEN current_setting('server_version_num')::int > 100000 THEN pg_current_logfile() ELSE NULL END as pg_current_logfile
54-
pg_current_logfile()
55-
-- current_setting('log_directory') AS "log_directory", -- log
56-
-- current_setting('log_filename') AS "log_filename", -- postgresql-%Y-%m-%d_%H%M%S.log
57-
-- not available on Postgres 10
58-
--pg_jit_available()
47+
pg_postmaster_start_time(),
48+
pg_conf_load_time(),
49+
current_setting('logging_collector') AS "logging_collector",
50+
current_setting('log_destination') AS "log_destination",
51+
-- not available in Postgres 9
52+
-- doesn't work because it still checks if pg_current_logfile() is valid and neither eval or execute seem to work around this
53+
-- CASE WHEN current_setting('server_version_num')::int > 100000 THEN pg_current_logfile() ELSE NULL END as pg_current_logfile
54+
pg_current_logfile()
55+
-- current_setting('log_directory') AS "log_directory", -- log
56+
-- current_setting('log_filename') AS "log_filename", -- postgresql-%Y-%m-%d_%H%M%S.log
57+
-- not available on Postgres 10
58+
--pg_jit_available()
5959
;
6060

6161
-- SELECT pg_reload_conf(), pg_rotate_logfile();
@@ -87,18 +87,18 @@ SELECT
8787
--\pset title 'Config Files'
8888

8989
SELECT
90-
current_setting('config_file') AS "config_file",
91-
current_setting('hba_file') AS "hba_file",
92-
current_setting('ident_file') AS "ident_file";
90+
current_setting('config_file') AS "config_file",
91+
current_setting('hba_file') AS "hba_file",
92+
current_setting('ident_file') AS "ident_file";
9393

9494
\echo
9595
--\pset title 'PostgreSQL Data Directory & Unix Sockets'
9696

9797
SELECT
98-
current_setting('data_directory') AS "data_directory",
99-
current_setting('unix_socket_directories') AS "unix_socket_directories",
100-
current_setting('unix_socket_permissions') AS "unix_socket_permissions",
101-
current_setting('unix_socket_group') AS "unix_socket_group";
98+
current_setting('data_directory') AS "data_directory",
99+
current_setting('unix_socket_directories') AS "unix_socket_directories",
100+
current_setting('unix_socket_permissions') AS "unix_socket_permissions",
101+
current_setting('unix_socket_group') AS "unix_socket_group";
102102

103103
-- ========================================================================== --
104104
-- B u f f e r s & C o n n e c t i o n s
@@ -108,13 +108,13 @@ SELECT
108108
--\pset title 'Buffers & Connections'
109109

110110
SELECT
111-
current_setting('shared_buffers') AS "shared_buffers",
112-
current_setting('work_mem') AS "work_mem",
113-
current_setting('max_connections') AS "max_connections",
114-
current_setting('max_files_per_process') AS "max_files_per_process", -- should be less than ulimit nofiles to avoid “Too many open files” failures
115-
current_setting('track_activities') AS "track_activities", -- for pg_stat / pg_statio family of system views that are used in many other adjacent scripts
116-
current_setting('track_counts') AS "track_counts", -- needed for the autovacuum daemon
117-
current_setting('password_encryption') AS "password_encryption";
111+
current_setting('shared_buffers') AS "shared_buffers",
112+
current_setting('work_mem') AS "work_mem",
113+
current_setting('max_connections') AS "max_connections",
114+
current_setting('max_files_per_process') AS "max_files_per_process", -- should be less than ulimit nofiles to avoid “Too many open files” failures
115+
current_setting('track_activities') AS "track_activities", -- for pg_stat / pg_statio family of system views that are used in many other adjacent scripts
116+
current_setting('track_counts') AS "track_counts", -- needed for the autovacuum daemon
117+
current_setting('password_encryption') AS "password_encryption";
118118

119119

120120
-- ========================================================================== --
@@ -126,12 +126,12 @@ SELECT
126126

127127
-- in SQL the following have special syntax and should be called without parens: current_catalog, current_role, current_schema, current_user, session_user
128128
SELECT
129-
current_user, -- aka user, current_role - this is the effective user for permission checking
130-
session_user, -- connection user before superuser SET SESSION AUTHORIZATION
131-
current_schema,
132-
current_catalog, -- SQL standard, same as current_database()
133-
pg_backend_pid(),
134-
current_query();
129+
current_user, -- aka user, current_role - this is the effective user for permission checking
130+
session_user, -- connection user before superuser SET SESSION AUTHORIZATION
131+
current_schema,
132+
current_catalog, -- SQL standard, same as current_database()
133+
pg_backend_pid(),
134+
current_query();
135135

136136
\echo
137137
--\pset title 'Schema search list'
@@ -147,16 +147,16 @@ SELECT current_schemas(true) AS "current_schemas(true) - auto-searched schemas";
147147
--\pset title 'Backup & Recovery'
148148

149149
SELECT
150-
pg_is_in_backup(),
151-
pg_is_in_recovery(),
152-
pg_backup_start_time(),
153-
'see postgres_recovery.sql for more info' AS "info";
154-
-- use postgres_recovery.sql instead of having a big blank table distracting us here
155-
-- the following recovery control functions can only be executed during recovery - to get just the above use postgres_funcs.sql
156-
--( CASE WHEN pg_is_in_recovery() THEN pg_is_wal_replay_paused() END) AS "pg_is_wal_replay_paused()",
157-
--( CASE WHEN pg_is_in_recovery() THEN pg_last_wal_receive_lsn() END) AS "pg_last_wal_receive_lsn()",
158-
--( CASE WHEN pg_is_in_recovery() THEN pg_last_wal_replay_lsn() END) AS "pg_last_wal_replay_lsn()",
159-
--( CASE WHEN pg_is_in_recovery() THEN pg_last_xact_replay_timestamp() END) AS "pg_last_xact_replay_timestamp()"
150+
pg_is_in_backup(),
151+
pg_is_in_recovery(),
152+
pg_backup_start_time(),
153+
'see postgres_recovery.sql for more info' AS "info";
154+
-- use postgres_recovery.sql instead of having a big blank table distracting us here
155+
-- the following recovery control functions can only be executed during recovery - to get just the above use postgres_funcs.sql
156+
--( CASE WHEN pg_is_in_recovery() THEN pg_is_wal_replay_paused() END) AS "pg_is_wal_replay_paused()",
157+
--( CASE WHEN pg_is_in_recovery() THEN pg_last_wal_receive_lsn() END) AS "pg_last_wal_receive_lsn()",
158+
--( CASE WHEN pg_is_in_recovery() THEN pg_last_wal_replay_lsn() END) AS "pg_last_wal_replay_lsn()",
159+
--( CASE WHEN pg_is_in_recovery() THEN pg_last_xact_replay_timestamp() END) AS "pg_last_xact_replay_timestamp()"
160160

161161
--SELECT
162162
-- pg_ls_logdir(),
@@ -173,10 +173,10 @@ SELECT
173173
--\pset title 'Networking'
174174

175175
SELECT
176-
inet_client_addr(),
177-
inet_client_addr(),
178-
inet_server_addr(),
179-
inet_server_port();
176+
inet_client_addr(),
177+
inet_client_addr(),
178+
inet_server_addr(),
179+
inet_server_port();
180180

181181
-- causes 0 rows when mixed with other select funcs
182182
--SELECT pg_listening_channels();
@@ -193,23 +193,23 @@ SELECT
193193
--\pset title 'Date & Time'
194194

195195
SELECT
196-
-- current timestamps even inside transactions/functions
197-
now(),
198-
timeofday(), -- human string timestamp with timezone
199-
200-
-- at start of current transaction for consistency, includes +offset timezone
201-
current_timestamp(2) AS "current_timestamp(2)", -- secs precision of 2 decimal places, includes +offset timezone
202-
current_date,
203-
current_time(1) AS "current_time(1)", -- includes +offset timezone
204-
localtime,
205-
localtimestamp(1) AS "localtimestamp(1)",
206-
207-
-- provide current timestamps even inside transactions/functions
208-
-- now()
209-
-- timeofday(), -- human string timestamp with timezone
210-
clock_timestamp(), -- current date + time (changes throughout function)
211-
statement_timestamp(),
212-
transaction_timestamp() -- same as CURRENT_TIMESTAMP
196+
-- current timestamps even inside transactions/functions
197+
now(),
198+
timeofday(), -- human string timestamp with timezone
199+
200+
-- at start of current transaction for consistency, includes +offset timezone
201+
current_timestamp(2) AS "current_timestamp(2)", -- secs precision of 2 decimal places, includes +offset timezone
202+
current_date,
203+
current_time(1) AS "current_time(1)", -- includes +offset timezone
204+
localtime,
205+
localtimestamp(1) AS "localtimestamp(1)",
206+
207+
-- provide current timestamps even inside transactions/functions
208+
-- now()
209+
-- timeofday(), -- human string timestamp with timezone
210+
clock_timestamp(), -- current date + time (changes throughout function)
211+
statement_timestamp(),
212+
transaction_timestamp() -- same as CURRENT_TIMESTAMP
213213
;
214214

215215
--\pset title

0 commit comments

Comments
 (0)