2010-09-20 22:08:53 +02:00
|
|
|
<!-- doc/src/sgml/adminpack.sgml -->
|
2007-12-06 05:12:10 +01:00
|
|
|
|
2011-05-08 04:29:20 +02:00
|
|
|
<sect1 id="adminpack" xreflabel="adminpack">
|
2007-11-11 00:30:46 +01:00
|
|
|
<title>adminpack</title>
|
2007-12-06 05:12:10 +01:00
|
|
|
|
2007-12-02 23:33:20 +01:00
|
|
|
<indexterm zone="adminpack">
|
|
|
|
<primary>adminpack</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
2007-11-11 00:30:46 +01:00
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<filename>adminpack</filename> provides a number of support functions which
|
|
|
|
<application>pgAdmin</application> and other administration and management tools can
|
2007-12-06 05:12:10 +01:00
|
|
|
use to provide additional functionality, such as remote management
|
|
|
|
of server log files.
|
2018-04-06 20:47:10 +02:00
|
|
|
Use of all these functions is only allowed to the superuser by default but may be
|
|
|
|
allowed to other users by using the <command>GRANT</command> command.
|
2007-11-11 00:30:46 +01:00
|
|
|
</para>
|
|
|
|
|
2016-08-11 03:39:50 +02:00
|
|
|
<para>
|
2017-11-23 15:39:47 +01:00
|
|
|
The functions shown in <xref linkend="functions-adminpack-table"/> provide
|
2016-08-11 03:39:50 +02:00
|
|
|
write access to files on the machine hosting the server. (See also the
|
2017-11-23 15:39:47 +01:00
|
|
|
functions in <xref linkend="functions-admin-genfile-table"/>, which
|
2016-08-11 03:39:50 +02:00
|
|
|
provide read-only access.)
|
2018-04-06 20:47:10 +02:00
|
|
|
Only files within the database cluster directory can be accessed, unless the
|
2022-04-16 09:05:07 +02:00
|
|
|
user is a superuser or given privileges of one of the pg_read_server_files,
|
2022-03-28 21:10:04 +02:00
|
|
|
or pg_write_server_files roles, as appropriate for the function, but either a
|
|
|
|
relative or absolute path is allowable.
|
2016-08-11 03:39:50 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<table id="functions-adminpack-table">
|
2017-10-09 03:44:17 +02:00
|
|
|
<title><filename>adminpack</filename> Functions</title>
|
2020-05-07 20:25:18 +02:00
|
|
|
<tgroup cols="1">
|
|
|
|
<thead>
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
Function
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Description
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
</thead>
|
2007-12-06 05:12:10 +01:00
|
|
|
|
2020-05-07 20:25:18 +02:00
|
|
|
<tbody>
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>pg_catalog.pg_file_write</function> ( <parameter>filename</parameter> <type>text</type>, <parameter>data</parameter> <type>text</type>, <parameter>append</parameter> <type>boolean</type> )
|
|
|
|
<returnvalue>bigint</returnvalue>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Writes, or appends to, a text file.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>pg_catalog.pg_file_sync</function> ( <parameter>filename</parameter> <type>text</type> )
|
|
|
|
<returnvalue>void</returnvalue>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Flushes a file or directory to disk.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>pg_catalog.pg_file_rename</function> ( <parameter>oldname</parameter> <type>text</type>, <parameter>newname</parameter> <type>text</type> <optional>, <parameter>archivename</parameter> <type>text</type> </optional> )
|
|
|
|
<returnvalue>boolean</returnvalue>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Renames a file.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>pg_catalog.pg_file_unlink</function> ( <parameter>filename</parameter> <type>text</type> )
|
|
|
|
<returnvalue>boolean</returnvalue>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Removes a file.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
|
|
|
|
<row>
|
|
|
|
<entry role="func_table_entry"><para role="func_signature">
|
|
|
|
<function>pg_catalog.pg_logdir_ls</function> ()
|
|
|
|
<returnvalue>setof record</returnvalue>
|
|
|
|
</para>
|
|
|
|
<para>
|
|
|
|
Lists the log files in the <varname>log_directory</varname> directory.
|
|
|
|
</para></entry>
|
|
|
|
</row>
|
|
|
|
</tbody>
|
2016-08-11 03:39:50 +02:00
|
|
|
</tgroup>
|
|
|
|
</table>
|
|
|
|
|
|
|
|
<indexterm>
|
|
|
|
<primary>pg_file_write</primary>
|
|
|
|
</indexterm>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<function>pg_file_write</function> writes the specified <parameter>data</parameter> into
|
|
|
|
the file named by <parameter>filename</parameter>. If <parameter>append</parameter> is
|
|
|
|
false, the file must not already exist. If <parameter>append</parameter> is true,
|
2016-08-11 03:39:50 +02:00
|
|
|
the file can already exist, and will be appended to if so.
|
|
|
|
Returns the number of bytes written.
|
|
|
|
</para>
|
|
|
|
|
2020-01-24 12:42:52 +01:00
|
|
|
<indexterm>
|
|
|
|
<primary>pg_file_sync</primary>
|
|
|
|
</indexterm>
|
|
|
|
<para>
|
|
|
|
<function>pg_file_sync</function> fsyncs the specified file or directory
|
|
|
|
named by <parameter>filename</parameter>. An error is thrown
|
|
|
|
on failure (e.g., the specified file is not present). Note that
|
|
|
|
<xref linkend="guc-data-sync-retry"/> has no effect on this function,
|
|
|
|
and therefore a PANIC-level error will not be raised even on failure to
|
|
|
|
flush database files.
|
|
|
|
</para>
|
|
|
|
|
2016-08-11 03:39:50 +02:00
|
|
|
<indexterm>
|
|
|
|
<primary>pg_file_rename</primary>
|
|
|
|
</indexterm>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<function>pg_file_rename</function> renames a file. If <parameter>archivename</parameter>
|
|
|
|
is omitted or NULL, it simply renames <parameter>oldname</parameter>
|
|
|
|
to <parameter>newname</parameter> (which must not already exist).
|
|
|
|
If <parameter>archivename</parameter> is provided, it first
|
|
|
|
renames <parameter>newname</parameter> to <parameter>archivename</parameter> (which must
|
|
|
|
not already exist), and then renames <parameter>oldname</parameter>
|
|
|
|
to <parameter>newname</parameter>. In event of failure of the second rename step,
|
|
|
|
it will try to rename <parameter>archivename</parameter> back
|
|
|
|
to <parameter>newname</parameter> before reporting the error.
|
2016-08-11 03:39:50 +02:00
|
|
|
Returns true on success, false if the source file(s) are not present or
|
|
|
|
not writable; other cases throw errors.
|
|
|
|
</para>
|
2007-12-06 05:12:10 +01:00
|
|
|
|
2016-08-11 03:39:50 +02:00
|
|
|
<indexterm>
|
|
|
|
<primary>pg_file_unlink</primary>
|
|
|
|
</indexterm>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<function>pg_file_unlink</function> removes the specified file.
|
2016-08-11 03:39:50 +02:00
|
|
|
Returns true on success, false if the specified file is not present
|
2017-10-09 03:44:17 +02:00
|
|
|
or the <function>unlink()</function> call fails; other cases throw errors.
|
2016-08-11 03:39:50 +02:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<indexterm>
|
|
|
|
<primary>pg_logdir_ls</primary>
|
|
|
|
</indexterm>
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
<function>pg_logdir_ls</function> returns the start timestamps and path
|
2017-11-23 15:39:47 +01:00
|
|
|
names of all the log files in the <xref linkend="guc-log-directory"/>
|
|
|
|
directory. The <xref linkend="guc-log-filename"/> parameter must have its
|
2017-10-09 03:44:17 +02:00
|
|
|
default setting (<literal>postgresql-%Y-%m-%d_%H%M%S.log</literal>) to use this
|
2016-08-11 03:39:50 +02:00
|
|
|
function.
|
|
|
|
</para>
|
|
|
|
|
2007-11-11 00:30:46 +01:00
|
|
|
</sect1>
|