mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -19646,7 +19646,8 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
database cluster directory and the <varname>log_directory</> can be
|
||||
accessed. Use a relative path for files in the cluster directory,
|
||||
and a path matching the <varname>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.
|
||||
</para>
|
||||
|
||||
<table id="functions-admin-genfile-table">
|
||||
@ -19667,6 +19668,26 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
List the contents of a directory.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_ls_logdir()</function></literal>
|
||||
</entry>
|
||||
<entry><type>setof record</type></entry>
|
||||
<entry>
|
||||
List the name, size, and last modification time of files in the log
|
||||
directory. Access may be granted to non-superuser roles.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_ls_waldir()</function></literal>
|
||||
</entry>
|
||||
<entry><type>setof record</type></entry>
|
||||
<entry>
|
||||
List the name, size, and last modification time of files in the WAL
|
||||
directory. Access may be granted to non-superuser roles.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<literal><function>pg_read_file(<parameter>filename</> <type>text</> [, <parameter>offset</> <type>bigint</>, <parameter>length</> <type>bigint</> [, <parameter>missing_ok</> <type>boolean</>] ])</function></literal>
|
||||
@ -19699,7 +19720,7 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup());
|
||||
</table>
|
||||
|
||||
<para>
|
||||
All of these functions take an optional <parameter>missing_ok</> parameter,
|
||||
Some of these functions take an optional <parameter>missing_ok</> parameter,
|
||||
which specifies the behavior when the file or directory does not exist.
|
||||
If <literal>true</literal>, the function returns NULL (except
|
||||
<function>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.
|
||||
</para>
|
||||
|
||||
<indexterm>
|
||||
<primary>pg_ls_logdir</primary>
|
||||
</indexterm>
|
||||
<para>
|
||||
<function>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
|
||||
<command>GRANT</command>.
|
||||
</para>
|
||||
|
||||
<indexterm>
|
||||
<primary>pg_ls_waldir</primary>
|
||||
</indexterm>
|
||||
<para>
|
||||
<function>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 <command>GRANT</command>.
|
||||
</para>
|
||||
|
||||
<indexterm>
|
||||
<primary>pg_read_file</primary>
|
||||
</indexterm>
|
||||
|
Reference in New Issue
Block a user