mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
Don't use SGML empty tags
For DocBook XML compatibility, don't use SGML empty tags (</>) anymore, replace by the full tag name. Add a warning option to catch future occurrences. Alexander Lakhin, Jürgen Purtz
This commit is contained in:
@@ -45,7 +45,7 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
|
||||
<note>
|
||||
<para>
|
||||
This page describes usage of cursors at the SQL command level.
|
||||
If you are trying to use cursors inside a <application>PL/pgSQL</>
|
||||
If you are trying to use cursors inside a <application>PL/pgSQL</application>
|
||||
function, the rules are different —
|
||||
see <xref linkend="plpgsql-cursors">.
|
||||
</para>
|
||||
@@ -144,13 +144,13 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
|
||||
|
||||
<para>
|
||||
Normal cursors return data in text format, the same as a
|
||||
<command>SELECT</> would produce. The <literal>BINARY</> option
|
||||
<command>SELECT</command> would produce. The <literal>BINARY</literal> option
|
||||
specifies that the cursor should return data in binary format.
|
||||
This reduces conversion effort for both the server and client,
|
||||
at the cost of more programmer effort to deal with platform-dependent
|
||||
binary data formats.
|
||||
As an example, if a query returns a value of one from an integer column,
|
||||
you would get a string of <literal>1</> with a default cursor,
|
||||
you would get a string of <literal>1</literal> with a default cursor,
|
||||
whereas with a binary cursor you would get
|
||||
a 4-byte field containing the internal representation of the value
|
||||
(in big-endian byte order).
|
||||
@@ -165,8 +165,8 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
|
||||
|
||||
<note>
|
||||
<para>
|
||||
When the client application uses the <quote>extended query</> protocol
|
||||
to issue a <command>FETCH</> command, the Bind protocol message
|
||||
When the client application uses the <quote>extended query</quote> protocol
|
||||
to issue a <command>FETCH</command> command, the Bind protocol message
|
||||
specifies whether data is to be retrieved in text or binary format.
|
||||
This choice overrides the way that the cursor is defined. The concept
|
||||
of a binary cursor as such is thus obsolete when using extended query
|
||||
@@ -177,7 +177,7 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
|
||||
<para>
|
||||
Unless <literal>WITH HOLD</literal> is specified, the cursor
|
||||
created by this command can only be used within the current
|
||||
transaction. Thus, <command>DECLARE</> without <literal>WITH
|
||||
transaction. Thus, <command>DECLARE</command> without <literal>WITH
|
||||
HOLD</literal> is useless outside a transaction block: the cursor would
|
||||
survive only to the completion of the statement. Therefore
|
||||
<productname>PostgreSQL</productname> reports an error if such a
|
||||
@@ -204,25 +204,25 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
|
||||
|
||||
<para>
|
||||
<literal>WITH HOLD</literal> may not be specified when the query
|
||||
includes <literal>FOR UPDATE</> or <literal>FOR SHARE</>.
|
||||
includes <literal>FOR UPDATE</literal> or <literal>FOR SHARE</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <literal>SCROLL</> option should be specified when defining a
|
||||
The <literal>SCROLL</literal> option should be specified when defining a
|
||||
cursor that will be used to fetch backwards. This is required by
|
||||
the SQL standard. However, for compatibility with earlier
|
||||
versions, <productname>PostgreSQL</productname> will allow
|
||||
backward fetches without <literal>SCROLL</>, if the cursor's query
|
||||
backward fetches without <literal>SCROLL</literal>, if the cursor's query
|
||||
plan is simple enough that no extra overhead is needed to support
|
||||
it. However, application developers are advised not to rely on
|
||||
using backward fetches from a cursor that has not been created
|
||||
with <literal>SCROLL</literal>. If <literal>NO SCROLL</> is
|
||||
with <literal>SCROLL</literal>. If <literal>NO SCROLL</literal> is
|
||||
specified, then backward fetches are disallowed in any case.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Backward fetches are also disallowed when the query
|
||||
includes <literal>FOR UPDATE</> or <literal>FOR SHARE</>; therefore
|
||||
includes <literal>FOR UPDATE</literal> or <literal>FOR SHARE</literal>; therefore
|
||||
<literal>SCROLL</literal> may not be specified in this case.
|
||||
</para>
|
||||
|
||||
@@ -241,42 +241,42 @@ DECLARE <replaceable class="parameter">name</replaceable> [ BINARY ] [ INSENSITI
|
||||
</caution>
|
||||
|
||||
<para>
|
||||
If the cursor's query includes <literal>FOR UPDATE</> or <literal>FOR
|
||||
SHARE</>, then returned rows are locked at the time they are first
|
||||
If the cursor's query includes <literal>FOR UPDATE</literal> or <literal>FOR
|
||||
SHARE</literal>, then returned rows are locked at the time they are first
|
||||
fetched, in the same way as for a regular
|
||||
<xref linkend="sql-select"> command with
|
||||
these options.
|
||||
In addition, the returned rows will be the most up-to-date versions;
|
||||
therefore these options provide the equivalent of what the SQL standard
|
||||
calls a <quote>sensitive cursor</>. (Specifying <literal>INSENSITIVE</>
|
||||
together with <literal>FOR UPDATE</> or <literal>FOR SHARE</> is an error.)
|
||||
calls a <quote>sensitive cursor</quote>. (Specifying <literal>INSENSITIVE</literal>
|
||||
together with <literal>FOR UPDATE</literal> or <literal>FOR SHARE</literal> is an error.)
|
||||
</para>
|
||||
|
||||
<caution>
|
||||
<para>
|
||||
It is generally recommended to use <literal>FOR UPDATE</> if the cursor
|
||||
is intended to be used with <command>UPDATE ... WHERE CURRENT OF</> or
|
||||
<command>DELETE ... WHERE CURRENT OF</>. Using <literal>FOR UPDATE</>
|
||||
It is generally recommended to use <literal>FOR UPDATE</literal> if the cursor
|
||||
is intended to be used with <command>UPDATE ... WHERE CURRENT OF</command> or
|
||||
<command>DELETE ... WHERE CURRENT OF</command>. Using <literal>FOR UPDATE</literal>
|
||||
prevents other sessions from changing the rows between the time they are
|
||||
fetched and the time they are updated. Without <literal>FOR UPDATE</>,
|
||||
a subsequent <literal>WHERE CURRENT OF</> command will have no effect if
|
||||
fetched and the time they are updated. Without <literal>FOR UPDATE</literal>,
|
||||
a subsequent <literal>WHERE CURRENT OF</literal> command will have no effect if
|
||||
the row was changed since the cursor was created.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Another reason to use <literal>FOR UPDATE</> is that without it, a
|
||||
subsequent <literal>WHERE CURRENT OF</> might fail if the cursor query
|
||||
Another reason to use <literal>FOR UPDATE</literal> is that without it, a
|
||||
subsequent <literal>WHERE CURRENT OF</literal> might fail if the cursor query
|
||||
does not meet the SQL standard's rules for being <quote>simply
|
||||
updatable</> (in particular, the cursor must reference just one table
|
||||
and not use grouping or <literal>ORDER BY</>). Cursors
|
||||
updatable</quote> (in particular, the cursor must reference just one table
|
||||
and not use grouping or <literal>ORDER BY</literal>). Cursors
|
||||
that are not simply updatable might work, or might not, depending on plan
|
||||
choice details; so in the worst case, an application might work in testing
|
||||
and then fail in production.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The main reason not to use <literal>FOR UPDATE</> with <literal>WHERE
|
||||
CURRENT OF</> is if you need the cursor to be scrollable, or to be
|
||||
The main reason not to use <literal>FOR UPDATE</literal> with <literal>WHERE
|
||||
CURRENT OF</literal> is if you need the cursor to be scrollable, or to be
|
||||
insensitive to the subsequent updates (that is, continue to show the old
|
||||
data). If this is a requirement, pay close heed to the caveats shown
|
||||
above.
|
||||
@@ -321,13 +321,13 @@ DECLARE liahona CURSOR FOR SELECT * FROM films;
|
||||
The SQL standard says that it is implementation-dependent whether cursors
|
||||
are sensitive to concurrent updates of the underlying data by default. In
|
||||
<productname>PostgreSQL</productname>, cursors are insensitive by default,
|
||||
and can be made sensitive by specifying <literal>FOR UPDATE</>. Other
|
||||
and can be made sensitive by specifying <literal>FOR UPDATE</literal>. Other
|
||||
products may work differently.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The SQL standard allows cursors only in embedded
|
||||
<acronym>SQL</acronym> and in modules. <productname>PostgreSQL</>
|
||||
<acronym>SQL</acronym> and in modules. <productname>PostgreSQL</productname>
|
||||
permits cursors to be used interactively.
|
||||
</para>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user