Use the correct article for abbreviations
We've accumulated quite a mix of instances of "an SQL" and "a SQL" in the documents. It would be good to be a bit more consistent with these. The most recent version of the SQL standard I looked at seems to prefer "an SQL". That seems like a good lead to follow, so here we change all instances of "a SQL" to become "an SQL". Most instances correctly use "an SQL" already, so it also makes sense to use the dominant variation in order to minimise churn. Additionally, there were some other abbreviations that needed to be adjusted. FSM, SSPI, SRF and a few others. Also fix some pronounceable, abbreviations to use "a" instead of "an". For example, "a SASL" instead of "an SASL". Here I've only adjusted the documents and error messages. Many others still exist in source code comments. Translator hint comments seem to be the biggest culprit. It currently does not seem worth the churn to change these. Discussion: https://postgr.es/m/CAApHDvpML27UqFXnrYO1MJddsKVMQoiZisPvsAGhKE_tsKXquw%40mail.gmail.com
This commit is contained in:
parent
e56bce5d43
commit
04539e73fa
|
@ -1462,7 +1462,7 @@ omicron bryanh guest1
|
|||
<listitem>
|
||||
<para>
|
||||
Allows for mapping between system and database user names. See
|
||||
<xref linkend="auth-username-maps"/> for details. For a SSPI/Kerberos
|
||||
<xref linkend="auth-username-maps"/> for details. For an SSPI/Kerberos
|
||||
principal, such as <literal>username@EXAMPLE.COM</literal> (or, less
|
||||
commonly, <literal>username/hostbased@EXAMPLE.COM</literal>), the
|
||||
user name used for mapping is
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
In general, enclose the value in single quotes, doubling any single
|
||||
quotes within the value. Quotes can usually be omitted if the value
|
||||
is a simple number or identifier, however.
|
||||
(Values that match a SQL keyword require quoting in some contexts.)
|
||||
(Values that match an SQL keyword require quoting in some contexts.)
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
|
@ -222,7 +222,7 @@ shared_buffers = 128MB
|
|||
<productname>PostgreSQL</productname> provides three SQL
|
||||
commands to establish configuration defaults.
|
||||
The already-mentioned <command>ALTER SYSTEM</command> command
|
||||
provides a SQL-accessible means of changing global defaults; it is
|
||||
provides an SQL-accessible means of changing global defaults; it is
|
||||
functionally equivalent to editing <filename>postgresql.conf</filename>.
|
||||
In addition, there are two commands that allow setting of defaults
|
||||
on a per-database or per-role basis:
|
||||
|
@ -9625,7 +9625,7 @@ dynamic_library_path = 'C:\tools\postgresql;H:\my_project\lib;$libdir'
|
|||
<literal>\'</literal>. However, use of <literal>\'</literal> creates security risks
|
||||
because in some client character set encodings, there are multibyte
|
||||
characters in which the last byte is numerically equivalent to ASCII
|
||||
<literal>\</literal>. If client-side code does escaping incorrectly then a
|
||||
<literal>\</literal>. If client-side code does escaping incorrectly then an
|
||||
SQL-injection attack is possible. This risk can be prevented by
|
||||
making the server reject queries in which a quote mark appears to be
|
||||
escaped by a backslash.
|
||||
|
|
|
@ -1538,7 +1538,7 @@ SELECT '\xDEADBEEF';
|
|||
<para>
|
||||
The reason that single quotes must be doubled, as shown
|
||||
in <xref linkend="datatype-binary-sqlesc"/>, is that this
|
||||
is true for any string literal in a SQL command. The generic
|
||||
is true for any string literal in an SQL command. The generic
|
||||
string-literal parser consumes the outermost single quotes
|
||||
and reduces any pair of single quotes to one data character.
|
||||
What the <type>bytea</type> input function sees is just one
|
||||
|
|
|
@ -1482,14 +1482,14 @@ dblink_get_result(text connname [, bool fail_on_error]) returns setof record
|
|||
<title>Return Value</title>
|
||||
|
||||
<para>
|
||||
For an async query (that is, a SQL statement returning rows),
|
||||
For an async query (that is, an SQL statement returning rows),
|
||||
the function returns the row(s) produced by the query. To use this
|
||||
function, you will need to specify the expected set of columns,
|
||||
as previously discussed for <function>dblink</function>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
For an async command (that is, a SQL statement not returning rows),
|
||||
For an async command (that is, an SQL statement not returning rows),
|
||||
the function returns a single row with a single text column containing
|
||||
the command's status string. It is still necessary to specify that
|
||||
the result will have a single text column in the calling <literal>FROM</literal>
|
||||
|
@ -1777,7 +1777,7 @@ dblink_build_sql_insert(text relname,
|
|||
<para>
|
||||
<function>dblink_build_sql_insert</function> can be useful in doing selective
|
||||
replication of a local table to a remote database. It selects a row
|
||||
from the local table based on primary key, and then builds a SQL
|
||||
from the local table based on primary key, and then builds an SQL
|
||||
<command>INSERT</command> command that will duplicate that row, but with
|
||||
the primary key values replaced by the values in the last argument.
|
||||
(To make an exact copy of the row, just specify the same values for
|
||||
|
@ -1909,7 +1909,7 @@ dblink_build_sql_delete(text relname,
|
|||
|
||||
<para>
|
||||
<function>dblink_build_sql_delete</function> can be useful in doing selective
|
||||
replication of a local table to a remote database. It builds a SQL
|
||||
replication of a local table to a remote database. It builds an SQL
|
||||
<command>DELETE</command> command that will delete the row with the given
|
||||
primary key values.
|
||||
</para>
|
||||
|
@ -2029,7 +2029,7 @@ dblink_build_sql_update(text relname,
|
|||
<para>
|
||||
<function>dblink_build_sql_update</function> can be useful in doing selective
|
||||
replication of a local table to a remote database. It selects a row
|
||||
from the local table based on primary key, and then builds a SQL
|
||||
from the local table based on primary key, and then builds an SQL
|
||||
<command>UPDATE</command> command that will duplicate that row, but with
|
||||
the primary key values replaced by the values in the last argument.
|
||||
(To make an exact copy of the row, just specify the same values for
|
||||
|
|
|
@ -354,13 +354,13 @@ current=testdb1 (should be testdb1)
|
|||
</para>
|
||||
|
||||
<para>
|
||||
The third option is to declare a SQL identifier linked to
|
||||
The third option is to declare an SQL identifier linked to
|
||||
the connection, for example:
|
||||
<programlisting>
|
||||
EXEC SQL AT <replaceable>connection-name</replaceable> DECLARE <replaceable>statement-name</replaceable> STATEMENT;
|
||||
EXEC SQL PREPARE <replaceable>statement-name</replaceable> FROM :<replaceable>dyn-string</replaceable>;
|
||||
</programlisting>
|
||||
Once you link a SQL identifier to a connection, you execute dynamic SQL
|
||||
Once you link an SQL identifier to a connection, you execute dynamic SQL
|
||||
without an AT clause. Note that this option behaves like preprocessor
|
||||
directives, therefore the link is enabled only in the file.
|
||||
</para>
|
||||
|
@ -1542,7 +1542,7 @@ EXEC SQL END DECLARE SECTION;
|
|||
variables and vice-versa. However, when creating a statement ecpg does
|
||||
not know the types of the columns, so that it cannot check if a C array
|
||||
is input into a corresponding SQL-level array. When processing the
|
||||
output of a SQL statement, ecpg has the necessary information and thus
|
||||
output of an SQL statement, ecpg has the necessary information and thus
|
||||
checks if both are arrays.
|
||||
</para>
|
||||
|
||||
|
@ -4348,7 +4348,7 @@ switch (v.sqltype)
|
|||
parameters to a prepared query are:
|
||||
</para>
|
||||
<step><simpara>Create a prepared query (prepared statement)</simpara></step>
|
||||
<step><simpara>Declare a sqlda_t structure as an input SQLDA.</simpara></step>
|
||||
<step><simpara>Declare an sqlda_t structure as an input SQLDA.</simpara></step>
|
||||
<step><simpara>Allocate memory area (as sqlda_t structure) for the input SQLDA.</simpara></step>
|
||||
<step><simpara>Set (copy) input values in the allocated memory.</simpara></step>
|
||||
<step><simpara>Open a cursor with specifying the input SQLDA.</simpara></step>
|
||||
|
@ -4630,7 +4630,7 @@ main(void)
|
|||
EXEC SQL PREPARE stmt1 FROM :query;
|
||||
EXEC SQL DECLARE cur1 CURSOR FOR stmt1;
|
||||
|
||||
/* Create a SQLDA structure for an input parameter */
|
||||
/* Create an SQLDA structure for an input parameter */
|
||||
sqlda2 = (sqlda_t *)malloc(sizeof(sqlda_t) + sizeof(sqlvar_t));
|
||||
memset(sqlda2, 0, sizeof(sqlda_t) + sizeof(sqlvar_t));
|
||||
sqlda2->sqln = 2; /* a number of input variables */
|
||||
|
@ -6911,7 +6911,7 @@ EXEC SQL [ AT <replaceable class="parameter">connection_name</replaceable> ] DEC
|
|||
<title>Description</title>
|
||||
|
||||
<para>
|
||||
<command>DECLARE STATEMENT</command> declares a SQL statement identifier.
|
||||
<command>DECLARE STATEMENT</command> declares an SQL statement identifier.
|
||||
SQL statement identifier can be associated with the connection.
|
||||
When the identifier is used by dynamic SQL statements, the statements
|
||||
are executed using the associated connection.
|
||||
|
@ -6945,7 +6945,7 @@ EXEC SQL [ AT <replaceable class="parameter">connection_name</replaceable> ] DEC
|
|||
<term><replaceable class="parameter">statement_name</replaceable></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The name of a SQL statement identifier, either as an SQL identifier or a host variable.
|
||||
The name of an SQL statement identifier, either as an SQL identifier or a host variable.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -1441,7 +1441,7 @@ include $(PGXS)
|
|||
and include the global <acronym>PGXS</acronym> makefile.
|
||||
Here is an example that builds an extension module named
|
||||
<literal>isbn_issn</literal>, consisting of a shared library containing
|
||||
some C code, an extension control file, a SQL script, an include file
|
||||
some C code, an extension control file, an SQL script, an include file
|
||||
(only needed if other modules might need to access the extension functions
|
||||
without going via SQL), and a documentation text file:
|
||||
<programlisting>
|
||||
|
|
|
@ -15196,7 +15196,7 @@ table2-mapping
|
|||
<returnvalue>json</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Converts a SQL array to a JSON array. The behavior is the same
|
||||
Converts an SQL array to a JSON array. The behavior is the same
|
||||
as <function>to_json</function> except that line feeds will be added
|
||||
between top-level array elements if the optional boolean parameter is
|
||||
true.
|
||||
|
@ -15216,7 +15216,7 @@ table2-mapping
|
|||
<returnvalue>json</returnvalue>
|
||||
</para>
|
||||
<para>
|
||||
Converts a SQL composite value to a JSON object. The behavior is the
|
||||
Converts an SQL composite value to a JSON object. The behavior is the
|
||||
same as <function>to_json</function> except that line feeds will be
|
||||
added between top-level elements if the optional boolean parameter is
|
||||
true.
|
||||
|
@ -15629,7 +15629,7 @@ table2-mapping
|
|||
<itemizedlist spacing="compact">
|
||||
<listitem>
|
||||
<para>
|
||||
A JSON null value is converted to a SQL null in all cases.
|
||||
A JSON null value is converted to an SQL null in all cases.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
|
@ -16152,7 +16152,7 @@ table2-mapping
|
|||
<literal>string</literal>, <literal>number</literal>,
|
||||
<literal>boolean</literal>, and <literal>null</literal>.
|
||||
(The <literal>null</literal> result should not be confused
|
||||
with a SQL NULL; see the examples.)
|
||||
with an SQL NULL; see the examples.)
|
||||
</para>
|
||||
<para>
|
||||
<literal>json_typeof('-123.4')</literal>
|
||||
|
|
|
@ -2194,7 +2194,7 @@ HINT: You can then restart the server after making the necessary configuration
|
|||
Currently, temporary table creation is not allowed during read only
|
||||
transactions, so in some cases existing scripts will not run correctly.
|
||||
This restriction might be relaxed in a later release. This is
|
||||
both a SQL Standard compliance issue and a technical issue.
|
||||
both an SQL Standard compliance issue and a technical issue.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
|
|
@ -338,7 +338,7 @@ aminsert (Relation indexRelation,
|
|||
|
||||
<para>
|
||||
If the index AM wishes to cache data across successive index insertions
|
||||
within a SQL statement, it can allocate space
|
||||
within an SQL statement, it can allocate space
|
||||
in <literal>indexInfo->ii_Context</literal> and store a pointer to the
|
||||
data in <literal>indexInfo->ii_AmCache</literal> (which will be NULL
|
||||
initially).
|
||||
|
|
|
@ -3468,7 +3468,7 @@ char *PQresultErrorField(const PGresult *res, int fieldcode);
|
|||
<listitem>
|
||||
<para>
|
||||
The text of a failed internally-generated command. This could
|
||||
be, for example, a SQL query issued by a PL/pgSQL function.
|
||||
be, for example, an SQL query issued by a PL/pgSQL function.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
@ -5468,7 +5468,7 @@ UPDATE mytable SET x = x + 1 WHERE id = 42;
|
|||
</indexterm>
|
||||
|
||||
<para>
|
||||
Ordinarily, <application>libpq</application> collects a SQL command's
|
||||
Ordinarily, <application>libpq</application> collects an SQL command's
|
||||
entire result and returns it to the application as a single
|
||||
<structname>PGresult</structname>. This can be unworkable for commands
|
||||
that return a large number of rows. For such cases, applications can use
|
||||
|
|
|
@ -804,7 +804,7 @@ ltreetest=> SELECT subpath(path,0,2)||'Space'||subpath(path,2) FROM test WHER
|
|||
</para>
|
||||
|
||||
<para>
|
||||
We could simplify this by creating a SQL function that inserts a label
|
||||
We could simplify this by creating an SQL function that inserts a label
|
||||
at a specified position in a path:
|
||||
<screen>
|
||||
CREATE FUNCTION ins_label(ltree, int, text) RETURNS ltree
|
||||
|
|
|
@ -703,7 +703,7 @@ ERROR: could not serialize access due to read/write dependencies among transact
|
|||
transactions might do, or it will not successfully commit. It is
|
||||
important that an environment which uses this technique have a
|
||||
generalized way of handling serialization failures (which always return
|
||||
with a SQLSTATE value of '40001'), because it will be very hard to
|
||||
with an SQLSTATE value of '40001'), because it will be very hard to
|
||||
predict exactly which transactions might contribute to the read/write
|
||||
dependencies and need to be rolled back to prevent serialization
|
||||
anomalies. The monitoring of read/write dependencies has a cost, as does
|
||||
|
|
|
@ -136,7 +136,7 @@ test=# SELECT page_checksum(get_raw_page('pg_class', 0), 0);
|
|||
<listitem>
|
||||
<para>
|
||||
<function>fsm_page_contents</function> shows the internal node structure
|
||||
of a FSM page. For example:
|
||||
of an FSM page. For example:
|
||||
<screen>
|
||||
test=# SELECT fsm_page_contents(get_raw_page('pg_class', 'fsm', 0));
|
||||
</screen>
|
||||
|
|
|
@ -521,7 +521,7 @@ gen_salt(type text [, iter_count integer ]) returns text
|
|||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
An SHA1 hash of the random prefix and data is appended.
|
||||
A SHA1 hash of the random prefix and data is appended.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
|
|
|
@ -1099,7 +1099,7 @@ PERFORM <replaceable>query</replaceable>;
|
|||
One might expect that writing <command>SELECT</command> directly
|
||||
would accomplish this result, but at
|
||||
present the only accepted way to do it is
|
||||
<command>PERFORM</command>. A SQL command that can return rows,
|
||||
<command>PERFORM</command>. An SQL command that can return rows,
|
||||
such as <command>SELECT</command>, will be rejected as an error
|
||||
unless it has an <literal>INTO</literal> clause as discussed in the
|
||||
next section.
|
||||
|
@ -1128,7 +1128,7 @@ PERFORM create_mv('cs_session_page_requests_mv', my_query);
|
|||
</indexterm>
|
||||
|
||||
<para>
|
||||
The result of a SQL command yielding a single row (possibly of multiple
|
||||
The result of an SQL command yielding a single row (possibly of multiple
|
||||
columns) can be assigned to a record variable, row-type variable, or list
|
||||
of scalar variables. This is done by writing the base SQL command and
|
||||
adding an <literal>INTO</literal> clause. For example,
|
||||
|
@ -1317,7 +1317,7 @@ EXECUTE <replaceable class="command">command-string</replaceable> <optional> INT
|
|||
|
||||
<para>
|
||||
The <literal>INTO</literal> clause specifies where the results of
|
||||
a SQL command returning rows should be assigned. If a row variable
|
||||
an SQL command returning rows should be assigned. If a row variable
|
||||
or variable list is provided, it must exactly match the structure
|
||||
of the command's results; if a
|
||||
record variable is provided, it will configure itself to match the
|
||||
|
@ -2659,7 +2659,7 @@ END LOOP <optional> <replaceable>label</replaceable> </optional>;
|
|||
|
||||
<para>
|
||||
The <literal>FOREACH</literal> loop is much like a <literal>FOR</literal> loop,
|
||||
but instead of iterating through the rows returned by a SQL query,
|
||||
but instead of iterating through the rows returned by an SQL query,
|
||||
it iterates through the elements of an array value.
|
||||
(In general, <literal>FOREACH</literal> is meant for looping through
|
||||
components of a composite-valued expression; variants for looping
|
||||
|
@ -4726,7 +4726,7 @@ INSERT INTO foo (foo) VALUES (foo(foo));
|
|||
|
||||
<para>
|
||||
Another way to understand this is that variable substitution can only
|
||||
insert data values into a SQL command; it cannot dynamically change which
|
||||
insert data values into an SQL command; it cannot dynamically change which
|
||||
database objects are referenced by the command. (If you want to do
|
||||
that, you must build a command string dynamically, as explained in
|
||||
<xref linkend="plpgsql-statements-executing-dyn"/>.)
|
||||
|
@ -4748,7 +4748,7 @@ INSERT INTO dest (col) SELECT foo + bar FROM src;
|
|||
|
||||
<para>
|
||||
By default, <application>PL/pgSQL</application> will report an error if a name
|
||||
in a SQL statement could refer to either a variable or a table column.
|
||||
in an SQL statement could refer to either a variable or a table column.
|
||||
You can fix such a problem by renaming the variable or column,
|
||||
or by qualifying the ambiguous reference, or by telling
|
||||
<application>PL/pgSQL</application> which interpretation to prefer.
|
||||
|
@ -5384,7 +5384,7 @@ HINT: Make sure the query returns the exact list of columns.
|
|||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
If a name used in a SQL command could be either a column name of a
|
||||
If a name used in an SQL command could be either a column name of a
|
||||
table used in the command or a reference to a variable of the function,
|
||||
<application>PL/SQL</application> treats it as a column name.
|
||||
By default, <application>PL/pgSQL</application> will throw an error
|
||||
|
|
|
@ -577,7 +577,7 @@ AS $$
|
|||
$$ LANGUAGE plpythonu;
|
||||
</programlisting>
|
||||
|
||||
To return a SQL null for any column, insert <symbol>None</symbol> at
|
||||
To return an SQL null for any column, insert <symbol>None</symbol> at
|
||||
the corresponding position.
|
||||
</para>
|
||||
<para>
|
||||
|
@ -605,7 +605,7 @@ $$ LANGUAGE plpythonu;
|
|||
|
||||
Any extra dictionary key/value pairs are ignored. Missing keys are
|
||||
treated as errors.
|
||||
To return a SQL null value for any column, insert
|
||||
To return an SQL null value for any column, insert
|
||||
<symbol>None</symbol> with the corresponding column name as the key.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -475,7 +475,7 @@ $$ LANGUAGE pltcl;
|
|||
<listitem>
|
||||
<para>
|
||||
The Tcl script contained in <replaceable>command</replaceable> is
|
||||
executed within a SQL subtransaction. If the script returns an
|
||||
executed within an SQL subtransaction. If the script returns an
|
||||
error, that entire subtransaction is rolled back before returning the
|
||||
error out to the surrounding Tcl code.
|
||||
See <xref linkend="pltcl-subtransactions"/> for more details and an
|
||||
|
@ -854,7 +854,7 @@ CREATE EVENT TRIGGER tcl_a_snitch ON ddl_command_start EXECUTE FUNCTION tclsnitc
|
|||
PL/Tcl's <function>elog</function> command. Such errors can be caught
|
||||
within Tcl using the Tcl <function>catch</function> command. If an
|
||||
error is not caught but is allowed to propagate out to the top level of
|
||||
execution of the PL/Tcl function, it is reported as a SQL error in the
|
||||
execution of the PL/Tcl function, it is reported as an SQL error in the
|
||||
function's calling query.
|
||||
</para>
|
||||
|
||||
|
@ -867,7 +867,7 @@ CREATE EVENT TRIGGER tcl_a_snitch ON ddl_command_start EXECUTE FUNCTION tclsnitc
|
|||
subtransaction, which is rolled back on error, so that any
|
||||
partially-completed operation is automatically cleaned up.)
|
||||
Again, if an error propagates out to the top level without being caught,
|
||||
it turns back into a SQL error.
|
||||
it turns back into an SQL error.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
|
|
|
@ -349,7 +349,7 @@
|
|||
<term>AuthenticationSSPI</term>
|
||||
<listitem>
|
||||
<para>
|
||||
The frontend must now initiate a SSPI negotiation. The frontend
|
||||
The frontend must now initiate an SSPI negotiation. The frontend
|
||||
will send a GSSResponse with the first part of the SSPI
|
||||
data stream in response to this. If further messages are needed,
|
||||
the server will respond with AuthenticationGSSContinue.
|
||||
|
@ -1605,7 +1605,7 @@ more details on SCRAM-SHA-256 and SCRAM-SHA-256-PLUS.
|
|||
<para>
|
||||
One or more server-challenge and client-response message will follow. Each
|
||||
server-challenge is sent in an AuthenticationSASLContinue message, followed
|
||||
by a response from client in an SASLResponse message. The particulars of
|
||||
by a response from client in a SASLResponse message. The particulars of
|
||||
the messages are mechanism specific.
|
||||
</para>
|
||||
</step>
|
||||
|
@ -6226,7 +6226,7 @@ message.
|
|||
<listitem>
|
||||
<para>
|
||||
Internal query: the text of a failed internally-generated command.
|
||||
This could be, for example, a SQL query issued by a PL/pgSQL function.
|
||||
This could be, for example, an SQL query issued by a PL/pgSQL function.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
|
@ -269,7 +269,7 @@ ALTER OPERATOR FAMILY <replaceable>name</replaceable> USING <replaceable class="
|
|||
</para>
|
||||
|
||||
<para>
|
||||
The operators should not be defined by SQL functions. A SQL function
|
||||
The operators should not be defined by SQL functions. An SQL function
|
||||
is likely to be inlined into the calling query, which will prevent
|
||||
the optimizer from recognizing that the query matches an index.
|
||||
</para>
|
||||
|
|
|
@ -701,7 +701,7 @@ CREATE FUNCTION foo(int, int default 42) ...
|
|||
<title>Examples</title>
|
||||
|
||||
<para>
|
||||
Add two integers using a SQL function:
|
||||
Add two integers using an SQL function:
|
||||
<programlisting>
|
||||
CREATE FUNCTION add(integer, integer) RETURNS integer
|
||||
AS 'select $1 + $2;'
|
||||
|
|
|
@ -265,7 +265,7 @@ CREATE OPERATOR CLASS <replaceable class="parameter">name</replaceable> [ DEFAUL
|
|||
</para>
|
||||
|
||||
<para>
|
||||
The operators should not be defined by SQL functions. A SQL function
|
||||
The operators should not be defined by SQL functions. An SQL function
|
||||
is likely to be inlined into the calling query, which will prevent
|
||||
the optimizer from recognizing that the query matches an index.
|
||||
</para>
|
||||
|
|
|
@ -208,7 +208,7 @@ EXPLAIN ANALYZE SELECT * FROM t1 WHERE (a = 1) AND (b = 0);
|
|||
|
||||
<para>
|
||||
Create table <structname>t2</structname> with two perfectly correlated columns
|
||||
(containing identical data), and a MCV list on those columns:
|
||||
(containing identical data), and an MCV list on those columns:
|
||||
|
||||
<programlisting>
|
||||
CREATE TABLE t2 (
|
||||
|
|
|
@ -515,7 +515,7 @@ UPDATE OF <replaceable>column_name1</replaceable> [, <replaceable>column_name2</
|
|||
as <literal>ON UPDATE CASCADE</literal> or <literal>ON DELETE SET NULL</literal>, are
|
||||
treated as part of the SQL command that caused them (note that such
|
||||
actions are never deferred). Relevant triggers on the affected table will
|
||||
be fired, so that this provides another way in which a SQL command might
|
||||
be fired, so that this provides another way in which an SQL command might
|
||||
fire triggers not directly matching its type. In simple cases, triggers
|
||||
that request transition relations will see all changes caused in their
|
||||
table by a single original SQL command as a single transition relation.
|
||||
|
|
|
@ -1413,7 +1413,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
|
|||
<title>Examples</title>
|
||||
|
||||
<para>
|
||||
To dump a database called <literal>mydb</literal> into a SQL-script file:
|
||||
To dump a database called <literal>mydb</literal> into an SQL-script file:
|
||||
<screen>
|
||||
<prompt>$</prompt> <userinput>pg_dump mydb > db.sql</userinput>
|
||||
</screen>
|
||||
|
|
|
@ -1012,7 +1012,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
|
|||
Before <productname>PostgreSQL</productname> 9.6, SQL commands in script files
|
||||
were terminated by newlines, and so they could not be continued across
|
||||
lines. Now a semicolon is <emphasis>required</emphasis> to separate consecutive
|
||||
SQL commands (though a SQL command does not need one if it is followed
|
||||
SQL commands (though an SQL command does not need one if it is followed
|
||||
by a meta command). If you need to create a script file that works with
|
||||
both old and new versions of <application>pgbench</application>, be sure to write
|
||||
each SQL command on a single line ending with a semicolon.
|
||||
|
@ -1030,7 +1030,7 @@ pgbench <optional> <replaceable>options</replaceable> </optional> <replaceable>d
|
|||
<xref linkend="pgbench-automatic-variables"/>. A value specified for these
|
||||
variables using <option>-D</option> takes precedence over the automatic presets.
|
||||
Once set, a variable's
|
||||
value can be inserted into a SQL command by writing
|
||||
value can be inserted into an SQL command by writing
|
||||
<literal>:</literal><replaceable>variablename</replaceable>. When running more than
|
||||
one client session, each session has its own set of variables.
|
||||
<application>pgbench</application> supports up to 255 variable uses in one
|
||||
|
|
|
@ -1044,7 +1044,7 @@ testdb=>
|
|||
For <literal>\copy ... from stdin</literal>, data rows are read from the same
|
||||
source that issued the command, continuing until <literal>\.</literal>
|
||||
is read or the stream reaches <acronym>EOF</acronym>. This option is useful
|
||||
for populating tables in-line within a SQL script file.
|
||||
for populating tables in-line within an SQL script file.
|
||||
For <literal>\copy ... to stdout</literal>, output is sent to the same place
|
||||
as <application>psql</application> command output, and
|
||||
the <literal>COPY <replaceable>count</replaceable></literal> command status is
|
||||
|
@ -2243,7 +2243,7 @@ Tue Oct 26 21:40:57 CEST 1999
|
|||
<listitem>
|
||||
<para>
|
||||
Sends the current query buffer to the server, then treats
|
||||
each column of each row of the query's output (if any) as a SQL
|
||||
each column of each row of the query's output (if any) as an SQL
|
||||
statement to be executed. For example, to create an index on each
|
||||
column of <structname>my_table</structname>:
|
||||
<programlisting>
|
||||
|
@ -3510,7 +3510,7 @@ testdb=> <userinput>\setenv LESS -imx4F</userinput>
|
|||
</para>
|
||||
|
||||
<para>
|
||||
Normally, <application>psql</application> will dispatch a SQL command to the
|
||||
Normally, <application>psql</application> will dispatch an SQL command to the
|
||||
server as soon as it reaches the command-ending semicolon, even if
|
||||
more input remains on the current line. Thus for example entering
|
||||
<programlisting>
|
||||
|
|
|
@ -198,13 +198,13 @@ row1 val11 val12 val13 ...
|
|||
row2 val21 val22 val23 ...
|
||||
...
|
||||
</programlisting>
|
||||
The <function>crosstab</function> function takes a text parameter that is a SQL
|
||||
The <function>crosstab</function> function takes a text parameter that is an SQL
|
||||
query producing raw data formatted in the first way, and produces a table
|
||||
formatted in the second way.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The <parameter>sql</parameter> parameter is a SQL statement that produces
|
||||
The <parameter>sql</parameter> parameter is an SQL statement that produces
|
||||
the source set of data. This statement must return one
|
||||
<structfield>row_name</structfield> column, one
|
||||
<structfield>category</structfield> column, and one
|
||||
|
@ -459,7 +459,7 @@ crosstab(text source_sql, text category_sql)
|
|||
</para>
|
||||
|
||||
<para>
|
||||
<parameter>source_sql</parameter> is a SQL statement that produces the
|
||||
<parameter>source_sql</parameter> is an SQL statement that produces the
|
||||
source set of data. This statement must return one
|
||||
<structfield>row_name</structfield> column, one
|
||||
<structfield>category</structfield> column, and one
|
||||
|
@ -493,7 +493,7 @@ SELECT row_name, extra_col, cat, value FROM foo ORDER BY 1;
|
|||
</para>
|
||||
|
||||
<para>
|
||||
<parameter>category_sql</parameter> is a SQL statement that produces
|
||||
<parameter>category_sql</parameter> is an SQL statement that produces
|
||||
the set of categories. This statement must return only one column.
|
||||
It must produce at least one row, or an error will be generated.
|
||||
Also, it must not produce duplicate values, or an error will be
|
||||
|
|
|
@ -28,7 +28,7 @@ method_name(internal) RETURNS tsm_handler
|
|||
The name of the function is the same method name appearing in the
|
||||
<literal>TABLESAMPLE</literal> clause. The <type>internal</type> argument is a dummy
|
||||
(always having value zero) that simply serves to prevent this function from
|
||||
being called directly from a SQL command.
|
||||
being called directly from an SQL command.
|
||||
The result of the function must be a palloc'd struct of
|
||||
type <type>TsmRoutine</type>, which contains pointers to support functions for
|
||||
the sampling method. These support functions are plain C functions and
|
||||
|
|
|
@ -1790,7 +1790,7 @@ SELECT ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'c'::tsquery);
|
|||
<listitem>
|
||||
<para>
|
||||
This form of <function>ts_rewrite</function> accepts a starting
|
||||
<replaceable>query</replaceable> and a SQL <replaceable>select</replaceable> command, which
|
||||
<replaceable>query</replaceable> and an SQL <replaceable>select</replaceable> command, which
|
||||
is given as a text string. The <replaceable>select</replaceable> must yield two
|
||||
columns of <type>tsquery</type> type. For each row of the
|
||||
<replaceable>select</replaceable> result, occurrences of the first column value
|
||||
|
|
|
@ -411,7 +411,7 @@
|
|||
trigger <emphasis>will</emphasis> see the effects of data
|
||||
changes for rows previously processed in the same outer
|
||||
command. This requires caution, since the ordering of these
|
||||
change events is not in general predictable; a SQL command that
|
||||
change events is not in general predictable; an SQL command that
|
||||
affects multiple rows can visit the rows in any order.
|
||||
</para>
|
||||
</listitem>
|
||||
|
|
|
@ -1222,7 +1222,7 @@ section consider all of their inputs in one resolution step.
|
|||
|
||||
<para>
|
||||
The rules given in the preceding sections will result in assignment
|
||||
of non-<type>unknown</type> data types to all expressions in a SQL query,
|
||||
of non-<type>unknown</type> data types to all expressions in an SQL query,
|
||||
except for unspecified-type literals that appear as simple output
|
||||
columns of a <command>SELECT</command> command. For example, in
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@
|
|||
must be a <command>SELECT</command> or have a <literal>RETURNING</literal>
|
||||
clause that returns whatever is
|
||||
specified as the function's return type. Alternatively, if you
|
||||
want to define a SQL function that performs actions but has no
|
||||
want to define an SQL function that performs actions but has no
|
||||
useful value to return, you can define it as returning <type>void</type>.
|
||||
For example, this function removes rows with negative salaries from
|
||||
the <literal>emp</literal> table:
|
||||
|
@ -234,8 +234,8 @@ CALL clean_emp();
|
|||
|
||||
<note>
|
||||
<para>
|
||||
The entire body of a SQL function is parsed before any of it is
|
||||
executed. While a SQL function can contain commands that alter
|
||||
The entire body of an SQL function is parsed before any of it is
|
||||
executed. While an SQL function can contain commands that alter
|
||||
the system catalogs (e.g., <command>CREATE TABLE</command>), the effects
|
||||
of such commands will not be visible during parse analysis of
|
||||
later commands in the function. Thus, for example,
|
||||
|
@ -243,7 +243,7 @@ CALL clean_emp();
|
|||
will not work as desired if packaged up into a single SQL function,
|
||||
since <structname>foo</structname> won't exist yet when the <command>INSERT</command>
|
||||
command is parsed. It's recommended to use <application>PL/pgSQL</application>
|
||||
instead of a SQL function in this type of situation.
|
||||
instead of an SQL function in this type of situation.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
|
@ -267,7 +267,7 @@ CALL clean_emp();
|
|||
</indexterm>
|
||||
|
||||
<para>
|
||||
Arguments of a SQL function can be referenced in the function
|
||||
Arguments of an SQL function can be referenced in the function
|
||||
body using either names or numbers. Examples of both methods appear
|
||||
below.
|
||||
</para>
|
||||
|
@ -1473,7 +1473,7 @@ SELECT concat_values('|', 1, 4, 2);
|
|||
</indexterm>
|
||||
|
||||
<para>
|
||||
When a SQL function has one or more parameters of collatable data types,
|
||||
When an SQL function has one or more parameters of collatable data types,
|
||||
a collation is identified for each function call depending on the
|
||||
collations assigned to the actual arguments, as described in <xref
|
||||
linkend="collation"/>. If a collation is successfully identified
|
||||
|
@ -1508,7 +1508,7 @@ $$ LANGUAGE SQL;
|
|||
|
||||
<para>
|
||||
If no common collation can be identified among the actual arguments,
|
||||
then a SQL function treats its parameters as having their data types'
|
||||
then an SQL function treats its parameters as having their data types'
|
||||
default collation (which is usually the database's default collation,
|
||||
but could be different for parameters of domain types).
|
||||
</para>
|
||||
|
@ -2952,7 +2952,7 @@ HeapTupleGetDatum(HeapTuple tuple)
|
|||
save enough state across calls to remember what it was doing and
|
||||
return the correct next item on each call.
|
||||
In the other method, called <firstterm>Materialize</firstterm> mode,
|
||||
a SRF fills and returns a tuplestore object containing its
|
||||
an SRF fills and returns a tuplestore object containing its
|
||||
entire result; then only one call occurs for the whole result, and
|
||||
no inter-call state is needed.
|
||||
</para>
|
||||
|
@ -3375,7 +3375,7 @@ CREATE FUNCTION make_array(anyelement) RETURNS anyarray
|
|||
There is a variant of polymorphism that is only available to C-language
|
||||
functions: they can be declared to take parameters of type
|
||||
<literal>"any"</literal>. (Note that this type name must be double-quoted,
|
||||
since it's also a SQL reserved word.) This works like
|
||||
since it's also an SQL reserved word.) This works like
|
||||
<type>anyelement</type> except that it does not constrain different
|
||||
<literal>"any"</literal> arguments to be the same type, nor do they help
|
||||
determine the function's result type. A C-language function can also
|
||||
|
@ -3544,7 +3544,7 @@ if (!ptr)
|
|||
|
||||
<para>
|
||||
It is also possible to attach a <firstterm>planner support
|
||||
function</firstterm> to a SQL-callable function (called
|
||||
function</firstterm> to an SQL-callable function (called
|
||||
its <firstterm>target function</firstterm>), and thereby provide
|
||||
knowledge about the target function that is too complex to be
|
||||
represented declaratively. Planner support functions have to be
|
||||
|
|
|
@ -511,13 +511,13 @@ init_execution_state(List *queryTree_list,
|
|||
((CopyStmt *) stmt->utilityStmt)->filename == NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("cannot COPY to/from client in a SQL function")));
|
||||
errmsg("cannot COPY to/from client in an SQL function")));
|
||||
|
||||
if (IsA(stmt->utilityStmt, TransactionStmt))
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
/* translator: %s is a SQL statement name */
|
||||
errmsg("%s is not allowed in a SQL function",
|
||||
errmsg("%s is not allowed in an SQL function",
|
||||
CreateCommandName(stmt->utilityStmt))));
|
||||
}
|
||||
|
||||
|
|
|
@ -5149,7 +5149,7 @@ ParseScript(const char *script, const char *desc, int weight)
|
|||
|
||||
if (index == 0)
|
||||
syntax_error(desc, lineno, NULL, NULL,
|
||||
"\\gset must follow a SQL command",
|
||||
"\\gset must follow an SQL command",
|
||||
NULL, -1);
|
||||
|
||||
cmd = ps.commands[index - 1];
|
||||
|
@ -5157,7 +5157,7 @@ ParseScript(const char *script, const char *desc, int weight)
|
|||
if (cmd->type != SQL_COMMAND ||
|
||||
cmd->varprefix != NULL)
|
||||
syntax_error(desc, lineno, NULL, NULL,
|
||||
"\\gset must follow a SQL command",
|
||||
"\\gset must follow an SQL command",
|
||||
cmd->first_line, -1);
|
||||
|
||||
/* get variable prefix */
|
||||
|
|
|
@ -1091,10 +1091,10 @@ SELECT LEAST(} . join(', ', (':i') x 256) . q{)}
|
|||
'gset no row', 2,
|
||||
[qr{expected one row, got 0\b}], q{SELECT WHERE FALSE \gset}
|
||||
],
|
||||
[ 'gset alone', 1, [qr{gset must follow a SQL command}], q{\gset} ],
|
||||
[ 'gset alone', 1, [qr{gset must follow an SQL command}], q{\gset} ],
|
||||
[
|
||||
'gset no SQL', 1,
|
||||
[qr{gset must follow a SQL command}], q{\set i +1
|
||||
[qr{gset must follow an SQL command}], q{\set i +1
|
||||
\gset}
|
||||
],
|
||||
[
|
||||
|
@ -1103,7 +1103,7 @@ SELECT LEAST(} . join(', ', (':i') x 256) . q{)}
|
|||
],
|
||||
[
|
||||
'gset after gset', 1,
|
||||
[qr{gset must follow a SQL command}], q{SELECT 1 AS i \gset
|
||||
[qr{gset must follow an SQL command}], q{SELECT 1 AS i \gset
|
||||
\gset}
|
||||
],
|
||||
[
|
||||
|
|
Loading…
Reference in New Issue