Commit 66424a28 authored by Peter Eisentraut's avatar Peter Eisentraut

Fix indentation of verbatim block elements

Block elements with verbatim formatting (literallayout, programlisting,
screen, synopsis) should be aligned at column 0 independent of the surrounding
SGML, because whitespace is significant, and indenting them creates erratic
whitespace in the output.  The CSS stylesheets already take care of indenting
the output.

Assorted markup improvements to go along with it.
parent 984d56b8
<!-- $PostgreSQL: pgsql/doc/src/sgml/auto-explain.sgml,v 1.8 2010/04/03 07:22:52 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/auto-explain.sgml,v 1.9 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="auto-explain"> <sect1 id="auto-explain">
<title>auto_explain</title> <title>auto_explain</title>
...@@ -19,9 +19,9 @@ ...@@ -19,9 +19,9 @@
The module provides no SQL-accessible functions. To use it, simply The module provides no SQL-accessible functions. To use it, simply
load it into the server. You can load it into an individual session: load it into the server. You can load it into an individual session:
<programlisting> <programlisting>
LOAD 'auto_explain'; LOAD 'auto_explain';
</programlisting> </programlisting>
(You must be superuser to do that.) More typical usage is to preload (You must be superuser to do that.) More typical usage is to preload
it into all sessions by including <literal>auto_explain</> in it into all sessions by including <literal>auto_explain</> in
...@@ -163,32 +163,32 @@ LOAD 'auto_explain'; ...@@ -163,32 +163,32 @@ LOAD 'auto_explain';
<xref linkend="guc-custom-variable-classes">. Typical usage might be: <xref linkend="guc-custom-variable-classes">. Typical usage might be:
</para> </para>
<programlisting> <programlisting>
# postgresql.conf # postgresql.conf
shared_preload_libraries = 'auto_explain' shared_preload_libraries = 'auto_explain'
custom_variable_classes = 'auto_explain' custom_variable_classes = 'auto_explain'
auto_explain.log_min_duration = '3s' auto_explain.log_min_duration = '3s'
</programlisting> </programlisting>
</sect2> </sect2>
<sect2> <sect2>
<title>Example</title> <title>Example</title>
<programlisting> <programlisting>
postgres=# LOAD 'auto_explain'; postgres=# LOAD 'auto_explain';
postgres=# SET auto_explain.log_min_duration = 0; postgres=# SET auto_explain.log_min_duration = 0;
postgres=# SELECT count(*) postgres=# SELECT count(*)
FROM pg_class, pg_index FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique; WHERE oid = indrelid AND indisunique;
</programlisting> </programlisting>
<para> <para>
This might produce log output such as: This might produce log output such as:
</para> </para>
<programlisting><![CDATA[ <screen><![CDATA[
LOG: duration: 3.651 ms plan: LOG: duration: 3.651 ms plan:
Query Text: SELECT count(*) Query Text: SELECT count(*)
FROM pg_class, pg_index FROM pg_class, pg_index
WHERE oid = indrelid AND indisunique; WHERE oid = indrelid AND indisunique;
...@@ -200,8 +200,7 @@ auto_explain.log_min_duration = '3s' ...@@ -200,8 +200,7 @@ auto_explain.log_min_duration = '3s'
Buckets: 1024 Batches: 1 Memory Usage: 4kB Buckets: 1024 Batches: 1 Memory Usage: 4kB
-> Seq Scan on pg_index (cost=0.00..3.02 rows=92 width=4) (actual time=0.008..3.187 rows=92 loops=1) -> Seq Scan on pg_index (cost=0.00..3.02 rows=92 width=4) (actual time=0.008..3.187 rows=92 loops=1)
Filter: indisunique Filter: indisunique
]]> ]]></screen>
</programlisting>
</sect2> </sect2>
<sect2> <sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/citext.sgml,v 1.4 2010/06/29 22:29:13 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/citext.sgml,v 1.5 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="citext"> <sect1 id="citext">
<title>citext</title> <title>citext</title>
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
in <productname>PostgreSQL</> has been to use the <function>lower</> in <productname>PostgreSQL</> has been to use the <function>lower</>
function when comparing values, for example function when comparing values, for example
<programlisting> <programlisting>
SELECT * FROM tab WHERE lower(col) = LOWER(?); SELECT * FROM tab WHERE lower(col) = LOWER(?);
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -74,20 +74,20 @@ ...@@ -74,20 +74,20 @@
<para> <para>
Here's a simple example of usage: Here's a simple example of usage:
<programlisting> <programlisting>
CREATE TABLE users ( CREATE TABLE users (
nick CITEXT PRIMARY KEY, nick CITEXT PRIMARY KEY,
pass TEXT NOT NULL pass TEXT NOT NULL
); );
INSERT INTO users VALUES ( 'larry', md5(random()::text) ); INSERT INTO users VALUES ( 'larry', md5(random()::text) );
INSERT INTO users VALUES ( 'Tom', md5(random()::text) ); INSERT INTO users VALUES ( 'Tom', md5(random()::text) );
INSERT INTO users VALUES ( 'Damian', md5(random()::text) ); INSERT INTO users VALUES ( 'Damian', md5(random()::text) );
INSERT INTO users VALUES ( 'NEAL', md5(random()::text) ); INSERT INTO users VALUES ( 'NEAL', md5(random()::text) );
INSERT INTO users VALUES ( 'Bj&oslash;rn', md5(random()::text) ); INSERT INTO users VALUES ( 'Bj&oslash;rn', md5(random()::text) );
SELECT * FROM users WHERE nick = 'Larry'; SELECT * FROM users WHERE nick = 'Larry';
</programlisting> </programlisting>
The <command>SELECT</> statement will return one tuple, even though The <command>SELECT</> statement will return one tuple, even though
the <structfield>nick</> column was set to <quote>larry</> and the query the <structfield>nick</> column was set to <quote>larry</> and the query
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.139 2010/06/29 22:29:13 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/client-auth.sgml,v 1.140 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="client-authentication"> <chapter id="client-authentication">
<title>Client Authentication</title> <title>Client Authentication</title>
...@@ -1353,11 +1353,11 @@ omicron bryanh guest1 ...@@ -1353,11 +1353,11 @@ omicron bryanh guest1
Since LDAP often uses commas and spaces to separate the different Since LDAP often uses commas and spaces to separate the different
parts of a DN, it is often necessary to use double-quoted parameter parts of a DN, it is often necessary to use double-quoted parameter
values when configuring LDAP options, for example: values when configuring LDAP options, for example:
<programlisting>
ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
</programlisting>
</para> </para>
</note> </note>
<synopsis>
ldapserver=ldap.example.net ldapprefix="cn=" ldapsuffix=", dc=example, dc=net"
</synopsis>
</sect2> </sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.301 2010/07/27 19:01:16 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.302 2010/07/29 19:34:40 petere Exp $ -->
<chapter Id="runtime-config"> <chapter Id="runtime-config">
<title>Server Configuration</title> <title>Server Configuration</title>
...@@ -5808,29 +5808,20 @@ plruby.use_strict = true # generates error: unknown class name ...@@ -5808,29 +5808,20 @@ plruby.use_strict = true # generates error: unknown class name
type a count of the number of granted locks and waiting locks is type a count of the number of granted locks and waiting locks is
also dumped as well as the totals. An example of the log file output also dumped as well as the totals. An example of the log file output
is shown here: is shown here:
</para> <screen>
<para> LOG: LockAcquire: new: lock(0xb7acd844) id(24688,24696,0,0,0,1)
LOG: LockAcquire: new: lock(0xb7acd844) id(24688,24696,0,0,0,1)
grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
wait(0) type(AccessShareLock) wait(0) type(AccessShareLock)
</para> LOG: GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1)
<para>
LOG: GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1)
grantMask(2) req(1,0,0,0,0,0,0)=1 grant(1,0,0,0,0,0,0)=1 grantMask(2) req(1,0,0,0,0,0,0)=1 grant(1,0,0,0,0,0,0)=1
wait(0) type(AccessShareLock) wait(0) type(AccessShareLock)
LOG: UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1)
</para>
<para>
LOG: UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1)
grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
wait(0) type(AccessShareLock) wait(0) type(AccessShareLock)
</para> LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
<para>
LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0 grantMask(0) req(0,0,0,0,0,0,0)=0 grant(0,0,0,0,0,0,0)=0
wait(0) type(INVALID) wait(0) type(INVALID)
</para> </screen>
<para>
Details of the structure being dumped may be found in Details of the structure being dumped may be found in
src/include/storage/lock.h src/include/storage/lock.h
</para> </para>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/cube.sgml,v 1.7 2009/12/08 20:08:30 mha Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/cube.sgml,v 1.8 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="cube"> <sect1 id="cube">
<title>cube</title> <title>cube</title>
...@@ -98,47 +98,46 @@ ...@@ -98,47 +98,46 @@
<para> <para>
The <filename>cube</> module includes a GiST index operator class for The <filename>cube</> module includes a GiST index operator class for
<type>cube</> values. <type>cube</> values.
The operators supported by the GiST opclass include: The operators supported by the GiST opclass are shown in <xref linkend="cube-gist-operators">.
</para> </para>
<itemizedlist> <table id="cube-gist-operators">
<listitem> <title>Cube GiST operators</title>
<programlisting> <tgroup cols="2">
a = b Same as <thead>
</programlisting> <row>
<para> <entry>Operator</entry>
The cubes a and b are identical. <entry>Description</entry>
</para> </row>
</listitem> </thead>
<listitem>
<programlisting> <tbody>
a &amp;&amp; b Overlaps <row>
</programlisting> <entry><literal>a = b</></entry>
<para> <entry>The cubes a and b are identical.</entry>
The cubes a and b overlap. </row>
</para>
</listitem> <row>
<listitem> <entry><literal>a &amp;&amp; b</></entry>
<programlisting> <entry>The cubes a and b overlap.</entry>
a @&gt; b Contains </row>
</programlisting>
<para> <row>
The cube a contains the cube b. <entry><literal>a @&gt; b</></entry>
</para> <entry>The cube a contains the cube b.</entry>
</listitem> </row>
<listitem>
<programlisting> <row>
a &lt;@ b Contained in <entry><literal>a &lt;@ b</></entry>
</programlisting> <entry>The cube a is contained in the cube b.</entry>
<para> </row>
The cube a is contained in the cube b. </tbody>
</para> </tgroup>
</listitem> </table>
</itemizedlist>
<para> <para>
(Before PostgreSQL 8.2, the containment operators @&gt; and &lt;@ were (Before PostgreSQL 8.2, the containment operators <literal>@&gt;</> and <literal>&lt;@</> were
respectively called @ and ~. These names are still available, but are respectively called <literal>@</> and <literal>~</>. These names are still available, but are
deprecated and will eventually be retired. Notice that the old names deprecated and will eventually be retired. Notice that the old names
are reversed from the convention formerly followed by the core geometric are reversed from the convention formerly followed by the core geometric
datatypes!) datatypes!)
...@@ -147,10 +146,28 @@ a &lt;@ b Contained in ...@@ -147,10 +146,28 @@ a &lt;@ b Contained in
<para> <para>
The standard B-tree operators are also provided, for example The standard B-tree operators are also provided, for example
<programlisting> <informaltable>
[a, b] &lt; [c, d] Less than <tgroup cols="2">
[a, b] &gt; [c, d] Greater than <thead>
</programlisting> <row>
<entry>Operator</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>[a, b] &lt; [c, d]</literal></entry>
<entry>Less than</entry>
</row>
<row>
<entry><literal>[a, b] &gt; [c, d]</literal></entry>
<entry>Greater than</entry>
</row>
</tbody>
</tgroup>
</informaltable>
These operators do not make a lot of sense for any practical These operators do not make a lot of sense for any practical
purpose but sorting. These operators first compare (a) to (c), purpose but sorting. These operators first compare (a) to (c),
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.254 2010/07/27 19:01:16 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.255 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="datatype"> <chapter id="datatype">
<title>Data Types</title> <title>Data Types</title>
...@@ -1584,21 +1584,21 @@ SELECT E'\\xDEADBEEF'; ...@@ -1584,21 +1584,21 @@ SELECT E'\\xDEADBEEF';
<para> <para>
The <type>interval</type> type has an additional option, which is The <type>interval</type> type has an additional option, which is
to restrict the set of stored fields by writing one of these phrases: to restrict the set of stored fields by writing one of these phrases:
<programlisting> <literallayout class="monospaced">
YEAR YEAR
MONTH MONTH
DAY DAY
HOUR HOUR
MINUTE MINUTE
SECOND SECOND
YEAR TO MONTH YEAR TO MONTH
DAY TO HOUR DAY TO HOUR
DAY TO MINUTE DAY TO MINUTE
DAY TO SECOND DAY TO SECOND
HOUR TO MINUTE HOUR TO MINUTE
HOUR TO SECOND HOUR TO SECOND
MINUTE TO SECOND MINUTE TO SECOND
</programlisting> </literallayout>
Note that if both <replaceable>fields</replaceable> and Note that if both <replaceable>fields</replaceable> and
<replaceable>p</replaceable> are specified, the <replaceable>p</replaceable> are specified, the
<replaceable>fields</replaceable> must include <literal>SECOND</>, <replaceable>fields</replaceable> must include <literal>SECOND</>,
...@@ -3811,7 +3811,7 @@ SELECT to_tsvector('english', 'The Fat Rats'); ...@@ -3811,7 +3811,7 @@ SELECT to_tsvector('english', 'The Fat Rats');
of the operators: of the operators:
<programlisting> <programlisting>
SELECT 'fat &amp; rat'::tsquery; SELECT 'fat &amp; rat'::tsquery;
tsquery tsquery
--------------- ---------------
'fat' &amp; 'rat' 'fat' &amp; 'rat'
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/dblink.sgml,v 1.13 2010/06/15 20:29:01 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/dblink.sgml,v 1.14 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="dblink"> <sect1 id="dblink">
<title>dblink</title> <title>dblink</title>
...@@ -25,10 +25,10 @@ ...@@ -25,10 +25,10 @@
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_connect(text connstr) returns text dblink_connect(text connstr) returns text
dblink_connect(text connname, text connstr) returns text dblink_connect(text connname, text connstr) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -116,45 +116,45 @@ ...@@ -116,45 +116,45 @@
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
select dblink_connect('dbname=postgres'); SELECT dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
select dblink_connect('myconn', 'dbname=postgres'); SELECT dblink_connect('myconn', 'dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
-- FOREIGN DATA WRAPPER functionality -- FOREIGN DATA WRAPPER functionality
-- Note: local connection must require password authentication for this to work properly -- Note: local connection must require password authentication for this to work properly
-- Otherwise, you will receive the following error from dblink_connect(): -- Otherwise, you will receive the following error from dblink_connect():
-- ---------------------------------------------------------------------- -- ----------------------------------------------------------------------
-- ERROR: password is required -- ERROR: password is required
-- DETAIL: Non-superuser cannot connect if the server does not request a password. -- DETAIL: Non-superuser cannot connect if the server does not request a password.
-- HINT: Target server's authentication method must be changed. -- HINT: Target server's authentication method must be changed.
CREATE USER dblink_regression_test WITH PASSWORD 'secret'; CREATE USER dblink_regression_test WITH PASSWORD 'secret';
CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator; CREATE FOREIGN DATA WRAPPER postgresql VALIDATOR postgresql_fdw_validator;
CREATE SERVER fdtest FOREIGN DATA WRAPPER postgresql OPTIONS (hostaddr '127.0.0.1', dbname 'contrib_regression'); CREATE SERVER fdtest FOREIGN DATA WRAPPER postgresql OPTIONS (hostaddr '127.0.0.1', dbname 'contrib_regression');
CREATE USER MAPPING FOR dblink_regression_test SERVER fdtest OPTIONS (user 'dblink_regression_test', password 'secret'); CREATE USER MAPPING FOR dblink_regression_test SERVER fdtest OPTIONS (user 'dblink_regression_test', password 'secret');
GRANT USAGE ON FOREIGN SERVER fdtest TO dblink_regression_test; GRANT USAGE ON FOREIGN SERVER fdtest TO dblink_regression_test;
GRANT SELECT ON TABLE foo TO dblink_regression_test; GRANT SELECT ON TABLE foo TO dblink_regression_test;
\set ORIGINAL_USER :USER \set ORIGINAL_USER :USER
\c - dblink_regression_test \c - dblink_regression_test
SELECT dblink_connect('myconn', 'fdtest'); SELECT dblink_connect('myconn', 'fdtest');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
SELECT * FROM dblink('myconn','SELECT * FROM foo') AS t(a int, b text, c text[]); SELECT * FROM dblink('myconn','SELECT * FROM foo') AS t(a int, b text, c text[]);
a | b | c a | b | c
----+---+--------------- ----+---+---------------
0 | a | {a0,b0,c0} 0 | a | {a0,b0,c0}
1 | b | {a1,b1,c1} 1 | b | {a1,b1,c1}
2 | c | {a2,b2,c2} 2 | c | {a2,b2,c2}
...@@ -166,16 +166,16 @@ ...@@ -166,16 +166,16 @@
8 | i | {a8,b8,c8} 8 | i | {a8,b8,c8}
9 | j | {a9,b9,c9} 9 | j | {a9,b9,c9}
10 | k | {a10,b10,c10} 10 | k | {a10,b10,c10}
(11 rows) (11 rows)
\c - :ORIGINAL_USER \c - :ORIGINAL_USER
REVOKE USAGE ON FOREIGN SERVER fdtest FROM dblink_regression_test; REVOKE USAGE ON FOREIGN SERVER fdtest FROM dblink_regression_test;
REVOKE SELECT ON TABLE foo FROM dblink_regression_test; REVOKE SELECT ON TABLE foo FROM dblink_regression_test;
DROP USER MAPPING FOR dblink_regression_test SERVER fdtest; DROP USER MAPPING FOR dblink_regression_test SERVER fdtest;
DROP USER dblink_regression_test; DROP USER dblink_regression_test;
DROP SERVER fdtest; DROP SERVER fdtest;
DROP FOREIGN DATA WRAPPER postgresql; DROP FOREIGN DATA WRAPPER postgresql;
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -191,10 +191,10 @@ ...@@ -191,10 +191,10 @@
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_connect_u(text connstr) returns text dblink_connect_u(text connstr) returns text
dblink_connect_u(text connname, text connstr) returns text dblink_connect_u(text connname, text connstr) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -244,10 +244,10 @@ ...@@ -244,10 +244,10 @@
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_disconnect() returns text dblink_disconnect() returns text
dblink_disconnect(text connname) returns text dblink_disconnect(text connname) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -287,19 +287,19 @@ ...@@ -287,19 +287,19 @@
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# select dblink_disconnect(); SELECT dblink_disconnect();
dblink_disconnect dblink_disconnect
------------------- -------------------
OK OK
(1 row) (1 row)
select dblink_disconnect('myconn'); SELECT dblink_disconnect('myconn');
dblink_disconnect dblink_disconnect
------------------- -------------------
OK OK
(1 row) (1 row)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -315,11 +315,11 @@ ...@@ -315,11 +315,11 @@
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink(text connname, text sql [, bool fail_on_error]) returns setof record dblink(text connname, text sql [, bool fail_on_error]) returns setof record
dblink(text connstr, text sql [, bool fail_on_error]) returns setof record dblink(text connstr, text sql [, bool fail_on_error]) returns setof record
dblink(text sql [, bool fail_on_error]) returns setof record dblink(text sql [, bool fail_on_error]) returns setof record
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -440,25 +440,25 @@ SELECT * ...@@ -440,25 +440,25 @@ SELECT *
This allows the column type information to be buried in the view, This allows the column type information to be buried in the view,
instead of having to spell it out in every query. For example, instead of having to spell it out in every query. For example,
<programlisting> <programlisting>
create view myremote_pg_proc as CREATE VIEW myremote_pg_proc AS
select * SELECT *
from dblink('dbname=postgres', 'select proname, prosrc from pg_proc') FROM dblink('dbname=postgres', 'select proname, prosrc from pg_proc')
as t1(proname name, prosrc text); AS t1(proname name, prosrc text);
select * from myremote_pg_proc where proname like 'bytea%'; SELECT * FROM myremote_pg_proc WHERE proname LIKE 'bytea%';
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
select * from dblink('dbname=postgres', 'select proname, prosrc from pg_proc') SELECT * FROM dblink('dbname=postgres', 'select proname, prosrc from pg_proc')
as t1(proname name, prosrc text) where proname like 'bytea%'; AS t1(proname name, prosrc text) WHERE proname LIKE 'bytea%';
proname | prosrc proname | prosrc
------------+------------ ------------+------------
byteacat | byteacat byteacat | byteacat
byteaeq | byteaeq byteaeq | byteaeq
bytealt | bytealt bytealt | bytealt
...@@ -471,18 +471,18 @@ SELECT * ...@@ -471,18 +471,18 @@ SELECT *
byteanlike | byteanlike byteanlike | byteanlike
byteain | byteain byteain | byteain
byteaout | byteaout byteaout | byteaout
(12 rows) (12 rows)
select dblink_connect('dbname=postgres'); SELECT dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
select * from dblink('select proname, prosrc from pg_proc') SELECT * FROM dblink('select proname, prosrc from pg_proc')
as t1(proname name, prosrc text) where proname like 'bytea%'; AS t1(proname name, prosrc text) WHERE proname LIKE 'bytea%';
proname | prosrc proname | prosrc
------------+------------ ------------+------------
byteacat | byteacat byteacat | byteacat
byteaeq | byteaeq byteaeq | byteaeq
bytealt | bytealt bytealt | bytealt
...@@ -495,18 +495,18 @@ SELECT * ...@@ -495,18 +495,18 @@ SELECT *
byteanlike | byteanlike byteanlike | byteanlike
byteain | byteain byteain | byteain
byteaout | byteaout byteaout | byteaout
(12 rows) (12 rows)
select dblink_connect('myconn', 'dbname=regression'); SELECT dblink_connect('myconn', 'dbname=regression');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
select * from dblink('myconn', 'select proname, prosrc from pg_proc') SELECT * FROM dblink('myconn', 'select proname, prosrc from pg_proc')
as t1(proname name, prosrc text) where proname like 'bytea%'; AS t1(proname name, prosrc text) WHERE proname LIKE 'bytea%';
proname | prosrc proname | prosrc
------------+------------ ------------+------------
bytearecv | bytearecv bytearecv | bytearecv
byteasend | byteasend byteasend | byteasend
byteale | byteale byteale | byteale
...@@ -521,8 +521,8 @@ SELECT * ...@@ -521,8 +521,8 @@ SELECT *
bytealt | bytealt bytealt | bytealt
byteain | byteain byteain | byteain
byteaout | byteaout byteaout | byteaout
(14 rows) (14 rows)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -538,11 +538,11 @@ SELECT * ...@@ -538,11 +538,11 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_exec(text connname, text sql [, bool fail_on_error]) returns text dblink_exec(text connname, text sql [, bool fail_on_error]) returns text
dblink_exec(text connstr, text sql [, bool fail_on_error]) returns text dblink_exec(text connstr, text sql [, bool fail_on_error]) returns text
dblink_exec(text sql [, bool fail_on_error]) returns text dblink_exec(text sql [, bool fail_on_error]) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -622,40 +622,40 @@ SELECT * ...@@ -622,40 +622,40 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
select dblink_connect('dbname=dblink_test_standby'); SELECT dblink_connect('dbname=dblink_test_standby');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
select dblink_exec('insert into foo values(21,''z'',''{"a0","b0","c0"}'');'); SELECT dblink_exec('insert into foo values(21,''z'',''{"a0","b0","c0"}'');');
dblink_exec dblink_exec
----------------- -----------------
INSERT 943366 1 INSERT 943366 1
(1 row) (1 row)
select dblink_connect('myconn', 'dbname=regression'); SELECT dblink_connect('myconn', 'dbname=regression');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
select dblink_exec('myconn', 'insert into foo values(21,''z'',''{"a0","b0","c0"}'');'); SELECT dblink_exec('myconn', 'insert into foo values(21,''z'',''{"a0","b0","c0"}'');');
dblink_exec dblink_exec
------------------ ------------------
INSERT 6432584 1 INSERT 6432584 1
(1 row) (1 row)
select dblink_exec('myconn', 'insert into pg_class values (''foo'')',false); SELECT dblink_exec('myconn', 'insert into pg_class values (''foo'')',false);
NOTICE: sql error NOTICE: sql error
DETAIL: ERROR: null value in column "relnamespace" violates not-null constraint DETAIL: ERROR: null value in column "relnamespace" violates not-null constraint
dblink_exec dblink_exec
------------- -------------
ERROR ERROR
(1 row) (1 row)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -671,10 +671,10 @@ SELECT * ...@@ -671,10 +671,10 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_open(text cursorname, text sql [, bool fail_on_error]) returns text dblink_open(text cursorname, text sql [, bool fail_on_error]) returns text
dblink_open(text connname, text cursorname, text sql [, bool fail_on_error]) returns text dblink_open(text connname, text cursorname, text sql [, bool fail_on_error]) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -763,19 +763,19 @@ SELECT * ...@@ -763,19 +763,19 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# select dblink_connect('dbname=postgres'); SELECT dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
test=# select dblink_open('foo', 'select proname, prosrc from pg_proc'); SELECT dblink_open('foo', 'select proname, prosrc from pg_proc');
dblink_open dblink_open
------------- -------------
OK OK
(1 row) (1 row)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -791,10 +791,10 @@ SELECT * ...@@ -791,10 +791,10 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_fetch(text cursorname, int howmany [, bool fail_on_error]) returns setof record dblink_fetch(text cursorname, int howmany [, bool fail_on_error]) returns setof record
dblink_fetch(text connname, text cursorname, int howmany [, bool fail_on_error]) returns setof record dblink_fetch(text connname, text cursorname, int howmany [, bool fail_on_error]) returns setof record
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -880,51 +880,51 @@ SELECT * ...@@ -880,51 +880,51 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# select dblink_connect('dbname=postgres'); SELECT dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
test=# select dblink_open('foo', 'select proname, prosrc from pg_proc where proname like ''bytea%'''); SELECT dblink_open('foo', 'select proname, prosrc from pg_proc where proname like ''bytea%''');
dblink_open dblink_open
------------- -------------
OK OK
(1 row) (1 row)
test=# select * from dblink_fetch('foo', 5) as (funcname name, source text); SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
funcname | source funcname | source
----------+---------- ----------+----------
byteacat | byteacat byteacat | byteacat
byteacmp | byteacmp byteacmp | byteacmp
byteaeq | byteaeq byteaeq | byteaeq
byteage | byteage byteage | byteage
byteagt | byteagt byteagt | byteagt
(5 rows) (5 rows)
test=# select * from dblink_fetch('foo', 5) as (funcname name, source text); SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
funcname | source funcname | source
-----------+----------- -----------+-----------
byteain | byteain byteain | byteain
byteale | byteale byteale | byteale
bytealike | bytealike bytealike | bytealike
bytealt | bytealt bytealt | bytealt
byteane | byteane byteane | byteane
(5 rows) (5 rows)
test=# select * from dblink_fetch('foo', 5) as (funcname name, source text); SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
funcname | source funcname | source
------------+------------ ------------+------------
byteanlike | byteanlike byteanlike | byteanlike
byteaout | byteaout byteaout | byteaout
(2 rows) (2 rows)
test=# select * from dblink_fetch('foo', 5) as (funcname name, source text); SELECT * FROM dblink_fetch('foo', 5) AS (funcname name, source text);
funcname | source funcname | source
----------+-------- ----------+--------
(0 rows) (0 rows)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -940,10 +940,10 @@ SELECT * ...@@ -940,10 +940,10 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_close(text cursorname [, bool fail_on_error]) returns text dblink_close(text cursorname [, bool fail_on_error]) returns text
dblink_close(text connname, text cursorname [, bool fail_on_error]) returns text dblink_close(text connname, text cursorname [, bool fail_on_error]) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1013,25 +1013,25 @@ SELECT * ...@@ -1013,25 +1013,25 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# select dblink_connect('dbname=postgres'); SELECT dblink_connect('dbname=postgres');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
test=# select dblink_open('foo', 'select proname, prosrc from pg_proc'); SELECT dblink_open('foo', 'select proname, prosrc from pg_proc');
dblink_open dblink_open
------------- -------------
OK OK
(1 row) (1 row)
test=# select dblink_close('foo'); SELECT dblink_close('foo');
dblink_close dblink_close
-------------- --------------
OK OK
(1 row) (1 row)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1047,9 +1047,9 @@ SELECT * ...@@ -1047,9 +1047,9 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_get_connections() returns text[] dblink_get_connections() returns text[]
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1070,9 +1070,9 @@ SELECT * ...@@ -1070,9 +1070,9 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <programlisting>
SELECT dblink_get_connections(); SELECT dblink_get_connections();
</programlisting> </programlisting>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1088,9 +1088,9 @@ SELECT * ...@@ -1088,9 +1088,9 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_error_message(text connname) returns text dblink_error_message(text connname) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1129,9 +1129,9 @@ SELECT * ...@@ -1129,9 +1129,9 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <programlisting>
SELECT dblink_error_message('dtest1'); SELECT dblink_error_message('dtest1');
</programlisting> </programlisting>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1147,9 +1147,9 @@ SELECT * ...@@ -1147,9 +1147,9 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_send_query(text connname, text sql) returns int dblink_send_query(text connname, text sql) returns int
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1207,9 +1207,9 @@ SELECT * ...@@ -1207,9 +1207,9 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <programlisting>
SELECT dblink_send_query('dtest1', 'SELECT * FROM foo WHERE f1 &lt; 3'); SELECT dblink_send_query('dtest1', 'SELECT * FROM foo WHERE f1 &lt; 3');
</programlisting> </programlisting>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1225,9 +1225,9 @@ SELECT * ...@@ -1225,9 +1225,9 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_is_busy(text connname) returns int dblink_is_busy(text connname) returns int
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1266,9 +1266,9 @@ SELECT * ...@@ -1266,9 +1266,9 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <programlisting>
SELECT dblink_is_busy('dtest1'); SELECT dblink_is_busy('dtest1');
</programlisting> </programlisting>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1284,10 +1284,10 @@ SELECT * ...@@ -1284,10 +1284,10 @@ SELECT *
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_get_notify() returns setof (notify_name text, be_pid int, extra text) dblink_get_notify() returns setof (notify_name text, be_pid int, extra text)
dblink_get_notify(text connname) returns setof (notify_name text, be_pid int, extra text) dblink_get_notify(text connname) returns setof (notify_name text, be_pid int, extra text)
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1326,19 +1326,19 @@ SELECT * ...@@ -1326,19 +1326,19 @@ SELECT *
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# SELECT dblink_exec('LISTEN virtual'); SELECT dblink_exec('LISTEN virtual');
dblink_exec dblink_exec
------------- -------------
LISTEN LISTEN
(1 row) (1 row)
test=# SELECT * FROM dblink_get_notify(); SELECT * FROM dblink_get_notify();
notify_name | be_pid | extra notify_name | be_pid | extra
-------------+--------+------- -------------+--------+-------
(0 rows) (0 rows)
test=# NOTIFY virtual; NOTIFY virtual;
NOTIFY NOTIFY
SELECT * FROM dblink_get_notify(); SELECT * FROM dblink_get_notify();
...@@ -1346,7 +1346,7 @@ SELECT * FROM dblink_get_notify(); ...@@ -1346,7 +1346,7 @@ SELECT * FROM dblink_get_notify();
-------------+--------+------- -------------+--------+-------
virtual | 1229 | virtual | 1229 |
(1 row) (1 row)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1362,9 +1362,9 @@ SELECT * FROM dblink_get_notify(); ...@@ -1362,9 +1362,9 @@ SELECT * FROM dblink_get_notify();
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_get_result(text connname [, bool fail_on_error]) returns setof record dblink_get_result(text connname [, bool fail_on_error]) returns setof record
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1439,62 +1439,62 @@ SELECT * FROM dblink_get_notify(); ...@@ -1439,62 +1439,62 @@ SELECT * FROM dblink_get_notify();
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
contrib_regression=# SELECT dblink_connect('dtest1', 'dbname=contrib_regression'); contrib_regression=# SELECT dblink_connect('dtest1', 'dbname=contrib_regression');
dblink_connect dblink_connect
---------------- ----------------
OK OK
(1 row) (1 row)
contrib_regression=# SELECT * from contrib_regression=# SELECT * FROM
contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 &lt; 3') as t1; contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 &lt; 3') AS t1;
t1 t1
---- ----
1 1
(1 row) (1 row)
contrib_regression=# SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]); contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
f1 | f2 | f3 f1 | f2 | f3
----+----+------------ ----+----+------------
0 | a | {a0,b0,c0} 0 | a | {a0,b0,c0}
1 | b | {a1,b1,c1} 1 | b | {a1,b1,c1}
2 | c | {a2,b2,c2} 2 | c | {a2,b2,c2}
(3 rows) (3 rows)
contrib_regression=# SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]); contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
f1 | f2 | f3 f1 | f2 | f3
----+----+---- ----+----+----
(0 rows) (0 rows)
contrib_regression=# SELECT * from contrib_regression=# SELECT * FROM
dblink_send_query('dtest1', 'select * from foo where f1 &lt; 3; select * from foo where f1 &gt; 6') as t1; contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 &lt; 3; select * from foo where f1 &gt; 6') AS t1;
t1 t1
---- ----
1 1
(1 row) (1 row)
contrib_regression=# SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]); contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
f1 | f2 | f3 f1 | f2 | f3
----+----+------------ ----+----+------------
0 | a | {a0,b0,c0} 0 | a | {a0,b0,c0}
1 | b | {a1,b1,c1} 1 | b | {a1,b1,c1}
2 | c | {a2,b2,c2} 2 | c | {a2,b2,c2}
(3 rows) (3 rows)
contrib_regression=# SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]); contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
f1 | f2 | f3 f1 | f2 | f3
----+----+--------------- ----+----+---------------
7 | h | {a7,b7,c7} 7 | h | {a7,b7,c7}
8 | i | {a8,b8,c8} 8 | i | {a8,b8,c8}
9 | j | {a9,b9,c9} 9 | j | {a9,b9,c9}
10 | k | {a10,b10,c10} 10 | k | {a10,b10,c10}
(4 rows) (4 rows)
contrib_regression=# SELECT * from dblink_get_result('dtest1') as t1(f1 int, f2 text, f3 text[]); contrib_regression=# SELECT * FROM dblink_get_result('dtest1') AS t1(f1 int, f2 text, f3 text[]);
f1 | f2 | f3 f1 | f2 | f3
----+----+---- ----+----+----
(0 rows) (0 rows)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1510,9 +1510,9 @@ SELECT * FROM dblink_get_notify(); ...@@ -1510,9 +1510,9 @@ SELECT * FROM dblink_get_notify();
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_cancel_query(text connname) returns text dblink_cancel_query(text connname) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1556,9 +1556,9 @@ SELECT * FROM dblink_get_notify(); ...@@ -1556,9 +1556,9 @@ SELECT * FROM dblink_get_notify();
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <programlisting>
SELECT dblink_cancel_query('dtest1'); SELECT dblink_cancel_query('dtest1');
</programlisting> </programlisting>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1576,9 +1576,9 @@ SELECT * FROM dblink_get_notify(); ...@@ -1576,9 +1576,9 @@ SELECT * FROM dblink_get_notify();
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_get_pkey(text relname) returns setof dblink_pkey_results dblink_get_pkey(text relname) returns setof dblink_pkey_results
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1617,9 +1617,9 @@ SELECT * FROM dblink_get_notify(); ...@@ -1617,9 +1617,9 @@ SELECT * FROM dblink_get_notify();
Returns one row for each primary key field, or no rows if the relation Returns one row for each primary key field, or no rows if the relation
has no primary key. The result rowtype is defined as has no primary key. The result rowtype is defined as
<programlisting> <programlisting>
CREATE TYPE dblink_pkey_results AS (position int, colname text); CREATE TYPE dblink_pkey_results AS (position int, colname text);
</programlisting> </programlisting>
The <literal>position</> column simply runs from 1 to <replaceable>N</>; The <literal>position</> column simply runs from 1 to <replaceable>N</>;
it is the number of the field within the primary key, not the number it is the number of the field within the primary key, not the number
...@@ -1630,18 +1630,23 @@ CREATE TYPE dblink_pkey_results AS (position int, colname text); ...@@ -1630,18 +1630,23 @@ CREATE TYPE dblink_pkey_results AS (position int, colname text);
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# create table foobar(f1 int, f2 int, f3 int, CREATE TABLE foobar (
test(# primary key(f1,f2,f3)); f1 int,
f2 int,
f3 int,
PRIMARY KEY (f1, f2, f3)
);
CREATE TABLE CREATE TABLE
test=# select * from dblink_get_pkey('foobar');
SELECT * FROM dblink_get_pkey('foobar');
position | colname position | colname
----------+--------- ----------+---------
1 | f1 1 | f1
2 | f2 2 | f2
3 | f3 3 | f3
(3 rows) (3 rows)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1660,13 +1665,13 @@ test=# select * from dblink_get_pkey('foobar'); ...@@ -1660,13 +1665,13 @@ test=# select * from dblink_get_pkey('foobar');
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_build_sql_insert(text relname, dblink_build_sql_insert(text relname,
int2vector primary_key_attnums, int2vector primary_key_attnums,
integer num_primary_key_atts, integer num_primary_key_atts,
text[] src_pk_att_vals_array, text[] src_pk_att_vals_array,
text[] tgt_pk_att_vals_array) returns text text[] tgt_pk_att_vals_array) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1766,13 +1771,13 @@ test=# select * from dblink_get_pkey('foobar'); ...@@ -1766,13 +1771,13 @@ test=# select * from dblink_get_pkey('foobar');
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# select dblink_build_sql_insert('foo', '1 2', 2, '{"1", "a"}', '{"1", "b''a"}'); SELECT dblink_build_sql_insert('foo', '1 2', 2, '{"1", "a"}', '{"1", "b''a"}');
dblink_build_sql_insert dblink_build_sql_insert
-------------------------------------------------- --------------------------------------------------
INSERT INTO foo(f1,f2,f3) VALUES('1','b''a','1') INSERT INTO foo(f1,f2,f3) VALUES('1','b''a','1')
(1 row) (1 row)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1790,12 +1795,12 @@ test=# select * from dblink_get_pkey('foobar'); ...@@ -1790,12 +1795,12 @@ test=# select * from dblink_get_pkey('foobar');
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_build_sql_delete(text relname, dblink_build_sql_delete(text relname,
int2vector primary_key_attnums, int2vector primary_key_attnums,
integer num_primary_key_atts, integer num_primary_key_atts,
text[] tgt_pk_att_vals_array) returns text text[] tgt_pk_att_vals_array) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -1880,13 +1885,13 @@ test=# select * from dblink_get_pkey('foobar'); ...@@ -1880,13 +1885,13 @@ test=# select * from dblink_get_pkey('foobar');
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# select dblink_build_sql_delete('"MyFoo"', '1 2', 2, '{"1", "b"}'); SELECT dblink_build_sql_delete('"MyFoo"', '1 2', 2, '{"1", "b"}');
dblink_build_sql_delete dblink_build_sql_delete
--------------------------------------------- ---------------------------------------------
DELETE FROM "MyFoo" WHERE f1='1' AND f2='b' DELETE FROM "MyFoo" WHERE f1='1' AND f2='b'
(1 row) (1 row)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
...@@ -1904,13 +1909,13 @@ test=# select * from dblink_get_pkey('foobar'); ...@@ -1904,13 +1909,13 @@ test=# select * from dblink_get_pkey('foobar');
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
dblink_build_sql_update(text relname, dblink_build_sql_update(text relname,
int2vector primary_key_attnums, int2vector primary_key_attnums,
integer num_primary_key_atts, integer num_primary_key_atts,
text[] src_pk_att_vals_array, text[] src_pk_att_vals_array,
text[] tgt_pk_att_vals_array) returns text text[] tgt_pk_att_vals_array) returns text
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -2013,13 +2018,13 @@ test=# select * from dblink_get_pkey('foobar'); ...@@ -2013,13 +2018,13 @@ test=# select * from dblink_get_pkey('foobar');
<refsect1> <refsect1>
<title>Example</title> <title>Example</title>
<programlisting> <screen>
test=# select dblink_build_sql_update('foo', '1 2', 2, '{"1", "a"}', '{"1", "b"}'); SELECT dblink_build_sql_update('foo', '1 2', 2, '{"1", "a"}', '{"1", "b"}');
dblink_build_sql_update dblink_build_sql_update
------------------------------------------------------------- -------------------------------------------------------------
UPDATE foo SET f1='1',f2='b',f3='1' WHERE f1='1' AND f2='b' UPDATE foo SET f1='1',f2='b',f3='1' WHERE f1='1' AND f2='b'
(1 row) (1 row)
</programlisting> </screen>
</refsect1> </refsect1>
</refentry> </refentry>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.93 2010/04/06 02:18:04 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.94 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="ddl"> <chapter id="ddl">
<title>Data Definition</title> <title>Data Definition</title>
...@@ -2520,7 +2520,7 @@ CREATE TABLE measurement_y2008m01 ( ) INHERITS (measurement); ...@@ -2520,7 +2520,7 @@ CREATE TABLE measurement_y2008m01 ( ) INHERITS (measurement);
just creating the partition tables as above, the table creation just creating the partition tables as above, the table creation
script should really be: script should really be:
<programlisting> <programlisting>
CREATE TABLE measurement_y2006m02 ( CREATE TABLE measurement_y2006m02 (
CHECK ( logdate &gt;= DATE '2006-02-01' AND logdate &lt; DATE '2006-03-01' ) CHECK ( logdate &gt;= DATE '2006-02-01' AND logdate &lt; DATE '2006-03-01' )
) INHERITS (measurement); ) INHERITS (measurement);
...@@ -2545,7 +2545,7 @@ CREATE TABLE measurement_y2008m01 ( ...@@ -2545,7 +2545,7 @@ CREATE TABLE measurement_y2008m01 (
<para> <para>
We probably need indexes on the key columns too: We probably need indexes on the key columns too:
<programlisting> <programlisting>
CREATE INDEX measurement_y2006m02_logdate ON measurement_y2006m02 (logdate); CREATE INDEX measurement_y2006m02_logdate ON measurement_y2006m02 (logdate);
CREATE INDEX measurement_y2006m03_logdate ON measurement_y2006m03 (logdate); CREATE INDEX measurement_y2006m03_logdate ON measurement_y2006m03 (logdate);
... ...
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/dict-xsyn.sgml,v 1.3 2009/08/05 18:06:49 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/dict-xsyn.sgml,v 1.4 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="dict-xsyn"> <sect1 id="dict-xsyn">
<title>dict_xsyn</title> <title>dict_xsyn</title>
...@@ -64,9 +64,9 @@ ...@@ -64,9 +64,9 @@
<para> <para>
Each line represents a group of synonyms for a single word, which is Each line represents a group of synonyms for a single word, which is
given first on the line. Synonyms are separated by whitespace, thus: given first on the line. Synonyms are separated by whitespace, thus:
<programlisting> <programlisting>
word syn1 syn2 syn3 word syn1 syn2 syn3
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
<listitem> <listitem>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/ecpg.sgml,v 1.100 2010/05/13 14:16:41 mha Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/ecpg.sgml,v 1.101 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="ecpg"> <chapter id="ecpg">
<title><application>ECPG</application> - Embedded <acronym>SQL</acronym> in C</title> <title><application>ECPG</application> - Embedded <acronym>SQL</acronym> in C</title>
...@@ -2857,11 +2857,11 @@ struct sqlname ...@@ -2857,11 +2857,11 @@ struct sqlname
the dollar sign instead of the <literal>EXEC SQL</> primitive to introduce the dollar sign instead of the <literal>EXEC SQL</> primitive to introduce
embedded SQL commands.: embedded SQL commands.:
<programlisting> <programlisting>
$int j = 3; $int j = 3;
$CONNECT TO :dbname; $CONNECT TO :dbname;
$CREATE TABLE test(i INT PRIMARY KEY, j INT); $CREATE TABLE test(i INT PRIMARY KEY, j INT);
$INSERT INTO test(i, j) VALUES (7, :j); $INSERT INTO test(i, j) VALUES (7, :j);
$COMMIT; $COMMIT;
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -2898,11 +2898,11 @@ struct sqlname ...@@ -2898,11 +2898,11 @@ struct sqlname
supported in Informix-mode without using <literal>typedef</literal>. In fact, in Informix-mode, supported in Informix-mode without using <literal>typedef</literal>. In fact, in Informix-mode,
ECPG refuses to process source files that contain <literal>typedef sometype string;</literal> ECPG refuses to process source files that contain <literal>typedef sometype string;</literal>
<programlisting> <programlisting>
EXEC SQL BEGIN DECLARE SECTION; EXEC SQL BEGIN DECLARE SECTION;
string userid; /* this variable will contain trimmed data */ string userid; /* this variable will contain trimmed data */
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;
EXEC SQL FETCH MYCUR INTO :userid; EXEC SQL FETCH MYCUR INTO :userid;
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
...@@ -2918,8 +2918,8 @@ struct sqlname ...@@ -2918,8 +2918,8 @@ struct sqlname
This statement closes the current connection. In fact, this is a This statement closes the current connection. In fact, this is a
synonym for ecpg's <literal>DISCONNECT CURRENT</>.: synonym for ecpg's <literal>DISCONNECT CURRENT</>.:
<programlisting> <programlisting>
$CLOSE DATABASE; /* close the current connection */ $CLOSE DATABASE; /* close the current connection */
EXEC SQL CLOSE DATABASE; EXEC SQL CLOSE DATABASE;
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
...@@ -3083,15 +3083,15 @@ typedef struct sqlda_compat sqlda_t; ...@@ -3083,15 +3083,15 @@ typedef struct sqlda_compat sqlda_t;
Pointer to the field data. The pointer is of <literal>char *</literal> type, Pointer to the field data. The pointer is of <literal>char *</literal> type,
the data pointed by it is in a binary format. Example: the data pointed by it is in a binary format. Example:
<programlisting> <programlisting>
int intval; int intval;
switch (sqldata->sqlvar[i].sqltype) switch (sqldata->sqlvar[i].sqltype)
{ {
case SQLINTEGER: case SQLINTEGER:
intval = *(int *)sqldata->sqlvar[i].sqldata; intval = *(int *)sqldata->sqlvar[i].sqldata;
break; break;
... ...
} }
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
...@@ -3106,7 +3106,7 @@ typedef struct sqlda_compat sqlda_t; ...@@ -3106,7 +3106,7 @@ typedef struct sqlda_compat sqlda_t;
that the value for this field is non-NULL. Otherwise a valid pointer and <literal>sqlitype</literal> that the value for this field is non-NULL. Otherwise a valid pointer and <literal>sqlitype</literal>
has to be properly set. Example: has to be properly set. Example:
<programlisting> <programlisting>
if (*(int2 *)sqldata->sqlvar[i].sqlind != 0) if (*(int2 *)sqldata->sqlvar[i].sqlind != 0)
printf("value is NULL\n"); printf("value is NULL\n");
</programlisting> </programlisting>
</para> </para>
...@@ -5208,13 +5208,13 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER; ...@@ -5208,13 +5208,13 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER;
<para> <para>
Example: Example:
<programlisting> <programlisting>
exec sql ifndef TZVAR; EXEC SQL ifndef TZVAR;
exec sql SET TIMEZONE TO 'GMT'; EXEC SQL SET TIMEZONE TO 'GMT';
exec sql elif TZNAME; EXEC SQL elif TZNAME;
exec sql SET TIMEZONE TO TZNAME; EXEC SQL SET TIMEZONE TO TZNAME;
exec sql else; EXEC SQL else;
exec sql SET TIMEZONE TO TZVAR; EXEC SQL SET TIMEZONE TO TZVAR;
exec sql endif; EXEC SQL endif;
</programlisting> </programlisting>
</para> </para>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.521 2010/07/03 17:21:48 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.522 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="functions"> <chapter id="functions">
<title>Functions and Operators</title> <title>Functions and Operators</title>
...@@ -8228,9 +8228,9 @@ SELECT xmlcomment('hello'); ...@@ -8228,9 +8228,9 @@ SELECT xmlcomment('hello');
<primary>xmlconcat</primary> <primary>xmlconcat</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
<function>xmlconcat</function>(<replaceable>xml</replaceable><optional>, ...</optional>) <function>xmlconcat</function>(<replaceable>xml</replaceable><optional>, ...</optional>)
</synopsis> </synopsis>
<para> <para>
The function <function>xmlconcat</function> concatenates a list The function <function>xmlconcat</function> concatenates a list
...@@ -8286,8 +8286,8 @@ SELECT xmlconcat('<?xml version="1.1"?><foo/>', '<?xml version="1.1" standalone= ...@@ -8286,8 +8286,8 @@ SELECT xmlconcat('<?xml version="1.1"?><foo/>', '<?xml version="1.1" standalone=
</indexterm> </indexterm>
<synopsis> <synopsis>
<function>xmlelement</function>(name <replaceable>name</replaceable> <optional>, xmlattributes(<replaceable>value</replaceable> <optional>AS <replaceable>attname</replaceable></optional> <optional>, ... </optional>)</optional> <optional><replaceable>, content, ...</replaceable></optional>) <function>xmlelement</function>(name <replaceable>name</replaceable> <optional>, xmlattributes(<replaceable>value</replaceable> <optional>AS <replaceable>attname</replaceable></optional> <optional>, ... </optional>)</optional> <optional><replaceable>, content, ...</replaceable></optional>)
</synopsis> </synopsis>
<para> <para>
The <function>xmlelement</function> expression produces an XML The <function>xmlelement</function> expression produces an XML
...@@ -8383,9 +8383,9 @@ SELECT xmlelement(name foo, xmlattributes('xyz' as bar), ...@@ -8383,9 +8383,9 @@ SELECT xmlelement(name foo, xmlattributes('xyz' as bar),
<primary>xmlforest</primary> <primary>xmlforest</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
<function>xmlforest</function>(<replaceable>content</replaceable> <optional>AS <replaceable>name</replaceable></optional> <optional>, ...</optional>) <function>xmlforest</function>(<replaceable>content</replaceable> <optional>AS <replaceable>name</replaceable></optional> <optional>, ...</optional>)
</synopsis> </synopsis>
<para> <para>
The <function>xmlforest</function> expression produces an XML The <function>xmlforest</function> expression produces an XML
...@@ -8440,9 +8440,9 @@ WHERE table_schema = 'pg_catalog'; ...@@ -8440,9 +8440,9 @@ WHERE table_schema = 'pg_catalog';
<primary>xmlpi</primary> <primary>xmlpi</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
<function>xmlpi</function>(name <replaceable>target</replaceable> <optional>, <replaceable>content</replaceable></optional>) <function>xmlpi</function>(name <replaceable>target</replaceable> <optional>, <replaceable>content</replaceable></optional>)
</synopsis> </synopsis>
<para> <para>
The <function>xmlpi</function> expression creates an XML The <function>xmlpi</function> expression creates an XML
...@@ -8469,9 +8469,9 @@ SELECT xmlpi(name php, 'echo "hello world";'); ...@@ -8469,9 +8469,9 @@ SELECT xmlpi(name php, 'echo "hello world";');
<primary>xmlroot</primary> <primary>xmlroot</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
<function>xmlroot</function>(<replaceable>xml</replaceable>, version <replaceable>text</replaceable> | no value <optional>, standalone yes|no|no value</optional>) <function>xmlroot</function>(<replaceable>xml</replaceable>, version <replaceable>text</replaceable> | no value <optional>, standalone yes|no|no value</optional>)
</synopsis> </synopsis>
<para> <para>
The <function>xmlroot</function> expression alters the properties The <function>xmlroot</function> expression alters the properties
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/fuzzystrmatch.sgml,v 1.5 2009/04/06 15:43:00 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/fuzzystrmatch.sgml,v 1.6 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="fuzzystrmatch"> <sect1 id="fuzzystrmatch">
<title>fuzzystrmatch</title> <title>fuzzystrmatch</title>
...@@ -34,10 +34,10 @@ ...@@ -34,10 +34,10 @@
for working with Soundex codes: for working with Soundex codes:
</para> </para>
<programlisting> <synopsis>
soundex(text) returns text soundex(text) returns text
difference(text, text) returns int difference(text, text) returns int
</programlisting> </synopsis>
<para> <para>
The <function>soundex</> function converts a string to its Soundex code. The <function>soundex</> function converts a string to its Soundex code.
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
Here are some usage examples: Here are some usage examples:
</para> </para>
<programlisting> <programlisting>
SELECT soundex('hello world!'); SELECT soundex('hello world!');
SELECT soundex('Anne'), soundex('Ann'), difference('Anne', 'Ann'); SELECT soundex('Anne'), soundex('Ann'), difference('Anne', 'Ann');
...@@ -70,7 +70,7 @@ INSERT INTO s VALUES ('jack'); ...@@ -70,7 +70,7 @@ INSERT INTO s VALUES ('jack');
SELECT * FROM s WHERE soundex(nm) = soundex('john'); SELECT * FROM s WHERE soundex(nm) = soundex('john');
SELECT * FROM s WHERE difference(s.nm, 'john') &gt; 2; SELECT * FROM s WHERE difference(s.nm, 'john') &gt; 2;
</programlisting> </programlisting>
</sect2> </sect2>
<sect2> <sect2>
...@@ -80,10 +80,10 @@ SELECT * FROM s WHERE difference(s.nm, 'john') &gt; 2; ...@@ -80,10 +80,10 @@ SELECT * FROM s WHERE difference(s.nm, 'john') &gt; 2;
This function calculates the Levenshtein distance between two strings: This function calculates the Levenshtein distance between two strings:
</para> </para>
<programlisting> <synopsis>
levenshtein(text source, text target, int ins_cost, int del_cost, int sub_cost) returns int levenshtein(text source, text target, int ins_cost, int del_cost, int sub_cost) returns int
levenshtein(text source, text target) returns int levenshtein(text source, text target) returns int
</programlisting> </synopsis>
<para> <para>
Both <literal>source</literal> and <literal>target</literal> can be any Both <literal>source</literal> and <literal>target</literal> can be any
...@@ -97,7 +97,7 @@ SELECT * FROM s WHERE difference(s.nm, 'john') &gt; 2; ...@@ -97,7 +97,7 @@ SELECT * FROM s WHERE difference(s.nm, 'john') &gt; 2;
Examples: Examples:
</para> </para>
<programlisting> <screen>
test=# SELECT levenshtein('GUMBO', 'GAMBOL'); test=# SELECT levenshtein('GUMBO', 'GAMBOL');
levenshtein levenshtein
------------- -------------
...@@ -109,7 +109,7 @@ test=# SELECT levenshtein('GUMBO', 'GAMBOL', 2,1,1); ...@@ -109,7 +109,7 @@ test=# SELECT levenshtein('GUMBO', 'GAMBOL', 2,1,1);
------------- -------------
3 3
(1 row) (1 row)
</programlisting> </screen>
</sect2> </sect2>
<sect2> <sect2>
...@@ -125,9 +125,9 @@ test=# SELECT levenshtein('GUMBO', 'GAMBOL', 2,1,1); ...@@ -125,9 +125,9 @@ test=# SELECT levenshtein('GUMBO', 'GAMBOL', 2,1,1);
This function calculates the metaphone code of an input string: This function calculates the metaphone code of an input string:
</para> </para>
<programlisting> <synopsis>
metaphone(text source, int max_output_length) returns text metaphone(text source, int max_output_length) returns text
</programlisting> </synopsis>
<para> <para>
<literal>source</literal> has to be a non-null string with a maximum of <literal>source</literal> has to be a non-null string with a maximum of
...@@ -140,13 +140,13 @@ test=# SELECT levenshtein('GUMBO', 'GAMBOL', 2,1,1); ...@@ -140,13 +140,13 @@ test=# SELECT levenshtein('GUMBO', 'GAMBOL', 2,1,1);
Example: Example:
</para> </para>
<programlisting> <screen>
test=# SELECT metaphone('GUMBO', 4); test=# SELECT metaphone('GUMBO', 4);
metaphone metaphone
----------- -----------
KM KM
(1 row) (1 row)
</programlisting> </screen>
</sect2> </sect2>
<sect2> <sect2>
...@@ -160,10 +160,10 @@ test=# SELECT metaphone('GUMBO', 4); ...@@ -160,10 +160,10 @@ test=# SELECT metaphone('GUMBO', 4);
These functions compute the primary and alternate codes: These functions compute the primary and alternate codes:
</para> </para>
<programlisting> <synopsis>
dmetaphone(text source) returns text dmetaphone(text source) returns text
dmetaphone_alt(text source) returns text dmetaphone_alt(text source) returns text
</programlisting> </synopsis>
<para> <para>
There is no length limit on the input strings. There is no length limit on the input strings.
...@@ -173,13 +173,13 @@ test=# SELECT metaphone('GUMBO', 4); ...@@ -173,13 +173,13 @@ test=# SELECT metaphone('GUMBO', 4);
Example: Example:
</para> </para>
<programlisting> <screen>
test=# select dmetaphone('gumbo'); test=# select dmetaphone('gumbo');
dmetaphone dmetaphone
------------ ------------
KMP KMP
(1 row) (1 row)
</programlisting> </screen>
</sect2> </sect2>
</sect1> </sect1>
<!-- $PostgreSQL: pgsql/doc/src/sgml/hstore.sgml,v 1.12 2010/07/02 20:36:49 rhaas Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/hstore.sgml,v 1.13 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="hstore"> <sect1 id="hstore">
<title>hstore</title> <title>hstore</title>
...@@ -24,11 +24,11 @@ ...@@ -24,11 +24,11 @@
includes zero or more <replaceable>key</> <literal>=&gt;</> includes zero or more <replaceable>key</> <literal>=&gt;</>
<replaceable>value</> pairs separated by commas. Some examples: <replaceable>value</> pairs separated by commas. Some examples:
<programlisting> <synopsis>
k =&gt; v k =&gt; v
foo =&gt; bar, baz =&gt; whatever foo =&gt; bar, baz =&gt; whatever
"1-a" =&gt; "anything at all" "1-a" =&gt; "anything at all"
</programlisting> </synopsis>
The order of the pairs is not significant (and may not be reproduced on The order of the pairs is not significant (and may not be reproduced on
output). Whitespace between pairs or around the <literal>=&gt;</> sign is output). Whitespace between pairs or around the <literal>=&gt;</> sign is
...@@ -42,23 +42,23 @@ ...@@ -42,23 +42,23 @@
with duplicate keys, only one will be stored in the <type>hstore</> and with duplicate keys, only one will be stored in the <type>hstore</> and
there is no guarantee as to which will be kept: there is no guarantee as to which will be kept:
<programlisting> <programlisting>
% select 'a=&gt;1,a=&gt;2'::hstore; SELECT 'a=&gt;1,a=&gt;2'::hstore;
hstore hstore
---------- ----------
"a"=&gt;"1" "a"=&gt;"1"
</programlisting> </programlisting>
</para> </para>
<para> <para>
A value (but not a key) can be an SQL <literal>NULL</>. For example: A value (but not a key) can be an SQL <literal>NULL</>. For example:
<programlisting> <programlisting>
key =&gt; NULL key =&gt; NULL
</programlisting> </programlisting>
The <literal>NULL</> keyword is case-insensitive. Double-quote the The <literal>NULL</> keyword is case-insensitive. Double-quote the
<literal>NULL</> to treat it as the ordinary string "NULL". <literal>NULL</> to treat it as the ordinary string <quote>NULL</quote>.
</para> </para>
<note> <note>
...@@ -421,11 +421,11 @@ b ...@@ -421,11 +421,11 @@ b
<type>hstore</> has GiST and GIN index support for the <literal>@&gt;</>, <type>hstore</> has GiST and GIN index support for the <literal>@&gt;</>,
<literal>?</>, <literal>?&amp;</> and <literal>?|</> operators. For example: <literal>?</>, <literal>?&amp;</> and <literal>?|</> operators. For example:
</para> </para>
<programlisting> <programlisting>
CREATE INDEX hidx ON testhstore USING GIST (h); CREATE INDEX hidx ON testhstore USING GIST (h);
CREATE INDEX hidx ON testhstore USING GIN (h); CREATE INDEX hidx ON testhstore USING GIN (h);
</programlisting> </programlisting>
<para> <para>
<type>hstore</> also supports <type>btree</> or <type>hash</> indexes for <type>hstore</> also supports <type>btree</> or <type>hash</> indexes for
...@@ -436,11 +436,11 @@ CREATE INDEX hidx ON testhstore USING GIN (h); ...@@ -436,11 +436,11 @@ CREATE INDEX hidx ON testhstore USING GIN (h);
may be useful for equivalence lookups. Create indexes for <literal>=</> may be useful for equivalence lookups. Create indexes for <literal>=</>
comparisons as follows: comparisons as follows:
</para> </para>
<programlisting> <programlisting>
CREATE INDEX hidx ON testhstore USING BTREE (h); CREATE INDEX hidx ON testhstore USING BTREE (h);
CREATE INDEX hidx ON testhstore USING HASH (h); CREATE INDEX hidx ON testhstore USING HASH (h);
</programlisting> </programlisting>
</sect2> </sect2>
<sect2> <sect2>
...@@ -448,22 +448,21 @@ CREATE INDEX hidx ON testhstore USING HASH (h); ...@@ -448,22 +448,21 @@ CREATE INDEX hidx ON testhstore USING HASH (h);
<para> <para>
Add a key, or update an existing key with a new value: Add a key, or update an existing key with a new value:
</para> <programlisting>
<programlisting>
UPDATE tab SET h = h || ('c' =&gt; '3'); UPDATE tab SET h = h || ('c' =&gt; '3');
</programlisting> </programlisting>
</para>
<para> <para>
Delete a key: Delete a key:
</para> <programlisting>
<programlisting>
UPDATE tab SET h = delete(h, 'k1'); UPDATE tab SET h = delete(h, 'k1');
</programlisting> </programlisting>
</para>
<para> <para>
Convert a <type>record</> to an <type>hstore</>: Convert a <type>record</> to an <type>hstore</>:
</para> <programlisting>
<programlisting>
CREATE TABLE test (col1 integer, col2 text, col3 text); CREATE TABLE test (col1 integer, col2 text, col3 text);
INSERT INTO test VALUES (123, 'foo', 'bar'); INSERT INTO test VALUES (123, 'foo', 'bar');
...@@ -472,12 +471,12 @@ SELECT hstore(t) FROM test AS t; ...@@ -472,12 +471,12 @@ SELECT hstore(t) FROM test AS t;
--------------------------------------------- ---------------------------------------------
"col1"=&gt;"123", "col2"=&gt;"foo", "col3"=&gt;"bar" "col1"=&gt;"123", "col2"=&gt;"foo", "col3"=&gt;"bar"
(1 row) (1 row)
</programlisting> </programlisting>
</para>
<para> <para>
Convert an <type>hstore</> to a predefined <type>record</> type: Convert an <type>hstore</> to a predefined <type>record</> type:
</para> <programlisting>
<programlisting>
CREATE TABLE test (col1 integer, col2 text, col3 text); CREATE TABLE test (col1 integer, col2 text, col3 text);
SELECT * FROM populate_record(null::test, SELECT * FROM populate_record(null::test,
...@@ -486,12 +485,12 @@ SELECT * FROM populate_record(null::test, ...@@ -486,12 +485,12 @@ SELECT * FROM populate_record(null::test,
------+------+------ ------+------+------
456 | zzz | 456 | zzz |
(1 row) (1 row)
</programlisting> </programlisting>
</para>
<para> <para>
Modify an existing record using the values from an <type>hstore</>: Modify an existing record using the values from an <type>hstore</>:
</para> <programlisting>
<programlisting>
CREATE TABLE test (col1 integer, col2 text, col3 text); CREATE TABLE test (col1 integer, col2 text, col3 text);
INSERT INTO test VALUES (123, 'foo', 'bar'); INSERT INTO test VALUES (123, 'foo', 'bar');
...@@ -500,7 +499,8 @@ SELECT (r).* FROM (SELECT t #= '"col3"=&gt;"baz"' AS r FROM test t) s; ...@@ -500,7 +499,8 @@ SELECT (r).* FROM (SELECT t #= '"col3"=&gt;"baz"' AS r FROM test t) s;
------+------+------ ------+------+------
123 | foo | baz 123 | foo | baz
(1 row) (1 row)
</programlisting> </programlisting>
</para>
</sect2> </sect2>
<sect2> <sect2>
...@@ -515,22 +515,21 @@ SELECT (r).* FROM (SELECT t #= '"col3"=&gt;"baz"' AS r FROM test t) s; ...@@ -515,22 +515,21 @@ SELECT (r).* FROM (SELECT t #= '"col3"=&gt;"baz"' AS r FROM test t) s;
<para> <para>
Simple example: Simple example:
</para> <programlisting>
<programlisting>
SELECT * FROM each('aaa=&gt;bq, b=&gt;NULL, ""=&gt;1'); SELECT * FROM each('aaa=&gt;bq, b=&gt;NULL, ""=&gt;1');
</programlisting> </programlisting>
</para>
<para> <para>
Using a table: Using a table:
</para> <programlisting>
<programlisting>
SELECT (each(h)).key, (each(h)).value INTO stat FROM testhstore; SELECT (each(h)).key, (each(h)).value INTO stat FROM testhstore;
</programlisting> </programlisting>
</para>
<para> <para>
Online statistics: Online statistics:
</para> <programlisting>
<programlisting>
SELECT key, count(*) FROM SELECT key, count(*) FROM
(SELECT (each(h)).key FROM testhstore) AS stat (SELECT (each(h)).key FROM testhstore) AS stat
GROUP BY key GROUP BY key
...@@ -547,7 +546,8 @@ SELECT key, count(*) FROM ...@@ -547,7 +546,8 @@ SELECT key, count(*) FROM
title | 190 title | 190
org | 189 org | 189
................... ...................
</programlisting> </programlisting>
</para>
</sect2> </sect2>
<sect2> <sect2>
...@@ -572,16 +572,16 @@ SELECT key, count(*) FROM ...@@ -572,16 +572,16 @@ SELECT key, count(*) FROM
performance penalty when processing data that has not yet been modified by performance penalty when processing data that has not yet been modified by
the new code. It is possible to force an upgrade of all values in a table the new code. It is possible to force an upgrade of all values in a table
column by doing an <literal>UPDATE</> statement as follows: column by doing an <literal>UPDATE</> statement as follows:
</para> <programlisting>
<programlisting>
UPDATE tablename SET hstorecol = hstorecol || ''; UPDATE tablename SET hstorecol = hstorecol || '';
</programlisting> </programlisting>
</para>
<para> <para>
Another way to do it is: Another way to do it is:
<programlisting> <programlisting>
ALTER TABLE tablename ALTER hstorecol TYPE hstore USING hstorecol || ''; ALTER TABLE tablename ALTER hstorecol TYPE hstore USING hstorecol || '';
</programlisting> </programlisting>
The <command>ALTER TABLE</> method requires an exclusive lock on the table, The <command>ALTER TABLE</> method requires an exclusive lock on the table,
but does not result in bloating the table with old row versions. but does not result in bloating the table with old row versions.
</para> </para>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/indexam.sgml,v 2.33 2010/02/08 04:33:51 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/indexam.sgml,v 2.34 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="indexam"> <chapter id="indexam">
<title>Index Access Method Interface Definition</title> <title>Index Access Method Interface Definition</title>
...@@ -1027,15 +1027,15 @@ amcostestimate (PlannerInfo *root, ...@@ -1027,15 +1027,15 @@ amcostestimate (PlannerInfo *root,
Compute the index access cost. A generic estimator might do this: Compute the index access cost. A generic estimator might do this:
<programlisting> <programlisting>
/* /*
* Our generic assumption is that the index pages will be read * Our generic assumption is that the index pages will be read
* sequentially, so they cost seq_page_cost each, not random_page_cost. * sequentially, so they cost seq_page_cost each, not random_page_cost.
* Also, we charge for evaluation of the indexquals at each index row. * Also, we charge for evaluation of the indexquals at each index row.
* All the costs are assumed to be paid incrementally during the scan. * All the costs are assumed to be paid incrementally during the scan.
*/ */
cost_qual_eval(&amp;index_qual_cost, indexQuals, root); cost_qual_eval(&amp;index_qual_cost, indexQuals, root);
*indexStartupCost = index_qual_cost.startup; *indexStartupCost = index_qual_cost.startup;
*indexTotalCost = seq_page_cost * numIndexPages + *indexTotalCost = seq_page_cost * numIndexPages +
(cpu_index_tuple_cost + index_qual_cost.per_tuple) * numIndexTuples; (cpu_index_tuple_cost + index_qual_cost.per_tuple) * numIndexTuples;
</programlisting> </programlisting>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.58 2010/07/27 19:01:16 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.59 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="install-win32"> <chapter id="install-win32">
<title>Installation from Source Code on <productname>Windows</productname></title> <title>Installation from Source Code on <productname>Windows</productname></title>
...@@ -102,9 +102,9 @@ ...@@ -102,9 +102,9 @@
and then apply any changes from <filename>config.pl</filename>. For example, and then apply any changes from <filename>config.pl</filename>. For example,
to specify the location of your <productname>Python</productname> installation, to specify the location of your <productname>Python</productname> installation,
put the following in <filename>config.pl</filename>: put the following in <filename>config.pl</filename>:
<screen> <programlisting>
$config->{python} = 'c:\python26'; $config->{python} = 'c:\python26';
</screen> </programlisting>
You only need to specify those parameters that are different from what's in You only need to specify those parameters that are different from what's in
<filename>config_default.pl</filename>. <filename>config_default.pl</filename>.
</para> </para>
...@@ -114,9 +114,9 @@ ...@@ -114,9 +114,9 @@
<filename>buildenv.pl</filename> and put the required commands there. For <filename>buildenv.pl</filename> and put the required commands there. For
example, to add the path for bison when it's not in the PATH, create a file example, to add the path for bison when it's not in the PATH, create a file
containing: containing:
<screen> <programlisting>
$ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin'; $ENV{PATH}=$ENV{PATH} . ';c:\some\where\bison\bin';
</screen> </programlisting>
</para> </para>
<sect2> <sect2>
...@@ -292,43 +292,31 @@ ...@@ -292,43 +292,31 @@
<para> <para>
To build all of PostgreSQL in release configuration (the default), run the To build all of PostgreSQL in release configuration (the default), run the
command: command:
<screen> <screen>
<userinput> <userinput>build</userinput>
build </screen>
</userinput>
</screen>
To build all of PostgreSQL in debug configuration, run the command: To build all of PostgreSQL in debug configuration, run the command:
<screen> <screen>
<userinput> <userinput>build DEBUG</userinput>
build DEBUG </screen>
</userinput>
</screen>
To build just a single project, for example psql, run the commands: To build just a single project, for example psql, run the commands:
<screen> <screen>
<userinput> <userinput>build psql</userinput>
build psql <userinput>build DEBUG psql</userinput>
</userinput> </screen>
<userinput>
build DEBUG psql
</userinput>
</screen>
To change the default build configuration to debug, put the following To change the default build configuration to debug, put the following
in the <filename>buildenv.pl</filename> file: in the <filename>buildenv.pl</filename> file:
<screen> <programlisting>
<userinput> $ENV{CONFIG}="Debug";
$ENV{CONFIG}="Debug"; </programlisting>
</userinput>
</screen>
</para> </para>
<para> <para>
It is also possible to build from inside the Visual Studio GUI. In this It is also possible to build from inside the Visual Studio GUI. In this
case, you need to run: case, you need to run:
<screen> <screen>
<userinput> <userinput>perl mkvcbuild.pl</userinput>
perl mkvcbuild.pl </screen>
</userinput>
</screen>
from the command prompt, and then open the generated from the command prompt, and then open the generated
<filename>pgsql.sln</filename> (in the root directory of the source tree) <filename>pgsql.sln</filename> (in the root directory of the source tree)
in Visual Studio. in Visual Studio.
...@@ -354,11 +342,9 @@ ...@@ -354,11 +342,9 @@
<filename>debug</filename> or <filename>release</filename> directories. To <filename>debug</filename> or <filename>release</filename> directories. To
install these files using the standard layout, and also generate the files install these files using the standard layout, and also generate the files
required to initialize and use the database, run the command: required to initialize and use the database, run the command:
<screen> <screen>
<userinput> <userinput>install c:\destination\directory</userinput>
install c:\destination\directory </screen>
</userinput>
</screen>
</para> </para>
</sect2> </sect2>
...@@ -373,28 +359,18 @@ ...@@ -373,28 +359,18 @@
the <filename>buildenv.pl</filename> file. To run the tests, run one of the <filename>buildenv.pl</filename> file. To run the tests, run one of
the following commands from the <filename>src\tools\msvc</filename> the following commands from the <filename>src\tools\msvc</filename>
directory: directory:
<screen> <screen>
<userinput> <userinput>vcregress check</userinput>
vcregress check <userinput>vcregress installcheck</userinput>
</userinput> <userinput>vcregress plcheck</userinput>
<userinput> <userinput>vcregress contribcheck</userinput>
vcregress installcheck </screen>
</userinput>
<userinput>
vcregress plcheck
</userinput>
<userinput>
vcregress contribcheck
</userinput>
</screen>
To change the schedule used (default is parallel), append it to the To change the schedule used (default is parallel), append it to the
command line like: command line like:
<screen> <screen>
<userinput> <userinput>vcregress check serial</userinput>
vcregress check serial </screen>
</userinput>
</screen>
For more information about the regression tests, see For more information about the regression tests, see
<xref linkend="regress">. <xref linkend="regress">.
...@@ -448,9 +424,9 @@ ...@@ -448,9 +424,9 @@
</variablelist> </variablelist>
Edit the <filename>buildenv.pl</filename> file, and add a variable for the Edit the <filename>buildenv.pl</filename> file, and add a variable for the
location of the root directory, for example: location of the root directory, for example:
<screen> <programlisting>
$ENV{DOCROOT}='c:\docbook'; $ENV{DOCROOT}='c:\docbook';
</screen> </programlisting>
To build the documentation, run the command To build the documentation, run the command
<filename>builddoc.bat</filename>. Note that this will actually run the <filename>builddoc.bat</filename>. Note that this will actually run the
build twice, in order to generate the indexes. The generated HTML files build twice, in order to generate the indexes. The generated HTML files
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/intagg.sgml,v 1.4 2008/11/14 19:58:45 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/intagg.sgml,v 1.5 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="intagg"> <sect1 id="intagg">
<title>intagg</title> <title>intagg</title>
...@@ -44,24 +44,20 @@ ...@@ -44,24 +44,20 @@
<para> <para>
Many database systems have the notion of a one to many table. Such a table Many database systems have the notion of a one to many table. Such a table
usually sits between two indexed tables, for example: usually sits between two indexed tables, for example:
</para>
<programlisting> <programlisting>
CREATE TABLE left (id INT PRIMARY KEY, ...); CREATE TABLE left (id INT PRIMARY KEY, ...);
CREATE TABLE right (id INT PRIMARY KEY, ...); CREATE TABLE right (id INT PRIMARY KEY, ...);
CREATE TABLE one_to_many(left INT REFERENCES left, right INT REFERENCES right); CREATE TABLE one_to_many(left INT REFERENCES left, right INT REFERENCES right);
</programlisting> </programlisting>
<para>
It is typically used like this: It is typically used like this:
</para>
<programlisting> <programlisting>
SELECT right.* from right JOIN one_to_many ON (right.id = one_to_many.right) SELECT right.* from right JOIN one_to_many ON (right.id = one_to_many.right)
WHERE one_to_many.left = <replaceable>item</>; WHERE one_to_many.left = <replaceable>item</>;
</programlisting> </programlisting>
<para>
This will return all the items in the right hand table for an entry This will return all the items in the right hand table for an entry
in the left hand table. This is a very common construct in SQL. in the left hand table. This is a very common construct in SQL.
</para> </para>
...@@ -74,35 +70,29 @@ CREATE TABLE one_to_many(left INT REFERENCES left, right INT REFERENCES right); ...@@ -74,35 +70,29 @@ CREATE TABLE one_to_many(left INT REFERENCES left, right INT REFERENCES right);
left hand entry. If you have a very dynamic system, there is not much you left hand entry. If you have a very dynamic system, there is not much you
can do. However, if you have some data which is fairly static, you can can do. However, if you have some data which is fairly static, you can
create a summary table with the aggregator. create a summary table with the aggregator.
</para>
<programlisting> <programlisting>
CREATE TABLE summary as CREATE TABLE summary AS
SELECT left, int_array_aggregate(right) AS right SELECT left, int_array_aggregate(right) AS right
FROM one_to_many FROM one_to_many
GROUP BY left; GROUP BY left;
</programlisting> </programlisting>
<para>
This will create a table with one row per left item, and an array This will create a table with one row per left item, and an array
of right items. Now this is pretty useless without some way of using of right items. Now this is pretty useless without some way of using
the array; that's why there is an array enumerator. You can do the array; that's why there is an array enumerator. You can do
</para>
<programlisting> <programlisting>
SELECT left, int_array_enum(right) FROM summary WHERE left = <replaceable>item</>; SELECT left, int_array_enum(right) FROM summary WHERE left = <replaceable>item</>;
</programlisting> </programlisting>
<para>
The above query using <function>int_array_enum</> produces the same results The above query using <function>int_array_enum</> produces the same results
as as
</para>
<programlisting> <programlisting>
SELECT left, right FROM one_to_many WHERE left = <replaceable>item</>; SELECT left, right FROM one_to_many WHERE left = <replaceable>item</>;
</programlisting> </programlisting>
<para>
The difference is that the query against the summary table has to get The difference is that the query against the summary table has to get
only one row from the table, whereas the direct query against only one row from the table, whereas the direct query against
<structname>one_to_many</> must index scan and fetch a row for each entry. <structname>one_to_many</> must index scan and fetch a row for each entry.
...@@ -112,9 +102,8 @@ SELECT left, right FROM one_to_many WHERE left = <replaceable>item</>; ...@@ -112,9 +102,8 @@ SELECT left, right FROM one_to_many WHERE left = <replaceable>item</>;
On one system, an <command>EXPLAIN</> showed a query with a cost of 8488 was On one system, an <command>EXPLAIN</> showed a query with a cost of 8488 was
reduced to a cost of 329. The original query was a join involving the reduced to a cost of 329. The original query was a join involving the
<structname>one_to_many</> table, which was replaced by: <structname>one_to_many</> table, which was replaced by:
</para>
<programlisting> <programlisting>
SELECT right, count(right) FROM SELECT right, count(right) FROM
( SELECT left, int_array_enum(right) AS right ( SELECT left, int_array_enum(right) AS right
FROM summary JOIN (SELECT left FROM left_table WHERE left = <replaceable>item</>) AS lefts FROM summary JOIN (SELECT left FROM left_table WHERE left = <replaceable>item</>) AS lefts
...@@ -122,7 +111,8 @@ SELECT right, count(right) FROM ...@@ -122,7 +111,8 @@ SELECT right, count(right) FROM
) AS list ) AS list
GROUP BY right GROUP BY right
ORDER BY count DESC; ORDER BY count DESC;
</programlisting> </programlisting>
</para>
</sect2> </sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/intarray.sgml,v 1.10 2010/05/05 15:10:25 heikki Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/intarray.sgml,v 1.11 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="intarray"> <sect1 id="intarray">
<title>intarray</title> <title>intarray</title>
...@@ -271,7 +271,7 @@ ...@@ -271,7 +271,7 @@
<sect2> <sect2>
<title>Example</title> <title>Example</title>
<programlisting> <programlisting>
-- a message can be in one or more <quote>sections</> -- a message can be in one or more <quote>sections</>
CREATE TABLE message (mid INT PRIMARY KEY, sections INT[], ...); CREATE TABLE message (mid INT PRIMARY KEY, sections INT[], ...);
...@@ -286,7 +286,7 @@ SELECT message.mid FROM message WHERE message.sections @&gt; '{1,2}'; ...@@ -286,7 +286,7 @@ SELECT message.mid FROM message WHERE message.sections @&gt; '{1,2}';
-- the same, using QUERY operator -- the same, using QUERY operator
SELECT message.mid FROM message WHERE message.sections @@ '1&amp;2'::query_int; SELECT message.mid FROM message WHERE message.sections @@ '1&amp;2'::query_int;
</programlisting> </programlisting>
</sect2> </sect2>
<sect2> <sect2>
...@@ -297,13 +297,13 @@ SELECT message.mid FROM message WHERE message.sections @@ '1&amp;2'::query_int; ...@@ -297,13 +297,13 @@ SELECT message.mid FROM message WHERE message.sections @@ '1&amp;2'::query_int;
benchmark test suite. To run: benchmark test suite. To run:
</para> </para>
<programlisting> <programlisting>
cd .../bench cd .../bench
createdb TEST createdb TEST
psql TEST &lt; ../_int.sql psql TEST &lt; ../_int.sql
./create_test.pl | psql TEST ./create_test.pl | psql TEST
./bench.pl ./bench.pl
</programlisting> </programlisting>
<para> <para>
The <filename>bench.pl</> script has numerous options, which The <filename>bench.pl</> script has numerous options, which
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/isn.sgml,v 1.5 2009/05/18 11:08:24 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/isn.sgml,v 1.6 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="isn"> <sect1 id="isn">
<title>isn</title> <title>isn</title>
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
<sect2> <sect2>
<title>Examples</title> <title>Examples</title>
<programlisting> <programlisting>
--Using the types directly: --Using the types directly:
SELECT isbn('978-0-393-04002-9'); SELECT isbn('978-0-393-04002-9');
SELECT isbn13('0901690546'); SELECT isbn13('0901690546');
...@@ -333,7 +333,7 @@ UPDATE test SET id = make_valid(id) WHERE id = '2-205-00876-X!'; ...@@ -333,7 +333,7 @@ UPDATE test SET id = make_valid(id) WHERE id = '2-205-00876-X!';
SELECT * FROM test; SELECT * FROM test;
SELECT isbn13(id) FROM test; SELECT isbn13(id) FROM test;
</programlisting> </programlisting>
</sect2> </sect2>
<sect2> <sect2>
...@@ -342,24 +342,20 @@ SELECT isbn13(id) FROM test; ...@@ -342,24 +342,20 @@ SELECT isbn13(id) FROM test;
<para> <para>
The information to implement this module was collected from The information to implement this module was collected from
several sites, including: several sites, including:
</para> <itemizedlist>
<programlisting> <listitem><para><ulink url="http://www.isbn-international.org/"></ulink></para></listitem>
http://www.isbn-international.org/ <listitem><para><ulink url="http://www.issn.org/"></ulink></para></listitem>
http://www.issn.org/ <listitem><para><ulink url="http://www.ismn-international.org/"></ulink></para></listitem>
http://www.ismn-international.org/ <listitem><para><ulink url="http://www.wikipedia.org/"></ulink></para></listitem>
http://www.wikipedia.org/ </itemizedlist>
</programlisting>
<para>
The prefixes used for hyphenation were also compiled from: The prefixes used for hyphenation were also compiled from:
</para> <itemizedlist>
<programlisting> <listitem><para><ulink url="http://www.gs1.org/productssolutions/idkeys/support/prefix_list.html"></ulink></para></listitem>
http://www.gs1.org/productssolutions/idkeys/support/prefix_list.html <listitem><para><ulink url="http://www.isbn-international.org/en/identifiers.html"></ulink></para></listitem>
http://www.isbn-international.org/en/identifiers.html <listitem><para><ulink url="http://www.ismn-international.org/ranges.html"></ulink></para></listitem>
http://www.ismn-international.org/ranges.html </itemizedlist>
</programlisting>
<para>
Care was taken during the creation of the algorithms and they Care was taken during the creation of the algorithms and they
were meticulously verified against the suggested algorithms were meticulously verified against the suggested algorithms
in the official ISBN, ISMN, ISSN User Manuals. in the official ISBN, ISMN, ISSN User Manuals.
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.316 2010/07/27 19:01:16 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.317 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="libpq"> <chapter id="libpq">
<title><application>libpq</application> - C Library</title> <title><application>libpq</application> - C Library</title>
...@@ -97,9 +97,9 @@ ...@@ -97,9 +97,9 @@
<para> <para>
Makes a new connection to the database server. Makes a new connection to the database server.
<synopsis> <synopsis>
PGconn *PQconnectdbParams(const char **keywords, const char **values, int expand_dbname); PGconn *PQconnectdbParams(const char **keywords, const char **values, int expand_dbname);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -600,9 +600,9 @@ ...@@ -600,9 +600,9 @@
<para> <para>
Makes a new connection to the database server. Makes a new connection to the database server.
<synopsis> <synopsis>
PGconn *PQconnectdb(const char *conninfo); PGconn *PQconnectdb(const char *conninfo);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -690,17 +690,13 @@ PGconn *PQsetdb(char *pghost, ...@@ -690,17 +690,13 @@ PGconn *PQsetdb(char *pghost,
<indexterm><primary>nonblocking connection</primary></indexterm> <indexterm><primary>nonblocking connection</primary></indexterm>
Make a connection to the database server in a nonblocking manner. Make a connection to the database server in a nonblocking manner.
<synopsis> <synopsis>
PGconn *PQconnectStartParams(const char **keywords, const char **values, int expand_dbname); PGconn *PQconnectStartParams(const char **keywords, const char **values, int expand_dbname);
</synopsis>
<synopsis> PGconn *PQconnectStart(const char *conninfo);
PGconn *PQconnectStart(const char *conninfo);
</synopsis>
<synopsis> PostgresPollingStatusType PQconnectPoll(PGconn *conn);
PostgresPollingStatusType PQconnectPoll(PGconn *conn); </synopsis>
</synopsis>
</para> </para>
<para> <para>
...@@ -995,9 +991,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -995,9 +991,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<para> <para>
Closes the connection to the server. Also frees Closes the connection to the server. Also frees
memory used by the <structname>PGconn</structname> object. memory used by the <structname>PGconn</structname> object.
<synopsis> <synopsis>
void PQfinish(PGconn *conn); void PQfinish(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -1015,9 +1011,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1015,9 +1011,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Resets the communication channel to the server. Resets the communication channel to the server.
<synopsis> <synopsis>
void PQreset(PGconn *conn); void PQreset(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -1037,12 +1033,11 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1037,12 +1033,11 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<para> <para>
Reset the communication channel to the server, in a nonblocking manner. Reset the communication channel to the server, in a nonblocking manner.
<synopsis> <synopsis>
int PQresetStart(PGconn *conn); int PQresetStart(PGconn *conn);
</synopsis>
<synopsis> PostgresPollingStatusType PQresetPoll(PGconn *conn);
PostgresPollingStatusType PQresetPoll(PGconn *conn); </synopsis>
</synopsis>
</para> </para>
<para> <para>
...@@ -1106,9 +1101,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1106,9 +1101,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Returns the database name of the connection. Returns the database name of the connection.
<synopsis> <synopsis>
char *PQdb(const PGconn *conn); char *PQdb(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1124,9 +1119,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1124,9 +1119,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Returns the user name of the connection. Returns the user name of the connection.
<synopsis> <synopsis>
char *PQuser(const PGconn *conn); char *PQuser(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1142,9 +1137,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1142,9 +1137,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Returns the password of the connection. Returns the password of the connection.
<synopsis> <synopsis>
char *PQpass(const PGconn *conn); char *PQpass(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1160,9 +1155,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1160,9 +1155,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Returns the server host name of the connection. Returns the server host name of the connection.
<synopsis> <synopsis>
char *PQhost(const PGconn *conn); char *PQhost(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1179,9 +1174,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1179,9 +1174,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<para> <para>
Returns the port of the connection. Returns the port of the connection.
<synopsis> <synopsis>
char *PQport(const PGconn *conn); char *PQport(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1201,9 +1196,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1201,9 +1196,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
to the <acronym>TTY</acronym> setting, but the function remains to the <acronym>TTY</acronym> setting, but the function remains
for backwards compatibility.) for backwards compatibility.)
<synopsis> <synopsis>
char *PQtty(const PGconn *conn); char *PQtty(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1219,9 +1214,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1219,9 +1214,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Returns the command-line options passed in the connection request. Returns the command-line options passed in the connection request.
<synopsis> <synopsis>
char *PQoptions(const PGconn *conn); char *PQoptions(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1244,9 +1239,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1244,9 +1239,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Returns the status of the connection. Returns the status of the connection.
<synopsis> <synopsis>
ConnStatusType PQstatus(const PGconn *conn); ConnStatusType PQstatus(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -1284,9 +1279,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1284,9 +1279,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<para> <para>
Returns the current in-transaction status of the server. Returns the current in-transaction status of the server.
<synopsis> <synopsis>
PGTransactionStatusType PQtransactionStatus(const PGconn *conn); PGTransactionStatusType PQtransactionStatus(const PGconn *conn);
</synopsis> </synopsis>
The status can be <literal>PQTRANS_IDLE</literal> (currently idle), The status can be <literal>PQTRANS_IDLE</literal> (currently idle),
<literal>PQTRANS_ACTIVE</literal> (a command is in progress), <literal>PQTRANS_ACTIVE</literal> (a command is in progress),
...@@ -1320,9 +1315,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1320,9 +1315,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<para> <para>
Looks up a current parameter setting of the server. Looks up a current parameter setting of the server.
<synopsis> <synopsis>
const char *PQparameterStatus(const PGconn *conn, const char *paramName); const char *PQparameterStatus(const PGconn *conn, const char *paramName);
</synopsis> </synopsis>
Certain parameter values are reported by the server automatically at Certain parameter values are reported by the server automatically at
connection startup or whenever their values change. connection startup or whenever their values change.
...@@ -1398,9 +1393,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1398,9 +1393,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Interrogates the frontend/backend protocol being used. Interrogates the frontend/backend protocol being used.
<synopsis> <synopsis>
int PQprotocolVersion(const PGconn *conn); int PQprotocolVersion(const PGconn *conn);
</synopsis> </synopsis>
Applications might wish to use this to determine whether certain Applications might wish to use this to determine whether certain
features are supported. Currently, the possible values are 2 (2.0 features are supported. Currently, the possible values are 2 (2.0
protocol), 3 (3.0 protocol), or zero (connection bad). This will protocol), 3 (3.0 protocol), or zero (connection bad). This will
...@@ -1425,9 +1420,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1425,9 +1420,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<listitem> <listitem>
<para> <para>
Returns an integer representing the backend version. Returns an integer representing the backend version.
<synopsis> <synopsis>
int PQserverVersion(const PGconn *conn); int PQserverVersion(const PGconn *conn);
</synopsis> </synopsis>
Applications might use this to determine the version of the database Applications might use this to determine the version of the database
server they are connected to. The number is formed by converting server they are connected to. The number is formed by converting
the major, minor, and revision numbers into two-decimal-digit the major, minor, and revision numbers into two-decimal-digit
...@@ -1452,9 +1447,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1452,9 +1447,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<indexterm><primary>error message</></> Returns the error message <indexterm><primary>error message</></> Returns the error message
most recently generated by an operation on the connection. most recently generated by an operation on the connection.
<synopsis> <synopsis>
char *PQerrorMessage(const PGconn *conn); char *PQerrorMessage(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
...@@ -1483,9 +1478,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1483,9 +1478,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
currently open. (This will not change during normal operation, currently open. (This will not change during normal operation,
but could change during connection setup or reset.) but could change during connection setup or reset.)
<synopsis> <synopsis>
int PQsocket(const PGconn *conn); int PQsocket(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
...@@ -1500,9 +1495,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1500,9 +1495,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
server process</><tertiary>in libpq</></> of the backend server server process</><tertiary>in libpq</></> of the backend server
process handling this connection. process handling this connection.
<synopsis> <synopsis>
int PQbackendPID(const PGconn *conn); int PQbackendPID(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -1524,9 +1519,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1524,9 +1519,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
required a password, but none was available. required a password, but none was available.
Returns false (0) if not. Returns false (0) if not.
<synopsis> <synopsis>
int PQconnectionNeedsPassword(const PGconn *conn); int PQconnectionNeedsPassword(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -1543,9 +1538,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1543,9 +1538,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
Returns true (1) if the connection authentication method Returns true (1) if the connection authentication method
used a password. Returns false (0) if not. used a password. Returns false (0) if not.
<synopsis> <synopsis>
int PQconnectionUsedPassword(const PGconn *conn); int PQconnectionUsedPassword(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -1563,9 +1558,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1563,9 +1558,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
Returns the SSL structure used in the connection, or null Returns the SSL structure used in the connection, or null
if SSL is not in use. if SSL is not in use.
<synopsis> <synopsis>
SSL *PQgetssl(const PGconn *conn); SSL *PQgetssl(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -1614,9 +1609,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg); ...@@ -1614,9 +1609,9 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
<para> <para>
Submits a command to the server and waits for the result. Submits a command to the server and waits for the result.
<synopsis> <synopsis>
PGresult *PQexec(PGconn *conn, const char *command); PGresult *PQexec(PGconn *conn, const char *command);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2058,9 +2053,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2058,9 +2053,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
<listitem> <listitem>
<para> <para>
Returns the result status of the command. Returns the result status of the command.
<synopsis> <synopsis>
ExecStatusType PQresultStatus(const PGresult *res); ExecStatusType PQresultStatus(const PGresult *res);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2176,9 +2171,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2176,9 +2171,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
<function>PQresultStatus</> into a string constant describing the <function>PQresultStatus</> into a string constant describing the
status code. The caller should not free the result. status code. The caller should not free the result.
<synopsis> <synopsis>
char *PQresStatus(ExecStatusType status); char *PQresStatus(ExecStatusType status);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2195,9 +2190,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2195,9 +2190,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
<para> <para>
Returns the error message associated with the command, or an empty string Returns the error message associated with the command, or an empty string
if there was no error. if there was no error.
<synopsis> <synopsis>
char *PQresultErrorMessage(const PGresult *res); char *PQresultErrorMessage(const PGresult *res);
</synopsis> </synopsis>
If there was an error, the returned string will include a trailing If there was an error, the returned string will include a trailing
newline. The caller should not free the result directly. It will newline. The caller should not free the result directly. It will
be freed when the associated <structname>PGresult</> handle is be freed when the associated <structname>PGresult</> handle is
...@@ -2226,9 +2221,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2226,9 +2221,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
<listitem> <listitem>
<para> <para>
Returns an individual field of an error report. Returns an individual field of an error report.
<synopsis> <synopsis>
char *PQresultErrorField(const PGresult *res, int fieldcode); char *PQresultErrorField(const PGresult *res, int fieldcode);
</synopsis> </synopsis>
<parameter>fieldcode</> is an error field identifier; see the symbols <parameter>fieldcode</> is an error field identifier; see the symbols
listed below. <symbol>NULL</symbol> is returned if the listed below. <symbol>NULL</symbol> is returned if the
<structname>PGresult</structname> is not an error or warning result, <structname>PGresult</structname> is not an error or warning result,
...@@ -2417,9 +2412,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2417,9 +2412,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
freed via <function>PQclear</function> when it is no longer freed via <function>PQclear</function> when it is no longer
needed. needed.
<synopsis> <synopsis>
void PQclear(PGresult *res); void PQclear(PGresult *res);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2464,9 +2459,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2464,9 +2459,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
it returns an integer result, large result sets might overflow the it returns an integer result, large result sets might overflow the
return value on 32-bit operating systems. return value on 32-bit operating systems.
<synopsis> <synopsis>
int PQntuples(const PGresult *res); int PQntuples(const PGresult *res);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
...@@ -2485,9 +2480,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2485,9 +2480,9 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
Returns the number of columns (fields) in each row of the query Returns the number of columns (fields) in each row of the query
result. result.
<synopsis> <synopsis>
int PQnfields(const PGresult *res); int PQnfields(const PGresult *res);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2507,10 +2502,10 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2507,10 +2502,10 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
directly. It will be freed when the associated directly. It will be freed when the associated
<structname>PGresult</> handle is passed to <structname>PGresult</> handle is passed to
<function>PQclear</function>. <function>PQclear</function>.
<synopsis> <synopsis>
char *PQfname(const PGresult *res, char *PQfname(const PGresult *res,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2530,10 +2525,10 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName); ...@@ -2530,10 +2525,10 @@ PGresult *PQdescribePortal(PGconn *conn, const char *portalName);
<listitem> <listitem>
<para> <para>
Returns the column number associated with the given column name. Returns the column number associated with the given column name.
<synopsis> <synopsis>
int PQfnumber(const PGresult *res, int PQfnumber(const PGresult *res,
const char *column_name); const char *column_name);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2572,10 +2567,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2572,10 +2567,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Returns the OID of the table from which the given column was Returns the OID of the table from which the given column was
fetched. Column numbers start at 0. fetched. Column numbers start at 0.
<synopsis> <synopsis>
Oid PQftable(const PGresult *res, Oid PQftable(const PGresult *res,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2608,10 +2603,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2608,10 +2603,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
Returns the column number (within its table) of the column making Returns the column number (within its table) of the column making
up the specified query result column. Query-result column numbers up the specified query result column. Query-result column numbers
start at 0, but table columns have nonzero numbers. start at 0, but table columns have nonzero numbers.
<synopsis> <synopsis>
int PQftablecol(const PGresult *res, int PQftablecol(const PGresult *res,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2634,10 +2629,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2634,10 +2629,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Returns the format code indicating the format of the given Returns the format code indicating the format of the given
column. Column numbers start at 0. column. Column numbers start at 0.
<synopsis> <synopsis>
int PQfformat(const PGresult *res, int PQfformat(const PGresult *res,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2661,10 +2656,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2661,10 +2656,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
Returns the data type associated with the given column number. Returns the data type associated with the given column number.
The integer returned is the internal OID number of the type. The integer returned is the internal OID number of the type.
Column numbers start at 0. Column numbers start at 0.
<synopsis> <synopsis>
Oid PQftype(const PGresult *res, Oid PQftype(const PGresult *res,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2689,10 +2684,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2689,10 +2684,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Returns the type modifier of the column associated with the Returns the type modifier of the column associated with the
given column number. Column numbers start at 0. given column number. Column numbers start at 0.
<synopsis> <synopsis>
int PQfmod(const PGresult *res, int PQfmod(const PGresult *res,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2717,10 +2712,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2717,10 +2712,10 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Returns the size in bytes of the column associated with the Returns the size in bytes of the column associated with the
given column number. Column numbers start at 0. given column number. Column numbers start at 0.
<synopsis> <synopsis>
int PQfsize(const PGresult *res, int PQfsize(const PGresult *res,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2745,9 +2740,9 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2745,9 +2740,9 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Returns 1 if the <structname>PGresult</> contains binary data Returns 1 if the <structname>PGresult</> contains binary data
and 0 if it contains text data. and 0 if it contains text data.
<synopsis> <synopsis>
int PQbinaryTuples(const PGresult *res); int PQbinaryTuples(const PGresult *res);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2776,11 +2771,11 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2776,11 +2771,11 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
at 0. The caller should not free the result directly. It will at 0. The caller should not free the result directly. It will
be freed when the associated <structname>PGresult</> handle is be freed when the associated <structname>PGresult</> handle is
passed to <function>PQclear</function>. passed to <function>PQclear</function>.
<synopsis> <synopsis>
char *PQgetvalue(const PGresult *res, char *PQgetvalue(const PGresult *res,
int row_number, int row_number,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2827,11 +2822,11 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2827,11 +2822,11 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Tests a field for a null value. Row and column numbers start Tests a field for a null value. Row and column numbers start
at 0. at 0.
<synopsis> <synopsis>
int PQgetisnull(const PGresult *res, int PQgetisnull(const PGresult *res,
int row_number, int row_number,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2854,11 +2849,11 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2854,11 +2849,11 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Returns the actual length of a field value in bytes. Row and Returns the actual length of a field value in bytes. Row and
column numbers start at 0. column numbers start at 0.
<synopsis> <synopsis>
int PQgetlength(const PGresult *res, int PQgetlength(const PGresult *res,
int row_number, int row_number,
int column_number); int column_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2884,9 +2879,9 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2884,9 +2879,9 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<listitem> <listitem>
<para> <para>
Returns the number of parameters of a prepared statement. Returns the number of parameters of a prepared statement.
<synopsis> <synopsis>
int PQnparams(const PGresult *res); int PQnparams(const PGresult *res);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2909,9 +2904,9 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2909,9 +2904,9 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Returns the data type of the indicated statement parameter. Returns the data type of the indicated statement parameter.
Parameter numbers start at 0. Parameter numbers start at 0.
<synopsis> <synopsis>
Oid PQparamtype(const PGresult *res, int param_number); Oid PQparamtype(const PGresult *res, int param_number);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2934,11 +2929,12 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation> ...@@ -2934,11 +2929,12 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
<para> <para>
Prints out all the rows and, optionally, the column names to Prints out all the rows and, optionally, the column names to
the specified output stream. the specified output stream.
<synopsis> <synopsis>
void PQprint(FILE *fout, /* output stream */ void PQprint(FILE *fout, /* output stream */
const PGresult *res, const PGresult *res,
const PQprintOpt *po); const PQprintOpt *po);
typedef struct { typedef struct
{
pqbool header; /* print output field headings and row count */ pqbool header; /* print output field headings and row count */
pqbool align; /* fill align the fields */ pqbool align; /* fill align the fields */
pqbool standard; /* old brain dead format */ pqbool standard; /* old brain dead format */
...@@ -2950,7 +2946,7 @@ typedef struct { ...@@ -2950,7 +2946,7 @@ typedef struct {
char *caption; /* HTML table caption */ char *caption; /* HTML table caption */
char **fieldName; /* null-terminated array of replacement field names */ char **fieldName; /* null-terminated array of replacement field names */
} PQprintOpt; } PQprintOpt;
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -2984,9 +2980,9 @@ typedef struct { ...@@ -2984,9 +2980,9 @@ typedef struct {
<para> <para>
Returns the command status tag from the SQL command that generated Returns the command status tag from the SQL command that generated
the <structname>PGresult</structname>. the <structname>PGresult</structname>.
<synopsis> <synopsis>
char *PQcmdStatus(PGresult *res); char *PQcmdStatus(PGresult *res);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3010,9 +3006,9 @@ typedef struct { ...@@ -3010,9 +3006,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Returns the number of rows affected by the SQL command. Returns the number of rows affected by the SQL command.
<synopsis> <synopsis>
char *PQcmdTuples(PGresult *res); char *PQcmdTuples(PGresult *res);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3051,9 +3047,9 @@ typedef struct { ...@@ -3051,9 +3047,9 @@ typedef struct {
returns <literal>InvalidOid</literal>. This function will also returns <literal>InvalidOid</literal>. This function will also
return <literal>InvalidOid</literal> if the table affected by the return <literal>InvalidOid</literal> if the table affected by the
<command>INSERT</> statement does not contain OIDs. <command>INSERT</> statement does not contain OIDs.
<synopsis> <synopsis>
Oid PQoidValue(const PGresult *res); Oid PQoidValue(const PGresult *res);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3076,9 +3072,9 @@ typedef struct { ...@@ -3076,9 +3072,9 @@ typedef struct {
the <command>INSERT</command> did not insert exactly one row, or the <command>INSERT</command> did not insert exactly one row, or
if the target table does not have OIDs.) If the command was not if the target table does not have OIDs.) If the command was not
an <command>INSERT</command>, returns an empty string. an <command>INSERT</command>, returns an empty string.
<synopsis> <synopsis>
char *PQoidStatus(const PGresult *res); char *PQoidStatus(const PGresult *res);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3110,9 +3106,9 @@ typedef struct { ...@@ -3110,9 +3106,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
<synopsis> <synopsis>
size_t PQescapeLiteral(PGconn *conn, char *str, size_t len) size_t PQescapeLiteral(PGconn *conn, char *str, size_t len);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3174,9 +3170,9 @@ typedef struct { ...@@ -3174,9 +3170,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
<synopsis> <synopsis>
size_t PQescapeIdentifier(PGconn *conn, char *str, size_t len) size_t PQescapeIdentifier(PGconn *conn, char *str, size_t len);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3229,11 +3225,11 @@ typedef struct { ...@@ -3229,11 +3225,11 @@ typedef struct {
<listitem> <listitem>
<para> <para>
<synopsis> <synopsis>
size_t PQescapeStringConn (PGconn *conn, size_t PQescapeStringConn(PGconn *conn,
char *to, const char *from, size_t length, char *to, const char *from, size_t length,
int *error); int *error);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3284,9 +3280,9 @@ typedef struct { ...@@ -3284,9 +3280,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
<synopsis> <synopsis>
size_t PQescapeString (char *to, const char *from, size_t length); size_t PQescapeString (char *to, const char *from, size_t length);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3323,12 +3319,12 @@ typedef struct { ...@@ -3323,12 +3319,12 @@ typedef struct {
Escapes binary data for use within an SQL command with the type Escapes binary data for use within an SQL command with the type
<type>bytea</type>. As with <function>PQescapeStringConn</function>, <type>bytea</type>. As with <function>PQescapeStringConn</function>,
this is only used when inserting data directly into an SQL command string. this is only used when inserting data directly into an SQL command string.
<synopsis> <synopsis>
unsigned char *PQescapeByteaConn(PGconn *conn, unsigned char *PQescapeByteaConn(PGconn *conn,
const unsigned char *from, const unsigned char *from,
size_t from_length, size_t from_length,
size_t *to_length); size_t *to_length);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3388,11 +3384,11 @@ typedef struct { ...@@ -3388,11 +3384,11 @@ typedef struct {
<para> <para>
<function>PQescapeBytea</> is an older, deprecated version of <function>PQescapeBytea</> is an older, deprecated version of
<function>PQescapeByteaConn</>. <function>PQescapeByteaConn</>.
<synopsis> <synopsis>
unsigned char *PQescapeBytea(const unsigned char *from, unsigned char *PQescapeBytea(const unsigned char *from,
size_t from_length, size_t from_length,
size_t *to_length); size_t *to_length);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3431,9 +3427,9 @@ typedef struct { ...@@ -3431,9 +3427,9 @@ typedef struct {
is needed when retrieving <type>bytea</type> data in text format, is needed when retrieving <type>bytea</type> data in text format,
but not when retrieving it in binary format. but not when retrieving it in binary format.
<synopsis> <synopsis>
unsigned char *PQunescapeBytea(const unsigned char *from, size_t *to_length); unsigned char *PQunescapeBytea(const unsigned char *from, size_t *to_length);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3539,9 +3535,9 @@ typedef struct { ...@@ -3539,9 +3535,9 @@ typedef struct {
1 is returned if the command was successfully dispatched and 0 if 1 is returned if the command was successfully dispatched and 0 if
not (in which case, use <function>PQerrorMessage</> to get more not (in which case, use <function>PQerrorMessage</> to get more
information about the failure). information about the failure).
<synopsis> <synopsis>
int PQsendQuery(PGconn *conn, const char *command); int PQsendQuery(PGconn *conn, const char *command);
</synopsis> </synopsis>
After successfully calling <function>PQsendQuery</function>, call After successfully calling <function>PQsendQuery</function>, call
<function>PQgetResult</function> one or more times to obtain the <function>PQgetResult</function> one or more times to obtain the
...@@ -3564,8 +3560,8 @@ typedef struct { ...@@ -3564,8 +3560,8 @@ typedef struct {
<para> <para>
Submits a command and separate parameters to the server without Submits a command and separate parameters to the server without
waiting for the result(s). waiting for the result(s).
<synopsis> <synopsis>
int PQsendQueryParams(PGconn *conn, int PQsendQueryParams(PGconn *conn,
const char *command, const char *command,
int nParams, int nParams,
const Oid *paramTypes, const Oid *paramTypes,
...@@ -3573,7 +3569,7 @@ typedef struct { ...@@ -3573,7 +3569,7 @@ typedef struct {
const int *paramLengths, const int *paramLengths,
const int *paramFormats, const int *paramFormats,
int resultFormat); int resultFormat);
</synopsis> </synopsis>
This is equivalent to <function>PQsendQuery</function> except that This is equivalent to <function>PQsendQuery</function> except that
query parameters can be specified separately from the query string. query parameters can be specified separately from the query string.
...@@ -3597,13 +3593,13 @@ typedef struct { ...@@ -3597,13 +3593,13 @@ typedef struct {
<para> <para>
Sends a request to create a prepared statement with the given Sends a request to create a prepared statement with the given
parameters, without waiting for completion. parameters, without waiting for completion.
<synopsis> <synopsis>
int PQsendPrepare(PGconn *conn, int PQsendPrepare(PGconn *conn,
const char *stmtName, const char *stmtName,
const char *query, const char *query,
int nParams, int nParams,
const Oid *paramTypes); const Oid *paramTypes);
</synopsis> </synopsis>
This is an asynchronous version of <function>PQprepare</>: it This is an asynchronous version of <function>PQprepare</>: it
returns 1 if it was able to dispatch the request, and 0 if not. returns 1 if it was able to dispatch the request, and 0 if not.
...@@ -3629,15 +3625,15 @@ typedef struct { ...@@ -3629,15 +3625,15 @@ typedef struct {
<para> <para>
Sends a request to execute a prepared statement with given Sends a request to execute a prepared statement with given
parameters, without waiting for the result(s). parameters, without waiting for the result(s).
<synopsis> <synopsis>
int PQsendQueryPrepared(PGconn *conn, int PQsendQueryPrepared(PGconn *conn,
const char *stmtName, const char *stmtName,
int nParams, int nParams,
const char * const *paramValues, const char * const *paramValues,
const int *paramLengths, const int *paramLengths,
const int *paramFormats, const int *paramFormats,
int resultFormat); int resultFormat);
</synopsis> </synopsis>
This is similar to <function>PQsendQueryParams</function>, but This is similar to <function>PQsendQueryParams</function>, but
the command to be executed is specified by naming a the command to be executed is specified by naming a
...@@ -3662,9 +3658,9 @@ typedef struct { ...@@ -3662,9 +3658,9 @@ typedef struct {
<para> <para>
Submits a request to obtain information about the specified Submits a request to obtain information about the specified
prepared statement, without waiting for completion. prepared statement, without waiting for completion.
<synopsis> <synopsis>
int PQsendDescribePrepared(PGconn *conn, const char *stmtName); int PQsendDescribePrepared(PGconn *conn, const char *stmtName);
</synopsis> </synopsis>
This is an asynchronous version of <function>PQdescribePrepared</>: This is an asynchronous version of <function>PQdescribePrepared</>:
it returns 1 if it was able to dispatch the request, and 0 if not. it returns 1 if it was able to dispatch the request, and 0 if not.
...@@ -3689,9 +3685,9 @@ typedef struct { ...@@ -3689,9 +3685,9 @@ typedef struct {
<para> <para>
Submits a request to obtain information about the specified Submits a request to obtain information about the specified
portal, without waiting for completion. portal, without waiting for completion.
<synopsis> <synopsis>
int PQsendDescribePortal(PGconn *conn, const char *portalName); int PQsendDescribePortal(PGconn *conn, const char *portalName);
</synopsis> </synopsis>
This is an asynchronous version of <function>PQdescribePortal</>: This is an asynchronous version of <function>PQdescribePortal</>:
it returns 1 if it was able to dispatch the request, and 0 if not. it returns 1 if it was able to dispatch the request, and 0 if not.
...@@ -3721,9 +3717,9 @@ typedef struct { ...@@ -3721,9 +3717,9 @@ typedef struct {
<function>PQsendQueryPrepared</function> call, and returns it. <function>PQsendQueryPrepared</function> call, and returns it.
A null pointer is returned when the command is complete and there A null pointer is returned when the command is complete and there
will be no more results. will be no more results.
<synopsis> <synopsis>
PGresult *PQgetResult(PGconn *conn); PGresult *PQgetResult(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3770,9 +3766,9 @@ typedef struct { ...@@ -3770,9 +3766,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
If input is available from the server, consume it. If input is available from the server, consume it.
<synopsis> <synopsis>
int PQconsumeInput(PGconn *conn); int PQconsumeInput(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3813,9 +3809,9 @@ typedef struct { ...@@ -3813,9 +3809,9 @@ typedef struct {
<function>PQgetResult</function> would block waiting for input. <function>PQgetResult</function> would block waiting for input.
A 0 return indicates that <function>PQgetResult</function> can be A 0 return indicates that <function>PQgetResult</function> can be
called with assurance of not blocking. called with assurance of not blocking.
<synopsis> <synopsis>
int PQisBusy(PGconn *conn); int PQisBusy(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3879,9 +3875,9 @@ typedef struct { ...@@ -3879,9 +3875,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Sets the nonblocking status of the connection. Sets the nonblocking status of the connection.
<synopsis> <synopsis>
int PQsetnonblocking(PGconn *conn, int arg); int PQsetnonblocking(PGconn *conn, int arg);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3916,9 +3912,9 @@ typedef struct { ...@@ -3916,9 +3912,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Returns the blocking status of the database connection. Returns the blocking status of the database connection.
<synopsis> <synopsis>
int PQisnonblocking(const PGconn *conn); int PQisnonblocking(const PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -3943,9 +3939,9 @@ typedef struct { ...@@ -3943,9 +3939,9 @@ typedef struct {
for some reason, or 1 if it was unable to send all the data in for some reason, or 1 if it was unable to send all the data in
the send queue yet (this case can only occur if the connection the send queue yet (this case can only occur if the connection
is nonblocking). is nonblocking).
<synopsis> <synopsis>
int PQflush(PGconn *conn); int PQflush(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3988,9 +3984,9 @@ typedef struct { ...@@ -3988,9 +3984,9 @@ typedef struct {
<para> <para>
Creates a data structure containing the information needed to cancel Creates a data structure containing the information needed to cancel
a command issued through a particular database connection. a command issued through a particular database connection.
<synopsis> <synopsis>
PGcancel *PQgetCancel(PGconn *conn); PGcancel *PQgetCancel(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4017,9 +4013,9 @@ typedef struct { ...@@ -4017,9 +4013,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Frees a data structure created by <function>PQgetCancel</function>. Frees a data structure created by <function>PQgetCancel</function>.
<synopsis> <synopsis>
void PQfreeCancel(PGcancel *cancel); void PQfreeCancel(PGcancel *cancel);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4040,9 +4036,9 @@ typedef struct { ...@@ -4040,9 +4036,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Requests that the server abandon processing of the current command. Requests that the server abandon processing of the current command.
<synopsis> <synopsis>
int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize); int PQcancel(PGcancel *cancel, char *errbuf, int errbufsize);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4087,9 +4083,9 @@ typedef struct { ...@@ -4087,9 +4083,9 @@ typedef struct {
<para> <para>
Requests that the server abandon processing of the current Requests that the server abandon processing of the current
command. command.
<synopsis> <synopsis>
int PQrequestCancel(PGconn *conn); int PQrequestCancel(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4135,8 +4131,8 @@ typedef struct { ...@@ -4135,8 +4131,8 @@ typedef struct {
<para> <para>
The function <function>PQfn</function><indexterm><primary>PQfn</></> The function <function>PQfn</function><indexterm><primary>PQfn</></>
requests execution of a server function via the fast-path interface: requests execution of a server function via the fast-path interface:
<synopsis> <synopsis>
PGresult *PQfn(PGconn *conn, PGresult *PQfn(PGconn *conn,
int fnid, int fnid,
int *result_buf, int *result_buf,
int *result_len, int *result_len,
...@@ -4144,15 +4140,17 @@ typedef struct { ...@@ -4144,15 +4140,17 @@ typedef struct {
const PQArgBlock *args, const PQArgBlock *args,
int nargs); int nargs);
typedef struct { typedef struct
{
int len; int len;
int isint; int isint;
union { union
{
int *ptr; int *ptr;
int integer; int integer;
} u; } u;
} PQArgBlock; } PQArgBlock;
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4230,15 +4228,16 @@ typedef struct { ...@@ -4230,15 +4228,16 @@ typedef struct {
notification is returned from <function>PQnotifies</>, it is considered notification is returned from <function>PQnotifies</>, it is considered
handled and will be removed from the list of notifications. handled and will be removed from the list of notifications.
<synopsis> <synopsis>
PGnotify *PQnotifies(PGconn *conn); PGnotify *PQnotifies(PGconn *conn);
typedef struct pgNotify { typedef struct pgNotify
{
char *relname; /* notification channel name */ char *relname; /* notification channel name */
int be_pid; /* process ID of notifying server process */ int be_pid; /* process ID of notifying server process */
char *extra; /* notification payload string */ char *extra; /* notification payload string */
} PGnotify; } PGnotify;
</synopsis> </synopsis>
After processing a <structname>PGnotify</structname> object returned After processing a <structname>PGnotify</structname> object returned
by <function>PQnotifies</function>, be sure to free it with by <function>PQnotifies</function>, be sure to free it with
...@@ -4431,11 +4430,11 @@ typedef struct { ...@@ -4431,11 +4430,11 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Sends data to the server during <literal>COPY_IN</> state. Sends data to the server during <literal>COPY_IN</> state.
<synopsis> <synopsis>
int PQputCopyData(PGconn *conn, int PQputCopyData(PGconn *conn,
const char *buffer, const char *buffer,
int nbytes); int nbytes);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4470,10 +4469,10 @@ typedef struct { ...@@ -4470,10 +4469,10 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Sends end-of-data indication to the server during <literal>COPY_IN</> state. Sends end-of-data indication to the server during <literal>COPY_IN</> state.
<synopsis> <synopsis>
int PQputCopyEnd(PGconn *conn, int PQputCopyEnd(PGconn *conn,
const char *errormsg); const char *errormsg);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4531,11 +4530,11 @@ typedef struct { ...@@ -4531,11 +4530,11 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Receives data from the server during <literal>COPY_OUT</> state. Receives data from the server during <literal>COPY_OUT</> state.
<synopsis> <synopsis>
int PQgetCopyData(PGconn *conn, int PQgetCopyData(PGconn *conn,
char **buffer, char **buffer,
int async); int async);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4609,11 +4608,11 @@ typedef struct { ...@@ -4609,11 +4608,11 @@ typedef struct {
<para> <para>
Reads a newline-terminated line of characters (transmitted Reads a newline-terminated line of characters (transmitted
by the server) into a buffer string of size <parameter>length</>. by the server) into a buffer string of size <parameter>length</>.
<synopsis> <synopsis>
int PQgetline(PGconn *conn, int PQgetline(PGconn *conn,
char *buffer, char *buffer,
int length); int length);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4648,11 +4647,11 @@ typedef struct { ...@@ -4648,11 +4647,11 @@ typedef struct {
<para> <para>
Reads a row of <command>COPY</command> data (transmitted by the Reads a row of <command>COPY</command> data (transmitted by the
server) into a buffer without blocking. server) into a buffer without blocking.
<synopsis> <synopsis>
int PQgetlineAsync(PGconn *conn, int PQgetlineAsync(PGconn *conn,
char *buffer, char *buffer,
int bufsize); int bufsize);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4707,10 +4706,10 @@ typedef struct { ...@@ -4707,10 +4706,10 @@ typedef struct {
<para> <para>
Sends a null-terminated string to the server. Returns 0 if Sends a null-terminated string to the server. Returns 0 if
OK and <symbol>EOF</symbol> if unable to send the string. OK and <symbol>EOF</symbol> if unable to send the string.
<synopsis> <synopsis>
int PQputline(PGconn *conn, int PQputline(PGconn *conn,
const char *string); const char *string);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4748,11 +4747,11 @@ typedef struct { ...@@ -4748,11 +4747,11 @@ typedef struct {
<para> <para>
Sends a non-null-terminated string to the server. Returns Sends a non-null-terminated string to the server. Returns
0 if OK and <symbol>EOF</symbol> if unable to send the string. 0 if OK and <symbol>EOF</symbol> if unable to send the string.
<synopsis> <synopsis>
int PQputnbytes(PGconn *conn, int PQputnbytes(PGconn *conn,
const char *buffer, const char *buffer,
int nbytes); int nbytes);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -4774,9 +4773,9 @@ typedef struct { ...@@ -4774,9 +4773,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Synchronizes with the server. Synchronizes with the server.
<synopsis> <synopsis>
int PQendcopy(PGconn *conn); int PQendcopy(PGconn *conn);
</synopsis> </synopsis>
This function waits until the server has finished the copying. This function waits until the server has finished the copying.
It should either be issued when the last string has been sent It should either be issued when the last string has been sent
to the server using <function>PQputline</function> or when the to the server using <function>PQputline</function> or when the
...@@ -4839,9 +4838,9 @@ typedef struct { ...@@ -4839,9 +4838,9 @@ typedef struct {
<listitem> <listitem>
<para> <para>
Returns the client encoding. Returns the client encoding.
<synopsis> <synopsis>
int PQclientEncoding(const PGconn *<replaceable>conn</replaceable>); int PQclientEncoding(const PGconn *<replaceable>conn</replaceable>);
</synopsis> </synopsis>
Note that it returns the encoding ID, not a symbolic string Note that it returns the encoding ID, not a symbolic string
such as <literal>EUC_JP</literal>. To convert an encoding ID to an encoding name, you such as <literal>EUC_JP</literal>. To convert an encoding ID to an encoding name, you
...@@ -4865,9 +4864,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -4865,9 +4864,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Sets the client encoding. Sets the client encoding.
<synopsis> <synopsis>
int PQsetClientEncoding(PGconn *<replaceable>conn</replaceable>, const char *<replaceable>encoding</replaceable>); int PQsetClientEncoding(PGconn *<replaceable>conn</replaceable>, const char *<replaceable>encoding</replaceable>);
</synopsis> </synopsis>
<replaceable>conn</replaceable> is a connection to the server, <replaceable>conn</replaceable> is a connection to the server,
and <replaceable>encoding</replaceable> is the encoding you want to and <replaceable>encoding</replaceable> is the encoding you want to
...@@ -4890,15 +4889,16 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -4890,15 +4889,16 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<para> <para>
Determines the verbosity of messages returned by Determines the verbosity of messages returned by
<function>PQerrorMessage</> and <function>PQresultErrorMessage</>. <function>PQerrorMessage</> and <function>PQresultErrorMessage</>.
<synopsis> <synopsis>
typedef enum { typedef enum
{
PQERRORS_TERSE, PQERRORS_TERSE,
PQERRORS_DEFAULT, PQERRORS_DEFAULT,
PQERRORS_VERBOSE PQERRORS_VERBOSE
} PGVerbosity; } PGVerbosity;
PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity); PGVerbosity PQsetErrorVerbosity(PGconn *conn, PGVerbosity verbosity);
</synopsis> </synopsis>
<function>PQsetErrorVerbosity</> sets the verbosity mode, returning <function>PQsetErrorVerbosity</> sets the verbosity mode, returning
the connection's previous setting. In <firstterm>TERSE</> mode, the connection's previous setting. In <firstterm>TERSE</> mode,
...@@ -4924,9 +4924,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -4924,9 +4924,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Enables tracing of the client/server communication to a debugging file stream. Enables tracing of the client/server communication to a debugging file stream.
<synopsis> <synopsis>
void PQtrace(PGconn *conn, FILE *stream); void PQtrace(PGconn *conn, FILE *stream);
</synopsis> </synopsis>
</para> </para>
<note> <note>
...@@ -4954,9 +4954,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -4954,9 +4954,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Disables tracing started by <function>PQtrace</function>. Disables tracing started by <function>PQtrace</function>.
<synopsis> <synopsis>
void PQuntrace(PGconn *conn); void PQuntrace(PGconn *conn);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -4983,9 +4983,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -4983,9 +4983,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Frees memory allocated by <application>libpq</>. Frees memory allocated by <application>libpq</>.
<synopsis> <synopsis>
void PQfreemem(void *ptr); void PQfreemem(void *ptr);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5017,9 +5017,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5017,9 +5017,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<para> <para>
Frees the data structures allocated by Frees the data structures allocated by
<function>PQconndefaults</> or <function>PQconninfoParse</>. <function>PQconndefaults</> or <function>PQconninfoParse</>.
<synopsis> <synopsis>
void PQconninfoFree(PQconninfoOption *connOptions); void PQconninfoFree(PQconninfoOption *connOptions);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5040,9 +5040,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5040,9 +5040,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Prepares the encrypted form of a <productname>PostgreSQL</> password. Prepares the encrypted form of a <productname>PostgreSQL</> password.
<synopsis> <synopsis>
char * PQencryptPassword(const char *passwd, const char *user); char * PQencryptPassword(const char *passwd, const char *user);
</synopsis> </synopsis>
This function is intended to be used by client applications that This function is intended to be used by client applications that
wish to send commands like <literal>ALTER USER joe PASSWORD wish to send commands like <literal>ALTER USER joe PASSWORD
'pwd'</>. It is good practice not to send the original cleartext 'pwd'</>. It is good practice not to send the original cleartext
...@@ -5070,9 +5070,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5070,9 +5070,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Constructs an empty <structname>PGresult</structname> object with the given status. Constructs an empty <structname>PGresult</structname> object with the given status.
<synopsis> <synopsis>
PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status); PGresult *PQmakeEmptyPGresult(PGconn *conn, ExecStatusType status);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5110,9 +5110,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5110,9 +5110,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<structname>PGresult</structname> object. Returns non-zero for success, <structname>PGresult</structname> object. Returns non-zero for success,
zero if any event procedure fails. zero if any event procedure fails.
<synopsis> <synopsis>
int PQfireResultCreateEvents(PGconn *conn, PGresult *res); int PQfireResultCreateEvents(PGconn *conn, PGresult *res);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5151,9 +5151,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5151,9 +5151,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<function>PQclear</function> must be called when the copy is no longer <function>PQclear</function> must be called when the copy is no longer
needed. If the function fails, NULL is returned. needed. If the function fails, NULL is returned.
<synopsis> <synopsis>
PGresult *PQcopyResult(const PGresult *src, int flags); PGresult *PQcopyResult(const PGresult *src, int flags);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5186,9 +5186,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5186,9 +5186,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Sets the attributes of a <structname>PGresult</structname> object. Sets the attributes of a <structname>PGresult</structname> object.
<synopsis> <synopsis>
int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs); int PQsetResultAttrs(PGresult *res, int numAttributes, PGresAttDesc *attDescs);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5214,9 +5214,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5214,9 +5214,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Sets a tuple field value of a <structname>PGresult</structname> object. Sets a tuple field value of a <structname>PGresult</structname> object.
<synopsis> <synopsis>
int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len); int PQsetvalue(PGresult *res, int tup_num, int field_num, char *value, int len);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5248,9 +5248,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5248,9 +5248,9 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<listitem> <listitem>
<para> <para>
Allocate subsidiary storage for a <structname>PGresult</structname> object. Allocate subsidiary storage for a <structname>PGresult</structname> object.
<synopsis> <synopsis>
void *PQresultAlloc(PGresult *res, size_t nBytes); void *PQresultAlloc(PGresult *res, size_t nBytes);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5304,21 +5304,21 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5304,21 +5304,21 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
processor</></><indexterm><primary>PQsetNoticeProcessor</></> sets or processor</></><indexterm><primary>PQsetNoticeProcessor</></> sets or
examines the current notice processor. examines the current notice processor.
<synopsis> <synopsis>
typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res); typedef void (*PQnoticeReceiver) (void *arg, const PGresult *res);
PQnoticeReceiver PQnoticeReceiver
PQsetNoticeReceiver(PGconn *conn, PQsetNoticeReceiver(PGconn *conn,
PQnoticeReceiver proc, PQnoticeReceiver proc,
void *arg); void *arg);
typedef void (*PQnoticeProcessor) (void *arg, const char *message); typedef void (*PQnoticeProcessor) (void *arg, const char *message);
PQnoticeProcessor PQnoticeProcessor
PQsetNoticeProcessor(PGconn *conn, PQsetNoticeProcessor(PGconn *conn,
PQnoticeProcessor proc, PQnoticeProcessor proc,
void *arg); void *arg);
</synopsis> </synopsis>
Each of these functions returns the previous notice receiver or Each of these functions returns the previous notice receiver or
processor function pointer, and sets the new value. If you supply a processor function pointer, and sets the new value. If you supply a
...@@ -5355,7 +5355,7 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>); ...@@ -5355,7 +5355,7 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
<para> <para>
The default notice processor is simply: The default notice processor is simply:
<programlisting> <programlisting>
static void static void
defaultNoticeProcessor(void *arg, const char *message) defaultNoticeProcessor(void *arg, const char *message)
{ {
...@@ -5434,12 +5434,12 @@ defaultNoticeProcessor(void *arg, const char *message) ...@@ -5434,12 +5434,12 @@ defaultNoticeProcessor(void *arg, const char *message)
register event will be fired per event handler per connection. If the register event will be fired per event handler per connection. If the
event procedure fails, the registration is aborted. event procedure fails, the registration is aborted.
<synopsis> <synopsis>
typedef struct typedef struct
{ {
PGconn *conn; PGconn *conn;
} PGEventRegister; } PGEventRegister;
</synopsis> </synopsis>
When a <literal>PGEVT_REGISTER</literal> event is received, the When a <literal>PGEVT_REGISTER</literal> event is received, the
<parameter>evtInfo</parameter> pointer should be cast to a <parameter>evtInfo</parameter> pointer should be cast to a
...@@ -5467,12 +5467,12 @@ typedef struct ...@@ -5467,12 +5467,12 @@ typedef struct
<function>PQresetPoll</function> will return <function>PQresetPoll</function> will return
<literal>PGRES_POLLING_FAILED</literal>. <literal>PGRES_POLLING_FAILED</literal>.
<synopsis> <synopsis>
typedef struct typedef struct
{ {
PGconn *conn; PGconn *conn;
} PGEventConnReset; } PGEventConnReset;
</synopsis> </synopsis>
When a <literal>PGEVT_CONNRESET</literal> event is received, the When a <literal>PGEVT_CONNRESET</literal> event is received, the
<parameter>evtInfo</parameter> pointer should be cast to a <parameter>evtInfo</parameter> pointer should be cast to a
...@@ -5497,12 +5497,12 @@ typedef struct ...@@ -5497,12 +5497,12 @@ typedef struct
ability to manage this memory. Failure to clean up will lead ability to manage this memory. Failure to clean up will lead
to memory leaks. to memory leaks.
<synopsis> <synopsis>
typedef struct typedef struct
{ {
PGconn *conn; PGconn *conn;
} PGEventConnDestroy; } PGEventConnDestroy;
</synopsis> </synopsis>
When a <literal>PGEVT_CONNDESTROY</literal> event is received, the When a <literal>PGEVT_CONNDESTROY</literal> event is received, the
<parameter>evtInfo</parameter> pointer should be cast to a <parameter>evtInfo</parameter> pointer should be cast to a
...@@ -5525,13 +5525,13 @@ typedef struct ...@@ -5525,13 +5525,13 @@ typedef struct
<function>PQgetResult</function>. This event will only be fired after <function>PQgetResult</function>. This event will only be fired after
the result has been created successfully. the result has been created successfully.
<synopsis> <synopsis>
typedef struct typedef struct
{ {
PGconn *conn; PGconn *conn;
PGresult *result; PGresult *result;
} PGEventResultCreate; } PGEventResultCreate;
</synopsis> </synopsis>
When a <literal>PGEVT_RESULTCREATE</literal> event is received, the When a <literal>PGEVT_RESULTCREATE</literal> event is received, the
<parameter>evtInfo</parameter> pointer should be cast to a <parameter>evtInfo</parameter> pointer should be cast to a
...@@ -5559,13 +5559,13 @@ typedef struct ...@@ -5559,13 +5559,13 @@ typedef struct
or <literal>PGEVT_RESULTCOPY</literal> event for the source result or <literal>PGEVT_RESULTCOPY</literal> event for the source result
will receive <literal>PGEVT_RESULTCOPY</literal> events. will receive <literal>PGEVT_RESULTCOPY</literal> events.
<synopsis> <synopsis>
typedef struct typedef struct
{ {
const PGresult *src; const PGresult *src;
PGresult *dest; PGresult *dest;
} PGEventResultCopy; } PGEventResultCopy;
</synopsis> </synopsis>
When a <literal>PGEVT_RESULTCOPY</literal> event is received, the When a <literal>PGEVT_RESULTCOPY</literal> event is received, the
<parameter>evtInfo</parameter> pointer should be cast to a <parameter>evtInfo</parameter> pointer should be cast to a
...@@ -5593,12 +5593,12 @@ typedef struct ...@@ -5593,12 +5593,12 @@ typedef struct
ability to manage this memory. Failure to clean up will lead ability to manage this memory. Failure to clean up will lead
to memory leaks. to memory leaks.
<synopsis> <synopsis>
typedef struct typedef struct
{ {
PGresult *result; PGresult *result;
} PGEventResultDestroy; } PGEventResultDestroy;
</synopsis> </synopsis>
When a <literal>PGEVT_RESULTDESTROY</literal> event is received, the When a <literal>PGEVT_RESULTDESTROY</literal> event is received, the
<parameter>evtInfo</parameter> pointer should be cast to a <parameter>evtInfo</parameter> pointer should be cast to a
...@@ -5632,9 +5632,9 @@ typedef struct ...@@ -5632,9 +5632,9 @@ typedef struct
event procedure, that is, the user callback function that receives event procedure, that is, the user callback function that receives
events from libpq. The signature of an event procedure must be events from libpq. The signature of an event procedure must be
<synopsis> <synopsis>
int eventproc(PGEventId evtId, void *evtInfo, void *passThrough) int eventproc(PGEventId evtId, void *evtInfo, void *passThrough)
</synopsis> </synopsis>
The <parameter>evtId</parameter> parameter indicates which The <parameter>evtId</parameter> parameter indicates which
<literal>PGEVT</literal> event occurred. The <literal>PGEVT</literal> event occurred. The
...@@ -5685,10 +5685,10 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough) ...@@ -5685,10 +5685,10 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough)
<para> <para>
Registers an event callback procedure with libpq. Registers an event callback procedure with libpq.
<synopsis> <synopsis>
int PQregisterEventProc(PGconn *conn, PGEventProc proc, int PQregisterEventProc(PGconn *conn, PGEventProc proc,
const char *name, void *passThrough); const char *name, void *passThrough);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -5726,9 +5726,9 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough) ...@@ -5726,9 +5726,9 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough)
for success and zero for failure. (Failure is only possible if for success and zero for failure. (Failure is only possible if
the proc has not been properly registered in the conn.) the proc has not been properly registered in the conn.)
<synopsis> <synopsis>
int PQsetInstanceData(PGconn *conn, PGEventProc proc, void *data); int PQsetInstanceData(PGconn *conn, PGEventProc proc, void *data);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -5745,9 +5745,9 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough) ...@@ -5745,9 +5745,9 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough)
Returns the conn's instanceData associated with proc, or NULL Returns the conn's instanceData associated with proc, or NULL
if there is none. if there is none.
<synopsis> <synopsis>
void *PQinstanceData(const PGconn *conn, PGEventProc proc); void *PQinstanceData(const PGconn *conn, PGEventProc proc);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -5765,9 +5765,9 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough) ...@@ -5765,9 +5765,9 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough)
for success and zero for failure. (Failure is only possible if the for success and zero for failure. (Failure is only possible if the
proc has not been properly registered in the result.) proc has not been properly registered in the result.)
<synopsis> <synopsis>
int PQresultSetInstanceData(PGresult *res, PGEventProc proc, void *data); int PQresultSetInstanceData(PGresult *res, PGEventProc proc, void *data);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -5784,9 +5784,9 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough) ...@@ -5784,9 +5784,9 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough)
Returns the result's instanceData associated with proc, or NULL Returns the result's instanceData associated with proc, or NULL
if there is none. if there is none.
<synopsis> <synopsis>
void *PQresultInstanceData(const PGresult *res, PGEventProc proc); void *PQresultInstanceData(const PGresult *res, PGEventProc proc);
</synopsis> </synopsis>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -5801,7 +5801,7 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough) ...@@ -5801,7 +5801,7 @@ int eventproc(PGEventId evtId, void *evtInfo, void *passThrough)
libpq connections and results. libpq connections and results.
</para> </para>
<programlisting> <programlisting>
<![CDATA[ <![CDATA[
/* required header for libpq events (note: includes libpq-fe.h) */ /* required header for libpq events (note: includes libpq-fe.h) */
#include <libpq-events.h> #include <libpq-events.h>
...@@ -6313,9 +6313,9 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough) ...@@ -6313,9 +6313,9 @@ myEventProc(PGEventId evtId, void *evtInfo, void *passThrough)
<para> <para>
This file should contain lines of the following format: This file should contain lines of the following format:
<synopsis> <synopsis>
<replaceable>hostname</replaceable>:<replaceable>port</replaceable>:<replaceable>database</replaceable>:<replaceable>username</replaceable>:<replaceable>password</replaceable> <replaceable>hostname</replaceable>:<replaceable>port</replaceable>:<replaceable>database</replaceable>:<replaceable>username</replaceable>:<replaceable>password</replaceable>
</synopsis> </synopsis>
Each of the first four fields can be a literal value, or Each of the first four fields can be a literal value, or
<literal>*</literal>, which matches anything. The password field from <literal>*</literal>, which matches anything. The password field from
the first line that matches the current connection parameters will be the first line that matches the current connection parameters will be
...@@ -6418,9 +6418,9 @@ user=admin ...@@ -6418,9 +6418,9 @@ user=admin
<literal>keyword = value</literal> pairs which will be used to set <literal>keyword = value</literal> pairs which will be used to set
connection options. The URL must conform to RFC 1959 and be of the connection options. The URL must conform to RFC 1959 and be of the
form form
<synopsis> <synopsis>
ldap://[<replaceable>hostname</replaceable>[:<replaceable>port</replaceable>]]/<replaceable>search_base</replaceable>?<replaceable>attribute</replaceable>?<replaceable>search_scope</replaceable>?<replaceable>filter</replaceable> ldap://[<replaceable>hostname</replaceable>[:<replaceable>port</replaceable>]]/<replaceable>search_base</replaceable>?<replaceable>attribute</replaceable>?<replaceable>search_scope</replaceable>?<replaceable>filter</replaceable>
</synopsis> </synopsis>
where <replaceable>hostname</replaceable> defaults to where <replaceable>hostname</replaceable> defaults to
<literal>localhost</literal> and <replaceable>port</replaceable> <literal>localhost</literal> and <replaceable>port</replaceable>
defaults to 389. defaults to 389.
...@@ -6438,36 +6438,36 @@ user=admin ...@@ -6438,36 +6438,36 @@ user=admin
<para> <para>
A sample LDAP entry that has been created with the LDIF file A sample LDAP entry that has been created with the LDIF file
<synopsis> <programlisting>
version:1 version:1
dn:cn=mydatabase,dc=mycompany,dc=com dn:cn=mydatabase,dc=mycompany,dc=com
changetype:add changetype:add
objectclass:top objectclass:top
objectclass:groupOfUniqueNames objectclass:groupOfUniqueNames
cn:mydatabase cn:mydatabase
uniqueMember:host=dbserver.mycompany.com uniqueMember:host=dbserver.mycompany.com
uniqueMember:port=5439 uniqueMember:port=5439
uniqueMember:dbname=mydb uniqueMember:dbname=mydb
uniqueMember:user=mydb_user uniqueMember:user=mydb_user
uniqueMember:sslmode=require uniqueMember:sslmode=require
</synopsis> </programlisting>
might be queried with the following LDAP URL: might be queried with the following LDAP URL:
<synopsis> <programlisting>
ldap://ldap.mycompany.com/dc=mycompany,dc=com?uniqueMember?one?(cn=mydatabase) ldap://ldap.mycompany.com/dc=mycompany,dc=com?uniqueMember?one?(cn=mydatabase)
</synopsis> </programlisting>
</para> </para>
<para> <para>
You can also mix regular service file entries with LDAP lookups. You can also mix regular service file entries with LDAP lookups.
A complete example for a stanza in <filename>pg_service.conf</filename> A complete example for a stanza in <filename>pg_service.conf</filename>
would be: would be:
<synopsis> <programlisting>
# only host and port are stored in LDAP, specify dbname and user explicitly # only host and port are stored in LDAP, specify dbname and user explicitly
[customerdb] [customerdb]
dbname=customer dbname=customer
user=appuser user=appuser
ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*) ldap://ldap.acme.com/cn=dbserver,cn=hosts?pgconnectinfo?base?(objectclass=*)
</synopsis> </programlisting>
</para> </para>
</sect1> </sect1>
...@@ -6844,9 +6844,9 @@ user=admin ...@@ -6844,9 +6844,9 @@ user=admin
<listitem> <listitem>
<para> <para>
Allows applications to select which security libraries to initialize. Allows applications to select which security libraries to initialize.
<synopsis> <synopsis>
void PQinitOpenSSL(int do_ssl, int do_crypto); void PQinitOpenSSL(int do_ssl, int do_crypto);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -6880,9 +6880,9 @@ user=admin ...@@ -6880,9 +6880,9 @@ user=admin
<listitem> <listitem>
<para> <para>
Allows applications to select which security libraries to initialize. Allows applications to select which security libraries to initialize.
<synopsis> <synopsis>
void PQinitSSL(int do_ssl); void PQinitSSL(int do_ssl);
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -6940,9 +6940,9 @@ user=admin ...@@ -6940,9 +6940,9 @@ user=admin
<para> <para>
Returns the thread safety status of the Returns the thread safety status of the
<application>libpq</application> library. <application>libpq</application> library.
<synopsis> <synopsis>
int PQisthreadsafe(); int PQisthreadsafe();
</synopsis> </synopsis>
</para> </para>
<para> <para>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/lo.sgml,v 1.3 2007/12/06 04:12:10 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/lo.sgml,v 1.4 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="lo"> <sect1 id="lo">
<title>lo</title> <title>lo</title>
...@@ -66,12 +66,12 @@ ...@@ -66,12 +66,12 @@
Here's a simple example of usage: Here's a simple example of usage:
</para> </para>
<programlisting> <programlisting>
CREATE TABLE image (title TEXT, raster lo); CREATE TABLE image (title TEXT, raster lo);
CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image CREATE TRIGGER t_raster BEFORE UPDATE OR DELETE ON image
FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster); FOR EACH ROW EXECUTE PROCEDURE lo_manage(raster);
</programlisting> </programlisting>
<para> <para>
For each column that will contain unique references to large objects, For each column that will contain unique references to large objects,
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/ltree.sgml,v 1.4 2010/03/17 17:12:31 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/ltree.sgml,v 1.5 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="ltree"> <sect1 id="ltree">
<title>ltree</title> <title>ltree</title>
...@@ -58,32 +58,32 @@ ...@@ -58,32 +58,32 @@
for matching <type>ltree</> values. A simple word matches that for matching <type>ltree</> values. A simple word matches that
label within a path. A star symbol (<literal>*</>) matches zero label within a path. A star symbol (<literal>*</>) matches zero
or more labels. For example: or more labels. For example:
<programlisting> <synopsis>
foo <lineannotation>Match the exact label path <literal>foo</></lineannotation> foo <lineannotation>Match the exact label path <literal>foo</></lineannotation>
*.foo.* <lineannotation>Match any label path containing the label <literal>foo</></lineannotation> *.foo.* <lineannotation>Match any label path containing the label <literal>foo</></lineannotation>
*.foo <lineannotation>Match any label path whose last label is <literal>foo</></lineannotation> *.foo <lineannotation>Match any label path whose last label is <literal>foo</></lineannotation>
</programlisting> </synopsis>
</para> </para>
<para> <para>
Star symbols can also be quantified to restrict how many labels Star symbols can also be quantified to restrict how many labels
they can match: they can match:
<programlisting> <synopsis>
*{<replaceable>n</>} <lineannotation>Match exactly <replaceable>n</> labels</lineannotation> *{<replaceable>n</>} <lineannotation>Match exactly <replaceable>n</> labels</lineannotation>
*{<replaceable>n</>,} <lineannotation>Match at least <replaceable>n</> labels</lineannotation> *{<replaceable>n</>,} <lineannotation>Match at least <replaceable>n</> labels</lineannotation>
*{<replaceable>n</>,<replaceable>m</>} <lineannotation>Match at least <replaceable>n</> but not more than <replaceable>m</> labels</lineannotation> *{<replaceable>n</>,<replaceable>m</>} <lineannotation>Match at least <replaceable>n</> but not more than <replaceable>m</> labels</lineannotation>
*{,<replaceable>m</>} <lineannotation>Match at most <replaceable>m</> labels &mdash; same as </lineannotation> *{0,<replaceable>m</>} *{,<replaceable>m</>} <lineannotation>Match at most <replaceable>m</> labels &mdash; same as </lineannotation> *{0,<replaceable>m</>}
</programlisting> </synopsis>
</para> </para>
<para> <para>
There are several modifiers that can be put at the end of a non-star There are several modifiers that can be put at the end of a non-star
label in <type>lquery</> to make it match more than just the exact match: label in <type>lquery</> to make it match more than just the exact match:
<programlisting> <synopsis>
@ <lineannotation>Match case-insensitively, for example <literal>a@</> matches <literal>A</></lineannotation> @ <lineannotation>Match case-insensitively, for example <literal>a@</> matches <literal>A</></lineannotation>
* <lineannotation>Match any label with this prefix, for example <literal>foo*</> matches <literal>foobar</></lineannotation> * <lineannotation>Match any label with this prefix, for example <literal>foo*</> matches <literal>foobar</></lineannotation>
% <lineannotation>Match initial underscore-separated words</lineannotation> % <lineannotation>Match initial underscore-separated words</lineannotation>
</programlisting> </synopsis>
The behavior of <literal>%</> is a bit complicated. It tries to match The behavior of <literal>%</> is a bit complicated. It tries to match
words rather than the entire label. For example words rather than the entire label. For example
<literal>foo_bar%</> matches <literal>foo_bar_baz</> but not <literal>foo_bar%</> matches <literal>foo_bar_baz</> but not
...@@ -102,10 +102,10 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno ...@@ -102,10 +102,10 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno
<para> <para>
Here's an annotated example of <type>lquery</type>: Here's an annotated example of <type>lquery</type>:
<programlisting> <programlisting>
Top.*{0,2}.sport*@.!football|tennis.Russ*|Spain Top.*{0,2}.sport*@.!football|tennis.Russ*|Spain
a. b. c. d. e. a. b. c. d. e.
</programlisting> </programlisting>
This query will match any label path that: This query will match any label path that:
</para> </para>
<orderedlist numeration='loweralpha'> <orderedlist numeration='loweralpha'>
...@@ -154,9 +154,9 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno ...@@ -154,9 +154,9 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno
<para> <para>
Here's an example <type>ltxtquery</type>: Here's an example <type>ltxtquery</type>:
<programlisting> <programlisting>
Europe &amp; Russia*@ &amp; !Transportation Europe &amp; Russia*@ &amp; !Transportation
</programlisting> </programlisting>
This will match paths that contain the label <literal>Europe</literal> and This will match paths that contain the label <literal>Europe</literal> and
any label beginning with <literal>Russia</literal> (case-insensitive), any label beginning with <literal>Russia</literal> (case-insensitive),
but not paths containing the label <literal>Transportation</literal>. but not paths containing the label <literal>Transportation</literal>.
...@@ -504,9 +504,9 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno ...@@ -504,9 +504,9 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno
<para> <para>
Example of creating such an index: Example of creating such an index:
</para> </para>
<programlisting> <programlisting>
CREATE INDEX path_gist_idx ON test USING GIST (path); CREATE INDEX path_gist_idx ON test USING GIST (path);
</programlisting> </programlisting>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
...@@ -517,9 +517,9 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno ...@@ -517,9 +517,9 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno
<para> <para>
Example of creating such an index: Example of creating such an index:
</para> </para>
<programlisting> <programlisting>
CREATE INDEX path_gist_idx ON test USING GIST (array_path); CREATE INDEX path_gist_idx ON test USING GIST (array_path);
</programlisting> </programlisting>
<para> <para>
Note: This index type is lossy. Note: This index type is lossy.
</para> </para>
...@@ -535,7 +535,7 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno ...@@ -535,7 +535,7 @@ foo <lineannotation>Match the exact label path <literal>foo</></lineanno
<filename>contrib/ltree/ltreetest.sql</> in the source distribution): <filename>contrib/ltree/ltreetest.sql</> in the source distribution):
</para> </para>
<programlisting> <programlisting>
CREATE TABLE test (path ltree); CREATE TABLE test (path ltree);
INSERT INTO test VALUES ('Top'); INSERT INTO test VALUES ('Top');
INSERT INTO test VALUES ('Top.Science'); INSERT INTO test VALUES ('Top.Science');
...@@ -552,31 +552,29 @@ INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Galaxies'); ...@@ -552,31 +552,29 @@ INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Galaxies');
INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Astronauts'); INSERT INTO test VALUES ('Top.Collections.Pictures.Astronomy.Astronauts');
CREATE INDEX path_gist_idx ON test USING gist(path); CREATE INDEX path_gist_idx ON test USING gist(path);
CREATE INDEX path_idx ON test USING btree(path); CREATE INDEX path_idx ON test USING btree(path);
</programlisting> </programlisting>
<para> <para>
Now, we have a table <structname>test</> populated with data describing Now, we have a table <structname>test</> populated with data describing
the hierarchy shown below: the hierarchy shown below:
</para> </para>
<programlisting> <literallayout class="monospaced">
Top Top
/ | \ / | \
Science Hobbies Collections Science Hobbies Collections
/ | \ / | \
Astronomy Amateurs_Astronomy Pictures Astronomy Amateurs_Astronomy Pictures
/ \ | / \ |
Astrophysics Cosmology Astronomy Astrophysics Cosmology Astronomy
/ | \ / | \
Galaxies Stars Astronauts Galaxies Stars Astronauts
</programlisting> </literallayout>
<para> <para>
We can do inheritance: We can do inheritance:
</para> <screen>
ltreetest=&gt; SELECT path FROM test WHERE path &lt;@ 'Top.Science';
<programlisting>
ltreetest=# select path from test where path &lt;@ 'Top.Science';
path path
------------------------------------ ------------------------------------
Top.Science Top.Science
...@@ -584,14 +582,13 @@ ltreetest=# select path from test where path &lt;@ 'Top.Science'; ...@@ -584,14 +582,13 @@ ltreetest=# select path from test where path &lt;@ 'Top.Science';
Top.Science.Astronomy.Astrophysics Top.Science.Astronomy.Astrophysics
Top.Science.Astronomy.Cosmology Top.Science.Astronomy.Cosmology
(4 rows) (4 rows)
</programlisting> </screen>
</para>
<para> <para>
Here are some examples of path matching: Here are some examples of path matching:
</para> <screen>
ltreetest=&gt; SELECT path FROM test WHERE path ~ '*.Astronomy.*';
<programlisting>
ltreetest=# select path from test where path ~ '*.Astronomy.*';
path path
----------------------------------------------- -----------------------------------------------
Top.Science.Astronomy Top.Science.Astronomy
...@@ -603,20 +600,20 @@ ltreetest=# select path from test where path ~ '*.Astronomy.*'; ...@@ -603,20 +600,20 @@ ltreetest=# select path from test where path ~ '*.Astronomy.*';
Top.Collections.Pictures.Astronomy.Astronauts Top.Collections.Pictures.Astronomy.Astronauts
(7 rows) (7 rows)
ltreetest=# select path from test where path ~ '*.!pictures@.*.Astronomy.*'; ltreetest=&gt; SELECT path FROM test WHERE path ~ '*.!pictures@.*.Astronomy.*';
path path
------------------------------------ ------------------------------------
Top.Science.Astronomy Top.Science.Astronomy
Top.Science.Astronomy.Astrophysics Top.Science.Astronomy.Astrophysics
Top.Science.Astronomy.Cosmology Top.Science.Astronomy.Cosmology
(3 rows) (3 rows)
</programlisting> </screen>
</para>
<para> <para>
Here are some examples of full text search: Here are some examples of full text search:
</para> <screen>
<programlisting> ltreetest=&gt; SELECT path FROM test WHERE path @ 'Astro*% &amp; !pictures@';
ltreetest=# select path from test where path @ 'Astro*% &amp; !pictures@';
path path
------------------------------------ ------------------------------------
Top.Science.Astronomy Top.Science.Astronomy
...@@ -625,45 +622,46 @@ ltreetest=# select path from test where path @ 'Astro*% &amp; !pictures@'; ...@@ -625,45 +622,46 @@ ltreetest=# select path from test where path @ 'Astro*% &amp; !pictures@';
Top.Hobbies.Amateurs_Astronomy Top.Hobbies.Amateurs_Astronomy
(4 rows) (4 rows)
ltreetest=# select path from test where path @ 'Astro* &amp; !pictures@'; ltreetest=&gt; SELECT path FROM test WHERE path @ 'Astro* &amp; !pictures@';
path path
------------------------------------ ------------------------------------
Top.Science.Astronomy Top.Science.Astronomy
Top.Science.Astronomy.Astrophysics Top.Science.Astronomy.Astrophysics
Top.Science.Astronomy.Cosmology Top.Science.Astronomy.Cosmology
(3 rows) (3 rows)
</programlisting> </screen>
</para>
<para> <para>
Path construction using functions: Path construction using functions:
</para> <screen>
<programlisting> ltreetest=&gt; SELECT subpath(path,0,2)||'Space'||subpath(path,2) FROM test WHERE path &lt;@ 'Top.Science.Astronomy';
ltreetest=# select subpath(path,0,2)||'Space'||subpath(path,2) from test where path &lt;@ 'Top.Science.Astronomy';
?column? ?column?
------------------------------------------ ------------------------------------------
Top.Science.Space.Astronomy Top.Science.Space.Astronomy
Top.Science.Space.Astronomy.Astrophysics Top.Science.Space.Astronomy.Astrophysics
Top.Science.Space.Astronomy.Cosmology Top.Science.Space.Astronomy.Cosmology
(3 rows) (3 rows)
</programlisting> </screen>
</para>
<para> <para>
We could simplify this by creating a SQL function that inserts a label We could simplify this by creating a SQL function that inserts a label
at a specified position in a path: at a specified position in a path:
</para> <screen>
<programlisting>
CREATE FUNCTION ins_label(ltree, int, text) RETURNS ltree CREATE FUNCTION ins_label(ltree, int, text) RETURNS ltree
AS 'select subpath($1,0,$2) || $3 || subpath($1,$2);' AS 'select subpath($1,0,$2) || $3 || subpath($1,$2);'
LANGUAGE SQL IMMUTABLE; LANGUAGE SQL IMMUTABLE;
ltreetest=# select ins_label(path,2,'Space') from test where path &lt;@ 'Top.Science.Astronomy'; ltreetest=&gt; SELECT ins_label(path,2,'Space') FROM test WHERE path &lt;@ 'Top.Science.Astronomy';
ins_label ins_label
------------------------------------------ ------------------------------------------
Top.Science.Space.Astronomy Top.Science.Space.Astronomy
Top.Science.Space.Astronomy.Astrophysics Top.Science.Space.Astronomy.Astrophysics
Top.Science.Space.Astronomy.Cosmology Top.Science.Space.Astronomy.Cosmology
(3 rows) (3 rows)
</programlisting> </screen>
</para>
</sect2> </sect2>
<sect2> <sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.80 2010/04/26 19:56:55 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.81 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="monitoring"> <chapter id="monitoring">
<title>Monitoring Database Activity</title> <title>Monitoring Database Activity</title>
...@@ -1680,7 +1680,7 @@ Total time (ns) 2312105013 ...@@ -1680,7 +1680,7 @@ Total time (ns) 2312105013
<para> <para>
Add the probe definition to <filename>src/backend/utils/probes.d</>: Add the probe definition to <filename>src/backend/utils/probes.d</>:
<programlisting> <programlisting>
probe transaction__start(LocalTransactionId); probe transaction__start(LocalTransactionId);
</programlisting> </programlisting>
Note the use of the double underline in the probe name. In a DTrace Note the use of the double underline in the probe name. In a DTrace
script using the probe, the double underline needs to be replaced with a script using the probe, the double underline needs to be replaced with a
...@@ -1698,7 +1698,7 @@ Total time (ns) 2312105013 ...@@ -1698,7 +1698,7 @@ Total time (ns) 2312105013
in the source code. In this case, it looks like the following: in the source code. In this case, it looks like the following:
<programlisting> <programlisting>
TRACE_POSTGRESQL_TRANSACTION_START(vxid.localTransactionId); TRACE_POSTGRESQL_TRANSACTION_START(vxid.localTransactionId);
</programlisting> </programlisting>
</para> </para>
</step> </step>
...@@ -1748,7 +1748,7 @@ Total time (ns) 2312105013 ...@@ -1748,7 +1748,7 @@ Total time (ns) 2312105013
is actually enabled: is actually enabled:
<programlisting> <programlisting>
if (TRACE_POSTGRESQL_TRANSACTION_START_ENABLED()) if (TRACE_POSTGRESQL_TRANSACTION_START_ENABLED())
TRACE_POSTGRESQL_TRANSACTION_START(some_function(...)); TRACE_POSTGRESQL_TRANSACTION_START(some_function(...));
</programlisting> </programlisting>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/oid2name.sgml,v 1.8 2010/05/25 15:55:28 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/oid2name.sgml,v 1.9 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="oid2name"> <sect1 id="oid2name">
<title>oid2name</title> <title>oid2name</title>
...@@ -147,7 +147,7 @@ ...@@ -147,7 +147,7 @@
<sect2> <sect2>
<title>Examples</title> <title>Examples</title>
<programlisting> <screen>
$ # what's in this database server, anyway? $ # what's in this database server, anyway?
$ oid2name $ oid2name
All databases: All databases:
...@@ -264,7 +264,7 @@ From database "alvherre": ...@@ -264,7 +264,7 @@ From database "alvherre":
Filenode Table Name Filenode Table Name
---------------------- ----------------------
155156 foo 155156 foo
</programlisting> </screen>
</sect2> </sect2>
<sect2> <sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pageinspect.sgml,v 1.6 2009/06/08 16:22:44 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pageinspect.sgml,v 1.7 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pageinspect"> <sect1 id="pageinspect">
<title>pageinspect</title> <title>pageinspect</title>
...@@ -62,15 +62,12 @@ ...@@ -62,15 +62,12 @@
<para> <para>
A page image obtained with <function>get_raw_page</function> should be A page image obtained with <function>get_raw_page</function> should be
passed as argument. For example: passed as argument. For example:
</para> <screen>
<programlisting>
test=# SELECT * FROM page_header(get_raw_page('pg_class', 0)); test=# SELECT * FROM page_header(get_raw_page('pg_class', 0));
lsn | tli | flags | lower | upper | special | pagesize | version | prune_xid lsn | tli | flags | lower | upper | special | pagesize | version | prune_xid
-----------+-----+-------+-------+-------+---------+----------+---------+----------- -----------+-----+-------+-------+-------+---------+----------+---------+-----------
0/24A1B50 | 1 | 1 | 232 | 368 | 8192 | 8192 | 4 | 0 0/24A1B50 | 1 | 1 | 232 | 368 | 8192 | 8192 | 4 | 0
</programlisting> </screen>
<para>
The returned columns correspond to the fields in the The returned columns correspond to the fields in the
<structname>PageHeaderData</> struct. <structname>PageHeaderData</> struct.
See <filename>src/include/storage/bufpage.h</> for details. See <filename>src/include/storage/bufpage.h</> for details.
...@@ -93,11 +90,9 @@ test=# SELECT * FROM page_header(get_raw_page('pg_class', 0)); ...@@ -93,11 +90,9 @@ test=# SELECT * FROM page_header(get_raw_page('pg_class', 0));
<para> <para>
A heap page image obtained with <function>get_raw_page</function> should A heap page image obtained with <function>get_raw_page</function> should
be passed as argument. For example: be passed as argument. For example:
</para> <screen>
<programlisting>
test=# SELECT * FROM heap_page_items(get_raw_page('pg_class', 0)); test=# SELECT * FROM heap_page_items(get_raw_page('pg_class', 0));
</programlisting> </screen>
<para>
See <filename>src/include/storage/itemid.h</> and See <filename>src/include/storage/itemid.h</> and
<filename>src/include/access/htup.h</> for explanations of the fields <filename>src/include/access/htup.h</> for explanations of the fields
returned. returned.
...@@ -114,8 +109,7 @@ test=# SELECT * FROM heap_page_items(get_raw_page('pg_class', 0)); ...@@ -114,8 +109,7 @@ test=# SELECT * FROM heap_page_items(get_raw_page('pg_class', 0));
<para> <para>
<function>bt_metap</function> returns information about a btree <function>bt_metap</function> returns information about a btree
index's metapage. For example: index's metapage. For example:
</para> <screen>
<programlisting>
test=# SELECT * FROM bt_metap('pg_cast_oid_index'); test=# SELECT * FROM bt_metap('pg_cast_oid_index');
-[ RECORD 1 ]----- -[ RECORD 1 ]-----
magic | 340322 magic | 340322
...@@ -124,7 +118,8 @@ root | 1 ...@@ -124,7 +118,8 @@ root | 1
level | 0 level | 0
fastroot | 1 fastroot | 1
fastlevel | 0 fastlevel | 0
</programlisting> </screen>
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -137,8 +132,7 @@ fastlevel | 0 ...@@ -137,8 +132,7 @@ fastlevel | 0
<para> <para>
<function>bt_page_stats</function> returns summary information about <function>bt_page_stats</function> returns summary information about
single pages of btree indexes. For example: single pages of btree indexes. For example:
</para> <screen>
<programlisting>
test=# SELECT * FROM bt_page_stats('pg_cast_oid_index', 1); test=# SELECT * FROM bt_page_stats('pg_cast_oid_index', 1);
-[ RECORD 1 ]-+----- -[ RECORD 1 ]-+-----
blkno | 1 blkno | 1
...@@ -152,7 +146,8 @@ btpo_prev | 0 ...@@ -152,7 +146,8 @@ btpo_prev | 0
btpo_next | 0 btpo_next | 0
btpo | 0 btpo | 0
btpo_flags | 3 btpo_flags | 3
</programlisting> </screen>
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -165,8 +160,7 @@ btpo_flags | 3 ...@@ -165,8 +160,7 @@ btpo_flags | 3
<para> <para>
<function>bt_page_items</function> returns detailed information about <function>bt_page_items</function> returns detailed information about
all of the items on a btree index page. For example: all of the items on a btree index page. For example:
</para> <screen>
<programlisting>
test=# SELECT * FROM bt_page_items('pg_cast_oid_index', 1); test=# SELECT * FROM bt_page_items('pg_cast_oid_index', 1);
itemoffset | ctid | itemlen | nulls | vars | data itemoffset | ctid | itemlen | nulls | vars | data
------------+---------+---------+-------+------+------------- ------------+---------+---------+-------+------+-------------
...@@ -178,7 +172,8 @@ test=# SELECT * FROM bt_page_items('pg_cast_oid_index', 1); ...@@ -178,7 +172,8 @@ test=# SELECT * FROM bt_page_items('pg_cast_oid_index', 1);
6 | (0,6) | 12 | f | f | 28 27 00 00 6 | (0,6) | 12 | f | f | 28 27 00 00
7 | (0,7) | 12 | f | f | 29 27 00 00 7 | (0,7) | 12 | f | f | 29 27 00 00
8 | (0,8) | 12 | f | f | 2a 27 00 00 8 | (0,8) | 12 | f | f | 2a 27 00 00
</programlisting> </screen>
</para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgarchivecleanup.sgml,v 1.1 2010/06/14 17:25:24 sriggs Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgarchivecleanup.sgml,v 1.2 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgarchivecleanup"> <sect1 id="pgarchivecleanup">
<title>pg_archivecleanup</title> <title>pg_archivecleanup</title>
...@@ -38,11 +38,9 @@ ...@@ -38,11 +38,9 @@
To configure a standby To configure a standby
server to use <application>pg_archivecleanup</>, put this into its server to use <application>pg_archivecleanup</>, put this into its
<filename>recovery.conf</filename> configuration file: <filename>recovery.conf</filename> configuration file:
</para> <programlisting>
<programlisting>
archive_cleanup_command = 'pg_archivecleanup <replaceable>archiveDir</> %r' archive_cleanup_command = 'pg_archivecleanup <replaceable>archiveDir</> %r'
</programlisting> </programlisting>
<para>
where <replaceable>archiveDir</> is the directory from which WAL segment where <replaceable>archiveDir</> is the directory from which WAL segment
files should be restored. files should be restored.
</para> </para>
...@@ -58,11 +56,9 @@ archive_cleanup_command = 'pg_archivecleanup <replaceable>archiveDir</> %r' ...@@ -58,11 +56,9 @@ archive_cleanup_command = 'pg_archivecleanup <replaceable>archiveDir</> %r'
</para> </para>
<para> <para>
The full syntax of <application>pg_archivecleanup</>'s command line is The full syntax of <application>pg_archivecleanup</>'s command line is
</para> <synopsis>
<synopsis>
pg_archivecleanup <optional> <replaceable>option</> ... </optional> <replaceable>archivelocation</> <replaceable>restartwalfile</> pg_archivecleanup <optional> <replaceable>option</> ... </optional> <replaceable>archivelocation</> <replaceable>restartwalfile</>
</synopsis> </synopsis>
<para>
When used as a standalone program all WAL files logically preceding the When used as a standalone program all WAL files logically preceding the
<literal>restartwalfile</> will be removed <replaceable>archivelocation</>. <literal>restartwalfile</> will be removed <replaceable>archivelocation</>.
In this mode, if you specify a .backup filename, then only the file prefix In this mode, if you specify a .backup filename, then only the file prefix
...@@ -70,15 +66,13 @@ pg_archivecleanup <optional> <replaceable>option</> ... </optional> <replaceable ...@@ -70,15 +66,13 @@ pg_archivecleanup <optional> <replaceable>option</> ... </optional> <replaceable
all WAL files archived prior to a specific base backup without error. all WAL files archived prior to a specific base backup without error.
For example, the following example will remove all files older than For example, the following example will remove all files older than
WAL filename 000000010000003700000010: WAL filename 000000010000003700000010:
</para> <programlisting>
<programlisting>
pg_archivecleanup -d archive 000000010000003700000010.00000020.backup pg_archivecleanup -d archive 000000010000003700000010.00000020.backup
pg_archivecleanup: keep WAL files 000000010000003700000010 and later pg_archivecleanup: keep WAL files 000000010000003700000010 and later
pg_archivecleanup: removing "archive/00000001000000370000000F" pg_archivecleanup: removing "archive/00000001000000370000000F"
pg_archivecleanup: removing "archive/00000001000000370000000E" pg_archivecleanup: removing "archive/00000001000000370000000E"
</programlisting> </programlisting>
<para>
<application>pg_archivecleanup</application> assumes that <application>pg_archivecleanup</application> assumes that
<replaceable>archivelocation</> is a directory readable and writable by the <replaceable>archivelocation</> is a directory readable and writable by the
server-owning user. server-owning user.
...@@ -110,12 +104,10 @@ pg_archivecleanup: removing "archive/00000001000000370000000E" ...@@ -110,12 +104,10 @@ pg_archivecleanup: removing "archive/00000001000000370000000E"
<sect2> <sect2>
<title>Examples</title> <title>Examples</title>
<para>On Linux or Unix systems, you might use:</para> <para>On Linux or Unix systems, you might use:
<programlisting>
<programlisting>
archive_cleanup_command = 'pg_archivecleanup -d .../archive %r 2>>cleanup.log' archive_cleanup_command = 'pg_archivecleanup -d .../archive %r 2>>cleanup.log'
</programlisting> </programlisting>
<para>
where the archive directory is physically located on the standby server, where the archive directory is physically located on the standby server,
so that the <literal>archive_command</> is accessing it across NFS, so that the <literal>archive_command</> is accessing it across NFS,
but the files are local to the standby. but the files are local to the standby.
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgbench.sgml,v 1.16 2010/05/25 15:55:28 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgbench.sgml,v 1.17 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgbench"> <sect1 id="pgbench">
<title>pgbench</title> <title>pgbench</title>
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<para> <para>
Typical output from pgbench looks like: Typical output from pgbench looks like:
<programlisting> <screen>
transaction type: TPC-B (sort of) transaction type: TPC-B (sort of)
scaling factor: 10 scaling factor: 10
query mode: simple query mode: simple
...@@ -32,7 +32,7 @@ number of transactions per client: 1000 ...@@ -32,7 +32,7 @@ number of transactions per client: 1000
number of transactions actually processed: 10000/10000 number of transactions actually processed: 10000/10000
tps = 85.184871 (including connections establishing) tps = 85.184871 (including connections establishing)
tps = 85.296346 (excluding connections establishing) tps = 85.296346 (excluding connections establishing)
</programlisting> </screen>
The first six lines report some of the most important parameter The first six lines report some of the most important parameter
settings. The next line reports the number of transactions completed settings. The next line reports the number of transactions completed
...@@ -53,9 +53,9 @@ tps = 85.296346 (excluding connections establishing) ...@@ -53,9 +53,9 @@ tps = 85.296346 (excluding connections establishing)
step, but will instead need to do whatever setup your test needs.) step, but will instead need to do whatever setup your test needs.)
Initialization looks like: Initialization looks like:
<programlisting> <programlisting>
pgbench -i <optional> <replaceable>other-options</> </optional> <replaceable>dbname</> pgbench -i <optional> <replaceable>other-options</> </optional> <replaceable>dbname</>
</programlisting> </programlisting>
where <replaceable>dbname</> is the name of the already-created where <replaceable>dbname</> is the name of the already-created
database to test in. (You may also need <literal>-h</>, database to test in. (You may also need <literal>-h</>,
...@@ -77,16 +77,14 @@ pgbench -i <optional> <replaceable>other-options</> </optional> <replaceable>dbn ...@@ -77,16 +77,14 @@ pgbench -i <optional> <replaceable>other-options</> </optional> <replaceable>dbn
<para> <para>
At the default <quote>scale factor</> of 1, the tables initially At the default <quote>scale factor</> of 1, the tables initially
contain this many rows: contain this many rows:
</para> <screen>
<programlisting>
table # of rows table # of rows
--------------------------------- ---------------------------------
pgbench_branches 1 pgbench_branches 1
pgbench_tellers 10 pgbench_tellers 10
pgbench_accounts 100000 pgbench_accounts 100000
pgbench_history 0 pgbench_history 0
</programlisting> </screen>
<para>
You can (and, for most purposes, probably should) increase the number You can (and, for most purposes, probably should) increase the number
of rows by using the <literal>-s</> (scale factor) option. The of rows by using the <literal>-s</> (scale factor) option. The
<literal>-F</> (fillfactor) option might also be used at this point. <literal>-F</> (fillfactor) option might also be used at this point.
...@@ -96,9 +94,9 @@ pgbench_history 0 ...@@ -96,9 +94,9 @@ pgbench_history 0
Once you have done the necessary setup, you can run your benchmark Once you have done the necessary setup, you can run your benchmark
with a command that doesn't include <literal>-i</>, that is with a command that doesn't include <literal>-i</>, that is
<programlisting> <programlisting>
pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
</programlisting> </programlisting>
In nearly all cases, you'll need some options to make a useful test. In nearly all cases, you'll need some options to make a useful test.
The most important options are <literal>-c</> (number of clients), The most important options are <literal>-c</> (number of clients),
...@@ -478,9 +476,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -478,9 +476,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<para> <para>
Example: Example:
<programlisting> <programlisting>
\set ntellers 10 * :scale \set ntellers 10 * :scale
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -501,9 +499,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -501,9 +499,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<para> <para>
Example: Example:
<programlisting> <programlisting>
\setrandom aid 1 :naccounts \setrandom aid 1 :naccounts
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -525,9 +523,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -525,9 +523,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<para> <para>
Example: Example:
<programlisting> <programlisting>
\sleep 10 ms \sleep 10 ms
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -554,9 +552,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -554,9 +552,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<para> <para>
Example: Example:
<programlisting> <programlisting>
\setshell variable_to_be_assigned command literal_argument :variable ::literal_starting_with_colon \setshell variable_to_be_assigned command literal_argument :variable ::literal_starting_with_colon
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -573,9 +571,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -573,9 +571,9 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
<para> <para>
Example: Example:
<programlisting> <programlisting>
\shell command literal_argument :variable ::literal_starting_with_colon \shell command literal_argument :variable ::literal_starting_with_colon
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -585,7 +583,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</> ...@@ -585,7 +583,7 @@ pgbench <optional> <replaceable>options</> </optional> <replaceable>dbname</>
As an example, the full definition of the built-in TPC-B-like As an example, the full definition of the built-in TPC-B-like
transaction is: transaction is:
<programlisting> <programlisting>
\set nbranches :scale \set nbranches :scale
\set ntellers 10 * :scale \set ntellers 10 * :scale
\set naccounts 100000 * :scale \set naccounts 100000 * :scale
...@@ -600,7 +598,7 @@ UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid; ...@@ -600,7 +598,7 @@ UPDATE pgbench_tellers SET tbalance = tbalance + :delta WHERE tid = :tid;
UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid; UPDATE pgbench_branches SET bbalance = bbalance + :delta WHERE bid = :bid;
INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP); INSERT INTO pgbench_history (tid, bid, aid, delta, mtime) VALUES (:tid, :bid, :aid, :delta, CURRENT_TIMESTAMP);
END; END;
</programlisting> </programlisting>
This script allows each iteration of the transaction to reference This script allows each iteration of the transaction to reference
different, randomly-chosen rows. (This example also shows why it's different, randomly-chosen rows. (This example also shows why it's
...@@ -630,9 +628,9 @@ END; ...@@ -630,9 +628,9 @@ END;
<para> <para>
The format of the log is: The format of the log is:
<programlisting> <synopsis>
<replaceable>client_id</> <replaceable>transaction_no</> <replaceable>time</> <replaceable>file_no</> <replaceable>time_epoch</> <replaceable>time_us</> <replaceable>client_id</> <replaceable>transaction_no</> <replaceable>time</> <replaceable>file_no</> <replaceable>time_epoch</> <replaceable>time_us</>
</programlisting> </synopsis>
where <replaceable>time</> is the elapsed transaction time in microseconds, where <replaceable>time</> is the elapsed transaction time in microseconds,
<replaceable>file_no</> identifies which script file was used <replaceable>file_no</> identifies which script file was used
...@@ -646,12 +644,12 @@ END; ...@@ -646,12 +644,12 @@ END;
<para> <para>
Here are example outputs: Here are example outputs:
<programlisting> <screen>
0 199 2241 0 1175850568 995598 0 199 2241 0 1175850568 995598
0 200 2465 0 1175850568 998079 0 200 2465 0 1175850568 998079
0 201 2513 0 1175850569 608 0 201 2513 0 1175850569 608
0 202 2038 0 1175850569 2663 0 202 2038 0 1175850569 2663
</programlisting> </screen>
</para> </para>
</sect2> </sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgbuffercache.sgml,v 2.6 2010/02/07 20:48:09 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgbuffercache.sgml,v 2.7 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgbuffercache"> <sect1 id="pgbuffercache">
<title>pg_buffercache</title> <title>pg_buffercache</title>
...@@ -134,8 +134,8 @@ ...@@ -134,8 +134,8 @@
<sect2> <sect2>
<title>Sample output</title> <title>Sample output</title>
<programlisting> <screen>
regression=# SELECT c.relname, count(*) AS buffers regression=# SELECT c.relname, count(*) AS buffers
FROM pg_buffercache b INNER JOIN pg_class c FROM pg_buffercache b INNER JOIN pg_class c
ON b.relfilenode = pg_relation_filenode(c.oid) AND ON b.relfilenode = pg_relation_filenode(c.oid) AND
b.reldatabase IN (0, (SELECT oid FROM pg_database b.reldatabase IN (0, (SELECT oid FROM pg_database
...@@ -143,8 +143,9 @@ ...@@ -143,8 +143,9 @@
GROUP BY c.relname GROUP BY c.relname
ORDER BY 2 DESC ORDER BY 2 DESC
LIMIT 10; LIMIT 10;
relname | buffers relname | buffers
---------------------------------+--------- ---------------------------------+---------
tenk2 | 345 tenk2 | 345
tenk1 | 141 tenk1 | 141
pg_proc | 46 pg_proc | 46
...@@ -155,8 +156,8 @@ ...@@ -155,8 +156,8 @@
pg_attribute_relid_attnam_index | 26 pg_attribute_relid_attnam_index | 26
pg_depend | 22 pg_depend | 22
pg_depend_reference_index | 20 pg_depend_reference_index | 20
(10 rows) (10 rows)
</programlisting> </screen>
</sect2> </sect2>
<sect2> <sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgcrypto.sgml,v 1.9 2010/06/29 22:29:14 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgcrypto.sgml,v 1.10 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgcrypto"> <sect1 id="pgcrypto">
<title>pgcrypto</title> <title>pgcrypto</title>
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
<sect3> <sect3>
<title><function>digest()</function></title> <title><function>digest()</function></title>
<synopsis> <synopsis>
digest(data text, type text) returns bytea digest(data text, type text) returns bytea
digest(data bytea, type text) returns bytea digest(data bytea, type text) returns bytea
</synopsis> </synopsis>
<para> <para>
Computes a binary hash of the given <parameter>data</>. Computes a binary hash of the given <parameter>data</>.
...@@ -37,21 +37,21 @@ ...@@ -37,21 +37,21 @@
<para> <para>
If you want the digest as a hexadecimal string, use If you want the digest as a hexadecimal string, use
<function>encode()</> on the result. For example: <function>encode()</> on the result. For example:
</para> <programlisting>
<programlisting> CREATE OR REPLACE FUNCTION sha1(bytea) returns text AS $$
CREATE OR REPLACE FUNCTION sha1(bytea) returns text AS $$
SELECT encode(digest($1, 'sha1'), 'hex') SELECT encode(digest($1, 'sha1'), 'hex')
$$ LANGUAGE SQL STRICT IMMUTABLE; $$ LANGUAGE SQL STRICT IMMUTABLE;
</programlisting> </programlisting>
</para>
</sect3> </sect3>
<sect3> <sect3>
<title><function>hmac()</function></title> <title><function>hmac()</function></title>
<synopsis> <synopsis>
hmac(data text, key text, type text) returns bytea hmac(data text, key text, type text) returns bytea
hmac(data bytea, key text, type text) returns bytea hmac(data bytea, key text, type text) returns bytea
</synopsis> </synopsis>
<para> <para>
Calculates hashed MAC for <parameter>data</> with key <parameter>key</>. Calculates hashed MAC for <parameter>data</> with key <parameter>key</>.
...@@ -163,9 +163,9 @@ ...@@ -163,9 +163,9 @@
<sect3> <sect3>
<title><function>crypt()</></title> <title><function>crypt()</></title>
<synopsis> <synopsis>
crypt(password text, salt text) returns text crypt(password text, salt text) returns text
</synopsis> </synopsis>
<para> <para>
Calculates a crypt(3)-style hash of <parameter>password</>. Calculates a crypt(3)-style hash of <parameter>password</>.
...@@ -176,17 +176,15 @@ ...@@ -176,17 +176,15 @@
</para> </para>
<para> <para>
Example of setting a new password: Example of setting a new password:
<programlisting>
UPDATE ... SET pswhash = crypt('new password', gen_salt('md5'));
</programlisting>
</para> </para>
<programlisting>
UPDATE ... SET pswhash = crypt('new password', gen_salt('md5'));
</programlisting>
<para> <para>
Example of authentication: Example of authentication:
</para> <programlisting>
<programlisting> SELECT pswhash = crypt('entered password', pswhash) FROM ... ;
SELECT pswhash = crypt('entered password', pswhash) FROM ... ; </programlisting>
</programlisting>
<para>
This returns <literal>true</> if the entered password is correct. This returns <literal>true</> if the entered password is correct.
</para> </para>
</sect3> </sect3>
...@@ -194,9 +192,9 @@ ...@@ -194,9 +192,9 @@
<sect3> <sect3>
<title><function>gen_salt()</></title> <title><function>gen_salt()</></title>
<synopsis> <synopsis>
gen_salt(type text [, iter_count integer ]) returns text gen_salt(type text [, iter_count integer ]) returns text
</synopsis> </synopsis>
<para> <para>
Generates a new random salt string for use in <function>crypt()</>. Generates a new random salt string for use in <function>crypt()</>.
...@@ -489,10 +487,10 @@ ...@@ -489,10 +487,10 @@
<sect3> <sect3>
<title><function>pgp_sym_encrypt()</function></title> <title><function>pgp_sym_encrypt()</function></title>
<synopsis> <synopsis>
pgp_sym_encrypt(data text, psw text [, options text ]) returns bytea pgp_sym_encrypt(data text, psw text [, options text ]) returns bytea
pgp_sym_encrypt_bytea(data bytea, psw text [, options text ]) returns bytea pgp_sym_encrypt_bytea(data bytea, psw text [, options text ]) returns bytea
</synopsis> </synopsis>
<para> <para>
Encrypt <parameter>data</> with a symmetric PGP key <parameter>psw</>. Encrypt <parameter>data</> with a symmetric PGP key <parameter>psw</>.
The <parameter>options</> parameter can contain option settings, The <parameter>options</> parameter can contain option settings,
...@@ -503,10 +501,10 @@ ...@@ -503,10 +501,10 @@
<sect3> <sect3>
<title><function>pgp_sym_decrypt()</function></title> <title><function>pgp_sym_decrypt()</function></title>
<synopsis> <synopsis>
pgp_sym_decrypt(msg bytea, psw text [, options text ]) returns text pgp_sym_decrypt(msg bytea, psw text [, options text ]) returns text
pgp_sym_decrypt_bytea(msg bytea, psw text [, options text ]) returns bytea pgp_sym_decrypt_bytea(msg bytea, psw text [, options text ]) returns bytea
</synopsis> </synopsis>
<para> <para>
Decrypt a symmetric-key-encrypted PGP message. Decrypt a symmetric-key-encrypted PGP message.
</para> </para>
...@@ -524,10 +522,10 @@ ...@@ -524,10 +522,10 @@
<sect3> <sect3>
<title><function>pgp_pub_encrypt()</function></title> <title><function>pgp_pub_encrypt()</function></title>
<synopsis> <synopsis>
pgp_pub_encrypt(data text, key bytea [, options text ]) returns bytea pgp_pub_encrypt(data text, key bytea [, options text ]) returns bytea
pgp_pub_encrypt_bytea(data bytea, key bytea [, options text ]) returns bytea pgp_pub_encrypt_bytea(data bytea, key bytea [, options text ]) returns bytea
</synopsis> </synopsis>
<para> <para>
Encrypt <parameter>data</> with a public PGP key <parameter>key</>. Encrypt <parameter>data</> with a public PGP key <parameter>key</>.
Giving this function a secret key will produce a error. Giving this function a secret key will produce a error.
...@@ -541,10 +539,10 @@ ...@@ -541,10 +539,10 @@
<sect3> <sect3>
<title><function>pgp_pub_decrypt()</function></title> <title><function>pgp_pub_decrypt()</function></title>
<synopsis> <synopsis>
pgp_pub_decrypt(msg bytea, key bytea [, psw text [, options text ]]) returns text pgp_pub_decrypt(msg bytea, key bytea [, psw text [, options text ]]) returns text
pgp_pub_decrypt_bytea(msg bytea, key bytea [, psw text [, options text ]]) returns bytea pgp_pub_decrypt_bytea(msg bytea, key bytea [, psw text [, options text ]]) returns bytea
</synopsis> </synopsis>
<para> <para>
Decrypt a public-key-encrypted message. <parameter>key</> must be the Decrypt a public-key-encrypted message. <parameter>key</> must be the
secret key corresponding to the public key that was used to encrypt. secret key corresponding to the public key that was used to encrypt.
...@@ -566,9 +564,9 @@ ...@@ -566,9 +564,9 @@
<sect3> <sect3>
<title><function>pgp_key_id()</function></title> <title><function>pgp_key_id()</function></title>
<synopsis> <synopsis>
pgp_key_id(bytea) returns text pgp_key_id(bytea) returns text
</synopsis> </synopsis>
<para> <para>
<function>pgp_key_id</> extracts the key ID of a PGP public or secret key. <function>pgp_key_id</> extracts the key ID of a PGP public or secret key.
Or it gives the key ID that was used for encrypting the data, if given Or it gives the key ID that was used for encrypting the data, if given
...@@ -608,10 +606,10 @@ ...@@ -608,10 +606,10 @@
<sect3> <sect3>
<title><function>armor()</function>, <function>dearmor()</function></title> <title><function>armor()</function>, <function>dearmor()</function></title>
<synopsis> <synopsis>
armor(data bytea) returns text armor(data bytea) returns text
dearmor(data text) returns bytea dearmor(data text) returns bytea
</synopsis> </synopsis>
<para> <para>
These functions wrap/unwrap binary data into PGP Ascii Armor format, These functions wrap/unwrap binary data into PGP Ascii Armor format,
which is basically Base64 with CRC and additional formatting. which is basically Base64 with CRC and additional formatting.
...@@ -625,10 +623,10 @@ ...@@ -625,10 +623,10 @@
Options are named to be similar to GnuPG. An option's value should be Options are named to be similar to GnuPG. An option's value should be
given after an equal sign; separate options from each other with commas. given after an equal sign; separate options from each other with commas.
For example: For example:
<programlisting>
pgp_sym_encrypt(data, psw, 'compress-algo=1, cipher-algo=aes256')
</programlisting>
</para> </para>
<programlisting>
pgp_sym_encrypt(data, psw, 'compress-algo=1, cipher-algo=aes256')
</programlisting>
<para> <para>
All of the options except <literal>convert-crlf</literal> apply only to All of the options except <literal>convert-crlf</literal> apply only to
...@@ -648,11 +646,11 @@ ...@@ -648,11 +646,11 @@
<para> <para>
Which cipher algorithm to use. Which cipher algorithm to use.
</para> </para>
<programlisting> <literallayout>
Values: bf, aes128, aes192, aes256 (OpenSSL-only: <literal>3des</literal>, <literal>cast5</literal>) Values: bf, aes128, aes192, aes256 (OpenSSL-only: <literal>3des</literal>, <literal>cast5</literal>)
Default: aes128 Default: aes128
Applies to: pgp_sym_encrypt, pgp_pub_encrypt Applies to: pgp_sym_encrypt, pgp_pub_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -662,14 +660,14 @@ ...@@ -662,14 +660,14 @@
Which compression algorithm to use. Only available if Which compression algorithm to use. Only available if
<productname>PostgreSQL</productname> was built with zlib. <productname>PostgreSQL</productname> was built with zlib.
</para> </para>
<programlisting> <literallayout>
Values: Values:
0 - no compression 0 - no compression
1 - ZIP compression 1 - ZIP compression
2 - ZLIB compression (= ZIP plus meta-data and block CRCs) 2 - ZLIB compression (= ZIP plus meta-data and block CRCs)
Default: 0 Default: 0
Applies to: pgp_sym_encrypt, pgp_pub_encrypt Applies to: pgp_sym_encrypt, pgp_pub_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -679,11 +677,11 @@ ...@@ -679,11 +677,11 @@
How much to compress. Higher levels compress smaller but are slower. How much to compress. Higher levels compress smaller but are slower.
0 disables compression. 0 disables compression.
</para> </para>
<programlisting> <literallayout>
Values: 0, 1-9 Values: 0, 1-9
Default: 6 Default: 6
Applies to: pgp_sym_encrypt, pgp_pub_encrypt Applies to: pgp_sym_encrypt, pgp_pub_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -696,11 +694,11 @@ ...@@ -696,11 +694,11 @@
<literal>\r\n</literal> line-feeds. Use this to get fully RFC-compliant <literal>\r\n</literal> line-feeds. Use this to get fully RFC-compliant
behavior. behavior.
</para> </para>
<programlisting> <literallayout>
Values: 0, 1 Values: 0, 1
Default: 0 Default: 0
Applies to: pgp_sym_encrypt, pgp_pub_encrypt, pgp_sym_decrypt, pgp_pub_decrypt Applies to: pgp_sym_encrypt, pgp_pub_encrypt, pgp_sym_decrypt, pgp_pub_decrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -712,11 +710,11 @@ ...@@ -712,11 +710,11 @@
the addition of SHA-1 protected packets to RFC 4880. the addition of SHA-1 protected packets to RFC 4880.
Recent gnupg.org and pgp.com software supports it fine. Recent gnupg.org and pgp.com software supports it fine.
</para> </para>
<programlisting> <literallayout>
Values: 0, 1 Values: 0, 1
Default: 0 Default: 0
Applies to: pgp_sym_encrypt, pgp_pub_encrypt Applies to: pgp_sym_encrypt, pgp_pub_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -727,11 +725,11 @@ ...@@ -727,11 +725,11 @@
session key; this is for symmetric-key encryption, which by default session key; this is for symmetric-key encryption, which by default
uses the S2K key directly. uses the S2K key directly.
</para> </para>
<programlisting> <literallayout>
Values: 0, 1 Values: 0, 1
Default: 0 Default: 0
Applies to: pgp_sym_encrypt Applies to: pgp_sym_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -740,14 +738,14 @@ ...@@ -740,14 +738,14 @@
<para> <para>
Which S2K algorithm to use. Which S2K algorithm to use.
</para> </para>
<programlisting> <literallayout>
Values: Values:
0 - Without salt. Dangerous! 0 - Without salt. Dangerous!
1 - With salt but with fixed iteration count. 1 - With salt but with fixed iteration count.
3 - Variable iteration count. 3 - Variable iteration count.
Default: 3 Default: 3
Applies to: pgp_sym_encrypt Applies to: pgp_sym_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -756,11 +754,11 @@ ...@@ -756,11 +754,11 @@
<para> <para>
Which digest algorithm to use in S2K calculation. Which digest algorithm to use in S2K calculation.
</para> </para>
<programlisting> <literallayout>
Values: md5, sha1 Values: md5, sha1
Default: sha1 Default: sha1
Applies to: pgp_sym_encrypt Applies to: pgp_sym_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -769,11 +767,11 @@ ...@@ -769,11 +767,11 @@
<para> <para>
Which cipher to use for encrypting separate session key. Which cipher to use for encrypting separate session key.
</para> </para>
<programlisting> <literallayout>
Values: bf, aes, aes128, aes192, aes256 Values: bf, aes, aes128, aes192, aes256
Default: use cipher-algo Default: use cipher-algo
Applies to: pgp_sym_encrypt Applies to: pgp_sym_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
<sect4> <sect4>
...@@ -785,11 +783,11 @@ ...@@ -785,11 +783,11 @@
be done, but the message will be tagged as UTF-8. Without this option be done, but the message will be tagged as UTF-8. Without this option
it will not be. it will not be.
</para> </para>
<programlisting> <literallayout>
Values: 0, 1 Values: 0, 1
Default: 0 Default: 0
Applies to: pgp_sym_encrypt, pgp_pub_encrypt Applies to: pgp_sym_encrypt, pgp_pub_encrypt
</programlisting> </literallayout>
</sect4> </sect4>
</sect3> </sect3>
...@@ -798,10 +796,10 @@ ...@@ -798,10 +796,10 @@
<para> <para>
To generate a new key: To generate a new key:
<programlisting>
gpg --gen-key
</programlisting>
</para> </para>
<programlisting>
gpg --gen-key
</programlisting>
<para> <para>
The preferred key type is <quote>DSA and Elgamal</>. The preferred key type is <quote>DSA and Elgamal</>.
</para> </para>
...@@ -812,22 +810,22 @@ ...@@ -812,22 +810,22 @@
</para> </para>
<para> <para>
To list keys: To list keys:
<programlisting>
gpg --list-secret-keys
</programlisting>
</para> </para>
<programlisting>
gpg --list-secret-keys
</programlisting>
<para> <para>
To export a public key in ascii-armor format: To export a public key in ascii-armor format:
<programlisting>
gpg -a --export KEYID > public.key
</programlisting>
</para> </para>
<programlisting>
gpg -a --export KEYID > public.key
</programlisting>
<para> <para>
To export a secret key in ascii-armor format: To export a secret key in ascii-armor format:
<programlisting>
gpg -a --export-secret-keys KEYID > secret.key
</programlisting>
</para> </para>
<programlisting>
gpg -a --export-secret-keys KEYID > secret.key
</programlisting>
<para> <para>
You need to use <function>dearmor()</> on these keys before giving them to You need to use <function>dearmor()</> on these keys before giving them to
the PGP functions. Or if you can handle binary data, you can drop the PGP functions. Or if you can handle binary data, you can drop
...@@ -905,34 +903,29 @@ ...@@ -905,34 +903,29 @@
encryption functions is discouraged. encryption functions is discouraged.
</para> </para>
<synopsis> <synopsis>
encrypt(data bytea, key bytea, type text) returns bytea encrypt(data bytea, key bytea, type text) returns bytea
decrypt(data bytea, key bytea, type text) returns bytea decrypt(data bytea, key bytea, type text) returns bytea
encrypt_iv(data bytea, key bytea, iv bytea, type text) returns bytea encrypt_iv(data bytea, key bytea, iv bytea, type text) returns bytea
decrypt_iv(data bytea, key bytea, iv bytea, type text) returns bytea decrypt_iv(data bytea, key bytea, iv bytea, type text) returns bytea
</synopsis> </synopsis>
<para> <para>
Encrypt/decrypt data using the cipher method specified by Encrypt/decrypt data using the cipher method specified by
<parameter>type</parameter>. The syntax of the <parameter>type</parameter>. The syntax of the
<parameter>type</parameter> string is: <parameter>type</parameter> string is:
</para>
<synopsis>
<replaceable>algorithm</> <optional> <literal>-</> <replaceable>mode</> </optional> <optional> <literal>/pad:</> <replaceable>padding</> </optional>
</synopsis>
<para> <synopsis>
<replaceable>algorithm</> <optional> <literal>-</> <replaceable>mode</> </optional> <optional> <literal>/pad:</> <replaceable>padding</> </optional>
</synopsis>
where <replaceable>algorithm</> is one of: where <replaceable>algorithm</> is one of:
</para>
<itemizedlist> <itemizedlist>
<listitem><para><literal>bf</literal> &mdash; Blowfish</para></listitem> <listitem><para><literal>bf</literal> &mdash; Blowfish</para></listitem>
<listitem><para><literal>aes</literal> &mdash; AES (Rijndael-128)</para></listitem> <listitem><para><literal>aes</literal> &mdash; AES (Rijndael-128)</para></listitem>
</itemizedlist> </itemizedlist>
<para>
and <replaceable>mode</> is one of: and <replaceable>mode</> is one of:
</para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
...@@ -946,9 +939,7 @@ ...@@ -946,9 +939,7 @@
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
<para>
and <replaceable>padding</> is one of: and <replaceable>padding</> is one of:
</para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
...@@ -961,13 +952,14 @@ ...@@ -961,13 +952,14 @@
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
</para>
<para> <para>
So, for example, these are equivalent: So, for example, these are equivalent:
<programlisting>
encrypt(data, 'fooz', 'bf')
encrypt(data, 'fooz', 'bf-cbc/pad:pkcs')
</programlisting>
</para> </para>
<programlisting>
encrypt(data, 'fooz', 'bf')
encrypt(data, 'fooz', 'bf-cbc/pad:pkcs')
</programlisting>
<para> <para>
In <function>encrypt_iv</> and <function>decrypt_iv</>, the In <function>encrypt_iv</> and <function>decrypt_iv</>, the
<parameter>iv</> parameter is the initial value for the CBC mode; <parameter>iv</> parameter is the initial value for the CBC mode;
...@@ -980,9 +972,9 @@ ...@@ -980,9 +972,9 @@
<sect2> <sect2>
<title>Random-data functions</title> <title>Random-data functions</title>
<synopsis> <synopsis>
gen_random_bytes(count integer) returns bytea gen_random_bytes(count integer) returns bytea
</synopsis> </synopsis>
<para> <para>
Returns <parameter>count</> cryptographically strong random bytes. Returns <parameter>count</> cryptographically strong random bytes.
At most 1024 bytes can be extracted at a time. This is to avoid At most 1024 bytes can be extracted at a time. This is to avoid
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgfreespacemap.sgml,v 2.6 2010/04/23 23:21:43 rhaas Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgfreespacemap.sgml,v 2.7 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgfreespacemap"> <sect1 id="pgfreespacemap">
<title>pg_freespacemap</title> <title>pg_freespacemap</title>
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,7 @@
<sect2> <sect2>
<title>Sample output</title> <title>Sample output</title>
<programlisting> <screen>
postgres=# SELECT * FROM pg_freespace('foo'); postgres=# SELECT * FROM pg_freespace('foo');
blkno | avail blkno | avail
-------+------- -------+-------
...@@ -106,8 +106,7 @@ postgres=# SELECT * FROM pg_freespace('foo', 7); ...@@ -106,8 +106,7 @@ postgres=# SELECT * FROM pg_freespace('foo', 7);
-------------- --------------
1216 1216
(1 row) (1 row)
</screen>
</programlisting>
</sect2> </sect2>
<sect2> <sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgrowlocks.sgml,v 1.5 2009/05/18 11:08:24 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgrowlocks.sgml,v 1.6 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgrowlocks"> <sect1 id="pgrowlocks">
<title>pgrowlocks</title> <title>pgrowlocks</title>
...@@ -101,10 +101,10 @@ pgrowlocks(text) returns setof record ...@@ -101,10 +101,10 @@ pgrowlocks(text) returns setof record
rows. If you want to take a look at the row contents at the same time, you rows. If you want to take a look at the row contents at the same time, you
could do something like this: could do something like this:
<programlisting> <programlisting>
SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p
WHERE p.locked_row = a.ctid; WHERE p.locked_row = a.ctid;
</programlisting> </programlisting>
Be aware however that (as of <productname>PostgreSQL</> 8.3) such a Be aware however that (as of <productname>PostgreSQL</> 8.3) such a
query will be very inefficient. query will be very inefficient.
...@@ -114,7 +114,7 @@ SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p ...@@ -114,7 +114,7 @@ SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p
<sect2> <sect2>
<title>Sample output</title> <title>Sample output</title>
<programlisting> <screen>
test=# SELECT * FROM pgrowlocks('t1'); test=# SELECT * FROM pgrowlocks('t1');
locked_row | lock_type | locker | multi | xids | pids locked_row | lock_type | locker | multi | xids | pids
------------+-----------+--------+-------+-----------+--------------- ------------+-----------+--------+-------+-----------+---------------
...@@ -123,7 +123,7 @@ test=# SELECT * FROM pgrowlocks('t1'); ...@@ -123,7 +123,7 @@ test=# SELECT * FROM pgrowlocks('t1');
(0,3) | Exclusive | 804 | f | {804} | {29066} (0,3) | Exclusive | 804 | f | {804} | {29066}
(0,4) | Exclusive | 804 | f | {804} | {29066} (0,4) | Exclusive | 804 | f | {804} | {29066}
(4 rows) (4 rows)
</programlisting> </screen>
</sect2> </sect2>
<sect2> <sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgstandby.sgml,v 2.11 2010/05/25 15:55:28 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgstandby.sgml,v 2.12 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgstandby"> <sect1 id="pgstandby">
<title>pg_standby</title> <title>pg_standby</title>
...@@ -50,21 +50,17 @@ ...@@ -50,21 +50,17 @@
To configure a standby To configure a standby
server to use <application>pg_standby</>, put this into its server to use <application>pg_standby</>, put this into its
<filename>recovery.conf</filename> configuration file: <filename>recovery.conf</filename> configuration file:
</para> <programlisting>
<programlisting>
restore_command = 'pg_standby <replaceable>archiveDir</> %f %p %r' restore_command = 'pg_standby <replaceable>archiveDir</> %f %p %r'
</programlisting> </programlisting>
<para>
where <replaceable>archiveDir</> is the directory from which WAL segment where <replaceable>archiveDir</> is the directory from which WAL segment
files should be restored. files should be restored.
</para> </para>
<para> <para>
The full syntax of <application>pg_standby</>'s command line is The full syntax of <application>pg_standby</>'s command line is
</para> <synopsis>
<synopsis>
pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archivelocation</> <replaceable>nextwalfile</> <replaceable>xlogfilepath</> <optional> <replaceable>restartwalfile</> </optional> pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archivelocation</> <replaceable>nextwalfile</> <replaceable>xlogfilepath</> <optional> <replaceable>restartwalfile</> </optional>
</synopsis> </synopsis>
<para>
When used within <literal>restore_command</literal>, the <literal>%f</> and When used within <literal>restore_command</literal>, the <literal>%f</> and
<literal>%p</> macros should be specified for <replaceable>nextwalfile</> <literal>%p</> macros should be specified for <replaceable>nextwalfile</>
and <replaceable>xlogfilepath</> respectively, to provide the actual file and <replaceable>xlogfilepath</> respectively, to provide the actual file
...@@ -235,21 +231,19 @@ pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archiv ...@@ -235,21 +231,19 @@ pg_standby <optional> <replaceable>option</> ... </optional> <replaceable>archiv
<sect2> <sect2>
<title>Examples</title> <title>Examples</title>
<para>On Linux or Unix systems, you might use:</para> <para>On Linux or Unix systems, you might use:
<programlisting> <programlisting>
archive_command = 'cp %p .../archive/%f' archive_command = 'cp %p .../archive/%f'
restore_command = 'pg_standby -d -s 2 -t /tmp/pgsql.trigger.5442 .../archive %f %p %r 2>>standby.log' restore_command = 'pg_standby -d -s 2 -t /tmp/pgsql.trigger.5442 .../archive %f %p %r 2>>standby.log'
recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442' recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442'
</programlisting> </programlisting>
<para>
where the archive directory is physically located on the standby server, where the archive directory is physically located on the standby server,
so that the <literal>archive_command</> is accessing it across NFS, so that the <literal>archive_command</> is accessing it across NFS,
but the files are local to the standby (enabling use of <literal>ln</>). but the files are local to the standby (enabling use of <literal>ln</>).
This will: This will:
</para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
...@@ -279,22 +273,21 @@ recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442' ...@@ -279,22 +273,21 @@ recovery_end_command = 'rm -f /tmp/pgsql.trigger.5442'
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
</para>
<para>On Windows, you might use:</para> <para>On Windows, you might use:
<programlisting> <programlisting>
archive_command = 'copy %p ...\\archive\\%f' archive_command = 'copy %p ...\\archive\\%f'
restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p %r 2>>standby.log' restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p %r 2>>standby.log'
recovery_end_command = 'del C:\pgsql.trigger.5442' recovery_end_command = 'del C:\pgsql.trigger.5442'
</programlisting> </programlisting>
<para>
Note that backslashes need to be doubled in the Note that backslashes need to be doubled in the
<literal>archive_command</>, but <emphasis>not</emphasis> in the <literal>archive_command</>, but <emphasis>not</emphasis> in the
<literal>restore_command</> or <literal>recovery_end_command</>. <literal>restore_command</> or <literal>recovery_end_command</>.
This will: This will:
</para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
<para> <para>
...@@ -329,6 +322,7 @@ recovery_end_command = 'del C:\pgsql.trigger.5442' ...@@ -329,6 +322,7 @@ recovery_end_command = 'del C:\pgsql.trigger.5442'
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
</para>
<para> <para>
The <literal>copy</> command on Windows sets the final file size The <literal>copy</> command on Windows sets the final file size
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgstatstatements.sgml,v 1.6 2010/01/08 00:38:20 itagaki Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgstatstatements.sgml,v 1.7 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgstatstatements"> <sect1 id="pgstatstatements">
<title>pg_stat_statements</title> <title>pg_stat_statements</title>
...@@ -279,22 +279,22 @@ ...@@ -279,22 +279,22 @@
<filename>postgresql.conf</> file, <filename>postgresql.conf</> file,
you will need to add <literal>pg_stat_statements</> to you will need to add <literal>pg_stat_statements</> to
<xref linkend="guc-custom-variable-classes">. Typical usage might be: <xref linkend="guc-custom-variable-classes">. Typical usage might be:
</para>
<programlisting> <programlisting>
# postgresql.conf # postgresql.conf
shared_preload_libraries = 'pg_stat_statements' shared_preload_libraries = 'pg_stat_statements'
custom_variable_classes = 'pg_stat_statements' custom_variable_classes = 'pg_stat_statements'
pg_stat_statements.max = 10000 pg_stat_statements.max = 10000
pg_stat_statements.track = all pg_stat_statements.track = all
</programlisting> </programlisting>
</para>
</sect2> </sect2>
<sect2> <sect2>
<title>Sample output</title> <title>Sample output</title>
<programlisting> <screen>
bench=# SELECT pg_stat_statements_reset(); bench=# SELECT pg_stat_statements_reset();
$ pgbench -i bench $ pgbench -i bench
...@@ -334,7 +334,7 @@ calls | 1 ...@@ -334,7 +334,7 @@ calls | 1
total_time | 0.08142 total_time | 0.08142
rows | 0 rows | 0
hit_percent | 34.4947735191637631 hit_percent | 34.4947735191637631
</programlisting> </screen>
</sect2> </sect2>
<sect2> <sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgstattuple.sgml,v 1.5 2009/05/18 11:08:24 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgstattuple.sgml,v 1.6 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgstattuple"> <sect1 id="pgstattuple">
<title>pgstattuple</title> <title>pgstattuple</title>
...@@ -141,8 +141,7 @@ free_percent | 1.95 ...@@ -141,8 +141,7 @@ free_percent | 1.95
<para> <para>
<function>pgstatindex</function> returns a record showing information <function>pgstatindex</function> returns a record showing information
about a btree index. For example: about a btree index. For example:
</para> <programlisting>
<programlisting>
test=> SELECT * FROM pgstatindex('pg_cast_oid_index'); test=> SELECT * FROM pgstatindex('pg_cast_oid_index');
-[ RECORD 1 ]------+------ -[ RECORD 1 ]------+------
version | 2 version | 2
...@@ -155,7 +154,8 @@ empty_pages | 0 ...@@ -155,7 +154,8 @@ empty_pages | 0
deleted_pages | 0 deleted_pages | 0
avg_leaf_density | 50.27 avg_leaf_density | 50.27
leaf_fragmentation | 0 leaf_fragmentation | 0
</programlisting> </programlisting>
</para>
<para> <para>
The output columns are: The output columns are:
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/pgtrgm.sgml,v 2.2 2007/12/10 05:32:51 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/pgtrgm.sgml,v 2.3 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="pgtrgm"> <sect1 id="pgtrgm">
<title>pg_trgm</title> <title>pg_trgm</title>
...@@ -136,27 +136,25 @@ ...@@ -136,27 +136,25 @@
<para> <para>
Example: Example:
<programlisting> <programlisting>
CREATE TABLE test_trgm (t text); CREATE TABLE test_trgm (t text);
CREATE INDEX trgm_idx ON test_trgm USING gist (t gist_trgm_ops); CREATE INDEX trgm_idx ON test_trgm USING gist (t gist_trgm_ops);
</programlisting> </programlisting>
or or
<programlisting> <programlisting>
CREATE INDEX trgm_idx ON test_trgm USING gin (t gin_trgm_ops); CREATE INDEX trgm_idx ON test_trgm USING gin (t gin_trgm_ops);
</programlisting> </programlisting>
</para> </para>
<para> <para>
At this point, you will have an index on the <structfield>t</> column that At this point, you will have an index on the <structfield>t</> column that
you can use for similarity searching. A typical query is you can use for similarity searching. A typical query is
</para> <programlisting>
<programlisting>
SELECT t, similarity(t, '<replaceable>word</>') AS sml SELECT t, similarity(t, '<replaceable>word</>') AS sml
FROM test_trgm FROM test_trgm
WHERE t % '<replaceable>word</>' WHERE t % '<replaceable>word</>'
ORDER BY sml DESC, t; ORDER BY sml DESC, t;
</programlisting> </programlisting>
<para>
This will return all values in the text column that are sufficiently This will return all values in the text column that are sufficiently
similar to <replaceable>word</>, sorted from best match to worst. The similar to <replaceable>word</>, sorted from best match to worst. The
index will be used to make this a fast operation even over very large data index will be used to make this a fast operation even over very large data
...@@ -185,14 +183,12 @@ SELECT t, similarity(t, '<replaceable>word</>') AS sml ...@@ -185,14 +183,12 @@ SELECT t, similarity(t, '<replaceable>word</>') AS sml
<para> <para>
The first step is to generate an auxiliary table containing all The first step is to generate an auxiliary table containing all
the unique words in the documents: the unique words in the documents:
</para>
<programlisting> <programlisting>
CREATE TABLE words AS SELECT word FROM CREATE TABLE words AS SELECT word FROM
ts_stat('SELECT to_tsvector(''simple'', bodytext) FROM documents'); ts_stat('SELECT to_tsvector(''simple'', bodytext) FROM documents');
</programlisting> </programlisting>
<para>
where <structname>documents</> is a table that has a text field where <structname>documents</> is a table that has a text field
<structfield>bodytext</> that we wish to search. The reason for using <structfield>bodytext</> that we wish to search. The reason for using
the <literal>simple</> configuration with the <function>to_tsvector</> the <literal>simple</> configuration with the <function>to_tsvector</>
...@@ -202,13 +198,11 @@ CREATE TABLE words AS SELECT word FROM ...@@ -202,13 +198,11 @@ CREATE TABLE words AS SELECT word FROM
<para> <para>
Next, create a trigram index on the word column: Next, create a trigram index on the word column:
</para>
<programlisting> <programlisting>
CREATE INDEX words_idx ON words USING gin(word gin_trgm_ops); CREATE INDEX words_idx ON words USING gin(word gin_trgm_ops);
</programlisting> </programlisting>
<para>
Now, a <command>SELECT</command> query similar to the previous example can Now, a <command>SELECT</command> query similar to the previous example can
be used to suggest spellings for misspelled words in user search terms. be used to suggest spellings for misspelled words in user search terms.
A useful extra test is to require that the selected words are also of A useful extra test is to require that the selected words are also of
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.86 2010/07/08 21:35:33 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.87 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="plperl"> <chapter id="plperl">
<title>PL/Perl - Perl Procedural Language</title> <title>PL/Perl - Perl Procedural Language</title>
...@@ -530,10 +530,7 @@ $plan = spi_prepare('SELECT * FROM test WHERE id &gt; $1 AND name = $2', ...@@ -530,10 +530,7 @@ $plan = spi_prepare('SELECT * FROM test WHERE id &gt; $1 AND name = $2',
The advantage of prepared queries is that is it possible to use one prepared plan for more The advantage of prepared queries is that is it possible to use one prepared plan for more
than one query execution. After the plan is not needed anymore, it can be freed with than one query execution. After the plan is not needed anymore, it can be freed with
<literal>spi_freeplan</literal>: <literal>spi_freeplan</literal>:
</para> <programlisting>
<para>
<programlisting>
CREATE OR REPLACE FUNCTION init() RETURNS VOID AS $$ CREATE OR REPLACE FUNCTION init() RETURNS VOID AS $$
$_SHARED{my_plan} = spi_prepare('SELECT (now() + $1)::date AS now', $_SHARED{my_plan} = spi_prepare('SELECT (now() + $1)::date AS now',
'INTERVAL'); 'INTERVAL');
...@@ -558,10 +555,7 @@ SELECT done(); ...@@ -558,10 +555,7 @@ SELECT done();
add_time | add_time | add_time add_time | add_time | add_time
------------+------------+------------ ------------+------------+------------
2005-12-10 | 2005-12-11 | 2005-12-12 2005-12-10 | 2005-12-11 | 2005-12-12
</programlisting> </programlisting>
</para>
<para>
Note that the parameter subscript in <literal>spi_prepare</literal> is defined via Note that the parameter subscript in <literal>spi_prepare</literal> is defined via
$1, $2, $3, etc, so avoid declaring query strings in double quotes that might easily $1, $2, $3, etc, so avoid declaring query strings in double quotes that might easily
lead to hard-to-catch bugs. lead to hard-to-catch bugs.
...@@ -569,10 +563,7 @@ SELECT done(); ...@@ -569,10 +563,7 @@ SELECT done();
<para> <para>
Another example illustrates usage of an optional parameter in <literal>spi_exec_prepared</literal>: Another example illustrates usage of an optional parameter in <literal>spi_exec_prepared</literal>:
</para> <programlisting>
<para>
<programlisting>
CREATE TABLE hosts AS SELECT id, ('192.168.1.'||id)::inet AS address CREATE TABLE hosts AS SELECT id, ('192.168.1.'||id)::inet AS address
FROM generate_series(1,3) AS id; FROM generate_series(1,3) AS id;
...@@ -603,7 +594,7 @@ SELECT release_hosts_query(); ...@@ -603,7 +594,7 @@ SELECT release_hosts_query();
(1,192.168.1.1) (1,192.168.1.1)
(2,192.168.1.2) (2,192.168.1.2)
(2 rows) (2 rows)
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.155 2010/07/27 20:02:06 rhaas Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.156 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="plpgsql"> <chapter id="plpgsql">
<title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title> <title><application>PL/pgSQL</application> - <acronym>SQL</acronym> Procedural Language</title>
...@@ -1217,14 +1217,14 @@ EXECUTE 'UPDATE tbl SET ' ...@@ -1217,14 +1217,14 @@ EXECUTE 'UPDATE tbl SET '
As always, care must be taken to ensure that null values in a query do As always, care must be taken to ensure that null values in a query do
not deliver unintended results. For example the <literal>WHERE</> clause not deliver unintended results. For example the <literal>WHERE</> clause
<programlisting> <programlisting>
'WHERE key = ' || quote_nullable(keyvalue) 'WHERE key = ' || quote_nullable(keyvalue)
</programlisting> </programlisting>
will never succeed if <literal>keyvalue</> is null, because the will never succeed if <literal>keyvalue</> is null, because the
result of using the equality operator <literal>=</> with a null operand result of using the equality operator <literal>=</> with a null operand
is always null. If you wish null to work like an ordinary key value, is always null. If you wish null to work like an ordinary key value,
you would need to rewrite the above as you would need to rewrite the above as
<programlisting> <programlisting>
'WHERE key IS NOT DISTINCT FROM ' || quote_nullable(keyvalue) 'WHERE key IS NOT DISTINCT FROM ' || quote_nullable(keyvalue)
</programlisting> </programlisting>
(At present, <literal>IS NOT DISTINCT FROM</> is handled much less (At present, <literal>IS NOT DISTINCT FROM</> is handled much less
efficiently than <literal>=</>, so don't do this unless you must. efficiently than <literal>=</>, so don't do this unless you must.
...@@ -1391,20 +1391,20 @@ NULL; ...@@ -1391,20 +1391,20 @@ NULL;
<para> <para>
For example, the following two fragments of code are equivalent: For example, the following two fragments of code are equivalent:
<programlisting> <programlisting>
BEGIN BEGIN
y := x / 0; y := x / 0;
EXCEPTION EXCEPTION
WHEN division_by_zero THEN WHEN division_by_zero THEN
NULL; -- ignore the error NULL; -- ignore the error
END; END;
</programlisting> </programlisting>
<programlisting> <programlisting>
BEGIN BEGIN
y := x / 0; y := x / 0;
EXCEPTION EXCEPTION
WHEN division_by_zero THEN -- ignore the error WHEN division_by_zero THEN -- ignore the error
END; END;
</programlisting> </programlisting>
Which is preferable is a matter of taste. Which is preferable is a matter of taste.
</para> </para>
...@@ -2275,8 +2275,8 @@ END; ...@@ -2275,8 +2275,8 @@ END;
not case-sensitive. Also, an error condition can be specified not case-sensitive. Also, an error condition can be specified
by <literal>SQLSTATE</> code; for example these are equivalent: by <literal>SQLSTATE</> code; for example these are equivalent:
<programlisting> <programlisting>
WHEN division_by_zero THEN ... WHEN division_by_zero THEN ...
WHEN SQLSTATE '22012' THEN ... WHEN SQLSTATE '22012' THEN ...
</programlisting> </programlisting>
</para> </para>
...@@ -2295,16 +2295,16 @@ END; ...@@ -2295,16 +2295,16 @@ END;
As an example, consider this fragment: As an example, consider this fragment:
<programlisting> <programlisting>
INSERT INTO mytab(firstname, lastname) VALUES('Tom', 'Jones'); INSERT INTO mytab(firstname, lastname) VALUES('Tom', 'Jones');
BEGIN BEGIN
UPDATE mytab SET firstname = 'Joe' WHERE lastname = 'Jones'; UPDATE mytab SET firstname = 'Joe' WHERE lastname = 'Jones';
x := x + 1; x := x + 1;
y := x / 0; y := x / 0;
EXCEPTION EXCEPTION
WHEN division_by_zero THEN WHEN division_by_zero THEN
RAISE NOTICE 'caught division_by_zero'; RAISE NOTICE 'caught division_by_zero';
RETURN x; RETURN x;
END; END;
</programlisting> </programlisting>
When control reaches the assignment to <literal>y</>, it will When control reaches the assignment to <literal>y</>, it will
...@@ -3519,7 +3519,7 @@ SELECT * FROM sales_summary_bytime; ...@@ -3519,7 +3519,7 @@ SELECT * FROM sales_summary_bytime;
column reference is syntactically allowed. As an extreme case, consider column reference is syntactically allowed. As an extreme case, consider
this example of poor programming style: this example of poor programming style:
<programlisting> <programlisting>
INSERT INTO foo (foo) VALUES (foo); INSERT INTO foo (foo) VALUES (foo);
</programlisting> </programlisting>
The first occurrence of <literal>foo</> must syntactically be a table The first occurrence of <literal>foo</> must syntactically be a table
name, so it will not be substituted, even if the function has a variable name, so it will not be substituted, even if the function has a variable
...@@ -3542,7 +3542,7 @@ SELECT * FROM sales_summary_bytime; ...@@ -3542,7 +3542,7 @@ SELECT * FROM sales_summary_bytime;
tables: is a given name meant to refer to a table column, or a variable? tables: is a given name meant to refer to a table column, or a variable?
Let's change the previous example to Let's change the previous example to
<programlisting> <programlisting>
INSERT INTO dest (col) SELECT foo + bar FROM src; INSERT INTO dest (col) SELECT foo + bar FROM src;
</programlisting> </programlisting>
Here, <literal>dest</> and <literal>src</> must be table names, and Here, <literal>dest</> and <literal>src</> must be table names, and
<literal>col</> must be a column of <literal>dest</>, but <literal>foo</> <literal>col</> must be a column of <literal>dest</>, but <literal>foo</>
...@@ -3575,10 +3575,10 @@ SELECT * FROM sales_summary_bytime; ...@@ -3575,10 +3575,10 @@ SELECT * FROM sales_summary_bytime;
declare it in a labeled block and use the block's label declare it in a labeled block and use the block's label
(see <xref linkend="plpgsql-structure">). For example, (see <xref linkend="plpgsql-structure">). For example,
<programlisting> <programlisting>
&lt;&lt;block&gt;&gt; &lt;&lt;block&gt;&gt;
DECLARE DECLARE
foo int; foo int;
BEGIN BEGIN
foo := ...; foo := ...;
INSERT INTO dest (col) SELECT block.foo + bar FROM src; INSERT INTO dest (col) SELECT block.foo + bar FROM src;
</programlisting> </programlisting>
...@@ -4591,17 +4591,17 @@ $$ LANGUAGE plpgsql; ...@@ -4591,17 +4591,17 @@ $$ LANGUAGE plpgsql;
is equivalent to what you'd get in Oracle with: is equivalent to what you'd get in Oracle with:
<programlisting> <programlisting>
BEGIN BEGIN
SAVEPOINT s1; SAVEPOINT s1;
... code here ... ... code here ...
EXCEPTION EXCEPTION
WHEN ... THEN WHEN ... THEN
ROLLBACK TO s1; ROLLBACK TO s1;
... code here ... ... code here ...
WHEN ... THEN WHEN ... THEN
ROLLBACK TO s1; ROLLBACK TO s1;
... code here ... ... code here ...
END; END;
</programlisting> </programlisting>
If you are translating an Oracle procedure that uses If you are translating an Oracle procedure that uses
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_domain.sgml,v 1.25 2010/04/03 07:22:56 petere Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_domain.sgml,v 1.26 2010/07/29 19:34:40 petere Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -22,7 +22,7 @@ PostgreSQL documentation ...@@ -22,7 +22,7 @@ PostgreSQL documentation
</indexterm> </indexterm>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
{ SET DEFAULT <replaceable class="PARAMETER">expression</replaceable> | DROP DEFAULT } { SET DEFAULT <replaceable class="PARAMETER">expression</replaceable> | DROP DEFAULT }
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
...@@ -35,7 +35,7 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -35,7 +35,7 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
OWNER TO <replaceable class="PARAMETER">new_owner</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
SET SCHEMA <replaceable class="PARAMETER">new_schema</replaceable> SET SCHEMA <replaceable class="PARAMETER">new_schema</replaceable>
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -214,34 +214,34 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable> ...@@ -214,34 +214,34 @@ ALTER DOMAIN <replaceable class="PARAMETER">name</replaceable>
<para> <para>
To add a <literal>NOT NULL</literal> constraint to a domain: To add a <literal>NOT NULL</literal> constraint to a domain:
<programlisting> <programlisting>
ALTER DOMAIN zipcode SET NOT NULL; ALTER DOMAIN zipcode SET NOT NULL;
</programlisting> </programlisting>
To remove a <literal>NOT NULL</literal> constraint from a domain: To remove a <literal>NOT NULL</literal> constraint from a domain:
<programlisting> <programlisting>
ALTER DOMAIN zipcode DROP NOT NULL; ALTER DOMAIN zipcode DROP NOT NULL;
</programlisting> </programlisting>
</para> </para>
<para> <para>
To add a check constraint to a domain: To add a check constraint to a domain:
<programlisting> <programlisting>
ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5); ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);
</programlisting> </programlisting>
</para> </para>
<para> <para>
To remove a check constraint from a domain: To remove a check constraint from a domain:
<programlisting> <programlisting>
ALTER DOMAIN zipcode DROP CONSTRAINT zipchk; ALTER DOMAIN zipcode DROP CONSTRAINT zipchk;
</programlisting> </programlisting>
</para> </para>
<para> <para>
To move the domain into a different schema: To move the domain into a different schema:
<programlisting> <programlisting>
ALTER DOMAIN zipcode SET SCHEMA customers; ALTER DOMAIN zipcode SET SCHEMA customers;
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.25 2010/04/03 07:22:57 petere Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_sequence.sgml,v 1.26 2010/07/29 19:34:40 petere Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -22,7 +22,7 @@ PostgreSQL documentation ...@@ -22,7 +22,7 @@ PostgreSQL documentation
</indexterm> </indexterm>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ BY ] <replaceable class="parameter">increment</replaceable> ] ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ BY ] <replaceable class="parameter">increment</replaceable> ]
[ MINVALUE <replaceable class="parameter">minvalue</replaceable> | NO MINVALUE ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE ] [ MINVALUE <replaceable class="parameter">minvalue</replaceable> | NO MINVALUE ] [ MAXVALUE <replaceable class="parameter">maxvalue</replaceable> | NO MAXVALUE ]
[ START [ WITH ] <replaceable class="parameter">start</replaceable> ] [ START [ WITH ] <replaceable class="parameter">start</replaceable> ]
...@@ -32,7 +32,7 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ B ...@@ -32,7 +32,7 @@ ALTER SEQUENCE <replaceable class="parameter">name</replaceable> [ INCREMENT [ B
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable> ALTER SEQUENCE <replaceable class="parameter">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable> ALTER SEQUENCE <replaceable class="parameter">name</replaceable> RENAME TO <replaceable class="parameter">new_name</replaceable>
ALTER SEQUENCE <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable> ALTER SEQUENCE <replaceable class="parameter">name</replaceable> SET SCHEMA <replaceable class="parameter">new_schema</replaceable>
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_type.sgml,v 1.8 2010/04/03 07:22:57 petere Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/alter_type.sgml,v 1.9 2010/07/29 19:34:40 petere Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -22,11 +22,11 @@ PostgreSQL documentation ...@@ -22,11 +22,11 @@ PostgreSQL documentation
</indexterm> </indexterm>
<refsynopsisdiv> <refsynopsisdiv>
<synopsis> <synopsis>
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable class="PARAMETER">new_name</replaceable> ALTER TYPE <replaceable class="PARAMETER">name</replaceable> RENAME TO <replaceable class="PARAMETER">new_name</replaceable>
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable> ALTER TYPE <replaceable class="PARAMETER">name</replaceable> OWNER TO <replaceable class="PARAMETER">new_owner</replaceable>
ALTER TYPE <replaceable class="PARAMETER">name</replaceable> SET SCHEMA <replaceable class="PARAMETER">new_schema</replaceable> ALTER TYPE <replaceable class="PARAMETER">name</replaceable> SET SCHEMA <replaceable class="PARAMETER">new_schema</replaceable>
</synopsis> </synopsis>
</refsynopsisdiv> </refsynopsisdiv>
<refsect1> <refsect1>
...@@ -99,25 +99,25 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> SET SCHEMA <replace ...@@ -99,25 +99,25 @@ ALTER TYPE <replaceable class="PARAMETER">name</replaceable> SET SCHEMA <replace
<para> <para>
To rename a data type: To rename a data type:
<programlisting> <programlisting>
ALTER TYPE electronic_mail RENAME TO email; ALTER TYPE electronic_mail RENAME TO email;
</programlisting> </programlisting>
</para> </para>
<para> <para>
To change the owner of the type <literal>email</literal> To change the owner of the type <literal>email</literal>
to <literal>joe</literal>: to <literal>joe</literal>:
<programlisting> <programlisting>
ALTER TYPE email OWNER TO joe; ALTER TYPE email OWNER TO joe;
</programlisting> </programlisting>
</para> </para>
<para> <para>
To change the schema of the type <literal>email</literal> To change the schema of the type <literal>email</literal>
to <literal>customers</literal>: to <literal>customers</literal>:
<programlisting> <programlisting>
ALTER TYPE email SET SCHEMA customers; ALTER TYPE email SET SCHEMA customers;
</programlisting> </programlisting>
</para> </para>
</refsect1> </refsect1>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.74 2010/04/03 07:22:58 petere Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/create_index.sgml,v 1.75 2010/07/29 19:34:40 petere Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -557,12 +557,12 @@ CREATE INDEX code_idx ON films (code) TABLESPACE indexspace; ...@@ -557,12 +557,12 @@ CREATE INDEX code_idx ON films (code) TABLESPACE indexspace;
To create a GiST index on a point attribute so that we To create a GiST index on a point attribute so that we
can efficiently use box operators on the result of the can efficiently use box operators on the result of the
conversion function: conversion function:
<programlisting> <programlisting>
CREATE INDEX pointloc CREATE INDEX pointloc
ON points USING gist (box(location,location)); ON points USING gist (box(location,location));
SELECT * FROM points SELECT * FROM points
WHERE box(location,location) &amp;&amp; '(0,0),(1,1)'::box; WHERE box(location,location) &amp;&amp; '(0,0),(1,1)'::box;
</programlisting> </programlisting>
</para> </para>
<para> <para>
......
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.83 2010/04/03 07:23:01 petere Exp $ $PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.84 2010/07/29 19:34:41 petere Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -492,8 +492,8 @@ GRANT <replaceable class="PARAMETER">role_name</replaceable> [, ...] TO <replace ...@@ -492,8 +492,8 @@ GRANT <replaceable class="PARAMETER">role_name</replaceable> [, ...] TO <replace
(1 row) (1 row)
</programlisting> </programlisting>
The entries shown by <command>\dp</command> are interpreted thus: The entries shown by <command>\dp</command> are interpreted thus:
<programlisting> <literallayout class="monospaced">
rolename=xxxx -- privileges granted to a role rolename=xxxx -- privileges granted to a role
=xxxx -- privileges granted to PUBLIC =xxxx -- privileges granted to PUBLIC
r -- SELECT ("read") r -- SELECT ("read")
...@@ -512,7 +512,7 @@ GRANT <replaceable class="PARAMETER">role_name</replaceable> [, ...] TO <replace ...@@ -512,7 +512,7 @@ GRANT <replaceable class="PARAMETER">role_name</replaceable> [, ...] TO <replace
* -- grant option for preceding privilege * -- grant option for preceding privilege
/yyyy -- role that granted this privilege /yyyy -- role that granted this privilege
</programlisting> </literallayout>
The above example display would be seen by user <literal>miriam</> after The above example display would be seen by user <literal>miriam</> after
creating table <literal>mytable</> and doing: creating table <literal>mytable</> and doing:
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/release-8.1.sgml,v 1.7 2010/05/13 21:26:59 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/release-8.1.sgml,v 1.8 2010/07/29 19:34:40 petere Exp $ -->
<!-- See header comment in release.sgml about typical markup --> <!-- See header comment in release.sgml about typical markup -->
<sect1 id="release-8-1-21"> <sect1 id="release-8-1-21">
...@@ -4040,9 +4040,9 @@ psql -t -f fixseq.sql db1 | psql -e db1 ...@@ -4040,9 +4040,9 @@ psql -t -f fixseq.sql db1 | psql -e db1
Previously, only a predefined list of time zone names were Previously, only a predefined list of time zone names were
supported by <command>AT TIME ZONE</>. Now any supported time supported by <command>AT TIME ZONE</>. Now any supported time
zone name can be used, e.g.: zone name can be used, e.g.:
<programlisting> <programlisting>
SELECT CURRENT_TIMESTAMP AT TIME ZONE 'Europe/London'; SELECT CURRENT_TIMESTAMP AT TIME ZONE 'Europe/London';
</programlisting> </programlisting>
In the above query, the time zone used is adjusted based on the In the above query, the time zone used is adjusted based on the
daylight saving time rules that were in effect on the supplied daylight saving time rules that were in effect on the supplied
date. date.
...@@ -4116,10 +4116,10 @@ psql -t -f fixseq.sql db1 | psql -e db1 ...@@ -4116,10 +4116,10 @@ psql -t -f fixseq.sql db1 | psql -e db1
the next day even if a daylight saving time adjustment occurs the next day even if a daylight saving time adjustment occurs
between, whereas adding <literal>24 hours</> will give a different between, whereas adding <literal>24 hours</> will give a different
local time when this happens. For example, under US DST rules: local time when this happens. For example, under US DST rules:
<programlisting> <programlisting>
'2005-04-03 00:00:00-05' + '1 day' = '2005-04-04 00:00:00-04' '2005-04-03 00:00:00-05' + '1 day' = '2005-04-04 00:00:00-04'
'2005-04-03 00:00:00-05' + '24 hours' = '2005-04-04 01:00:00-04' '2005-04-03 00:00:00-05' + '24 hours' = '2005-04-04 01:00:00-04'
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/release-old.sgml,v 1.1 2009/05/02 20:17:19 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/release-old.sgml,v 1.2 2010/07/29 19:34:40 petere Exp $ -->
<!-- See header comment in release.sgml about typical markup --> <!-- See header comment in release.sgml about typical markup -->
<sect1 id="release-7-3-21"> <sect1 id="release-7-3-21">
...@@ -2919,7 +2919,7 @@ since <productname>PostgreSQL</productname> 7.1. ...@@ -2919,7 +2919,7 @@ since <productname>PostgreSQL</productname> 7.1.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Remove unused WAL segments of large transactions (Tom) Remove unused WAL segments of large transactions (Tom)
Multiaction rule fix (Tom) Multiaction rule fix (Tom)
PL/pgSQL memory allocation fix (Jan) PL/pgSQL memory allocation fix (Jan)
...@@ -2930,7 +2930,7 @@ Fix subselects with DISTINCT ON or LIMIT (Tom) ...@@ -2930,7 +2930,7 @@ Fix subselects with DISTINCT ON or LIMIT (Tom)
BeOS fix BeOS fix
Disable COPY TO/FROM a view (Tom) Disable COPY TO/FROM a view (Tom)
Cygwin build (Jason Tishler) Cygwin build (Jason Tishler)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -2962,13 +2962,13 @@ Cygwin build (Jason Tishler) ...@@ -2962,13 +2962,13 @@ Cygwin build (Jason Tishler)
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Fix PL/pgSQL SELECTs when returning no rows Fix PL/pgSQL SELECTs when returning no rows
Fix for psql backslash core dump Fix for psql backslash core dump
Referential integrity privilege fix Referential integrity privilege fix
Optimizer fixes Optimizer fixes
pg_dump cleanups pg_dump cleanups
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -3000,7 +3000,7 @@ pg_dump cleanups ...@@ -3000,7 +3000,7 @@ pg_dump cleanups
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Fix for numeric MODULO operator (Tom) Fix for numeric MODULO operator (Tom)
pg_dump fixes (Philip) pg_dump fixes (Philip)
pg_dump can dump 7.0 databases (Philip) pg_dump can dump 7.0 databases (Philip)
...@@ -3015,7 +3015,7 @@ Fix for pg_ctl and option strings with spaces (Peter E) ...@@ -3015,7 +3015,7 @@ Fix for pg_ctl and option strings with spaces (Peter E)
ODBC fixes (Hiroshi) ODBC fixes (Hiroshi)
EXTRACT can now take string argument (Thomas) EXTRACT can now take string argument (Thomas)
Python fixes (Darcy) Python fixes (Darcy)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -3127,7 +3127,7 @@ Subqueries in FROM are now supported. ...@@ -3127,7 +3127,7 @@ Subqueries in FROM are now supported.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Bug Fixes Bug Fixes
--------- ---------
Many multibyte/Unicode/locale fixes (Tatsuo and others) Many multibyte/Unicode/locale fixes (Tatsuo and others)
...@@ -3313,7 +3313,7 @@ New contrib/pg_logger ...@@ -3313,7 +3313,7 @@ New contrib/pg_logger
New --template option to createdb New --template option to createdb
New contrib/pg_control utility (Oliver) New contrib/pg_control utility (Oliver)
New FreeBSD tools ipc_check, start-scripts/freebsd New FreeBSD tools ipc_check, start-scripts/freebsd
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -3345,7 +3345,7 @@ New FreeBSD tools ipc_check, start-scripts/freebsd ...@@ -3345,7 +3345,7 @@ New FreeBSD tools ipc_check, start-scripts/freebsd
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Jdbc fixes (Peter) Jdbc fixes (Peter)
Large object fix (Tom) Large object fix (Tom)
Fix lean in COPY WITH OIDS leak (Tom) Fix lean in COPY WITH OIDS leak (Tom)
...@@ -3385,7 +3385,7 @@ Buffer fix (Tom) ...@@ -3385,7 +3385,7 @@ Buffer fix (Tom)
Fix for inserting/copying longer multibyte strings into char() data Fix for inserting/copying longer multibyte strings into char() data
types (Tatsuo) types (Tatsuo)
Fix for crash of backend, on abort (Tom) Fix for crash of backend, on abort (Tom)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -3417,9 +3417,9 @@ Fix for crash of backend, on abort (Tom) ...@@ -3417,9 +3417,9 @@ Fix for crash of backend, on abort (Tom)
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Added documentation to tarball. Added documentation to tarball.
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -3450,7 +3450,7 @@ Added documentation to tarball. ...@@ -3450,7 +3450,7 @@ Added documentation to tarball.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Fix many CLUSTER failures (Tom) Fix many CLUSTER failures (Tom)
Allow ALTER TABLE RENAME works on indexes (Tom) Allow ALTER TABLE RENAME works on indexes (Tom)
Fix plpgsql to handle datetime-&gt;timestamp and timespan-&gt;interval (Bruce) Fix plpgsql to handle datetime-&gt;timestamp and timespan-&gt;interval (Bruce)
...@@ -3475,7 +3475,7 @@ Fix too long syslog message (Tatsuo) ...@@ -3475,7 +3475,7 @@ Fix too long syslog message (Tatsuo)
Fix problem with quoted indexes that are too long (Tom) Fix problem with quoted indexes that are too long (Tom)
JDBC ResultSet.getTimestamp() fix (Gregory Krasnow &amp; Floyd Marinescu) JDBC ResultSet.getTimestamp() fix (Gregory Krasnow &amp; Floyd Marinescu)
ecpg changes (Michael) ecpg changes (Michael)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -3626,7 +3626,7 @@ ecpg changes (Michael) ...@@ -3626,7 +3626,7 @@ ecpg changes (Michael)
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Bug Fixes Bug Fixes
--------- ---------
Prevent function calls exceeding maximum number of arguments (Tom) Prevent function calls exceeding maximum number of arguments (Tom)
...@@ -3944,7 +3944,7 @@ NT fixes ...@@ -3944,7 +3944,7 @@ NT fixes
NetBSD fixes (Johnny C. Lam <email>lamj@stat.cmu.edu</email>) NetBSD fixes (Johnny C. Lam <email>lamj@stat.cmu.edu</email>)
Fixes for Alpha compiles Fixes for Alpha compiles
New multibyte encodings New multibyte encodings
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -3975,11 +3975,11 @@ New multibyte encodings ...@@ -3975,11 +3975,11 @@ New multibyte encodings
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Updated version of pgaccess 0.98 Updated version of pgaccess 0.98
NT-specific patch NT-specific patch
Fix dumping rules on inherited tables Fix dumping rules on inherited tables
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -4012,7 +4012,7 @@ Fix dumping rules on inherited tables ...@@ -4012,7 +4012,7 @@ Fix dumping rules on inherited tables
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
subselect+CASE fixes(Tom) subselect+CASE fixes(Tom)
Add SHLIB_LINK setting for solaris_i386 and solaris_sparc ports(Daren Sefcik) Add SHLIB_LINK setting for solaris_i386 and solaris_sparc ports(Daren Sefcik)
Fixes for CASE in WHERE join clauses(Tom) Fixes for CASE in WHERE join clauses(Tom)
...@@ -4037,7 +4037,7 @@ Repair logic error in LIKE: should not return LIKE_ABORT ...@@ -4037,7 +4037,7 @@ Repair logic error in LIKE: should not return LIKE_ABORT
when reach end of pattern before end of text(Tom) when reach end of pattern before end of text(Tom)
Repair incorrect cleanup of heap memory allocation during transaction abort(Tom) Repair incorrect cleanup of heap memory allocation during transaction abort(Tom)
Updated version of pgaccess 0.98 Updated version of pgaccess 0.98
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -4068,7 +4068,7 @@ Updated version of pgaccess 0.98 ...@@ -4068,7 +4068,7 @@ Updated version of pgaccess 0.98
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Add NT README file Add NT README file
Portability fixes for linux_ppc, IRIX, linux_alpha, OpenBSD, alpha Portability fixes for linux_ppc, IRIX, linux_alpha, OpenBSD, alpha
Remove QUERY_LIMIT, use SELECT...LIMIT Remove QUERY_LIMIT, use SELECT...LIMIT
...@@ -4092,7 +4092,7 @@ Shared library dependencies fixed (Tom) ...@@ -4092,7 +4092,7 @@ Shared library dependencies fixed (Tom)
Fixed glitches affecting GROUP BY in subselects(Tom) Fixed glitches affecting GROUP BY in subselects(Tom)
Fix some compiler warnings (Tomoaki Nishiyama) Fix some compiler warnings (Tomoaki Nishiyama)
Add Win1250 (Czech) support (Pavel Behal) Add Win1250 (Czech) support (Pavel Behal)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -4329,7 +4329,7 @@ Add Win1250 (Czech) support (Pavel Behal) ...@@ -4329,7 +4329,7 @@ Add Win1250 (Czech) support (Pavel Behal)
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Bug Fixes Bug Fixes
--------- ---------
Fix text&lt;-&gt;float8 and text&lt;-&gt;float4 conversion functions(Thomas) Fix text&lt;-&gt;float8 and text&lt;-&gt;float4 conversion functions(Thomas)
...@@ -4491,7 +4491,7 @@ Add ARM32 support(Andrew McMurry) ...@@ -4491,7 +4491,7 @@ Add ARM32 support(Andrew McMurry)
Better support for HP-UX 11 and UnixWare Better support for HP-UX 11 and UnixWare
Improve file handling to be more uniform, prevent file descriptor leak(Tom) Improve file handling to be more uniform, prevent file descriptor leak(Tom)
New install commands for plpgsql(Jan) New install commands for plpgsql(Jan)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -4695,7 +4695,7 @@ previous release of <productname>PostgreSQL</productname>. ...@@ -4695,7 +4695,7 @@ previous release of <productname>PostgreSQL</productname>.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Bug Fixes Bug Fixes
--------- ---------
Fix for a tiny memory leak in PQsetdb/PQfinish(Bryan) Fix for a tiny memory leak in PQsetdb/PQfinish(Bryan)
...@@ -4939,7 +4939,7 @@ refer to the installation and migration instructions for version 6.3. ...@@ -4939,7 +4939,7 @@ refer to the installation and migration instructions for version 6.3.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Configure detection improvements for tcl/tk(Brook Milligan, Alvin) Configure detection improvements for tcl/tk(Brook Milligan, Alvin)
Manual page improvements(Bruce) Manual page improvements(Bruce)
BETWEEN and LIKE fix(Thomas) BETWEEN and LIKE fix(Thomas)
...@@ -4958,7 +4958,7 @@ libreadline cleanup(Erwan MAS) ...@@ -4958,7 +4958,7 @@ libreadline cleanup(Erwan MAS)
Remove DISTDIR(Bruce) Remove DISTDIR(Bruce)
Makefile dependency cleanup(Jeroen van Vianen) Makefile dependency cleanup(Jeroen van Vianen)
ASSERT fixes(Bruce) ASSERT fixes(Bruce)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -5016,7 +5016,7 @@ refer to the installation and migration instructions for version 6.3. ...@@ -5016,7 +5016,7 @@ refer to the installation and migration instructions for version 6.3.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
ecpg cleanup/fixes, now version 1.1(Michael Meskes) ecpg cleanup/fixes, now version 1.1(Michael Meskes)
pg_user cleanup(Bruce) pg_user cleanup(Bruce)
large object fix for pg_dump and tclsh (alvin) large object fix for pg_dump and tclsh (alvin)
...@@ -5044,7 +5044,7 @@ Fix Alpha port(Dwayne Bailey) ...@@ -5044,7 +5044,7 @@ Fix Alpha port(Dwayne Bailey)
Fix for text arrays containing quotes(Doug Gibson) Fix for text arrays containing quotes(Doug Gibson)
Solaris compile fix(Albert Chin-A-Young) Solaris compile fix(Albert Chin-A-Young)
Better identify tcl and tk libs and includes(Bruce) Better identify tcl and tk libs and includes(Bruce)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -5191,7 +5191,7 @@ Better identify tcl and tk libs and includes(Bruce) ...@@ -5191,7 +5191,7 @@ Better identify tcl and tk libs and includes(Bruce)
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Bug Fixes Bug Fixes
--------- ---------
Fix binary cursors broken by MOVE implementation(Vadim) Fix binary cursors broken by MOVE implementation(Vadim)
...@@ -5413,7 +5413,7 @@ Another way to avoid dump/reload is to use the following SQL command ...@@ -5413,7 +5413,7 @@ Another way to avoid dump/reload is to use the following SQL command
from <command>psql</command> to update the existing system table: from <command>psql</command> to update the existing system table:
<programlisting> <programlisting>
update pg_aggregate set aggfinalfn = 'cash_div_flt8' update pg_aggregate set aggfinalfn = 'cash_div_flt8'
where aggname = 'avg' and aggbasetype = 790; where aggname = 'avg' and aggbasetype = 790;
</programlisting> </programlisting>
</para> </para>
...@@ -5426,7 +5426,7 @@ This will need to be done to every existing database, including template1. ...@@ -5426,7 +5426,7 @@ This will need to be done to every existing database, including template1.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Allow TIME and TYPE column names(Thomas) Allow TIME and TYPE column names(Thomas)
Allow larger range of true/false as boolean values(Thomas) Allow larger range of true/false as boolean values(Thomas)
Support output of "now" and "current"(Thomas) Support output of "now" and "current"(Thomas)
...@@ -5438,7 +5438,7 @@ Fix avg(cash) computation(Thomas) ...@@ -5438,7 +5438,7 @@ Fix avg(cash) computation(Thomas)
Fix for specifying a column twice in ORDER/GROUP BY(Vadim) Fix for specifying a column twice in ORDER/GROUP BY(Vadim)
Documented new libpq function to return affected rows, PQcmdTuples(Bruce) Documented new libpq function to return affected rows, PQcmdTuples(Bruce)
Trigger function for inserting user names for INSERT/UPDATE(Brook Milligan) Trigger function for inserting user names for INSERT/UPDATE(Brook Milligan)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -5482,7 +5482,7 @@ because the COPY output format was improved from the 1.02 release. ...@@ -5482,7 +5482,7 @@ because the COPY output format was improved from the 1.02 release.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Bug Fixes Bug Fixes
--------- ---------
Fix problems with pg_dump for inheritance, sequences, archive tables(Bruce) Fix problems with pg_dump for inheritance, sequences, archive tables(Bruce)
...@@ -5618,7 +5618,7 @@ Refer to the release notes for 6.1 for more details. ...@@ -5618,7 +5618,7 @@ Refer to the release notes for 6.1 for more details.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
fix for SET with options (Thomas) fix for SET with options (Thomas)
allow pg_dump/pg_dumpall to preserve ownership of all tables/objects(Bruce) allow pg_dump/pg_dumpall to preserve ownership of all tables/objects(Bruce)
new psql \connect option allows changing usernames without changing databases new psql \connect option allows changing usernames without changing databases
...@@ -5636,7 +5636,7 @@ major fix for endian handling of communication to server(Thomas, Tatsuo) ...@@ -5636,7 +5636,7 @@ major fix for endian handling of communication to server(Thomas, Tatsuo)
Fix for Solaris assembler and include files(Yoshihiko Ichikawa) Fix for Solaris assembler and include files(Yoshihiko Ichikawa)
allow underscores in usernames(Bruce) allow underscores in usernames(Bruce)
pg_dumpall now returns proper status, portability fix(Bruce) pg_dumpall now returns proper status, portability fix(Bruce)
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
</sect1> </sect1>
...@@ -5713,7 +5713,7 @@ because the COPY output format was improved from the 1.02 release. ...@@ -5713,7 +5713,7 @@ because the COPY output format was improved from the 1.02 release.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Bug Fixes Bug Fixes
--------- ---------
packet length checking in library routines packet length checking in library routines
...@@ -5848,7 +5848,7 @@ because the COPY output format was improved from the 1.02 release. ...@@ -5848,7 +5848,7 @@ because the COPY output format was improved from the 1.02 release.
<title>Changes</title> <title>Changes</title>
<para> <para>
<programlisting> <programlisting>
Bug Fixes Bug Fixes
--------- ---------
ALTER TABLE bug - running postgres process needs to re-read table definition ALTER TABLE bug - running postgres process needs to re-read table definition
...@@ -6017,7 +6017,7 @@ Add the new built-in functions and operators of 1.02.1 to 1.01 or 1.02 ...@@ -6017,7 +6017,7 @@ Add the new built-in functions and operators of 1.02.1 to 1.01 or 1.02
1.01 or 1.02 database is named <literal>testdb</literal> and you have cut the commands 1.01 or 1.02 database is named <literal>testdb</literal> and you have cut the commands
from the end of this file and saved them in <filename>addfunc.sql</filename>: from the end of this file and saved them in <filename>addfunc.sql</filename>:
<programlisting> <programlisting>
% psql testdb -f addfunc.sql % psql testdb -f addfunc.sql
</programlisting> </programlisting>
Those upgrading 1.02 databases will get a warning when executing the Those upgrading 1.02 databases will get a warning when executing the
...@@ -6040,7 +6040,7 @@ end-of-data marker. Also, empty strings are now loaded in as '' rather ...@@ -6040,7 +6040,7 @@ end-of-data marker. Also, empty strings are now loaded in as '' rather
than NULL. See the copy manual page for full details. than NULL. See the copy manual page for full details.
<programlisting> <programlisting>
sed 's/^\.$/\\./g' &lt;in_file &gt;out_file sed 's/^\.$/\\./g' &lt;in_file &gt;out_file
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -6169,7 +6169,7 @@ If you do, you must create a file name <literal>pg_hba</literal> in your top-lev ...@@ -6169,7 +6169,7 @@ If you do, you must create a file name <literal>pg_hba</literal> in your top-lev
If you do not want host-based authentication, you can comment out If you do not want host-based authentication, you can comment out
the line: the line:
<programlisting> <programlisting>
HBA = 1 HBA = 1
</programlisting> </programlisting>
in <filename>src/Makefile.global</filename> in <filename>src/Makefile.global</filename>
</para> </para>
...@@ -6218,7 +6218,7 @@ Add the new built-in functions and operators of 1.01 to 1.0 ...@@ -6218,7 +6218,7 @@ Add the new built-in functions and operators of 1.01 to 1.0
If your 1.0 database is name <literal>testdb</literal>: If your 1.0 database is name <literal>testdb</literal>:
<programlisting> <programlisting>
% psql testdb -f 1.0_to_1.01.sql % psql testdb -f 1.0_to_1.01.sql
</programlisting> </programlisting>
and then execute the following commands (cut and paste from here): and then execute the following commands (cut and paste from here):
...@@ -6563,11 +6563,11 @@ Initial release. ...@@ -6563,11 +6563,11 @@ Initial release.
<para> <para>
These timing results are from running the regression test with the commands These timing results are from running the regression test with the commands
<programlisting> <programlisting>
% cd src/test/regress % cd src/test/regress
% make all % make all
% time make runtest % time make runtest
</programlisting> </programlisting>
</para> </para>
<para> <para>
Timing under Linux 2.0.27 seems to have a roughly 5% variation from run Timing under Linux 2.0.27 seems to have a roughly 5% variation from run
...@@ -6587,20 +6587,20 @@ Initial release. ...@@ -6587,20 +6587,20 @@ Initial release.
<para> <para>
Timing with <function>fsync()</function> disabled: Timing with <function>fsync()</function> disabled:
<programlisting> <literallayout class="monospaced">
Time System Time System
02:00 Dual Pentium Pro 180, 224MB, UW-SCSI, Linux 2.0.36, gcc 2.7.2.3 -O2 -m486 02:00 Dual Pentium Pro 180, 224MB, UW-SCSI, Linux 2.0.36, gcc 2.7.2.3 -O2 -m486
04:38 Sparc Ultra 1 143MHz, 64MB, Solaris 2.6 04:38 Sparc Ultra 1 143MHz, 64MB, Solaris 2.6
</programlisting> </literallayout>
</para> </para>
<para> <para>
Timing with <function>fsync()</function> enabled: Timing with <function>fsync()</function> enabled:
<programlisting> <literallayout class="monospaced">
Time System Time System
04:21 Dual Pentium Pro 180, 224MB, UW-SCSI, Linux 2.0.36, gcc 2.7.2.3 -O2 -m486 04:21 Dual Pentium Pro 180, 224MB, UW-SCSI, Linux 2.0.36, gcc 2.7.2.3 -O2 -m486
</programlisting> </literallayout>
For the <systemitem class="osname">Linux</systemitem> system above, using <acronym>UW-SCSI</acronym> disks rather than (older) <acronym>IDE</acronym> For the <systemitem class="osname">Linux</systemitem> system above, using <acronym>UW-SCSI</acronym> disks rather than (older) <acronym>IDE</acronym>
disks leads to a 50% improvement in speed on the regression test. disks leads to a 50% improvement in speed on the regression test.
...@@ -6616,10 +6616,10 @@ since some additional regression tests have been included. ...@@ -6616,10 +6616,10 @@ since some additional regression tests have been included.
In general, however, 6.4 should be slightly faster than the previous release (thanks, Bruce!). In general, however, 6.4 should be slightly faster than the previous release (thanks, Bruce!).
</para> </para>
<para> <para>
<programlisting> <literallayout class="monospaced">
Time System Time System
02:26 Dual Pentium Pro 180, 96MB, UW-SCSI, Linux 2.0.30, gcc 2.7.2.1 -O2 -m486 02:26 Dual Pentium Pro 180, 96MB, UW-SCSI, Linux 2.0.30, gcc 2.7.2.1 -O2 -m486
</programlisting> </literallayout>
</para> </para>
</sect2> </sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/seg.sgml,v 1.6 2009/12/08 20:08:30 mha Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/seg.sgml,v 1.7 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="seg"> <sect1 id="seg">
<title>seg</title> <title>seg</title>
...@@ -39,13 +39,13 @@ ...@@ -39,13 +39,13 @@
6.50, and you input this reading into the database. What do you get 6.50, and you input this reading into the database. What do you get
when you fetch it? Watch: when you fetch it? Watch:
<programlisting> <screen>
test=> select 6.50 :: float8 as "pH"; test=> select 6.50 :: float8 as "pH";
pH pH
--- ---
6.5 6.5
(1 row) (1 row)
</programlisting> </screen>
In the world of measurements, 6.50 is not the same as 6.5. It may In the world of measurements, 6.50 is not the same as 6.5. It may
sometimes be critically different. The experimenters usually write sometimes be critically different. The experimenters usually write
...@@ -65,13 +65,13 @@ test=> select 6.50 :: float8 as "pH"; ...@@ -65,13 +65,13 @@ test=> select 6.50 :: float8 as "pH";
<para> <para>
Check this out: Check this out:
<programlisting> <screen>
test=> select '6.25 .. 6.50'::seg as "pH"; test=> select '6.25 .. 6.50'::seg as "pH";
pH pH
------------ ------------
6.25 .. 6.50 6.25 .. 6.50
(1 row) (1 row)
</programlisting> </screen>
</para> </para>
</sect2> </sect2>
...@@ -234,85 +234,75 @@ test=> select '6.25 .. 6.50'::seg as "pH"; ...@@ -234,85 +234,75 @@ test=> select '6.25 .. 6.50'::seg as "pH";
<para> <para>
The <filename>seg</> module includes a GiST index operator class for The <filename>seg</> module includes a GiST index operator class for
<type>seg</> values. <type>seg</> values.
The operators supported by the GiST opclass include: The operators supported by the GiST opclass are shown in <xref linkend="seg-gist-operators">.
</para> </para>
<itemizedlist> <table id="seg-gist-operators">
<listitem> <title>Seg GiST operators</title>
<programlisting> <tgroup cols="2">
[a, b] &lt;&lt; [c, d] Is left of <thead>
</programlisting> <row>
<para> <entry>Operator</entry>
[a, b] is entirely to the left of [c, d]. That is, <entry>Description</entry>
[a, b] &lt;&lt; [c, d] is true if b &lt; c and false otherwise </row>
</para> </thead>
</listitem>
<listitem> <tbody>
<programlisting> <row>
[a, b] &gt;&gt; [c, d] Is right of <entry><literal>[a, b] &lt;&lt; [c, d]</literal></entry>
</programlisting> <entry>[a, b] is entirely to the left of [c, d]. That is, [a,
<para> b] &lt;&lt; [c, d] is true if b &lt; c and false otherwise.</entry>
[a, b] is entirely to the right of [c, d]. That is, </row>
[a, b] &gt;&gt; [c, d] is true if a &gt; d and false otherwise
</para> <row>
</listitem> <entry><literal>[a, b] &gt;&gt; [c, d]</literal></entry>
<listitem> <entry>[a, b] is entirely to the right of [c, d]. That is, [a,
<programlisting> b] &gt;&gt; [c, d] is true if a &gt; d and false otherwise.</entry>
[a, b] &amp;&lt; [c, d] Overlaps or is left of </row>
</programlisting>
<para> <row>
This might be better read as <quote>does not extend to right of</quote>. <entry><literal>[a, b] &amp;&lt; [c, d]</literal></entry>
It is true when b &lt;= d. <entry>Overlaps or is left of &mdash; This might be better read
</para> as <quote>does not extend to right of</quote>. It is true when
</listitem> b &lt;= d.</entry>
<listitem> </row>
<programlisting>
[a, b] &amp;&gt; [c, d] Overlaps or is right of <row>
</programlisting> <entry><literal>[a, b] &amp;&gt; [c, d]</literal></entry>
<para> <entry>Overlaps or is right of &mdash; This might be better read
This might be better read as <quote>does not extend to left of</quote>. as <quote>does not extend to left of</quote>. It is true when
It is true when a &gt;= c. a &gt;= c.</entry>
</para> </row>
</listitem>
<listitem> <row>
<programlisting> <entry><literal>[a, b] = [c, d]</literal></entry>
[a, b] = [c, d] Same as <entry>Same as &mdash; The segments [a, b] and [c, d] are
</programlisting> identical, that is, a = c and b = d.</entry>
<para> </row>
The segments [a, b] and [c, d] are identical, that is, a = c and b = d
</para> <row>
</listitem> <entry><literal>[a, b] &amp;&amp; [c, d]</literal></entry>
<listitem> <entry>The segments [a, b] and [c, d] overlap.</entry>
<programlisting> </row>
[a, b] &amp;&amp; [c, d] Overlaps
</programlisting> <row>
<para> <entry><literal>[a, b] @&gt; [c, d]</literal></entry>
The segments [a, b] and [c, d] overlap. <entry>The segment [a, b] contains the segment [c, d], that is,
</para> a &lt;= c and b &gt;= d.</entry>
</listitem> </row>
<listitem>
<programlisting> <row>
[a, b] @&gt; [c, d] Contains <entry><literal>[a, b] &lt;@ [c, d]</literal></entry>
</programlisting> <entry>The segment [a, b] is contained in [c, d], that is, a
<para> &gt;= c and b &lt;= d.</entry>
The segment [a, b] contains the segment [c, d], that is, </row>
a &lt;= c and b &gt;= d </tbody>
</para> </tgroup>
</listitem> </table>
<listitem>
<programlisting>
[a, b] &lt;@ [c, d] Contained in
</programlisting>
<para>
The segment [a, b] is contained in [c, d], that is,
a &gt;= c and b &lt;= d
</para>
</listitem>
</itemizedlist>
<para> <para>
(Before PostgreSQL 8.2, the containment operators @&gt; and &lt;@ were (Before PostgreSQL 8.2, the containment operators <literal>@&gt;</> and <literal>&lt;@</> were
respectively called @ and ~. These names are still available, but are respectively called <literal>@</> and <literal>~</>. These names are still available, but are
deprecated and will eventually be retired. Notice that the old names deprecated and will eventually be retired. Notice that the old names
are reversed from the convention formerly followed by the core geometric are reversed from the convention formerly followed by the core geometric
datatypes!) datatypes!)
...@@ -321,10 +311,28 @@ test=> select '6.25 .. 6.50'::seg as "pH"; ...@@ -321,10 +311,28 @@ test=> select '6.25 .. 6.50'::seg as "pH";
<para> <para>
The standard B-tree operators are also provided, for example The standard B-tree operators are also provided, for example
<programlisting> <informaltable>
[a, b] &lt; [c, d] Less than <tgroup cols="2">
[a, b] &gt; [c, d] Greater than <thead>
</programlisting> <row>
<entry>Operator</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>[a, b] &lt; [c, d]</literal></entry>
<entry>Less than</entry>
</row>
<row>
<entry><literal>[a, b] &gt; [c, d]</literal></entry>
<entry>Greater than</entry>
</row>
</tbody>
</tgroup>
</informaltable>
These operators do not make a lot of sense for any practical These operators do not make a lot of sense for any practical
purpose but sorting. These operators first compare (a) to (c), purpose but sorting. These operators first compare (a) to (c),
...@@ -347,12 +355,12 @@ test=> select '6.25 .. 6.50'::seg as "pH"; ...@@ -347,12 +355,12 @@ test=> select '6.25 .. 6.50'::seg as "pH";
for the boundaries. For example, it adds an extra digit to the lower for the boundaries. For example, it adds an extra digit to the lower
boundary if the resulting interval includes a power of ten: boundary if the resulting interval includes a power of ten:
<programlisting> <screen>
postgres=> select '10(+-)1'::seg as seg; postgres=> select '10(+-)1'::seg as seg;
seg seg
--------- ---------
9.0 .. 11 -- should be: 9 .. 11 9.0 .. 11 -- should be: 9 .. 11
</programlisting> </screen>
</para> </para>
<para> <para>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/sql.sgml,v 1.48 2009/04/27 16:27:36 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/sql.sgml,v 1.49 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="sql-intro"> <chapter id="sql-intro">
<title>SQL</title> <title>SQL</title>
...@@ -151,7 +151,7 @@ ...@@ -151,7 +151,7 @@
<example> <example>
<title id="supplier-fig">The Suppliers and Parts Database</title> <title id="supplier-fig">The Suppliers and Parts Database</title>
<programlisting> <screen>
SUPPLIER: SELLS: SUPPLIER: SELLS:
SNO | SNAME | CITY SNO | PNO SNO | SNAME | CITY SNO | PNO
----+---------+-------- -----+----- ----+---------+-------- -----+-----
...@@ -168,7 +168,7 @@ PART: 4 | 3 ...@@ -168,7 +168,7 @@ PART: 4 | 3
2 | Nut | 8 2 | Nut | 8
3 | Bolt | 15 3 | Bolt | 15
4 | Cam | 25 4 | Cam | 25
</programlisting> </screen>
</example> </example>
</para> </para>
...@@ -530,14 +530,14 @@ attributes are taken from. We often write a relation scheme as ...@@ -530,14 +530,14 @@ attributes are taken from. We often write a relation scheme as
necessary for a join. necessary for a join.
Let the following two tables be given: Let the following two tables be given:
<programlisting> <screen>
R: S: R: S:
A | B | C C | D | E A | B | C C | D | E
---+---+--- ---+---+--- ---+---+--- ---+---+---
1 | 2 | 3 3 | a | b 1 | 2 | 3 3 | a | b
4 | 5 | 6 6 | c | d 4 | 5 | 6 6 | c | d
7 | 8 | 9 7 | 8 | 9
</programlisting> </screen>
</para> </para>
</example> </example>
...@@ -546,7 +546,7 @@ R: S: ...@@ -546,7 +546,7 @@ R: S:
<classname>R</classname> &times; <classname>S</classname> and <classname>R</classname> &times; <classname>S</classname> and
get: get:
<programlisting> <screen>
R x S: R x S:
A | B | R.C | S.C | D | E A | B | R.C | S.C | D | E
---+---+-----+-----+---+--- ---+---+-----+-----+---+---
...@@ -556,7 +556,7 @@ R x S: ...@@ -556,7 +556,7 @@ R x S:
4 | 5 | 6 | 6 | c | d 4 | 5 | 6 | 6 | c | d
7 | 8 | 9 | 3 | a | b 7 | 8 | 9 | 3 | a | b
7 | 8 | 9 | 6 | c | d 7 | 8 | 9 | 6 | c | d
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -564,12 +564,12 @@ R x S: ...@@ -564,12 +564,12 @@ R x S:
&sigma;<subscript>R.C=S.C</subscript>(R &times; S) &sigma;<subscript>R.C=S.C</subscript>(R &times; S)
we get: we get:
<programlisting> <screen>
A | B | R.C | S.C | D | E A | B | R.C | S.C | D | E
---+---+-----+-----+---+--- ---+---+-----+-----+---+---
1 | 2 | 3 | 3 | a | b 1 | 2 | 3 | 3 | a | b
4 | 5 | 6 | 6 | c | d 4 | 5 | 6 | 6 | c | d
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -579,12 +579,12 @@ R x S: ...@@ -579,12 +579,12 @@ R x S:
&pi;<subscript>R.A,R.B,R.C,S.D,S.E</subscript>(&sigma;<subscript>R.C=S.C</subscript>(R &times; S)) &pi;<subscript>R.A,R.B,R.C,S.D,S.E</subscript>(&sigma;<subscript>R.C=S.C</subscript>(R &times; S))
and get: and get:
<programlisting> <screen>
A | B | C | D | E A | B | C | D | E
---+---+---+---+--- ---+---+---+---+---
1 | 2 | 3 | a | b 1 | 2 | 3 | a | b
4 | 5 | 6 | c | d 4 | 5 | 6 | c | d
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
...@@ -596,9 +596,9 @@ R x S: ...@@ -596,9 +596,9 @@ R x S:
C and D. C and D.
Then we define the division as: Then we define the division as:
<programlisting> <programlisting>
R &divide; S = {t &mid; &forall; t<subscript>s</subscript> &isin; S &exist; t<subscript>r</subscript> &isin; R R &divide; S = {t &mid; &forall; t<subscript>s</subscript> &isin; S &exist; t<subscript>r</subscript> &isin; R
</programlisting> </programlisting>
such that such that
t<subscript>r</subscript>(A,B)=t&and;t<subscript>r</subscript>(C,D)=t<subscript>s</subscript>} t<subscript>r</subscript>(A,B)=t&and;t<subscript>r</subscript>(C,D)=t<subscript>s</subscript>}
...@@ -615,7 +615,7 @@ t<subscript>r</subscript>(A,B)=t&and;t<subscript>r</subscript>(C,D)=t<subscript> ...@@ -615,7 +615,7 @@ t<subscript>r</subscript>(A,B)=t&and;t<subscript>r</subscript>(C,D)=t<subscript>
<para id="divide-example"> <para id="divide-example">
Given the following tables Given the following tables
<programlisting> <screen>
R: S: R: S:
A | B | C | D C | D A | B | C | D C | D
---+---+---+--- ---+--- ---+---+---+--- ---+---
...@@ -625,17 +625,17 @@ R: S: ...@@ -625,17 +625,17 @@ R: S:
e | d | c | d e | d | c | d
e | d | e | f e | d | e | f
a | b | d | e a | b | d | e
</programlisting> </screen>
R &divide; S R &divide; S
is derived as is derived as
<programlisting> <screen>
A | B A | B
---+--- ---+---
a | b a | b
e | d e | d
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
...@@ -659,9 +659,9 @@ R: S: ...@@ -659,9 +659,9 @@ R: S:
This question can be answered This question can be answered
using relational algebra by the following operation: using relational algebra by the following operation:
<programlisting> <programlisting>
&pi;<subscript>SUPPLIER.SNAME</subscript>(&sigma;<subscript>PART.PNAME='Screw'</subscript>(SUPPLIER &prod; SELLS &prod; PART)) &pi;<subscript>SUPPLIER.SNAME</subscript>(&sigma;<subscript>PART.PNAME='Screw'</subscript>(SUPPLIER &prod; SELLS &prod; PART))
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -670,12 +670,12 @@ R: S: ...@@ -670,12 +670,12 @@ R: S:
(<xref linkend="supplier-fig" endterm="supplier-fig">) (<xref linkend="supplier-fig" endterm="supplier-fig">)
we will obtain the following result: we will obtain the following result:
<programlisting> <screen>
SNAME SNAME
------- -------
Smith Smith
Adams Adams
</programlisting> </screen>
</para> </para>
</example> </example>
</sect2> </sect2>
...@@ -724,9 +724,9 @@ R: S: ...@@ -724,9 +724,9 @@ R: S:
The queries used in <acronym>TRC</acronym> are of the following The queries used in <acronym>TRC</acronym> are of the following
form: form:
<programlisting> <programlisting>
x(A) &mid; F(x) x(A) &mid; F(x)
</programlisting> </programlisting>
where <literal>x</literal> is a tuple variable where <literal>x</literal> is a tuple variable
<classname>A</classname> is a set of attributes and <literal>F</literal> is a <classname>A</classname> is a set of attributes and <literal>F</literal> is a
...@@ -739,12 +739,12 @@ x(A) &mid; F(x) ...@@ -739,12 +739,12 @@ x(A) &mid; F(x)
<xref linkend="suppl-rel-alg" endterm="suppl-rel-alg"> <xref linkend="suppl-rel-alg" endterm="suppl-rel-alg">
using <acronym>TRC</acronym> we formulate the following query: using <acronym>TRC</acronym> we formulate the following query:
<programlisting> <programlisting>
{x(SNAME) &mid; x &isin; SUPPLIER &and; {x(SNAME) &mid; x &isin; SUPPLIER &and;
&exist; y &isin; SELLS &exist; z &isin; PART (y(SNO)=x(SNO) &and; &exist; y &isin; SELLS &exist; z &isin; PART (y(SNO)=x(SNO) &and;
z(PNO)=y(PNO) &and; z(PNO)=y(PNO) &and;
z(PNAME)='Screw')} z(PNAME)='Screw')}
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -813,9 +813,9 @@ x(A) &mid; F(x) ...@@ -813,9 +813,9 @@ x(A) &mid; F(x)
to involve to involve
arithmetic operations as well as comparisons, e.g.: arithmetic operations as well as comparisons, e.g.:
<programlisting> <programlisting>
A &lt; B + 3. A &lt; B + 3.
</programlisting> </programlisting>
Note Note
that + or other arithmetic operators appear neither in relational that + or other arithmetic operators appear neither in relational
...@@ -851,7 +851,7 @@ A &lt; B + 3. ...@@ -851,7 +851,7 @@ A &lt; B + 3.
<command>SELECT</command> statement, <command>SELECT</command> statement,
used to retrieve data. The syntax is: used to retrieve data. The syntax is:
<synopsis> <synopsis>
SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replaceable> [, ...] ) ] ] SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replaceable> [, ...] ) ] ]
* | <replaceable class="PARAMETER">expression</replaceable> [ [ AS ] <replaceable class="PARAMETER">output_name</replaceable> ] [, ...] * | <replaceable class="PARAMETER">expression</replaceable> [ [ AS ] <replaceable class="PARAMETER">output_name</replaceable> ] [, ...]
[ INTO [ TEMPORARY | TEMP ] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ] [ INTO [ TEMPORARY | TEMP ] [ TABLE ] <replaceable class="PARAMETER">new_table</replaceable> ]
...@@ -864,7 +864,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac ...@@ -864,7 +864,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac
[ LIMIT { <replaceable class="PARAMETER">count</replaceable> | ALL } ] [ LIMIT { <replaceable class="PARAMETER">count</replaceable> | ALL } ]
[ OFFSET <replaceable class="PARAMETER">start</replaceable> ] [ OFFSET <replaceable class="PARAMETER">start</replaceable> ]
[ FOR { UPDATE | SHARE } [ OF <replaceable class="parameter">table_name</replaceable> [, ...] ] [ NOWAIT ] [...] ] [ FOR { UPDATE | SHARE } [ OF <replaceable class="parameter">table_name</replaceable> [, ...] ] [ NOWAIT ] [...] ]
</synopsis> </synopsis>
</para> </para>
<para> <para>
...@@ -886,19 +886,19 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac ...@@ -886,19 +886,19 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac
To retrieve all tuples from table PART where the attribute PRICE is To retrieve all tuples from table PART where the attribute PRICE is
greater than 10 we formulate the following query: greater than 10 we formulate the following query:
<programlisting> <programlisting>
SELECT * FROM PART SELECT * FROM PART
WHERE PRICE &gt; 10; WHERE PRICE &gt; 10;
</programlisting> </programlisting>
and get the table: and get the table:
<programlisting> <screen>
PNO | PNAME | PRICE PNO | PNAME | PRICE
-----+---------+-------- -----+---------+--------
3 | Bolt | 15 3 | Bolt | 15
4 | Cam | 25 4 | Cam | 25
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -907,20 +907,20 @@ SELECT * FROM PART ...@@ -907,20 +907,20 @@ SELECT * FROM PART
only the attributes PNAME and PRICE from table PART we use the only the attributes PNAME and PRICE from table PART we use the
statement: statement:
<programlisting> <programlisting>
SELECT PNAME, PRICE SELECT PNAME, PRICE
FROM PART FROM PART
WHERE PRICE &gt; 10; WHERE PRICE &gt; 10;
</programlisting> </programlisting>
In this case the result is: In this case the result is:
<programlisting> <screen>
PNAME | PRICE PNAME | PRICE
--------+-------- --------+--------
Bolt | 15 Bolt | 15
Cam | 25 Cam | 25
</programlisting> </screen>
Note that the <acronym>SQL</acronym> <command>SELECT</command> Note that the <acronym>SQL</acronym> <command>SELECT</command>
corresponds to the <quote>projection</quote> in relational algebra corresponds to the <quote>projection</quote> in relational algebra
...@@ -932,20 +932,20 @@ SELECT PNAME, PRICE ...@@ -932,20 +932,20 @@ SELECT PNAME, PRICE
The qualifications in the WHERE clause can also be logically connected The qualifications in the WHERE clause can also be logically connected
using the keywords OR, AND, and NOT: using the keywords OR, AND, and NOT:
<programlisting> <programlisting>
SELECT PNAME, PRICE SELECT PNAME, PRICE
FROM PART FROM PART
WHERE PNAME = 'Bolt' AND WHERE PNAME = 'Bolt' AND
(PRICE = 0 OR PRICE &lt;= 15); (PRICE = 0 OR PRICE &lt;= 15);
</programlisting> </programlisting>
will lead to the result: will lead to the result:
<programlisting> <screen>
PNAME | PRICE PNAME | PRICE
--------+-------- --------+--------
Bolt | 15 Bolt | 15
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -953,21 +953,21 @@ SELECT PNAME, PRICE ...@@ -953,21 +953,21 @@ SELECT PNAME, PRICE
clause. For example if we want to know how much it would cost if we clause. For example if we want to know how much it would cost if we
take two pieces of a part we could use the following query: take two pieces of a part we could use the following query:
<programlisting> <programlisting>
SELECT PNAME, PRICE * 2 AS DOUBLE SELECT PNAME, PRICE * 2 AS DOUBLE
FROM PART FROM PART
WHERE PRICE * 2 &lt; 50; WHERE PRICE * 2 &lt; 50;
</programlisting> </programlisting>
and we get: and we get:
<programlisting> <screen>
PNAME | DOUBLE PNAME | DOUBLE
--------+--------- --------+---------
Screw | 20 Screw | 20
Nut | 16 Nut | 16
Bolt | 30 Bolt | 30
</programlisting> </screen>
Note that the word DOUBLE after the keyword AS is the new title of the Note that the word DOUBLE after the keyword AS is the new title of the
second column. This technique can be used for every element of the second column. This technique can be used for every element of the
...@@ -992,16 +992,16 @@ SELECT PNAME, PRICE * 2 AS DOUBLE ...@@ -992,16 +992,16 @@ SELECT PNAME, PRICE * 2 AS DOUBLE
To join the three tables SUPPLIER, PART and SELLS over their common To join the three tables SUPPLIER, PART and SELLS over their common
attributes we formulate the following statement: attributes we formulate the following statement:
<programlisting> <programlisting>
SELECT S.SNAME, P.PNAME SELECT S.SNAME, P.PNAME
FROM SUPPLIER S, PART P, SELLS SE FROM SUPPLIER S, PART P, SELLS SE
WHERE S.SNO = SE.SNO AND WHERE S.SNO = SE.SNO AND
P.PNO = SE.PNO; P.PNO = SE.PNO;
</programlisting> </programlisting>
and get the following table as a result: and get the following table as a result:
<programlisting> <screen>
SNAME | PNAME SNAME | PNAME
-------+------- -------+-------
Smith | Screw Smith | Screw
...@@ -1012,7 +1012,7 @@ SELECT S.SNAME, P.PNAME ...@@ -1012,7 +1012,7 @@ SELECT S.SNAME, P.PNAME
Blake | Nut Blake | Nut
Blake | Bolt Blake | Bolt
Blake | Cam Blake | Cam
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1034,13 +1034,13 @@ SELECT S.SNAME, P.PNAME ...@@ -1034,13 +1034,13 @@ SELECT S.SNAME, P.PNAME
<para> <para>
Another way to perform joins is to use the SQL JOIN syntax as follows: Another way to perform joins is to use the SQL JOIN syntax as follows:
<programlisting> <programlisting>
select sname, pname from supplier SELECT sname, pname from supplier
JOIN sells USING (sno) JOIN sells USING (sno)
JOIN part USING (pno); JOIN part USING (pno);
</programlisting> </programlisting>
giving again: giving again:
<programlisting> <screen>
sname | pname sname | pname
-------+------- -------+-------
Smith | Screw Smith | Screw
...@@ -1052,7 +1052,7 @@ select sname, pname from supplier ...@@ -1052,7 +1052,7 @@ select sname, pname from supplier
Jones | Cam Jones | Cam
Blake | Cam Blake | Cam
(8 rows) (8 rows)
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1267,38 +1267,38 @@ select sname, pname from supplier ...@@ -1267,38 +1267,38 @@ select sname, pname from supplier
If we want to know the average cost of all parts in table PART we use If we want to know the average cost of all parts in table PART we use
the following query: the following query:
<programlisting> <programlisting>
SELECT AVG(PRICE) AS AVG_PRICE SELECT AVG(PRICE) AS AVG_PRICE
FROM PART; FROM PART;
</programlisting> </programlisting>
</para> </para>
<para> <para>
The result is: The result is:
<programlisting> <screen>
AVG_PRICE AVG_PRICE
----------- -----------
14.5 14.5
</programlisting> </screen>
</para> </para>
<para> <para>
If we want to know how many parts are defined in table PART we use If we want to know how many parts are defined in table PART we use
the statement: the statement:
<programlisting> <programlisting>
SELECT COUNT(PNO) SELECT COUNT(PNO)
FROM PART; FROM PART;
</programlisting> </programlisting>
and get: and get:
<programlisting> <screen>
COUNT COUNT
------- -------
4 4
</programlisting> </screen>
</para> </para>
</example> </example>
...@@ -1335,23 +1335,23 @@ SELECT COUNT(PNO) ...@@ -1335,23 +1335,23 @@ SELECT COUNT(PNO)
If we want to know how many parts are sold by every supplier we If we want to know how many parts are sold by every supplier we
formulate the query: formulate the query:
<programlisting> <programlisting>
SELECT S.SNO, S.SNAME, COUNT(SE.PNO) SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
FROM SUPPLIER S, SELLS SE FROM SUPPLIER S, SELLS SE
WHERE S.SNO = SE.SNO WHERE S.SNO = SE.SNO
GROUP BY S.SNO, S.SNAME; GROUP BY S.SNO, S.SNAME;
</programlisting> </programlisting>
and get: and get:
<programlisting> <screen>
SNO | SNAME | COUNT SNO | SNAME | COUNT
-----+-------+------- -----+-------+-------
1 | Smith | 2 1 | Smith | 2
2 | Jones | 1 2 | Jones | 1
3 | Adams | 2 3 | Adams | 2
4 | Blake | 3 4 | Blake | 3
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1359,7 +1359,7 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO) ...@@ -1359,7 +1359,7 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
First the join of the First the join of the
tables SUPPLIER and SELLS is derived: tables SUPPLIER and SELLS is derived:
<programlisting> <screen>
S.SNO | S.SNAME | SE.PNO S.SNO | S.SNAME | SE.PNO
-------+---------+-------- -------+---------+--------
1 | Smith | 1 1 | Smith | 1
...@@ -1370,14 +1370,14 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO) ...@@ -1370,14 +1370,14 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
4 | Blake | 2 4 | Blake | 2
4 | Blake | 3 4 | Blake | 3
4 | Blake | 4 4 | Blake | 4
</programlisting> </screen>
</para> </para>
<para> <para>
Next we partition the tuples into groups by putting all tuples Next we partition the tuples into groups by putting all tuples
together that agree on both attributes S.SNO and S.SNAME: together that agree on both attributes S.SNO and S.SNAME:
<programlisting> <screen>
S.SNO | S.SNAME | SE.PNO S.SNO | S.SNAME | SE.PNO
-------+---------+-------- -------+---------+--------
1 | Smith | 1 1 | Smith | 1
...@@ -1391,7 +1391,7 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO) ...@@ -1391,7 +1391,7 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
4 | Blake | 2 4 | Blake | 2
| 3 | 3
| 4 | 4
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1442,23 +1442,23 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO) ...@@ -1442,23 +1442,23 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
If we want only those suppliers selling more than one part we use the If we want only those suppliers selling more than one part we use the
query: query:
<programlisting> <programlisting>
SELECT S.SNO, S.SNAME, COUNT(SE.PNO) SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
FROM SUPPLIER S, SELLS SE FROM SUPPLIER S, SELLS SE
WHERE S.SNO = SE.SNO WHERE S.SNO = SE.SNO
GROUP BY S.SNO, S.SNAME GROUP BY S.SNO, S.SNAME
HAVING COUNT(SE.PNO) &gt; 1; HAVING COUNT(SE.PNO) &gt; 1;
</programlisting> </programlisting>
and get: and get:
<programlisting> <screen>
SNO | SNAME | COUNT SNO | SNAME | COUNT
-----+-------+------- -----+-------+-------
1 | Smith | 2 1 | Smith | 2
3 | Adams | 2 3 | Adams | 2
4 | Blake | 3 4 | Blake | 3
</programlisting> </screen>
</para> </para>
</example> </example>
</para> </para>
...@@ -1481,23 +1481,23 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO) ...@@ -1481,23 +1481,23 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
If we want to know all parts having a greater price than the part If we want to know all parts having a greater price than the part
named 'Screw' we use the query: named 'Screw' we use the query:
<programlisting> <programlisting>
SELECT * SELECT *
FROM PART FROM PART
WHERE PRICE &gt; (SELECT PRICE FROM PART WHERE PRICE &gt; (SELECT PRICE FROM PART
WHERE PNAME='Screw'); WHERE PNAME='Screw');
</programlisting> </programlisting>
</para> </para>
<para> <para>
The result is: The result is:
<programlisting> <screen>
PNO | PNAME | PRICE PNO | PNAME | PRICE
-----+---------+-------- -----+---------+--------
3 | Bolt | 15 3 | Bolt | 15
4 | Cam | 25 4 | Cam | 25
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1519,13 +1519,13 @@ SELECT * ...@@ -1519,13 +1519,13 @@ SELECT *
If we want to know all suppliers that do not sell any part If we want to know all suppliers that do not sell any part
(e.g., to be able to remove these suppliers from the database) we use: (e.g., to be able to remove these suppliers from the database) we use:
<programlisting> <programlisting>
SELECT * SELECT *
FROM SUPPLIER S FROM SUPPLIER S
WHERE NOT EXISTS WHERE NOT EXISTS
(SELECT * FROM SELLS SE (SELECT * FROM SELLS SE
WHERE SE.SNO = S.SNO); WHERE SE.SNO = S.SNO);
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -1559,14 +1559,14 @@ SELECT * ...@@ -1559,14 +1559,14 @@ SELECT *
If we want to know the highest average part price among all our If we want to know the highest average part price among all our
suppliers, we cannot write MAX(AVG(PRICE)), but we can write: suppliers, we cannot write MAX(AVG(PRICE)), but we can write:
<programlisting> <programlisting>
SELECT MAX(subtable.avgprice) SELECT MAX(subtable.avgprice)
FROM (SELECT AVG(P.PRICE) AS avgprice FROM (SELECT AVG(P.PRICE) AS avgprice
FROM SUPPLIER S, PART P, SELLS SE FROM SUPPLIER S, PART P, SELLS SE
WHERE S.SNO = SE.SNO AND WHERE S.SNO = SE.SNO AND
P.PNO = SE.PNO P.PNO = SE.PNO
GROUP BY S.SNO) subtable; GROUP BY S.SNO) subtable;
</programlisting> </programlisting>
The subquery returns one row per supplier (because of its GROUP BY) The subquery returns one row per supplier (because of its GROUP BY)
and then we aggregate over those rows in the outer query. and then we aggregate over those rows in the outer query.
...@@ -1588,7 +1588,7 @@ SELECT MAX(subtable.avgprice) ...@@ -1588,7 +1588,7 @@ SELECT MAX(subtable.avgprice)
<para> <para>
The following query is an example for UNION: The following query is an example for UNION:
<programlisting> <programlisting>
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNAME = 'Jones' WHERE S.SNAME = 'Jones'
...@@ -1596,22 +1596,22 @@ UNION ...@@ -1596,22 +1596,22 @@ UNION
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNAME = 'Adams'; WHERE S.SNAME = 'Adams';
</programlisting> </programlisting>
gives the result: gives the result:
<programlisting> <screen>
SNO | SNAME | CITY SNO | SNAME | CITY
-----+-------+-------- -----+-------+--------
2 | Jones | Paris 2 | Jones | Paris
3 | Adams | Vienna 3 | Adams | Vienna
</programlisting> </screen>
</para> </para>
<para> <para>
Here is an example for INTERSECT: Here is an example for INTERSECT:
<programlisting> <programlisting>
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNO &gt; 1 WHERE S.SNO &gt; 1
...@@ -1619,15 +1619,15 @@ INTERSECT ...@@ -1619,15 +1619,15 @@ INTERSECT
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNO &lt; 3; WHERE S.SNO &lt; 3;
</programlisting> </programlisting>
gives the result: gives the result:
<programlisting> <screen>
SNO | SNAME | CITY SNO | SNAME | CITY
-----+-------+-------- -----+-------+--------
2 | Jones | Paris 2 | Jones | Paris
</programlisting> </screen>
The only tuple returned by both parts of the query is the one having SNO=2. The only tuple returned by both parts of the query is the one having SNO=2.
</para> </para>
...@@ -1635,7 +1635,7 @@ INTERSECT ...@@ -1635,7 +1635,7 @@ INTERSECT
<para> <para>
Finally an example for EXCEPT: Finally an example for EXCEPT:
<programlisting> <programlisting>
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNO &gt; 1 WHERE S.SNO &gt; 1
...@@ -1643,16 +1643,16 @@ EXCEPT ...@@ -1643,16 +1643,16 @@ EXCEPT
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNO &gt; 3; WHERE S.SNO &gt; 3;
</programlisting> </programlisting>
gives the result: gives the result:
<programlisting> <screen>
SNO | SNAME | CITY SNO | SNAME | CITY
-----+-------+-------- -----+-------+--------
2 | Jones | Paris 2 | Jones | Paris
3 | Adams | Vienna 3 | Adams | Vienna
</programlisting> </screen>
</para> </para>
</example> </example>
</para> </para>
...@@ -1675,12 +1675,12 @@ EXCEPT ...@@ -1675,12 +1675,12 @@ EXCEPT
one that creates a new relation (a new table). The syntax of the one that creates a new relation (a new table). The syntax of the
<command>CREATE TABLE</command> command is: <command>CREATE TABLE</command> command is:
<synopsis> <synopsis>
CREATE TABLE <replaceable class="parameter">table_name</replaceable> CREATE TABLE <replaceable class="parameter">table_name</replaceable>
(<replaceable class="parameter">name_of_attr_1</replaceable> <replaceable class="parameter">type_of_attr_1</replaceable> (<replaceable class="parameter">name_of_attr_1</replaceable> <replaceable class="parameter">type_of_attr_1</replaceable>
[, <replaceable class="parameter">name_of_attr_2</replaceable> <replaceable class="parameter">type_of_attr_2</replaceable> [, <replaceable class="parameter">name_of_attr_2</replaceable> <replaceable class="parameter">type_of_attr_2</replaceable>
[, ...]]); [, ...]]);
</synopsis> </synopsis>
<example> <example>
<title id="table-create">Table Creation</title> <title id="table-create">Table Creation</title>
...@@ -1690,25 +1690,25 @@ CREATE TABLE <replaceable class="parameter">table_name</replaceable> ...@@ -1690,25 +1690,25 @@ CREATE TABLE <replaceable class="parameter">table_name</replaceable>
<xref linkend="supplier-fig" endterm="supplier-fig"> the <xref linkend="supplier-fig" endterm="supplier-fig"> the
following <acronym>SQL</acronym> statements are used: following <acronym>SQL</acronym> statements are used:
<programlisting> <programlisting>
CREATE TABLE SUPPLIER CREATE TABLE SUPPLIER
(SNO INTEGER, (SNO INTEGER,
SNAME VARCHAR(20), SNAME VARCHAR(20),
CITY VARCHAR(20)); CITY VARCHAR(20));
</programlisting> </programlisting>
<programlisting> <programlisting>
CREATE TABLE PART CREATE TABLE PART
(PNO INTEGER, (PNO INTEGER,
PNAME VARCHAR(20), PNAME VARCHAR(20),
PRICE DECIMAL(4 , 2)); PRICE DECIMAL(4 , 2));
</programlisting> </programlisting>
<programlisting> <programlisting>
CREATE TABLE SELLS CREATE TABLE SELLS
(SNO INTEGER, (SNO INTEGER,
PNO INTEGER); PNO INTEGER);
</programlisting> </programlisting>
</para> </para>
</example> </example>
</para> </para>
...@@ -1791,10 +1791,10 @@ CREATE TABLE SELLS ...@@ -1791,10 +1791,10 @@ CREATE TABLE SELLS
To create an index in <acronym>SQL</acronym> To create an index in <acronym>SQL</acronym>
the <command>CREATE INDEX</command> command is used. The syntax is: the <command>CREATE INDEX</command> command is used. The syntax is:
<programlisting> <programlisting>
CREATE INDEX <replaceable class="parameter">index_name</replaceable> CREATE INDEX <replaceable class="parameter">index_name</replaceable>
ON <replaceable class="parameter">table_name</replaceable> ( <replaceable class="parameter">name_of_attribute</replaceable> ); ON <replaceable class="parameter">table_name</replaceable> ( <replaceable class="parameter">name_of_attribute</replaceable> );
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -1805,9 +1805,9 @@ CREATE INDEX <replaceable class="parameter">index_name</replaceable> ...@@ -1805,9 +1805,9 @@ CREATE INDEX <replaceable class="parameter">index_name</replaceable>
To create an index named I on attribute SNAME of relation SUPPLIER To create an index named I on attribute SNAME of relation SUPPLIER
we use the following statement: we use the following statement:
<programlisting> <programlisting>
CREATE INDEX I ON SUPPLIER (SNAME); CREATE INDEX I ON SUPPLIER (SNAME);
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -1855,10 +1855,10 @@ CREATE INDEX I ON SUPPLIER (SNAME); ...@@ -1855,10 +1855,10 @@ CREATE INDEX I ON SUPPLIER (SNAME);
command is used to define a view. The syntax command is used to define a view. The syntax
is: is:
<programlisting> <programlisting>
CREATE VIEW <replaceable class="parameter">view_name</replaceable> CREATE VIEW <replaceable class="parameter">view_name</replaceable>
AS <replaceable class="parameter">select_stmt</replaceable> AS <replaceable class="parameter">select_stmt</replaceable>
</programlisting> </programlisting>
where <replaceable class="parameter">select_stmt</replaceable> where <replaceable class="parameter">select_stmt</replaceable>
is a valid select statement as defined is a valid select statement as defined
...@@ -1874,14 +1874,14 @@ CREATE VIEW <replaceable class="parameter">view_name</replaceable> ...@@ -1874,14 +1874,14 @@ CREATE VIEW <replaceable class="parameter">view_name</replaceable>
the tables from the tables from
<xref linkend="supplier-fig" endterm="supplier-fig"> again): <xref linkend="supplier-fig" endterm="supplier-fig"> again):
<programlisting> <programlisting>
CREATE VIEW London_Suppliers CREATE VIEW London_Suppliers
AS SELECT S.SNAME, P.PNAME AS SELECT S.SNAME, P.PNAME
FROM SUPPLIER S, PART P, SELLS SE FROM SUPPLIER S, PART P, SELLS SE
WHERE S.SNO = SE.SNO AND WHERE S.SNO = SE.SNO AND
P.PNO = SE.PNO AND P.PNO = SE.PNO AND
S.CITY = 'London'; S.CITY = 'London';
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -1889,18 +1889,18 @@ CREATE VIEW London_Suppliers ...@@ -1889,18 +1889,18 @@ CREATE VIEW London_Suppliers
<classname>London_Suppliers</classname> as <classname>London_Suppliers</classname> as
if it were another base table: if it were another base table:
<programlisting> <programlisting>
SELECT * FROM London_Suppliers SELECT * FROM London_Suppliers
WHERE PNAME = 'Screw'; WHERE PNAME = 'Screw';
</programlisting> </programlisting>
which will return the following table: which will return the following table:
<programlisting> <screen>
SNAME | PNAME SNAME | PNAME
-------+------- -------+-------
Smith | Screw Smith | Screw
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1922,34 +1922,34 @@ SELECT * FROM London_Suppliers ...@@ -1922,34 +1922,34 @@ SELECT * FROM London_Suppliers
To destroy a table (including all tuples stored in that table) the To destroy a table (including all tuples stored in that table) the
<command>DROP TABLE</command> command is used: <command>DROP TABLE</command> command is used:
<programlisting> <programlisting>
DROP TABLE <replaceable class="parameter">table_name</replaceable>; DROP TABLE <replaceable class="parameter">table_name</replaceable>;
</programlisting> </programlisting>
</para> </para>
<para> <para>
To destroy the SUPPLIER table use the following statement: To destroy the SUPPLIER table use the following statement:
<programlisting> <programlisting>
DROP TABLE SUPPLIER; DROP TABLE SUPPLIER;
</programlisting> </programlisting>
</para> </para>
<para> <para>
The <command>DROP INDEX</command> command is used to destroy an index: The <command>DROP INDEX</command> command is used to destroy an index:
<programlisting> <programlisting>
DROP INDEX <replaceable class="parameter">index_name</replaceable>; DROP INDEX <replaceable class="parameter">index_name</replaceable>;
</programlisting> </programlisting>
</para> </para>
<para> <para>
Finally to destroy a given view use the command <command>DROP Finally to destroy a given view use the command <command>DROP
VIEW</command>: VIEW</command>:
<programlisting> <programlisting>
DROP VIEW <replaceable class="parameter">view_name</replaceable>; DROP VIEW <replaceable class="parameter">view_name</replaceable>;
</programlisting> </programlisting>
</para> </para>
</sect3> </sect3>
</sect2> </sect2>
...@@ -1966,11 +1966,11 @@ DROP VIEW <replaceable class="parameter">view_name</replaceable>; ...@@ -1966,11 +1966,11 @@ DROP VIEW <replaceable class="parameter">view_name</replaceable>;
with tuples using the command <command>INSERT INTO</command>. with tuples using the command <command>INSERT INTO</command>.
The syntax is: The syntax is:
<programlisting> <programlisting>
INSERT INTO <replaceable class="parameter">table_name</replaceable> (<replaceable class="parameter">name_of_attr_1</replaceable> INSERT INTO <replaceable class="parameter">table_name</replaceable> (<replaceable class="parameter">name_of_attr_1</replaceable>
[, <replaceable class="parameter">name_of_attr_2</replaceable> [,...]]) [, <replaceable class="parameter">name_of_attr_2</replaceable> [,...]])
VALUES (<replaceable class="parameter">val_attr_1</replaceable> [, <replaceable class="parameter">val_attr_2</replaceable> [, ...]]); VALUES (<replaceable class="parameter">val_attr_1</replaceable> [, <replaceable class="parameter">val_attr_2</replaceable> [, ...]]);
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -1978,19 +1978,19 @@ INSERT INTO <replaceable class="parameter">table_name</replaceable> (<replaceabl ...@@ -1978,19 +1978,19 @@ INSERT INTO <replaceable class="parameter">table_name</replaceable> (<replaceabl
<xref linkend="supplier-fig" endterm="supplier-fig">) we use the <xref linkend="supplier-fig" endterm="supplier-fig">) we use the
following statement: following statement:
<programlisting> <programlisting>
INSERT INTO SUPPLIER (SNO, SNAME, CITY) INSERT INTO SUPPLIER (SNO, SNAME, CITY)
VALUES (1, 'Smith', 'London'); VALUES (1, 'Smith', 'London');
</programlisting> </programlisting>
</para> </para>
<para> <para>
To insert the first tuple into the relation SELLS we use: To insert the first tuple into the relation SELLS we use:
<programlisting> <programlisting>
INSERT INTO SELLS (SNO, PNO) INSERT INTO SELLS (SNO, PNO)
VALUES (1, 1); VALUES (1, 1);
</programlisting> </programlisting>
</para> </para>
</sect3> </sect3>
...@@ -2001,23 +2001,23 @@ INSERT INTO SELLS (SNO, PNO) ...@@ -2001,23 +2001,23 @@ INSERT INTO SELLS (SNO, PNO)
To change one or more attribute values of tuples in a relation the To change one or more attribute values of tuples in a relation the
<command>UPDATE</command> command is used. The syntax is: <command>UPDATE</command> command is used. The syntax is:
<programlisting> <programlisting>
UPDATE <replaceable class="parameter">table_name</replaceable> UPDATE <replaceable class="parameter">table_name</replaceable>
SET <replaceable class="parameter">name_of_attr_1</replaceable> = <replaceable class="parameter">value_1</replaceable> SET <replaceable class="parameter">name_of_attr_1</replaceable> = <replaceable class="parameter">value_1</replaceable>
[, ... [, <replaceable class="parameter">name_of_attr_k</replaceable> = <replaceable class="parameter">value_k</replaceable>]] [, ... [, <replaceable class="parameter">name_of_attr_k</replaceable> = <replaceable class="parameter">value_k</replaceable>]]
WHERE <replaceable class="parameter">condition</replaceable>; WHERE <replaceable class="parameter">condition</replaceable>;
</programlisting> </programlisting>
</para> </para>
<para> <para>
To change the value of attribute PRICE of the part 'Screw' in the To change the value of attribute PRICE of the part 'Screw' in the
relation PART we use: relation PART we use:
<programlisting> <programlisting>
UPDATE PART UPDATE PART
SET PRICE = 15 SET PRICE = 15
WHERE PNAME = 'Screw'; WHERE PNAME = 'Screw';
</programlisting> </programlisting>
</para> </para>
<para> <para>
...@@ -2033,20 +2033,20 @@ UPDATE PART ...@@ -2033,20 +2033,20 @@ UPDATE PART
To delete a tuple from a particular table use the command DELETE To delete a tuple from a particular table use the command DELETE
FROM. The syntax is: FROM. The syntax is:
<programlisting> <programlisting>
DELETE FROM <replaceable class="parameter">table_name</replaceable> DELETE FROM <replaceable class="parameter">table_name</replaceable>
WHERE <replaceable class="parameter">condition</replaceable>; WHERE <replaceable class="parameter">condition</replaceable>;
</programlisting> </programlisting>
</para> </para>
<para> <para>
To delete the supplier called 'Smith' of the table SUPPLIER the To delete the supplier called 'Smith' of the table SUPPLIER the
following statement is used: following statement is used:
<programlisting> <programlisting>
DELETE FROM SUPPLIER DELETE FROM SUPPLIER
WHERE SNAME = 'Smith'; WHERE SNAME = 'Smith';
</programlisting> </programlisting>
</para> </para>
</sect3> </sect3>
</sect2> </sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/sslinfo.sgml,v 1.4 2010/07/27 23:43:42 rhaas Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/sslinfo.sgml,v 1.5 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="sslinfo"> <sect1 id="sslinfo">
<title>sslinfo</title> <title>sslinfo</title>
...@@ -147,7 +147,7 @@ ssl_client_dn_field(fieldname text) returns text ...@@ -147,7 +147,7 @@ ssl_client_dn_field(fieldname text) returns text
converted into ASN1 object identifiers using the OpenSSL object converted into ASN1 object identifiers using the OpenSSL object
database. The following values are acceptable: database. The following values are acceptable:
</para> </para>
<programlisting> <literallayout class="monospaced">
commonName (alias CN) commonName (alias CN)
surname (alias SN) surname (alias SN)
name name
...@@ -169,7 +169,7 @@ x500UniqueIdentifier ...@@ -169,7 +169,7 @@ x500UniqueIdentifier
pseudonym pseudonym
role role
emailAddress emailAddress
</programlisting> </literallayout>
<para> <para>
All of these fields are optional, except <structfield>commonName</>. All of these fields are optional, except <structfield>commonName</>.
It depends It depends
......
/* $PostgreSQL: pgsql/doc/src/sgml/stylesheet.css,v 1.9 2009/08/26 21:18:29 petere Exp $ */ /* $PostgreSQL: pgsql/doc/src/sgml/stylesheet.css,v 1.10 2010/07/29 19:34:40 petere Exp $ */
/* color scheme similar to www.postgresql.org */ /* color scheme similar to www.postgresql.org */
...@@ -85,7 +85,7 @@ DIV.EXAMPLE { ...@@ -85,7 +85,7 @@ DIV.EXAMPLE {
/* miscellaneous */ /* miscellaneous */
.SCREEN, .SYNOPSIS, .PROGRAMLISTING { PRE.LITERALLAYOUT, .SCREEN, .SYNOPSIS, .PROGRAMLISTING {
margin-left: 4ex; margin-left: 4ex;
} }
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/tablefunc.sgml,v 1.4 2007/12/06 04:12:10 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/tablefunc.sgml,v 1.5 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="tablefunc"> <sect1 id="tablefunc">
<title>tablefunc</title> <title>tablefunc</title>
...@@ -94,9 +94,9 @@ ...@@ -94,9 +94,9 @@
<sect3> <sect3>
<title><function>normal_rand</function></title> <title><function>normal_rand</function></title>
<programlisting> <synopsis>
normal_rand(int numvals, float8 mean, float8 stddev) returns setof float8 normal_rand(int numvals, float8 mean, float8 stddev) returns setof float8
</programlisting> </synopsis>
<para> <para>
<function>normal_rand</> produces a set of normally distributed random <function>normal_rand</> produces a set of normally distributed random
...@@ -115,7 +115,7 @@ normal_rand(int numvals, float8 mean, float8 stddev) returns setof float8 ...@@ -115,7 +115,7 @@ normal_rand(int numvals, float8 mean, float8 stddev) returns setof float8
standard deviation of 3: standard deviation of 3:
</para> </para>
<programlisting> <screen>
test=# SELECT * FROM normal_rand(1000, 5, 3); test=# SELECT * FROM normal_rand(1000, 5, 3);
normal_rand normal_rand
---------------------- ----------------------
...@@ -131,22 +131,22 @@ test=# SELECT * FROM normal_rand(1000, 5, 3); ...@@ -131,22 +131,22 @@ test=# SELECT * FROM normal_rand(1000, 5, 3);
9.71308014517282 9.71308014517282
2.49639286969028 2.49639286969028
(1000 rows) (1000 rows)
</programlisting> </screen>
</sect3> </sect3>
<sect3> <sect3>
<title><function>crosstab(text)</function></title> <title><function>crosstab(text)</function></title>
<programlisting> <synopsis>
crosstab(text sql) crosstab(text sql)
crosstab(text sql, int N) crosstab(text sql, int N)
</programlisting> </synopsis>
<para> <para>
The <function>crosstab</> function is used to produce <quote>pivot</> The <function>crosstab</> function is used to produce <quote>pivot</>
displays, wherein data is listed across the page rather than down. displays, wherein data is listed across the page rather than down.
For example, we might have data like For example, we might have data like
<programlisting> <programlisting>
row1 val11 row1 val11
row1 val12 row1 val12
row1 val13 row1 val13
...@@ -155,13 +155,13 @@ row2 val21 ...@@ -155,13 +155,13 @@ row2 val21
row2 val22 row2 val22
row2 val23 row2 val23
... ...
</programlisting> </programlisting>
which we wish to display like which we wish to display like
<programlisting> <programlisting>
row1 val11 val12 val13 ... row1 val11 val12 val13 ...
row2 val21 val22 val23 ... row2 val21 val22 val23 ...
... ...
</programlisting> </programlisting>
The <function>crosstab</> function takes a text parameter that is a SQL The <function>crosstab</> function takes a text parameter that is a SQL
query producing raw data formatted in the first way, and produces a table query producing raw data formatted in the first way, and produces a table
formatted in the second way. formatted in the second way.
...@@ -180,8 +180,6 @@ row2 val21 val22 val23 ... ...@@ -180,8 +180,6 @@ row2 val21 val22 val23 ...
<para> <para>
For example, the provided query might produce a set something like: For example, the provided query might produce a set something like:
</para>
<programlisting> <programlisting>
row_name cat value row_name cat value
----------+-------+------- ----------+-------+-------
...@@ -194,29 +192,25 @@ row2 val21 val22 val23 ... ...@@ -194,29 +192,25 @@ row2 val21 val22 val23 ...
row2 cat3 val7 row2 cat3 val7
row2 cat4 val8 row2 cat4 val8
</programlisting> </programlisting>
</para>
<para> <para>
The <function>crosstab</> function is declared to return <type>setof The <function>crosstab</> function is declared to return <type>setof
record</type>, so the actual names and types of the output columns must be record</type>, so the actual names and types of the output columns must be
defined in the <literal>FROM</> clause of the calling <command>SELECT</> defined in the <literal>FROM</> clause of the calling <command>SELECT</>
statement, for example: statement, for example:
</para> <programlisting>
SELECT * FROM crosstab('...') AS ct(row_name text, category_1 text, category_2 text);
<programlisting> </programlisting>
SELECT * FROM crosstab('...') AS ct(row_name text, category_1 text, category_2 text);
</programlisting>
<para>
This example produces a set something like: This example produces a set something like:
</para> <programlisting>
<programlisting>
&lt;== value columns ==&gt; &lt;== value columns ==&gt;
row_name category_1 category_2 row_name category_1 category_2
---------+------------+------------ ----------+------------+------------
row1 val1 val2 row1 val1 val2
row2 val5 val6 row2 val5 val6
</programlisting> </programlisting>
</para>
<para> <para>
The <literal>FROM</> clause must define the output as one The <literal>FROM</> clause must define the output as one
...@@ -250,9 +244,7 @@ row_name category_1 category_2 ...@@ -250,9 +244,7 @@ row_name category_1 category_2
<para> <para>
Here is a complete example: Here is a complete example:
</para> <programlisting>
<programlisting>
CREATE TABLE ct(id SERIAL, rowid TEXT, attribute TEXT, value TEXT); CREATE TABLE ct(id SERIAL, rowid TEXT, attribute TEXT, value TEXT);
INSERT INTO ct(rowid, attribute, value) VALUES('test1','att1','val1'); INSERT INTO ct(rowid, attribute, value) VALUES('test1','att1','val1');
INSERT INTO ct(rowid, attribute, value) VALUES('test1','att2','val2'); INSERT INTO ct(rowid, attribute, value) VALUES('test1','att2','val2');
...@@ -276,7 +268,8 @@ AS ct(row_name text, category_1 text, category_2 text, category_3 text); ...@@ -276,7 +268,8 @@ AS ct(row_name text, category_1 text, category_2 text, category_3 text);
test1 | val2 | val3 | test1 | val2 | val3 |
test2 | val6 | val7 | test2 | val6 | val7 |
(2 rows) (2 rows)
</programlisting> </programlisting>
</para>
<para> <para>
You can avoid always having to write out a <literal>FROM</> clause to You can avoid always having to write out a <literal>FROM</> clause to
...@@ -291,9 +284,9 @@ AS ct(row_name text, category_1 text, category_2 text, category_3 text); ...@@ -291,9 +284,9 @@ AS ct(row_name text, category_1 text, category_2 text, category_3 text);
<sect3> <sect3>
<title><function>crosstab<replaceable>N</>(text)</function></title> <title><function>crosstab<replaceable>N</>(text)</function></title>
<programlisting> <synopsis>
crosstab<replaceable>N</>(text sql) crosstab<replaceable>N</>(text sql)
</programlisting> </synopsis>
<para> <para>
The <function>crosstab<replaceable>N</></> functions are examples of how The <function>crosstab<replaceable>N</></> functions are examples of how
...@@ -304,7 +297,7 @@ crosstab<replaceable>N</>(text sql) ...@@ -304,7 +297,7 @@ crosstab<replaceable>N</>(text sql)
<function>crosstab4</>, whose output rowtypes are defined as <function>crosstab4</>, whose output rowtypes are defined as
</para> </para>
<programlisting> <programlisting>
CREATE TYPE tablefunc_crosstab_N AS ( CREATE TYPE tablefunc_crosstab_N AS (
row_name TEXT, row_name TEXT,
category_1 TEXT, category_1 TEXT,
...@@ -314,7 +307,7 @@ CREATE TYPE tablefunc_crosstab_N AS ( ...@@ -314,7 +307,7 @@ CREATE TYPE tablefunc_crosstab_N AS (
. .
category_N TEXT category_N TEXT
); );
</programlisting> </programlisting>
<para> <para>
Thus, these functions can be used directly when the input query produces Thus, these functions can be used directly when the input query produces
...@@ -327,23 +320,21 @@ CREATE TYPE tablefunc_crosstab_N AS ( ...@@ -327,23 +320,21 @@ CREATE TYPE tablefunc_crosstab_N AS (
<para> <para>
For instance, the example given in the previous section would also For instance, the example given in the previous section would also
work as work as
</para> <programlisting>
<programlisting>
SELECT * SELECT *
FROM crosstab3( FROM crosstab3(
'select rowid, attribute, value 'select rowid, attribute, value
from ct from ct
where attribute = ''att2'' or attribute = ''att3'' where attribute = ''att2'' or attribute = ''att3''
order by 1,2'); order by 1,2');
</programlisting> </programlisting>
</para>
<para> <para>
These functions are provided mostly for illustration purposes. You These functions are provided mostly for illustration purposes. You
can create your own return types and functions based on the can create your own return types and functions based on the
underlying <function>crosstab()</> function. There are two ways underlying <function>crosstab()</> function. There are two ways
to do it: to do it:
</para>
<itemizedlist> <itemizedlist>
<listitem> <listitem>
...@@ -355,32 +346,30 @@ FROM crosstab3( ...@@ -355,32 +346,30 @@ FROM crosstab3(
<function>crosstab</> C function. For example, if your source data <function>crosstab</> C function. For example, if your source data
produces row names that are <type>text</>, and values that are produces row names that are <type>text</>, and values that are
<type>float8</>, and you want 5 value columns: <type>float8</>, and you want 5 value columns:
</para> <programlisting>
CREATE TYPE my_crosstab_float8_5_cols AS (
<programlisting>
CREATE TYPE my_crosstab_float8_5_cols AS (
my_row_name text, my_row_name text,
my_category_1 float8, my_category_1 float8,
my_category_2 float8, my_category_2 float8,
my_category_3 float8, my_category_3 float8,
my_category_4 float8, my_category_4 float8,
my_category_5 float8 my_category_5 float8
); );
CREATE OR REPLACE FUNCTION crosstab_float8_5_cols(text) CREATE OR REPLACE FUNCTION crosstab_float8_5_cols(text)
RETURNS setof my_crosstab_float8_5_cols RETURNS setof my_crosstab_float8_5_cols
AS '$libdir/tablefunc','crosstab' LANGUAGE C STABLE STRICT; AS '$libdir/tablefunc','crosstab' LANGUAGE C STABLE STRICT;
</programlisting> </programlisting>
</para>
</listitem> </listitem>
<listitem> <listitem>
<para> <para>
Use <literal>OUT</> parameters to define the return type implicitly. Use <literal>OUT</> parameters to define the return type implicitly.
The same example could also be done this way: The same example could also be done this way:
</para> <programlisting>
CREATE OR REPLACE FUNCTION crosstab_float8_5_cols(
<programlisting> IN text,
CREATE OR REPLACE FUNCTION crosstab_float8_5_cols(IN text,
OUT my_row_name text, OUT my_row_name text,
OUT my_category_1 float8, OUT my_category_1 float8,
OUT my_category_2 float8, OUT my_category_2 float8,
...@@ -389,18 +378,20 @@ FROM crosstab3( ...@@ -389,18 +378,20 @@ FROM crosstab3(
OUT my_category_5 float8) OUT my_category_5 float8)
RETURNS setof record RETURNS setof record
AS '$libdir/tablefunc','crosstab' LANGUAGE C STABLE STRICT; AS '$libdir/tablefunc','crosstab' LANGUAGE C STABLE STRICT;
</programlisting> </programlisting>
</para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
</para>
</sect3> </sect3>
<sect3> <sect3>
<title><function>crosstab(text, text)</function></title> <title><function>crosstab(text, text)</function></title>
<programlisting> <synopsis>
crosstab(text source_sql, text category_sql) crosstab(text source_sql, text category_sql)
</programlisting> </synopsis>
<para> <para>
The main limitation of the single-parameter form of <function>crosstab</> The main limitation of the single-parameter form of <function>crosstab</>
...@@ -432,8 +423,7 @@ crosstab(text source_sql, text category_sql) ...@@ -432,8 +423,7 @@ crosstab(text source_sql, text category_sql)
<para> <para>
For example, <parameter>source_sql</parameter> might produce a set For example, <parameter>source_sql</parameter> might produce a set
something like: something like:
</para> <programlisting>
<programlisting>
SELECT row_name, extra_col, cat, value FROM foo ORDER BY 1; SELECT row_name, extra_col, cat, value FROM foo ORDER BY 1;
row_name extra_col cat value row_name extra_col cat value
...@@ -445,7 +435,8 @@ crosstab(text source_sql, text category_sql) ...@@ -445,7 +435,8 @@ crosstab(text source_sql, text category_sql)
row2 extra2 cat2 val6 row2 extra2 cat2 val6
row2 extra2 cat3 val7 row2 extra2 cat3 val7
row2 extra2 cat4 val8 row2 extra2 cat4 val8
</programlisting> </programlisting>
</para>
<para> <para>
<parameter>category_sql</parameter> is a SQL statement that produces <parameter>category_sql</parameter> is a SQL statement that produces
...@@ -453,9 +444,8 @@ crosstab(text source_sql, text category_sql) ...@@ -453,9 +444,8 @@ crosstab(text source_sql, text category_sql)
It must produce at least one row, or an error will be generated. 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 Also, it must not produce duplicate values, or an error will be
generated. <parameter>category_sql</parameter> might be something like: generated. <parameter>category_sql</parameter> might be something like:
</para>
<programlisting> <programlisting>
SELECT DISTINCT cat FROM foo ORDER BY 1; SELECT DISTINCT cat FROM foo ORDER BY 1;
cat cat
------- -------
...@@ -463,31 +453,31 @@ SELECT DISTINCT cat FROM foo ORDER BY 1; ...@@ -463,31 +453,31 @@ SELECT DISTINCT cat FROM foo ORDER BY 1;
cat2 cat2
cat3 cat3
cat4 cat4
</programlisting> </programlisting>
</para>
<para> <para>
The <function>crosstab</> function is declared to return <type>setof The <function>crosstab</> function is declared to return <type>setof
record</type>, so the actual names and types of the output columns must be record</type>, so the actual names and types of the output columns must be
defined in the <literal>FROM</> clause of the calling <command>SELECT</> defined in the <literal>FROM</> clause of the calling <command>SELECT</>
statement, for example: statement, for example:
</para>
<programlisting> <programlisting>
SELECT * FROM crosstab('...', '...') SELECT * FROM crosstab('...', '...')
AS ct(row_name text, extra text, cat1 text, cat2 text, cat3 text, cat4 text); AS ct(row_name text, extra text, cat1 text, cat2 text, cat3 text, cat4 text);
</programlisting> </programlisting>
</para>
<para> <para>
This will produce a result something like: This will produce a result something like:
</para> <programlisting>
<programlisting>
&lt;== value columns ==&gt; &lt;== value columns ==&gt;
row_name extra cat1 cat2 cat3 cat4 row_name extra cat1 cat2 cat3 cat4
---------+-------+------+------+------+------ ---------+-------+------+------+------+------
row1 extra1 val1 val2 val4 row1 extra1 val1 val2 val4
row2 extra2 val5 val6 val7 val8 row2 extra2 val5 val6 val7 val8
</programlisting> </programlisting>
</para>
<para> <para>
The <literal>FROM</> clause must define the proper number of output The <literal>FROM</> clause must define the proper number of output
...@@ -527,9 +517,7 @@ SELECT DISTINCT cat FROM foo ORDER BY 1; ...@@ -527,9 +517,7 @@ SELECT DISTINCT cat FROM foo ORDER BY 1;
<para> <para>
Here are two complete examples: Here are two complete examples:
</para> <programlisting>
<programlisting>
create table sales(year int, month int, qty int); create table sales(year int, month int, qty int);
insert into sales values(2007, 1, 1000); insert into sales values(2007, 1, 1000);
insert into sales values(2007, 2, 1500); insert into sales values(2007, 2, 1500);
...@@ -561,9 +549,9 @@ select * from crosstab( ...@@ -561,9 +549,9 @@ select * from crosstab(
2007 | 1000 | 1500 | | | | | 500 | | | | 1500 | 2000 2007 | 1000 | 1500 | | | | | 500 | | | | 1500 | 2000
2008 | 1000 | | | | | | | | | | | 2008 | 1000 | | | | | | | | | | |
(2 rows) (2 rows)
</programlisting> </programlisting>
<programlisting> <programlisting>
CREATE TABLE cth(rowid text, rowdt timestamp, attribute text, val text); CREATE TABLE cth(rowid text, rowdt timestamp, attribute text, val text);
INSERT INTO cth VALUES('test1','01 March 2003','temperature','42'); INSERT INTO cth VALUES('test1','01 March 2003','temperature','42');
INSERT INTO cth VALUES('test1','01 March 2003','test_result','PASS'); INSERT INTO cth VALUES('test1','01 March 2003','test_result','PASS');
...@@ -592,7 +580,8 @@ AS ...@@ -592,7 +580,8 @@ AS
test1 | Sat Mar 01 00:00:00 2003 | 42 | PASS | | 2.6987 test1 | Sat Mar 01 00:00:00 2003 | 42 | PASS | | 2.6987
test2 | Sun Mar 02 00:00:00 2003 | 53 | FAIL | Sat Mar 01 00:00:00 2003 | 3.1234 test2 | Sun Mar 02 00:00:00 2003 | 53 | FAIL | Sat Mar 01 00:00:00 2003 | 3.1234
(2 rows) (2 rows)
</programlisting> </programlisting>
</para>
<para> <para>
You can create predefined functions to avoid having to write out You can create predefined functions to avoid having to write out
...@@ -606,11 +595,11 @@ AS ...@@ -606,11 +595,11 @@ AS
<sect3> <sect3>
<title><function>connectby</function></title> <title><function>connectby</function></title>
<programlisting> <synopsis>
connectby(text relname, text keyid_fld, text parent_keyid_fld connectby(text relname, text keyid_fld, text parent_keyid_fld
[, text orderby_fld ], text start_with, int max_depth [, text orderby_fld ], text start_with, int max_depth
[, text branch_delim ]) [, text branch_delim ])
</programlisting> </synopsis>
<para> <para>
The <function>connectby</> function produces a display of hierarchical The <function>connectby</> function produces a display of hierarchical
...@@ -675,10 +664,10 @@ connectby(text relname, text keyid_fld, text parent_keyid_fld ...@@ -675,10 +664,10 @@ connectby(text relname, text keyid_fld, text parent_keyid_fld
statement, for example: statement, for example:
</para> </para>
<programlisting> <programlisting>
SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', 'pos', 'row2', 0, '~') SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', 'pos', 'row2', 0, '~')
AS t(keyid text, parent_keyid text, level int, branch text, pos int); AS t(keyid text, parent_keyid text, level int, branch text, pos int);
</programlisting> </programlisting>
<para> <para>
The first two output columns are used for the current row's key and The first two output columns are used for the current row's key and
...@@ -731,9 +720,7 @@ connectby(text relname, text keyid_fld, text parent_keyid_fld ...@@ -731,9 +720,7 @@ connectby(text relname, text keyid_fld, text parent_keyid_fld
<para> <para>
Here is an example: Here is an example:
</para> <programlisting>
<programlisting>
CREATE TABLE connectby_tree(keyid text, parent_keyid text, pos int); CREATE TABLE connectby_tree(keyid text, parent_keyid text, pos int);
INSERT INTO connectby_tree VALUES('row1',NULL, 0); INSERT INTO connectby_tree VALUES('row1',NULL, 0);
...@@ -797,7 +784,8 @@ SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', 'pos', 'row2' ...@@ -797,7 +784,8 @@ SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', 'pos', 'row2'
row6 | row4 | 2 | 5 row6 | row4 | 2 | 5
row8 | row6 | 3 | 6 row8 | row6 | 3 | 6
(6 rows) (6 rows)
</programlisting> </programlisting>
</para>
</sect3> </sect3>
</sect2> </sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.56 2010/04/03 07:22:56 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/textsearch.sgml,v 1.57 2010/07/29 19:34:40 petere Exp $ -->
<chapter id="textsearch"> <chapter id="textsearch">
<title>Full Text Search</title> <title>Full Text Search</title>
...@@ -613,9 +613,9 @@ LIMIT 10; ...@@ -613,9 +613,9 @@ LIMIT 10;
<primary>to_tsvector</primary> <primary>to_tsvector</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
to_tsvector(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">document</replaceable> <type>text</>) returns <type>tsvector</> to_tsvector(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">document</replaceable> <type>text</>) returns <type>tsvector</>
</synopsis> </synopsis>
<para> <para>
<function>to_tsvector</function> parses a textual document into tokens, <function>to_tsvector</function> parses a textual document into tokens,
...@@ -625,12 +625,12 @@ LIMIT 10; ...@@ -625,12 +625,12 @@ LIMIT 10;
text search configuration. text search configuration.
Here is a simple example: Here is a simple example:
<programlisting> <screen>
SELECT to_tsvector('english', 'a fat cat sat on a mat - it ate a fat rats'); SELECT to_tsvector('english', 'a fat cat sat on a mat - it ate a fat rats');
to_tsvector to_tsvector
----------------------------------------------------- -----------------------------------------------------
'ate':9 'cat':3 'fat':2,11 'mat':7 'rat':12 'sat':4 'ate':9 'cat':3 'fat':2,11 'mat':7 'rat':12 'sat':4
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -720,9 +720,9 @@ UPDATE tt SET ti = ...@@ -720,9 +720,9 @@ UPDATE tt SET ti =
<primary>to_tsquery</primary> <primary>to_tsquery</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
to_tsquery(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">querytext</replaceable> <type>text</>) returns <type>tsquery</> to_tsquery(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">querytext</replaceable> <type>text</>) returns <type>tsquery</>
</synopsis> </synopsis>
<para> <para>
<function>to_tsquery</function> creates a <type>tsquery</> value from <function>to_tsquery</function> creates a <type>tsquery</> value from
...@@ -738,32 +738,32 @@ UPDATE tt SET ti = ...@@ -738,32 +738,32 @@ UPDATE tt SET ti =
the specified or default configuration, and discards any tokens that are the specified or default configuration, and discards any tokens that are
stop words according to the configuration. For example: stop words according to the configuration. For example:
<programlisting> <screen>
SELECT to_tsquery('english', 'The &amp; Fat &amp; Rats'); SELECT to_tsquery('english', 'The &amp; Fat &amp; Rats');
to_tsquery to_tsquery
--------------- ---------------
'fat' &amp; 'rat' 'fat' &amp; 'rat'
</programlisting> </screen>
As in basic <type>tsquery</> input, weight(s) can be attached to each As in basic <type>tsquery</> input, weight(s) can be attached to each
lexeme to restrict it to match only <type>tsvector</> lexemes of those lexeme to restrict it to match only <type>tsvector</> lexemes of those
weight(s). For example: weight(s). For example:
<programlisting> <screen>
SELECT to_tsquery('english', 'Fat | Rats:AB'); SELECT to_tsquery('english', 'Fat | Rats:AB');
to_tsquery to_tsquery
------------------ ------------------
'fat' | 'rat':AB 'fat' | 'rat':AB
</programlisting> </screen>
Also, <literal>*</> can be attached to a lexeme to specify prefix matching: Also, <literal>*</> can be attached to a lexeme to specify prefix matching:
<programlisting> <screen>
SELECT to_tsquery('supern:*A &amp; star:A*B'); SELECT to_tsquery('supern:*A &amp; star:A*B');
to_tsquery to_tsquery
-------------------------- --------------------------
'supern':*A &amp; 'star':*AB 'supern':*A &amp; 'star':*AB
</programlisting> </screen>
Such a lexeme will match any word in a <type>tsvector</> that begins Such a lexeme will match any word in a <type>tsvector</> that begins
with the given string. with the given string.
...@@ -776,12 +776,12 @@ SELECT to_tsquery('supern:*A &amp; star:A*B'); ...@@ -776,12 +776,12 @@ SELECT to_tsquery('supern:*A &amp; star:A*B');
In the example below, a thesaurus contains the rule <literal>supernovae In the example below, a thesaurus contains the rule <literal>supernovae
stars : sn</literal>: stars : sn</literal>:
<programlisting> <screen>
SELECT to_tsquery('''supernovae stars'' &amp; !crab'); SELECT to_tsquery('''supernovae stars'' &amp; !crab');
to_tsquery to_tsquery
--------------- ---------------
'sn' &amp; !'crab' 'sn' &amp; !'crab'
</programlisting> </screen>
Without quotes, <function>to_tsquery</function> will generate a syntax Without quotes, <function>to_tsquery</function> will generate a syntax
error for tokens that are not separated by an AND or OR operator. error for tokens that are not separated by an AND or OR operator.
...@@ -791,9 +791,9 @@ SELECT to_tsquery('''supernovae stars'' &amp; !crab'); ...@@ -791,9 +791,9 @@ SELECT to_tsquery('''supernovae stars'' &amp; !crab');
<primary>plainto_tsquery</primary> <primary>plainto_tsquery</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
plainto_tsquery(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">querytext</replaceable> <type>text</>) returns <type>tsquery</> plainto_tsquery(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">querytext</replaceable> <type>text</>) returns <type>tsquery</>
</synopsis> </synopsis>
<para> <para>
<function>plainto_tsquery</> transforms unformatted text <function>plainto_tsquery</> transforms unformatted text
...@@ -806,23 +806,23 @@ SELECT to_tsquery('''supernovae stars'' &amp; !crab'); ...@@ -806,23 +806,23 @@ SELECT to_tsquery('''supernovae stars'' &amp; !crab');
<para> <para>
Example: Example:
<programlisting> <screen>
SELECT plainto_tsquery('english', 'The Fat Rats'); SELECT plainto_tsquery('english', 'The Fat Rats');
plainto_tsquery plainto_tsquery
----------------- -----------------
'fat' &amp; 'rat' 'fat' &amp; 'rat'
</programlisting> </screen>
Note that <function>plainto_tsquery</> cannot Note that <function>plainto_tsquery</> cannot
recognize Boolean operators, weight labels, or prefix-match labels recognize Boolean operators, weight labels, or prefix-match labels
in its input: in its input:
<programlisting> <screen>
SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C'); SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C');
plainto_tsquery plainto_tsquery
--------------------- ---------------------
'fat' &amp; 'rat' &amp; 'c' 'fat' &amp; 'rat' &amp; 'c'
</programlisting> </screen>
Here, all the input punctuation was discarded as being space symbols. Here, all the input punctuation was discarded as being space symbols.
</para> </para>
...@@ -859,10 +859,10 @@ SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C'); ...@@ -859,10 +859,10 @@ SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C');
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
ts_rank(<optional> <replaceable class="PARAMETER">weights</replaceable> <type>float4[]</>, </optional> <replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>, ts_rank(<optional> <replaceable class="PARAMETER">weights</replaceable> <type>float4[]</>, </optional> <replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>,
<replaceable class="PARAMETER">query</replaceable> <type>tsquery</> <optional>, <replaceable class="PARAMETER">normalization</replaceable> <type>integer</> </optional>) returns <type>float4</> <replaceable class="PARAMETER">query</replaceable> <type>tsquery</> <optional>, <replaceable class="PARAMETER">normalization</replaceable> <type>integer</> </optional>) returns <type>float4</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -879,10 +879,10 @@ SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C'); ...@@ -879,10 +879,10 @@ SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C');
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
ts_rank_cd(<optional> <replaceable class="PARAMETER">weights</replaceable> <type>float4[]</>, </optional> <replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>, ts_rank_cd(<optional> <replaceable class="PARAMETER">weights</replaceable> <type>float4[]</>, </optional> <replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>,
<replaceable class="PARAMETER">query</replaceable> <type>tsquery</> <optional>, <replaceable class="PARAMETER">normalization</replaceable> <type>integer</> </optional>) returns <type>float4</> <replaceable class="PARAMETER">query</replaceable> <type>tsquery</> <optional>, <replaceable class="PARAMETER">normalization</replaceable> <type>integer</> </optional>) returns <type>float4</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -913,9 +913,9 @@ SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C'); ...@@ -913,9 +913,9 @@ SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C');
heavily depending on how they are labeled. The weight arrays specify heavily depending on how they are labeled. The weight arrays specify
how heavily to weigh each category of word, in the order: how heavily to weigh each category of word, in the order:
<programlisting> <synopsis>
{D-weight, C-weight, B-weight, A-weight} {D-weight, C-weight, B-weight, A-weight}
</programlisting> </synopsis>
If no <replaceable class="PARAMETER">weights</replaceable> are provided, If no <replaceable class="PARAMETER">weights</replaceable> are provided,
then these defaults are used: then these defaults are used:
...@@ -996,7 +996,7 @@ SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C'); ...@@ -996,7 +996,7 @@ SELECT plainto_tsquery('english', 'The Fat &amp; Rats:C');
<para> <para>
Here is an example that selects only the ten highest-ranked matches: Here is an example that selects only the ten highest-ranked matches:
<programlisting> <screen>
SELECT title, ts_rank_cd(textsearch, query) AS rank SELECT title, ts_rank_cd(textsearch, query) AS rank
FROM apod, to_tsquery('neutrino|(dark &amp; matter)') query FROM apod, to_tsquery('neutrino|(dark &amp; matter)') query
WHERE query @@ textsearch WHERE query @@ textsearch
...@@ -1014,11 +1014,11 @@ LIMIT 10; ...@@ -1014,11 +1014,11 @@ LIMIT 10;
Hot Gas and Dark Matter | 1.6123 Hot Gas and Dark Matter | 1.6123
Ice Fishing for Cosmic Neutrinos | 1.6 Ice Fishing for Cosmic Neutrinos | 1.6
Weak Lensing Distorts the Universe | 0.818218 Weak Lensing Distorts the Universe | 0.818218
</programlisting> </screen>
This is the same example using normalized ranking: This is the same example using normalized ranking:
<programlisting> <screen>
SELECT title, ts_rank_cd(textsearch, query, 32 /* rank/(rank+1) */ ) AS rank SELECT title, ts_rank_cd(textsearch, query, 32 /* rank/(rank+1) */ ) AS rank
FROM apod, to_tsquery('neutrino|(dark &amp; matter)') query FROM apod, to_tsquery('neutrino|(dark &amp; matter)') query
WHERE query @@ textsearch WHERE query @@ textsearch
...@@ -1036,7 +1036,7 @@ LIMIT 10; ...@@ -1036,7 +1036,7 @@ LIMIT 10;
Hot Gas and Dark Matter | 0.617195790024749 Hot Gas and Dark Matter | 0.617195790024749
Ice Fishing for Cosmic Neutrinos | 0.615384618911517 Ice Fishing for Cosmic Neutrinos | 0.615384618911517
Weak Lensing Distorts the Universe | 0.450010798361481 Weak Lensing Distorts the Universe | 0.450010798361481
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1063,9 +1063,9 @@ LIMIT 10; ...@@ -1063,9 +1063,9 @@ LIMIT 10;
<primary>ts_headline</primary> <primary>ts_headline</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
ts_headline(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">document</replaceable> <type>text</>, <replaceable class="PARAMETER">query</replaceable> <type>tsquery</> <optional>, <replaceable class="PARAMETER">options</replaceable> <type>text</> </optional>) returns <type>text</> ts_headline(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">document</replaceable> <type>text</>, <replaceable class="PARAMETER">query</replaceable> <type>tsquery</> <optional>, <replaceable class="PARAMETER">options</replaceable> <type>text</> </optional>) returns <type>text</>
</synopsis> </synopsis>
<para> <para>
<function>ts_headline</function> accepts a document along <function>ts_headline</function> accepts a document along
...@@ -1148,7 +1148,7 @@ MaxFragments=0, FragmentDelimiter=" ... " ...@@ -1148,7 +1148,7 @@ MaxFragments=0, FragmentDelimiter=" ... "
<para> <para>
For example: For example:
<programlisting> <screen>
SELECT ts_headline('english', SELECT ts_headline('english',
'The most common type of search 'The most common type of search
is to find all documents containing given query terms is to find all documents containing given query terms
...@@ -1173,7 +1173,7 @@ query.', ...@@ -1173,7 +1173,7 @@ query.',
containing given &lt;query&gt; terms containing given &lt;query&gt; terms
and return them in order of their &lt;similarity&gt; to the and return them in order of their &lt;similarity&gt; to the
&lt;query&gt;. &lt;query&gt;.
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1226,9 +1226,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1226,9 +1226,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
<type>tsvector</> || <type>tsvector</> <type>tsvector</> || <type>tsvector</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1267,9 +1267,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1267,9 +1267,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
setweight(<replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>, <replaceable class="PARAMETER">weight</replaceable> <type>"char"</>) returns <type>tsvector</> setweight(<replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>, <replaceable class="PARAMETER">weight</replaceable> <type>"char"</>) returns <type>tsvector</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1297,9 +1297,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1297,9 +1297,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
length(<replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>) returns <type>integer</> length(<replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>) returns <type>integer</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1316,9 +1316,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1316,9 +1316,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
strip(<replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>) returns <type>tsvector</> strip(<replaceable class="PARAMETER">vector</replaceable> <type>tsvector</>) returns <type>tsvector</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1352,9 +1352,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1352,9 +1352,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
<varlistentry> <varlistentry>
<term> <term>
<synopsis> <synopsis>
<type>tsquery</> &amp;&amp; <type>tsquery</> <type>tsquery</> &amp;&amp; <type>tsquery</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1368,9 +1368,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1368,9 +1368,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
<varlistentry> <varlistentry>
<term> <term>
<synopsis> <synopsis>
<type>tsquery</> || <type>tsquery</> <type>tsquery</> || <type>tsquery</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1384,9 +1384,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1384,9 +1384,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
<varlistentry> <varlistentry>
<term> <term>
<synopsis> <synopsis>
!! <type>tsquery</> !! <type>tsquery</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1404,9 +1404,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1404,9 +1404,9 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
numnode(<replaceable class="PARAMETER">query</replaceable> <type>tsquery</>) returns <type>integer</> numnode(<replaceable class="PARAMETER">query</replaceable> <type>tsquery</>) returns <type>integer</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1417,7 +1417,7 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank ...@@ -1417,7 +1417,7 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
(returns &gt; 0), or contains only stop words (returns 0). (returns &gt; 0), or contains only stop words (returns 0).
Examples: Examples:
<programlisting> <screen>
SELECT numnode(plainto_tsquery('the any')); SELECT numnode(plainto_tsquery('the any'));
NOTICE: query contains only stopword(s) or doesn't contain lexeme(s), ignored NOTICE: query contains only stopword(s) or doesn't contain lexeme(s), ignored
numnode numnode
...@@ -1428,7 +1428,7 @@ SELECT numnode('foo &amp; bar'::tsquery); ...@@ -1428,7 +1428,7 @@ SELECT numnode('foo &amp; bar'::tsquery);
numnode numnode
--------- ---------
3 3
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1440,9 +1440,9 @@ SELECT numnode('foo &amp; bar'::tsquery); ...@@ -1440,9 +1440,9 @@ SELECT numnode('foo &amp; bar'::tsquery);
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
querytree(<replaceable class="PARAMETER">query</replaceable> <type>tsquery</>) returns <type>text</> querytree(<replaceable class="PARAMETER">query</replaceable> <type>tsquery</>) returns <type>text</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1452,12 +1452,12 @@ SELECT numnode('foo &amp; bar'::tsquery); ...@@ -1452,12 +1452,12 @@ SELECT numnode('foo &amp; bar'::tsquery);
unindexable queries, for example those containing only stop words unindexable queries, for example those containing only stop words
or only negated terms. For example: or only negated terms. For example:
<programlisting> <screen>
SELECT querytree(to_tsquery('!defined')); SELECT querytree(to_tsquery('!defined'));
querytree querytree
----------- -----------
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1495,9 +1495,9 @@ SELECT querytree(to_tsquery('!defined')); ...@@ -1495,9 +1495,9 @@ SELECT querytree(to_tsquery('!defined'));
<varlistentry> <varlistentry>
<term> <term>
<synopsis> <synopsis>
ts_rewrite (<replaceable class="PARAMETER">query</replaceable> <type>tsquery</>, <replaceable class="PARAMETER">target</replaceable> <type>tsquery</>, <replaceable class="PARAMETER">substitute</replaceable> <type>tsquery</>) returns <type>tsquery</> ts_rewrite (<replaceable class="PARAMETER">query</replaceable> <type>tsquery</>, <replaceable class="PARAMETER">target</replaceable> <type>tsquery</>, <replaceable class="PARAMETER">substitute</replaceable> <type>tsquery</>) returns <type>tsquery</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1508,12 +1508,12 @@ SELECT querytree(to_tsquery('!defined')); ...@@ -1508,12 +1508,12 @@ SELECT querytree(to_tsquery('!defined'));
wherever it appears in <replaceable wherever it appears in <replaceable
class="PARAMETER">query</replaceable>. For example: class="PARAMETER">query</replaceable>. For example:
<programlisting> <screen>
SELECT ts_rewrite('a &amp; b'::tsquery, 'a'::tsquery, 'c'::tsquery); SELECT ts_rewrite('a &amp; b'::tsquery, 'a'::tsquery, 'c'::tsquery);
ts_rewrite ts_rewrite
------------ ------------
'b' &amp; 'c' 'b' &amp; 'c'
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1521,9 +1521,9 @@ SELECT ts_rewrite('a &amp; b'::tsquery, 'a'::tsquery, 'c'::tsquery); ...@@ -1521,9 +1521,9 @@ SELECT ts_rewrite('a &amp; b'::tsquery, 'a'::tsquery, 'c'::tsquery);
<varlistentry> <varlistentry>
<term> <term>
<synopsis> <synopsis>
ts_rewrite (<replaceable class="PARAMETER">query</> <type>tsquery</>, <replaceable class="PARAMETER">select</> <type>text</>) returns <type>tsquery</> ts_rewrite (<replaceable class="PARAMETER">query</> <type>tsquery</>, <replaceable class="PARAMETER">select</> <type>text</>) returns <type>tsquery</>
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -1536,7 +1536,7 @@ SELECT ts_rewrite('a &amp; b'::tsquery, 'a'::tsquery, 'c'::tsquery); ...@@ -1536,7 +1536,7 @@ SELECT ts_rewrite('a &amp; b'::tsquery, 'a'::tsquery, 'c'::tsquery);
(the target) are replaced by the second column value (the substitute) (the target) are replaced by the second column value (the substitute)
within the current <replaceable>query</> value. For example: within the current <replaceable>query</> value. For example:
<programlisting> <screen>
CREATE TABLE aliases (t tsquery PRIMARY KEY, s tsquery); CREATE TABLE aliases (t tsquery PRIMARY KEY, s tsquery);
INSERT INTO aliases VALUES('a', 'c'); INSERT INTO aliases VALUES('a', 'c');
...@@ -1544,7 +1544,7 @@ SELECT ts_rewrite('a &amp; b'::tsquery, 'SELECT t,s FROM aliases'); ...@@ -1544,7 +1544,7 @@ SELECT ts_rewrite('a &amp; b'::tsquery, 'SELECT t,s FROM aliases');
ts_rewrite ts_rewrite
------------ ------------
'b' &amp; 'c' 'b' &amp; 'c'
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1561,7 +1561,7 @@ SELECT ts_rewrite('a &amp; b'::tsquery, 'SELECT t,s FROM aliases'); ...@@ -1561,7 +1561,7 @@ SELECT ts_rewrite('a &amp; b'::tsquery, 'SELECT t,s FROM aliases');
Let's consider a real-life astronomical example. We'll expand query Let's consider a real-life astronomical example. We'll expand query
<literal>supernovae</literal> using table-driven rewriting rules: <literal>supernovae</literal> using table-driven rewriting rules:
<programlisting> <screen>
CREATE TABLE aliases (t tsquery primary key, s tsquery); CREATE TABLE aliases (t tsquery primary key, s tsquery);
INSERT INTO aliases VALUES(to_tsquery('supernovae'), to_tsquery('supernovae|sn')); INSERT INTO aliases VALUES(to_tsquery('supernovae'), to_tsquery('supernovae|sn'));
...@@ -1569,11 +1569,11 @@ SELECT ts_rewrite(to_tsquery('supernovae &amp; crab'), 'SELECT * FROM aliases'); ...@@ -1569,11 +1569,11 @@ SELECT ts_rewrite(to_tsquery('supernovae &amp; crab'), 'SELECT * FROM aliases');
ts_rewrite ts_rewrite
--------------------------------- ---------------------------------
'crab' &amp; ( 'supernova' | 'sn' ) 'crab' &amp; ( 'supernova' | 'sn' )
</programlisting> </screen>
We can change the rewriting rules just by updating the table: We can change the rewriting rules just by updating the table:
<programlisting> <screen>
UPDATE aliases UPDATE aliases
SET s = to_tsquery('supernovae|sn &amp; !nebulae') SET s = to_tsquery('supernovae|sn &amp; !nebulae')
WHERE t = to_tsquery('supernovae'); WHERE t = to_tsquery('supernovae');
...@@ -1582,7 +1582,7 @@ SELECT ts_rewrite(to_tsquery('supernovae &amp; crab'), 'SELECT * FROM aliases'); ...@@ -1582,7 +1582,7 @@ SELECT ts_rewrite(to_tsquery('supernovae &amp; crab'), 'SELECT * FROM aliases');
ts_rewrite ts_rewrite
--------------------------------------------- ---------------------------------------------
'crab' &amp; ( 'supernova' | 'sn' &amp; !'nebula' ) 'crab' &amp; ( 'supernova' | 'sn' &amp; !'nebula' )
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -1592,13 +1592,13 @@ SELECT ts_rewrite(to_tsquery('supernovae &amp; crab'), 'SELECT * FROM aliases'); ...@@ -1592,13 +1592,13 @@ SELECT ts_rewrite(to_tsquery('supernovae &amp; crab'), 'SELECT * FROM aliases');
type. In the example below, we select only those rules which might match type. In the example below, we select only those rules which might match
the original query: the original query:
<programlisting> <screen>
SELECT ts_rewrite('a &amp; b'::tsquery, SELECT ts_rewrite('a &amp; b'::tsquery,
'SELECT t,s FROM aliases WHERE ''a &amp; b''::tsquery @&gt; t'); 'SELECT t,s FROM aliases WHERE ''a &amp; b''::tsquery @&gt; t');
ts_rewrite ts_rewrite
------------ ------------
'b' &amp; 'c' 'b' &amp; 'c'
</programlisting> </screen>
</para> </para>
</sect3> </sect3>
...@@ -1621,10 +1621,10 @@ SELECT ts_rewrite('a &amp; b'::tsquery, ...@@ -1621,10 +1621,10 @@ SELECT ts_rewrite('a &amp; b'::tsquery,
your own. your own.
</para> </para>
<synopsis> <synopsis>
tsvector_update_trigger(<replaceable class="PARAMETER">tsvector_column_name</replaceable>, <replaceable class="PARAMETER">config_name</replaceable>, <replaceable class="PARAMETER">text_column_name</replaceable> <optional>, ... </optional>) tsvector_update_trigger(<replaceable class="PARAMETER">tsvector_column_name</replaceable>, <replaceable class="PARAMETER">config_name</replaceable>, <replaceable class="PARAMETER">text_column_name</replaceable> <optional>, ... </optional>)
tsvector_update_trigger_column(<replaceable class="PARAMETER">tsvector_column_name</replaceable>, <replaceable class="PARAMETER">config_column_name</replaceable>, <replaceable class="PARAMETER">text_column_name</replaceable> <optional>, ... </optional>) tsvector_update_trigger_column(<replaceable class="PARAMETER">tsvector_column_name</replaceable>, <replaceable class="PARAMETER">config_column_name</replaceable>, <replaceable class="PARAMETER">text_column_name</replaceable> <optional>, ... </optional>)
</synopsis> </synopsis>
<para> <para>
These trigger functions automatically compute a <type>tsvector</> These trigger functions automatically compute a <type>tsvector</>
...@@ -1632,7 +1632,7 @@ SELECT ts_rewrite('a &amp; b'::tsquery, ...@@ -1632,7 +1632,7 @@ SELECT ts_rewrite('a &amp; b'::tsquery,
parameters specified in the <command>CREATE TRIGGER</> command. parameters specified in the <command>CREATE TRIGGER</> command.
An example of their use is: An example of their use is:
<programlisting> <screen>
CREATE TABLE messages ( CREATE TABLE messages (
title text, title text,
body text, body text,
...@@ -1654,7 +1654,7 @@ SELECT title, body FROM messages WHERE tsv @@ to_tsquery('title &amp; body'); ...@@ -1654,7 +1654,7 @@ SELECT title, body FROM messages WHERE tsv @@ to_tsquery('title &amp; body');
title | body title | body
------------+----------------------- ------------+-----------------------
title here | the body text is here title here | the body text is here
</programlisting> </screen>
Having created this trigger, any change in <structfield>title</> or Having created this trigger, any change in <structfield>title</> or
<structfield>body</> will automatically be reflected into <structfield>body</> will automatically be reflected into
...@@ -1696,7 +1696,7 @@ end ...@@ -1696,7 +1696,7 @@ end
$$ LANGUAGE plpgsql; $$ LANGUAGE plpgsql;
CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE CREATE TRIGGER tsvectorupdate BEFORE INSERT OR UPDATE
ON messages FOR EACH ROW EXECUTE PROCEDURE messages_trigger(); ON messages FOR EACH ROW EXECUTE PROCEDURE messages_trigger();
</programlisting> </programlisting>
</para> </para>
...@@ -1722,11 +1722,11 @@ ON messages FOR EACH ROW EXECUTE PROCEDURE messages_trigger(); ...@@ -1722,11 +1722,11 @@ ON messages FOR EACH ROW EXECUTE PROCEDURE messages_trigger();
configuration and for finding stop-word candidates. configuration and for finding stop-word candidates.
</para> </para>
<synopsis> <synopsis>
ts_stat(<replaceable class="PARAMETER">sqlquery</replaceable> <type>text</>, <optional> <replaceable class="PARAMETER">weights</replaceable> <type>text</>, </optional> ts_stat(<replaceable class="PARAMETER">sqlquery</replaceable> <type>text</>, <optional> <replaceable class="PARAMETER">weights</replaceable> <type>text</>, </optional>
OUT <replaceable class="PARAMETER">word</replaceable> <type>text</>, OUT <replaceable class="PARAMETER">ndoc</replaceable> <type>integer</>, OUT <replaceable class="PARAMETER">word</replaceable> <type>text</>, OUT <replaceable class="PARAMETER">ndoc</replaceable> <type>integer</>,
OUT <replaceable class="PARAMETER">nentry</replaceable> <type>integer</>) returns <type>setof record</> OUT <replaceable class="PARAMETER">nentry</replaceable> <type>integer</>) returns <type>setof record</>
</synopsis> </synopsis>
<para> <para>
<replaceable>sqlquery</replaceable> is a text value containing an SQL <replaceable>sqlquery</replaceable> is a text value containing an SQL
...@@ -1957,7 +1957,7 @@ LIMIT 10; ...@@ -1957,7 +1957,7 @@ LIMIT 10;
piece of text. As an example, a hyphenated word will be reported both piece of text. As an example, a hyphenated word will be reported both
as the entire word and as each component: as the entire word and as each component:
<programlisting> <screen>
SELECT alias, description, token FROM ts_debug('foo-bar-beta1'); SELECT alias, description, token FROM ts_debug('foo-bar-beta1');
alias | description | token alias | description | token
-----------------+------------------------------------------+--------------- -----------------+------------------------------------------+---------------
...@@ -1967,13 +1967,13 @@ SELECT alias, description, token FROM ts_debug('foo-bar-beta1'); ...@@ -1967,13 +1967,13 @@ SELECT alias, description, token FROM ts_debug('foo-bar-beta1');
hword_asciipart | Hyphenated word part, all ASCII | bar hword_asciipart | Hyphenated word part, all ASCII | bar
blank | Space symbols | - blank | Space symbols | -
hword_numpart | Hyphenated word part, letters and digits | beta1 hword_numpart | Hyphenated word part, letters and digits | beta1
</programlisting> </screen>
This behavior is desirable since it allows searches to work for both This behavior is desirable since it allows searches to work for both
the whole compound word and for components. Here is another the whole compound word and for components. Here is another
instructive example: instructive example:
<programlisting> <screen>
SELECT alias, description, token FROM ts_debug('http://example.com/stuff/index.html'); SELECT alias, description, token FROM ts_debug('http://example.com/stuff/index.html');
alias | description | token alias | description | token
----------+---------------+------------------------------ ----------+---------------+------------------------------
...@@ -1981,7 +1981,7 @@ SELECT alias, description, token FROM ts_debug('http://example.com/stuff/index.h ...@@ -1981,7 +1981,7 @@ SELECT alias, description, token FROM ts_debug('http://example.com/stuff/index.h
url | URL | example.com/stuff/index.html url | URL | example.com/stuff/index.html
host | Host | example.com host | Host | example.com
url_path | URL path | /stuff/index.html url_path | URL path | /stuff/index.html
</programlisting> </screen>
</para> </para>
</sect1> </sect1>
...@@ -2123,17 +2123,17 @@ ALTER TEXT SEARCH CONFIGURATION astro_en ...@@ -2123,17 +2123,17 @@ ALTER TEXT SEARCH CONFIGURATION astro_en
useless to store them in an index. However, stop words do affect the useless to store them in an index. However, stop words do affect the
positions in <type>tsvector</type>, which in turn affect ranking: positions in <type>tsvector</type>, which in turn affect ranking:
<programlisting> <screen>
SELECT to_tsvector('english','in the list of stop words'); SELECT to_tsvector('english','in the list of stop words');
to_tsvector to_tsvector
---------------------------- ----------------------------
'list':3 'stop':5 'word':6 'list':3 'stop':5 'word':6
</programlisting> </screen>
The missing positions 1,2,4 are because of stop words. Ranks The missing positions 1,2,4 are because of stop words. Ranks
calculated for documents with and without stop words are quite different: calculated for documents with and without stop words are quite different:
<programlisting> <screen>
SELECT ts_rank_cd (to_tsvector('english','in the list of stop words'), to_tsquery('list &amp; stop')); SELECT ts_rank_cd (to_tsvector('english','in the list of stop words'), to_tsquery('list &amp; stop'));
ts_rank_cd ts_rank_cd
------------ ------------
...@@ -2143,7 +2143,7 @@ SELECT ts_rank_cd (to_tsvector('english','list stop words'), to_tsquery('list &a ...@@ -2143,7 +2143,7 @@ SELECT ts_rank_cd (to_tsvector('english','list stop words'), to_tsquery('list &a
ts_rank_cd ts_rank_cd
------------ ------------
0.1 0.1
</programlisting> </screen>
</para> </para>
...@@ -2197,7 +2197,7 @@ CREATE TEXT SEARCH DICTIONARY public.simple_dict ( ...@@ -2197,7 +2197,7 @@ CREATE TEXT SEARCH DICTIONARY public.simple_dict (
<para> <para>
Now we can test our dictionary: Now we can test our dictionary:
<programlisting> <screen>
SELECT ts_lexize('public.simple_dict','YeS'); SELECT ts_lexize('public.simple_dict','YeS');
ts_lexize ts_lexize
----------- -----------
...@@ -2207,7 +2207,7 @@ SELECT ts_lexize('public.simple_dict','The'); ...@@ -2207,7 +2207,7 @@ SELECT ts_lexize('public.simple_dict','The');
ts_lexize ts_lexize
----------- -----------
{} {}
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -2216,7 +2216,7 @@ SELECT ts_lexize('public.simple_dict','The'); ...@@ -2216,7 +2216,7 @@ SELECT ts_lexize('public.simple_dict','The');
selected by setting the dictionary's <literal>Accept</> parameter to selected by setting the dictionary's <literal>Accept</> parameter to
<literal>false</>. Continuing the example: <literal>false</>. Continuing the example:
<programlisting> <screen>
ALTER TEXT SEARCH DICTIONARY public.simple_dict ( Accept = false ); ALTER TEXT SEARCH DICTIONARY public.simple_dict ( Accept = false );
SELECT ts_lexize('public.simple_dict','YeS'); SELECT ts_lexize('public.simple_dict','YeS');
...@@ -2228,7 +2228,7 @@ SELECT ts_lexize('public.simple_dict','The'); ...@@ -2228,7 +2228,7 @@ SELECT ts_lexize('public.simple_dict','The');
ts_lexize ts_lexize
----------- -----------
{} {}
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -2274,7 +2274,7 @@ SELECT ts_lexize('public.simple_dict','The'); ...@@ -2274,7 +2274,7 @@ SELECT ts_lexize('public.simple_dict','The');
synonym dictionary and put it before the <literal>english_stem</> synonym dictionary and put it before the <literal>english_stem</>
dictionary. For example: dictionary. For example:
<programlisting> <screen>
SELECT * FROM ts_debug('english', 'Paris'); SELECT * FROM ts_debug('english', 'Paris');
alias | description | token | dictionaries | dictionary | lexemes alias | description | token | dictionaries | dictionary | lexemes
-----------+-----------------+-------+----------------+--------------+--------- -----------+-----------------+-------+----------------+--------------+---------
...@@ -2293,7 +2293,7 @@ SELECT * FROM ts_debug('english', 'Paris'); ...@@ -2293,7 +2293,7 @@ SELECT * FROM ts_debug('english', 'Paris');
alias | description | token | dictionaries | dictionary | lexemes alias | description | token | dictionaries | dictionary | lexemes
-----------+-----------------+-------+---------------------------+------------+--------- -----------+-----------------+-------+---------------------------+------------+---------
asciiword | Word, all ASCII | Paris | {my_synonym,english_stem} | my_synonym | {paris} asciiword | Word, all ASCII | Paris | {my_synonym,english_stem} | my_synonym | {paris}
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -2306,7 +2306,6 @@ SELECT * FROM ts_debug('english', 'Paris'); ...@@ -2306,7 +2306,6 @@ SELECT * FROM ts_debug('english', 'Paris');
<para> <para>
Contents of <filename>$SHAREDIR/tsearch_data/synonym_sample.syn</>: Contents of <filename>$SHAREDIR/tsearch_data/synonym_sample.syn</>:
</para>
<programlisting> <programlisting>
postgres pgsql postgres pgsql
postgresql pgsql postgresql pgsql
...@@ -2314,44 +2313,45 @@ postgre pgsql ...@@ -2314,44 +2313,45 @@ postgre pgsql
gogle googl gogle googl
indices index* indices index*
</programlisting> </programlisting>
</para>
<para> <para>
Results: Results:
</para> <screen>
<programlisting> =# CREATE TEXT SEARCH DICTIONARY syn (template=synonym, synonyms='synonym_sample');
=# create text search dictionary syn( template=synonym,synonyms='synonym_sample'); =# SELECT ts_lexize('syn','indices');
=# select ts_lexize('syn','indices');
ts_lexize ts_lexize
----------- -----------
{index} {index}
(1 row) (1 row)
=# create text search configuration tst ( copy=simple); =# CREATE TEXT SEARCH CONFIGURATION tst (copy=simple);
=# alter text search configuration tst alter mapping for asciiword with syn; =# ALTER TEXT SEARCH CONFIGURATION tst ALTER MAPPING FOR asciiword WITH syn;
=# select to_tsquery('tst','indices'); =# SELECT to_tsquery('tst','indices');
to_tsquery to_tsquery
------------ ------------
'index':* 'index':*
(1 row) (1 row)
=# select 'indexes are very useful'::tsvector; =# SELECT 'indexes are very useful'::tsvector;
tsvector tsvector
--------------------------------- ---------------------------------
'are' 'indexes' 'useful' 'very' 'are' 'indexes' 'useful' 'very'
(1 row) (1 row)
=# select 'indexes are very useful'::tsvector @@ to_tsquery('tst','indices'); =# SELECT 'indexes are very useful'::tsvector @@ to_tsquery('tst','indices');
?column? ?column?
---------- ----------
t t
(1 row) (1 row)
=# select to_tsvector('tst','indices'); =# SELECT to_tsvector('tst','indices');
to_tsvector to_tsvector
------------- -------------
'index':1 'index':1
(1 row) (1 row)
</programlisting> </screen>
</para>
<para> <para>
The only parameter required by the <literal>synonym</> template is The only parameter required by the <literal>synonym</> template is
...@@ -2544,7 +2544,7 @@ ALTER TEXT SEARCH CONFIGURATION russian ...@@ -2544,7 +2544,7 @@ ALTER TEXT SEARCH CONFIGURATION russian
<function>plainto_tsquery</function> and <function>to_tsvector</function> <function>plainto_tsquery</function> and <function>to_tsvector</function>
which will break their input strings into multiple tokens: which will break their input strings into multiple tokens:
<programlisting> <screen>
SELECT plainto_tsquery('supernova star'); SELECT plainto_tsquery('supernova star');
plainto_tsquery plainto_tsquery
----------------- -----------------
...@@ -2554,17 +2554,17 @@ SELECT to_tsvector('supernova star'); ...@@ -2554,17 +2554,17 @@ SELECT to_tsvector('supernova star');
to_tsvector to_tsvector
------------- -------------
'sn':1 'sn':1
</programlisting> </screen>
In principle, one can use <function>to_tsquery</function> if you quote In principle, one can use <function>to_tsquery</function> if you quote
the argument: the argument:
<programlisting> <screen>
SELECT to_tsquery('''supernova star'''); SELECT to_tsquery('''supernova star''');
to_tsquery to_tsquery
------------ ------------
'sn' 'sn'
</programlisting> </screen>
Notice that <literal>supernova star</literal> matches <literal>supernovae Notice that <literal>supernova star</literal> matches <literal>supernovae
stars</literal> in <literal>thesaurus_astro</literal> because we specified stars</literal> in <literal>thesaurus_astro</literal> because we specified
...@@ -2576,14 +2576,14 @@ SELECT to_tsquery('''supernova star'''); ...@@ -2576,14 +2576,14 @@ SELECT to_tsquery('''supernova star''');
To index the original phrase as well as the substitute, just include it To index the original phrase as well as the substitute, just include it
in the right-hand part of the definition: in the right-hand part of the definition:
<programlisting> <screen>
supernovae stars : sn supernovae stars supernovae stars : sn supernovae stars
SELECT plainto_tsquery('supernova star'); SELECT plainto_tsquery('supernova star');
plainto_tsquery plainto_tsquery
----------------------------- -----------------------------
'sn' &amp; 'supernova' &amp; 'star' 'sn' &amp; 'supernova' &amp; 'star'
</programlisting> </screen>
</para> </para>
</sect3> </sect3>
...@@ -2820,7 +2820,7 @@ version of our software. ...@@ -2820,7 +2820,7 @@ version of our software.
The next step is to set the session to use the new configuration, which was The next step is to set the session to use the new configuration, which was
created in the <literal>public</> schema: created in the <literal>public</> schema:
<programlisting> <screen>
=&gt; \dF =&gt; \dF
List of text search configurations List of text search configurations
Schema | Name | Description Schema | Name | Description
...@@ -2834,7 +2834,7 @@ SHOW default_text_search_config; ...@@ -2834,7 +2834,7 @@ SHOW default_text_search_config;
default_text_search_config default_text_search_config
---------------------------- ----------------------------
public.pg public.pg
</programlisting> </screen>
</para> </para>
</sect1> </sect1>
...@@ -2861,8 +2861,8 @@ SHOW default_text_search_config; ...@@ -2861,8 +2861,8 @@ SHOW default_text_search_config;
<primary>ts_debug</primary> <primary>ts_debug</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
ts_debug(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">document</replaceable> <type>text</>, ts_debug(<optional> <replaceable class="PARAMETER">config</replaceable> <type>regconfig</>, </optional> <replaceable class="PARAMETER">document</replaceable> <type>text</>,
OUT <replaceable class="PARAMETER">alias</> <type>text</>, OUT <replaceable class="PARAMETER">alias</> <type>text</>,
OUT <replaceable class="PARAMETER">description</> <type>text</>, OUT <replaceable class="PARAMETER">description</> <type>text</>,
OUT <replaceable class="PARAMETER">token</> <type>text</>, OUT <replaceable class="PARAMETER">token</> <type>text</>,
...@@ -2870,7 +2870,7 @@ SHOW default_text_search_config; ...@@ -2870,7 +2870,7 @@ SHOW default_text_search_config;
OUT <replaceable class="PARAMETER">dictionary</> <type>regdictionary</>, OUT <replaceable class="PARAMETER">dictionary</> <type>regdictionary</>,
OUT <replaceable class="PARAMETER">lexemes</> <type>text[]</>) OUT <replaceable class="PARAMETER">lexemes</> <type>text[]</>)
returns setof record returns setof record
</synopsis> </synopsis>
<para> <para>
<function>ts_debug</> displays information about every token of <function>ts_debug</> displays information about every token of
...@@ -2929,7 +2929,7 @@ SHOW default_text_search_config; ...@@ -2929,7 +2929,7 @@ SHOW default_text_search_config;
<para> <para>
Here is a simple example: Here is a simple example:
<programlisting> <screen>
SELECT * FROM ts_debug('english','a fat cat sat on a mat - it ate a fat rats'); SELECT * FROM ts_debug('english','a fat cat sat on a mat - it ate a fat rats');
alias | description | token | dictionaries | dictionary | lexemes alias | description | token | dictionaries | dictionary | lexemes
-----------+-----------------+-------+----------------+--------------+--------- -----------+-----------------+-------+----------------+--------------+---------
...@@ -2957,7 +2957,7 @@ SELECT * FROM ts_debug('english','a fat cat sat on a mat - it ate a fat rats'); ...@@ -2957,7 +2957,7 @@ SELECT * FROM ts_debug('english','a fat cat sat on a mat - it ate a fat rats');
asciiword | Word, all ASCII | fat | {english_stem} | english_stem | {fat} asciiword | Word, all ASCII | fat | {english_stem} | english_stem | {fat}
blank | Space symbols | | {} | | blank | Space symbols | | {} | |
asciiword | Word, all ASCII | rats | {english_stem} | english_stem | {rat} asciiword | Word, all ASCII | rats | {english_stem} | english_stem | {rat}
</programlisting> </screen>
</para> </para>
<para> <para>
...@@ -2980,7 +2980,7 @@ ALTER TEXT SEARCH CONFIGURATION public.english ...@@ -2980,7 +2980,7 @@ ALTER TEXT SEARCH CONFIGURATION public.english
ALTER MAPPING FOR asciiword WITH english_ispell, english_stem; ALTER MAPPING FOR asciiword WITH english_ispell, english_stem;
</programlisting> </programlisting>
<programlisting> <screen>
SELECT * FROM ts_debug('public.english','The Brightest supernovaes'); SELECT * FROM ts_debug('public.english','The Brightest supernovaes');
alias | description | token | dictionaries | dictionary | lexemes alias | description | token | dictionaries | dictionary | lexemes
-----------+-----------------+-------------+-------------------------------+----------------+------------- -----------+-----------------+-------------+-------------------------------+----------------+-------------
...@@ -2989,7 +2989,7 @@ SELECT * FROM ts_debug('public.english','The Brightest supernovaes'); ...@@ -2989,7 +2989,7 @@ SELECT * FROM ts_debug('public.english','The Brightest supernovaes');
asciiword | Word, all ASCII | Brightest | {english_ispell,english_stem} | english_ispell | {bright} asciiword | Word, all ASCII | Brightest | {english_ispell,english_stem} | english_ispell | {bright}
blank | Space symbols | | {} | | blank | Space symbols | | {} | |
asciiword | Word, all ASCII | supernovaes | {english_ispell,english_stem} | english_stem | {supernova} asciiword | Word, all ASCII | supernovaes | {english_ispell,english_stem} | english_stem | {supernova}
</programlisting> </screen>
<para> <para>
In this example, the word <literal>Brightest</> was recognized by the In this example, the word <literal>Brightest</> was recognized by the
...@@ -3018,7 +3018,7 @@ SELECT * FROM ts_debug('public.english','The Brightest supernovaes'); ...@@ -3018,7 +3018,7 @@ SELECT * FROM ts_debug('public.english','The Brightest supernovaes');
You can reduce the width of the output by explicitly specifying which columns You can reduce the width of the output by explicitly specifying which columns
you want to see: you want to see:
<programlisting> <screen>
SELECT alias, token, dictionary, lexemes SELECT alias, token, dictionary, lexemes
FROM ts_debug('public.english','The Brightest supernovaes'); FROM ts_debug('public.english','The Brightest supernovaes');
alias | token | dictionary | lexemes alias | token | dictionary | lexemes
...@@ -3028,7 +3028,7 @@ FROM ts_debug('public.english','The Brightest supernovaes'); ...@@ -3028,7 +3028,7 @@ FROM ts_debug('public.english','The Brightest supernovaes');
asciiword | Brightest | english_ispell | {bright} asciiword | Brightest | english_ispell | {bright}
blank | | | blank | | |
asciiword | supernovaes | english_stem | {supernova} asciiword | supernovaes | english_stem | {supernova}
</programlisting> </screen>
</para> </para>
</sect2> </sect2>
...@@ -3044,12 +3044,12 @@ FROM ts_debug('public.english','The Brightest supernovaes'); ...@@ -3044,12 +3044,12 @@ FROM ts_debug('public.english','The Brightest supernovaes');
<primary>ts_parse</primary> <primary>ts_parse</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
ts_parse(<replaceable class="PARAMETER">parser_name</replaceable> <type>text</>, <replaceable class="PARAMETER">document</replaceable> <type>text</>, ts_parse(<replaceable class="PARAMETER">parser_name</replaceable> <type>text</>, <replaceable class="PARAMETER">document</replaceable> <type>text</>,
OUT <replaceable class="PARAMETER">tokid</> <type>integer</>, OUT <replaceable class="PARAMETER">token</> <type>text</>) returns <type>setof record</> OUT <replaceable class="PARAMETER">tokid</> <type>integer</>, OUT <replaceable class="PARAMETER">token</> <type>text</>) returns <type>setof record</>
ts_parse(<replaceable class="PARAMETER">parser_oid</replaceable> <type>oid</>, <replaceable class="PARAMETER">document</replaceable> <type>text</>, ts_parse(<replaceable class="PARAMETER">parser_oid</replaceable> <type>oid</>, <replaceable class="PARAMETER">document</replaceable> <type>text</>,
OUT <replaceable class="PARAMETER">tokid</> <type>integer</>, OUT <replaceable class="PARAMETER">token</> <type>text</>) returns <type>setof record</> OUT <replaceable class="PARAMETER">tokid</> <type>integer</>, OUT <replaceable class="PARAMETER">token</> <type>text</>) returns <type>setof record</>
</synopsis> </synopsis>
<para> <para>
<function>ts_parse</> parses the given <replaceable>document</replaceable> <function>ts_parse</> parses the given <replaceable>document</replaceable>
...@@ -3058,7 +3058,7 @@ FROM ts_debug('public.english','The Brightest supernovaes'); ...@@ -3058,7 +3058,7 @@ FROM ts_debug('public.english','The Brightest supernovaes');
assigned token type and a <varname>token</varname> which is the text of the assigned token type and a <varname>token</varname> which is the text of the
token. For example: token. For example:
<programlisting> <screen>
SELECT * FROM ts_parse('default', '123 - a number'); SELECT * FROM ts_parse('default', '123 - a number');
tokid | token tokid | token
-------+-------- -------+--------
...@@ -3068,19 +3068,19 @@ SELECT * FROM ts_parse('default', '123 - a number'); ...@@ -3068,19 +3068,19 @@ SELECT * FROM ts_parse('default', '123 - a number');
1 | a 1 | a
12 | 12 |
1 | number 1 | number
</programlisting> </screen>
</para> </para>
<indexterm> <indexterm>
<primary>ts_token_type</primary> <primary>ts_token_type</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
ts_token_type(<replaceable class="PARAMETER">parser_name</> <type>text</>, OUT <replaceable class="PARAMETER">tokid</> <type>integer</>, ts_token_type(<replaceable class="PARAMETER">parser_name</> <type>text</>, OUT <replaceable class="PARAMETER">tokid</> <type>integer</>,
OUT <replaceable class="PARAMETER">alias</> <type>text</>, OUT <replaceable class="PARAMETER">description</> <type>text</>) returns <type>setof record</> OUT <replaceable class="PARAMETER">alias</> <type>text</>, OUT <replaceable class="PARAMETER">description</> <type>text</>) returns <type>setof record</>
ts_token_type(<replaceable class="PARAMETER">parser_oid</> <type>oid</>, OUT <replaceable class="PARAMETER">tokid</> <type>integer</>, ts_token_type(<replaceable class="PARAMETER">parser_oid</> <type>oid</>, OUT <replaceable class="PARAMETER">tokid</> <type>integer</>,
OUT <replaceable class="PARAMETER">alias</> <type>text</>, OUT <replaceable class="PARAMETER">description</> <type>text</>) returns <type>setof record</> OUT <replaceable class="PARAMETER">alias</> <type>text</>, OUT <replaceable class="PARAMETER">description</> <type>text</>) returns <type>setof record</>
</synopsis> </synopsis>
<para> <para>
<function>ts_token_type</> returns a table which describes each type of <function>ts_token_type</> returns a table which describes each type of
...@@ -3090,7 +3090,7 @@ SELECT * FROM ts_parse('default', '123 - a number'); ...@@ -3090,7 +3090,7 @@ SELECT * FROM ts_parse('default', '123 - a number');
in configuration commands, and a short <varname>description</varname>. For in configuration commands, and a short <varname>description</varname>. For
example: example:
<programlisting> <screen>
SELECT * FROM ts_token_type('default'); SELECT * FROM ts_token_type('default');
tokid | alias | description tokid | alias | description
-------+-----------------+------------------------------------------ -------+-----------------+------------------------------------------
...@@ -3117,7 +3117,7 @@ SELECT * FROM ts_token_type('default'); ...@@ -3117,7 +3117,7 @@ SELECT * FROM ts_token_type('default');
21 | int | Signed integer 21 | int | Signed integer
22 | uint | Unsigned integer 22 | uint | Unsigned integer
23 | entity | XML entity 23 | entity | XML entity
</programlisting> </screen>
</para> </para>
</sect2> </sect2>
...@@ -3133,9 +3133,9 @@ SELECT * FROM ts_token_type('default'); ...@@ -3133,9 +3133,9 @@ SELECT * FROM ts_token_type('default');
<primary>ts_lexize</primary> <primary>ts_lexize</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
ts_lexize(<replaceable class="PARAMETER">dict</replaceable> <type>regdictionary</>, <replaceable class="PARAMETER">token</replaceable> <type>text</>) returns <type>text[]</> ts_lexize(<replaceable class="PARAMETER">dict</replaceable> <type>regdictionary</>, <replaceable class="PARAMETER">token</replaceable> <type>text</>) returns <type>text[]</>
</synopsis> </synopsis>
<para> <para>
<function>ts_lexize</> returns an array of lexemes if the input <function>ts_lexize</> returns an array of lexemes if the input
...@@ -3148,7 +3148,7 @@ SELECT * FROM ts_token_type('default'); ...@@ -3148,7 +3148,7 @@ SELECT * FROM ts_token_type('default');
<para> <para>
Examples: Examples:
<programlisting> <screen>
SELECT ts_lexize('english_stem', 'stars'); SELECT ts_lexize('english_stem', 'stars');
ts_lexize ts_lexize
----------- -----------
...@@ -3158,7 +3158,7 @@ SELECT ts_lexize('english_stem', 'a'); ...@@ -3158,7 +3158,7 @@ SELECT ts_lexize('english_stem', 'a');
ts_lexize ts_lexize
----------- -----------
{} {}
</programlisting> </screen>
</para> </para>
<note> <note>
...@@ -3167,12 +3167,12 @@ SELECT ts_lexize('english_stem', 'a'); ...@@ -3167,12 +3167,12 @@ SELECT ts_lexize('english_stem', 'a');
<emphasis>token</emphasis>, not text. Here is a case <emphasis>token</emphasis>, not text. Here is a case
where this can be confusing: where this can be confusing:
<programlisting> <screen>
SELECT ts_lexize('thesaurus_astro','supernovae stars') is null; SELECT ts_lexize('thesaurus_astro','supernovae stars') is null;
?column? ?column?
---------- ----------
t t
</programlisting> </screen>
The thesaurus dictionary <literal>thesaurus_astro</literal> does know the The thesaurus dictionary <literal>thesaurus_astro</literal> does know the
phrase <literal>supernovae stars</literal>, but <function>ts_lexize</> phrase <literal>supernovae stars</literal>, but <function>ts_lexize</>
...@@ -3180,12 +3180,12 @@ SELECT ts_lexize('thesaurus_astro','supernovae stars') is null; ...@@ -3180,12 +3180,12 @@ SELECT ts_lexize('thesaurus_astro','supernovae stars') is null;
token. Use <function>plainto_tsquery</> or <function>to_tsvector</> to token. Use <function>plainto_tsquery</> or <function>to_tsvector</> to
test thesaurus dictionaries, for example: test thesaurus dictionaries, for example:
<programlisting> <screen>
SELECT plainto_tsquery('supernovae stars'); SELECT plainto_tsquery('supernovae stars');
plainto_tsquery plainto_tsquery
----------------- -----------------
'sn' 'sn'
</programlisting> </screen>
</para> </para>
</note> </note>
...@@ -3219,9 +3219,9 @@ SELECT plainto_tsquery('supernovae stars'); ...@@ -3219,9 +3219,9 @@ SELECT plainto_tsquery('supernovae stars');
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> USING gist(<replaceable>column</replaceable>); CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> USING gist(<replaceable>column</replaceable>);
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -3242,9 +3242,9 @@ SELECT plainto_tsquery('supernovae stars'); ...@@ -3242,9 +3242,9 @@ SELECT plainto_tsquery('supernovae stars');
</indexterm> </indexterm>
<term> <term>
<synopsis> <synopsis>
CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> USING gin(<replaceable>column</replaceable>); CREATE INDEX <replaceable>name</replaceable> ON <replaceable>table</replaceable> USING gin(<replaceable>column</replaceable>);
</synopsis> </synopsis>
</term> </term>
<listitem> <listitem>
...@@ -3358,9 +3358,9 @@ SELECT plainto_tsquery('supernovae stars'); ...@@ -3358,9 +3358,9 @@ SELECT plainto_tsquery('supernovae stars');
<para> <para>
Information about text search configuration objects can be obtained Information about text search configuration objects can be obtained
in <application>psql</application> using a set of commands: in <application>psql</application> using a set of commands:
<synopsis> <synopsis>
\dF{d,p,t}<optional>+</optional> <optional>PATTERN</optional> \dF{d,p,t}<optional>+</optional> <optional>PATTERN</optional>
</synopsis> </synopsis>
An optional <literal>+</literal> produces more details. An optional <literal>+</literal> produces more details.
</para> </para>
...@@ -3372,39 +3372,33 @@ SELECT plainto_tsquery('supernovae stars'); ...@@ -3372,39 +3372,33 @@ SELECT plainto_tsquery('supernovae stars');
regular expression and can provide <emphasis>separate</emphasis> patterns regular expression and can provide <emphasis>separate</emphasis> patterns
for the schema and object names. The following examples illustrate this: for the schema and object names. The following examples illustrate this:
<programlisting> <screen>
=&gt; \dF *fulltext* =&gt; \dF *fulltext*
List of text search configurations List of text search configurations
Schema | Name | Description Schema | Name | Description
--------+--------------+------------- --------+--------------+-------------
public | fulltext_cfg | public | fulltext_cfg |
</programlisting> </screen>
<programlisting> <screen>
=&gt; \dF *.fulltext* =&gt; \dF *.fulltext*
List of text search configurations List of text search configurations
Schema | Name | Description Schema | Name | Description
----------+---------------------------- ----------+----------------------------
fulltext | fulltext_cfg | fulltext | fulltext_cfg |
public | fulltext_cfg | public | fulltext_cfg |
</programlisting> </screen>
The available commands are: The available commands are:
</para> </para>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><synopsis>\dF<optional>+</optional> <optional>PATTERN</optional></synopsis></term> <term><synopsis>\dF<optional>+</optional> <optional>PATTERN</optional></synopsis></term>
<listitem> <listitem>
<para> <para>
List text search configurations (add <literal>+</> for more detail). List text search configurations (add <literal>+</> for more detail).
</para> <screen>
<para>
<programlisting>
=&gt; \dF russian =&gt; \dF russian
List of text search configurations List of text search configurations
Schema | Name | Description Schema | Name | Description
...@@ -3435,7 +3429,7 @@ Parser: "pg_catalog.default" ...@@ -3435,7 +3429,7 @@ Parser: "pg_catalog.default"
url_path | simple url_path | simple
version | simple version | simple
word | russian_stem word | russian_stem
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3445,10 +3439,7 @@ Parser: "pg_catalog.default" ...@@ -3445,10 +3439,7 @@ Parser: "pg_catalog.default"
<listitem> <listitem>
<para> <para>
List text search dictionaries (add <literal>+</> for more detail). List text search dictionaries (add <literal>+</> for more detail).
</para> <screen>
<para>
<programlisting>
=&gt; \dFd =&gt; \dFd
List of text search dictionaries List of text search dictionaries
Schema | Name | Description Schema | Name | Description
...@@ -3469,21 +3460,17 @@ Parser: "pg_catalog.default" ...@@ -3469,21 +3460,17 @@ Parser: "pg_catalog.default"
pg_catalog | spanish_stem | snowball stemmer for spanish language pg_catalog | spanish_stem | snowball stemmer for spanish language
pg_catalog | swedish_stem | snowball stemmer for swedish language pg_catalog | swedish_stem | snowball stemmer for swedish language
pg_catalog | turkish_stem | snowball stemmer for turkish language pg_catalog | turkish_stem | snowball stemmer for turkish language
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><synopsis>\dFp<optional>+</optional> <optional>PATTERN</optional></synopsis></term> <term><synopsis>\dFp<optional>+</optional> <optional>PATTERN</optional></synopsis></term>
<listitem> <listitem>
<para> <para>
List text search parsers (add <literal>+</> for more detail). List text search parsers (add <literal>+</> for more detail).
</para> <screen>
<para>
<programlisting>
=&gt; \dFp =&gt; \dFp
List of text search parsers List of text search parsers
Schema | Name | Description Schema | Name | Description
...@@ -3526,21 +3513,17 @@ Parser: "pg_catalog.default" ...@@ -3526,21 +3513,17 @@ Parser: "pg_catalog.default"
version | Version number version | Version number
word | Word, all letters word | Word, all letters
(23 rows) (23 rows)
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><synopsis>\dFt<optional>+</optional> <optional>PATTERN</optional></synopsis></term> <term><synopsis>\dFt<optional>+</optional> <optional>PATTERN</optional></synopsis></term>
<listitem> <listitem>
<para> <para>
List text search templates (add <literal>+</> for more detail). List text search templates (add <literal>+</> for more detail).
</para> <screen>
<para>
<programlisting>
=&gt; \dFt =&gt; \dFt
List of text search templates List of text search templates
Schema | Name | Description Schema | Name | Description
...@@ -3550,11 +3533,10 @@ Parser: "pg_catalog.default" ...@@ -3550,11 +3533,10 @@ Parser: "pg_catalog.default"
pg_catalog | snowball | snowball stemmer pg_catalog | snowball | snowball stemmer
pg_catalog | synonym | synonym dictionary: replace word by its synonym pg_catalog | synonym | synonym dictionary: replace word by its synonym
pg_catalog | thesaurus | thesaurus dictionary: phrase by phrase substitution pg_catalog | thesaurus | thesaurus dictionary: phrase by phrase substitution
</programlisting> </screen>
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
</sect1> </sect1>
......
...@@ -44,7 +44,7 @@ ...@@ -44,7 +44,7 @@
<listitem> <listitem>
<para> <para>
Each line represents pair: character_with_accent character_without_accent Each line represents pair: character_with_accent character_without_accent
<programlisting> <programlisting>
&Agrave; A &Agrave; A
&Aacute; A &Aacute; A
&Acirc; A &Acirc; A
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
&Auml; A &Auml; A
&Aring; A &Aring; A
&AElig; A &AElig; A
</programlisting> </programlisting>
</para> </para>
</listitem> </listitem>
</itemizedlist> </itemizedlist>
...@@ -133,15 +133,14 @@ ...@@ -133,15 +133,14 @@
<primary>unaccent</primary> <primary>unaccent</primary>
</indexterm> </indexterm>
<synopsis> <synopsis>
unaccent(<optional><replaceable class="PARAMETER">dictionary</replaceable>, unaccent(<optional><replaceable class="PARAMETER">dictionary</replaceable>, </optional> <replaceable class="PARAMETER">string</replaceable>)
</optional> <replaceable class="PARAMETER">string</replaceable>) returns <type>text</type>
returns <type>text</type> </synopsis>
</synopsis>
<para> <para>
<programlisting> <programlisting>
SELECT unaccent('unaccent','Hôtel'); SELECT unaccent('unaccent', 'Hôtel');
SELECT unaccent('Hôtel'); SELECT unaccent('Hôtel');
</programlisting> </programlisting>
</para> </para>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/uuid-ossp.sgml,v 1.2 2007/12/06 04:12:10 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/uuid-ossp.sgml,v 1.3 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="uuid-ossp"> <sect1 id="uuid-ossp">
<title>uuid-ossp</title> <title>uuid-ossp</title>
...@@ -99,9 +99,9 @@ ...@@ -99,9 +99,9 @@
<para> <para>
For example: For example:
<programlisting> <programlisting>
SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org'); SELECT uuid_generate_v3(uuid_ns_url(), 'http://www.postgresql.org');
</programlisting> </programlisting>
The name parameter will be MD5-hashed, so the cleartext cannot be The name parameter will be MD5-hashed, so the cleartext cannot be
derived from the generated UUID. derived from the generated UUID.
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/vacuumlo.sgml,v 1.4 2009/02/26 16:02:37 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/vacuumlo.sgml,v 1.5 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="vacuumlo"> <sect1 id="vacuumlo">
<title>vacuumlo</title> <title>vacuumlo</title>
...@@ -25,9 +25,9 @@ ...@@ -25,9 +25,9 @@
<sect2> <sect2>
<title>Usage</title> <title>Usage</title>
<synopsis> <synopsis>
vacuumlo [options] database [database2 ... databaseN] vacuumlo [options] database [database2 ... databaseN]
</synopsis> </synopsis>
<para> <para>
All databases named on the command line are processed. Available options All databases named on the command line are processed. Available options
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.40 2010/04/03 07:22:56 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.41 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="xaggr"> <sect1 id="xaggr">
<title>User-Defined Aggregates</title> <title>User-Defined Aggregates</title>
...@@ -169,7 +169,7 @@ SELECT attrelid::regclass, array_accum(atttypid::regtype) ...@@ -169,7 +169,7 @@ SELECT attrelid::regclass, array_accum(atttypid::regtype)
aggregate transition or final function by calling aggregate transition or final function by calling
<function>AggCheckCallContext</>, for example: <function>AggCheckCallContext</>, for example:
<programlisting> <programlisting>
if (AggCheckCallContext(fcinfo, NULL)) if (AggCheckCallContext(fcinfo, NULL))
</programlisting> </programlisting>
One reason for checking this is that when it is true for a transition One reason for checking this is that when it is true for a transition
function, the first input function, the first input
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.151 2010/07/26 20:14:05 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.152 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="xfunc"> <sect1 id="xfunc">
<title>User-Defined Functions</title> <title>User-Defined Functions</title>
...@@ -3359,10 +3359,10 @@ void RequestAddinLWLocks(int n) ...@@ -3359,10 +3359,10 @@ void RequestAddinLWLocks(int n)
<function>AddinShmemInitLock</> when connecting to and initializing <function>AddinShmemInitLock</> when connecting to and initializing
its allocation of shared memory, as shown here: its allocation of shared memory, as shown here:
<programlisting> <programlisting>
static mystruct *ptr = NULL; static mystruct *ptr = NULL;
if (!ptr) if (!ptr)
{ {
bool found; bool found;
LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE); LWLockAcquire(AddinShmemInitLock, LW_EXCLUSIVE);
...@@ -3374,7 +3374,7 @@ void RequestAddinLWLocks(int n) ...@@ -3374,7 +3374,7 @@ void RequestAddinLWLocks(int n)
ptr->mylockid = LWLockAssign(); ptr->mylockid = LWLockAssign();
} }
LWLockRelease(AddinShmemInitLock); LWLockRelease(AddinShmemInitLock);
} }
</programlisting> </programlisting>
</para> </para>
</sect2> </sect2>
......
<!-- $PostgreSQL: pgsql/doc/src/sgml/xml2.sgml,v 1.8 2010/07/27 19:01:16 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/xml2.sgml,v 1.9 2010/07/29 19:34:40 petere Exp $ -->
<sect1 id="xml2"> <sect1 id="xml2">
<title>xml2</title> <title>xml2</title>
...@@ -45,9 +45,9 @@ ...@@ -45,9 +45,9 @@
<tbody> <tbody>
<row> <row>
<entry> <entry>
<synopsis> <synopsis>
xml_is_well_formed(document) returns bool xml_is_well_formed(document) returns bool
</synopsis> </synopsis>
</entry> </entry>
<entry> <entry>
<para> <para>
...@@ -61,11 +61,11 @@ ...@@ -61,11 +61,11 @@
</row> </row>
<row> <row>
<entry> <entry>
<synopsis> <synopsis>
xpath_string(document,query) returns text xpath_string(document, query) returns text
xpath_number(document,query) returns float4 xpath_number(document, query) returns float4
xpath_bool(document,query) returns bool xpath_bool(document, query) returns bool
</synopsis> </synopsis>
</entry> </entry>
<entry> <entry>
<para> <para>
...@@ -76,31 +76,29 @@ ...@@ -76,31 +76,29 @@
</row> </row>
<row> <row>
<entry> <entry>
<synopsis> <synopsis>
xpath_nodeset(document,query,toptag,itemtag) returns text xpath_nodeset(document, query, toptag, itemtag) returns text
</synopsis> </synopsis>
</entry> </entry>
<entry> <entry>
<para> <para>
This evaluates query on document and wraps the result in XML tags. If This evaluates query on document and wraps the result in XML tags. If
the result is multivalued, the output will look like: the result is multivalued, the output will look like:
</para> <synopsis>
<literal> &lt;toptag&gt;
&lt;toptag&gt; &lt;itemtag&gt;Value 1 which could be an XML fragment&lt;/itemtag&gt;
&lt;itemtag&gt;Value 1 which could be an XML fragment&lt;/itemtag&gt; &lt;itemtag&gt;Value 2....&lt;/itemtag&gt;
&lt;itemtag&gt;Value 2....&lt;/itemtag&gt; &lt;/toptag&gt;
&lt;/toptag&gt; </synopsis>
</literal>
<para>
If either toptag or itemtag is an empty string, the relevant tag is omitted. If either toptag or itemtag is an empty string, the relevant tag is omitted.
</para> </para>
</entry> </entry>
</row> </row>
<row> <row>
<entry> <entry>
<synopsis> <synopsis>
xpath_nodeset(document,query) returns text xpath_nodeset(document, query) returns text
</synopsis> </synopsis>
</entry> </entry>
<entry> <entry>
<para> <para>
...@@ -110,9 +108,9 @@ ...@@ -110,9 +108,9 @@
</row> </row>
<row> <row>
<entry> <entry>
<synopsis> <synopsis>
xpath_nodeset(document,query,itemtag) returns text xpath_nodeset(document, query, itemtag) returns text
</synopsis> </synopsis>
</entry> </entry>
<entry> <entry>
<para> <para>
...@@ -122,9 +120,9 @@ ...@@ -122,9 +120,9 @@
</row> </row>
<row> <row>
<entry> <entry>
<synopsis> <synopsis>
xpath_list(document,query,separator) returns text xpath_list(document, query, separator) returns text
</synopsis> </synopsis>
</entry> </entry>
<entry> <entry>
<para> <para>
...@@ -136,9 +134,9 @@ ...@@ -136,9 +134,9 @@
</row> </row>
<row> <row>
<entry> <entry>
<synopsis> <synopsis>
xpath_list(document,query) returns text xpath_list(document, query) returns text
</synopsis> </synopsis>
</entry> </entry>
<entry> <entry>
This is a wrapper for the above function that uses <literal>,</> This is a wrapper for the above function that uses <literal>,</>
...@@ -153,9 +151,9 @@ ...@@ -153,9 +151,9 @@
<sect2> <sect2>
<title><literal>xpath_table</literal></title> <title><literal>xpath_table</literal></title>
<synopsis> <synopsis>
xpath_table(text key, text document, text relation, text xpaths, text criteria) returns setof record xpath_table(text key, text document, text relation, text xpaths, text criteria) returns setof record
</synopsis> </synopsis>
<para> <para>
<function>xpath_table</> is a table function that evaluates a set of XPath <function>xpath_table</> is a table function that evaluates a set of XPath
...@@ -240,9 +238,7 @@ ...@@ -240,9 +238,7 @@
<para> <para>
The function has to be used in a <literal>FROM</> expression, with an The function has to be used in a <literal>FROM</> expression, with an
<literal>AS</> clause to specify the output columns; for example <literal>AS</> clause to specify the output columns; for example
</para> <programlisting>
<programlisting>
SELECT * FROM SELECT * FROM
xpath_table('article_id', xpath_table('article_id',
'article_xml', 'article_xml',
...@@ -250,9 +246,7 @@ xpath_table('article_id', ...@@ -250,9 +246,7 @@ xpath_table('article_id',
'/article/author|/article/pages|/article/title', '/article/author|/article/pages|/article/title',
'date_entered > ''2003-01-01'' ') 'date_entered > ''2003-01-01'' ')
AS t(article_id integer, author text, page_count integer, title text); AS t(article_id integer, author text, page_count integer, title text);
</programlisting> </programlisting>
<para>
The <literal>AS</> clause defines the names and types of the columns in the The <literal>AS</> clause defines the names and types of the columns in the
output table. The first is the <quote>key</> field and the rest correspond output table. The first is the <quote>key</> field and the rest correspond
to the XPath queries. to the XPath queries.
...@@ -278,9 +272,7 @@ AS t(article_id integer, author text, page_count integer, title text); ...@@ -278,9 +272,7 @@ AS t(article_id integer, author text, page_count integer, title text);
columns by name or join them to other tables. The function produces a columns by name or join them to other tables. The function produces a
virtual table with which you can perform any operation you wish (e.g. virtual table with which you can perform any operation you wish (e.g.
aggregation, joining, sorting etc). So we could also have: aggregation, joining, sorting etc). So we could also have:
</para> <programlisting>
<programlisting>
SELECT t.title, p.fullname, p.email SELECT t.title, p.fullname, p.email
FROM xpath_table('article_id', 'article_xml', 'articles', FROM xpath_table('article_id', 'article_xml', 'articles',
'/article/title|/article/author/@id', '/article/title|/article/author/@id',
...@@ -288,9 +280,7 @@ FROM xpath_table('article_id', 'article_xml', 'articles', ...@@ -288,9 +280,7 @@ FROM xpath_table('article_id', 'article_xml', 'articles',
AS t(article_id integer, title text, author_id integer), AS t(article_id integer, title text, author_id integer),
tblPeopleInfo AS p tblPeopleInfo AS p
WHERE t.author_id = p.person_id; WHERE t.author_id = p.person_id;
</programlisting> </programlisting>
<para>
as a more complicated example. Of course, you could wrap all as a more complicated example. Of course, you could wrap all
of this in a view for convenience. of this in a view for convenience.
</para> </para>
...@@ -314,60 +304,59 @@ WHERE t.author_id = p.person_id; ...@@ -314,60 +304,59 @@ WHERE t.author_id = p.person_id;
result will appear only on the first row of the result. The solution result will appear only on the first row of the result. The solution
to this is to use the key field as part of a join against a simpler to this is to use the key field as part of a join against a simpler
XPath query. As an example: XPath query. As an example:
</para>
<programlisting> <programlisting>
CREATE TABLE test ( CREATE TABLE test (
id int4 NOT NULL, id int PRIMARY KEY,
xml text, xml text
CONSTRAINT pk PRIMARY KEY (id) );
);
INSERT INTO test VALUES (1, '&lt;doc num="C1"&gt; INSERT INTO test VALUES (1, '&lt;doc num="C1"&gt;
&lt;line num="L1"&gt;&lt;a&gt;1&lt;/a&gt;&lt;b&gt;2&lt;/b&gt;&lt;c&gt;3&lt;/c&gt;&lt;/line&gt; &lt;line num="L1"&gt;&lt;a&gt;1&lt;/a&gt;&lt;b&gt;2&lt;/b&gt;&lt;c&gt;3&lt;/c&gt;&lt;/line&gt;
&lt;line num="L2"&gt;&lt;a&gt;11&lt;/a&gt;&lt;b&gt;22&lt;/b&gt;&lt;c&gt;33&lt;/c&gt;&lt;/line&gt; &lt;line num="L2"&gt;&lt;a&gt;11&lt;/a&gt;&lt;b&gt;22&lt;/b&gt;&lt;c&gt;33&lt;/c&gt;&lt;/line&gt;
&lt;/doc&gt;'); &lt;/doc&gt;');
INSERT INTO test VALUES (2, '&lt;doc num="C2"&gt; INSERT INTO test VALUES (2, '&lt;doc num="C2"&gt;
&lt;line num="L1"&gt;&lt;a&gt;111&lt;/a&gt;&lt;b&gt;222&lt;/b&gt;&lt;c&gt;333&lt;/c&gt;&lt;/line&gt; &lt;line num="L1"&gt;&lt;a&gt;111&lt;/a&gt;&lt;b&gt;222&lt;/b&gt;&lt;c&gt;333&lt;/c&gt;&lt;/line&gt;
&lt;line num="L2"&gt;&lt;a&gt;111&lt;/a&gt;&lt;b&gt;222&lt;/b&gt;&lt;c&gt;333&lt;/c&gt;&lt;/line&gt; &lt;line num="L2"&gt;&lt;a&gt;111&lt;/a&gt;&lt;b&gt;222&lt;/b&gt;&lt;c&gt;333&lt;/c&gt;&lt;/line&gt;
&lt;/doc&gt;'); &lt;/doc&gt;');
SELECT * FROM SELECT * FROM
xpath_table('id','xml','test', xpath_table('id','xml','test',
'/doc/@num|/doc/line/@num|/doc/line/a|/doc/line/b|/doc/line/c', '/doc/@num|/doc/line/@num|/doc/line/a|/doc/line/b|/doc/line/c',
'true') 'true')
AS t(id int4, doc_num varchar(10), line_num varchar(10), val1 int4, val2 int4, val3 int4) AS t(id int, doc_num varchar(10), line_num varchar(10), val1 int, val2 int, val3 int)
WHERE id = 1 ORDER BY doc_num, line_num WHERE id = 1 ORDER BY doc_num, line_num
id | doc_num | line_num | val1 | val2 | val3 id | doc_num | line_num | val1 | val2 | val3
----+---------+----------+------+------+------ ----+---------+----------+------+------+------
1 | C1 | L1 | 1 | 2 | 3 1 | C1 | L1 | 1 | 2 | 3
1 | | L2 | 11 | 22 | 33 1 | | L2 | 11 | 22 | 33
</programlisting> </programlisting>
</para>
<para> <para>
To get doc_num on every line, the solution is to use two invocations To get doc_num on every line, the solution is to use two invocations
of xpath_table and join the results: of xpath_table and join the results:
</para>
<programlisting> <programlisting>
SELECT t.*,i.doc_num FROM SELECT t.*,i.doc_num FROM
xpath_table('id', 'xml', 'test', xpath_table('id', 'xml', 'test',
'/doc/line/@num|/doc/line/a|/doc/line/b|/doc/line/c', '/doc/line/@num|/doc/line/a|/doc/line/b|/doc/line/c',
'true') 'true')
AS t(id int4, line_num varchar(10), val1 int4, val2 int4, val3 int4), AS t(id int, line_num varchar(10), val1 int, val2 int, val3 int),
xpath_table('id', 'xml', 'test', '/doc/@num', 'true') xpath_table('id', 'xml', 'test', '/doc/@num', 'true')
AS i(id int4, doc_num varchar(10)) AS i(id int, doc_num varchar(10))
WHERE i.id=t.id AND i.id=1 WHERE i.id=t.id AND i.id=1
ORDER BY doc_num, line_num; ORDER BY doc_num, line_num;
id | line_num | val1 | val2 | val3 | doc_num id | line_num | val1 | val2 | val3 | doc_num
----+----------+------+------+------+--------- ----+----------+------+------+------+---------
1 | L1 | 1 | 2 | 3 | C1 1 | L1 | 1 | 2 | 3 | C1
1 | L2 | 11 | 22 | 33 | C1 1 | L2 | 11 | 22 | 33 | C1
(2 rows) (2 rows)
</programlisting> </programlisting>
</para>
</sect3> </sect3>
</sect2> </sect2>
...@@ -381,9 +370,9 @@ WHERE t.author_id = p.person_id; ...@@ -381,9 +370,9 @@ WHERE t.author_id = p.person_id;
<sect3> <sect3>
<title><literal>xslt_process</literal></title> <title><literal>xslt_process</literal></title>
<synopsis> <synopsis>
xslt_process(text document, text stylesheet, text paramlist) returns text xslt_process(text document, text stylesheet, text paramlist) returns text
</synopsis> </synopsis>
<para> <para>
This function applies the XSL stylesheet to the document and returns This function applies the XSL stylesheet to the document and returns
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment