mirror of
https://github.com/postgres/postgres.git
synced 2025-07-18 17:42:25 +03:00
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.
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.8.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="auto-explain">
|
<sect1 id="auto-explain">
|
||||||
<title>auto_explain</title>
|
<title>auto_explain</title>
|
||||||
@ -187,7 +187,7 @@ auto_explain.log_min_duration = '3s'
|
|||||||
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
|
||||||
@ -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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.4.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="citext">
|
<sect1 id="citext">
|
||||||
<title>citext</title>
|
<title>citext</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.139.2.1 2010/07/29 19:34:36 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
|
|||||||
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>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.294.2.2 2010/07/27 19:01:04 petere Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.294.2.3 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<chapter Id="runtime-config">
|
<chapter Id="runtime-config">
|
||||||
<title>Server Configuration</title>
|
<title>Server Configuration</title>
|
||||||
@ -5720,29 +5720,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>
|
|
||||||
<para>
|
|
||||||
LOG: GrantLock: lock(0xb7acd844) id(24688,24696,0,0,0,1)
|
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)
|
||||||
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
LOG: UnGrantLock: updated: lock(0xb7acd844) id(24688,24696,0,0,0,1)
|
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>
|
|
||||||
<para>
|
|
||||||
LOG: CleanUpLock: deleting: lock(0xb7acd844) id(24688,24696,0,0,0,1)
|
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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.7.8.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="cube">
|
<sect1 id="cube">
|
||||||
<title>cube</title>
|
<title>cube</title>
|
||||||
@ -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 && 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 && b</></entry>
|
||||||
<programlisting>
|
<entry>The cubes a and b overlap.</entry>
|
||||||
a @> b Contains
|
</row>
|
||||||
</programlisting>
|
|
||||||
<para>
|
<row>
|
||||||
The cube a contains the cube b.
|
<entry><literal>a @> b</></entry>
|
||||||
</para>
|
<entry>The cube a contains the cube b.</entry>
|
||||||
</listitem>
|
</row>
|
||||||
<listitem>
|
|
||||||
<programlisting>
|
<row>
|
||||||
a <@ b Contained in
|
<entry><literal>a <@ 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 @> and <@ were
|
(Before PostgreSQL 8.2, the containment operators <literal>@></> and <literal><@</> 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 <@ 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] < [c, d] Less than
|
<tgroup cols="2">
|
||||||
[a, b] > [c, d] Greater than
|
<thead>
|
||||||
</programlisting>
|
<row>
|
||||||
|
<entry>Operator</entry>
|
||||||
|
<entry>Description</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><literal>[a, b] < [c, d]</literal></entry>
|
||||||
|
<entry>Less than</entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry><literal>[a, b] > [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),
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.250.2.3 2010/07/27 19:01:04 petere Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.250.2.4 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="datatype">
|
<chapter id="datatype">
|
||||||
<title>Data Types</title>
|
<title>Data Types</title>
|
||||||
@ -1576,7 +1576,7 @@ 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
|
||||||
@ -1590,7 +1590,7 @@ SELECT E'\\xDEADBEEF';
|
|||||||
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</>,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.13.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="dblink">
|
<sect1 id="dblink">
|
||||||
<title>dblink</title>
|
<title>dblink</title>
|
||||||
@ -116,14 +116,14 @@
|
|||||||
<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
|
||||||
@ -175,7 +175,7 @@
|
|||||||
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>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -441,12 +441,12 @@ SELECT *
|
|||||||
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>
|
||||||
@ -454,9 +454,9 @@ SELECT *
|
|||||||
<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
|
||||||
@ -473,14 +473,14 @@ SELECT *
|
|||||||
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
|
||||||
@ -497,14 +497,14 @@ SELECT *
|
|||||||
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
|
||||||
@ -522,7 +522,7 @@ SELECT *
|
|||||||
byteain | byteain
|
byteain | byteain
|
||||||
byteaout | byteaout
|
byteaout | byteaout
|
||||||
(14 rows)
|
(14 rows)
|
||||||
</programlisting>
|
</screen>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
|
||||||
@ -622,32 +622,32 @@ 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
|
||||||
|
|
||||||
@ -655,7 +655,7 @@ SELECT *
|
|||||||
-------------
|
-------------
|
||||||
ERROR
|
ERROR
|
||||||
(1 row)
|
(1 row)
|
||||||
</programlisting>
|
</screen>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -880,20 +880,20 @@ 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
|
||||||
@ -903,7 +903,7 @@ SELECT *
|
|||||||
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
|
||||||
@ -913,18 +913,18 @@ SELECT *
|
|||||||
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>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -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();
|
|||||||
-------------+--------+-------
|
-------------+--------+-------
|
||||||
virtual | 1229 |
|
virtual | 1229 |
|
||||||
(1 row)
|
(1 row)
|
||||||
</programlisting>
|
</screen>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
</refentry>
|
</refentry>
|
||||||
|
|
||||||
@ -1439,21 +1439,21 @@ 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 < 3') as t1;
|
contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 < 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}
|
||||||
@ -1461,19 +1461,19 @@ SELECT * FROM dblink_get_notify();
|
|||||||
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 < 3; select * from foo where f1 > 6') as t1;
|
contrib_regression-# dblink_send_query('dtest1', 'select * from foo where f1 < 3; select * from foo where f1 > 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}
|
||||||
@ -1481,7 +1481,7 @@ SELECT * FROM dblink_get_notify();
|
|||||||
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}
|
||||||
@ -1490,11 +1490,11 @@ SELECT * FROM dblink_get_notify();
|
|||||||
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>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|
||||||
@ -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>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.93.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="ddl">
|
<chapter id="ddl">
|
||||||
<title>Data Definition</title>
|
<title>Data Definition</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.3.12.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="dict-xsyn">
|
<sect1 id="dict-xsyn">
|
||||||
<title>dict_xsyn</title>
|
<title>dict_xsyn</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.100.2.1 2010/07/29 19:34:36 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>
|
||||||
@ -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>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.521.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="functions">
|
<chapter id="functions">
|
||||||
<title>Functions and Operators</title>
|
<title>Functions and Operators</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.5.14.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="fuzzystrmatch">
|
<sect1 id="fuzzystrmatch">
|
||||||
<title>fuzzystrmatch</title>
|
<title>fuzzystrmatch</title>
|
||||||
@ -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.
|
||||||
@ -80,10 +80,10 @@ SELECT * FROM s WHERE difference(s.nm, 'john') > 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') > 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);
|
|||||||
-------------
|
-------------
|
||||||
3
|
3
|
||||||
(1 row)
|
(1 row)
|
||||||
</programlisting>
|
</screen>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2>
|
<sect2>
|
||||||
@ -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);
|
|||||||
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);
|
|||||||
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);
|
|||||||
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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.12.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="hstore">
|
<sect1 id="hstore">
|
||||||
<title>hstore</title>
|
<title>hstore</title>
|
||||||
@ -24,11 +24,11 @@
|
|||||||
includes zero or more <replaceable>key</> <literal>=></>
|
includes zero or more <replaceable>key</> <literal>=></>
|
||||||
<replaceable>value</> pairs separated by commas. Some examples:
|
<replaceable>value</> pairs separated by commas. Some examples:
|
||||||
|
|
||||||
<programlisting>
|
<synopsis>
|
||||||
k => v
|
k => v
|
||||||
foo => bar, baz => whatever
|
foo => bar, baz => whatever
|
||||||
"1-a" => "anything at all"
|
"1-a" => "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>=></> sign is
|
output). Whitespace between pairs or around the <literal>=></> sign is
|
||||||
@ -43,7 +43,7 @@
|
|||||||
there is no guarantee as to which will be kept:
|
there is no guarantee as to which will be kept:
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
% select 'a=>1,a=>2'::hstore;
|
SELECT 'a=>1,a=>2'::hstore;
|
||||||
hstore
|
hstore
|
||||||
----------
|
----------
|
||||||
"a"=>"1"
|
"a"=>"1"
|
||||||
@ -58,7 +58,7 @@
|
|||||||
</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>
|
||||||
@ -448,21 +448,20 @@ 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' => '3');
|
UPDATE tab SET h = h || ('c' => '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');
|
||||||
@ -473,10 +472,10 @@ SELECT hstore(t) FROM test AS t;
|
|||||||
"col1"=>"123", "col2"=>"foo", "col3"=>"bar"
|
"col1"=>"123", "col2"=>"foo", "col3"=>"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);
|
||||||
|
|
||||||
@ -487,10 +486,10 @@ 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');
|
||||||
@ -501,6 +500,7 @@ SELECT (r).* FROM (SELECT t #= '"col3"=>"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,21 +515,20 @@ SELECT (r).* FROM (SELECT t #= '"col3"=>"baz"' AS r FROM test t) s;
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
Simple example:
|
Simple example:
|
||||||
</para>
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
SELECT * FROM each('aaa=>bq, b=>NULL, ""=>1');
|
SELECT * FROM each('aaa=>bq, b=>NULL, ""=>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
|
||||||
@ -548,6 +547,7 @@ SELECT key, count(*) FROM
|
|||||||
org | 189
|
org | 189
|
||||||
...................
|
...................
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2>
|
<sect2>
|
||||||
@ -572,10 +572,10 @@ 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:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.33.6.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="indexam">
|
<chapter id="indexam">
|
||||||
<title>Index Access Method Interface Definition</title>
|
<title>Index Access Method Interface Definition</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.57.4.1 2010/07/27 19:01:04 petere Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/install-win32.sgml,v 1.57.4.2 2010/07/29 19:34:36 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 @@
|
|||||||
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 @@
|
|||||||
<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>
|
||||||
@ -293,41 +293,29 @@
|
|||||||
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
|
|
||||||
</userinput>
|
|
||||||
</screen>
|
</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
|
|
||||||
</userinput>
|
|
||||||
</screen>
|
</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>
|
|
||||||
<userinput>
|
|
||||||
build DEBUG psql
|
|
||||||
</userinput>
|
|
||||||
</screen>
|
</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";
|
||||||
</userinput>
|
</programlisting>
|
||||||
</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
|
|
||||||
</userinput>
|
|
||||||
</screen>
|
</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)
|
||||||
@ -355,9 +343,7 @@
|
|||||||
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
|
|
||||||
</userinput>
|
|
||||||
</screen>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
@ -374,26 +360,16 @@
|
|||||||
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
|
|
||||||
</userinput>
|
|
||||||
<userinput>
|
|
||||||
vcregress plcheck
|
|
||||||
</userinput>
|
|
||||||
<userinput>
|
|
||||||
vcregress contribcheck
|
|
||||||
</userinput>
|
|
||||||
</screen>
|
</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
|
|
||||||
</userinput>
|
|
||||||
</screen>
|
</screen>
|
||||||
|
|
||||||
For more information about the regression tests, see
|
For more information about the regression tests, see
|
||||||
@ -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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.4.14.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="intagg">
|
<sect1 id="intagg">
|
||||||
<title>intagg</title>
|
<title>intagg</title>
|
||||||
@ -44,7 +44,6 @@
|
|||||||
<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, ...);
|
||||||
@ -52,16 +51,13 @@ 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);
|
|||||||
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,7 +102,6 @@ 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
|
||||||
@ -123,6 +112,7 @@ SELECT right, count(right) FROM
|
|||||||
GROUP BY right
|
GROUP BY right
|
||||||
ORDER BY count DESC;
|
ORDER BY count DESC;
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.10.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="intarray">
|
<sect1 id="intarray">
|
||||||
<title>intarray</title>
|
<title>intarray</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.5.14.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="isn">
|
<sect1 id="isn">
|
||||||
<title>isn</title>
|
<title>isn</title>
|
||||||
@ -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.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.313.2.2 2010/07/27 19:01:04 petere Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.313.2.3 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="libpq">
|
<chapter id="libpq">
|
||||||
<title><application>libpq</application> - C Library</title>
|
<title><application>libpq</application> - C Library</title>
|
||||||
@ -670,13 +670,9 @@ PGconn *PQsetdb(char *pghost,
|
|||||||
|
|
||||||
<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>
|
||||||
@ -1017,8 +1013,7 @@ PQconninfoOption *PQconninfoParse(const char *conninfo, char **errmsg);
|
|||||||
|
|
||||||
<synopsis>
|
<synopsis>
|
||||||
int PQresetStart(PGconn *conn);
|
int PQresetStart(PGconn *conn);
|
||||||
</synopsis>
|
|
||||||
<synopsis>
|
|
||||||
PostgresPollingStatusType PQresetPoll(PGconn *conn);
|
PostgresPollingStatusType PQresetPoll(PGconn *conn);
|
||||||
</synopsis>
|
</synopsis>
|
||||||
</para>
|
</para>
|
||||||
@ -2916,7 +2911,8 @@ PQfnumber(res, "\"BAR\"") <lineannotation>1</lineannotation>
|
|||||||
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 */
|
||||||
@ -3089,7 +3085,7 @@ 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>
|
||||||
|
|
||||||
@ -3153,7 +3149,7 @@ 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>
|
||||||
|
|
||||||
@ -4122,10 +4118,12 @@ 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;
|
||||||
@ -4211,7 +4209,8 @@ typedef struct {
|
|||||||
<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 */
|
||||||
@ -4869,7 +4868,8 @@ char *pg_encoding_to_char(int <replaceable>encoding_id</replaceable>);
|
|||||||
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
|
||||||
@ -6406,7 +6406,7 @@ 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
|
||||||
@ -6418,24 +6418,24 @@ user=admin
|
|||||||
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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.3.16.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="lo">
|
<sect1 id="lo">
|
||||||
<title>lo</title>
|
<title>lo</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.4.4.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="ltree">
|
<sect1 id="ltree">
|
||||||
<title>ltree</title>
|
<title>ltree</title>
|
||||||
@ -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 — same as </lineannotation> *{0,<replaceable>m</>}
|
*{,<replaceable>m</>} <lineannotation>Match at most <replaceable>m</> labels — 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
|
||||||
@ -559,7 +559,7 @@ CREATE INDEX path_idx ON test USING btree(path);
|
|||||||
the hierarchy shown below:
|
the hierarchy shown below:
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<programlisting>
|
<literallayout class="monospaced">
|
||||||
Top
|
Top
|
||||||
/ | \
|
/ | \
|
||||||
Science Hobbies Collections
|
Science Hobbies Collections
|
||||||
@ -569,14 +569,12 @@ CREATE INDEX path_idx ON test USING btree(path);
|
|||||||
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=> SELECT path FROM test WHERE path <@ 'Top.Science';
|
||||||
<programlisting>
|
|
||||||
ltreetest=# select path from test where path <@ 'Top.Science';
|
|
||||||
path
|
path
|
||||||
------------------------------------
|
------------------------------------
|
||||||
Top.Science
|
Top.Science
|
||||||
@ -584,14 +582,13 @@ ltreetest=# select path from test where path <@ '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=> 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.*';
|
|||||||
Top.Collections.Pictures.Astronomy.Astronauts
|
Top.Collections.Pictures.Astronomy.Astronauts
|
||||||
(7 rows)
|
(7 rows)
|
||||||
|
|
||||||
ltreetest=# select path from test where path ~ '*.!pictures@.*.Astronomy.*';
|
ltreetest=> 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=> SELECT path FROM test WHERE path @ 'Astro*% & !pictures@';
|
||||||
ltreetest=# select path from test where path @ 'Astro*% & !pictures@';
|
|
||||||
path
|
path
|
||||||
------------------------------------
|
------------------------------------
|
||||||
Top.Science.Astronomy
|
Top.Science.Astronomy
|
||||||
@ -625,45 +622,46 @@ ltreetest=# select path from test where path @ 'Astro*% & !pictures@';
|
|||||||
Top.Hobbies.Amateurs_Astronomy
|
Top.Hobbies.Amateurs_Astronomy
|
||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
ltreetest=# select path from test where path @ 'Astro* & !pictures@';
|
ltreetest=> SELECT path FROM test WHERE path @ 'Astro* & !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=> SELECT subpath(path,0,2)||'Space'||subpath(path,2) FROM test WHERE path <@ 'Top.Science.Astronomy';
|
||||||
ltreetest=# select subpath(path,0,2)||'Space'||subpath(path,2) from test where path <@ '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 <@ 'Top.Science.Astronomy';
|
ltreetest=> SELECT ins_label(path,2,'Space') FROM test WHERE path <@ '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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.80.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="monitoring">
|
<chapter id="monitoring">
|
||||||
<title>Monitoring Database Activity</title>
|
<title>Monitoring Database Activity</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.8.2.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="oid2name">
|
<sect1 id="oid2name">
|
||||||
<title>oid2name</title>
|
<title>oid2name</title>
|
||||||
@ -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":
|
|||||||
Filenode Table Name
|
Filenode Table Name
|
||||||
----------------------
|
----------------------
|
||||||
155156 foo
|
155156 foo
|
||||||
</programlisting>
|
</screen>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2>
|
<sect2>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.6.14.1 2010/07/29 19:34:36 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pageinspect">
|
<sect1 id="pageinspect">
|
||||||
<title>pageinspect</title>
|
<title>pageinspect</title>
|
||||||
@ -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));
|
|||||||
<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));
|
|||||||
<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
|
|||||||
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
|
|||||||
<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
|
|||||||
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
|
|||||||
<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);
|
|||||||
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>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.1.2.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgarchivecleanup">
|
<sect1 id="pgarchivecleanup">
|
||||||
<title>pg_archivecleanup</title>
|
<title>pg_archivecleanup</title>
|
||||||
@ -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'
|
|||||||
</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,7 +66,6 @@ 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
|
||||||
|
|
||||||
@ -78,7 +73,6 @@ 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"
|
|||||||
<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.
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.16.2.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgbench">
|
<sect1 id="pgbench">
|
||||||
<title>pgbench</title>
|
<title>pgbench</title>
|
||||||
@ -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
|
|||||||
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
|
||||||
@ -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.
|
||||||
@ -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;
|
|||||||
|
|
||||||
<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>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.6.6.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgbuffercache">
|
<sect1 id="pgbuffercache">
|
||||||
<title>pg_buffercache</title>
|
<title>pg_buffercache</title>
|
||||||
@ -134,7 +134,7 @@
|
|||||||
<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
|
||||||
@ -143,6 +143,7 @@
|
|||||||
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
|
||||||
@ -156,7 +157,7 @@
|
|||||||
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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.9.2.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgcrypto">
|
<sect1 id="pgcrypto">
|
||||||
<title>pgcrypto</title>
|
<title>pgcrypto</title>
|
||||||
@ -37,12 +37,12 @@
|
|||||||
<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>
|
||||||
@ -176,17 +176,15 @@
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Example of setting a new password:
|
Example of setting a new password:
|
||||||
</para>
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
UPDATE ... SET pswhash = crypt('new password', gen_salt('md5'));
|
UPDATE ... SET pswhash = crypt('new password', gen_salt('md5'));
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
<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>
|
||||||
@ -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:
|
||||||
</para>
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
pgp_sym_encrypt(data, psw, 'compress-algo=1, cipher-algo=aes256')
|
pgp_sym_encrypt(data, psw, 'compress-algo=1, cipher-algo=aes256')
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
|
|
||||||
<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 @@
|
|||||||
<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 @@
|
|||||||
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 @@
|
|||||||
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 @@
|
|||||||
<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 @@
|
|||||||
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 @@
|
|||||||
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 @@
|
|||||||
<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 @@
|
|||||||
<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 @@
|
|||||||
<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 @@
|
|||||||
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 @@
|
|||||||
|
|
||||||
<para>
|
<para>
|
||||||
To generate a new key:
|
To generate a new key:
|
||||||
</para>
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
gpg --gen-key
|
gpg --gen-key
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
<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 @@
|
|||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
To list keys:
|
To list keys:
|
||||||
</para>
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
gpg --list-secret-keys
|
gpg --list-secret-keys
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
<para>
|
<para>
|
||||||
To export a public key in ascii-armor format:
|
To export a public key in ascii-armor format:
|
||||||
</para>
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
gpg -a --export KEYID > public.key
|
gpg -a --export KEYID > public.key
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
<para>
|
<para>
|
||||||
To export a secret key in ascii-armor format:
|
To export a secret key in ascii-armor format:
|
||||||
</para>
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
gpg -a --export-secret-keys KEYID > secret.key
|
gpg -a --export-secret-keys KEYID > secret.key
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
<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
|
||||||
@ -917,22 +915,17 @@
|
|||||||
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>
|
<synopsis>
|
||||||
<replaceable>algorithm</> <optional> <literal>-</> <replaceable>mode</> </optional> <optional> <literal>/pad:</> <replaceable>padding</> </optional>
|
<replaceable>algorithm</> <optional> <literal>-</> <replaceable>mode</> </optional> <optional> <literal>/pad:</> <replaceable>padding</> </optional>
|
||||||
</synopsis>
|
</synopsis>
|
||||||
|
|
||||||
<para>
|
|
||||||
where <replaceable>algorithm</> is one of:
|
where <replaceable>algorithm</> is one of:
|
||||||
</para>
|
|
||||||
<itemizedlist>
|
<itemizedlist>
|
||||||
<listitem><para><literal>bf</literal> — Blowfish</para></listitem>
|
<listitem><para><literal>bf</literal> — Blowfish</para></listitem>
|
||||||
<listitem><para><literal>aes</literal> — AES (Rijndael-128)</para></listitem>
|
<listitem><para><literal>aes</literal> — 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 @@
|
|||||||
</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 @@
|
|||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</itemizedlist>
|
</itemizedlist>
|
||||||
|
</para>
|
||||||
<para>
|
<para>
|
||||||
So, for example, these are equivalent:
|
So, for example, these are equivalent:
|
||||||
</para>
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
encrypt(data, 'fooz', 'bf')
|
encrypt(data, 'fooz', 'bf')
|
||||||
encrypt(data, 'fooz', 'bf-cbc/pad:pkcs')
|
encrypt(data, 'fooz', 'bf-cbc/pad:pkcs')
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
<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;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.6.2.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgfreespacemap">
|
<sect1 id="pgfreespacemap">
|
||||||
<title>pg_freespacemap</title>
|
<title>pg_freespacemap</title>
|
||||||
@ -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);
|
|||||||
--------------
|
--------------
|
||||||
1216
|
1216
|
||||||
(1 row)
|
(1 row)
|
||||||
|
</screen>
|
||||||
</programlisting>
|
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
<sect2>
|
<sect2>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.5.14.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgrowlocks">
|
<sect1 id="pgrowlocks">
|
||||||
<title>pgrowlocks</title>
|
<title>pgrowlocks</title>
|
||||||
@ -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');
|
|||||||
(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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.11.2.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgstandby">
|
<sect1 id="pgstandby">
|
||||||
<title>pg_standby</title>
|
<title>pg_standby</title>
|
||||||
@ -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,7 +231,7 @@ 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'
|
||||||
@ -244,12 +240,10 @@ restore_command = 'pg_standby -d -s 2 -t /tmp/pgsql.trigger.5442 .../archive %f
|
|||||||
|
|
||||||
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,8 +273,9 @@ 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'
|
||||||
@ -289,12 +284,10 @@ restore_command = 'pg_standby -d -s 5 -t C:\pgsql.trigger.5442 ...\archive %f %p
|
|||||||
|
|
||||||
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'
|
|||||||
</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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.6.6.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgstatstatements">
|
<sect1 id="pgstatstatements">
|
||||||
<title>pg_stat_statements</title>
|
<title>pg_stat_statements</title>
|
||||||
@ -279,7 +279,6 @@
|
|||||||
<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
|
||||||
@ -289,12 +288,13 @@ 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
|
|||||||
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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.5.14.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgstattuple">
|
<sect1 id="pgstattuple">
|
||||||
<title>pgstattuple</title>
|
<title>pgstattuple</title>
|
||||||
@ -141,7 +141,6 @@ 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 ]------+------
|
||||||
@ -156,6 +155,7 @@ 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:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.2.16.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="pgtrgm">
|
<sect1 id="pgtrgm">
|
||||||
<title>pg_trgm</title>
|
<title>pg_trgm</title>
|
||||||
@ -149,14 +149,12 @@ CREATE INDEX trgm_idx ON test_trgm USING gin (t gin_trgm_ops);
|
|||||||
<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
|
|||||||
<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
|
|||||||
|
|
||||||
<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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.86.2.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="plperl">
|
<chapter id="plperl">
|
||||||
<title>PL/Perl - Perl Procedural Language</title>
|
<title>PL/Perl - Perl Procedural Language</title>
|
||||||
@ -530,9 +530,6 @@ $plan = spi_prepare('SELECT * FROM test WHERE id > $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>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<programlisting>
|
<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',
|
||||||
@ -559,9 +556,6 @@ SELECT done();
|
|||||||
------------+------------+------------
|
------------+------------+------------
|
||||||
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,9 +563,6 @@ 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>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
<programlisting>
|
<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;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.154.2.1 2010/07/27 20:02:17 rhaas Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.154.2.2 2010/07/29 19:34:37 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>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$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.25.2.1 2010/07/29 19:34:37 petere Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$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.25.2.1 2010/07/29 19:34:37 petere Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$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.8.2.1 2010/07/29 19:34:37 petere Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$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.74.2.1 2010/07/29 19:34:37 petere Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$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.83.2.1 2010/07/29 19:34:37 petere Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -492,7 +492,7 @@ 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
|
||||||
|
|
||||||
@ -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:
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.7.2.1 2010/07/29 19:34:37 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">
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.1.24.1 2010/07/29 19:34:37 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">
|
||||||
@ -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.
|
|||||||
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>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.6.8.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="seg">
|
<sect1 id="seg">
|
||||||
<title>seg</title>
|
<title>seg</title>
|
||||||
@ -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";
|
|||||||
<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";
|
|||||||
<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] << [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] << [c, d] is true if b < c and false otherwise
|
</row>
|
||||||
</para>
|
</thead>
|
||||||
</listitem>
|
|
||||||
<listitem>
|
<tbody>
|
||||||
<programlisting>
|
<row>
|
||||||
[a, b] >> [c, d] Is right of
|
<entry><literal>[a, b] << [c, d]</literal></entry>
|
||||||
</programlisting>
|
<entry>[a, b] is entirely to the left of [c, d]. That is, [a,
|
||||||
<para>
|
b] << [c, d] is true if b < c and false otherwise.</entry>
|
||||||
[a, b] is entirely to the right of [c, d]. That is,
|
</row>
|
||||||
[a, b] >> [c, d] is true if a > d and false otherwise
|
|
||||||
</para>
|
<row>
|
||||||
</listitem>
|
<entry><literal>[a, b] >> [c, d]</literal></entry>
|
||||||
<listitem>
|
<entry>[a, b] is entirely to the right of [c, d]. That is, [a,
|
||||||
<programlisting>
|
b] >> [c, d] is true if a > d and false otherwise.</entry>
|
||||||
[a, b] &< [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] &< [c, d]</literal></entry>
|
||||||
It is true when b <= d.
|
<entry>Overlaps or is left of — This might be better read
|
||||||
</para>
|
as <quote>does not extend to right of</quote>. It is true when
|
||||||
</listitem>
|
b <= d.</entry>
|
||||||
<listitem>
|
</row>
|
||||||
<programlisting>
|
|
||||||
[a, b] &> [c, d] Overlaps or is right of
|
<row>
|
||||||
</programlisting>
|
<entry><literal>[a, b] &> [c, d]</literal></entry>
|
||||||
<para>
|
<entry>Overlaps or is right of — 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 >= c.
|
a >= 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 — 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] && [c, d]</literal></entry>
|
||||||
<listitem>
|
<entry>The segments [a, b] and [c, d] overlap.</entry>
|
||||||
<programlisting>
|
</row>
|
||||||
[a, b] && [c, d] Overlaps
|
|
||||||
</programlisting>
|
<row>
|
||||||
<para>
|
<entry><literal>[a, b] @> [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 <= c and b >= d.</entry>
|
||||||
</listitem>
|
</row>
|
||||||
<listitem>
|
|
||||||
<programlisting>
|
<row>
|
||||||
[a, b] @> [c, d] Contains
|
<entry><literal>[a, b] <@ [c, d]</literal></entry>
|
||||||
</programlisting>
|
<entry>The segment [a, b] is contained in [c, d], that is, a
|
||||||
<para>
|
>= c and b <= d.</entry>
|
||||||
The segment [a, b] contains the segment [c, d], that is,
|
</row>
|
||||||
a <= c and b >= d
|
</tbody>
|
||||||
</para>
|
</tgroup>
|
||||||
</listitem>
|
</table>
|
||||||
<listitem>
|
|
||||||
<programlisting>
|
|
||||||
[a, b] <@ [c, d] Contained in
|
|
||||||
</programlisting>
|
|
||||||
<para>
|
|
||||||
The segment [a, b] is contained in [c, d], that is,
|
|
||||||
a >= c and b <= d
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</itemizedlist>
|
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
(Before PostgreSQL 8.2, the containment operators @> and <@ were
|
(Before PostgreSQL 8.2, the containment operators <literal>@></> and <literal><@</> 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";
|
|||||||
<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] < [c, d] Less than
|
<tgroup cols="2">
|
||||||
[a, b] > [c, d] Greater than
|
<thead>
|
||||||
</programlisting>
|
<row>
|
||||||
|
<entry>Operator</entry>
|
||||||
|
<entry>Description</entry>
|
||||||
|
</row>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
<tbody>
|
||||||
|
<row>
|
||||||
|
<entry><literal>[a, b] < [c, d]</literal></entry>
|
||||||
|
<entry>Less than</entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry><literal>[a, b] > [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";
|
|||||||
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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.48.14.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="sql-intro">
|
<chapter id="sql-intro">
|
||||||
<title>SQL</title>
|
<title>SQL</title>
|
||||||
@ -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
|
|||||||
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
|
|||||||
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:
|
|||||||
<classname>R</classname> × <classname>S</classname> and
|
<classname>R</classname> × <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:
|
|||||||
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:
|
|||||||
σ<subscript>R.C=S.C</subscript>(R × S)
|
σ<subscript>R.C=S.C</subscript>(R × 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:
|
|||||||
π<subscript>R.A,R.B,R.C,S.D,S.E</subscript>(σ<subscript>R.C=S.C</subscript>(R × S))
|
π<subscript>R.A,R.B,R.C,S.D,S.E</subscript>(σ<subscript>R.C=S.C</subscript>(R × 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>
|
||||||
|
|
||||||
@ -615,7 +615,7 @@ t<subscript>r</subscript>(A,B)=t∧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:
|
|||||||
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 ÷ S
|
R ÷ 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>
|
||||||
@ -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>
|
||||||
@ -893,12 +893,12 @@ SELECT * FROM PART
|
|||||||
|
|
||||||
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>
|
||||||
@ -915,12 +915,12 @@ SELECT PNAME, PRICE
|
|||||||
|
|
||||||
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
|
||||||
@ -941,11 +941,11 @@ SELECT PNAME, PRICE
|
|||||||
|
|
||||||
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>
|
||||||
@ -961,13 +961,13 @@ SELECT PNAME, PRICE * 2 AS DOUBLE
|
|||||||
|
|
||||||
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
|
||||||
@ -1001,7 +1001,7 @@ SELECT S.SNAME, P.PNAME
|
|||||||
|
|
||||||
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
|
|||||||
Blake | Nut
|
Blake | Nut
|
||||||
Blake | Bolt
|
Blake | Bolt
|
||||||
Blake | Cam
|
Blake | Cam
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1035,12 +1035,12 @@ 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
|
|||||||
Jones | Cam
|
Jones | Cam
|
||||||
Blake | Cam
|
Blake | Cam
|
||||||
(8 rows)
|
(8 rows)
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1276,11 +1276,11 @@ SELECT AVG(PRICE) AS AVG_PRICE
|
|||||||
<para>
|
<para>
|
||||||
The result is:
|
The result is:
|
||||||
|
|
||||||
<programlisting>
|
<screen>
|
||||||
AVG_PRICE
|
AVG_PRICE
|
||||||
-----------
|
-----------
|
||||||
14.5
|
14.5
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1294,11 +1294,11 @@ SELECT COUNT(PNO)
|
|||||||
|
|
||||||
and get:
|
and get:
|
||||||
|
|
||||||
<programlisting>
|
<screen>
|
||||||
COUNT
|
COUNT
|
||||||
-------
|
-------
|
||||||
4
|
4
|
||||||
</programlisting>
|
</screen>
|
||||||
|
|
||||||
</para>
|
</para>
|
||||||
</example>
|
</example>
|
||||||
@ -1344,14 +1344,14 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
|
|||||||
|
|
||||||
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)
|
|||||||
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)
|
|||||||
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)
|
|||||||
4 | Blake | 2
|
4 | Blake | 2
|
||||||
| 3
|
| 3
|
||||||
| 4
|
| 4
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1452,13 +1452,13 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
|
|||||||
|
|
||||||
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>
|
||||||
@ -1492,12 +1492,12 @@ SELECT *
|
|||||||
<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>
|
||||||
@ -1600,12 +1600,12 @@ UNION
|
|||||||
|
|
||||||
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>
|
||||||
@ -1623,11 +1623,11 @@ INTERSECT
|
|||||||
|
|
||||||
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>
|
||||||
@ -1647,12 +1647,12 @@ EXCEPT
|
|||||||
|
|
||||||
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>
|
||||||
@ -1896,11 +1896,11 @@ SELECT * FROM London_Suppliers
|
|||||||
|
|
||||||
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>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/sslinfo.sgml,v 1.3 2007/12/06 04:12:10 tgl Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/sslinfo.sgml,v 1.3.16.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="sslinfo">
|
<sect1 id="sslinfo">
|
||||||
<title>sslinfo</title>
|
<title>sslinfo</title>
|
||||||
@ -123,7 +123,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
|
||||||
@ -145,7 +145,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
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* $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.9.10.1 2010/07/29 19:34:37 petere Exp $ */
|
||||||
|
|
||||||
/* color scheme similar to www.postgresql.org */
|
/* color scheme similar to www.postgresql.org */
|
||||||
|
|
||||||
@ -85,7 +85,7 @@ DIV.EXAMPLE {
|
|||||||
|
|
||||||
/* miscellaneous */
|
/* miscellaneous */
|
||||||
|
|
||||||
.SCREEN, .SYNOPSIS, .PROGRAMLISTING {
|
PRE.LITERALLAYOUT, .SCREEN, .SYNOPSIS, .PROGRAMLISTING {
|
||||||
margin-left: 4ex;
|
margin-left: 4ex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.4.16.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="tablefunc">
|
<sect1 id="tablefunc">
|
||||||
<title>tablefunc</title>
|
<title>tablefunc</title>
|
||||||
@ -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
|
|||||||
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,16 +131,16 @@ 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</>
|
||||||
@ -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 ...
|
|||||||
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>
|
<programlisting>
|
||||||
SELECT * FROM crosstab('...') AS ct(row_name text, category_1 text, category_2 text);
|
SELECT * FROM crosstab('...') AS ct(row_name text, category_1 text, category_2 text);
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
<para>
|
|
||||||
This example produces a set something like:
|
This example produces a set something like:
|
||||||
</para>
|
|
||||||
|
|
||||||
<programlisting>
|
<programlisting>
|
||||||
<== value columns ==>
|
<== value columns ==>
|
||||||
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,8 +244,6 @@ 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');
|
||||||
@ -277,6 +269,7 @@ AS ct(row_name text, category_1 text, category_2 text, category_3 text);
|
|||||||
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);
|
|||||||
<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
|
||||||
@ -327,8 +320,6 @@ 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(
|
||||||
@ -337,13 +328,13 @@ FROM crosstab3(
|
|||||||
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,8 +346,6 @@ 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>
|
<programlisting>
|
||||||
CREATE TYPE my_crosstab_float8_5_cols AS (
|
CREATE TYPE my_crosstab_float8_5_cols AS (
|
||||||
my_row_name text,
|
my_row_name text,
|
||||||
@ -371,16 +360,16 @@ FROM crosstab3(
|
|||||||
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>
|
<programlisting>
|
||||||
CREATE OR REPLACE FUNCTION crosstab_float8_5_cols(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,
|
||||||
@ -390,17 +379,19 @@ FROM crosstab3(
|
|||||||
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,7 +423,6 @@ 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;
|
||||||
|
|
||||||
@ -446,6 +436,7 @@ crosstab(text source_sql, text category_sql)
|
|||||||
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,7 +444,6 @@ 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;
|
||||||
@ -464,23 +454,22 @@ SELECT DISTINCT cat FROM foo ORDER BY 1;
|
|||||||
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>
|
||||||
<== value columns ==>
|
<== value columns ==>
|
||||||
row_name extra cat1 cat2 cat3 cat4
|
row_name extra cat1 cat2 cat3 cat4
|
||||||
@ -488,6 +477,7 @@ SELECT DISTINCT cat FROM foo ORDER BY 1;
|
|||||||
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,8 +517,6 @@ 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);
|
||||||
@ -593,6 +581,7 @@ AS
|
|||||||
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
|
|||||||
<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
|
||||||
@ -731,8 +720,6 @@ 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);
|
||||||
|
|
||||||
@ -798,6 +785,7 @@ SELECT * FROM connectby('connectby_tree', 'keyid', 'parent_keyid', 'pos', 'row2'
|
|||||||
row8 | row6 | 3 | 6
|
row8 | row6 | 3 | 6
|
||||||
(6 rows)
|
(6 rows)
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
</sect3>
|
</sect3>
|
||||||
|
|
||||||
</sect2>
|
</sect2>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.56.2.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<chapter id="textsearch">
|
<chapter id="textsearch">
|
||||||
<title>Full Text Search</title>
|
<title>Full Text Search</title>
|
||||||
@ -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>
|
||||||
@ -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 & Fat & Rats');
|
SELECT to_tsquery('english', 'The & Fat & Rats');
|
||||||
to_tsquery
|
to_tsquery
|
||||||
---------------
|
---------------
|
||||||
'fat' & 'rat'
|
'fat' & '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 & star:A*B');
|
SELECT to_tsquery('supern:*A & star:A*B');
|
||||||
to_tsquery
|
to_tsquery
|
||||||
--------------------------
|
--------------------------
|
||||||
'supern':*A & 'star':*AB
|
'supern':*A & '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 & 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'' & !crab');
|
SELECT to_tsquery('''supernovae stars'' & !crab');
|
||||||
to_tsquery
|
to_tsquery
|
||||||
---------------
|
---------------
|
||||||
'sn' & !'crab'
|
'sn' & !'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.
|
||||||
@ -806,23 +806,23 @@ SELECT to_tsquery('''supernovae stars'' & !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' & 'rat'
|
'fat' & '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 & Rats:C');
|
SELECT plainto_tsquery('english', 'The Fat & Rats:C');
|
||||||
plainto_tsquery
|
plainto_tsquery
|
||||||
---------------------
|
---------------------
|
||||||
'fat' & 'rat' & 'c'
|
'fat' & 'rat' & '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>
|
||||||
@ -913,9 +913,9 @@ SELECT plainto_tsquery('english', 'The Fat & 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 & 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 & matter)') query
|
FROM apod, to_tsquery('neutrino|(dark & matter)') query
|
||||||
WHERE query @@ textsearch
|
WHERE query @@ textsearch
|
||||||
@ -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 & matter)') query
|
FROM apod, to_tsquery('neutrino|(dark & matter)') query
|
||||||
WHERE query @@ textsearch
|
WHERE query @@ textsearch
|
||||||
@ -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>
|
||||||
@ -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.',
|
|||||||
containing given <query> terms
|
containing given <query> terms
|
||||||
and return them in order of their <similarity> to the
|
and return them in order of their <similarity> to the
|
||||||
<query>.
|
<query>.
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1417,7 +1417,7 @@ FROM (SELECT id, body, q, ts_rank_cd(ti, q) AS rank
|
|||||||
(returns > 0), or contains only stop words (returns 0).
|
(returns > 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 & bar'::tsquery);
|
|||||||
numnode
|
numnode
|
||||||
---------
|
---------
|
||||||
3
|
3
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -1452,12 +1452,12 @@ SELECT numnode('foo & 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>
|
||||||
@ -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 & b'::tsquery, 'a'::tsquery, 'c'::tsquery);
|
SELECT ts_rewrite('a & b'::tsquery, 'a'::tsquery, 'c'::tsquery);
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
------------
|
------------
|
||||||
'b' & 'c'
|
'b' & 'c'
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
@ -1536,7 +1536,7 @@ SELECT ts_rewrite('a & 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 & b'::tsquery, 'SELECT t,s FROM aliases');
|
|||||||
ts_rewrite
|
ts_rewrite
|
||||||
------------
|
------------
|
||||||
'b' & 'c'
|
'b' & 'c'
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1561,7 +1561,7 @@ SELECT ts_rewrite('a & 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 & crab'), 'SELECT * FROM aliases');
|
|||||||
ts_rewrite
|
ts_rewrite
|
||||||
---------------------------------
|
---------------------------------
|
||||||
'crab' & ( 'supernova' | 'sn' )
|
'crab' & ( '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 & !nebulae')
|
SET s = to_tsquery('supernovae|sn & !nebulae')
|
||||||
WHERE t = to_tsquery('supernovae');
|
WHERE t = to_tsquery('supernovae');
|
||||||
@ -1582,7 +1582,7 @@ SELECT ts_rewrite(to_tsquery('supernovae & crab'), 'SELECT * FROM aliases');
|
|||||||
ts_rewrite
|
ts_rewrite
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
'crab' & ( 'supernova' | 'sn' & !'nebula' )
|
'crab' & ( 'supernova' | 'sn' & !'nebula' )
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -1592,13 +1592,13 @@ SELECT ts_rewrite(to_tsquery('supernovae & 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 & b'::tsquery,
|
SELECT ts_rewrite('a & b'::tsquery,
|
||||||
'SELECT t,s FROM aliases WHERE ''a & b''::tsquery @> t');
|
'SELECT t,s FROM aliases WHERE ''a & b''::tsquery @> t');
|
||||||
ts_rewrite
|
ts_rewrite
|
||||||
------------
|
------------
|
||||||
'b' & 'c'
|
'b' & 'c'
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</sect3>
|
</sect3>
|
||||||
@ -1632,7 +1632,7 @@ SELECT ts_rewrite('a & 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 & 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
|
||||||
@ -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');
|
|||||||
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
|
|||||||
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
|
|||||||
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 & stop'));
|
SELECT ts_rank_cd (to_tsvector('english','in the list of stop words'), to_tsquery('list & 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
|
|||||||
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 (
|
|||||||
<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');
|
|||||||
ts_lexize
|
ts_lexize
|
||||||
-----------
|
-----------
|
||||||
{}
|
{}
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -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');
|
|||||||
ts_lexize
|
ts_lexize
|
||||||
-----------
|
-----------
|
||||||
{}
|
{}
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@ -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');
|
|||||||
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');
|
|||||||
|
|
||||||
<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
|
|||||||
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
|
|||||||
<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');
|
|||||||
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''');
|
|||||||
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' & 'supernova' & 'star'
|
'sn' & 'supernova' & 'star'
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</sect3>
|
</sect3>
|
||||||
@ -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>
|
||||||
=> \dF
|
=> \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;
|
|||||||
default_text_search_config
|
default_text_search_config
|
||||||
----------------------------
|
----------------------------
|
||||||
public.pg
|
public.pg
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
</sect1>
|
</sect1>
|
||||||
@ -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');
|
|||||||
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
|
|||||||
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');
|
|||||||
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');
|
|||||||
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');
|
|||||||
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>
|
||||||
@ -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,7 +3068,7 @@ SELECT * FROM ts_parse('default', '123 - a number');
|
|||||||
1 | a
|
1 | a
|
||||||
12 |
|
12 |
|
||||||
1 | number
|
1 | number
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<indexterm>
|
<indexterm>
|
||||||
@ -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');
|
|||||||
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>
|
||||||
@ -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');
|
|||||||
ts_lexize
|
ts_lexize
|
||||||
-----------
|
-----------
|
||||||
{}
|
{}
|
||||||
</programlisting>
|
</screen>
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<note>
|
<note>
|
||||||
@ -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;
|
|||||||
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>
|
||||||
|
|
||||||
@ -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>
|
||||||
=> \dF *fulltext*
|
=> \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>
|
||||||
=> \dF *.fulltext*
|
=> \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>
|
|
||||||
=> \dF russian
|
=> \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"
|
|||||||
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"
|
|||||||
<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>
|
|
||||||
=> \dFd
|
=> \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"
|
|||||||
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>
|
|
||||||
=> \dFp
|
=> \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"
|
|||||||
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>
|
|
||||||
=> \dFt
|
=> \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"
|
|||||||
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>
|
||||||
|
@ -134,8 +134,7 @@
|
|||||||
</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>
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.2.16.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="uuid-ossp">
|
<sect1 id="uuid-ossp">
|
||||||
<title>uuid-ossp</title>
|
<title>uuid-ossp</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.4.14.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="vacuumlo">
|
<sect1 id="vacuumlo">
|
||||||
<title>vacuumlo</title>
|
<title>vacuumlo</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $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.40.2.1 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="xaggr">
|
<sect1 id="xaggr">
|
||||||
<title>User-Defined Aggregates</title>
|
<title>User-Defined Aggregates</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.149.2.2 2010/07/26 20:14:06 petere Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.149.2.3 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="xfunc">
|
<sect1 id="xfunc">
|
||||||
<title>User-Defined Functions</title>
|
<title>User-Defined Functions</title>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<!-- $PostgreSQL: pgsql/doc/src/sgml/xml2.sgml,v 1.7.14.1 2010/07/27 19:01:04 petere Exp $ -->
|
<!-- $PostgreSQL: pgsql/doc/src/sgml/xml2.sgml,v 1.7.14.2 2010/07/29 19:34:37 petere Exp $ -->
|
||||||
|
|
||||||
<sect1 id="xml2">
|
<sect1 id="xml2">
|
||||||
<title>xml2</title>
|
<title>xml2</title>
|
||||||
@ -84,14 +84,12 @@
|
|||||||
<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>
|
|
||||||
<toptag>
|
<toptag>
|
||||||
<itemtag>Value 1 which could be an XML fragment</itemtag>
|
<itemtag>Value 1 which could be an XML fragment</itemtag>
|
||||||
<itemtag>Value 2....</itemtag>
|
<itemtag>Value 2....</itemtag>
|
||||||
</toptag>
|
</toptag>
|
||||||
</literal>
|
</synopsis>
|
||||||
<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>
|
||||||
@ -240,8 +238,6 @@
|
|||||||
<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',
|
||||||
@ -251,8 +247,6 @@ xpath_table('article_id',
|
|||||||
'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,8 +272,6 @@ 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',
|
||||||
@ -289,8 +281,6 @@ FROM xpath_table('article_id', 'article_xml', 'articles',
|
|||||||
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,13 +304,11 @@ 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, '<doc num="C1">
|
INSERT INTO test VALUES (1, '<doc num="C1">
|
||||||
@ -337,7 +325,7 @@ WHERE t.author_id = p.person_id;
|
|||||||
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
|
||||||
@ -345,20 +333,20 @@ WHERE t.author_id = p.person_id;
|
|||||||
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;
|
||||||
|
|
||||||
@ -368,6 +356,7 @@ WHERE t.author_id = p.person_id;
|
|||||||
1 | L2 | 11 | 22 | 33 | C1
|
1 | L2 | 11 | 22 | 33 | C1
|
||||||
(2 rows)
|
(2 rows)
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
</para>
|
||||||
</sect3>
|
</sect3>
|
||||||
</sect2>
|
</sect2>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user