## Michael Paquier (mich...@paquier.xyz): > Thanks Iwata-san. I was just trying to apply the patch but it failed so > the new status is fine. On top of taking care of the rebase, please > make sure of the following:
OK, that was an easy one. > - Calling pg_ls_dir_files() with missing_ok set to true. Done. > - Renaming pg_ls_archive_status to pg_ls_archive_statusdir. Done. > + last modified time (mtime) of each file in the write ahead log (WAL) > + <literal>archive_status</literal> directory. By default only superusers > Here I would mention pg_wal/archive_status. Done. Attached is the updated patch. I made sure the function's OID hadn't been taken otherwise, and it compiles and works in a quick check. Regards, Christoph -- Spare Space.
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index f984d069e1..3573896120 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -20357,6 +20357,18 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); </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> </entry> <entry><type>setof record</type></entry> @@ -20443,6 +20455,18 @@ postgres=# SELECT * FROM pg_walfile_name_offset(pg_stop_backup()); </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 write ahead log (WAL) + <literal>pg_wal/archive_status</literal> directory. 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> <para> diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql index 020f28cbf6..0c1bcebb0d 100644 --- a/src/backend/catalog/system_views.sql +++ b/src/backend/catalog/system_views.sql @@ -1150,6 +1150,7 @@ REVOKE EXECUTE ON FUNCTION lo_export(oid, text) FROM public; 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; @@ -1172,6 +1173,7 @@ REVOKE EXECUTE ON FUNCTION pg_ls_dir(text,boolean,boolean) 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; diff --git a/src/backend/utils/adt/genfile.c b/src/backend/utils/adt/genfile.c index 85bea8d502..a3d60ae31f 100644 --- a/src/backend/utils/adt/genfile.c +++ b/src/backend/utils/adt/genfile.c @@ -658,3 +658,10 @@ pg_ls_tmpdir_1arg(PG_FUNCTION_ARGS) { 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); +} diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat index 963ff6848a..28240d6331 100644 --- a/src/include/catalog/pg_proc.dat +++ b/src/include/catalog/pg_proc.dat @@ -10200,6 +10200,11 @@ provolatile => 'v', prorettype => 'record', proargtypes => '', proallargtypes => '{text,int8,timestamptz}', proargmodes => '{o,o,o}', proargnames => '{name,size,modification}', prosrc => 'pg_ls_waldir' }, +{ oid => '3996', 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 => '',