This function lists the contents of the WAL archive status directory,
and is intended to be used by monitoring tools. Unlike pg_ls_dir(),
access to it can be granted to non-superusers so that those monitoring
tools can observe the principle of least privilege. Access is also
given by default to members of pg_monitor.
Author: Christoph Moench-Tegeder
Reviewed-by: Aya Iwata
Discussion: https://postgr.es/m/
20180930205920.GA64534@elch.exwg.net
role and may be granted to other non-superuser roles.
</entry>
</row>
+ <row>
+ <entry>
+ <literal><function>pg_ls_archive_statusdir()</function></literal>
+ </entry>
+ <entry><type>setof record</type></entry>
+ <entry>
+ List the name, size, and last modification time of files in the WAL
+ archive status directory. Access is granted to members of the
+ <literal>pg_monitor</literal> role and may be granted to other
+ non-superuser roles.
+ </entry>
+ </row>
<row>
<entry>
<literal><function>pg_ls_tmpdir(<optional><parameter>tablespace</parameter> <type>oid</type></optional>)</function></literal>
<command>GRANT</command>.
</para>
+ <indexterm>
+ <primary>pg_ls_archive_statusdir</primary>
+ </indexterm>
+ <para>
+ <function>pg_ls_archive_statusdir</function> returns the name, size, and
+ last modified time (mtime) of each file in the WAL archive status
+ directory <literal>pg_wal/archive_status</literal>. By default only
+ superusers and members of the <literal>pg_monitor</literal> role can
+ use this function. Access may be granted to others using
+ <command>GRANT</command>.
+ </para>
+
<indexterm>
<primary>pg_ls_tmpdir</primary>
</indexterm>
REVOKE EXECUTE ON FUNCTION pg_ls_logdir() FROM public;
REVOKE EXECUTE ON FUNCTION pg_ls_waldir() FROM public;
+REVOKE EXECUTE ON FUNCTION pg_ls_archive_statusdir() FROM public;
REVOKE EXECUTE ON FUNCTION pg_ls_tmpdir() FROM public;
REVOKE EXECUTE ON FUNCTION pg_ls_tmpdir(oid) FROM public;
--
GRANT EXECUTE ON FUNCTION pg_ls_logdir() TO pg_monitor;
GRANT EXECUTE ON FUNCTION pg_ls_waldir() TO pg_monitor;
+GRANT EXECUTE ON FUNCTION pg_ls_archive_statusdir() TO pg_monitor;
GRANT EXECUTE ON FUNCTION pg_ls_tmpdir() TO pg_monitor;
GRANT EXECUTE ON FUNCTION pg_ls_tmpdir(oid) TO pg_monitor;
{
return pg_ls_tmpdir(fcinfo, PG_GETARG_OID(0));
}
+
+/*
+ * Function to return the list of files in the WAL archive status directory.
+ */
+Datum
+pg_ls_archive_statusdir(PG_FUNCTION_ARGS)
+{
+ return pg_ls_dir_files(fcinfo, XLOGDIR "/archive_status", true);
+}
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 201810061
+#define CATALOG_VERSION_NO 201810091
#endif
provolatile => 'v', prorettype => 'record', proargtypes => '',
proallargtypes => '{text,int8,timestamptz}', proargmodes => '{o,o,o}',
proargnames => '{name,size,modification}', prosrc => 'pg_ls_waldir' },
+{ oid => '5031', descr => 'list of files in the archive_status directory',
+ proname => 'pg_ls_archive_statusdir', procost => '10', prorows => '20', proretset => 't',
+ provolatile => 'v', prorettype => 'record', proargtypes => '',
+ proallargtypes => '{text,int8,timestamptz}', proargmodes => '{o,o,o}',
+ proargnames => '{name,size,modification}', prosrc => 'pg_ls_archive_statusdir' },
{ oid => '5029', descr => 'list files in the pgsql_tmp directory',
proname => 'pg_ls_tmpdir', procost => '10', prorows => '20', proretset => 't',
provolatile => 'v', prorettype => 'record', proargtypes => '',