From befd73c50f11a6c6a6719dae20f0de7b7585bef4 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 16 Mar 2017 15:05:02 -0400 Subject: Add pg_ls_logdir() and pg_ls_waldir() functions. These functions are intended to be used by monitoring tools, and, unlike pg_ls_dir(), access to them can be granted to non-superusers, so that those monitoring tools can observe the principle of least privilege. Dave Page, revised by me, and also reviewed a bit by Thomas Munro. Discussion: http://postgr.es/m/CA+OCxow-X=D2fWdKy+HP+vQ1LtrgbsYQ=CshzZBqyFT5jOYrFw@mail.gmail.com --- doc/src/sgml/func.sgml | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index a521912317b..9518fa20388 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -19646,7 +19646,8 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); database cluster directory and the log_directory can be accessed. Use a relative path for files in the cluster directory, and a path matching the log_directory configuration setting - for log files. Use of these functions is restricted to superusers. + for log files. Use of these functions is restricted to superusers + except where stated otherwise. @@ -19667,6 +19668,26 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); List the contents of a directory. + + + pg_ls_logdir() + + setof record + + List the name, size, and last modification time of files in the log + directory. Access may be granted to non-superuser roles. + + + + + pg_ls_waldir() + + setof record + + List the name, size, and last modification time of files in the WAL + directory. Access may be granted to non-superuser roles. + + pg_read_file(filename text [, offset bigint, length bigint [, missing_ok boolean] ]) @@ -19699,7 +19720,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
- All of these functions take an optional missing_ok parameter, + Some of these functions take an optional missing_ok parameter, which specifies the behavior when the file or directory does not exist. If true, the function returns NULL (except pg_ls_dir, which returns an empty result set). If @@ -19719,6 +19740,26 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); empty directory from an non-existent directory. + + pg_ls_logdir + + + pg_ls_logdir returns the name, size, and last modified time + (mtime) of each file in the log directory. By default, only superusers + can use this function, but access may be granted to others using + GRANT. + + + + pg_ls_waldir + + + pg_ls_waldir returns the name, size, and last modified time + (mtime) of each file in the write ahead log (WAL) directory. By + default only superusers can use this function, but access may be granted + to others using GRANT. + + pg_read_file -- cgit v1.2.3