Sophie

Sophie

distrib > Mandriva > 2008.1 > x86_64 > media > main-testing > by-pkgid > bab02a23fa9f3df8d66a9a3231b50245 > files > 206

postgresql8.3-docs-8.3.6-2mdv2008.1.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>System Administration Functions</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 8.3.6 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="Functions and Operators"
HREF="functions.html"><LINK
REL="PREVIOUS"
TITLE="System Information Functions"
HREF="functions-info.html"><LINK
REL="NEXT"
TITLE="Type Conversion"
HREF="typeconv.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2009-02-03T04:34:16"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 8.3.6 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="functions-info.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="functions.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 9. Functions and Operators</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="functions.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="typeconv.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="FUNCTIONS-ADMIN"
>9.23. System Administration Functions</A
></H1
><P
>    <A
HREF="functions-admin.html#FUNCTIONS-ADMIN-SET-TABLE"
>Table 9-51</A
> shows the functions
    available to query and alter run-time configuration parameters.
   </P
><DIV
CLASS="TABLE"
><A
NAME="FUNCTIONS-ADMIN-SET-TABLE"
></A
><P
><B
>Table 9-51. Configuration Settings Functions</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Return Type</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>current_setting</CODE
>(<TT
CLASS="PARAMETER"
>setting_name</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>current value of setting</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>set_config(<TT
CLASS="PARAMETER"
>setting_name</TT
>,
                             <TT
CLASS="PARAMETER"
>new_value</TT
>,
                             <TT
CLASS="PARAMETER"
>is_local</TT
>)</CODE
></TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>set parameter and return new value</TD
></TR
></TBODY
></TABLE
></DIV
><A
NAME="AEN16581"
></A
><A
NAME="AEN16583"
></A
><A
NAME="AEN16585"
></A
><P
>    The function <CODE
CLASS="FUNCTION"
>current_setting</CODE
> yields the
    current value of the setting <TT
CLASS="PARAMETER"
>setting_name</TT
>.
    It corresponds to the <ACRONYM
CLASS="ACRONYM"
>SQL</ACRONYM
> command
    <TT
CLASS="COMMAND"
>SHOW</TT
>.  An example:
</P><PRE
CLASS="PROGRAMLISTING"
>SELECT current_setting('datestyle');

 current_setting
-----------------
 ISO, MDY
(1 row)</PRE
><P>
   </P
><P
>    <CODE
CLASS="FUNCTION"
>set_config</CODE
> sets the parameter
    <TT
CLASS="PARAMETER"
>setting_name</TT
> to
    <TT
CLASS="PARAMETER"
>new_value</TT
>.  If
    <TT
CLASS="PARAMETER"
>is_local</TT
> is <TT
CLASS="LITERAL"
>true</TT
>, the
    new value will only apply to the current transaction. If you want
    the new value to apply for the current session, use
    <TT
CLASS="LITERAL"
>false</TT
> instead. The function corresponds to the
    SQL command <TT
CLASS="COMMAND"
>SET</TT
>. An example:
</P><PRE
CLASS="PROGRAMLISTING"
>SELECT set_config('log_statement_stats', 'off', false);

 set_config
------------
 off
(1 row)</PRE
><P>
   </P
><A
NAME="AEN16604"
></A
><A
NAME="AEN16606"
></A
><A
NAME="AEN16608"
></A
><A
NAME="AEN16610"
></A
><P
>    The functions shown in <A
HREF="functions-admin.html#FUNCTIONS-ADMIN-SIGNAL-TABLE"
>Table 9-52</A
> send control signals to
    other server processes.  Use of these functions is restricted
    to superusers.
   </P
><DIV
CLASS="TABLE"
><A
NAME="FUNCTIONS-ADMIN-SIGNAL-TABLE"
></A
><P
><B
>Table 9-52. Server Signalling Functions</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Return Type</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_cancel_backend</CODE
>(<TT
CLASS="PARAMETER"
>pid</TT
> <TT
CLASS="TYPE"
>int</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Cancel a backend's current query</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_reload_conf</CODE
>()</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Cause server processes to reload their configuration files</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_rotate_logfile</CODE
>()</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Rotate server's log file</TD
></TR
></TBODY
></TABLE
></DIV
><P
>    Each of these functions returns <TT
CLASS="LITERAL"
>true</TT
> if
    successful and <TT
CLASS="LITERAL"
>false</TT
> otherwise.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_cancel_backend</CODE
> sends a query cancel
    (<SPAN
CLASS="SYSTEMITEM"
>SIGINT</SPAN
>) signal to a backend process identified by
    process ID.  The process ID of an active backend can be found from
    the <TT
CLASS="STRUCTFIELD"
>procpid</TT
> column in the
    <TT
CLASS="STRUCTNAME"
>pg_stat_activity</TT
> view, or by listing the
    <TT
CLASS="COMMAND"
>postgres</TT
> processes on the server with
    <SPAN
CLASS="APPLICATION"
>ps</SPAN
>.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_reload_conf</CODE
> sends a <SPAN
CLASS="SYSTEMITEM"
>SIGHUP</SPAN
> signal
    to the server, causing the configuration files
    to be reloaded by all server processes.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_rotate_logfile</CODE
> signals the log-file manager to switch
    to a new output file immediately.  This works only when the built-in
    log collector is running, since otherwise there is no log-file manager 
    subprocess.
   </P
><A
NAME="AEN16662"
></A
><A
NAME="AEN16664"
></A
><A
NAME="AEN16666"
></A
><A
NAME="AEN16668"
></A
><A
NAME="AEN16670"
></A
><A
NAME="AEN16672"
></A
><A
NAME="AEN16674"
></A
><A
NAME="AEN16676"
></A
><P
>    The functions shown in <A
HREF="functions-admin.html#FUNCTIONS-ADMIN-BACKUP-TABLE"
>Table 9-53</A
> assist in making on-line backups.
    Use of the first three functions is restricted to superusers.
   </P
><DIV
CLASS="TABLE"
><A
NAME="FUNCTIONS-ADMIN-BACKUP-TABLE"
></A
><P
><B
>Table 9-53. Backup Control Functions</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Return Type</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_start_backup</CODE
>(<TT
CLASS="PARAMETER"
>label</TT
> <TT
CLASS="TYPE"
>text</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>Set up for performing on-line backup</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stop_backup</CODE
>()</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>Finish performing on-line backup</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_switch_xlog</CODE
>()</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>Force switch to a new transaction log file</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_current_xlog_location</CODE
>()</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>Get current transaction log write location</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_current_xlog_insert_location</CODE
>()</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>Get current transaction log insert location</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_xlogfile_name_offset</CODE
>(<TT
CLASS="PARAMETER"
>location</TT
> <TT
CLASS="TYPE"
>text</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>text</TT
>, <TT
CLASS="TYPE"
>integer</TT
></TD
><TD
>Convert transaction log location string to file name and decimal byte offset within file</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_xlogfile_name</CODE
>(<TT
CLASS="PARAMETER"
>location</TT
> <TT
CLASS="TYPE"
>text</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>Convert transaction log location string to file name</TD
></TR
></TBODY
></TABLE
></DIV
><P
>    <CODE
CLASS="FUNCTION"
>pg_start_backup</CODE
> accepts a single parameter which is an
    arbitrary user-defined label for the backup.  (Typically this would be
    the name under which the backup dump file will be stored.)  The function
    writes a backup label file into the database cluster's data directory,
    and then returns the backup's starting transaction log location as text.  The user
    need not pay any attention to this result value, but it is provided in
    case it is of use. 
</P><PRE
CLASS="PROGRAMLISTING"
>postgres=# select pg_start_backup('label_goes_here');
 pg_start_backup
-----------------
 0/D4445B8
(1 row)</PRE
><P>
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_stop_backup</CODE
> removes the label file created by
    <CODE
CLASS="FUNCTION"
>pg_start_backup</CODE
>, and instead creates a backup history file in
    the transaction log archive area.  The history file includes the label given to
    <CODE
CLASS="FUNCTION"
>pg_start_backup</CODE
>, the starting and ending transaction log locations for
    the backup, and the starting and ending times of the backup.  The return
    value is the backup's ending transaction log location (which again might be of little
    interest).  After noting the ending location, the current transaction log insertion
    point is automatically advanced to the next transaction log file, so that the
    ending transaction log file can be archived immediately to complete the backup.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_switch_xlog</CODE
> moves to the next transaction log file, allowing the 
    current file to be archived (assuming you are using continuous archiving).
    The result is the ending transaction log location + 1 within the just-completed transaction log file.
    If there has been no transaction log activity since the last transaction log switch,
    <CODE
CLASS="FUNCTION"
>pg_switch_xlog</CODE
> does nothing and returns the start location
    of the transaction log file currently in use.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_current_xlog_location</CODE
> displays the current transaction log write
    location in the same format used by the above functions.  Similarly,
    <CODE
CLASS="FUNCTION"
>pg_current_xlog_insert_location</CODE
> displays the current transaction log
    insertion point.  The insertion point is the <SPAN
CLASS="QUOTE"
>"logical"</SPAN
> end
    of the transaction log
    at any instant, while the write location is the end of what has actually
    been written out from the server's internal buffers.  The write location
    is the end of what can be examined from outside the server, and is usually
    what you want if you are interested in archiving partially-complete transaction log
    files.  The insertion point is made available primarily for server
    debugging purposes.  These are both read-only operations and do not
    require superuser permissions.
   </P
><P
>    You can use <CODE
CLASS="FUNCTION"
>pg_xlogfile_name_offset</CODE
> to extract the
    corresponding transaction log file name and byte offset from the results of any of the
    above functions.  For example:
</P><PRE
CLASS="PROGRAMLISTING"
>postgres=# select * from pg_xlogfile_name_offset(pg_stop_backup());
        file_name         | file_offset 
--------------------------+-------------
 00000001000000000000000D |     4039624
(1 row)</PRE
><P>
    Similarly, <CODE
CLASS="FUNCTION"
>pg_xlogfile_name</CODE
> extracts just the transaction log file name.
    When the given transaction log location is exactly at a transaction log file boundary, both
    these functions return the name of the preceding transaction log file.
    This is usually the desired behavior for managing transaction log archiving
    behavior, since the preceding file is the last one that currently
    needs to be archived.
   </P
><P
>    For details about proper usage of these functions, see
    <A
HREF="continuous-archiving.html"
>Section 24.3</A
>.
   </P
><P
>    The functions shown in <A
HREF="functions-admin.html#FUNCTIONS-ADMIN-DBSIZE"
>Table 9-54</A
> calculate
    the actual disk space usage of database objects.
   </P
><A
NAME="AEN16767"
></A
><A
NAME="AEN16769"
></A
><A
NAME="AEN16771"
></A
><A
NAME="AEN16773"
></A
><A
NAME="AEN16775"
></A
><A
NAME="AEN16777"
></A
><DIV
CLASS="TABLE"
><A
NAME="FUNCTIONS-ADMIN-DBSIZE"
></A
><P
><B
>Table 9-54. Database Object Size Functions</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Return Type</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><CODE
CLASS="FUNCTION"
>pg_column_size</CODE
>(<TT
CLASS="TYPE"
>any</TT
>)</TD
><TD
><TT
CLASS="TYPE"
>int</TT
></TD
><TD
>Number of bytes used to store a particular value (possibly compressed)</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_database_size</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>Disk space used by the database with the specified OID</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_database_size</CODE
>(<TT
CLASS="TYPE"
>name</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>Disk space used by the database with the specified name</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_relation_size</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>Disk space used by the table or index with the specified OID</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_relation_size</CODE
>(<TT
CLASS="TYPE"
>text</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>        Disk space used by the table or index with the specified name.
        The table name can be qualified with a schema name
       </TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_size_pretty</CODE
>(<TT
CLASS="TYPE"
>bigint</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>Converts a size in bytes into a human-readable format with size units</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_tablespace_size</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>Disk space used by the tablespace with the specified OID</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_tablespace_size</CODE
>(<TT
CLASS="TYPE"
>name</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>Disk space used by the tablespace with the specified name</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_total_relation_size</CODE
>(<TT
CLASS="TYPE"
>oid</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>        Total disk space used by the table with the specified OID,
        including indexes and toasted data
       </TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_total_relation_size</CODE
>(<TT
CLASS="TYPE"
>text</TT
>)</TT
>
        </TD
><TD
><TT
CLASS="TYPE"
>bigint</TT
></TD
><TD
>        Total disk space used by the table with the specified name,
        including indexes and toasted data.  The table name can be
        qualified with a schema name
       </TD
></TR
></TBODY
></TABLE
></DIV
><P
>    <CODE
CLASS="FUNCTION"
>pg_column_size</CODE
> shows the space used to store any individual
    data value.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_database_size</CODE
> and <CODE
CLASS="FUNCTION"
>pg_tablespace_size</CODE
>
    accept the OID or name of a database or tablespace, and return the total
    disk space used therein.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_relation_size</CODE
> accepts the OID or name of a table, index or
    toast table, and returns the size in bytes.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_size_pretty</CODE
> can be used to format the result of one of
    the other functions in a human-readable way, using kB, MB, GB or TB as
    appropriate.
   </P
><P
>    <CODE
CLASS="FUNCTION"
>pg_total_relation_size</CODE
> accepts the OID or name of a
    table or toast table, and returns the size in bytes of the data
    and all associated indexes and toast tables.
   </P
><P
>    The functions shown in <A
HREF="functions-admin.html#FUNCTIONS-ADMIN-GENFILE"
>Table 9-55</A
> provide native file access to
    files on the machine hosting the server. Only files within the
    database cluster directory and the <TT
CLASS="VARNAME"
>log_directory</TT
> can be
    accessed.  Use a relative path for files within the cluster directory,
    and a path matching the <TT
CLASS="VARNAME"
>log_directory</TT
> configuration setting
    for log files.  Use of these functions is restricted to superusers.
   </P
><DIV
CLASS="TABLE"
><A
NAME="FUNCTIONS-ADMIN-GENFILE"
></A
><P
><B
>Table 9-55. Generic File Access Functions</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Return Type</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_ls_dir</CODE
>(<TT
CLASS="PARAMETER"
>dirname</TT
> <TT
CLASS="TYPE"
>text</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>setof text</TT
></TD
><TD
>List the contents of a directory</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_read_file</CODE
>(<TT
CLASS="PARAMETER"
>filename</TT
> <TT
CLASS="TYPE"
>text</TT
>, <TT
CLASS="PARAMETER"
>offset</TT
> <TT
CLASS="TYPE"
>bigint</TT
>, <TT
CLASS="PARAMETER"
>length</TT
> <TT
CLASS="TYPE"
>bigint</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>Return the contents of a text file</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_stat_file</CODE
>(<TT
CLASS="PARAMETER"
>filename</TT
> <TT
CLASS="TYPE"
>text</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>record</TT
></TD
><TD
>Return information about a file</TD
></TR
></TBODY
></TABLE
></DIV
><A
NAME="AEN16922"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_ls_dir</CODE
> returns all the names in the specified
    directory, except the special entries <SPAN
CLASS="QUOTE"
>"<TT
CLASS="LITERAL"
>.</TT
>"</SPAN
> and
    <SPAN
CLASS="QUOTE"
>"<TT
CLASS="LITERAL"
>..</TT
>"</SPAN
>.
   </P
><A
NAME="AEN16930"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_read_file</CODE
> returns part of a text file, starting
    at the given <TT
CLASS="PARAMETER"
>offset</TT
>, returning at most <TT
CLASS="PARAMETER"
>length</TT
>
    bytes (less if the end of file is reached first).  If <TT
CLASS="PARAMETER"
>offset</TT
>
    is negative, it is relative to the end of the file.
   </P
><A
NAME="AEN16937"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_stat_file</CODE
> returns a record containing the file
    size, last accessed time stamp, last modified time stamp,
    last file status change time stamp (Unix platforms only),
    file creation time stamp (Windows only), and a <TT
CLASS="TYPE"
>boolean</TT
>
    indicating if it is a directory.  Typical usages include:
</P><PRE
CLASS="PROGRAMLISTING"
>SELECT * FROM pg_stat_file('filename');
SELECT (pg_stat_file('filename')).modification;</PRE
><P>
   </P
><P
>    The functions shown in <A
HREF="functions-admin.html#FUNCTIONS-ADVISORY-LOCKS"
>Table 9-56</A
> manage
    advisory locks.  For details about proper usage of these functions, see
    <A
HREF="explicit-locking.html#ADVISORY-LOCKS"
>Section 13.3.4</A
>.
   </P
><DIV
CLASS="TABLE"
><A
NAME="FUNCTIONS-ADVISORY-LOCKS"
></A
><P
><B
>Table 9-56. Advisory Lock Functions</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Return Type</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_lock</CODE
>(<TT
CLASS="PARAMETER"
>key</TT
> <TT
CLASS="TYPE"
>bigint</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>Obtain exclusive advisory lock</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_lock</CODE
>(<TT
CLASS="PARAMETER"
>key1</TT
> <TT
CLASS="TYPE"
>int</TT
>, <TT
CLASS="PARAMETER"
>key2</TT
> <TT
CLASS="TYPE"
>int</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>Obtain exclusive advisory lock</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_lock_shared</CODE
>(<TT
CLASS="PARAMETER"
>key</TT
> <TT
CLASS="TYPE"
>bigint</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>Obtain shared advisory lock</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_lock_shared</CODE
>(<TT
CLASS="PARAMETER"
>key1</TT
> <TT
CLASS="TYPE"
>int</TT
>, <TT
CLASS="PARAMETER"
>key2</TT
> <TT
CLASS="TYPE"
>int</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>Obtain shared advisory lock</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_try_advisory_lock</CODE
>(<TT
CLASS="PARAMETER"
>key</TT
> <TT
CLASS="TYPE"
>bigint</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Obtain exclusive advisory lock if available</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_try_advisory_lock</CODE
>(<TT
CLASS="PARAMETER"
>key1</TT
> <TT
CLASS="TYPE"
>int</TT
>, <TT
CLASS="PARAMETER"
>key2</TT
> <TT
CLASS="TYPE"
>int</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Obtain exclusive advisory lock if available</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_try_advisory_lock_shared</CODE
>(<TT
CLASS="PARAMETER"
>key</TT
> <TT
CLASS="TYPE"
>bigint</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Obtain shared advisory lock if available</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_try_advisory_lock_shared</CODE
>(<TT
CLASS="PARAMETER"
>key1</TT
> <TT
CLASS="TYPE"
>int</TT
>, <TT
CLASS="PARAMETER"
>key2</TT
> <TT
CLASS="TYPE"
>int</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Obtain shared advisory lock if available</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_unlock</CODE
>(<TT
CLASS="PARAMETER"
>key</TT
> <TT
CLASS="TYPE"
>bigint</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Release an exclusive advisory lock</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_unlock</CODE
>(<TT
CLASS="PARAMETER"
>key1</TT
> <TT
CLASS="TYPE"
>int</TT
>, <TT
CLASS="PARAMETER"
>key2</TT
> <TT
CLASS="TYPE"
>int</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Release an exclusive advisory lock</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_unlock_shared</CODE
>(<TT
CLASS="PARAMETER"
>key</TT
> <TT
CLASS="TYPE"
>bigint</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Release a shared advisory lock</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_unlock_shared</CODE
>(<TT
CLASS="PARAMETER"
>key1</TT
> <TT
CLASS="TYPE"
>int</TT
>, <TT
CLASS="PARAMETER"
>key2</TT
> <TT
CLASS="TYPE"
>int</TT
>)</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>Release a shared advisory lock</TD
></TR
><TR
><TD
>        <TT
CLASS="LITERAL"
><CODE
CLASS="FUNCTION"
>pg_advisory_unlock_all</CODE
>()</TT
>
       </TD
><TD
><TT
CLASS="TYPE"
>void</TT
></TD
><TD
>Release all advisory locks held by the current session</TD
></TR
></TBODY
></TABLE
></DIV
><A
NAME="AEN17082"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_advisory_lock</CODE
> locks an application-defined resource,
    which can be identified either by a single 64-bit key value or two
    32-bit key values (note that these two key spaces do not overlap).  If
    another session already holds a lock on the same resource, the
    function will wait until the resource becomes available.  The lock
    is exclusive.  Multiple lock requests stack, so that if the same resource
    is locked three times it must be also unlocked three times to be
    released for other sessions' use.
   </P
><A
NAME="AEN17086"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_advisory_lock_shared</CODE
> works the same as
    <CODE
CLASS="FUNCTION"
>pg_advisory_lock</CODE
>,
    except the lock can be shared with other sessions requesting shared locks.
    Only would-be exclusive lockers are locked out.
   </P
><A
NAME="AEN17091"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_try_advisory_lock</CODE
> is similar to
    <CODE
CLASS="FUNCTION"
>pg_advisory_lock</CODE
>, except the function will not wait for the
    lock to become available.  It will either obtain the lock immediately and
    return <TT
CLASS="LITERAL"
>true</TT
>, or return <TT
CLASS="LITERAL"
>false</TT
> if the lock cannot be
    acquired now.
   </P
><A
NAME="AEN17098"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_try_advisory_lock_shared</CODE
> works the same as
    <CODE
CLASS="FUNCTION"
>pg_try_advisory_lock</CODE
>, except it attempts to acquire
    shared rather than exclusive lock.
   </P
><A
NAME="AEN17103"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_advisory_unlock</CODE
> will release a previously-acquired
    exclusive advisory lock.  It
    will return <TT
CLASS="LITERAL"
>true</TT
> if the lock is successfully released.
    If the lock was in fact not held, it will return <TT
CLASS="LITERAL"
>false</TT
>,
    and in addition, an SQL warning will be raised by the server.
   </P
><A
NAME="AEN17109"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_advisory_unlock_shared</CODE
> works the same as
    <CODE
CLASS="FUNCTION"
>pg_advisory_unlock</CODE
>, 
    except to release a shared advisory lock.
   </P
><A
NAME="AEN17114"
></A
><P
>    <CODE
CLASS="FUNCTION"
>pg_advisory_unlock_all</CODE
> will release all advisory locks
    held by the current session.  (This function is implicitly invoked
    at session end, even if the client disconnects ungracefully.)
   </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="functions-info.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="typeconv.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>System Information Functions</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="functions.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Type Conversion</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>