# Enable some extra warnings
# -wfully-tagged needed to throw a warning on missing tags
# for older tool chains, 2007-08-31
-override SPFLAGS += -wall -wno-unused-param -wno-empty -wfully-tagged
+override SPFLAGS += -wall -wno-unused-param -wfully-tagged
# Additional warnings for XML compatibility. The conditional is meant
# to detect whether we are using OpenSP rather than the ancient
# original SP.
+override SPFLAGS += -wempty
ifneq (,$(filter o%,$(notdir $(OSX))))
override SPFLAGS += -wdata-delim -winstance-ignore-ms -winstance-include-ms -winstance-param-entity
endif
<title>Acronyms</title>
<para>
- This is a list of acronyms commonly used in the <productname>PostgreSQL</>
- documentation and in discussions about <productname>PostgreSQL</>.
+ This is a list of acronyms commonly used in the <productname>PostgreSQL</productname>
+ documentation and in discussions about <productname>PostgreSQL</productname>.
<variablelist>
<ulink
url="http://en.wikipedia.org/wiki/Data_Definition_Language">Data
Definition Language</ulink>, SQL commands such as <command>CREATE
- TABLE</>, <command>ALTER USER</>
+ TABLE</command>, <command>ALTER USER</command>
</para>
</listitem>
</varlistentry>
<para>
<ulink
url="http://en.wikipedia.org/wiki/Data_Manipulation_Language">Data
- Manipulation Language</ulink>, SQL commands such as <command>INSERT</>,
- <command>UPDATE</>, <command>DELETE</>
+ Manipulation Language</ulink>, SQL commands such as <command>INSERT</command>,
+ <command>UPDATE</command>, <command>DELETE</command>
</para>
</listitem>
</varlistentry>
<listitem>
<para>
<link linkend="config-setting">Grand Unified Configuration</link>,
- the <productname>PostgreSQL</> subsystem that handles server configuration
+ the <productname>PostgreSQL</productname> subsystem that handles server configuration
</para>
</listitem>
</varlistentry>
<term><acronym>LSN</acronym></term>
<listitem>
<para>
- Log Sequence Number, see <link linkend="datatype-pg-lsn"><type>pg_lsn</></link>
+ Log Sequence Number, see <link linkend="datatype-pg-lsn"><type>pg_lsn</type></link>
and <link linkend="wal-internals">WAL Internals</link>.
</para>
</listitem>
<term><acronym>PGSQL</acronym></term>
<listitem>
<para>
- <link linkend="postgres"><productname>PostgreSQL</></link>
+ <link linkend="postgres"><productname>PostgreSQL</productname></link>
</para>
</listitem>
</varlistentry>
<term><acronym>PGXS</acronym></term>
<listitem>
<para>
- <link linkend="extend-pgxs"><productname>PostgreSQL</> Extension System</link>
+ <link linkend="extend-pgxs"><productname>PostgreSQL</productname> Extension System</link>
</para>
</listitem>
</varlistentry>
</indexterm>
<para>
- <filename>adminpack</> provides a number of support functions which
- <application>pgAdmin</> and other administration and management tools can
+ <filename>adminpack</filename> provides a number of support functions which
+ <application>pgAdmin</application> and other administration and management tools can
use to provide additional functionality, such as remote management
of server log files.
Use of all these functions is restricted to superusers.
</para>
<table id="functions-adminpack-table">
- <title><filename>adminpack</> Functions</title>
+ <title><filename>adminpack</filename> Functions</title>
<tgroup cols="3">
<thead>
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry>
<entry><function>pg_catalog.pg_logdir_ls()</function></entry>
<entry><type>setof record</type></entry>
<entry>
- List the log files in the <varname>log_directory</> directory
+ List the log files in the <varname>log_directory</varname> directory
</entry>
</row>
</tbody>
<primary>pg_file_write</primary>
</indexterm>
<para>
- <function>pg_file_write</> writes the specified <parameter>data</> into
- the file named by <parameter>filename</>. If <parameter>append</> is
- false, the file must not already exist. If <parameter>append</> is true,
+ <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,
the file can already exist, and will be appended to if so.
Returns the number of bytes written.
</para>
<primary>pg_file_rename</primary>
</indexterm>
<para>
- <function>pg_file_rename</> renames a file. If <parameter>archivename</>
- is omitted or NULL, it simply renames <parameter>oldname</>
- to <parameter>newname</> (which must not already exist).
- If <parameter>archivename</> is provided, it first
- renames <parameter>newname</> to <parameter>archivename</> (which must
- not already exist), and then renames <parameter>oldname</>
- to <parameter>newname</>. In event of failure of the second rename step,
- it will try to rename <parameter>archivename</> back
- to <parameter>newname</> before reporting the error.
+ <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.
Returns true on success, false if the source file(s) are not present or
not writable; other cases throw errors.
</para>
<primary>pg_file_unlink</primary>
</indexterm>
<para>
- <function>pg_file_unlink</> removes the specified file.
+ <function>pg_file_unlink</function> removes the specified file.
Returns true on success, false if the specified file is not present
- or the <function>unlink()</> call fails; other cases throw errors.
+ or the <function>unlink()</function> call fails; other cases throw errors.
</para>
<indexterm>
<primary>pg_logdir_ls</primary>
</indexterm>
<para>
- <function>pg_logdir_ls</> returns the start timestamps and path
+ <function>pg_logdir_ls</function> returns the start timestamps and path
names of all the log files in the <xref linkend="guc-log-directory">
directory. The <xref linkend="guc-log-filename"> parameter must have its
- default setting (<literal>postgresql-%Y-%m-%d_%H%M%S.log</>) to use this
+ default setting (<literal>postgresql-%Y-%m-%d_%H%M%S.log</literal>) to use this
function.
</para>
and should not be used in new applications; instead use those shown
in <xref linkend="functions-admin-signal-table">
and <xref linkend="functions-admin-genfile-table">. These functions are
- provided in <filename>adminpack</> only for compatibility with old
- versions of <application>pgAdmin</>.
+ provided in <filename>adminpack</filename> only for compatibility with old
+ versions of <application>pgAdmin</application>.
</para>
<table id="functions-adminpack-deprecated-table">
- <title>Deprecated <filename>adminpack</> Functions</title>
+ <title>Deprecated <filename>adminpack</filename> Functions</title>
<tgroup cols="3">
<thead>
<row><entry>Name</entry> <entry>Return Type</entry> <entry>Description</entry>
<entry><function>pg_catalog.pg_file_read(filename text, offset bigint, nbytes bigint)</function></entry>
<entry><type>text</type></entry>
<entry>
- Alternate name for <function>pg_read_file()</>
+ Alternate name for <function>pg_read_file()</function>
</entry>
</row>
<row>
<entry><function>pg_catalog.pg_file_length(filename text)</function></entry>
<entry><type>bigint</type></entry>
<entry>
- Same as <structfield>size</> column returned
- by <function>pg_stat_file()</>
+ Same as <structfield>size</structfield> column returned
+ by <function>pg_stat_file()</function>
</entry>
</row>
<row>
<entry><function>pg_catalog.pg_logfile_rotate()</function></entry>
<entry><type>integer</type></entry>
<entry>
- Alternate name for <function>pg_rotate_logfile()</>, but note that it
+ Alternate name for <function>pg_rotate_logfile()</function>, but note that it
returns integer 0 or 1 rather than <type>boolean</type>
</entry>
</row>
</indexterm>
<para>
- <firstterm>Transactions</> are a fundamental concept of all database
+ <firstterm>Transactions</firstterm> are a fundamental concept of all database
systems. The essential point of a transaction is that it bundles
multiple steps into a single, all-or-nothing operation. The intermediate
states between the steps are not visible to other concurrent transactions,
remain a happy customer if she was debited without Bob being credited.
We need a guarantee that if something goes wrong partway through the
operation, none of the steps executed so far will take effect. Grouping
- the updates into a <firstterm>transaction</> gives us this guarantee.
- A transaction is said to be <firstterm>atomic</>: from the point of
+ the updates into a <firstterm>transaction</firstterm> gives us this guarantee.
+ A transaction is said to be <firstterm>atomic</firstterm>: from the point of
view of other transactions, it either happens completely or not at all.
</para>
</para>
<para>
- In <productname>PostgreSQL</>, a transaction is set up by surrounding
+ In <productname>PostgreSQL</productname>, a transaction is set up by surrounding
the SQL commands of the transaction with
- <command>BEGIN</> and <command>COMMIT</> commands. So our banking
+ <command>BEGIN</command> and <command>COMMIT</command> commands. So our banking
transaction would actually look like:
<programlisting>
<para>
If, partway through the transaction, we decide we do not want to
commit (perhaps we just noticed that Alice's balance went negative),
- we can issue the command <command>ROLLBACK</> instead of
- <command>COMMIT</>, and all our updates so far will be canceled.
+ we can issue the command <command>ROLLBACK</command> instead of
+ <command>COMMIT</command>, and all our updates so far will be canceled.
</para>
<para>
- <productname>PostgreSQL</> actually treats every SQL statement as being
- executed within a transaction. If you do not issue a <command>BEGIN</>
+ <productname>PostgreSQL</productname> actually treats every SQL statement as being
+ executed within a transaction. If you do not issue a <command>BEGIN</command>
command,
- then each individual statement has an implicit <command>BEGIN</> and
- (if successful) <command>COMMIT</> wrapped around it. A group of
- statements surrounded by <command>BEGIN</> and <command>COMMIT</>
- is sometimes called a <firstterm>transaction block</>.
+ then each individual statement has an implicit <command>BEGIN</command> and
+ (if successful) <command>COMMIT</command> wrapped around it. A group of
+ statements surrounded by <command>BEGIN</command> and <command>COMMIT</command>
+ is sometimes called a <firstterm>transaction block</firstterm>.
</para>
<note>
<para>
- Some client libraries issue <command>BEGIN</> and <command>COMMIT</>
+ Some client libraries issue <command>BEGIN</command> and <command>COMMIT</command>
commands automatically, so that you might get the effect of transaction
blocks without asking. Check the documentation for the interface
you are using.
<para>
It's possible to control the statements in a transaction in a more
- granular fashion through the use of <firstterm>savepoints</>. Savepoints
+ granular fashion through the use of <firstterm>savepoints</firstterm>. Savepoints
allow you to selectively discard parts of the transaction, while
committing the rest. After defining a savepoint with
- <command>SAVEPOINT</>, you can if needed roll back to the savepoint
- with <command>ROLLBACK TO</>. All the transaction's database changes
+ <command>SAVEPOINT</command>, you can if needed roll back to the savepoint
+ with <command>ROLLBACK TO</command>. All the transaction's database changes
between defining the savepoint and rolling back to it are discarded, but
changes earlier than the savepoint are kept.
</para>
<para>
This example is, of course, oversimplified, but there's a lot of control
possible in a transaction block through the use of savepoints.
- Moreover, <command>ROLLBACK TO</> is the only way to regain control of a
+ Moreover, <command>ROLLBACK TO</command> is the only way to regain control of a
transaction block that was put in aborted state by the
system due to an error, short of rolling it back completely and starting
again.
</indexterm>
<para>
- A <firstterm>window function</> performs a calculation across a set of
+ A <firstterm>window function</firstterm> performs a calculation across a set of
table rows that are somehow related to the current row. This is comparable
to the type of calculation that can be done with an aggregate function.
However, window functions do not cause rows to become grouped into a single
</screen>
The first three output columns come directly from the table
- <structname>empsalary</>, and there is one output row for each row in the
+ <structname>empsalary</structname>, and there is one output row for each row in the
table. The fourth column represents an average taken across all the table
- rows that have the same <structfield>depname</> value as the current row.
- (This actually is the same function as the non-window <function>avg</>
- aggregate, but the <literal>OVER</> clause causes it to be
+ rows that have the same <structfield>depname</structfield> value as the current row.
+ (This actually is the same function as the non-window <function>avg</function>
+ aggregate, but the <literal>OVER</literal> clause causes it to be
treated as a window function and computed across the window frame.)
</para>
<para>
- A window function call always contains an <literal>OVER</> clause
+ A window function call always contains an <literal>OVER</literal> clause
directly following the window function's name and argument(s). This is what
syntactically distinguishes it from a normal function or non-window
- aggregate. The <literal>OVER</> clause determines exactly how the
+ aggregate. The <literal>OVER</literal> clause determines exactly how the
rows of the query are split up for processing by the window function.
- The <literal>PARTITION BY</> clause within <literal>OVER</>
+ The <literal>PARTITION BY</literal> clause within <literal>OVER</literal>
divides the rows into groups, or partitions, that share the same
- values of the <literal>PARTITION BY</> expression(s). For each row,
+ values of the <literal>PARTITION BY</literal> expression(s). For each row,
the window function is computed across the rows that fall into the
same partition as the current row.
</para>
<para>
You can also control the order in which rows are processed by
- window functions using <literal>ORDER BY</> within <literal>OVER</>.
- (The window <literal>ORDER BY</> does not even have to match the
+ window functions using <literal>ORDER BY</literal> within <literal>OVER</literal>.
+ (The window <literal>ORDER BY</literal> does not even have to match the
order in which the rows are output.) Here is an example:
<programlisting>
(10 rows)
</screen>
- As shown here, the <function>rank</> function produces a numerical rank
- for each distinct <literal>ORDER BY</> value in the current row's
- partition, using the order defined by the <literal>ORDER BY</> clause.
- <function>rank</> needs no explicit parameter, because its behavior
- is entirely determined by the <literal>OVER</> clause.
+ As shown here, the <function>rank</function> function produces a numerical rank
+ for each distinct <literal>ORDER BY</literal> value in the current row's
+ partition, using the order defined by the <literal>ORDER BY</literal> clause.
+ <function>rank</function> needs no explicit parameter, because its behavior
+ is entirely determined by the <literal>OVER</literal> clause.
</para>
<para>
The rows considered by a window function are those of the <quote>virtual
- table</> produced by the query's <literal>FROM</> clause as filtered by its
- <literal>WHERE</>, <literal>GROUP BY</>, and <literal>HAVING</> clauses
+ table</quote> produced by the query's <literal>FROM</literal> clause as filtered by its
+ <literal>WHERE</literal>, <literal>GROUP BY</literal>, and <literal>HAVING</literal> clauses
if any. For example, a row removed because it does not meet the
- <literal>WHERE</> condition is not seen by any window function.
+ <literal>WHERE</literal> condition is not seen by any window function.
A query can contain multiple window functions that slice up the data
- in different ways using different <literal>OVER</> clauses, but
+ in different ways using different <literal>OVER</literal> clauses, but
they all act on the same collection of rows defined by this virtual table.
</para>
<para>
- We already saw that <literal>ORDER BY</> can be omitted if the ordering
+ We already saw that <literal>ORDER BY</literal> can be omitted if the ordering
of rows is not important. It is also possible to omit <literal>PARTITION
- BY</>, in which case there is a single partition containing all rows.
+ BY</literal>, in which case there is a single partition containing all rows.
</para>
<para>
There is another important concept associated with window functions:
for each row, there is a set of rows within its partition called its
- <firstterm>window frame</>. Some window functions act only
+ <firstterm>window frame</firstterm>. Some window functions act only
on the rows of the window frame, rather than of the whole partition.
- By default, if <literal>ORDER BY</> is supplied then the frame consists of
+ By default, if <literal>ORDER BY</literal> is supplied then the frame consists of
all rows from the start of the partition up through the current row, plus
any following rows that are equal to the current row according to the
- <literal>ORDER BY</> clause. When <literal>ORDER BY</> is omitted the
+ <literal>ORDER BY</literal> clause. When <literal>ORDER BY</literal> is omitted the
default frame consists of all rows in the partition.
<footnote>
<para>
<xref linkend="syntax-window-functions"> for details.
</para>
</footnote>
- Here is an example using <function>sum</>:
+ Here is an example using <function>sum</function>:
</para>
<programlisting>
</screen>
<para>
- Above, since there is no <literal>ORDER BY</> in the <literal>OVER</>
+ Above, since there is no <literal>ORDER BY</literal> in the <literal>OVER</literal>
clause, the window frame is the same as the partition, which for lack of
- <literal>PARTITION BY</> is the whole table; in other words each sum is
+ <literal>PARTITION BY</literal> is the whole table; in other words each sum is
taken over the whole table and so we get the same result for each output
- row. But if we add an <literal>ORDER BY</> clause, we get very different
+ row. But if we add an <literal>ORDER BY</literal> clause, we get very different
results:
</para>
<para>
Window functions are permitted only in the <literal>SELECT</literal> list
- and the <literal>ORDER BY</> clause of the query. They are forbidden
- elsewhere, such as in <literal>GROUP BY</>, <literal>HAVING</>
+ and the <literal>ORDER BY</literal> clause of the query. They are forbidden
+ elsewhere, such as in <literal>GROUP BY</literal>, <literal>HAVING</literal>
and <literal>WHERE</literal> clauses. This is because they logically
execute after the processing of those clauses. Also, window functions
execute after non-window aggregate functions. This means it is valid to
</programlisting>
The above query only shows the rows from the inner query having
- <literal>rank</> less than 3.
+ <literal>rank</literal> less than 3.
</para>
<para>
When a query involves multiple window functions, it is possible to write
- out each one with a separate <literal>OVER</> clause, but this is
+ out each one with a separate <literal>OVER</literal> clause, but this is
duplicative and error-prone if the same windowing behavior is wanted
for several functions. Instead, each windowing behavior can be named
- in a <literal>WINDOW</> clause and then referenced in <literal>OVER</>.
+ in a <literal>WINDOW</literal> clause and then referenced in <literal>OVER</literal>.
For example:
<programlisting>
<para>
In this case, a row of <classname>capitals</classname>
- <firstterm>inherits</firstterm> all columns (<structfield>name</>,
- <structfield>population</>, and <structfield>altitude</>) from its
+ <firstterm>inherits</firstterm> all columns (<structfield>name</structfield>,
+ <structfield>population</structfield>, and <structfield>altitude</structfield>) from its
<firstterm>parent</firstterm>, <classname>cities</classname>. The
type of the column <structfield>name</structfield> is
<type>text</type>, a native <productname>PostgreSQL</productname>
type for variable length character strings. State capitals have
- an extra column, <structfield>state</>, that shows their state. In
+ an extra column, <structfield>state</structfield>, that shows their state. In
<productname>PostgreSQL</productname>, a table can inherit from
zero or more other tables.
</para>
</indexterm>
<para>
- The <filename>amcheck</> module provides functions that allow you to
+ The <filename>amcheck</filename> module provides functions that allow you to
verify the logical consistency of the structure of indexes. If the
structure appears to be valid, no error is raised.
</para>
<para>
- The functions verify various <emphasis>invariants</> in the
+ The functions verify various <emphasis>invariants</emphasis> in the
structure of the representation of particular indexes. The
correctness of the access method functions behind index scans and
other important operations relies on these invariants always
holding. For example, certain functions verify, among other things,
- that all B-Tree pages have items in <quote>logical</> order (e.g.,
- for B-Tree indexes on <type>text</>, index tuples should be in
+ that all B-Tree pages have items in <quote>logical</quote> order (e.g.,
+ for B-Tree indexes on <type>text</type>, index tuples should be in
collated lexical order). If that particular invariant somehow fails
to hold, we can expect binary searches on the affected page to
incorrectly guide index scans, resulting in wrong answers to SQL
functions.
</para>
<para>
- <filename>amcheck</> functions may be used only by superusers.
+ <filename>amcheck</filename> functions may be used only by superusers.
</para>
<sect2>
(10 rows)
</screen>
This example shows a session that performs verification of every
- catalog index in the database <quote>test</>. Details of just
+ catalog index in the database <quote>test</quote>. Details of just
the 10 largest indexes verified are displayed. Since no error
is raised, all indexes tested appear to be logically consistent.
Naturally, this query could easily be changed to call
database where verification is supported.
</para>
<para>
- <function>bt_index_check</function> acquires an <literal>AccessShareLock</>
+ <function>bt_index_check</function> acquires an <literal>AccessShareLock</literal>
on the target index and the heap relation it belongs to. This lock mode
is the same lock mode acquired on relations by simple
- <literal>SELECT</> statements.
+ <literal>SELECT</literal> statements.
<function>bt_index_check</function> does not verify invariants
that span child/parent relationships, nor does it verify that
the target index is consistent with its heap relation. When a
logical inconsistency or other problem.
</para>
<para>
- A <literal>ShareLock</> is required on the target index by
+ A <literal>ShareLock</literal> is required on the target index by
<function>bt_index_parent_check</function> (a
- <literal>ShareLock</> is also acquired on the heap relation).
+ <literal>ShareLock</literal> is also acquired on the heap relation).
These locks prevent concurrent data modification from
- <command>INSERT</>, <command>UPDATE</>, and <command>DELETE</>
+ <command>INSERT</command>, <command>UPDATE</command>, and <command>DELETE</command>
commands. The locks also prevent the underlying relation from
- being concurrently processed by <command>VACUUM</>, as well as
+ being concurrently processed by <command>VACUUM</command>, as well as
all other utility commands. Note that the function holds locks
only while running, not for the entire transaction.
</para>
</sect2>
<sect2>
- <title>Using <filename>amcheck</> effectively</title>
+ <title>Using <filename>amcheck</filename> effectively</title>
<para>
- <filename>amcheck</> can be effective at detecting various types of
+ <filename>amcheck</filename> can be effective at detecting various types of
failure modes that <link
linkend="app-initdb-data-checksums"><application>data page
- checksums</></link> will always fail to catch. These include:
+ checksums</application></link> will always fail to catch. These include:
<itemizedlist>
<listitem>
<para>
This includes issues caused by the comparison rules of operating
system collations changing. Comparisons of datums of a collatable
- type like <type>text</> must be immutable (just as all
+ type like <type>text</type> must be immutable (just as all
comparisons used for B-Tree index scans must be immutable), which
implies that operating system collation rules must never change.
Though rare, updates to operating system collation rules can
cause these issues. More commonly, an inconsistency in the
collation order between a master server and a standby server is
- implicated, possibly because the <emphasis>major</> operating
+ implicated, possibly because the <emphasis>major</emphasis> operating
system version in use is inconsistent. Such inconsistencies will
generally only arise on standby servers, and so can generally
only be detected on standby servers.
<para>
If a problem like this arises, it may not affect each individual
index that is ordered using an affected collation, simply because
- <emphasis>indexed</> values might happen to have the same
+ <emphasis>indexed</emphasis> values might happen to have the same
absolute ordering regardless of the behavioral inconsistency. See
<xref linkend="locale"> and <xref linkend="collation"> for
- further details about how <productname>PostgreSQL</> uses
+ further details about how <productname>PostgreSQL</productname> uses
operating system locales and collations.
</para>
</listitem>
<listitem>
<para>
Corruption caused by hypothetical undiscovered bugs in the
- underlying <productname>PostgreSQL</> access method code or sort
+ underlying <productname>PostgreSQL</productname> access method code or sort
code.
</para>
<para>
Automatic verification of the structural integrity of indexes
plays a role in the general testing of new or proposed
- <productname>PostgreSQL</> features that could plausibly allow a
+ <productname>PostgreSQL</productname> features that could plausibly allow a
logical inconsistency to be introduced. One obvious testing
- strategy is to call <filename>amcheck</> functions continuously
+ strategy is to call <filename>amcheck</filename> functions continuously
when running the standard regression tests. See <xref
linkend="regress-run"> for details on running the tests.
</para>
simply not be enabled.
</para>
<para>
- Note that <filename>amcheck</> examines a page as represented in some
+ Note that <filename>amcheck</filename> examines a page as represented in some
shared memory buffer at the time of verification if there is only a
shared buffer hit when accessing the block. Consequently,
- <filename>amcheck</> does not necessarily examine data read from the
+ <filename>amcheck</filename> does not necessarily examine data read from the
file system at the time of verification. Note that when checksums are
- enabled, <filename>amcheck</> may raise an error due to a checksum
+ enabled, <filename>amcheck</filename> may raise an error due to a checksum
failure when a corrupt block is read into a buffer.
</para>
</listitem>
and operating system.
</para>
<para>
- <productname>PostgreSQL</> does not protect against correctable
+ <productname>PostgreSQL</productname> does not protect against correctable
memory errors and it is assumed you will operate using RAM that
uses industry standard Error Correcting Codes (ECC) or better
protection. However, ECC memory is typically only immune to
</para>
</listitem>
</itemizedlist>
- In general, <filename>amcheck</> can only prove the presence of
+ In general, <filename>amcheck</filename> can only prove the presence of
corruption; it cannot prove its absence.
</para>
<sect2>
<title>Repairing corruption</title>
<para>
- No error concerning corruption raised by <filename>amcheck</> should
- ever be a false positive. In practice, <filename>amcheck</> is more
+ No error concerning corruption raised by <filename>amcheck</filename> should
+ ever be a false positive. In practice, <filename>amcheck</filename> is more
likely to find software bugs than problems with hardware.
- <filename>amcheck</> raises errors in the event of conditions that,
+ <filename>amcheck</filename> raises errors in the event of conditions that,
by definition, should never happen, and so careful analysis of
- <filename>amcheck</> errors is often required.
+ <filename>amcheck</filename> errors is often required.
</para>
<para>
There is no general method of repairing problems that
- <filename>amcheck</> detects. An explanation for the root cause of
+ <filename>amcheck</filename> detects. An explanation for the root cause of
an invariant violation should be sought. <xref
linkend="pageinspect"> may play a useful role in diagnosing
- corruption that <filename>amcheck</> detects. A <command>REINDEX</>
+ corruption that <filename>amcheck</filename> detects. A <command>REINDEX</command>
may not be effective in repairing corruption.
</para>
<para>
<productname>PostgreSQL</productname> is implemented using a
- simple <quote>process per user</> client/server model. In this model
+ simple <quote>process per user</quote> client/server model. In this model
there is one <firstterm>client process</firstterm> connected to
exactly one <firstterm>server process</firstterm>. As we do not
know ahead of time how many connections will be made, we have to
The client process can be any program that understands the
<productname>PostgreSQL</productname> protocol described in
<xref linkend="protocol">. Many clients are based on the
- C-language library <application>libpq</>, but several independent
+ C-language library <application>libpq</application>, but several independent
implementations of the protocol exist, such as the Java
- <application>JDBC</> driver.
+ <application>JDBC</application> driver.
</para>
<para>
text) for valid syntax. If the syntax is correct a
<firstterm>parse tree</firstterm> is built up and handed back;
otherwise an error is returned. The parser and lexer are
- implemented using the well-known Unix tools <application>bison</>
- and <application>flex</>.
+ implemented using the well-known Unix tools <application>bison</application>
+ and <application>flex</application>.
</para>
<para>
back by the parser as input and does the semantic interpretation needed
to understand which tables, functions, and operators are referenced by
the query. The data structure that is built to represent this
- information is called the <firstterm>query tree</>.
+ information is called the <firstterm>query tree</firstterm>.
</para>
<para>
system catalog lookups can only be done within a transaction, and we
do not wish to start a transaction immediately upon receiving a query
string. The raw parsing stage is sufficient to identify the transaction
- control commands (<command>BEGIN</>, <command>ROLLBACK</>, etc), and
+ control commands (<command>BEGIN</command>, <command>ROLLBACK</command>, etc), and
these can then be correctly executed without any further analysis.
Once we know that we are dealing with an actual query (such as
- <command>SELECT</> or <command>UPDATE</>), it is okay to
+ <command>SELECT</command> or <command>UPDATE</command>), it is okay to
start a transaction if we're not already in one. Only then can the
transformation process be invoked.
</para>
<para>
The query tree created by the transformation process is structurally
similar to the raw parse tree in most places, but it has many differences
- in detail. For example, a <structname>FuncCall</> node in the
+ in detail. For example, a <structname>FuncCall</structname> node in the
parse tree represents something that looks syntactically like a function
- call. This might be transformed to either a <structname>FuncExpr</>
- or <structname>Aggref</> node depending on whether the referenced
+ call. This might be transformed to either a <structname>FuncExpr</structname>
+ or <structname>Aggref</structname> node depending on whether the referenced
name turns out to be an ordinary function or an aggregate function.
Also, information about the actual data types of columns and expression
results is added to the query tree.
<para>
The planner's search procedure actually works with data structures
- called <firstterm>paths</>, which are simply cut-down representations of
+ called <firstterm>paths</firstterm>, which are simply cut-down representations of
plans containing only as much information as the planner needs to make
its decisions. After the cheapest path is determined, a full-fledged
- <firstterm>plan tree</> is built to pass to the executor. This represents
+ <firstterm>plan tree</firstterm> is built to pass to the executor. This represents
the desired execution plan in sufficient detail for the executor to run it.
In the rest of this section we'll ignore the distinction between paths
and plans.
<literal>relation.attribute OPR constant</literal>. If
<literal>relation.attribute</literal> happens to match the key of the B-tree
index and <literal>OPR</literal> is one of the operators listed in
- the index's <firstterm>operator class</>, another plan is created using
+ the index's <firstterm>operator class</firstterm>, another plan is created using
the B-tree index to scan the relation. If there are further indexes
present and the restrictions in the query happen to match a key of an
index, further plans will be considered. Index scan plans are also
generated for indexes that have a sort ordering that can match the
- query's <literal>ORDER BY</> clause (if any), or a sort ordering that
+ query's <literal>ORDER BY</literal> clause (if any), or a sort ordering that
might be useful for merge joining (see below).
</para>
the base relations, plus nested-loop, merge, or hash join nodes as
needed, plus any auxiliary steps needed, such as sort nodes or
aggregate-function calculation nodes. Most of these plan node
- types have the additional ability to do <firstterm>selection</>
+ types have the additional ability to do <firstterm>selection</firstterm>
(discarding rows that do not meet a specified Boolean condition)
- and <firstterm>projection</> (computation of a derived column set
+ and <firstterm>projection</firstterm> (computation of a derived column set
based on given column values, that is, evaluation of scalar
expressions where needed). One of the responsibilities of the
planner is to attach selection conditions from the
subplan) is, let's say, a
<literal>Sort</literal> node and again recursion is needed to obtain
an input row. The child node of the <literal>Sort</literal> might
- be a <literal>SeqScan</> node, representing actual reading of a table.
+ be a <literal>SeqScan</literal> node, representing actual reading of a table.
Execution of this node causes the executor to fetch a row from the
table and return it up to the calling node. The <literal>Sort</literal>
node will repeatedly call its child to obtain all the rows to be sorted.
<para>
The executor mechanism is used to evaluate all four basic SQL query types:
- <command>SELECT</>, <command>INSERT</>, <command>UPDATE</>, and
- <command>DELETE</>. For <command>SELECT</>, the top-level executor
+ <command>SELECT</command>, <command>INSERT</command>, <command>UPDATE</command>, and
+ <command>DELETE</command>. For <command>SELECT</command>, the top-level executor
code only needs to send each row returned by the query plan tree off
- to the client. For <command>INSERT</>, each returned row is inserted
- into the target table specified for the <command>INSERT</>. This is
- done in a special top-level plan node called <literal>ModifyTable</>.
+ to the client. For <command>INSERT</command>, each returned row is inserted
+ into the target table specified for the <command>INSERT</command>. This is
+ done in a special top-level plan node called <literal>ModifyTable</literal>.
(A simple
- <command>INSERT ... VALUES</> command creates a trivial plan tree
- consisting of a single <literal>Result</> node, which computes just one
- result row, and <literal>ModifyTable</> above it to perform the insertion.
- But <command>INSERT ... SELECT</> can demand the full power
- of the executor mechanism.) For <command>UPDATE</>, the planner arranges
+ <command>INSERT ... VALUES</command> command creates a trivial plan tree
+ consisting of a single <literal>Result</literal> node, which computes just one
+ result row, and <literal>ModifyTable</literal> above it to perform the insertion.
+ But <command>INSERT ... SELECT</command> can demand the full power
+ of the executor mechanism.) For <command>UPDATE</command>, the planner arranges
that each computed row includes all the updated column values, plus
- the <firstterm>TID</> (tuple ID, or row ID) of the original target row;
- this data is fed into a <literal>ModifyTable</> node, which uses the
+ the <firstterm>TID</firstterm> (tuple ID, or row ID) of the original target row;
+ this data is fed into a <literal>ModifyTable</literal> node, which uses the
information to create a new updated row and mark the old row deleted.
- For <command>DELETE</>, the only column that is actually returned by the
- plan is the TID, and the <literal>ModifyTable</> node simply uses the TID
+ For <command>DELETE</command>, the only column that is actually returned by the
+ plan is the TID, and the <literal>ModifyTable</literal> node simply uses the TID
to visit each target row and mark it deleted.
</para>
);
</programlisting>
As shown, an array data type is named by appending square brackets
- (<literal>[]</>) to the data type name of the array elements. The
+ (<literal>[]</literal>) to the data type name of the array elements. The
above command will create a table named
<structname>sal_emp</structname> with a column of type
<type>text</type> (<structfield>name</structfield>), a
<para>
An alternative syntax, which conforms to the SQL standard by using
- the keyword <literal>ARRAY</>, can be used for one-dimensional arrays.
+ the keyword <literal>ARRAY</literal>, can be used for one-dimensional arrays.
<structfield>pay_by_quarter</structfield> could have been defined
as:
<programlisting>
<programlisting>
pay_by_quarter integer ARRAY,
</programlisting>
- As before, however, <productname>PostgreSQL</> does not enforce the
+ As before, however, <productname>PostgreSQL</productname> does not enforce the
size restriction in any case.
</para>
</sect2>
for the type, as recorded in its <literal>pg_type</literal> entry.
Among the standard data types provided in the
<productname>PostgreSQL</productname> distribution, all use a comma
- (<literal>,</>), except for type <type>box</> which uses a semicolon
- (<literal>;</>). Each <replaceable>val</replaceable> is
+ (<literal>,</literal>), except for type <type>box</type> which uses a semicolon
+ (<literal>;</literal>). Each <replaceable>val</replaceable> is
either a constant of the array element type, or a subarray. An example
of an array constant is:
<programlisting>
</para>
<para>
- To set an element of an array constant to NULL, write <literal>NULL</>
+ To set an element of an array constant to NULL, write <literal>NULL</literal>
for the element value. (Any upper- or lower-case variant of
- <literal>NULL</> will do.) If you want an actual string value
- <quote>NULL</>, you must put double quotes around it.
+ <literal>NULL</literal> will do.) If you want an actual string value
+ <quote>NULL</quote>, you must put double quotes around it.
</para>
<para>
</para>
<para>
- The <literal>ARRAY</> constructor syntax can also be used:
+ The <literal>ARRAY</literal> constructor syntax can also be used:
<programlisting>
INSERT INTO sal_emp
VALUES ('Bill',
</programlisting>
Notice that the array elements are ordinary SQL constants or
expressions; for instance, string literals are single quoted, instead of
- double quoted as they would be in an array literal. The <literal>ARRAY</>
+ double quoted as they would be in an array literal. The <literal>ARRAY</literal>
constructor syntax is discussed in more detail in
<xref linkend="sql-syntax-array-constructors">.
</para>
The array subscript numbers are written within square brackets.
By default <productname>PostgreSQL</productname> uses a
one-based numbering convention for arrays, that is,
- an array of <replaceable>n</> elements starts with <literal>array[1]</literal> and
- ends with <literal>array[<replaceable>n</>]</literal>.
+ an array of <replaceable>n</replaceable> elements starts with <literal>array[1]</literal> and
+ ends with <literal>array[<replaceable>n</replaceable>]</literal>.
</para>
<para>
If any dimension is written as a slice, i.e., contains a colon, then all
dimensions are treated as slices. Any dimension that has only a single
number (no colon) is treated as being from 1
- to the number specified. For example, <literal>[2]</> is treated as
- <literal>[1:2]</>, as in this example:
+ to the number specified. For example, <literal>[2]</literal> is treated as
+ <literal>[1:2]</literal>, as in this example:
<programlisting>
SELECT schedule[1:2][2] FROM sal_emp WHERE name = 'Bill';
</programlisting>
To avoid confusion with the non-slice case, it's best to use slice syntax
- for all dimensions, e.g., <literal>[1:2][1:1]</>, not <literal>[2][1:1]</>.
+ for all dimensions, e.g., <literal>[1:2][1:1]</literal>, not <literal>[2][1:1]</literal>.
</para>
<para>
An array subscript expression will return null if either the array itself or
any of the subscript expressions are null. Also, null is returned if a
subscript is outside the array bounds (this case does not raise an error).
- For example, if <literal>schedule</>
- currently has the dimensions <literal>[1:3][1:2]</> then referencing
- <literal>schedule[3][3]</> yields NULL. Similarly, an array reference
+ For example, if <literal>schedule</literal>
+ currently has the dimensions <literal>[1:3][1:2]</literal> then referencing
+ <literal>schedule[3][3]</literal> yields NULL. Similarly, an array reference
with the wrong number of subscripts yields a null rather than an error.
</para>
A stored array value can be enlarged by assigning to elements not already
present. Any positions between those previously present and the newly
assigned elements will be filled with nulls. For example, if array
- <literal>myarray</> currently has 4 elements, it will have six
- elements after an update that assigns to <literal>myarray[6]</>;
- <literal>myarray[5]</> will contain null.
+ <literal>myarray</literal> currently has 4 elements, it will have six
+ elements after an update that assigns to <literal>myarray[6]</literal>;
+ <literal>myarray[5]</literal> will contain null.
Currently, enlargement in this fashion is only allowed for one-dimensional
arrays, not multidimensional arrays.
</para>
<para>
Subscripted assignment allows creation of arrays that do not use one-based
- subscripts. For example one might assign to <literal>myarray[-2:7]</> to
+ subscripts. For example one might assign to <literal>myarray[-2:7]</literal> to
create an array with subscript values from -2 to 7.
</para>
<para>
The concatenation operator allows a single element to be pushed onto the
beginning or end of a one-dimensional array. It also accepts two
- <replaceable>N</>-dimensional arrays, or an <replaceable>N</>-dimensional
- and an <replaceable>N+1</>-dimensional array.
+ <replaceable>N</replaceable>-dimensional arrays, or an <replaceable>N</replaceable>-dimensional
+ and an <replaceable>N+1</replaceable>-dimensional array.
</para>
<para>
</para>
<para>
- When an <replaceable>N</>-dimensional array is pushed onto the beginning
- or end of an <replaceable>N+1</>-dimensional array, the result is
- analogous to the element-array case above. Each <replaceable>N</>-dimensional
- sub-array is essentially an element of the <replaceable>N+1</>-dimensional
+ When an <replaceable>N</replaceable>-dimensional array is pushed onto the beginning
+ or end of an <replaceable>N+1</replaceable>-dimensional array, the result is
+ analogous to the element-array case above. Each <replaceable>N</replaceable>-dimensional
+ sub-array is essentially an element of the <replaceable>N+1</replaceable>-dimensional
array's outer dimension. For example:
<programlisting>
SELECT array_dims(ARRAY[1,2] || ARRAY[[3,4],[5,6]]);
The heuristic it uses to resolve the constant's type is to assume it's of
the same type as the operator's other input — in this case,
integer array. So the concatenation operator is presumed to
- represent <function>array_cat</>, not <function>array_append</>. When
+ represent <function>array_cat</function>, not <function>array_append</function>. When
that's the wrong choice, it could be fixed by casting the constant to the
- array's element type; but explicit use of <function>array_append</> might
+ array's element type; but explicit use of <function>array_append</function> might
be a preferable solution.
</para>
</sect2>
</para>
<para>
- Alternatively, the <function>generate_subscripts</> function can be used.
+ Alternatively, the <function>generate_subscripts</function> function can be used.
For example:
<programlisting>
</para>
<para>
- You can also search an array using the <literal>&&</> operator,
+ You can also search an array using the <literal>&&</literal> operator,
which checks whether the left operand overlaps with the right operand.
For instance:
</para>
<para>
- You can also search for specific values in an array using the <function>array_position</>
- and <function>array_positions</> functions. The former returns the subscript of
+ You can also search for specific values in an array using the <function>array_position</function>
+ and <function>array_positions</function> functions. The former returns the subscript of
the first occurrence of a value in an array; the latter returns an array with the
subscripts of all occurrences of the value in the array. For example:
The external text representation of an array value consists of items that
are interpreted according to the I/O conversion rules for the array's
element type, plus decoration that indicates the array structure.
- The decoration consists of curly braces (<literal>{</> and <literal>}</>)
+ The decoration consists of curly braces (<literal>{</literal> and <literal>}</literal>)
around the array value plus delimiter characters between adjacent items.
- The delimiter character is usually a comma (<literal>,</>) but can be
- something else: it is determined by the <literal>typdelim</> setting
+ The delimiter character is usually a comma (<literal>,</literal>) but can be
+ something else: it is determined by the <literal>typdelim</literal> setting
for the array's element type. Among the standard data types provided
in the <productname>PostgreSQL</productname> distribution, all use a comma,
- except for type <type>box</>, which uses a semicolon (<literal>;</>).
+ except for type <type>box</type>, which uses a semicolon (<literal>;</literal>).
In a multidimensional array, each dimension (row, plane,
cube, etc.) gets its own level of curly braces, and delimiters
must be written between adjacent curly-braced entities of the same level.
The array output routine will put double quotes around element values
if they are empty strings, contain curly braces, delimiter characters,
double quotes, backslashes, or white space, or match the word
- <literal>NULL</>. Double quotes and backslashes
+ <literal>NULL</literal>. Double quotes and backslashes
embedded in element values will be backslash-escaped. For numeric
data types it is safe to assume that double quotes will never appear, but
for textual data types one should be prepared to cope with either the presence
set to one. To represent arrays with other lower bounds, the array
subscript ranges can be specified explicitly before writing the
array contents.
- This decoration consists of square brackets (<literal>[]</>)
+ This decoration consists of square brackets (<literal>[]</literal>)
around each array dimension's lower and upper bounds, with
- a colon (<literal>:</>) delimiter character in between. The
- array dimension decoration is followed by an equal sign (<literal>=</>).
+ a colon (<literal>:</literal>) delimiter character in between. The
+ array dimension decoration is followed by an equal sign (<literal>=</literal>).
For example:
<programlisting>
SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
</para>
<para>
- If the value written for an element is <literal>NULL</> (in any case
+ If the value written for an element is <literal>NULL</literal> (in any case
variant), the element is taken to be NULL. The presence of any quotes
or backslashes disables this and allows the literal string value
- <quote>NULL</> to be entered. Also, for backward compatibility with
- pre-8.2 versions of <productname>PostgreSQL</>, the <xref
+ <quote>NULL</quote> to be entered. Also, for backward compatibility with
+ pre-8.2 versions of <productname>PostgreSQL</productname>, the <xref
linkend="guc-array-nulls"> configuration parameter can be turned
- <literal>off</> to suppress recognition of <literal>NULL</> as a NULL.
+ <literal>off</literal> to suppress recognition of <literal>NULL</literal> as a NULL.
</para>
<para>
As shown previously, when writing an array value you can use double
- quotes around any individual array element. You <emphasis>must</> do so
+ quotes around any individual array element. You <emphasis>must</emphasis> do so
if the element value would otherwise confuse the array-value parser.
For example, elements containing curly braces, commas (or the data type's
delimiter character), double quotes, backslashes, or leading or trailing
whitespace must be double-quoted. Empty strings and strings matching the
- word <literal>NULL</> must be quoted, too. To put a double quote or
+ word <literal>NULL</literal> must be quoted, too. To put a double quote or
backslash in a quoted array element value, use escape string syntax
and precede it with a backslash. Alternatively, you can avoid quotes and use
backslash-escaping to protect all data characters that would otherwise
<para>
Remember that what you write in an SQL command will first be interpreted
as a string literal, and then as an array. This doubles the number of
- backslashes you need. For example, to insert a <type>text</> array
+ backslashes you need. For example, to insert a <type>text</type> array
value containing a backslash and a double quote, you'd need to write:
<programlisting>
INSERT ... VALUES (E'{"\\\\","\\""}');
</programlisting>
The escape string processor removes one level of backslashes, so that
- what arrives at the array-value parser looks like <literal>{"\\","\""}</>.
- In turn, the strings fed to the <type>text</> data type's input routine
- become <literal>\</> and <literal>"</> respectively. (If we were working
+ what arrives at the array-value parser looks like <literal>{"\\","\""}</literal>.
+ In turn, the strings fed to the <type>text</type> data type's input routine
+ become <literal>\</literal> and <literal>"</literal> respectively. (If we were working
with a data type whose input routine also treated backslashes specially,
- <type>bytea</> for example, we might need as many as eight backslashes
+ <type>bytea</type> for example, we might need as many as eight backslashes
in the command to get one backslash into the stored array element.)
Dollar quoting (see <xref linkend="sql-syntax-dollar-quoting">) can be
used to avoid the need to double backslashes.
<tip>
<para>
- The <literal>ARRAY</> constructor syntax (see
+ The <literal>ARRAY</literal> constructor syntax (see
<xref linkend="sql-syntax-array-constructors">) is often easier to work
with than the array-literal syntax when writing array values in SQL
- commands. In <literal>ARRAY</>, individual element values are written the
+ commands. In <literal>ARRAY</literal>, individual element values are written the
same way they would be written when not members of an array.
</para>
</tip>
<para>
In order to function, this module must be loaded via
- <xref linkend="guc-shared-preload-libraries"> in <filename>postgresql.conf</>.
+ <xref linkend="guc-shared-preload-libraries"> in <filename>postgresql.conf</filename>.
</para>
<sect2>
<term>
<varname>auth_delay.milliseconds</varname> (<type>int</type>)
<indexterm>
- <primary><varname>auth_delay.milliseconds</> configuration parameter</primary>
+ <primary><varname>auth_delay.milliseconds</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
</variablelist>
<para>
- These parameters must be set in <filename>postgresql.conf</>.
+ These parameters must be set in <filename>postgresql.conf</filename>.
Typical usage might be:
</para>
</programlisting>
(You must be superuser to do that.) More typical usage is to preload
- it into some or all sessions by including <literal>auto_explain</> in
+ it into some or all sessions by including <literal>auto_explain</literal> in
<xref linkend="guc-session-preload-libraries"> or
<xref linkend="guc-shared-preload-libraries"> in
- <filename>postgresql.conf</>. Then you can track unexpectedly slow queries
+ <filename>postgresql.conf</filename>. Then you can track unexpectedly slow queries
no matter when they happen. Of course there is a price in overhead for
that.
</para>
<term>
<varname>auto_explain.log_min_duration</varname> (<type>integer</type>)
<indexterm>
- <primary><varname>auto_explain.log_min_duration</> configuration parameter</primary>
+ <primary><varname>auto_explain.log_min_duration</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<term>
<varname>auto_explain.log_analyze</varname> (<type>boolean</type>)
<indexterm>
- <primary><varname>auto_explain.log_analyze</> configuration parameter</primary>
+ <primary><varname>auto_explain.log_analyze</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
- <varname>auto_explain.log_analyze</varname> causes <command>EXPLAIN ANALYZE</>
- output, rather than just <command>EXPLAIN</> output, to be printed
+ <varname>auto_explain.log_analyze</varname> causes <command>EXPLAIN ANALYZE</command>
+ output, rather than just <command>EXPLAIN</command> output, to be printed
when an execution plan is logged. This parameter is off by default.
Only superusers can change this setting.
</para>
<term>
<varname>auto_explain.log_buffers</varname> (<type>boolean</type>)
<indexterm>
- <primary><varname>auto_explain.log_buffers</> configuration parameter</primary>
+ <primary><varname>auto_explain.log_buffers</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
<varname>auto_explain.log_buffers</varname> controls whether buffer
usage statistics are printed when an execution plan is logged; it's
- equivalent to the <literal>BUFFERS</> option of <command>EXPLAIN</>.
+ equivalent to the <literal>BUFFERS</literal> option of <command>EXPLAIN</command>.
This parameter has no effect
unless <varname>auto_explain.log_analyze</varname> is enabled.
This parameter is off by default.
<term>
<varname>auto_explain.log_timing</varname> (<type>boolean</type>)
<indexterm>
- <primary><varname>auto_explain.log_timing</> configuration parameter</primary>
+ <primary><varname>auto_explain.log_timing</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
<varname>auto_explain.log_timing</varname> controls whether per-node
timing information is printed when an execution plan is logged; it's
- equivalent to the <literal>TIMING</> option of <command>EXPLAIN</>.
+ equivalent to the <literal>TIMING</literal> option of <command>EXPLAIN</command>.
The overhead of repeatedly reading the system clock can slow down
queries significantly on some systems, so it may be useful to set this
parameter to off when only actual row counts, and not exact times, are
<term>
<varname>auto_explain.log_triggers</varname> (<type>boolean</type>)
<indexterm>
- <primary><varname>auto_explain.log_triggers</> configuration parameter</primary>
+ <primary><varname>auto_explain.log_triggers</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<term>
<varname>auto_explain.log_verbose</varname> (<type>boolean</type>)
<indexterm>
- <primary><varname>auto_explain.log_verbose</> configuration parameter</primary>
+ <primary><varname>auto_explain.log_verbose</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
<varname>auto_explain.log_verbose</varname> controls whether verbose
details are printed when an execution plan is logged; it's
- equivalent to the <literal>VERBOSE</> option of <command>EXPLAIN</>.
+ equivalent to the <literal>VERBOSE</literal> option of <command>EXPLAIN</command>.
This parameter is off by default.
Only superusers can change this setting.
</para>
<term>
<varname>auto_explain.log_format</varname> (<type>enum</type>)
<indexterm>
- <primary><varname>auto_explain.log_format</> configuration parameter</primary>
+ <primary><varname>auto_explain.log_format</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
<varname>auto_explain.log_format</varname> selects the
- <command>EXPLAIN</> output format to be used.
+ <command>EXPLAIN</command> output format to be used.
The allowed values are <literal>text</literal>, <literal>xml</literal>,
<literal>json</literal>, and <literal>yaml</literal>. The default is text.
Only superusers can change this setting.
<term>
<varname>auto_explain.log_nested_statements</varname> (<type>boolean</type>)
<indexterm>
- <primary><varname>auto_explain.log_nested_statements</> configuration parameter</primary>
+ <primary><varname>auto_explain.log_nested_statements</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<term>
<varname>auto_explain.sample_rate</varname> (<type>real</type>)
<indexterm>
- <primary><varname>auto_explain.sample_rate</> configuration parameter</primary>
+ <primary><varname>auto_explain.sample_rate</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
In ordinary usage, these parameters are set
- in <filename>postgresql.conf</>, although superusers can alter them
+ in <filename>postgresql.conf</filename>, although superusers can alter them
on-the-fly within their own sessions.
Typical usage might be:
</para>
<chapter id="backup">
<title>Backup and Restore</title>
- <indexterm zone="backup"><primary>backup</></>
+ <indexterm zone="backup"><primary>backup</primary></indexterm>
<para>
- As with everything that contains valuable data, <productname>PostgreSQL</>
+ As with everything that contains valuable data, <productname>PostgreSQL</productname>
databases should be backed up regularly. While the procedure is
essentially simple, it is important to have a clear understanding of
the underlying techniques and assumptions.
<para>
There are three fundamentally different approaches to backing up
- <productname>PostgreSQL</> data:
+ <productname>PostgreSQL</productname> data:
<itemizedlist>
- <listitem><para><acronym>SQL</> dump</para></listitem>
+ <listitem><para><acronym>SQL</acronym> dump</para></listitem>
<listitem><para>File system level backup</para></listitem>
<listitem><para>Continuous archiving</para></listitem>
</itemizedlist>
</para>
<sect1 id="backup-dump">
- <title><acronym>SQL</> Dump</title>
+ <title><acronym>SQL</acronym> Dump</title>
<para>
The idea behind this dump method is to generate a file with SQL
commands that, when fed back to the server, will recreate the
database in the same state as it was at the time of the dump.
- <productname>PostgreSQL</> provides the utility program
+ <productname>PostgreSQL</productname> provides the utility program
<xref linkend="app-pgdump"> for this purpose. The basic usage of this
command is:
<synopsis>
pg_dump <replaceable class="parameter">dbname</replaceable> > <replaceable class="parameter">outfile</replaceable>
</synopsis>
- As you see, <application>pg_dump</> writes its result to the
+ As you see, <application>pg_dump</application> writes its result to the
standard output. We will see below how this can be useful.
- While the above command creates a text file, <application>pg_dump</>
+ While the above command creates a text file, <application>pg_dump</application>
can create files in other formats that allow for parallelism and more
fine-grained control of object restoration.
</para>
<para>
- <application>pg_dump</> is a regular <productname>PostgreSQL</>
+ <application>pg_dump</application> is a regular <productname>PostgreSQL</productname>
client application (albeit a particularly clever one). This means
that you can perform this backup procedure from any remote host that has
- access to the database. But remember that <application>pg_dump</>
+ access to the database. But remember that <application>pg_dump</application>
does not operate with special permissions. In particular, it must
have read access to all tables that you want to back up, so in order
to back up the entire database you almost always have to run it as a
</para>
<para>
- To specify which database server <application>pg_dump</> should
+ To specify which database server <application>pg_dump</application> should
contact, use the command line options <option>-h
- <replaceable>host</></> and <option>-p <replaceable>port</></>. The
+ <replaceable>host</replaceable></option> and <option>-p <replaceable>port</replaceable></option>. The
default host is the local host or whatever your
<envar>PGHOST</envar> environment variable specifies. Similarly,
the default port is indicated by the <envar>PGPORT</envar>
</para>
<para>
- Like any other <productname>PostgreSQL</> client application,
- <application>pg_dump</> will by default connect with the database
+ Like any other <productname>PostgreSQL</productname> client application,
+ <application>pg_dump</application> will by default connect with the database
user name that is equal to the current operating system user name. To override
this, either specify the <option>-U</option> option or set the
environment variable <envar>PGUSER</envar>. Remember that
- <application>pg_dump</> connections are subject to the normal
+ <application>pg_dump</application> connections are subject to the normal
client authentication mechanisms (which are described in <xref
linkend="client-authentication">).
</para>
<para>
- An important advantage of <application>pg_dump</> over the other backup
- methods described later is that <application>pg_dump</>'s output can
- generally be re-loaded into newer versions of <productname>PostgreSQL</>,
+ An important advantage of <application>pg_dump</application> over the other backup
+ methods described later is that <application>pg_dump</application>'s output can
+ generally be re-loaded into newer versions of <productname>PostgreSQL</productname>,
whereas file-level backups and continuous archiving are both extremely
- server-version-specific. <application>pg_dump</> is also the only method
+ server-version-specific. <application>pg_dump</application> is also the only method
that will work when transferring a database to a different machine
architecture, such as going from a 32-bit to a 64-bit server.
</para>
<para>
- Dumps created by <application>pg_dump</> are internally consistent,
+ Dumps created by <application>pg_dump</application> are internally consistent,
meaning, the dump represents a snapshot of the database at the time
- <application>pg_dump</> began running. <application>pg_dump</> does not
+ <application>pg_dump</application> began running. <application>pg_dump</application> does not
block other operations on the database while it is working.
(Exceptions are those operations that need to operate with an
exclusive lock, such as most forms of <command>ALTER TABLE</command>.)
<title>Restoring the Dump</title>
<para>
- Text files created by <application>pg_dump</> are intended to
+ Text files created by <application>pg_dump</application> are intended to
be read in by the <application>psql</application> program. The
general command form to restore a dump is
<synopsis>
psql <replaceable class="parameter">dbname</replaceable> < <replaceable class="parameter">infile</replaceable>
</synopsis>
where <replaceable class="parameter">infile</replaceable> is the
- file output by the <application>pg_dump</> command. The database <replaceable
+ file output by the <application>pg_dump</application> command. The database <replaceable
class="parameter">dbname</replaceable> will not be created by this
- command, so you must create it yourself from <literal>template0</>
- before executing <application>psql</> (e.g., with
+ command, so you must create it yourself from <literal>template0</literal>
+ before executing <application>psql</application> (e.g., with
<literal>createdb -T template0 <replaceable
- class="parameter">dbname</></literal>). <application>psql</>
- supports options similar to <application>pg_dump</> for specifying
+ class="parameter">dbname</replaceable></literal>). <application>psql</application>
+ supports options similar to <application>pg_dump</application> for specifying
the database server to connect to and the user name to use. See
the <xref linkend="app-psql"> reference page for more information.
Non-text file dumps are restored using the <xref
</para>
<para>
- By default, the <application>psql</> script will continue to
+ By default, the <application>psql</application> script will continue to
execute after an SQL error is encountered. You might wish to run
<application>psql</application> with
- the <literal>ON_ERROR_STOP</> variable set to alter that
+ the <literal>ON_ERROR_STOP</literal> variable set to alter that
behavior and have <application>psql</application> exit with an
exit status of 3 if an SQL error occurs:
<programlisting>
Alternatively, you can specify that the whole dump should be
restored as a single transaction, so the restore is either fully
completed or fully rolled back. This mode can be specified by
- passing the <option>-1</> or <option>--single-transaction</>
- command-line options to <application>psql</>. When using this
+ passing the <option>-1</option> or <option>--single-transaction</option>
+ command-line options to <application>psql</application>. When using this
mode, be aware that even a minor error can rollback a
restore that has already run for many hours. However, that might
still be preferable to manually cleaning up a complex database
</para>
<para>
- The ability of <application>pg_dump</> and <application>psql</> to
+ The ability of <application>pg_dump</application> and <application>psql</application> to
write to or read from pipes makes it possible to dump a database
directly from one server to another, for example:
<programlisting>
-pg_dump -h <replaceable>host1</> <replaceable>dbname</> | psql -h <replaceable>host2</> <replaceable>dbname</>
+pg_dump -h <replaceable>host1</replaceable> <replaceable>dbname</replaceable> | psql -h <replaceable>host2</replaceable> <replaceable>dbname</replaceable>
</programlisting>
</para>
<important>
<para>
- The dumps produced by <application>pg_dump</> are relative to
- <literal>template0</>. This means that any languages, procedures,
- etc. added via <literal>template1</> will also be dumped by
- <application>pg_dump</>. As a result, when restoring, if you are
- using a customized <literal>template1</>, you must create the
- empty database from <literal>template0</>, as in the example
+ The dumps produced by <application>pg_dump</application> are relative to
+ <literal>template0</literal>. This means that any languages, procedures,
+ etc. added via <literal>template1</literal> will also be dumped by
+ <application>pg_dump</application>. As a result, when restoring, if you are
+ using a customized <literal>template1</literal>, you must create the
+ empty database from <literal>template0</literal>, as in the example
above.
</para>
</important>
see <xref linkend="vacuum-for-statistics">
and <xref linkend="autovacuum"> for more information.
For more advice on how to load large amounts of data
- into <productname>PostgreSQL</> efficiently, refer to <xref
+ into <productname>PostgreSQL</productname> efficiently, refer to <xref
linkend="populate">.
</para>
</sect2>
<sect2 id="backup-dump-all">
- <title>Using <application>pg_dumpall</></title>
+ <title>Using <application>pg_dumpall</application></title>
<para>
- <application>pg_dump</> dumps only a single database at a time,
+ <application>pg_dump</application> dumps only a single database at a time,
and it does not dump information about roles or tablespaces
(because those are cluster-wide rather than per-database).
To support convenient dumping of the entire contents of a database
cluster, the <xref linkend="app-pg-dumpall"> program is provided.
- <application>pg_dumpall</> backs up each database in a given
+ <application>pg_dumpall</application> backs up each database in a given
cluster, and also preserves cluster-wide data such as role and
tablespace definitions. The basic usage of this command is:
<synopsis>
-pg_dumpall > <replaceable>outfile</>
+pg_dumpall > <replaceable>outfile</replaceable>
</synopsis>
- The resulting dump can be restored with <application>psql</>:
+ The resulting dump can be restored with <application>psql</application>:
<synopsis>
psql -f <replaceable class="parameter">infile</replaceable> postgres
</synopsis>
(Actually, you can specify any existing database name to start from,
- but if you are loading into an empty cluster then <literal>postgres</>
+ but if you are loading into an empty cluster then <literal>postgres</literal>
should usually be used.) It is always necessary to have
- database superuser access when restoring a <application>pg_dumpall</>
+ database superuser access when restoring a <application>pg_dumpall</application>
dump, as that is required to restore the role and tablespace information.
If you use tablespaces, make sure that the tablespace paths in the
dump are appropriate for the new installation.
</para>
<para>
- <application>pg_dumpall</> works by emitting commands to re-create
+ <application>pg_dumpall</application> works by emitting commands to re-create
roles, tablespaces, and empty databases, then invoking
- <application>pg_dump</> for each database. This means that while
+ <application>pg_dump</application> for each database. This means that while
each database will be internally consistent, the snapshots of
different databases are not synchronized.
</para>
<para>
Cluster-wide data can be dumped alone using the
- <application>pg_dumpall</> <option>--globals-only</> option.
+ <application>pg_dumpall</application> <option>--globals-only</option> option.
This is necessary to fully backup the cluster if running the
- <application>pg_dump</> command on individual databases.
+ <application>pg_dump</application> command on individual databases.
</para>
</sect2>
<para>
Some operating systems have maximum file size limits that cause
- problems when creating large <application>pg_dump</> output files.
- Fortunately, <application>pg_dump</> can write to the standard
+ problems when creating large <application>pg_dump</application> output files.
+ Fortunately, <application>pg_dump</application> can write to the standard
output, so you can use standard Unix tools to work around this
potential problem. There are several possible methods:
</para>
</formalpara>
<formalpara>
- <title>Use <command>split</>.</title>
+ <title>Use <command>split</command>.</title>
<para>
The <command>split</command> command
allows you to split the output into smaller files that are
</formalpara>
<formalpara>
- <title>Use <application>pg_dump</>'s custom dump format.</title>
+ <title>Use <application>pg_dump</application>'s custom dump format.</title>
<para>
If <productname>PostgreSQL</productname> was built on a system with the
- <application>zlib</> compression library installed, the custom dump
+ <application>zlib</application> compression library installed, the custom dump
format will compress data as it writes it to the output file. This will
produce dump file sizes similar to using <command>gzip</command>, but it
has the added advantage that tables can be restored selectively. The
pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable class="parameter">filename</replaceable>
</programlisting>
- A custom-format dump is not a script for <application>psql</>, but
- instead must be restored with <application>pg_restore</>, for example:
+ A custom-format dump is not a script for <application>psql</application>, but
+ instead must be restored with <application>pg_restore</application>, for example:
<programlisting>
pg_restore -d <replaceable class="parameter">dbname</replaceable> <replaceable class="parameter">filename</replaceable>
</formalpara>
<para>
- For very large databases, you might need to combine <command>split</>
+ For very large databases, you might need to combine <command>split</command>
with one of the other two approaches.
</para>
<formalpara>
- <title>Use <application>pg_dump</>'s parallel dump feature.</title>
+ <title>Use <application>pg_dump</application>'s parallel dump feature.</title>
<para>
To speed up the dump of a large database, you can use
<application>pg_dump</application>'s parallel mode. This will dump
<para>
An alternative backup strategy is to directly copy the files that
- <productname>PostgreSQL</> uses to store the data in the database;
+ <productname>PostgreSQL</productname> uses to store the data in the database;
<xref linkend="creating-cluster"> explains where these files
are located. You can use whatever method you prefer
for doing file system backups; for example:
<para>
There are two restrictions, however, which make this method
- impractical, or at least inferior to the <application>pg_dump</>
+ impractical, or at least inferior to the <application>pg_dump</application>
method:
<orderedlist>
<listitem>
<para>
- The database server <emphasis>must</> be shut down in order to
+ The database server <emphasis>must</emphasis> be shut down in order to
get a usable backup. Half-way measures such as disallowing all
connections will <emphasis>not</emphasis> work
(in part because <command>tar</command> and similar tools do not take
If you have dug into the details of the file system layout of the
database, you might be tempted to try to back up or restore only certain
individual tables or databases from their respective files or
- directories. This will <emphasis>not</> work because the
+ directories. This will <emphasis>not</emphasis> work because the
information contained in these files is not usable without
the commit log files,
<filename>pg_xact/*</filename>, which contain the commit status of
<quote>consistent snapshot</quote> of the data directory, if the
file system supports that functionality (and you are willing to
trust that it is implemented correctly). The typical procedure is
- to make a <quote>frozen snapshot</> of the volume containing the
+ to make a <quote>frozen snapshot</quote> of the volume containing the
database, then copy the whole data directory (not just parts, see
above) from the snapshot to a backup device, then release the frozen
snapshot. This will work even while the database server is running.
the volumes. For example, if your data files and WAL log are on different
disks, or if tablespaces are on different file systems, it might
not be possible to use snapshot backup because the snapshots
- <emphasis>must</> be simultaneous.
+ <emphasis>must</emphasis> be simultaneous.
Read your file system documentation very carefully before trusting
the consistent-snapshot technique in such situations.
</para>
</para>
<para>
- Another option is to use <application>rsync</> to perform a file
- system backup. This is done by first running <application>rsync</>
+ Another option is to use <application>rsync</application> to perform a file
+ system backup. This is done by first running <application>rsync</application>
while the database server is running, then shutting down the database
- server long enough to do an <command>rsync --checksum</>.
- (<option>--checksum</> is necessary because <command>rsync</> only
+ server long enough to do an <command>rsync --checksum</command>.
+ (<option>--checksum</option> is necessary because <command>rsync</command> only
has file modification-time granularity of one second.) The
- second <application>rsync</> will be quicker than the first,
+ second <application>rsync</application> will be quicker than the first,
because it has relatively little data to transfer, and the end result
will be consistent because the server was down. This method
allows a file system backup to be performed with minimal downtime.
</indexterm>
<para>
- At all times, <productname>PostgreSQL</> maintains a
- <firstterm>write ahead log</> (WAL) in the <filename>pg_wal/</>
+ At all times, <productname>PostgreSQL</productname> maintains a
+ <firstterm>write ahead log</firstterm> (WAL) in the <filename>pg_wal/</filename>
subdirectory of the cluster's data directory. The log records
every change made to the database's data files. This log exists
primarily for crash-safety purposes: if the system crashes, the
- database can be restored to consistency by <quote>replaying</> the
+ database can be restored to consistency by <quote>replaying</quote> the
log entries made since the last checkpoint. However, the existence
of the log makes it possible to use a third strategy for backing up
databases: we can combine a file-system-level backup with backup of
Any internal inconsistency in the backup will be corrected by log
replay (this is not significantly different from what happens during
crash recovery). So we do not need a file system snapshot capability,
- just <application>tar</> or a similar archiving tool.
+ just <application>tar</application> or a similar archiving tool.
</para>
</listitem>
<listitem>
It is not necessary to replay the WAL entries all the
way to the end. We could stop the replay at any point and have a
consistent snapshot of the database as it was at that time. Thus,
- this technique supports <firstterm>point-in-time recovery</>: it is
+ this technique supports <firstterm>point-in-time recovery</firstterm>: it is
possible to restore the database to its state at any time since your base
backup was taken.
</para>
<para>
If we continuously feed the series of WAL files to another
machine that has been loaded with the same base backup file, we
- have a <firstterm>warm standby</> system: at any point we can bring up
+ have a <firstterm>warm standby</firstterm> system: at any point we can bring up
the second machine and it will have a nearly-current copy of the
database.
</para>
<application>pg_dump</application> and
<application>pg_dumpall</application> do not produce file-system-level
backups and cannot be used as part of a continuous-archiving solution.
- Such dumps are <emphasis>logical</> and do not contain enough
+ Such dumps are <emphasis>logical</emphasis> and do not contain enough
information to be used by WAL replay.
</para>
</note>
<para>
To recover successfully using continuous archiving (also called
- <quote>online backup</> by many database vendors), you need a continuous
+ <quote>online backup</quote> by many database vendors), you need a continuous
sequence of archived WAL files that extends back at least as far as the
start time of your backup. So to get started, you should set up and test
- your procedure for archiving WAL files <emphasis>before</> you take your
+ your procedure for archiving WAL files <emphasis>before</emphasis> you take your
first base backup. Accordingly, we first discuss the mechanics of
archiving WAL files.
</para>
<title>Setting Up WAL Archiving</title>
<para>
- In an abstract sense, a running <productname>PostgreSQL</> system
+ In an abstract sense, a running <productname>PostgreSQL</productname> system
produces an indefinitely long sequence of WAL records. The system
physically divides this sequence into WAL <firstterm>segment
- files</>, which are normally 16MB apiece (although the segment size
- can be altered during <application>initdb</>). The segment
+ files</firstterm>, which are normally 16MB apiece (although the segment size
+ can be altered during <application>initdb</application>). The segment
files are given numeric names that reflect their position in the
abstract WAL sequence. When not using WAL archiving, the system
normally creates just a few segment files and then
- <quote>recycles</> them by renaming no-longer-needed segment files
+ <quote>recycles</quote> them by renaming no-longer-needed segment files
to higher segment numbers. It's assumed that segment files whose
contents precede the checkpoint-before-last are no longer of
interest and can be recycled.
file once it is filled, and save that data somewhere before the segment
file is recycled for reuse. Depending on the application and the
available hardware, there could be many different ways of <quote>saving
- the data somewhere</>: we could copy the segment files to an NFS-mounted
+ the data somewhere</quote>: we could copy the segment files to an NFS-mounted
directory on another machine, write them onto a tape drive (ensuring that
you have a way of identifying the original name of each file), or batch
them together and burn them onto CDs, or something else entirely. To
provide the database administrator with flexibility,
- <productname>PostgreSQL</> tries not to make any assumptions about how
- the archiving will be done. Instead, <productname>PostgreSQL</> lets
+ <productname>PostgreSQL</productname> tries not to make any assumptions about how
+ the archiving will be done. Instead, <productname>PostgreSQL</productname> lets
the administrator specify a shell command to be executed to copy a
completed segment file to wherever it needs to go. The command could be
- as simple as a <literal>cp</>, or it could invoke a complex shell
+ as simple as a <literal>cp</literal>, or it could invoke a complex shell
script — it's all up to you.
</para>
<para>
To enable WAL archiving, set the <xref linkend="guc-wal-level">
- configuration parameter to <literal>replica</> or higher,
- <xref linkend="guc-archive-mode"> to <literal>on</>,
+ configuration parameter to <literal>replica</literal> or higher,
+ <xref linkend="guc-archive-mode"> to <literal>on</literal>,
and specify the shell command to use in the <xref
linkend="guc-archive-command"> configuration parameter. In practice
these settings will always be placed in the
<filename>postgresql.conf</filename> file.
- In <varname>archive_command</>,
- <literal>%p</> is replaced by the path name of the file to
- archive, while <literal>%f</> is replaced by only the file name.
+ In <varname>archive_command</varname>,
+ <literal>%p</literal> is replaced by the path name of the file to
+ archive, while <literal>%f</literal> is replaced by only the file name.
(The path name is relative to the current working directory,
i.e., the cluster's data directory.)
- Use <literal>%%</> if you need to embed an actual <literal>%</>
+ Use <literal>%%</literal> if you need to embed an actual <literal>%</literal>
character in the command. The simplest useful command is something
like:
<programlisting>
archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"' # Windows
</programlisting>
which will copy archivable WAL segments to the directory
- <filename>/mnt/server/archivedir</>. (This is an example, not a
+ <filename>/mnt/server/archivedir</filename>. (This is an example, not a
recommendation, and might not work on all platforms.) After the
- <literal>%p</> and <literal>%f</> parameters have been replaced,
+ <literal>%p</literal> and <literal>%f</literal> parameters have been replaced,
the actual command executed might look like this:
<programlisting>
test ! -f /mnt/server/archivedir/00000001000000A900000065 && cp pg_wal/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900000065
<para>
The archive command will be executed under the ownership of the same
- user that the <productname>PostgreSQL</> server is running as. Since
+ user that the <productname>PostgreSQL</productname> server is running as. Since
the series of WAL files being archived contains effectively everything
in your database, you will want to be sure that the archived data is
protected from prying eyes; for example, archive into a directory that
<para>
It is important that the archive command return zero exit status if and
only if it succeeds. Upon getting a zero result,
- <productname>PostgreSQL</> will assume that the file has been
+ <productname>PostgreSQL</productname> will assume that the file has been
successfully archived, and will remove or recycle it. However, a nonzero
- status tells <productname>PostgreSQL</> that the file was not archived;
+ status tells <productname>PostgreSQL</productname> that the file was not archived;
it will try again periodically until it succeeds.
</para>
<para>
It is advisable to test your proposed archive command to ensure that it
indeed does not overwrite an existing file, <emphasis>and that it returns
- nonzero status in this case</>.
+ nonzero status in this case</emphasis>.
The example command above for Unix ensures this by including a separate
- <command>test</> step. On some Unix platforms, <command>cp</> has
- switches such as <option>-i</> that can be used to do the same thing
+ <command>test</command> step. On some Unix platforms, <command>cp</command> has
+ switches such as <option>-i</option> that can be used to do the same thing
less verbosely, but you should not rely on these without verifying that
- the right exit status is returned. (In particular, GNU <command>cp</>
- will return status zero when <option>-i</> is used and the target file
- already exists, which is <emphasis>not</> the desired behavior.)
+ the right exit status is returned. (In particular, GNU <command>cp</command>
+ will return status zero when <option>-i</option> is used and the target file
+ already exists, which is <emphasis>not</emphasis> the desired behavior.)
</para>
<para>
fills, nothing further can be archived until the tape is swapped.
You should ensure that any error condition or request to a human operator
is reported appropriately so that the situation can be
- resolved reasonably quickly. The <filename>pg_wal/</> directory will
+ resolved reasonably quickly. The <filename>pg_wal/</filename> directory will
continue to fill with WAL segment files until the situation is resolved.
- (If the file system containing <filename>pg_wal/</> fills up,
- <productname>PostgreSQL</> will do a PANIC shutdown. No committed
+ (If the file system containing <filename>pg_wal/</filename> fills up,
+ <productname>PostgreSQL</productname> will do a PANIC shutdown. No committed
transactions will be lost, but the database will remain offline until
you free some space.)
</para>
operation continues even if the archiving process falls a little behind.
If archiving falls significantly behind, this will increase the amount of
data that would be lost in the event of a disaster. It will also mean that
- the <filename>pg_wal/</> directory will contain large numbers of
+ the <filename>pg_wal/</filename> directory will contain large numbers of
not-yet-archived segment files, which could eventually exceed available
disk space. You are advised to monitor the archiving process to ensure that
it is working as you intend.
In writing your archive command, you should assume that the file names to
be archived can be up to 64 characters long and can contain any
combination of ASCII letters, digits, and dots. It is not necessary to
- preserve the original relative path (<literal>%p</>) but it is necessary to
- preserve the file name (<literal>%f</>).
+ preserve the original relative path (<literal>%p</literal>) but it is necessary to
+ preserve the file name (<literal>%f</literal>).
</para>
<para>
Note that although WAL archiving will allow you to restore any
- modifications made to the data in your <productname>PostgreSQL</> database,
+ modifications made to the data in your <productname>PostgreSQL</productname> database,
it will not restore changes made to configuration files (that is,
- <filename>postgresql.conf</>, <filename>pg_hba.conf</> and
- <filename>pg_ident.conf</>), since those are edited manually rather
+ <filename>postgresql.conf</filename>, <filename>pg_hba.conf</filename> and
+ <filename>pg_ident.conf</filename>), since those are edited manually rather
than through SQL operations.
You might wish to keep the configuration files in a location that will
be backed up by your regular file system backup procedures. See
to a new WAL segment file at least that often. Note that archived
files that are archived early due to a forced switch are still the same
length as completely full files. It is therefore unwise to set a very
- short <varname>archive_timeout</> — it will bloat your archive
- storage. <varname>archive_timeout</> settings of a minute or so are
+ short <varname>archive_timeout</varname> — it will bloat your archive
+ storage. <varname>archive_timeout</varname> settings of a minute or so are
usually reasonable.
</para>
<para>
Also, you can force a segment switch manually with
- <function>pg_switch_wal</> if you want to ensure that a
+ <function>pg_switch_wal</function> if you want to ensure that a
just-finished transaction is archived as soon as possible. Other utility
functions related to WAL management are listed in <xref
linkend="functions-admin-backup-table">.
</para>
<para>
- When <varname>wal_level</> is <literal>minimal</> some SQL commands
+ When <varname>wal_level</varname> is <literal>minimal</literal> some SQL commands
are optimized to avoid WAL logging, as described in <xref
linkend="populate-pitr">. If archiving or streaming replication were
turned on during execution of one of these statements, WAL would not
contain enough information for archive recovery. (Crash recovery is
- unaffected.) For this reason, <varname>wal_level</> can only be changed at
- server start. However, <varname>archive_command</> can be changed with a
+ unaffected.) For this reason, <varname>wal_level</varname> can only be changed at
+ server start. However, <varname>archive_command</varname> can be changed with a
configuration file reload. If you wish to temporarily stop archiving,
- one way to do it is to set <varname>archive_command</> to the empty
- string (<literal>''</>).
- This will cause WAL files to accumulate in <filename>pg_wal/</> until a
- working <varname>archive_command</> is re-established.
+ one way to do it is to set <varname>archive_command</varname> to the empty
+ string (<literal>''</literal>).
+ This will cause WAL files to accumulate in <filename>pg_wal/</filename> until a
+ working <varname>archive_command</varname> is re-established.
</para>
</sect2>
<para>
It is not necessary to be concerned about the amount of time it takes
to make a base backup. However, if you normally run the
- server with <varname>full_page_writes</> disabled, you might notice a drop
- in performance while the backup runs since <varname>full_page_writes</> is
+ server with <varname>full_page_writes</varname> disabled, you might notice a drop
+ in performance while the backup runs since <varname>full_page_writes</varname> is
effectively forced on during backup mode.
</para>
To make use of the backup, you will need to keep all the WAL
segment files generated during and after the file system backup.
To aid you in doing this, the base backup process
- creates a <firstterm>backup history file</> that is immediately
+ creates a <firstterm>backup history file</firstterm> that is immediately
stored into the WAL archive area. This file is named after the first
WAL segment file that you need for the file system backup.
For example, if the starting WAL file is
- <literal>0000000100001234000055CD</> the backup history file will be
+ <literal>0000000100001234000055CD</literal> the backup history file will be
named something like
- <literal>0000000100001234000055CD.007C9330.backup</>. (The second
+ <literal>0000000100001234000055CD.007C9330.backup</literal>. (The second
part of the file name stands for an exact position within the WAL
file, and can ordinarily be ignored.) Once you have safely archived
the file system backup and the WAL segment files used during the
<programlisting>
SELECT pg_start_backup('label', false, false);
</programlisting>
- where <literal>label</> is any string you want to use to uniquely
+ where <literal>label</literal> is any string you want to use to uniquely
identify this backup operation. The connection
- calling <function>pg_start_backup</> must be maintained until the end of
+ calling <function>pg_start_backup</function> must be maintained until the end of
the backup, or the backup will be automatically aborted.
</para>
<para>
- By default, <function>pg_start_backup</> can take a long time to finish.
+ By default, <function>pg_start_backup</function> can take a long time to finish.
This is because it performs a checkpoint, and the I/O
required for the checkpoint will be spread out over a significant
period of time, by default half your inter-checkpoint interval
<xref linkend="guc-checkpoint-completion-target">). This is
usually what you want, because it minimizes the impact on query
processing. If you want to start the backup as soon as
- possible, change the second parameter to <literal>true</>, which will
+ possible, change the second parameter to <literal>true</literal>, which will
issue an immediate checkpoint using as much I/O as available.
</para>
<para>
- The third parameter being <literal>false</> tells
- <function>pg_start_backup</> to initiate a non-exclusive base backup.
+ The third parameter being <literal>false</literal> tells
+ <function>pg_start_backup</function> to initiate a non-exclusive base backup.
</para>
</listitem>
<listitem>
<para>
Perform the backup, using any convenient file-system-backup tool
- such as <application>tar</> or <application>cpio</> (not
+ such as <application>tar</application> or <application>cpio</application> (not
<application>pg_dump</application> or
<application>pg_dumpall</application>). It is neither
necessary nor desirable to stop normal operation of the database
ready to archive.
</para>
<para>
- The <function>pg_stop_backup</> will return one row with three
+ The <function>pg_stop_backup</function> will return one row with three
values. The second of these fields should be written to a file named
- <filename>backup_label</> in the root directory of the backup. The
+ <filename>backup_label</filename> in the root directory of the backup. The
third field should be written to a file named
- <filename>tablespace_map</> unless the field is empty. These files are
+ <filename>tablespace_map</filename> unless the field is empty. These files are
vital to the backup working, and must be written without modification.
</para>
</listitem>
<listitem>
<para>
Once the WAL segment files active during the backup are archived, you are
- done. The file identified by <function>pg_stop_backup</>'s first return
+ done. The file identified by <function>pg_stop_backup</function>'s first return
value is the last segment that is required to form a complete set of
- backup files. On a primary, if <varname>archive_mode</> is enabled and the
- <literal>wait_for_archive</> parameter is <literal>true</>,
- <function>pg_stop_backup</> does not return until the last segment has
+ backup files. On a primary, if <varname>archive_mode</varname> is enabled and the
+ <literal>wait_for_archive</literal> parameter is <literal>true</literal>,
+ <function>pg_stop_backup</function> does not return until the last segment has
been archived.
- On a standby, <varname>archive_mode</> must be <literal>always</> in order
- for <function>pg_stop_backup</> to wait.
+ On a standby, <varname>archive_mode</varname> must be <literal>always</literal> in order
+ for <function>pg_stop_backup</function> to wait.
Archiving of these files happens automatically since you have
- already configured <varname>archive_command</>. In most cases this
+ already configured <varname>archive_command</varname>. In most cases this
happens quickly, but you are advised to monitor your archive
system to ensure there are no delays.
If the archive process has fallen behind
because of failures of the archive command, it will keep retrying
until the archive succeeds and the backup is complete.
If you wish to place a time limit on the execution of
- <function>pg_stop_backup</>, set an appropriate
+ <function>pg_stop_backup</function>, set an appropriate
<varname>statement_timeout</varname> value, but make note that if
- <function>pg_stop_backup</> terminates because of this your backup
+ <function>pg_stop_backup</function> terminates because of this your backup
may not be valid.
</para>
<para>
If the backup process monitors and ensures that all WAL segment files
required for the backup are successfully archived then the
- <literal>wait_for_archive</> parameter (which defaults to true) can be set
+ <literal>wait_for_archive</literal> parameter (which defaults to true) can be set
to false to have
- <function>pg_stop_backup</> return as soon as the stop backup record is
- written to the WAL. By default, <function>pg_stop_backup</> will wait
+ <function>pg_stop_backup</function> return as soon as the stop backup record is
+ written to the WAL. By default, <function>pg_stop_backup</function> will wait
until all WAL has been archived, which can take some time. This option
must be used with caution: if WAL archiving is not monitored correctly
then the backup might not include all of the WAL files and will
The process for an exclusive backup is mostly the same as for a
non-exclusive one, but it differs in a few key steps. This type of backup
can only be taken on a primary and does not allow concurrent backups.
- Prior to <productname>PostgreSQL</> 9.6, this
+ Prior to <productname>PostgreSQL</productname> 9.6, this
was the only low-level method available, but it is now recommended that
all users upgrade their scripts to use non-exclusive backups if possible.
</para>
<programlisting>
SELECT pg_start_backup('label');
</programlisting>
- where <literal>label</> is any string you want to use to uniquely
+ where <literal>label</literal> is any string you want to use to uniquely
identify this backup operation.
- <function>pg_start_backup</> creates a <firstterm>backup label</> file,
- called <filename>backup_label</>, in the cluster directory with
+ <function>pg_start_backup</function> creates a <firstterm>backup label</firstterm> file,
+ called <filename>backup_label</filename>, in the cluster directory with
information about your backup, including the start time and label string.
- The function also creates a <firstterm>tablespace map</> file,
- called <filename>tablespace_map</>, in the cluster directory with
- information about tablespace symbolic links in <filename>pg_tblspc/</> if
+ The function also creates a <firstterm>tablespace map</firstterm> file,
+ called <filename>tablespace_map</filename>, in the cluster directory with
+ information about tablespace symbolic links in <filename>pg_tblspc/</filename> if
one or more such link is present. Both files are critical to the
integrity of the backup, should you need to restore from it.
</para>
<para>
- By default, <function>pg_start_backup</> can take a long time to finish.
+ By default, <function>pg_start_backup</function> can take a long time to finish.
This is because it performs a checkpoint, and the I/O
required for the checkpoint will be spread out over a significant
period of time, by default half your inter-checkpoint interval
<listitem>
<para>
Perform the backup, using any convenient file-system-backup tool
- such as <application>tar</> or <application>cpio</> (not
+ such as <application>tar</application> or <application>cpio</application> (not
<application>pg_dump</application> or
<application>pg_dumpall</application>). It is neither
necessary nor desirable to stop normal operation of the database
</para>
<para>
Note that if the server crashes during the backup it may not be
- possible to restart until the <literal>backup_label</> file has been
+ possible to restart until the <literal>backup_label</literal> file has been
manually deleted from the <envar>PGDATA</envar> directory.
</para>
</listitem>
<listitem>
<para>
Once the WAL segment files active during the backup are archived, you are
- done. The file identified by <function>pg_stop_backup</>'s result is
+ done. The file identified by <function>pg_stop_backup</function>'s result is
the last segment that is required to form a complete set of backup files.
- If <varname>archive_mode</> is enabled,
- <function>pg_stop_backup</> does not return until the last segment has
+ If <varname>archive_mode</varname> is enabled,
+ <function>pg_stop_backup</function> does not return until the last segment has
been archived.
Archiving of these files happens automatically since you have
- already configured <varname>archive_command</>. In most cases this
+ already configured <varname>archive_command</varname>. In most cases this
happens quickly, but you are advised to monitor your archive
system to ensure there are no delays.
If the archive process has fallen behind
because of failures of the archive command, it will keep retrying
until the archive succeeds and the backup is complete.
If you wish to place a time limit on the execution of
- <function>pg_stop_backup</>, set an appropriate
+ <function>pg_stop_backup</function>, set an appropriate
<varname>statement_timeout</varname> value, but make note that if
- <function>pg_stop_backup</> terminates because of this your backup
+ <function>pg_stop_backup</function> terminates because of this your backup
may not be valid.
</para>
</listitem>
When taking a base backup of an active database, this situation is normal
and not an error. However, you need to ensure that you can distinguish
complaints of this sort from real errors. For example, some versions
- of <application>rsync</> return a separate exit code for
- <quote>vanished source files</>, and you can write a driver script to
+ of <application>rsync</application> return a separate exit code for
+ <quote>vanished source files</quote>, and you can write a driver script to
accept this exit code as a non-error case. Also, some versions of
- GNU <application>tar</> return an error code indistinguishable from
- a fatal error if a file was truncated while <application>tar</> was
- copying it. Fortunately, GNU <application>tar</> versions 1.16 and
+ GNU <application>tar</application> return an error code indistinguishable from
+ a fatal error if a file was truncated while <application>tar</application> was
+ copying it. Fortunately, GNU <application>tar</application> versions 1.16 and
later exit with 1 if a file was changed during the backup,
- and 2 for other errors. With GNU <application>tar</> version 1.23 and
+ and 2 for other errors. With GNU <application>tar</application> version 1.23 and
later, you can use the warning options <literal>--warning=no-file-changed
--warning=no-file-removed</literal> to hide the related warning messages.
</para>
<para>
Be certain that your backup includes all of the files under
- the database cluster directory (e.g., <filename>/usr/local/pgsql/data</>).
+ the database cluster directory (e.g., <filename>/usr/local/pgsql/data</filename>).
If you are using tablespaces that do not reside underneath this directory,
be careful to include them as well (and be sure that your backup
archives symbolic links as links, otherwise the restore will corrupt
<para>
You should, however, omit from the backup the files within the
- cluster's <filename>pg_wal/</> subdirectory. This
+ cluster's <filename>pg_wal/</filename> subdirectory. This
slight adjustment is worthwhile because it reduces the risk
of mistakes when restoring. This is easy to arrange if
- <filename>pg_wal/</> is a symbolic link pointing to someplace outside
+ <filename>pg_wal/</filename> is a symbolic link pointing to someplace outside
the cluster directory, which is a common setup anyway for performance
- reasons. You might also want to exclude <filename>postmaster.pid</>
- and <filename>postmaster.opts</>, which record information
- about the running <application>postmaster</>, not about the
- <application>postmaster</> which will eventually use this backup.
- (These files can confuse <application>pg_ctl</>.)
+ reasons. You might also want to exclude <filename>postmaster.pid</filename>
+ and <filename>postmaster.opts</filename>, which record information
+ about the running <application>postmaster</application>, not about the
+ <application>postmaster</application> which will eventually use this backup.
+ (These files can confuse <application>pg_ctl</application>.)
</para>
<para>
It is often a good idea to also omit from the backup the files
- within the cluster's <filename>pg_replslot/</> directory, so that
+ within the cluster's <filename>pg_replslot/</filename> directory, so that
replication slots that exist on the master do not become part of the
backup. Otherwise, the subsequent use of the backup to create a standby
may result in indefinite retention of WAL files on the standby, and
</para>
<para>
- The contents of the directories <filename>pg_dynshmem/</>,
- <filename>pg_notify/</>, <filename>pg_serial/</>,
- <filename>pg_snapshots/</>, <filename>pg_stat_tmp/</>,
- and <filename>pg_subtrans/</> (but not the directories themselves) can be
+ The contents of the directories <filename>pg_dynshmem/</filename>,
+ <filename>pg_notify/</filename>, <filename>pg_serial/</filename>,
+ <filename>pg_snapshots/</filename>, <filename>pg_stat_tmp/</filename>,
+ and <filename>pg_subtrans/</filename> (but not the directories themselves) can be
omitted from the backup as they will be initialized on postmaster startup.
If <xref linkend="guc-stats-temp-directory"> is set and is under the data
directory then the contents of that directory can also be omitted.
<para>
The backup label
- file includes the label string you gave to <function>pg_start_backup</>,
- as well as the time at which <function>pg_start_backup</> was run, and
+ file includes the label string you gave to <function>pg_start_backup</function>,
+ as well as the time at which <function>pg_start_backup</function> was run, and
the name of the starting WAL file. In case of confusion it is therefore
possible to look inside a backup file and determine exactly which
backup session the dump file came from. The tablespace map file includes
the symbolic link names as they exist in the directory
- <filename>pg_tblspc/</> and the full path of each symbolic link.
+ <filename>pg_tblspc/</filename> and the full path of each symbolic link.
These files are not merely for your information; their presence and
contents are critical to the proper operation of the system's recovery
process.
<para>
It is also possible to make a backup while the server is
stopped. In this case, you obviously cannot use
- <function>pg_start_backup</> or <function>pg_stop_backup</>, and
+ <function>pg_start_backup</function> or <function>pg_stop_backup</function>, and
you will therefore be left to your own devices to keep track of which
backup is which and how far back the associated WAL files go.
It is generally better to follow the continuous archiving procedure above.
location in case you need them later. Note that this precaution will
require that you have enough free space on your system to hold two
copies of your existing database. If you do not have enough space,
- you should at least save the contents of the cluster's <filename>pg_wal</>
+ you should at least save the contents of the cluster's <filename>pg_wal</filename>
subdirectory, as it might contain logs which
were not archived before the system went down.
</para>
<para>
Restore the database files from your file system backup. Be sure that they
are restored with the right ownership (the database system user, not
- <literal>root</>!) and with the right permissions. If you are using
+ <literal>root</literal>!) and with the right permissions. If you are using
tablespaces,
- you should verify that the symbolic links in <filename>pg_tblspc/</>
+ you should verify that the symbolic links in <filename>pg_tblspc/</filename>
were correctly restored.
</para>
</listitem>
<listitem>
<para>
- Remove any files present in <filename>pg_wal/</>; these came from the
+ Remove any files present in <filename>pg_wal/</filename>; these came from the
file system backup and are therefore probably obsolete rather than current.
- If you didn't archive <filename>pg_wal/</> at all, then recreate
+ If you didn't archive <filename>pg_wal/</filename> at all, then recreate
it with proper permissions,
being careful to ensure that you re-establish it as a symbolic link
if you had it set up that way before.
<listitem>
<para>
If you have unarchived WAL segment files that you saved in step 2,
- copy them into <filename>pg_wal/</>. (It is best to copy them,
+ copy them into <filename>pg_wal/</filename>. (It is best to copy them,
not move them, so you still have the unmodified files if a
problem occurs and you have to start over.)
</para>
</listitem>
<listitem>
<para>
- Create a recovery command file <filename>recovery.conf</> in the cluster
+ Create a recovery command file <filename>recovery.conf</filename> in the cluster
data directory (see <xref linkend="recovery-config">). You might
- also want to temporarily modify <filename>pg_hba.conf</> to prevent
+ also want to temporarily modify <filename>pg_hba.conf</filename> to prevent
ordinary users from connecting until you are sure the recovery was successful.
</para>
</listitem>
recovery be terminated because of an external error, the server can
simply be restarted and it will continue recovery. Upon completion
of the recovery process, the server will rename
- <filename>recovery.conf</> to <filename>recovery.done</> (to prevent
+ <filename>recovery.conf</filename> to <filename>recovery.done</filename> (to prevent
accidentally re-entering recovery mode later) and then
commence normal database operations.
</para>
<para>
Inspect the contents of the database to ensure you have recovered to
the desired state. If not, return to step 1. If all is well,
- allow your users to connect by restoring <filename>pg_hba.conf</> to normal.
+ allow your users to connect by restoring <filename>pg_hba.conf</filename> to normal.
</para>
</listitem>
</orderedlist>
<para>
The key part of all this is to set up a recovery configuration file that
describes how you want to recover and how far the recovery should
- run. You can use <filename>recovery.conf.sample</> (normally
- located in the installation's <filename>share/</> directory) as a
+ run. You can use <filename>recovery.conf.sample</filename> (normally
+ located in the installation's <filename>share/</filename> directory) as a
prototype. The one thing that you absolutely must specify in
- <filename>recovery.conf</> is the <varname>restore_command</>,
- which tells <productname>PostgreSQL</> how to retrieve archived
- WAL file segments. Like the <varname>archive_command</>, this is
- a shell command string. It can contain <literal>%f</>, which is
- replaced by the name of the desired log file, and <literal>%p</>,
+ <filename>recovery.conf</filename> is the <varname>restore_command</varname>,
+ which tells <productname>PostgreSQL</productname> how to retrieve archived
+ WAL file segments. Like the <varname>archive_command</varname>, this is
+ a shell command string. It can contain <literal>%f</literal>, which is
+ replaced by the name of the desired log file, and <literal>%p</literal>,
which is replaced by the path name to copy the log file to.
(The path name is relative to the current working directory,
i.e., the cluster's data directory.)
- Write <literal>%%</> if you need to embed an actual <literal>%</>
+ Write <literal>%%</literal> if you need to embed an actual <literal>%</literal>
character in the command. The simplest useful command is
something like:
<programlisting>
restore_command = 'cp /mnt/server/archivedir/%f %p'
</programlisting>
which will copy previously archived WAL segments from the directory
- <filename>/mnt/server/archivedir</>. Of course, you can use something
+ <filename>/mnt/server/archivedir</filename>. Of course, you can use something
much more complicated, perhaps even a shell script that requests the
operator to mount an appropriate tape.
</para>
<para>
It is important that the command return nonzero exit status on failure.
- The command <emphasis>will</> be called requesting files that are not
+ The command <emphasis>will</emphasis> be called requesting files that are not
present in the archive; it must return nonzero when so asked. This is not
an error condition. An exception is that if the command was terminated by
a signal (other than <systemitem>SIGTERM</systemitem>, which is used as
<para>
Not all of the requested files will be WAL segment
files; you should also expect requests for files with a suffix of
- <literal>.backup</> or <literal>.history</>. Also be aware that
- the base name of the <literal>%p</> path will be different from
- <literal>%f</>; do not expect them to be interchangeable.
+ <literal>.backup</literal> or <literal>.history</literal>. Also be aware that
+ the base name of the <literal>%p</literal> path will be different from
+ <literal>%f</literal>; do not expect them to be interchangeable.
</para>
<para>
WAL segments that cannot be found in the archive will be sought in
- <filename>pg_wal/</>; this allows use of recent un-archived segments.
+ <filename>pg_wal/</filename>; this allows use of recent un-archived segments.
However, segments that are available from the archive will be used in
- preference to files in <filename>pg_wal/</>.
+ preference to files in <filename>pg_wal/</filename>.
</para>
<para>
Normally, recovery will proceed through all available WAL segments,
thereby restoring the database to the current point in time (or as
close as possible given the available WAL segments). Therefore, a normal
- recovery will end with a <quote>file not found</> message, the exact text
+ recovery will end with a <quote>file not found</quote> message, the exact text
of the error message depending upon your choice of
- <varname>restore_command</>. You may also see an error message
+ <varname>restore_command</varname>. You may also see an error message
at the start of recovery for a file named something like
- <filename>00000001.history</>. This is also normal and does not
+ <filename>00000001.history</filename>. This is also normal and does not
indicate a problem in simple recovery situations; see
<xref linkend="backup-timelines"> for discussion.
</para>
<para>
If you want to recover to some previous point in time (say, right before
the junior DBA dropped your main transaction table), just specify the
- required <link linkend="recovery-target-settings">stopping point</link> in <filename>recovery.conf</>. You can specify
- the stop point, known as the <quote>recovery target</>, either by
+ required <link linkend="recovery-target-settings">stopping point</link> in <filename>recovery.conf</filename>. You can specify
+ the stop point, known as the <quote>recovery target</quote>, either by
date/time, named restore point or by completion of a specific transaction
ID. As of this writing only the date/time and named restore point options
are very usable, since there are no tools to help you identify with any
<note>
<para>
The stop point must be after the ending time of the base backup, i.e.,
- the end time of <function>pg_stop_backup</>. You cannot use a base backup
+ the end time of <function>pg_stop_backup</function>. You cannot use a base backup
to recover to a time when that backup was in progress. (To
recover to such a time, you must go back to your previous base backup
and roll forward from there.)
If recovery finds corrupted WAL data, recovery will
halt at that point and the server will not start. In such a case the
recovery process could be re-run from the beginning, specifying a
- <quote>recovery target</> before the point of corruption so that recovery
+ <quote>recovery target</quote> before the point of corruption so that recovery
can complete normally.
If recovery fails for an external reason, such as a system crash or
if the WAL archive has become inaccessible, then the recovery can simply
be restarted and it will restart almost from where it failed.
Recovery restart works much like checkpointing in normal operation:
the server periodically forces all its state to disk, and then updates
- the <filename>pg_control</> file to indicate that the already-processed
+ the <filename>pg_control</filename> file to indicate that the already-processed
WAL data need not be scanned again.
</para>
suppose you dropped a critical table at 5:15PM on Tuesday evening, but
didn't realize your mistake until Wednesday noon.
Unfazed, you get out your backup, restore to the point-in-time 5:14PM
- Tuesday evening, and are up and running. In <emphasis>this</> history of
+ Tuesday evening, and are up and running. In <emphasis>this</emphasis> history of
the database universe, you never dropped the table. But suppose
you later realize this wasn't such a great idea, and would like
to return to sometime Wednesday morning in the original history.
</para>
<para>
- To deal with this problem, <productname>PostgreSQL</> has a notion
- of <firstterm>timelines</>. Whenever an archive recovery completes,
+ To deal with this problem, <productname>PostgreSQL</productname> has a notion
+ of <firstterm>timelines</firstterm>. Whenever an archive recovery completes,
a new timeline is created to identify the series of WAL records
generated after that recovery. The timeline
ID number is part of WAL segment file names so a new timeline does
and so have to do several point-in-time recoveries by trial and error
until you find the best place to branch off from the old history. Without
timelines this process would soon generate an unmanageable mess. With
- timelines, you can recover to <emphasis>any</> prior state, including
+ timelines, you can recover to <emphasis>any</emphasis> prior state, including
states in timeline branches that you abandoned earlier.
</para>
<para>
- Every time a new timeline is created, <productname>PostgreSQL</> creates
- a <quote>timeline history</> file that shows which timeline it branched
+ Every time a new timeline is created, <productname>PostgreSQL</productname> creates
+ a <quote>timeline history</quote> file that shows which timeline it branched
off from and when. These history files are necessary to allow the system
to pick the right WAL segment files when recovering from an archive that
contains multiple timelines. Therefore, they are archived into the WAL
that was current when the base backup was taken. If you wish to recover
into some child timeline (that is, you want to return to some state that
was itself generated after a recovery attempt), you need to specify the
- target timeline ID in <filename>recovery.conf</>. You cannot recover into
+ target timeline ID in <filename>recovery.conf</filename>. You cannot recover into
timelines that branched off earlier than the base backup.
</para>
</sect2>
<title>Standalone Hot Backups</title>
<para>
- It is possible to use <productname>PostgreSQL</>'s backup facilities to
+ It is possible to use <productname>PostgreSQL</productname>'s backup facilities to
produce standalone hot backups. These are backups that cannot be used
for point-in-time recovery, yet are typically much faster to backup and
- restore than <application>pg_dump</> dumps. (They are also much larger
- than <application>pg_dump</> dumps, so in some cases the speed advantage
+ restore than <application>pg_dump</application> dumps. (They are also much larger
+ than <application>pg_dump</application> dumps, so in some cases the speed advantage
might be negated.)
</para>
<para>
As with base backups, the easiest way to produce a standalone
hot backup is to use the <xref linkend="app-pgbasebackup">
- tool. If you include the <literal>-X</> parameter when calling
+ tool. If you include the <literal>-X</literal> parameter when calling
it, all the write-ahead log required to use the backup will be
included in the backup automatically, and no special action is
required to restore the backup.
If more flexibility in copying the backup files is needed, a lower
level process can be used for standalone hot backups as well.
To prepare for low level standalone hot backups, make sure
- <varname>wal_level</> is set to
- <literal>replica</> or higher, <varname>archive_mode</> to
- <literal>on</>, and set up an <varname>archive_command</> that performs
- archiving only when a <emphasis>switch file</> exists. For example:
+ <varname>wal_level</varname> is set to
+ <literal>replica</literal> or higher, <varname>archive_mode</varname> to
+ <literal>on</literal>, and set up an <varname>archive_command</varname> that performs
+ archiving only when a <emphasis>switch file</emphasis> exists. For example:
<programlisting>
archive_command = 'test ! -f /var/lib/pgsql/backup_in_progress || (test ! -f /var/lib/pgsql/archive/%f && cp %p /var/lib/pgsql/archive/%f)'
</programlisting>
This command will perform archiving when
- <filename>/var/lib/pgsql/backup_in_progress</> exists, and otherwise
- silently return zero exit status (allowing <productname>PostgreSQL</>
+ <filename>/var/lib/pgsql/backup_in_progress</filename> exists, and otherwise
+ silently return zero exit status (allowing <productname>PostgreSQL</productname>
to recycle the unwanted WAL file).
</para>
rm /var/lib/pgsql/backup_in_progress
tar -rf /var/lib/pgsql/backup.tar /var/lib/pgsql/archive/
</programlisting>
- The switch file <filename>/var/lib/pgsql/backup_in_progress</> is
+ The switch file <filename>/var/lib/pgsql/backup_in_progress</filename> is
created first, enabling archiving of completed WAL files to occur.
After the backup the switch file is removed. Archived WAL files are
then added to the backup so that both base backup and all required
- WAL files are part of the same <application>tar</> file.
+ WAL files are part of the same <application>tar</application> file.
Please remember to add error handling to your backup scripts.
</para>
<programlisting>
archive_command = 'gzip < %p > /var/lib/pgsql/archive/%f'
</programlisting>
- You will then need to use <application>gunzip</> during recovery:
+ You will then need to use <application>gunzip</application> during recovery:
<programlisting>
restore_command = 'gunzip < /mnt/server/archivedir/%f > %p'
</programlisting>
<para>
Many people choose to use scripts to define their
<varname>archive_command</varname>, so that their
- <filename>postgresql.conf</> entry looks very simple:
+ <filename>postgresql.conf</filename> entry looks very simple:
<programlisting>
archive_command = 'local_backup_script.sh "%p" "%f"'
</programlisting>
more than a single command in the archiving process.
This allows all complexity to be managed within the script, which
can be written in a popular scripting language such as
- <application>bash</> or <application>perl</>.
+ <application>bash</application> or <application>perl</application>.
</para>
<para>
<para>
When using an <varname>archive_command</varname> script, it's desirable
to enable <xref linkend="guc-logging-collector">.
- Any messages written to <systemitem>stderr</> from the script will then
+ Any messages written to <systemitem>stderr</systemitem> from the script will then
appear in the database server log, allowing complex configurations to
be diagnosed easily if they fail.
</para>
<para>
If a <xref linkend="sql-createdatabase">
command is executed while a base backup is being taken, and then
- the template database that the <command>CREATE DATABASE</> copied
+ the template database that the <command>CREATE DATABASE</command> copied
is modified while the base backup is still in progress, it is
possible that recovery will cause those modifications to be
propagated into the created database as well. This is of course
before you do so.) Turning off page snapshots does not prevent
use of the logs for PITR operations. An area for future
development is to compress archived WAL data by removing
- unnecessary page copies even when <varname>full_page_writes</> is
+ unnecessary page copies even when <varname>full_page_writes</varname> is
on. In the meantime, administrators might wish to reduce the number
of page snapshots included in WAL by increasing the checkpoint
interval parameters as much as feasible.
PostgreSQL can be extended to run user-supplied code in separate processes.
Such processes are started, stopped and monitored by <command>postgres</command>,
which permits them to have a lifetime closely linked to the server's status.
- These processes have the option to attach to <productname>PostgreSQL</>'s
+ These processes have the option to attach to <productname>PostgreSQL</productname>'s
shared memory area and to connect to databases internally; they can also run
multiple transactions serially, just like a regular client-connected server
- process. Also, by linking to <application>libpq</> they can connect to the
+ process. Also, by linking to <application>libpq</application> they can connect to the
server and behave like a regular client application.
</para>
<warning>
<para>
There are considerable robustness and security risks in using background
- worker processes because, being written in the <literal>C</> language,
+ worker processes because, being written in the <literal>C</literal> language,
they have unrestricted access to data. Administrators wishing to enable
modules that include background worker process should exercise extreme
caution. Only carefully audited modules should be permitted to run
<para>
Background workers can be initialized at the time that
- <productname>PostgreSQL</> is started by including the module name in
- <varname>shared_preload_libraries</>. A module wishing to run a background
+ <productname>PostgreSQL</productname> is started by including the module name in
+ <varname>shared_preload_libraries</varname>. A module wishing to run a background
worker can register it by calling
<function>RegisterBackgroundWorker(<type>BackgroundWorker *worker</type>)</function>
- from its <function>_PG_init()</>. Background workers can also be started
+ from its <function>_PG_init()</function>. Background workers can also be started
after the system is up and running by calling the function
<function>RegisterDynamicBackgroundWorker(<type>BackgroundWorker
*worker, BackgroundWorkerHandle **handle</type>)</function>. Unlike
- <function>RegisterBackgroundWorker</>, which can only be called from within
+ <function>RegisterBackgroundWorker</function>, which can only be called from within
the postmaster, <function>RegisterDynamicBackgroundWorker</function> must be
called from a regular backend.
</para>
</para>
<para>
- <structfield>bgw_name</> and <structfield>bgw_type</structfield> are
+ <structfield>bgw_name</structfield> and <structfield>bgw_type</structfield> are
strings to be used in log messages, process listings and similar contexts.
<structfield>bgw_type</structfield> should be the same for all background
workers of the same type, so that it is possible to group such workers in a
</para>
<para>
- <structfield>bgw_flags</> is a bitwise-or'd bit mask indicating the
+ <structfield>bgw_flags</structfield> is a bitwise-or'd bit mask indicating the
capabilities that the module wants. Possible values are:
<variablelist>
<para>
<structfield>bgw_start_time</structfield> is the server state during which
- <command>postgres</> should start the process; it can be one of
- <literal>BgWorkerStart_PostmasterStart</> (start as soon as
- <command>postgres</> itself has finished its own initialization; processes
+ <command>postgres</command> should start the process; it can be one of
+ <literal>BgWorkerStart_PostmasterStart</literal> (start as soon as
+ <command>postgres</command> itself has finished its own initialization; processes
requesting this are not eligible for database connections),
- <literal>BgWorkerStart_ConsistentState</> (start as soon as a consistent state
+ <literal>BgWorkerStart_ConsistentState</literal> (start as soon as a consistent state
has been reached in a hot standby, allowing processes to connect to
databases and run read-only queries), and
- <literal>BgWorkerStart_RecoveryFinished</> (start as soon as the system has
+ <literal>BgWorkerStart_RecoveryFinished</literal> (start as soon as the system has
entered normal read-write state). Note the last two values are equivalent
in a server that's not a hot standby. Note that this setting only indicates
when the processes are to be started; they do not stop when a different state
</para>
<para>
- <structfield>bgw_main_arg</structfield> is the <type>Datum</> argument
+ <structfield>bgw_main_arg</structfield> is the <type>Datum</type> argument
to the background worker main function. This main function should take a
- single argument of type <type>Datum</> and return <type>void</>.
+ single argument of type <type>Datum</type> and return <type>void</type>.
<structfield>bgw_main_arg</structfield> will be passed as the argument.
In addition, the global variable <literal>MyBgworkerEntry</literal>
points to a copy of the <structname>BackgroundWorker</structname> structure
<para>
On Windows (and anywhere else where <literal>EXEC_BACKEND</literal> is
defined) or in dynamic background workers it is not safe to pass a
- <type>Datum</> by reference, only by value. If an argument is required, it
+ <type>Datum</type> by reference, only by value. If an argument is required, it
is safest to pass an int32 or other small value and use that as an index
- into an array allocated in shared memory. If a value like a <type>cstring</>
+ into an array allocated in shared memory. If a value like a <type>cstring</type>
or <type>text</type> is passed then the pointer won't be valid from the
new background worker process.
</para>
<para>
<structfield>bgw_extra</structfield> can contain extra data to be passed
- to the background worker. Unlike <structfield>bgw_main_arg</>, this data
+ to the background worker. Unlike <structfield>bgw_main_arg</structfield>, this data
is not passed as an argument to the worker's main function, but it can be
accessed via <literal>MyBgworkerEntry</literal>, as discussed above.
</para>
<para>
<structfield>bgw_notify_pid</structfield> is the PID of a PostgreSQL
- backend process to which the postmaster should send <literal>SIGUSR1</>
+ backend process to which the postmaster should send <literal>SIGUSR1</literal>
when the process is started or exits. It should be 0 for workers registered
at postmaster startup time, or when the backend registering the worker does
not wish to wait for the worker to start up. Otherwise, it should be
- initialized to <literal>MyProcPid</>.
+ initialized to <literal>MyProcPid</literal>.
</para>
<para>Once running, the process can connect to a database by calling
<function>BackgroundWorkerInitializeConnection(<parameter>char *dbname</parameter>, <parameter>char *username</parameter>)</function> or
<function>BackgroundWorkerInitializeConnectionByOid(<parameter>Oid dboid</parameter>, <parameter>Oid useroid</parameter>)</function>.
This allows the process to run transactions and queries using the
- <literal>SPI</literal> interface. If <varname>dbname</> is NULL or
- <varname>dboid</> is <literal>InvalidOid</>, the session is not connected
+ <literal>SPI</literal> interface. If <varname>dbname</varname> is NULL or
+ <varname>dboid</varname> is <literal>InvalidOid</literal>, the session is not connected
to any particular database, but shared catalogs can be accessed.
- If <varname>username</> is NULL or <varname>useroid</> is
- <literal>InvalidOid</>, the process will run as the superuser created
- during <command>initdb</>.
+ If <varname>username</varname> is NULL or <varname>useroid</varname> is
+ <literal>InvalidOid</literal>, the process will run as the superuser created
+ during <command>initdb</command>.
A background worker can only call one of these two functions, and only
once. It is not possible to switch databases.
</para>
background worker's main function, and must be unblocked by it; this is to
allow the process to customize its signal handlers, if necessary.
Signals can be unblocked in the new process by calling
- <function>BackgroundWorkerUnblockSignals</> and blocked by calling
- <function>BackgroundWorkerBlockSignals</>.
+ <function>BackgroundWorkerUnblockSignals</function> and blocked by calling
+ <function>BackgroundWorkerBlockSignals</function>.
</para>
<para>
If <structfield>bgw_restart_time</structfield> for a background worker is
- configured as <literal>BGW_NEVER_RESTART</>, or if it exits with an exit
- code of 0 or is terminated by <function>TerminateBackgroundWorker</>,
+ configured as <literal>BGW_NEVER_RESTART</literal>, or if it exits with an exit
+ code of 0 or is terminated by <function>TerminateBackgroundWorker</function>,
it will be automatically unregistered by the postmaster on exit.
Otherwise, it will be restarted after the time period configured via
- <structfield>bgw_restart_time</>, or immediately if the postmaster
+ <structfield>bgw_restart_time</structfield>, or immediately if the postmaster
reinitializes the cluster due to a backend failure. Backends which need
to suspend execution only temporarily should use an interruptible sleep
rather than exiting; this can be achieved by calling
<function>WaitLatch()</function>. Make sure the
- <literal>WL_POSTMASTER_DEATH</> flag is set when calling that function, and
+ <literal>WL_POSTMASTER_DEATH</literal> flag is set when calling that function, and
verify the return code for a prompt exit in the emergency case that
- <command>postgres</> itself has terminated.
+ <command>postgres</command> itself has terminated.
</para>
<para>
opaque handle that can subsequently be passed to
<function>GetBackgroundWorkerPid(<parameter>BackgroundWorkerHandle *</parameter>, <parameter>pid_t *</parameter>)</function> or
<function>TerminateBackgroundWorker(<parameter>BackgroundWorkerHandle *</parameter>)</function>.
- <function>GetBackgroundWorkerPid</> can be used to poll the status of the
- worker: a return value of <literal>BGWH_NOT_YET_STARTED</> indicates that
+ <function>GetBackgroundWorkerPid</function> can be used to poll the status of the
+ worker: a return value of <literal>BGWH_NOT_YET_STARTED</literal> indicates that
the worker has not yet been started by the postmaster;
<literal>BGWH_STOPPED</literal> indicates that it has been started but is
no longer running; and <literal>BGWH_STARTED</literal> indicates that it is
currently running. In this last case, the PID will also be returned via the
second argument.
- <function>TerminateBackgroundWorker</> causes the postmaster to send
- <literal>SIGTERM</> to the worker if it is running, and to unregister it
+ <function>TerminateBackgroundWorker</function> causes the postmaster to send
+ <literal>SIGTERM</literal> to the worker if it is running, and to unregister it
as soon as it is not.
</para>
<para>
In some cases, a process which registers a background worker may wish to
wait for the worker to start up. This can be accomplished by initializing
- <structfield>bgw_notify_pid</structfield> to <literal>MyProcPid</> and
+ <structfield>bgw_notify_pid</structfield> to <literal>MyProcPid</literal> and
then passing the <type>BackgroundWorkerHandle *</type> obtained at
registration time to
<function>WaitForBackgroundWorkerStartup(<parameter>BackgroundWorkerHandle
*handle</parameter>, <parameter>pid_t *</parameter>)</function> function.
This function will block until the postmaster has attempted to start the
background worker, or until the postmaster dies. If the background runner
- is running, the return value will <literal>BGWH_STARTED</>, and
+ is running, the return value will <literal>BGWH_STARTED</literal>, and
the PID will be written to the provided address. Otherwise, the return
value will be <literal>BGWH_STOPPED</literal> or
<literal>BGWH_POSTMASTER_DIED</literal>.
</para>
<para>
- The <filename>src/test/modules/worker_spi</> module
+ The <filename>src/test/modules/worker_spi</filename> module
contains a working example,
which demonstrates some useful techniques.
</para>
<abstract>
<para>
Discusses SQL history and syntax, and describes the addition of
- <literal>INTERSECT</> and <literal>EXCEPT</> constructs into
+ <literal>INTERSECT</literal> and <literal>EXCEPT</literal> constructs into
<productname>PostgreSQL</productname>. Prepared as a Master's
Thesis with the support of O. Univ. Prof. Dr. Georg Gottlob and
Univ. Ass. Mag. Katrin Seyr at Vienna University of Technology.
input file used by <application>initdb</application> is created as
part of building and installing <productname>PostgreSQL</productname>
by a program named <filename>genbki.pl</filename>, which reads some
- specially formatted C header files in the <filename>src/include/catalog/</>
+ specially formatted C header files in the <filename>src/include/catalog/</filename>
directory of the source tree. The created <acronym>BKI</acronym> file
is called <filename>postgres.bki</filename> and is
normally installed in the
<variablelist>
<varlistentry>
<term>
- <literal>create</>
+ <literal>create</literal>
<replaceable class="parameter">tablename</replaceable>
<replaceable class="parameter">tableoid</replaceable>
- <optional><literal>bootstrap</></optional>
- <optional><literal>shared_relation</></optional>
- <optional><literal>without_oids</></optional>
- <optional><literal>rowtype_oid</> <replaceable>oid</></optional>
+ <optional><literal>bootstrap</literal></optional>
+ <optional><literal>shared_relation</literal></optional>
+ <optional><literal>without_oids</literal></optional>
+ <optional><literal>rowtype_oid</literal> <replaceable>oid</replaceable></optional>
(<replaceable class="parameter">name1</replaceable> =
<replaceable class="parameter">type1</replaceable>
<optional>FORCE NOT NULL | FORCE NULL </optional> <optional>,
<para>
The following column types are supported directly by
- <filename>bootstrap.c</>: <type>bool</type>,
+ <filename>bootstrap.c</filename>: <type>bool</type>,
<type>bytea</type>, <type>char</type> (1 byte),
<type>name</type>, <type>int2</type>,
<type>int4</type>, <type>regproc</type>, <type>regclass</type>,
<type>_oid</type> (array), <type>_char</type> (array),
<type>_aclitem</type> (array). Although it is possible to create
tables containing columns of other types, this cannot be done until
- after <structname>pg_type</> has been created and filled with
+ after <structname>pg_type</structname> has been created and filled with
appropriate entries. (That effectively means that only these
column types can be used in bootstrapped tables, but non-bootstrap
catalogs can contain any built-in type.)
</para>
<para>
- When <literal>bootstrap</> is specified,
+ When <literal>bootstrap</literal> is specified,
the table will only be created on disk; nothing is entered into
<structname>pg_class</structname>,
<structname>pg_attribute</structname>, etc, for it. Thus the
table will not be accessible by ordinary SQL operations until
- such entries are made the hard way (with <literal>insert</>
+ such entries are made the hard way (with <literal>insert</literal>
commands). This option is used for creating
<structname>pg_class</structname> etc themselves.
</para>
<para>
- The table is created as shared if <literal>shared_relation</> is
+ The table is created as shared if <literal>shared_relation</literal> is
specified.
- It will have OIDs unless <literal>without_oids</> is specified.
- The table's row type OID (<structname>pg_type</> OID) can optionally
- be specified via the <literal>rowtype_oid</> clause; if not specified,
- an OID is automatically generated for it. (The <literal>rowtype_oid</>
- clause is useless if <literal>bootstrap</> is specified, but it can be
+ It will have OIDs unless <literal>without_oids</literal> is specified.
+ The table's row type OID (<structname>pg_type</structname> OID) can optionally
+ be specified via the <literal>rowtype_oid</literal> clause; if not specified,
+ an OID is automatically generated for it. (The <literal>rowtype_oid</literal>
+ clause is useless if <literal>bootstrap</literal> is specified, but it can be
provided anyway for documentation.)
</para>
</listitem>
<varlistentry>
<term>
- <literal>open</> <replaceable class="parameter">tablename</replaceable>
+ <literal>open</literal> <replaceable class="parameter">tablename</replaceable>
</term>
<listitem>
<varlistentry>
<term>
- <literal>close</> <optional><replaceable class="parameter">tablename</replaceable></optional>
+ <literal>close</literal> <optional><replaceable class="parameter">tablename</replaceable></optional>
</term>
<listitem>
<varlistentry>
<term>
- <literal>insert</> <optional><literal>OID =</> <replaceable class="parameter">oid_value</replaceable></optional> <literal>(</> <replaceable class="parameter">value1</replaceable> <replaceable class="parameter">value2</replaceable> ... <literal>)</>
+ <literal>insert</literal> <optional><literal>OID =</literal> <replaceable class="parameter">oid_value</replaceable></optional> <literal>(</literal> <replaceable class="parameter">value1</replaceable> <replaceable class="parameter">value2</replaceable> ... <literal>)</literal>
</term>
<listitem>
<varlistentry>
<term>
- <literal>declare</> <optional><literal>unique</></optional>
- <literal>index</> <replaceable class="parameter">indexname</replaceable>
+ <literal>declare</literal> <optional><literal>unique</literal></optional>
+ <literal>index</literal> <replaceable class="parameter">indexname</replaceable>
<replaceable class="parameter">indexoid</replaceable>
- <literal>on</> <replaceable class="parameter">tablename</replaceable>
- <literal>using</> <replaceable class="parameter">amname</replaceable>
- <literal>(</> <replaceable class="parameter">opclass1</replaceable>
+ <literal>on</literal> <replaceable class="parameter">tablename</replaceable>
+ <literal>using</literal> <replaceable class="parameter">amname</replaceable>
+ <literal>(</literal> <replaceable class="parameter">opclass1</replaceable>
<replaceable class="parameter">name1</replaceable>
- <optional>, ...</optional> <literal>)</>
+ <optional>, ...</optional> <literal>)</literal>
</term>
<listitem>
<varlistentry>
<term>
- <literal>declare toast</>
+ <literal>declare toast</literal>
<replaceable class="parameter">toasttableoid</replaceable>
<replaceable class="parameter">toastindexoid</replaceable>
- <literal>on</> <replaceable class="parameter">tablename</replaceable>
+ <literal>on</literal> <replaceable class="parameter">tablename</replaceable>
</term>
<listitem>
<replaceable class="parameter">toasttableoid</replaceable>
and its index is assigned OID
<replaceable class="parameter">toastindexoid</replaceable>.
- As with <literal>declare index</>, filling of the index
+ As with <literal>declare index</literal>, filling of the index
is postponed.
</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><literal>build indices</></term>
+ <term><literal>build indices</literal></term>
<listitem>
<para>
<title>Structure of the Bootstrap <acronym>BKI</acronym> File</title>
<para>
- The <literal>open</> command cannot be used until the tables it uses
+ The <literal>open</literal> command cannot be used until the tables it uses
exist and have entries for the table that is to be opened.
- (These minimum tables are <structname>pg_class</>,
- <structname>pg_attribute</>, <structname>pg_proc</>, and
- <structname>pg_type</>.) To allow those tables themselves to be filled,
- <literal>create</> with the <literal>bootstrap</> option implicitly opens
+ (These minimum tables are <structname>pg_class</structname>,
+ <structname>pg_attribute</structname>, <structname>pg_proc</structname>, and
+ <structname>pg_type</structname>.) To allow those tables themselves to be filled,
+ <literal>create</literal> with the <literal>bootstrap</literal> option implicitly opens
the created table for data insertion.
</para>
<para>
- Also, the <literal>declare index</> and <literal>declare toast</>
+ Also, the <literal>declare index</literal> and <literal>declare toast</literal>
commands cannot be used until the system catalogs they need have been
created and filled in.
</para>
<orderedlist>
<listitem>
<para>
- <literal>create bootstrap</> one of the critical tables
+ <literal>create bootstrap</literal> one of the critical tables
</para>
</listitem>
<listitem>
<para>
- <literal>insert</> data describing at least the critical tables
+ <literal>insert</literal> data describing at least the critical tables
</para>
</listitem>
<listitem>
<para>
- <literal>close</>
+ <literal>close</literal>
</para>
</listitem>
<listitem>
</listitem>
<listitem>
<para>
- <literal>create</> (without <literal>bootstrap</>) a noncritical table
+ <literal>create</literal> (without <literal>bootstrap</literal>) a noncritical table
</para>
</listitem>
<listitem>
<para>
- <literal>open</>
+ <literal>open</literal>
</para>
</listitem>
<listitem>
<para>
- <literal>insert</> desired data
+ <literal>insert</literal> desired data
</para>
</listitem>
<listitem>
<para>
- <literal>close</>
+ <literal>close</literal>
</para>
</listitem>
<listitem>
</listitem>
<listitem>
<para>
- <literal>build indices</>
+ <literal>build indices</literal>
</para>
</listitem>
</orderedlist>
</indexterm>
<para>
- <literal>bloom</> provides an index access method based on
+ <literal>bloom</literal> provides an index access method based on
<ulink url="http://en.wikipedia.org/wiki/Bloom_filter">Bloom filters</ulink>.
</para>
<title>Parameters</title>
<para>
- A <literal>bloom</> index accepts the following parameters in its
- <literal>WITH</> clause:
+ A <literal>bloom</literal> index accepts the following parameters in its
+ <literal>WITH</literal> clause:
</para>
<variablelist>
<varlistentry>
- <term><literal>length</></term>
+ <term><literal>length</literal></term>
<listitem>
<para>
Length of each signature (index entry) in bits. The default
- is <literal>80</> bits and maximum is <literal>4096</>.
+ is <literal>80</literal> bits and maximum is <literal>4096</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
<variablelist>
<varlistentry>
- <term><literal>col1 — col32</></term>
+ <term><literal>col1 — col32</literal></term>
<listitem>
<para>
Number of bits generated for each index column. Each parameter's name
refers to the number of the index column that it controls. The default
- is <literal>2</> bits and maximum is <literal>4095</>. Parameters for
+ is <literal>2</literal> bits and maximum is <literal>4095</literal>. Parameters for
index columns not actually used are ignored.
</para>
</listitem>
<para>
The index is created with a signature length of 80 bits, with attributes
i1 and i2 mapped to 2 bits, and attribute i3 mapped to 4 bits. We could
- have omitted the <literal>length</>, <literal>col1</>,
- and <literal>col2</> specifications since those have the default values.
+ have omitted the <literal>length</literal>, <literal>col1</literal>,
+ and <literal>col2</literal> specifications since those have the default values.
</para>
<para>
Note the relatively large number of false positives: 2439 rows were
selected to be visited in the heap, but none actually matched the
query. We could reduce that by specifying a larger signature length.
- In this example, creating the index with <literal>length=200</>
+ In this example, creating the index with <literal>length=200</literal>
reduced the number of false positives to 55; but it doubled the index size
(to 306 MB) and ended up being slower for this query (125 ms overall).
</para>
<para>
An operator class for bloom indexes requires only a hash function for the
indexed data type and an equality operator for searching. This example
- shows the operator class definition for the <type>text</> data type:
+ shows the operator class definition for the <type>text</type> data type:
</para>
<programlisting>
<itemizedlist>
<listitem>
<para>
- Only operator classes for <type>int4</> and <type>text</> are
+ Only operator classes for <type>int4</type> and <type>text</type> are
included with the module.
</para>
</listitem>
<acronym>BRIN</acronym> is designed for handling very large tables
in which certain columns have some natural correlation with their
physical location within the table.
- A <firstterm>block range</> is a group of pages that are physically
+ A <firstterm>block range</firstterm> is a group of pages that are physically
adjacent in the table; for each block range, some summary info is stored
by the index.
For example, a table storing a store's sale orders might have
<para>
<acronym>BRIN</acronym> indexes can satisfy queries via regular bitmap
index scans, and will return all tuples in all pages within each range if
- the summary info stored by the index is <firstterm>consistent</> with the
+ the summary info stored by the index is <firstterm>consistent</firstterm> with the
query conditions.
The query executor is in charge of rechecking these tuples and discarding
those that do not match the query conditions — in other words, these
<para>
The size of the block range is determined at index creation time by
- the <literal>pages_per_range</> storage parameter. The number of index
+ the <literal>pages_per_range</literal> storage parameter. The number of index
entries will be equal to the size of the relation in pages divided by
- the selected value for <literal>pages_per_range</>. Therefore, the smaller
+ the selected value for <literal>pages_per_range</literal>. Therefore, the smaller
the number, the larger the index becomes (because of the need to
store more index entries), but at the same time the summary data stored can
be more precise and more data blocks can be skipped during an index scan.
</para>
<para>
- The <firstterm>minmax</>
+ The <firstterm>minmax</firstterm>
operator classes store the minimum and the maximum values appearing
- in the indexed column within the range. The <firstterm>inclusion</>
+ in the indexed column within the range. The <firstterm>inclusion</firstterm>
operator classes store a value which includes the values in the indexed
column within the range.
</para>
</entry>
</row>
<row>
- <entry><literal>box_inclusion_ops</></entry>
+ <entry><literal>box_inclusion_ops</literal></entry>
<entry><type>box</type></entry>
<entry>
- <literal><<</>
- <literal>&<</>
- <literal>&&</>
- <literal>&></>
- <literal>>></>
- <literal>~=</>
- <literal>@></>
- <literal><@</>
- <literal>&<|</>
- <literal><<|</>
+ <literal><<</literal>
+ <literal>&<</literal>
+ <literal>&&</literal>
+ <literal>&></literal>
+ <literal>>></literal>
+ <literal>~=</literal>
+ <literal>@></literal>
+ <literal><@</literal>
+ <literal>&<|</literal>
+ <literal><<|</literal>
<literal>|>></literal>
- <literal>|&></>
+ <literal>|&></literal>
</entry>
</row>
<row>
<entry><literal>network_inclusion_ops</literal></entry>
<entry><type>inet</type></entry>
<entry>
- <literal>&&</>
- <literal>>>=</>
+ <literal>&&</literal>
+ <literal>>>=</literal>
<literal><<=</literal>
<literal>=</literal>
- <literal>>></>
+ <literal>>></literal>
<literal><<</literal>
</entry>
</row>
</entry>
</row>
<row>
- <entry><literal>range_inclusion_ops</></entry>
+ <entry><literal>range_inclusion_ops</literal></entry>
<entry><type>any range type</type></entry>
<entry>
- <literal><<</>
- <literal>&<</>
- <literal>&&</>
- <literal>&></>
- <literal>>></>
- <literal>@></>
- <literal><@</>
- <literal>-|-</>
- <literal>=</>
+ <literal><<</literal>
+ <literal>&<</literal>
+ <literal>&&</literal>
+ <literal>&></literal>
+ <literal>>></literal>
+ <literal>@></literal>
+ <literal><@</literal>
+ <literal>-|-</literal>
+ <literal>=</literal>
<literal><</literal>
<literal><=</literal>
<literal>=</literal>
<variablelist>
<varlistentry>
- <term><function>BrinOpcInfo *opcInfo(Oid type_oid)</></term>
+ <term><function>BrinOpcInfo *opcInfo(Oid type_oid)</function></term>
<listitem>
<para>
Returns internal information about the indexed columns' summary data.
- The return value must point to a palloc'd <structname>BrinOpcInfo</>,
+ The return value must point to a palloc'd <structname>BrinOpcInfo</structname>,
which has this definition:
<programlisting>
typedef struct BrinOpcInfo
TypeCacheEntry *oi_typcache[FLEXIBLE_ARRAY_MEMBER];
} BrinOpcInfo;
</programlisting>
- <structname>BrinOpcInfo</>.<structfield>oi_opaque</> can be used by the
+ <structname>BrinOpcInfo</structname>.<structfield>oi_opaque</structfield> can be used by the
operator class routines to pass information between support procedures
during an index scan.
</para>
It should accept two arguments with the same data type as the operator class,
and return the union of them. The inclusion operator class can store union
values with different data types if it is defined with the
- <literal>STORAGE</> parameter. The return value of the union
- function should match the <literal>STORAGE</> data type.
+ <literal>STORAGE</literal> parameter. The return value of the union
+ function should match the <literal>STORAGE</literal> data type.
</para>
<para>
on another operator strategy as shown in
<xref linkend="brin-extensibility-inclusion-table">, or the same
operator strategy as themselves. They require the dependency
- operator to be defined with the <literal>STORAGE</> data type as the
+ operator to be defined with the <literal>STORAGE</literal> data type as the
left-hand-side argument and the other supported data type to be the
right-hand-side argument of the supported operator. See
- <literal>float4_minmax_ops</> as an example of minmax, and
- <literal>box_inclusion_ops</> as an example of inclusion.
+ <literal>float4_minmax_ops</literal> as an example of minmax, and
+ <literal>box_inclusion_ops</literal> as an example of inclusion.
</para>
</sect1>
</chapter>
</indexterm>
<para>
- <filename>btree_gin</> provides sample GIN operator classes that
+ <filename>btree_gin</filename> provides sample GIN operator classes that
implement B-tree equivalent behavior for the data types
- <type>int2</>, <type>int4</>, <type>int8</>, <type>float4</>,
- <type>float8</>, <type>timestamp with time zone</>,
- <type>timestamp without time zone</>, <type>time with time zone</>,
- <type>time without time zone</>, <type>date</>, <type>interval</>,
- <type>oid</>, <type>money</>, <type>"char"</>,
- <type>varchar</>, <type>text</>, <type>bytea</>, <type>bit</>,
- <type>varbit</>, <type>macaddr</>, <type>macaddr8</>, <type>inet</>,
- <type>cidr</>, and all <type>enum</> types.
+ <type>int2</type>, <type>int4</type>, <type>int8</type>, <type>float4</type>,
+ <type>float8</type>, <type>timestamp with time zone</type>,
+ <type>timestamp without time zone</type>, <type>time with time zone</type>,
+ <type>time without time zone</type>, <type>date</type>, <type>interval</type>,
+ <type>oid</type>, <type>money</type>, <type>"char"</type>,
+ <type>varchar</type>, <type>text</type>, <type>bytea</type>, <type>bit</type>,
+ <type>varbit</type>, <type>macaddr</type>, <type>macaddr8</type>, <type>inet</type>,
+ <type>cidr</type>, and all <type>enum</type> types.
</para>
<para>
</indexterm>
<para>
- <filename>btree_gist</> provides GiST index operator classes that
+ <filename>btree_gist</filename> provides GiST index operator classes that
implement B-tree equivalent behavior for the data types
- <type>int2</>, <type>int4</>, <type>int8</>, <type>float4</>,
- <type>float8</>, <type>numeric</>, <type>timestamp with time zone</>,
- <type>timestamp without time zone</>, <type>time with time zone</>,
- <type>time without time zone</>, <type>date</>, <type>interval</>,
- <type>oid</>, <type>money</>, <type>char</>,
- <type>varchar</>, <type>text</>, <type>bytea</>, <type>bit</>,
- <type>varbit</>, <type>macaddr</>, <type>macaddr8</>, <type>inet</>,
- <type>cidr</>, <type>uuid</>, and all <type>enum</> types.
+ <type>int2</type>, <type>int4</type>, <type>int8</type>, <type>float4</type>,
+ <type>float8</type>, <type>numeric</type>, <type>timestamp with time zone</type>,
+ <type>timestamp without time zone</type>, <type>time with time zone</type>,
+ <type>time without time zone</type>, <type>date</type>, <type>interval</type>,
+ <type>oid</type>, <type>money</type>, <type>char</type>,
+ <type>varchar</type>, <type>text</type>, <type>bytea</type>, <type>bit</type>,
+ <type>varbit</type>, <type>macaddr</type>, <type>macaddr8</type>, <type>inet</type>,
+ <type>cidr</type>, <type>uuid</type>, and all <type>enum</type> types.
</para>
<para>
</para>
<para>
- In addition to the typical B-tree search operators, <filename>btree_gist</>
+ In addition to the typical B-tree search operators, <filename>btree_gist</filename>
also provides index support for <literal><></literal> (<quote>not
equals</quote>). This may be useful in combination with an
<link linkend="SQL-CREATETABLE-EXCLUDE">exclusion constraint</link>,
<para>
Also, for data types for which there is a natural distance metric,
- <filename>btree_gist</> defines a distance operator <literal><-></>,
+ <filename>btree_gist</filename> defines a distance operator <literal><-></literal>,
and provides GiST index support for nearest-neighbor searches using
this operator. Distance operators are provided for
- <type>int2</>, <type>int4</>, <type>int8</>, <type>float4</>,
- <type>float8</>, <type>timestamp with time zone</>,
- <type>timestamp without time zone</>,
- <type>time without time zone</>, <type>date</>, <type>interval</>,
- <type>oid</>, and <type>money</>.
+ <type>int2</type>, <type>int4</type>, <type>int8</type>, <type>float4</type>,
+ <type>float8</type>, <type>timestamp with time zone</type>,
+ <type>timestamp without time zone</type>,
+ <type>time without time zone</type>, <type>date</type>, <type>interval</type>,
+ <type>oid</type>, and <type>money</type>.
</para>
<sect2>
</para>
<table>
- <title><structname>pg_aggregate</> Columns</title>
+ <title><structname>pg_aggregate</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><type>char</type></entry>
<entry></entry>
<entry>Aggregate kind:
- <literal>n</literal> for <quote>normal</> aggregates,
- <literal>o</literal> for <quote>ordered-set</> aggregates, or
- <literal>h</literal> for <quote>hypothetical-set</> aggregates
+ <literal>n</literal> for <quote>normal</quote> aggregates,
+ <literal>o</literal> for <quote>ordered-set</quote> aggregates, or
+ <literal>h</literal> for <quote>hypothetical-set</quote> aggregates
</entry>
</row>
<row>
<entry></entry>
<entry>Number of direct (non-aggregated) arguments of an ordered-set or
hypothetical-set aggregate, counting a variadic array as one argument.
- If equal to <structfield>pronargs</>, the aggregate must be variadic
+ If equal to <structfield>pronargs</structfield>, the aggregate must be variadic
and the variadic array describes the aggregated arguments as well as
the final direct arguments.
Always zero for normal aggregates.</entry>
</para>
<table>
- <title><structname>pg_am</> Columns</title>
+ <title><structname>pg_am</structname> Columns</title>
<tgroup cols="4">
<thead>
<note>
<para>
- Before <productname>PostgreSQL</> 9.6, <structname>pg_am</structname>
+ Before <productname>PostgreSQL</productname> 9.6, <structname>pg_am</structname>
contained many additional columns representing properties of index access
methods. That data is now only directly visible at the C code level.
However, <function>pg_index_column_has_property()</function> and related
The catalog <structname>pg_amop</structname> stores information about
operators associated with access method operator families. There is one
row for each operator that is a member of an operator family. A family
- member can be either a <firstterm>search</> operator or an
- <firstterm>ordering</> operator. An operator
+ member can be either a <firstterm>search</firstterm> operator or an
+ <firstterm>ordering</firstterm> operator. An operator
can appear in more than one family, but cannot appear in more than one
search position nor more than one ordering position within a family.
(It is allowed, though unlikely, for an operator to be used for both
</para>
<table>
- <title><structname>pg_amop</> Columns</title>
+ <title><structname>pg_amop</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><structfield>amoppurpose</structfield></entry>
<entry><type>char</type></entry>
<entry></entry>
- <entry>Operator purpose, either <literal>s</> for search or
- <literal>o</> for ordering</entry>
+ <entry>Operator purpose, either <literal>s</literal> for search or
+ <literal>o</literal> for ordering</entry>
</row>
<row>
</table>
<para>
- A <quote>search</> operator entry indicates that an index of this operator
+ A <quote>search</quote> operator entry indicates that an index of this operator
family can be searched to find all rows satisfying
- <literal>WHERE</>
- <replaceable>indexed_column</>
- <replaceable>operator</>
- <replaceable>constant</>.
+ <literal>WHERE</literal>
+ <replaceable>indexed_column</replaceable>
+ <replaceable>operator</replaceable>
+ <replaceable>constant</replaceable>.
Obviously, such an operator must return <type>boolean</type>, and its left-hand input
type must match the index's column data type.
</para>
<para>
- An <quote>ordering</> operator entry indicates that an index of this
+ An <quote>ordering</quote> operator entry indicates that an index of this
operator family can be scanned to return rows in the order represented by
- <literal>ORDER BY</>
- <replaceable>indexed_column</>
- <replaceable>operator</>
- <replaceable>constant</>.
+ <literal>ORDER BY</literal>
+ <replaceable>indexed_column</replaceable>
+ <replaceable>operator</replaceable>
+ <replaceable>constant</replaceable>.
Such an operator could return any sortable data type, though again
its left-hand input type must match the index's column data type.
- The exact semantics of the <literal>ORDER BY</> are specified by the
+ The exact semantics of the <literal>ORDER BY</literal> are specified by the
<structfield>amopsortfamily</structfield> column, which must reference
a B-tree operator family for the operator's result type.
</para>
<para>
At present, it's assumed that the sort order for an ordering operator
is the default for the referenced operator family, i.e., <literal>ASC NULLS
- LAST</>. This might someday be relaxed by adding additional columns
+ LAST</literal>. This might someday be relaxed by adding additional columns
to specify sort options explicitly.
</para>
</note>
<para>
- An entry's <structfield>amopmethod</> must match the
- <structname>opfmethod</> of its containing operator family (including
- <structfield>amopmethod</> here is an intentional denormalization of the
+ An entry's <structfield>amopmethod</structfield> must match the
+ <structname>opfmethod</structname> of its containing operator family (including
+ <structfield>amopmethod</structfield> here is an intentional denormalization of the
catalog structure for performance reasons). Also,
- <structfield>amoplefttype</> and <structfield>amoprighttype</> must match
- the <structfield>oprleft</> and <structfield>oprright</> fields of the
- referenced <structname>pg_operator</> entry.
+ <structfield>amoplefttype</structfield> and <structfield>amoprighttype</structfield> must match
+ the <structfield>oprleft</structfield> and <structfield>oprright</structfield> fields of the
+ referenced <structname>pg_operator</structname> entry.
</para>
</sect1>
<para>
The usual interpretation of the
- <structfield>amproclefttype</> and <structfield>amprocrighttype</> fields
+ <structfield>amproclefttype</structfield> and <structfield>amprocrighttype</structfield> fields
is that they identify the left and right input types of the operator(s)
that a particular support procedure supports. For some access methods
these match the input data type(s) of the support procedure itself, for
- others not. There is a notion of <quote>default</> support procedures for
- an index, which are those with <structfield>amproclefttype</> and
- <structfield>amprocrighttype</> both equal to the index operator class's
- <structfield>opcintype</>.
+ others not. There is a notion of <quote>default</quote> support procedures for
+ an index, which are those with <structfield>amproclefttype</structfield> and
+ <structfield>amprocrighttype</structfield> both equal to the index operator class's
+ <structfield>opcintype</structfield>.
</para>
</sect1>
</para>
<table>
- <title><structname>pg_attrdef</> Columns</title>
+ <title><structname>pg_attrdef</structname> Columns</title>
<tgroup cols="4">
<thead>
The <structfield>adsrc</structfield> field is historical, and is best
not used, because it does not track outside changes that might affect
the representation of the default value. Reverse-compiling the
- <structfield>adbin</structfield> field (with <function>pg_get_expr</> for
+ <structfield>adbin</structfield> field (with <function>pg_get_expr</function> for
example) is a better way to display the default value.
</para>
</para>
<table>
- <title><structname>pg_attribute</> Columns</title>
+ <title><structname>pg_attribute</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry>
Number of dimensions, if the column is an array type; otherwise 0.
(Presently, the number of dimensions of an array is not enforced,
- so any nonzero value effectively means <quote>it's an array</>.)
+ so any nonzero value effectively means <quote>it's an array</quote>.)
</entry>
</row>
supplied at table creation time (for example, the maximum
length of a <type>varchar</type> column). It is passed to
type-specific input functions and length coercion functions.
- The value will generally be -1 for types that do not need <structfield>atttypmod</>.
+ The value will generally be -1 for types that do not need <structfield>atttypmod</structfield>.
</entry>
</row>
<entry><type>bool</type></entry>
<entry></entry>
<entry>
- A copy of <literal>pg_type.typbyval</> of this column's type
+ A copy of <literal>pg_type.typbyval</literal> of this column's type
</entry>
</row>
<entry><type>char</type></entry>
<entry></entry>
<entry>
- Normally a copy of <literal>pg_type.typstorage</> of this
+ Normally a copy of <literal>pg_type.typstorage</literal> of this
column's type. For TOAST-able data types, this can be altered
after column creation to control storage policy.
</entry>
<entry><type>char</type></entry>
<entry></entry>
<entry>
- A copy of <literal>pg_type.typalign</> of this column's type
+ A copy of <literal>pg_type.typalign</literal> of this column's type
</entry>
</row>
<entry><type>text[]</type></entry>
<entry></entry>
<entry>
- Attribute-level options, as <quote>keyword=value</> strings
+ Attribute-level options, as <quote>keyword=value</quote> strings
</entry>
</row>
<entry><type>text[]</type></entry>
<entry></entry>
<entry>
- Attribute-level foreign data wrapper options, as <quote>keyword=value</> strings
+ Attribute-level foreign data wrapper options, as <quote>keyword=value</quote> strings
</entry>
</row>
In a dropped column's <structname>pg_attribute</structname> entry,
<structfield>atttypid</structfield> is reset to zero, but
<structfield>attlen</structfield> and the other fields copied from
- <structname>pg_type</> are still valid. This arrangement is needed
+ <structname>pg_type</structname> are still valid. This arrangement is needed
to cope with the situation where the dropped column's data type was
- later dropped, and so there is no <structname>pg_type</> row anymore.
+ later dropped, and so there is no <structname>pg_type</structname> row anymore.
<structfield>attlen</structfield> and the other fields can be used
to interpret the contents of a row of the table.
</para>
<para>
The catalog <structname>pg_authid</structname> contains information about
database authorization identifiers (roles). A role subsumes the concepts
- of <quote>users</> and <quote>groups</>. A user is essentially just a
- role with the <structfield>rolcanlogin</> flag set. Any role (with or
- without <structfield>rolcanlogin</>) can have other roles as members; see
+ of <quote>users</quote> and <quote>groups</quote>. A user is essentially just a
+ role with the <structfield>rolcanlogin</structfield> flag set. Any role (with or
+ without <structfield>rolcanlogin</structfield>) can have other roles as members; see
<link linkend="catalog-pg-auth-members"><structname>pg_auth_members</structname></link>.
</para>
</para>
<table>
- <title><structname>pg_authid</> Columns</title>
+ <title><structname>pg_authid</structname> Columns</title>
<tgroup cols="3">
<thead>
<para>
For an MD5 encrypted password, <structfield>rolpassword</structfield>
- column will begin with the string <literal>md5</> followed by a
+ column will begin with the string <literal>md5</literal> followed by a
32-character hexadecimal MD5 hash. The MD5 hash will be of the user's
password concatenated to their user name. For example, if user
- <literal>joe</> has password <literal>xyzzy</>, <productname>PostgreSQL</>
- will store the md5 hash of <literal>xyzzyjoe</>.
+ <literal>joe</literal> has password <literal>xyzzy</literal>, <productname>PostgreSQL</productname>
+ will store the md5 hash of <literal>xyzzyjoe</literal>.
</para>
<para>
If the password is encrypted with SCRAM-SHA-256, it has the format:
<synopsis>
-SCRAM-SHA-256$<replaceable><iteration count></>:<replaceable><salt></>$<replaceable><StoredKey></>:<replaceable><ServerKey></>
+SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable><salt></replaceable>$<replaceable><StoredKey></replaceable>:<replaceable><ServerKey></replaceable>
</synopsis>
- where <replaceable>salt</>, <replaceable>StoredKey</> and
- <replaceable>ServerKey</> are in Base64 encoded format. This format is
+ where <replaceable>salt</replaceable>, <replaceable>StoredKey</replaceable> and
+ <replaceable>ServerKey</replaceable> are in Base64 encoded format. This format is
the same as that specified by RFC 5803.
</para>
</para>
<table>
- <title><structname>pg_auth_members</> Columns</title>
+ <title><structname>pg_auth_members</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><structfield>member</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-authid"><structname>pg_authid</structname></link>.oid</literal></entry>
- <entry>ID of a role that is a member of <structfield>roleid</></entry>
+ <entry>ID of a role that is a member of <structfield>roleid</structfield></entry>
</row>
<row>
<entry><structfield>admin_option</structfield></entry>
<entry><type>bool</type></entry>
<entry></entry>
- <entry>True if <structfield>member</> can grant membership in
- <structfield>roleid</> to others</entry>
+ <entry>True if <structfield>member</structfield> can grant membership in
+ <structfield>roleid</structfield> to others</entry>
</row>
</tbody>
</tgroup>
cannot be deduced from some generic rule. For example, casting between a
domain and its base type is not explicitly represented in
<structname>pg_cast</structname>. Another important exception is that
- <quote>automatic I/O conversion casts</>, those performed using a data
- type's own I/O functions to convert to or from <type>text</> or other
+ <quote>automatic I/O conversion casts</quote>, those performed using a data
+ type's own I/O functions to convert to or from <type>text</type> or other
string types, are not explicitly represented in
<structname>pg_cast</structname>.
</para>
<table>
- <title><structname>pg_cast</> Columns</title>
+ <title><structname>pg_cast</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry></entry>
<entry>
Indicates what contexts the cast can be invoked in.
- <literal>e</> means only as an explicit cast (using
- <literal>CAST</> or <literal>::</> syntax).
- <literal>a</> means implicitly in assignment
+ <literal>e</literal> means only as an explicit cast (using
+ <literal>CAST</literal> or <literal>::</literal> syntax).
+ <literal>a</literal> means implicitly in assignment
to a target column, as well as explicitly.
- <literal>i</> means implicitly in expressions, as well as the
+ <literal>i</literal> means implicitly in expressions, as well as the
other cases.
</entry>
</row>
<entry></entry>
<entry>
Indicates how the cast is performed.
- <literal>f</> means that the function specified in the <structfield>castfunc</> field is used.
- <literal>i</> means that the input/output functions are used.
- <literal>b</> means that the types are binary-coercible, thus no conversion is required.
+ <literal>f</literal> means that the function specified in the <structfield>castfunc</structfield> field is used.
+ <literal>i</literal> means that the input/output functions are used.
+ <literal>b</literal> means that the types are binary-coercible, thus no conversion is required.
</entry>
</row>
</tbody>
always take the cast source type as their first argument type, and
return the cast destination type as their result type. A cast
function can have up to three arguments. The second argument,
- if present, must be type <type>integer</>; it receives the type
+ if present, must be type <type>integer</type>; it receives the type
modifier associated with the destination type, or -1
if there is none. The third argument,
- if present, must be type <type>boolean</>; it receives <literal>true</>
- if the cast is an explicit cast, <literal>false</> otherwise.
+ if present, must be type <type>boolean</type>; it receives <literal>true</literal>
+ if the cast is an explicit cast, <literal>false</literal> otherwise.
</para>
<para>
It is legitimate to create a <structname>pg_cast</structname> entry
in which the source and target types are the same, if the associated
function takes more than one argument. Such entries represent
- <quote>length coercion functions</> that coerce values of the type
+ <quote>length coercion functions</quote> that coerce values of the type
to be legal for a particular type modifier value.
</para>
table. This includes indexes (but see also
<structname>pg_index</structname>), sequences (but see also
<structname>pg_sequence</structname>), views, materialized
- views, composite types, and TOAST tables; see <structfield>relkind</>.
+ views, composite types, and TOAST tables; see <structfield>relkind</structfield>.
Below, when we mean all of these
kinds of objects we speak of <quote>relations</quote>. Not all
columns are meaningful for all relation types.
</para>
<table>
- <title><structname>pg_class</> Columns</title>
+ <title><structname>pg_class</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
<entry>
The OID of the data type that corresponds to this table's row type,
- if any (zero for indexes, which have no <structname>pg_type</> entry)
+ if any (zero for indexes, which have no <structname>pg_type</structname> entry)
</entry>
</row>
<entry><type>oid</type></entry>
<entry></entry>
<entry>Name of the on-disk file of this relation; zero means this
- is a <quote>mapped</> relation whose disk file name is determined
+ is a <quote>mapped</quote> relation whose disk file name is determined
by low-level state</entry>
</row>
<entry><type>char</type></entry>
<entry></entry>
<entry>
- <literal>p</> = permanent table, <literal>u</> = unlogged table,
- <literal>t</> = temporary table
+ <literal>p</literal> = permanent table, <literal>u</literal> = unlogged table,
+ <literal>t</literal> = temporary table
</entry>
</row>
<entry><type>char</type></entry>
<entry></entry>
<entry>
- <literal>r</> = ordinary table,
- <literal>i</> = index,
- <literal>S</> = sequence,
- <literal>t</> = TOAST table,
- <literal>v</> = view,
- <literal>m</> = materialized view,
- <literal>c</> = composite type,
- <literal>f</> = foreign table,
- <literal>p</> = partitioned table
+ <literal>r</literal> = ordinary table,
+ <literal>i</literal> = index,
+ <literal>S</literal> = sequence,
+ <literal>t</literal> = TOAST table,
+ <literal>v</literal> = view,
+ <literal>m</literal> = materialized view,
+ <literal>c</literal> = composite type,
+ <literal>f</literal> = foreign table,
+ <literal>p</literal> = partitioned table
</entry>
</row>
<entry><type>int2</type></entry>
<entry></entry>
<entry>
- Number of <literal>CHECK</> constraints on the table; see
+ Number of <literal>CHECK</literal> constraints on the table; see
<link linkend="catalog-pg-constraint"><structname>pg_constraint</structname></link> catalog
</entry>
</row>
<entry><type>char</type></entry>
<entry></entry>
<entry>
- Columns used to form <quote>replica identity</> for rows:
- <literal>d</> = default (primary key, if any),
- <literal>n</> = nothing,
- <literal>f</> = all columns
- <literal>i</> = index with <structfield>indisreplident</structfield> set, or default
+ Columns used to form <quote>replica identity</quote> for rows:
+ <literal>d</literal> = default (primary key, if any),
+ <literal>n</literal> = nothing,
+ <literal>f</literal> = all columns
+ <literal>i</literal> = index with <structfield>indisreplident</structfield> set, or default
</entry>
</row>
<entry></entry>
<entry>
All transaction IDs before this one have been replaced with a permanent
- (<quote>frozen</>) transaction ID in this table. This is used to track
+ (<quote>frozen</quote>) transaction ID in this table. This is used to track
whether the table needs to be vacuumed in order to prevent transaction
- ID wraparound or to allow <literal>pg_xact</> to be shrunk. Zero
+ ID wraparound or to allow <literal>pg_xact</literal> to be shrunk. Zero
(<symbol>InvalidTransactionId</symbol>) if the relation is not a table.
</entry>
</row>
All multixact IDs before this one have been replaced by a
transaction ID in this table. This is used to track
whether the table needs to be vacuumed in order to prevent multixact ID
- wraparound or to allow <literal>pg_multixact</> to be shrunk. Zero
+ wraparound or to allow <literal>pg_multixact</literal> to be shrunk. Zero
(<symbol>InvalidMultiXactId</symbol>) if the relation is not a table.
</entry>
</row>
<entry><type>text[]</type></entry>
<entry></entry>
<entry>
- Access-method-specific options, as <quote>keyword=value</> strings
+ Access-method-specific options, as <quote>keyword=value</quote> strings
</entry>
</row>
</table>
<para>
- Several of the Boolean flags in <structname>pg_class</> are maintained
+ Several of the Boolean flags in <structname>pg_class</structname> are maintained
lazily: they are guaranteed to be true if that's the correct state, but
may not be reset to false immediately when the condition is no longer
- true. For example, <structfield>relhasindex</> is set by
+ true. For example, <structfield>relhasindex</structfield> is set by
<command>CREATE INDEX</command>, but it is never cleared by
<command>DROP INDEX</command>. Instead, <command>VACUUM</command> clears
- <structfield>relhasindex</> if it finds the table has no indexes. This
+ <structfield>relhasindex</structfield> if it finds the table has no indexes. This
arrangement avoids race conditions and improves concurrency.
</para>
</sect1>
</para>
<table>
- <title><structname>pg_collation</> Columns</title>
+ <title><structname>pg_collation</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><structfield>collcollate</structfield></entry>
<entry><type>name</type></entry>
<entry></entry>
- <entry><symbol>LC_COLLATE</> for this collation object</entry>
+ <entry><symbol>LC_COLLATE</symbol> for this collation object</entry>
</row>
<row>
<entry><structfield>collctype</structfield></entry>
<entry><type>name</type></entry>
<entry></entry>
- <entry><symbol>LC_CTYPE</> for this collation object</entry>
+ <entry><symbol>LC_CTYPE</symbol> for this collation object</entry>
</row>
<row>
</table>
<para>
- Note that the unique key on this catalog is (<structfield>collname</>,
- <structfield>collencoding</>, <structfield>collnamespace</>) not just
- (<structfield>collname</>, <structfield>collnamespace</>).
+ Note that the unique key on this catalog is (<structfield>collname</structfield>,
+ <structfield>collencoding</structfield>, <structfield>collnamespace</structfield>) not just
+ (<structfield>collname</structfield>, <structfield>collnamespace</structfield>).
<productname>PostgreSQL</productname> generally ignores all
- collations that do not have <structfield>collencoding</> equal to
+ collations that do not have <structfield>collencoding</structfield> equal to
either the current database's encoding or -1, and creation of new entries
- with the same name as an entry with <structfield>collencoding</> = -1
+ with the same name as an entry with <structfield>collencoding</structfield> = -1
is forbidden. Therefore it is sufficient to use a qualified SQL name
- (<replaceable>schema</>.<replaceable>name</>) to identify a collation,
+ (<replaceable>schema</replaceable>.<replaceable>name</replaceable>) to identify a collation,
even though this is not unique according to the catalog definition.
The reason for defining the catalog this way is that
- <application>initdb</> fills it in at cluster initialization time with
+ <application>initdb</application> fills it in at cluster initialization time with
entries for all locales available on the system, so it must be able to
hold entries for all encodings that might ever be used in the cluster.
</para>
<para>
- In the <literal>template0</> database, it could be useful to create
+ In the <literal>template0</literal> database, it could be useful to create
collations whose encoding does not match the database encoding,
since they could match the encodings of databases later cloned from
- <literal>template0</>. This would currently have to be done manually.
+ <literal>template0</literal>. This would currently have to be done manually.
</para>
</sect1>
key, unique, foreign key, and exclusion constraints on tables.
(Column constraints are not treated specially. Every column constraint is
equivalent to some table constraint.)
- Not-null constraints are represented in the <structname>pg_attribute</>
+ Not-null constraints are represented in the <structname>pg_attribute</structname>
catalog, not here.
</para>
<para>
User-defined constraint triggers (created with <command>CREATE CONSTRAINT
- TRIGGER</>) also give rise to an entry in this table.
+ TRIGGER</command>) also give rise to an entry in this table.
</para>
<para>
</para>
<table>
- <title><structname>pg_constraint</> Columns</title>
+ <title><structname>pg_constraint</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><type>char</type></entry>
<entry></entry>
<entry>
- <literal>c</> = check constraint,
- <literal>f</> = foreign key constraint,
- <literal>p</> = primary key constraint,
- <literal>u</> = unique constraint,
- <literal>t</> = constraint trigger,
- <literal>x</> = exclusion constraint
+ <literal>c</literal> = check constraint,
+ <literal>f</literal> = foreign key constraint,
+ <literal>p</literal> = primary key constraint,
+ <literal>u</literal> = unique constraint,
+ <literal>t</literal> = constraint trigger,
+ <literal>x</literal> = exclusion constraint
</entry>
</row>
<entry><type>char</type></entry>
<entry></entry>
<entry>Foreign key update action code:
- <literal>a</> = no action,
- <literal>r</> = restrict,
- <literal>c</> = cascade,
- <literal>n</> = set null,
- <literal>d</> = set default
+ <literal>a</literal> = no action,
+ <literal>r</literal> = restrict,
+ <literal>c</literal> = cascade,
+ <literal>n</literal> = set null,
+ <literal>d</literal> = set default
</entry>
</row>
<entry><type>char</type></entry>
<entry></entry>
<entry>Foreign key deletion action code:
- <literal>a</> = no action,
- <literal>r</> = restrict,
- <literal>c</> = cascade,
- <literal>n</> = set null,
- <literal>d</> = set default
+ <literal>a</literal> = no action,
+ <literal>r</literal> = restrict,
+ <literal>c</literal> = cascade,
+ <literal>n</literal> = set null,
+ <literal>d</literal> = set default
</entry>
</row>
<entry><type>char</type></entry>
<entry></entry>
<entry>Foreign key match type:
- <literal>f</> = full,
- <literal>p</> = partial,
- <literal>s</> = simple
+ <literal>f</literal> = full,
+ <literal>p</literal> = partial,
+ <literal>s</literal> = simple
</entry>
</row>
<row>
<entry><structfield>conkey</structfield></entry>
<entry><type>int2[]</type></entry>
- <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
+ <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
<entry>If a table constraint (including foreign keys, but not constraint
triggers), list of the constrained columns</entry>
</row>
<row>
<entry><structfield>confkey</structfield></entry>
<entry><type>int2[]</type></entry>
- <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</></entry>
+ <entry><literal><link linkend="catalog-pg-attribute"><structname>pg_attribute</structname></link>.attnum</literal></entry>
<entry>If a foreign key, list of the referenced columns</entry>
</row>
<row>
<entry><structfield>conpfeqop</structfield></entry>
<entry><type>oid[]</type></entry>
- <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
+ <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
<entry>If a foreign key, list of the equality operators for PK = FK comparisons</entry>
</row>
<row>
<entry><structfield>conppeqop</structfield></entry>
<entry><type>oid[]</type></entry>
- <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
+ <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
<entry>If a foreign key, list of the equality operators for PK = PK comparisons</entry>
</row>
<row>
<entry><structfield>conffeqop</structfield></entry>
<entry><type>oid[]</type></entry>
- <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
+ <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
<entry>If a foreign key, list of the equality operators for FK = FK comparisons</entry>
</row>
<row>
<entry><structfield>conexclop</structfield></entry>
<entry><type>oid[]</type></entry>
- <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</></entry>
+ <entry><literal><link linkend="catalog-pg-operator"><structname>pg_operator</structname></link>.oid</literal></entry>
<entry>If an exclusion constraint, list of the per-column exclusion operators</entry>
</row>
For other cases, a zero appears in <structfield>conkey</structfield>
and the associated index must be consulted to discover the expression
that is constrained. (<structfield>conkey</structfield> thus has the
- same contents as <structname>pg_index</>.<structfield>indkey</> for the
+ same contents as <structname>pg_index</structname>.<structfield>indkey</structfield> for the
index.)
</para>
<para>
<structfield>consrc</structfield> is not updated when referenced objects
change; for example, it won't track renaming of columns. Rather than
- relying on this field, it's best to use <function>pg_get_constraintdef()</>
+ relying on this field, it's best to use <function>pg_get_constraintdef()</function>
to extract the definition of a check constraint.
</para>
</note>
</para>
<table>
- <title><structname>pg_conversion</> Columns</title>
+ <title><structname>pg_conversion</structname> Columns</title>
<tgroup cols="4">
<thead>
</para>
<table>
- <title><structname>pg_database</> Columns</title>
+ <title><structname>pg_database</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry></entry>
<entry>
If true, then this database can be cloned by
- any user with <literal>CREATEDB</> privileges;
+ any user with <literal>CREATEDB</literal> privileges;
if false, then only superusers or the owner of
the database can clone it.
</entry>
<entry></entry>
<entry>
If false then no one can connect to this database. This is
- used to protect the <literal>template0</> database from being altered.
+ used to protect the <literal>template0</literal> database from being altered.
</entry>
</row>
<entry></entry>
<entry>
All transaction IDs before this one have been replaced with a permanent
- (<quote>frozen</>) transaction ID in this database. This is used to
+ (<quote>frozen</quote>) transaction ID in this database. This is used to
track whether the database needs to be vacuumed in order to prevent
- transaction ID wraparound or to allow <literal>pg_xact</> to be shrunk.
+ transaction ID wraparound or to allow <literal>pg_xact</literal> to be shrunk.
It is the minimum of the per-table
- <structname>pg_class</>.<structfield>relfrozenxid</> values.
+ <structname>pg_class</structname>.<structfield>relfrozenxid</structfield> values.
</entry>
</row>
All multixact IDs before this one have been replaced with a
transaction ID in this database. This is used to
track whether the database needs to be vacuumed in order to prevent
- multixact ID wraparound or to allow <literal>pg_multixact</> to be shrunk.
+ multixact ID wraparound or to allow <literal>pg_multixact</literal> to be shrunk.
It is the minimum of the per-table
- <structname>pg_class</>.<structfield>relminmxid</> values.
+ <structname>pg_class</structname>.<structfield>relminmxid</structfield> values.
</entry>
</row>
<entry>
The default tablespace for the database.
Within this database, all tables for which
- <structname>pg_class</>.<structfield>reltablespace</> is zero
+ <structname>pg_class</structname>.<structfield>reltablespace</structfield> is zero
will be stored in this tablespace; in particular, all the non-shared
system catalogs will be there.
</entry>
</para>
<table>
- <title><structname>pg_db_role_setting</> Columns</title>
+ <title><structname>pg_db_role_setting</structname> Columns</title>
<tgroup cols="4">
<thead>
</indexterm>
<para>
- The catalog <structname>pg_default_acl</> stores initial
+ The catalog <structname>pg_default_acl</structname> stores initial
privileges to be assigned to newly created objects.
</para>
<table>
- <title><structname>pg_default_acl</> Columns</title>
+ <title><structname>pg_default_acl</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry></entry>
<entry>
Type of object this entry is for:
- <literal>r</> = relation (table, view),
- <literal>S</> = sequence,
- <literal>f</> = function,
- <literal>T</> = type
+ <literal>r</literal> = relation (table, view),
+ <literal>S</literal> = sequence,
+ <literal>f</literal> = function,
+ <literal>T</literal> = type
</entry>
</row>
</table>
<para>
- A <structname>pg_default_acl</> entry shows the initial privileges to
+ A <structname>pg_default_acl</structname> entry shows the initial privileges to
be assigned to an object belonging to the indicated user. There are
- currently two types of entry: <quote>global</> entries with
- <structfield>defaclnamespace</> = 0, and <quote>per-schema</> entries
+ currently two types of entry: <quote>global</quote> entries with
+ <structfield>defaclnamespace</structfield> = 0, and <quote>per-schema</quote> entries
that reference a particular schema. If a global entry is present then
- it <emphasis>overrides</> the normal hard-wired default privileges
+ it <emphasis>overrides</emphasis> the normal hard-wired default privileges
for the object type. A per-schema entry, if present, represents privileges
- to be <emphasis>added to</> the global or hard-wired default privileges.
+ to be <emphasis>added to</emphasis> the global or hard-wired default privileges.
</para>
<para>
Note that when an ACL entry in another catalog is null, it is taken
to represent the hard-wired default privileges for its object,
- <emphasis>not</> whatever might be in <structname>pg_default_acl</>
- at the moment. <structname>pg_default_acl</> is only consulted during
+ <emphasis>not</emphasis> whatever might be in <structname>pg_default_acl</structname>
+ at the moment. <structname>pg_default_acl</structname> is only consulted during
object creation.
</para>
<para>
The catalog <structname>pg_depend</structname> records the dependency
relationships between database objects. This information allows
- <command>DROP</> commands to find which other objects must be dropped
- by <command>DROP CASCADE</> or prevent dropping in the <command>DROP
- RESTRICT</> case.
+ <command>DROP</command> commands to find which other objects must be dropped
+ by <command>DROP CASCADE</command> or prevent dropping in the <command>DROP
+ RESTRICT</command> case.
</para>
<para>
</para>
<table>
- <title><structname>pg_depend</> Columns</title>
+ <title><structname>pg_depend</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry></entry>
<entry>
For a table column, this is the column number (the
- <structfield>objid</> and <structfield>classid</> refer to the
+ <structfield>objid</structfield> and <structfield>classid</structfield> refer to the
table itself). For all other object types, this column is
zero.
</entry>
<entry></entry>
<entry>
For a table column, this is the column number (the
- <structfield>refobjid</> and <structfield>refclassid</> refer
+ <structfield>refobjid</structfield> and <structfield>refclassid</structfield> refer
to the table itself). For all other object types, this column
is zero.
</entry>
In all cases, a <structname>pg_depend</structname> entry indicates that the
referenced object cannot be dropped without also dropping the dependent
object. However, there are several subflavors identified by
- <structfield>deptype</>:
+ <structfield>deptype</structfield>:
<variablelist>
<varlistentry>
- <term><symbol>DEPENDENCY_NORMAL</> (<literal>n</>)</term>
+ <term><symbol>DEPENDENCY_NORMAL</symbol> (<literal>n</literal>)</term>
<listitem>
<para>
A normal relationship between separately-created objects. The
dependent object can be dropped without affecting the
referenced object. The referenced object can only be dropped
- by specifying <literal>CASCADE</>, in which case the dependent
+ by specifying <literal>CASCADE</literal>, in which case the dependent
object is dropped, too. Example: a table column has a normal
dependency on its data type.
</para>
</varlistentry>
<varlistentry>
- <term><symbol>DEPENDENCY_AUTO</> (<literal>a</>)</term>
+ <term><symbol>DEPENDENCY_AUTO</symbol> (<literal>a</literal>)</term>
<listitem>
<para>
The dependent object can be dropped separately from the
referenced object, and should be automatically dropped
- (regardless of <literal>RESTRICT</> or <literal>CASCADE</>
+ (regardless of <literal>RESTRICT</literal> or <literal>CASCADE</literal>
mode) if the referenced object is dropped. Example: a named
constraint on a table is made autodependent on the table, so
that it will go away if the table is dropped.
</varlistentry>
<varlistentry>
- <term><symbol>DEPENDENCY_INTERNAL</> (<literal>i</>)</term>
+ <term><symbol>DEPENDENCY_INTERNAL</symbol> (<literal>i</literal>)</term>
<listitem>
<para>
The dependent object was created as part of creation of the
referenced object, and is really just a part of its internal
- implementation. A <command>DROP</> of the dependent object
+ implementation. A <command>DROP</command> of the dependent object
will be disallowed outright (we'll tell the user to issue a
- <command>DROP</> against the referenced object, instead). A
- <command>DROP</> of the referenced object will be propagated
+ <command>DROP</command> against the referenced object, instead). A
+ <command>DROP</command> of the referenced object will be propagated
through to drop the dependent object whether
- <command>CASCADE</> is specified or not. Example: a trigger
+ <command>CASCADE</command> is specified or not. Example: a trigger
that's created to enforce a foreign-key constraint is made
internally dependent on the constraint's
- <structname>pg_constraint</> entry.
+ <structname>pg_constraint</structname> entry.
</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><symbol>DEPENDENCY_EXTENSION</> (<literal>e</>)</term>
+ <term><symbol>DEPENDENCY_EXTENSION</symbol> (<literal>e</literal>)</term>
<listitem>
<para>
- The dependent object is a member of the <firstterm>extension</> that is
+ The dependent object is a member of the <firstterm>extension</firstterm> that is
the referenced object (see
<link linkend="catalog-pg-extension"><structname>pg_extension</structname></link>).
The dependent object can be dropped only via
- <command>DROP EXTENSION</> on the referenced object. Functionally
+ <command>DROP EXTENSION</command> on the referenced object. Functionally
this dependency type acts the same as an internal dependency, but
- it's kept separate for clarity and to simplify <application>pg_dump</>.
+ it's kept separate for clarity and to simplify <application>pg_dump</application>.
</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><symbol>DEPENDENCY_AUTO_EXTENSION</> (<literal>x</>)</term>
+ <term><symbol>DEPENDENCY_AUTO_EXTENSION</symbol> (<literal>x</literal>)</term>
<listitem>
<para>
The dependent object is not a member of the extension that is the
</varlistentry>
<varlistentry>
- <term><symbol>DEPENDENCY_PIN</> (<literal>p</>)</term>
+ <term><symbol>DEPENDENCY_PIN</symbol> (<literal>p</literal>)</term>
<listitem>
<para>
There is no dependent object; this type of entry is a signal
</indexterm>
<para>
- The catalog <structname>pg_description</> stores optional descriptions
+ The catalog <structname>pg_description</structname> stores optional descriptions
(comments) for each database object. Descriptions can be manipulated
with the <xref linkend="sql-comment"> command and viewed with
<application>psql</application>'s <literal>\d</literal> commands.
</para>
<table>
- <title><structname>pg_description</> Columns</title>
+ <title><structname>pg_description</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry></entry>
<entry>
For a comment on a table column, this is the column number (the
- <structfield>objoid</> and <structfield>classoid</> refer to
+ <structfield>objoid</structfield> and <structfield>classoid</structfield> refer to
the table itself). For all other object types, this column is
zero.
</entry>
</para>
<table>
- <title><structname>pg_enum</> Columns</title>
+ <title><structname>pg_enum</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><structfield>enumtypid</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
- <entry>The OID of the <structname>pg_type</> entry owning this enum value</entry>
+ <entry>The OID of the <structname>pg_type</structname> entry owning this enum value</entry>
</row>
<row>
<para>
When an enum type is created, its members are assigned sort-order
- positions 1..<replaceable>n</>. But members added later might be given
+ positions 1..<replaceable>n</replaceable>. But members added later might be given
negative or fractional values of <structfield>enumsortorder</structfield>.
The only requirement on these values is that they be correctly
ordered and unique within each enum type.
</para>
<table>
- <title><structname>pg_event_trigger</> Columns</title>
+ <title><structname>pg_event_trigger</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry>
Controls in which <xref linkend="guc-session-replication-role"> modes
the event trigger fires.
- <literal>O</> = trigger fires in <quote>origin</> and <quote>local</> modes,
- <literal>D</> = trigger is disabled,
- <literal>R</> = trigger fires in <quote>replica</> mode,
- <literal>A</> = trigger fires always.
+ <literal>O</literal> = trigger fires in <quote>origin</quote> and <quote>local</quote> modes,
+ <literal>D</literal> = trigger is disabled,
+ <literal>R</literal> = trigger fires in <quote>replica</quote> mode,
+ <literal>A</literal> = trigger fires always.
</entry>
</row>
</para>
<table>
- <title><structname>pg_extension</> Columns</title>
+ <title><structname>pg_extension</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><structfield>extconfig</structfield></entry>
<entry><type>oid[]</type></entry>
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
- <entry>Array of <type>regclass</> OIDs for the extension's configuration
- table(s), or <literal>NULL</> if none</entry>
+ <entry>Array of <type>regclass</type> OIDs for the extension's configuration
+ table(s), or <literal>NULL</literal> if none</entry>
</row>
<row>
<entry><structfield>extcondition</structfield></entry>
<entry><type>text[]</type></entry>
<entry></entry>
- <entry>Array of <literal>WHERE</>-clause filter conditions for the
- extension's configuration table(s), or <literal>NULL</> if none</entry>
+ <entry>Array of <literal>WHERE</literal>-clause filter conditions for the
+ extension's configuration table(s), or <literal>NULL</literal> if none</entry>
</row>
</tbody>
</table>
<para>
- Note that unlike most catalogs with a <quote>namespace</> column,
+ Note that unlike most catalogs with a <quote>namespace</quote> column,
<structfield>extnamespace</structfield> is not meant to imply
that the extension belongs to that schema. Extension names are never
schema-qualified. Rather, <structfield>extnamespace</structfield>
</para>
<table>
- <title><structname>pg_foreign_data_wrapper</> Columns</title>
+ <title><structname>pg_foreign_data_wrapper</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><type>text[]</type></entry>
<entry></entry>
<entry>
- Foreign-data wrapper specific options, as <quote>keyword=value</> strings
+ Foreign-data wrapper specific options, as <quote>keyword=value</quote> strings
</entry>
</row>
</tbody>
</para>
<table>
- <title><structname>pg_foreign_server</> Columns</title>
+ <title><structname>pg_foreign_server</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><type>text[]</type></entry>
<entry></entry>
<entry>
- Foreign server specific options, as <quote>keyword=value</> strings
+ Foreign server specific options, as <quote>keyword=value</quote> strings
</entry>
</row>
</tbody>
</para>
<table>
- <title><structname>pg_foreign_table</> Columns</title>
+ <title><structname>pg_foreign_table</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><structfield>ftrelid</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
- <entry>OID of the <structname>pg_class</> entry for this foreign table</entry>
+ <entry>OID of the <structname>pg_class</structname> entry for this foreign table</entry>
</row>
<row>
<entry><type>text[]</type></entry>
<entry></entry>
<entry>
- Foreign table options, as <quote>keyword=value</> strings
+ Foreign table options, as <quote>keyword=value</quote> strings
</entry>
</row>
</tbody>
</para>
<table>
- <title><structname>pg_index</> Columns</title>
+ <title><structname>pg_index</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><structfield>indexrelid</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
- <entry>The OID of the <structname>pg_class</> entry for this index</entry>
+ <entry>The OID of the <structname>pg_class</structname> entry for this index</entry>
</row>
<row>
<entry><structfield>indrelid</structfield></entry>
<entry><type>oid</type></entry>
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
- <entry>The OID of the <structname>pg_class</> entry for the table this index is for</entry>
+ <entry>The OID of the <structname>pg_class</structname> entry for the table this index is for</entry>
</row>
<row>
<entry><type>bool</type></entry>
<entry></entry>
<entry>If true, this index represents the primary key of the table
- (<structfield>indisunique</> should always be true when this is true)</entry>
+ (<structfield>indisunique</structfield> should always be true when this is true)</entry>
</row>
<row>
<entry></entry>
<entry>If true, the uniqueness check is enforced immediately on
insertion
- (irrelevant if <structfield>indisunique</> is not true)</entry>
+ (irrelevant if <structfield>indisunique</structfield> is not true)</entry>
</row>
<row>
<entry>
If true, the index is currently valid for queries. False means the
index is possibly incomplete: it must still be modified by
- <command>INSERT</>/<command>UPDATE</> operations, but it cannot safely
+ <command>INSERT</command>/<command>UPDATE</command> operations, but it cannot safely
be used for queries. If it is unique, the uniqueness property is not
guaranteed true either.
</entry>
<entry><type>bool</type></entry>
<entry></entry>
<entry>
- If true, queries must not use the index until the <structfield>xmin</>
- of this <structname>pg_index</> row is below their <symbol>TransactionXmin</symbol>
+ If true, queries must not use the index until the <structfield>xmin</structfield>
+ of this <structname>pg_index</structname> row is below their <symbol>TransactionXmin</symbol>
event horizon, because the table may contain broken HOT chains with
incompatible rows that they can see
</entry>
<entry></entry>
<entry>
If true, the index is currently ready for inserts. False means the
- index must be ignored by <command>INSERT</>/<command>UPDATE</>
+ index must be ignored by <command>INSERT</command>/<command>UPDATE</command>
operations.
</entry>
</row>
<entry><type>bool</type></entry>
<entry></entry>
<entry>
- If true this index has been chosen as <quote>replica identity</>
+ If true this index has been chosen as <quote>replica identity</quote>
using <command>ALTER TABLE ... REPLICA IDENTITY USING INDEX
- ...</>
+ ...</command>
</entry>
</row>
Expression trees (in <function>nodeToString()</function>
representation) for index attributes that are not simple column
references. This is a list with one element for each zero
- entry in <structfield>indkey</>. Null if all index attributes
+ entry in <structfield>indkey</structfield>. Null if all index attributes
are simple references.
</entry>
</row>
</indexterm>
<para>
- The catalog <structname>pg_inherits</> records information about
+ The catalog <structname>pg_inherits</structname> records information about
table inheritance hierarchies. There is one entry for each direct
parent-child table relationship in the database. (Indirect inheritance can be determined
by following chains of entries.)
</para>
<table>
- <title><structname>pg_inherits</> Columns</title>
+ <title><structname>pg_inherits</structname> Columns</title>
<tgroup cols="4">
<thead>
</indexterm>
<para>
- The catalog <structname>pg_init_privs</> records information about
+ The catalog <structname>pg_init_privs</structname> records information about
the initial privileges of objects in the system. There is one entry
for each object in the database which has a non-default (non-NULL)
initial set of privileges.
<para>
Objects can have initial privileges either by having those privileges set
- when the system is initialized (by <application>initdb</>) or when the
+ when the system is initialized (by <application>initdb</application>) or when the
object is created during a <command>CREATE EXTENSION</command> and the
extension script sets initial privileges using the <command>GRANT</command>
system. Note that the system will automatically handle recording of the
only use the <command>GRANT</command> and <command>REVOKE</command>
statements in their script to have the privileges recorded. The
<literal>privtype</literal> column indicates if the initial privilege was
- set by <application>initdb</> or during a
+ set by <application>initdb</application> or during a
<command>CREATE EXTENSION</command> command.
</para>
<para>
- Objects which have initial privileges set by <application>initdb</> will
+ Objects which have initial privileges set by <application>initdb</application> will
have entries where <literal>privtype</literal> is
<literal>'i'</literal>, while objects which have initial privileges set
by <command>CREATE EXTENSION</command> will have entries where
</para>
<table>
- <title><structname>pg_init_privs</> Columns</title>
+ <title><structname>pg_init_privs</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry></entry>
<entry>
For a table column, this is the column number (the
- <structfield>objoid</> and <structfield>classoid</> refer to the
+ <structfield>objoid</structfield> and <structfield>classoid</structfield> refer to the
table itself). For all other object types, this column is
zero.
</entry>
</para>
<table>
- <title><structname>pg_language</> Columns</title>
+ <title><structname>pg_language</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
<entry>
This references a function that is responsible for executing
- <quote>inline</> anonymous code blocks
+ <quote>inline</quote> anonymous code blocks
(<xref linkend="sql-do"> blocks).
Zero if inline blocks are not supported.
</entry>
The catalog <structname>pg_largeobject</structname> holds the data making up
<quote>large objects</quote>. A large object is identified by an OID
assigned when it is created. Each large object is broken into
- segments or <quote>pages</> small enough to be conveniently stored as rows
+ segments or <quote>pages</quote> small enough to be conveniently stored as rows
in <structname>pg_largeobject</structname>.
- The amount of data per page is defined to be <symbol>LOBLKSIZE</> (which is currently
- <literal>BLCKSZ/4</>, or typically 2 kB).
+ The amount of data per page is defined to be <symbol>LOBLKSIZE</symbol> (which is currently
+ <literal>BLCKSZ/4</literal>, or typically 2 kB).
</para>
<para>
- Prior to <productname>PostgreSQL</> 9.0, there was no permission structure
+ Prior to <productname>PostgreSQL</productname> 9.0, there was no permission structure
associated with large objects. As a result,
<structname>pg_largeobject</structname> was publicly readable and could be
used to obtain the OIDs (and contents) of all large objects in the system.
This is no longer the case; use
- <link linkend="catalog-pg-largeobject-metadata"><structname>pg_largeobject_metadata</></link>
+ <link linkend="catalog-pg-largeobject-metadata"><structname>pg_largeobject_metadata</structname></link>
to obtain a list of large object OIDs.
</para>
<table>
- <title><structname>pg_largeobject</> Columns</title>
+ <title><structname>pg_largeobject</structname> Columns</title>
<tgroup cols="4">
<thead>
<entry></entry>
<entry>
Actual data stored in the large object.
- This will never be more than <symbol>LOBLKSIZE</> bytes and might be less.
+ This will never be more than <symbol>LOBLKSIZE</symbol> bytes and might be less.
</entry>
</row>
</tbody>
<para>
Each row of <structname>pg_largeobject</structname> holds data
for one page of a large object, beginning at
- byte offset (<literal>pageno * LOBLKSIZE</>) within the object. The implementation
+ byte offset (<literal>pageno * LOBLKSIZE</literal>) within the object. The implementation
allows sparse storage: pages might be missing, and might be shorter than
- <literal>LOBLKSIZE</> bytes even if they are not the last page of the object.
+ <literal>LOBLKSIZE</literal> bytes even if they are not the last page of the object.
Missing regions within a large object read as zeroes.
</para>
The catalog <structname>pg_largeobject_metadata</structname>
holds metadata associated with large objects. The actual large object
data is stored in
- <link linkend="catalog-pg-largeobject"><structname>pg_largeobject</></link>.
+ <link linkend="catalog-pg-largeobject"><structname>pg_largeobject</structname></link>.
</para>
<table>
- <title><structname>pg_largeobject_metadata</> Columns</title>
+ <title><structname>pg_largeobject_metadata</structname> Columns</title>
<tgroup cols="4">
<thead>