More < and > cleanups converted to ampersands.

This commit is contained in:
Bruce Momjian 2005-01-22 22:56:36 +00:00
parent 9e292e3e48
commit 1ced129aa3
22 changed files with 158 additions and 158 deletions

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.54 2004/12/28 19:08:58 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.55 2005/01/22 22:56:35 momjian Exp $
--> -->
<chapter id="backup"> <chapter id="backup">
<title>Backup and Restore</title> <title>Backup and Restore</title>
@ -256,7 +256,7 @@ cat <replaceable class="parameter">filename</replaceable>* | psql <replaceable c
following command dumps a database using the custom dump format: following command dumps a database using the custom dump format:
<programlisting> <programlisting>
pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceable class="parameter">filename</replaceable> pg_dump -Fc <replaceable class="parameter">dbname</replaceable> &gt; <replaceable class="parameter">filename</replaceable>
</programlisting> </programlisting>
A custom-format dump is not a script for <application>psql</>, but A custom-format dump is not a script for <application>psql</>, but
@ -1203,14 +1203,14 @@ pg_dumpall -p 5432 | psql -d template1 -p 6543
version, start the new server, restore the data. For example: version, start the new server, restore the data. For example:
<programlisting> <programlisting>
pg_dumpall > backup pg_dumpall &gt; backup
pg_ctl stop pg_ctl stop
mv /usr/local/pgsql /usr/local/pgsql.old mv /usr/local/pgsql /usr/local/pgsql.old
cd ~/postgresql-&version; cd ~/postgresql-&version;
gmake install gmake install
initdb -D /usr/local/pgsql/data initdb -D /usr/local/pgsql/data
postmaster -D /usr/local/pgsql/data postmaster -D /usr/local/pgsql/data
psql template1 < backup psql template1 &lt; backup
</programlisting> </programlisting>
See <xref linkend="runtime"> about ways to start and stop the See <xref linkend="runtime"> about ways to start and stop the

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.154 2005/01/17 18:47:15 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.155 2005/01/22 22:56:35 momjian Exp $
--> -->
<chapter id="datatype"> <chapter id="datatype">
@ -1645,7 +1645,7 @@ SELECT b, char_length(b) FROM test2;
</row> </row>
<row> <row>
<entry><literal>04:05 PM</literal></entry> <entry><literal>04:05 PM</literal></entry>
<entry>same as 16:05; input hour must be <= 12</entry> <entry>same as 16:05; input hour must be &lt;= 12</entry>
</row> </row>
<row> <row>
<entry><literal>04:05:06.789-8</literal></entry> <entry><literal>04:05:06.789-8</literal></entry>
@ -2367,7 +2367,7 @@ SELECT * FROM test1 WHERE a;
<entry><type>circle</type></entry> <entry><type>circle</type></entry>
<entry>24 bytes</entry> <entry>24 bytes</entry>
<entry>Circle</entry> <entry>Circle</entry>
<entry><(x,y),r> (center and radius)</entry> <entry>&lt;(x,y),r&gt; (center and radius)</entry>
</row> </row>
</tbody> </tbody>
</tgroup> </tgroup>

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.38 2005/01/17 01:29:02 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.39 2005/01/22 22:56:35 momjian Exp $ -->
<chapter id="ddl"> <chapter id="ddl">
<title>Data Definition</title> <title>Data Definition</title>
@ -275,7 +275,7 @@ CREATE TABLE products (
CREATE TABLE products ( CREATE TABLE products (
product_no integer, product_no integer,
name text, name text,
price numeric <emphasis>CHECK (price > 0)</emphasis> price numeric <emphasis>CHECK (price &gt; 0)</emphasis>
); );
</programlisting> </programlisting>
</para> </para>
@ -303,7 +303,7 @@ CREATE TABLE products (
CREATE TABLE products ( CREATE TABLE products (
product_no integer, product_no integer,
name text, name text,
price numeric <emphasis>CONSTRAINT positive_price</emphasis> CHECK (price > 0) price numeric <emphasis>CONSTRAINT positive_price</emphasis> CHECK (price &gt; 0)
); );
</programlisting> </programlisting>
So, to specify a named constraint, use the key word So, to specify a named constraint, use the key word
@ -320,9 +320,9 @@ CREATE TABLE products (
CREATE TABLE products ( CREATE TABLE products (
product_no integer, product_no integer,
name text, name text,
price numeric CHECK (price > 0), price numeric CHECK (price &gt; 0),
discounted_price numeric CHECK (discounted_price > 0), discounted_price numeric CHECK (discounted_price &gt; 0),
<emphasis>CHECK (price > discounted_price)</emphasis> <emphasis>CHECK (price &gt; discounted_price)</emphasis>
); );
</programlisting> </programlisting>
</para> </para>
@ -350,10 +350,10 @@ CREATE TABLE products (
product_no integer, product_no integer,
name text, name text,
price numeric, price numeric,
CHECK (price > 0), CHECK (price &gt; 0),
discounted_price numeric, discounted_price numeric,
CHECK (discounted_price > 0), CHECK (discounted_price &gt; 0),
CHECK (price > discounted_price) CHECK (price &gt; discounted_price)
); );
</programlisting> </programlisting>
or even or even
@ -361,9 +361,9 @@ CREATE TABLE products (
CREATE TABLE products ( CREATE TABLE products (
product_no integer, product_no integer,
name text, name text,
price numeric CHECK (price > 0), price numeric CHECK (price &gt; 0),
discounted_price numeric, discounted_price numeric,
CHECK (discounted_price > 0 AND price > discounted_price) CHECK (discounted_price &gt; 0 AND price &gt; discounted_price)
); );
</programlisting> </programlisting>
It's a matter of taste. It's a matter of taste.
@ -377,10 +377,10 @@ CREATE TABLE products (
product_no integer, product_no integer,
name text, name text,
price numeric, price numeric,
CHECK (price > 0), CHECK (price &gt; 0),
discounted_price numeric, discounted_price numeric,
CHECK (discounted_price > 0), CHECK (discounted_price &gt; 0),
<emphasis>CONSTRAINT valid_discount</> CHECK (price > discounted_price) <emphasis>CONSTRAINT valid_discount</> CHECK (price &gt; discounted_price)
); );
</programlisting> </programlisting>
</para> </para>
@ -442,7 +442,7 @@ CREATE TABLE products (
CREATE TABLE products ( CREATE TABLE products (
product_no integer NOT NULL, product_no integer NOT NULL,
name text NOT NULL, name text NOT NULL,
price numeric NOT NULL CHECK (price > 0) price numeric NOT NULL CHECK (price &gt; 0)
); );
</programlisting> </programlisting>
The order doesn't matter. It does not necessarily determine in which The order doesn't matter. It does not necessarily determine in which

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/dfunc.sgml,v 1.28 2004/11/15 06:32:13 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/dfunc.sgml,v 1.29 2005/01/22 22:56:35 momjian Exp $
--> -->
<sect2 id="dfunc"> <sect2 id="dfunc">
@ -307,7 +307,7 @@ cc <other flags> -c foo.c
You must then create a symbol \*(lqexports\*(rq file for the object You must then create a symbol \*(lqexports\*(rq file for the object
file: file:
.nf .nf
mkldexport foo.o `pwd` > foo.exp mkldexport foo.o `pwd` &gt; foo.exp
.fi .fi
Finally, you can create the shared library: Finally, you can create the shared library:
.nf .nf

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/dml.sgml,v 1.9 2004/12/23 05:37:39 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/dml.sgml,v 1.10 2005/01/22 22:56:35 momjian Exp $ -->
<chapter id="dml"> <chapter id="dml">
<title>Data Manipulation</title> <title>Data Manipulation</title>
@ -191,7 +191,7 @@ UPDATE products SET price = price * 1.10;
<literal>UPDATE</literal> command by listing more than one <literal>UPDATE</literal> command by listing more than one
assignment in the <literal>SET</literal> clause. For example: assignment in the <literal>SET</literal> clause. For example:
<programlisting> <programlisting>
UPDATE mytable SET a = 5, b = 3, c = 1 WHERE a > 0; UPDATE mytable SET a = 5, b = 3, c = 1 WHERE a &gt; 0;
</programlisting> </programlisting>
</para> </para>
</sect1> </sect1>

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/ecpg.sgml,v 1.62 2005/01/08 22:13:25 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/ecpg.sgml,v 1.63 2005/01/22 22:56:35 momjian Exp $
--> -->
<chapter id="ecpg"> <chapter id="ecpg">
@ -627,7 +627,7 @@ EXEC SQL EXECUTE mystmt USING 42, 'foobar';
<literal>INTO</literal> clause: <literal>INTO</literal> clause:
<programlisting> <programlisting>
EXEC SQL BEGIN DECLARE SECTION; EXEC SQL BEGIN DECLARE SECTION;
const char *stmt = "SELECT a, b, c FROM test1 WHERE a > ?"; const char *stmt = "SELECT a, b, c FROM test1 WHERE a &gt; ?";
int v1, v2; int v1, v2;
VARCHAR v3; VARCHAR v3;
EXEC SQL END DECLARE SECTION; EXEC SQL END DECLARE SECTION;

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.234 2005/01/09 20:08:50 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.235 2005/01/22 22:56:35 momjian Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
@ -5890,7 +5890,7 @@ SELECT TIMESTAMP 'now';
<row> <row>
<entry> <literal>&gt;^</literal> </entry> <entry> <literal>&gt;^</literal> </entry>
<entry>Is above?</entry> <entry>Is above?</entry>
<entry><literal>circle '((0,5),1)' >^ circle '((0,0),1)'</literal></entry> <entry><literal>circle '((0,5),1)' &gt;^ circle '((0,0),1)'</literal></entry>
</row> </row>
<row> <row>
<entry> <literal>?#</literal> </entry> <entry> <literal>?#</literal> </entry>

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/geqo.sgml,v 1.27 2005/01/05 23:42:03 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/geqo.sgml,v 1.28 2005/01/22 22:56:36 momjian Exp $
Genetic Optimizer Genetic Optimizer
--> -->
@ -147,7 +147,7 @@ Genetic Optimizer
<literallayout class="monospaced"> <literallayout class="monospaced">
+=========================================+ +=========================================+
|>>>>>>>>>>> Algorithm GA <<<<<<<<<<<<<<| |&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; Algorithm GA &lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;|
+=========================================+ +=========================================+
| INITIALIZE t := 0 | | INITIALIZE t := 0 |
+=========================================+ +=========================================+

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.49 2005/01/08 22:13:25 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.50 2005/01/22 22:56:36 momjian Exp $ -->
<chapter id="indexes"> <chapter id="indexes">
<title id="indexes-title">Indexes</title> <title id="indexes-title">Indexes</title>
@ -563,7 +563,7 @@ CREATE TABLE access_log (
such as this: such as this:
<programlisting> <programlisting>
CREATE INDEX access_log_client_ip_ix ON access_log (client_ip) CREATE INDEX access_log_client_ip_ix ON access_log (client_ip)
WHERE NOT (client_ip > inet '192.168.100.0' AND client_ip < inet '192.168.100.255'); WHERE NOT (client_ip &gt; inet '192.168.100.0' AND client_ip &lt; inet '192.168.100.255');
</programlisting> </programlisting>
</para> </para>
@ -617,12 +617,12 @@ CREATE INDEX orders_unbilled_index ON orders (order_nr)
<para> <para>
A possible query to use this index would be A possible query to use this index would be
<programlisting> <programlisting>
SELECT * FROM orders WHERE billed is not true AND order_nr < 10000; SELECT * FROM orders WHERE billed is not true AND order_nr &lt; 10000;
</programlisting> </programlisting>
However, the index can also be used in queries that do not involve However, the index can also be used in queries that do not involve
<structfield>order_nr</> at all, e.g., <structfield>order_nr</> at all, e.g.,
<programlisting> <programlisting>
SELECT * FROM orders WHERE billed is not true AND amount > 5000.00; SELECT * FROM orders WHERE billed is not true AND amount &gt; 5000.00;
</programlisting> </programlisting>
This is not as efficient as a partial index on the This is not as efficient as a partial index on the
<structfield>amount</> column would be, since the system has to <structfield>amount</> column would be, since the system has to

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.57 2005/01/15 03:38:44 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.58 2005/01/22 22:56:36 momjian Exp $
--> -->
<chapter id="plpgsql"> <chapter id="plpgsql">
@ -1570,7 +1570,7 @@ END IF;
</programlisting> </programlisting>
<programlisting> <programlisting>
IF v_count > 0 THEN IF v_count &gt; 0 THEN
INSERT INTO users_count (count) VALUES (v_count); INSERT INTO users_count (count) VALUES (v_count);
RETURN 't'; RETURN 't';
ELSE ELSE
@ -3233,7 +3233,7 @@ BEGIN
SELECT count(*) INTO a_running_job_count FROM cs_jobs WHERE end_stamp IS NULL; SELECT count(*) INTO a_running_job_count FROM cs_jobs WHERE end_stamp IS NULL;
IF a_running_job_count > 0 THEN IF a_running_job_count &gt; 0 THEN
COMMIT; -- free lock<co id="co.plpgsql-porting-commit"> COMMIT; -- free lock<co id="co.plpgsql-porting-commit">
raise_application_error(-20000, 'Unable to create a new job: a job is currently running.'); raise_application_error(-20000, 'Unable to create a new job: a job is currently running.');
END IF; END IF;
@ -3299,7 +3299,7 @@ BEGIN
SELECT count(*) INTO a_running_job_count FROM cs_jobs WHERE end_stamp IS NULL; SELECT count(*) INTO a_running_job_count FROM cs_jobs WHERE end_stamp IS NULL;
IF a_running_job_count > 0 THEN IF a_running_job_count &gt; 0 THEN
RAISE EXCEPTION 'Unable to create a new job: a job is currently running';<co id="co.plpgsql-porting-raise"> RAISE EXCEPTION 'Unable to create a new job: a job is currently running';<co id="co.plpgsql-porting-raise">
END IF; END IF;
@ -3464,7 +3464,7 @@ DECLARE
length integer; length integer;
ss_length integer; ss_length integer;
BEGIN BEGIN
IF beg_index > 0 THEN IF beg_index &gt; 0 THEN
temp_str := substring(string FROM beg_index); temp_str := substring(string FROM beg_index);
pos := position(string_to_search IN temp_str); pos := position(string_to_search IN temp_str);
@ -3478,11 +3478,11 @@ BEGIN
length := char_length(string); length := char_length(string);
beg := length + beg_index - ss_length + 2; beg := length + beg_index - ss_length + 2;
WHILE beg > 0 LOOP WHILE beg &gt; 0 LOOP
temp_str := substring(string FROM beg FOR ss_length); temp_str := substring(string FROM beg FOR ss_length);
pos := position(string_to_search IN temp_str); pos := position(string_to_search IN temp_str);
IF pos > 0 THEN IF pos &gt; 0 THEN
RETURN beg; RETURN beg;
END IF; END IF;
@ -3507,7 +3507,7 @@ DECLARE
length integer; length integer;
ss_length integer; ss_length integer;
BEGIN BEGIN
IF beg_index > 0 THEN IF beg_index &gt; 0 THEN
beg := beg_index; beg := beg_index;
temp_str := substring(string FROM beg_index); temp_str := substring(string FROM beg_index);
@ -3533,11 +3533,11 @@ BEGIN
length := char_length(string); length := char_length(string);
beg := length + beg_index - ss_length + 2; beg := length + beg_index - ss_length + 2;
WHILE beg > 0 LOOP WHILE beg &gt; 0 LOOP
temp_str := substring(string FROM beg FOR ss_length); temp_str := substring(string FROM beg FOR ss_length);
pos := position(string_to_search IN temp_str); pos := position(string_to_search IN temp_str);
IF pos > 0 THEN IF pos &gt; 0 THEN
occur_number := occur_number + 1; occur_number := occur_number + 1;
IF occur_number = occur_index THEN IF occur_number = occur_index THEN

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/pltcl.sgml,v 2.33 2004/12/30 21:45:37 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/pltcl.sgml,v 2.34 2005/01/22 22:56:36 momjian Exp $
--> -->
<chapter id="pltcl"> <chapter id="pltcl">
@ -102,7 +102,7 @@ $$ LANGUAGE pltcl;
<programlisting> <programlisting>
CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS $$ CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS $$
if {$1 > $2} {return $1} if {$1 &gt; $2} {return $1}
return $2 return $2
$$ LANGUAGE pltcl STRICT; $$ LANGUAGE pltcl STRICT;
</programlisting> </programlisting>
@ -129,7 +129,7 @@ CREATE FUNCTION tcl_max(integer, integer) RETURNS integer AS $$
return $2 return $2
} }
if {[argisnull 2]} { return $1 } if {[argisnull 2]} { return $1 }
if {$1 > $2} {return $1} if {$1 &gt; $2} {return $1}
return $2 return $2
$$ LANGUAGE pltcl; $$ LANGUAGE pltcl;
</programlisting> </programlisting>
@ -156,10 +156,10 @@ CREATE TABLE employee (
); );
CREATE FUNCTION overpaid(employee) RETURNS boolean AS $$ CREATE FUNCTION overpaid(employee) RETURNS boolean AS $$
if {200000.0 < $1(salary)} { if {200000.0 &lt; $1(salary)} {
return "t" return "t"
} }
if {$1(age) < 30 && 100000.0 < $1(salary)} { if {$1(age) &lt; 30 && 100000.0 &lt; $1(salary)} {
return "t" return "t"
} }
return "f" return "f"

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/queries.sgml,v 1.32 2004/12/23 05:37:40 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/queries.sgml,v 1.33 2005/01/22 22:56:36 momjian Exp $ -->
<chapter id="queries"> <chapter id="queries">
<title>Queries</title> <title>Queries</title>
@ -374,7 +374,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
</programlisting> </programlisting>
then we get the following results for the various joins: then we get the following results for the various joins:
<screen> <screen>
<prompt>=></> <userinput>SELECT * FROM t1 CROSS JOIN t2;</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 CROSS JOIN t2;</>
num | name | num | value num | name | num | value
-----+------+-----+------- -----+------+-----+-------
1 | a | 1 | xxx 1 | a | 1 | xxx
@ -388,28 +388,28 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
3 | c | 5 | zzz 3 | c | 5 | zzz
(9 rows) (9 rows)
<prompt>=></> <userinput>SELECT * FROM t1 INNER JOIN t2 ON t1.num = t2.num;</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 INNER JOIN t2 ON t1.num = t2.num;</>
num | name | num | value num | name | num | value
-----+------+-----+------- -----+------+-----+-------
1 | a | 1 | xxx 1 | a | 1 | xxx
3 | c | 3 | yyy 3 | c | 3 | yyy
(2 rows) (2 rows)
<prompt>=></> <userinput>SELECT * FROM t1 INNER JOIN t2 USING (num);</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 INNER JOIN t2 USING (num);</>
num | name | value num | name | value
-----+------+------- -----+------+-------
1 | a | xxx 1 | a | xxx
3 | c | yyy 3 | c | yyy
(2 rows) (2 rows)
<prompt>=></> <userinput>SELECT * FROM t1 NATURAL INNER JOIN t2;</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 NATURAL INNER JOIN t2;</>
num | name | value num | name | value
-----+------+------- -----+------+-------
1 | a | xxx 1 | a | xxx
3 | c | yyy 3 | c | yyy
(2 rows) (2 rows)
<prompt>=></> <userinput>SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num;</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num;</>
num | name | num | value num | name | num | value
-----+------+-----+------- -----+------+-----+-------
1 | a | 1 | xxx 1 | a | 1 | xxx
@ -417,7 +417,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
3 | c | 3 | yyy 3 | c | 3 | yyy
(3 rows) (3 rows)
<prompt>=></> <userinput>SELECT * FROM t1 LEFT JOIN t2 USING (num);</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 LEFT JOIN t2 USING (num);</>
num | name | value num | name | value
-----+------+------- -----+------+-------
1 | a | xxx 1 | a | xxx
@ -425,7 +425,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
3 | c | yyy 3 | c | yyy
(3 rows) (3 rows)
<prompt>=></> <userinput>SELECT * FROM t1 RIGHT JOIN t2 ON t1.num = t2.num;</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 RIGHT JOIN t2 ON t1.num = t2.num;</>
num | name | num | value num | name | num | value
-----+------+-----+------- -----+------+-----+-------
1 | a | 1 | xxx 1 | a | 1 | xxx
@ -433,7 +433,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
| | 5 | zzz | | 5 | zzz
(3 rows) (3 rows)
<prompt>=></> <userinput>SELECT * FROM t1 FULL JOIN t2 ON t1.num = t2.num;</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 FULL JOIN t2 ON t1.num = t2.num;</>
num | name | num | value num | name | num | value
-----+------+-----+------- -----+------+-----+-------
1 | a | 1 | xxx 1 | a | 1 | xxx
@ -450,7 +450,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
prove useful for some queries but needs to be thought out prove useful for some queries but needs to be thought out
carefully. For example: carefully. For example:
<screen> <screen>
<prompt>=></> <userinput>SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num AND t2.value = 'xxx';</> <prompt>=&gt;</> <userinput>SELECT * FROM t1 LEFT JOIN t2 ON t1.num = t2.num AND t2.value = 'xxx';</>
num | name | num | value num | name | num | value
-----+------+-----+------- -----+------+-----+-------
1 | a | 1 | xxx 1 | a | 1 | xxx
@ -508,7 +508,7 @@ SELECT * FROM some_very_long_table_name s JOIN another_fairly_long_name a ON s.i
current query &mdash; it is no longer possible to refer to the table current query &mdash; it is no longer possible to refer to the table
by the original name. Thus by the original name. Thus
<programlisting> <programlisting>
SELECT * FROM my_table AS m WHERE my_table.a > 5; SELECT * FROM my_table AS m WHERE my_table.a &gt; 5;
</programlisting> </programlisting>
is not valid SQL syntax. What will actually happen (this is a is not valid SQL syntax. What will actually happen (this is a
<productname>PostgreSQL</productname> extension to the standard) <productname>PostgreSQL</productname> extension to the standard)
@ -516,7 +516,7 @@ SELECT * FROM my_table AS m WHERE my_table.a > 5;
<literal>FROM</literal> clause, so the query is processed as if <literal>FROM</literal> clause, so the query is processed as if
it were written as it were written as
<programlisting> <programlisting>
SELECT * FROM my_table AS m, my_table AS my_table WHERE my_table.a > 5; SELECT * FROM my_table AS m, my_table AS my_table WHERE my_table.a &gt; 5;
</programlisting> </programlisting>
which will result in a cross join, which is usually not what you which will result in a cross join, which is usually not what you
want. want.
@ -732,7 +732,7 @@ FROM a NATURAL JOIN b WHERE b.val &gt; 5
<para> <para>
Here are some examples of <literal>WHERE</literal> clauses: Here are some examples of <literal>WHERE</literal> clauses:
<programlisting> <programlisting>
SELECT ... FROM fdt WHERE c1 > 5 SELECT ... FROM fdt WHERE c1 &gt; 5
SELECT ... FROM fdt WHERE c1 IN (1, 2, 3) SELECT ... FROM fdt WHERE c1 IN (1, 2, 3)
@ -742,7 +742,7 @@ SELECT ... FROM fdt WHERE c1 IN (SELECT c3 FROM t2 WHERE c2 = fdt.c1 + 10)
SELECT ... FROM fdt WHERE c1 BETWEEN (SELECT c3 FROM t2 WHERE c2 = fdt.c1 + 10) AND 100 SELECT ... FROM fdt WHERE c1 BETWEEN (SELECT c3 FROM t2 WHERE c2 = fdt.c1 + 10) AND 100
SELECT ... FROM fdt WHERE EXISTS (SELECT c1 FROM t2 WHERE c2 > fdt.c1) SELECT ... FROM fdt WHERE EXISTS (SELECT c1 FROM t2 WHERE c2 &gt; fdt.c1)
</programlisting> </programlisting>
<literal>fdt</literal> is the table derived in the <literal>fdt</literal> is the table derived in the
<literal>FROM</> clause. Rows that do not meet the search <literal>FROM</> clause. Rows that do not meet the search
@ -795,7 +795,7 @@ SELECT <replaceable>select_list</replaceable>
eliminate redundancy in the output and/or compute aggregates that eliminate redundancy in the output and/or compute aggregates that
apply to these groups. For instance: apply to these groups. For instance:
<screen> <screen>
<prompt>=></> <userinput>SELECT * FROM test1;</> <prompt>=&gt;</> <userinput>SELECT * FROM test1;</>
x | y x | y
---+--- ---+---
a | 3 a | 3
@ -804,7 +804,7 @@ SELECT <replaceable>select_list</replaceable>
a | 1 a | 1
(4 rows) (4 rows)
<prompt>=></> <userinput>SELECT x FROM test1 GROUP BY x;</> <prompt>=&gt;</> <userinput>SELECT x FROM test1 GROUP BY x;</>
x x
--- ---
a a
@ -827,7 +827,7 @@ SELECT <replaceable>select_list</replaceable>
used in the grouping cannot be referenced except in aggregate used in the grouping cannot be referenced except in aggregate
expressions. An example with aggregate expressions is: expressions. An example with aggregate expressions is:
<screen> <screen>
<prompt>=></> <userinput>SELECT x, sum(y) FROM test1 GROUP BY x;</> <prompt>=&gt;</> <userinput>SELECT x, sum(y) FROM test1 GROUP BY x;</>
x | sum x | sum
---+----- ---+-----
a | 4 a | 4
@ -901,14 +901,14 @@ SELECT <replaceable>select_list</replaceable> FROM ... <optional>WHERE ...</opti
<para> <para>
Example: Example:
<screen> <screen>
<prompt>=></> <userinput>SELECT x, sum(y) FROM test1 GROUP BY x HAVING sum(y) > 3;</> <prompt>=&gt;</> <userinput>SELECT x, sum(y) FROM test1 GROUP BY x HAVING sum(y) &gt; 3;</>
x | sum x | sum
---+----- ---+-----
a | 4 a | 4
b | 5 b | 5
(2 rows) (2 rows)
<prompt>=></> <userinput>SELECT x, sum(y) FROM test1 GROUP BY x HAVING x < 'c';</> <prompt>=&gt;</> <userinput>SELECT x, sum(y) FROM test1 GROUP BY x HAVING x &lt; 'c';</>
x | sum x | sum
---+----- ---+-----
a | 4 a | 4
@ -922,9 +922,9 @@ SELECT <replaceable>select_list</replaceable> FROM ... <optional>WHERE ...</opti
<programlisting> <programlisting>
SELECT product_id, p.name, (sum(s.units) * (p.price - p.cost)) AS profit SELECT product_id, p.name, (sum(s.units) * (p.price - p.cost)) AS profit
FROM products p LEFT JOIN sales s USING (product_id) FROM products p LEFT JOIN sales s USING (product_id)
WHERE s.date > CURRENT_DATE - INTERVAL '4 weeks' WHERE s.date &gt; CURRENT_DATE - INTERVAL '4 weeks'
GROUP BY product_id, p.name, p.price, p.cost GROUP BY product_id, p.name, p.price, p.cost
HAVING sum(p.price * s.units) > 5000; HAVING sum(p.price * s.units) &gt; 5000;
</programlisting> </programlisting>
In the example above, the <literal>WHERE</> clause is selecting In the example above, the <literal>WHERE</> clause is selecting
rows by a column that is not grouped (the expression is only true for rows by a column that is not grouped (the expression is only true for

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/query.sgml,v 1.42 2005/01/08 01:44:08 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/query.sgml,v 1.43 2005/01/22 22:56:36 momjian Exp $
--> -->
<chapter id="tutorial-sql"> <chapter id="tutorial-sql">
@ -605,8 +605,8 @@ SELECT *
SELECT W1.city, W1.temp_lo AS low, W1.temp_hi AS high, SELECT W1.city, W1.temp_lo AS low, W1.temp_hi AS high,
W2.city, W2.temp_lo AS low, W2.temp_hi AS high W2.city, W2.temp_lo AS low, W2.temp_hi AS high
FROM weather W1, weather W2 FROM weather W1, weather W2
WHERE W1.temp_lo < W2.temp_lo WHERE W1.temp_lo &lt; W2.temp_lo
AND W1.temp_hi > W2.temp_hi; AND W1.temp_hi &gt; W2.temp_hi;
city | low | high | city | low | high city | low | high | city | low | high
---------------+-----+------+---------------+-----+------ ---------------+-----+------+---------------+-----+------
@ -737,7 +737,7 @@ SELECT city, max(temp_lo)
SELECT city, max(temp_lo) SELECT city, max(temp_lo)
FROM weather FROM weather
GROUP BY city GROUP BY city
HAVING max(temp_lo) < 40; HAVING max(temp_lo) &lt; 40;
</programlisting> </programlisting>
<screen> <screen>
@ -757,7 +757,7 @@ SELECT city, max(temp_lo)
FROM weather FROM weather
WHERE city LIKE 'S%'<co id="co.tutorial-agg-like"> WHERE city LIKE 'S%'<co id="co.tutorial-agg-like">
GROUP BY city GROUP BY city
HAVING max(temp_lo) < 40; HAVING max(temp_lo) &lt; 40;
</programlisting> </programlisting>
<calloutlist> <calloutlist>
<callout arearefs="co.tutorial-agg-like"> <callout arearefs="co.tutorial-agg-like">
@ -814,7 +814,7 @@ SELECT city, max(temp_lo)
<programlisting> <programlisting>
UPDATE weather UPDATE weather
SET temp_hi = temp_hi - 2, temp_lo = temp_lo - 2 SET temp_hi = temp_hi - 2, temp_lo = temp_lo - 2
WHERE date > '1994-11-28'; WHERE date &gt; '1994-11-28';
</programlisting> </programlisting>
</para> </para>

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.322 2005/01/22 22:06:17 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.323 2005/01/22 22:56:36 momjian Exp $
--> -->
<appendix id="release"> <appendix id="release">
@ -945,7 +945,7 @@ $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.322 2005/01/22 22:06:17 momjian
</para> </para>
<para> <para>
Fixes improper failure of cases such as <literal>SELECT SUM(win)/SUM(lose) Fixes improper failure of cases such as <literal>SELECT SUM(win)/SUM(lose)
... GROUP BY ... HAVING SUM(lose) > 0</>. This should work but formerly ... GROUP BY ... HAVING SUM(lose) &gt; 0</>. This should work but formerly
could fail with divide-by-zero. could fail with divide-by-zero.
</para> </para>
</listitem> </listitem>
@ -2776,7 +2776,7 @@ DROP SCHEMA information_schema CASCADE;
<listitem><para>Force zero_damaged_pages to be on during recovery from WAL</para></listitem> <listitem><para>Force zero_damaged_pages to be on during recovery from WAL</para></listitem>
<listitem><para>Prevent some obscure cases of <quote>variable not in subplan target lists</quote></para></listitem> <listitem><para>Prevent some obscure cases of <quote>variable not in subplan target lists</quote></para></listitem>
<listitem><para>Make <function>PQescapeBytea</function> and <function>byteaout</function> consistent with each other (Joe)</para></listitem> <listitem><para>Make <function>PQescapeBytea</function> and <function>byteaout</function> consistent with each other (Joe)</para></listitem>
<listitem><para>Escape <type>bytea</type> output for bytes > 0x7e(Joe)</para> <listitem><para>Escape <type>bytea</type> output for bytes &gt; 0x7e(Joe)</para>
<para> <para>
If different client encodings are used for <type>bytea</type> output and input, it If different client encodings are used for <type>bytea</type> output and input, it
is possible for <type>bytea</type> values to be corrupted by the differing is possible for <type>bytea</type> values to be corrupted by the differing
@ -4609,7 +4609,7 @@ DROP SCHEMA information_schema CASCADE;
<listitem><para>Allow libpq to compile with Borland C++ compiler (Lester Godwin, Karl Waclawek)</para></listitem> <listitem><para>Allow libpq to compile with Borland C++ compiler (Lester Godwin, Karl Waclawek)</para></listitem>
<listitem><para>Use our own version of <function>getopt_long()</function> if needed (Peter)</para></listitem> <listitem><para>Use our own version of <function>getopt_long()</function> if needed (Peter)</para></listitem>
<listitem><para>Convert administration scripts to C (Peter)</para></listitem> <listitem><para>Convert administration scripts to C (Peter)</para></listitem>
<listitem><para> Bison >= 1.85 is now required to build the <productname>PostgreSQL</> grammar, if building from CVS</para></listitem> <listitem><para> Bison &gt;= 1.85 is now required to build the <productname>PostgreSQL</> grammar, if building from CVS</para></listitem>
<listitem><para>Merge documentation into one book (Peter)</para></listitem> <listitem><para>Merge documentation into one book (Peter)</para></listitem>
<listitem><para>Add Windows compatibility functions (Bruce)</para></listitem> <listitem><para>Add Windows compatibility functions (Bruce)</para></listitem>
<listitem><para>Allow client interfaces to compile under MinGW (Bruce)</para></listitem> <listitem><para>Allow client interfaces to compile under MinGW (Bruce)</para></listitem>
@ -5450,7 +5450,7 @@ operations on bytea columns (Joe)</para></listitem>
<listitem><para>Make cursors insensitive, meaning their contents do not change (Tom)</para></listitem> <listitem><para>Make cursors insensitive, meaning their contents do not change (Tom)</para></listitem>
<listitem><para>Disable LIMIT #,# syntax; now only LIMIT # OFFSET # supported (Bruce)</para></listitem> <listitem><para>Disable LIMIT #,# syntax; now only LIMIT # OFFSET # supported (Bruce)</para></listitem>
<listitem><para>Increase identifier length to 63 (Neil, Bruce)</para></listitem> <listitem><para>Increase identifier length to 63 (Neil, Bruce)</para></listitem>
<listitem><para>UNION fixes for merging >= 3 columns of different lengths (Tom)</para></listitem> <listitem><para>UNION fixes for merging &gt;= 3 columns of different lengths (Tom)</para></listitem>
<listitem><para>Add DEFAULT key word to INSERT, e.g., INSERT ... (..., DEFAULT, ...) (Rod)</para></listitem> <listitem><para>Add DEFAULT key word to INSERT, e.g., INSERT ... (..., DEFAULT, ...) (Rod)</para></listitem>
<listitem><para>Allow views to have default values using ALTER COLUMN ... SET DEFAULT (Neil)</para></listitem> <listitem><para>Allow views to have default values using ALTER COLUMN ... SET DEFAULT (Neil)</para></listitem>
<listitem><para>Fail on INSERTs with column lists that don't supply all column values, e.g., INSERT INTO tab (col1, col2) VALUES ('val1'); (Rod)</para></listitem> <listitem><para>Fail on INSERTs with column lists that don't supply all column values, e.g., INSERT INTO tab (col1, col2) VALUES ('val1'); (Rod)</para></listitem>
@ -5533,7 +5533,7 @@ operations on bytea columns (Joe)</para></listitem>
<listitem><para>New pg_settings table to view/modify GUC settings (Joe)</para></listitem> <listitem><para>New pg_settings table to view/modify GUC settings (Joe)</para></listitem>
<listitem><para>Add smart quoting, portability improvements to <application>pg_dump</> output (Peter)</para></listitem> <listitem><para>Add smart quoting, portability improvements to <application>pg_dump</> output (Peter)</para></listitem>
<listitem><para>Dump serial columns out as SERIAL (Tom)</para></listitem> <listitem><para>Dump serial columns out as SERIAL (Tom)</para></listitem>
<listitem><para>Enable large file support, >2G for <application>pg_dump</> (Peter, Philip Warner, Bruce)</para></listitem> <listitem><para>Enable large file support, &gt;2G for <application>pg_dump</> (Peter, Philip Warner, Bruce)</para></listitem>
<listitem><para>Disallow TRUNCATE on tables that are involved in referential constraints (Rod)</para></listitem> <listitem><para>Disallow TRUNCATE on tables that are involved in referential constraints (Rod)</para></listitem>
<listitem><para>Have TRUNCATE also auto-truncate the toast table of the relation (Tom)</para></listitem> <listitem><para>Have TRUNCATE also auto-truncate the toast table of the relation (Tom)</para></listitem>
<listitem><para>Add clusterdb utility that will auto-cluster an entire database based on previous CLUSTER operations (Alvaro Herrera)</para></listitem> <listitem><para>Add clusterdb utility that will auto-cluster an entire database based on previous CLUSTER operations (Alvaro Herrera)</para></listitem>
@ -5597,7 +5597,7 @@ operations on bytea columns (Joe)</para></listitem>
<listitem><para>Add additional encodings: Korean (JOHAB), Thai (WIN874), Vietnamese (TCVN), Arabic (WIN1256), Simplified Chinese (GBK), Korean (UHC) (Eiji Tokuya)</para></listitem> <listitem><para>Add additional encodings: Korean (JOHAB), Thai (WIN874), Vietnamese (TCVN), Arabic (WIN1256), Simplified Chinese (GBK), Korean (UHC) (Eiji Tokuya)</para></listitem>
<listitem><para>Enable locale support by default (Peter)</para></listitem> <listitem><para>Enable locale support by default (Peter)</para></listitem>
<listitem><para>Add locale variables (Peter)</para></listitem> <listitem><para>Add locale variables (Peter)</para></listitem>
<listitem><para>Escape byes >= 0x7f for multibyte in PQescapeBytea/PQunescapeBytea (Tatsuo)</para></listitem> <listitem><para>Escape byes &gt;= 0x7f for multibyte in PQescapeBytea/PQunescapeBytea (Tatsuo)</para></listitem>
<listitem><para>Add locale awareness to regular expression character classes</para></listitem> <listitem><para>Add locale awareness to regular expression character classes</para></listitem>
<listitem><para>Enable multibyte support by default (Tatsuo)</para></listitem> <listitem><para>Enable multibyte support by default (Tatsuo)</para></listitem>
<listitem><para>Add GB18030 multibyte support (Bill Huang)</para></listitem> <listitem><para>Add GB18030 multibyte support (Bill Huang)</para></listitem>
@ -5967,7 +5967,7 @@ since <productname>PostgreSQL</productname> 7.1.
<itemizedlist> <itemizedlist>
<listitem><para>Allow EXECUTE of "CREATE TABLE AS ... SELECT" in PL/pgSQL (Tom)</para></listitem> <listitem><para>Allow EXECUTE of "CREATE TABLE AS ... SELECT" in PL/pgSQL (Tom)</para></listitem>
<listitem><para>Fix for compressed transaction log id wraparound (Tom)</para></listitem> <listitem><para>Fix for compressed transaction log id wraparound (Tom)</para></listitem>
<listitem><para>Fix PQescapeBytea/PQunescapeBytea so that they handle bytes > 0x7f (Tatsuo)</para></listitem> <listitem><para>Fix PQescapeBytea/PQunescapeBytea so that they handle bytes &gt; 0x7f (Tatsuo)</para></listitem>
<listitem><para>Fix for psql and <application>pg_dump</> crashing when invoked with non-existent long options (Tatsuo)</para></listitem> <listitem><para>Fix for psql and <application>pg_dump</> crashing when invoked with non-existent long options (Tatsuo)</para></listitem>
<listitem><para>Fix crash when invoking geometric operators (Tom)</para></listitem> <listitem><para>Fix crash when invoking geometric operators (Tom)</para></listitem>
<listitem><para>Allow OPEN cursor(args) (Tom)</para></listitem> <listitem><para>Allow OPEN cursor(args) (Tom)</para></listitem>
@ -7386,7 +7386,7 @@ Fix mismatched types in CREATE TABLE ... DEFAULT
Fix SELECT * FROM pg_class where oid in (0,-1) Fix SELECT * FROM pg_class where oid in (0,-1)
Fix SELECT COUNT('asdf') FROM pg_class WHERE oid=12 Fix SELECT COUNT('asdf') FROM pg_class WHERE oid=12
Prevent user who can create databases can modifying pg_database table (Peter E) Prevent user who can create databases can modifying pg_database table (Peter E)
Fix btree to give a useful elog when key > 1/2 (page - overhead) (Tom) Fix btree to give a useful elog when key &gt; 1/2 (page - overhead) (Tom)
Fix INSERT of 0.0 into DECIMAL(4,4) field (Tom) Fix INSERT of 0.0 into DECIMAL(4,4) field (Tom)
Enhancements Enhancements
@ -7595,7 +7595,7 @@ Fewer fsync writes when fsync is not disabled (Tom)
Improved LIKE optimizer estimates (Tom) Improved LIKE optimizer estimates (Tom)
Prevent fsync in SELECT-only queries (Vadim) Prevent fsync in SELECT-only queries (Vadim)
Make index creation use psort code, because it is now faster (Tom) Make index creation use psort code, because it is now faster (Tom)
Allow creation of sort temp tables > 1 Gig Allow creation of sort temp tables &gt; 1 Gig
Source Tree Changes Source Tree Changes
------------------- -------------------
@ -9225,7 +9225,7 @@ Check explicitly for points and polygons contained within polygons
using an axis-crossing algorithm(Thomas) using an axis-crossing algorithm(Thomas)
Add routine to convert circle-box(Thomas) Add routine to convert circle-box(Thomas)
Merge conflicting operators for different geometric data types(Thomas) Merge conflicting operators for different geometric data types(Thomas)
Replace distance operator "<===>" with "&lt;-&gt;"(Thomas) Replace distance operator "&lt;===&gt;" with "&lt;-&gt;"(Thomas)
Replace "above" operator "!^" with "&gt;^" and "below" operator "!|" with "&lt;^"(Thomas) Replace "above" operator "!^" with "&gt;^" and "below" operator "!|" with "&lt;^"(Thomas)
Add routines for text trimming on both ends, substring, and string position(Thomas) Add routines for text trimming on both ends, substring, and string position(Thomas)
Added conversion routines circle(box) and poly(circle)(Thomas) Added conversion routines circle(box) and poly(circle)(Thomas)

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/rowtypes.sgml,v 2.4 2004/12/23 05:37:40 tgl Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/rowtypes.sgml,v 2.5 2005/01/22 22:56:36 momjian Exp $ -->
<sect1 id="rowtypes"> <sect1 id="rowtypes">
<title>Composite Types</title> <title>Composite Types</title>
@ -75,7 +75,7 @@ SELECT price_extension(item, 10) FROM on_hand;
CREATE TABLE inventory_item ( CREATE TABLE inventory_item (
name text, name text,
supplier_id integer REFERENCES suppliers, supplier_id integer REFERENCES suppliers,
price numeric CHECK (price > 0) price numeric CHECK (price &gt; 0)
); );
</programlisting> </programlisting>
then the same <literal>inventory_item</> composite type shown above would then the same <literal>inventory_item</> composite type shown above would
@ -165,21 +165,21 @@ ROW('', 42, NULL)
like: like:
<programlisting> <programlisting>
SELECT item.name FROM on_hand WHERE item.price > 9.99; SELECT item.name FROM on_hand WHERE item.price &gt; 9.99;
</programlisting> </programlisting>
This will not work since the name <literal>item</> is taken to be a table This will not work since the name <literal>item</> is taken to be a table
name, not a field name, per SQL syntax rules. You must write it like this: name, not a field name, per SQL syntax rules. You must write it like this:
<programlisting> <programlisting>
SELECT (item).name FROM on_hand WHERE (item).price > 9.99; SELECT (item).name FROM on_hand WHERE (item).price &gt; 9.99;
</programlisting> </programlisting>
or if you need to use the table name as well (for instance in a multi-table or if you need to use the table name as well (for instance in a multi-table
query), like this: query), like this:
<programlisting> <programlisting>
SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price > 9.99; SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price &gt; 9.99;
</programlisting> </programlisting>
Now the parenthesized object is correctly interpreted as a reference to Now the parenthesized object is correctly interpreted as a reference to

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/rules.sgml,v 1.38 2005/01/22 22:06:27 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/rules.sgml,v 1.39 2005/01/22 22:56:36 momjian Exp $ -->
<Chapter Id="rules"> <Chapter Id="rules">
<Title>The Rule System</Title> <Title>The Rule System</Title>
@ -344,7 +344,7 @@ returns the lower of 2 integer values. We create that as
<ProgramListing> <ProgramListing>
CREATE FUNCTION min(integer, integer) RETURNS integer AS $$ CREATE FUNCTION min(integer, integer) RETURNS integer AS $$
SELECT CASE WHEN $1 < $2 THEN $1 ELSE $2 END SELECT CASE WHEN $1 &lt; $2 THEN $1 ELSE $2 END
$$ LANGUAGE SQL STRICT; $$ LANGUAGE SQL STRICT;
</ProgramListing> </ProgramListing>
</Para> </Para>
@ -414,8 +414,8 @@ CREATE VIEW shoe_ready AS
min(rsh.sh_avail, rsl.sl_avail) AS total_avail min(rsh.sh_avail, rsl.sl_avail) AS total_avail
FROM shoe rsh, shoelace rsl FROM shoe rsh, shoelace rsl
WHERE rsl.sl_color = rsh.slcolor WHERE rsl.sl_color = rsh.slcolor
AND rsl.sl_len_cm >= rsh.slminlen_cm AND rsl.sl_len_cm &gt;= rsh.slminlen_cm
AND rsl.sl_len_cm <= rsh.slmaxlen_cm; AND rsl.sl_len_cm &lt;= rsh.slmaxlen_cm;
</ProgramListing> </ProgramListing>
The <command>CREATE VIEW</command> command for the The <command>CREATE VIEW</command> command for the
@ -558,7 +558,7 @@ SELECT shoelace.sl_name, shoelace.sl_avail,
total number of exactly matching pairs is greater or equal to two. total number of exactly matching pairs is greater or equal to two.
<ProgramListing> <ProgramListing>
SELECT * FROM shoe_ready WHERE total_avail >= 2; SELECT * FROM shoe_ready WHERE total_avail &gt;= 2;
shoename | sh_avail | sl_name | sl_avail | total_avail shoename | sh_avail | sl_name | sl_avail | total_avail
----------+----------+---------+----------+------------- ----------+----------+---------+----------+-------------
@ -576,7 +576,7 @@ SELECT shoe_ready.shoename, shoe_ready.sh_avail,
shoe_ready.sl_name, shoe_ready.sl_avail, shoe_ready.sl_name, shoe_ready.sl_avail,
shoe_ready.total_avail shoe_ready.total_avail
FROM shoe_ready shoe_ready FROM shoe_ready shoe_ready
WHERE shoe_ready.total_avail >= 2; WHERE shoe_ready.total_avail &gt;= 2;
</ProgramListing> </ProgramListing>
The first rule applied will be the one for the The first rule applied will be the one for the
@ -594,9 +594,9 @@ SELECT shoe_ready.shoename, shoe_ready.sh_avail,
min(rsh.sh_avail, rsl.sl_avail) AS total_avail min(rsh.sh_avail, rsl.sl_avail) AS total_avail
FROM shoe rsh, shoelace rsl FROM shoe rsh, shoelace rsl
WHERE rsl.sl_color = rsh.slcolor WHERE rsl.sl_color = rsh.slcolor
AND rsl.sl_len_cm >= rsh.slminlen_cm AND rsl.sl_len_cm &gt;= rsh.slminlen_cm
AND rsl.sl_len_cm <= rsh.slmaxlen_cm) shoe_ready AND rsl.sl_len_cm &lt;= rsh.slmaxlen_cm) shoe_ready
WHERE shoe_ready.total_avail >= 2; WHERE shoe_ready.total_avail &gt;= 2;
</ProgramListing> </ProgramListing>
Similarly, the rules for <literal>shoe</literal> and Similarly, the rules for <literal>shoe</literal> and
@ -631,9 +631,9 @@ SELECT shoe_ready.shoename, shoe_ready.sh_avail,
FROM shoelace_data s, unit u FROM shoelace_data s, unit u
WHERE s.sl_unit = u.un_name) rsl WHERE s.sl_unit = u.un_name) rsl
WHERE rsl.sl_color = rsh.slcolor WHERE rsl.sl_color = rsh.slcolor
AND rsl.sl_len_cm >= rsh.slminlen_cm AND rsl.sl_len_cm &gt;= rsh.slminlen_cm
AND rsl.sl_len_cm <= rsh.slmaxlen_cm) shoe_ready AND rsl.sl_len_cm &lt;= rsh.slmaxlen_cm) shoe_ready
WHERE shoe_ready.total_avail > 2; WHERE shoe_ready.total_avail &gt; 2;
</ProgramListing> </ProgramListing>
</para> </para>
@ -1958,14 +1958,14 @@ Nestloop
is is
<ProgramListing> <ProgramListing>
DELETE FROM computer WHERE hostname >= 'old' DELETE FROM computer WHERE hostname &gt;= 'old'
AND hostname < 'ole' AND hostname &lt; 'ole'
</ProgramListing> </ProgramListing>
The command added by the rule will be The command added by the rule will be
<ProgramListing> <ProgramListing>
DELETE FROM software WHERE computer.hostname >= 'old' AND computer.hostname < 'ole' DELETE FROM software WHERE computer.hostname &gt;= 'old' AND computer.hostname &lt; 'ole'
AND software.hostname = computer.hostname; AND software.hostname = computer.hostname;
</ProgramListing> </ProgramListing>

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.301 2005/01/08 22:13:35 tgl Exp $ $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.302 2005/01/22 22:56:36 momjian Exp $
--> -->
<Chapter Id="runtime"> <Chapter Id="runtime">
@ -4420,8 +4420,8 @@ options SEMMAP=256
<filename>proc</filename> file system (without reboot). For <filename>proc</filename> file system (without reboot). For
example, to allow 128 MB: example, to allow 128 MB:
<screen> <screen>
<prompt>$</prompt> <userinput>echo 134217728 >/proc/sys/kernel/shmall</userinput> <prompt>$</prompt> <userinput>echo 134217728 &gt;/proc/sys/kernel/shmall</userinput>
<prompt>$</prompt> <userinput>echo 134217728 >/proc/sys/kernel/shmmax</userinput> <prompt>$</prompt> <userinput>echo 134217728 &gt;/proc/sys/kernel/shmmax</userinput>
</screen> </screen>
You could put these commands into a script run at boot-time. You could put these commands into a script run at boot-time.
</para> </para>

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.38 2005/01/22 22:06:27 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.39 2005/01/22 22:56:36 momjian Exp $
--> -->
<chapter id="spi"> <chapter id="spi">
@ -2929,18 +2929,18 @@ execq(text *sql, int cnt)
* If this is a SELECT and some rows were fetched, * If this is a SELECT and some rows were fetched,
* then the rows are printed via elog(INFO). * then the rows are printed via elog(INFO).
*/ */
if (ret == SPI_OK_SELECT && SPI_processed > 0) if (ret == SPI_OK_SELECT && SPI_processed &gt; 0)
{ {
TupleDesc tupdesc = SPI_tuptable-&gt;tupdesc; TupleDesc tupdesc = SPI_tuptable-&gt;tupdesc;
SPITupleTable *tuptable = SPI_tuptable; SPITupleTable *tuptable = SPI_tuptable;
char buf[8192]; char buf[8192];
int i, j; int i, j;
for (j = 0; j < proc; j++) for (j = 0; j &lt; proc; j++)
{ {
HeapTuple tuple = tuptable-&gt;vals[j]; HeapTuple tuple = tuptable-&gt;vals[j];
for (i = 1, buf[0] = 0; i <= tupdesc-&gt;natts; i++) for (i = 1, buf[0] = 0; i &lt;= tupdesc-&gt;natts; i++)
snprintf(buf + strlen (buf), sizeof(buf) - strlen(buf), " %s%s", snprintf(buf + strlen (buf), sizeof(buf) - strlen(buf), " %s%s",
SPI_getvalue(tuple, tupdesc, i), SPI_getvalue(tuple, tupdesc, i),
(i == tupdesc-&gt;natts) ? " " : " |"); (i == tupdesc-&gt;natts) ? " " : " |");
@ -2976,15 +2976,15 @@ CREATE FUNCTION execq(text, integer) RETURNS integer
Here is a sample session: Here is a sample session:
<programlisting> <programlisting>
=> SELECT execq('CREATE TABLE a (x integer)', 0); =&gt; SELECT execq('CREATE TABLE a (x integer)', 0);
execq execq
------- -------
0 0
(1 row) (1 row)
=> INSERT INTO a VALUES (execq('INSERT INTO a VALUES (0)', 0)); =&gt; INSERT INTO a VALUES (execq('INSERT INTO a VALUES (0)', 0));
INSERT 167631 1 INSERT 167631 1
=> SELECT execq('SELECT * FROM a', 0); =&gt; SELECT execq('SELECT * FROM a', 0);
INFO: EXECQ: 0 -- inserted by execq INFO: EXECQ: 0 -- inserted by execq
INFO: EXECQ: 1 -- returned by execq and inserted by upper INSERT INFO: EXECQ: 1 -- returned by execq and inserted by upper INSERT
@ -2993,13 +2993,13 @@ INFO: EXECQ: 1 -- returned by execq and inserted by upper INSERT
2 2
(1 row) (1 row)
=> SELECT execq('INSERT INTO a SELECT x + 2 FROM a', 1); =&gt; SELECT execq('INSERT INTO a SELECT x + 2 FROM a', 1);
execq execq
------- -------
1 1
(1 row) (1 row)
=> SELECT execq('SELECT * FROM a', 10); =&gt; SELECT execq('SELECT * FROM a', 10);
INFO: EXECQ: 0 INFO: EXECQ: 0
INFO: EXECQ: 1 INFO: EXECQ: 1
INFO: EXECQ: 2 -- 0 + 2, only one row inserted - as specified INFO: EXECQ: 2 -- 0 + 2, only one row inserted - as specified
@ -3009,20 +3009,20 @@ INFO: EXECQ: 2 -- 0 + 2, only one row inserted - as specified
3 -- 10 is the max value only, 3 is the real number of rows 3 -- 10 is the max value only, 3 is the real number of rows
(1 row) (1 row)
=> DELETE FROM a; =&gt; DELETE FROM a;
DELETE 3 DELETE 3
=> INSERT INTO a VALUES (execq('SELECT * FROM a', 0) + 1); =&gt; INSERT INTO a VALUES (execq('SELECT * FROM a', 0) + 1);
INSERT 167712 1 INSERT 167712 1
=> SELECT * FROM a; =&gt; SELECT * FROM a;
x x
--- ---
1 -- no rows in a (0) + 1 1 -- no rows in a (0) + 1
(1 row) (1 row)
=> INSERT INTO a VALUES (execq('SELECT * FROM a', 0) + 1); =&gt; INSERT INTO a VALUES (execq('SELECT * FROM a', 0) + 1);
INFO: EXECQ: 0 INFO: EXECQ: 0
INSERT 167713 1 INSERT 167713 1
=> SELECT * FROM a; =&gt; SELECT * FROM a;
x x
--- ---
1 1
@ -3031,14 +3031,14 @@ INSERT 167713 1
-- This demonstrates the data changes visibility rule: -- This demonstrates the data changes visibility rule:
=> INSERT INTO a SELECT execq('SELECT * FROM a', 0) * x FROM a; =&gt; INSERT INTO a SELECT execq('SELECT * FROM a', 0) * x FROM a;
INFO: EXECQ: 1 INFO: EXECQ: 1
INFO: EXECQ: 2 INFO: EXECQ: 2
INFO: EXECQ: 1 INFO: EXECQ: 1
INFO: EXECQ: 2 INFO: EXECQ: 2
INFO: EXECQ: 2 INFO: EXECQ: 2
INSERT 0 2 INSERT 0 2
=> SELECT * FROM a; =&gt; SELECT * FROM a;
x x
--- ---
1 1

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/sql.sgml,v 1.33 2004/11/15 06:32:14 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/sql.sgml,v 1.34 2005/01/22 22:56:36 momjian Exp $
--> -->
<chapter id="sql-intro"> <chapter id="sql-intro">
@ -891,7 +891,7 @@ SELECT [ ALL | DISTINCT [ ON ( <replaceable class="PARAMETER">expression</replac
<programlisting> <programlisting>
SELECT * FROM PART SELECT * FROM PART
WHERE PRICE > 10; WHERE PRICE &gt; 10;
</programlisting> </programlisting>
and get the table: and get the table:
@ -913,7 +913,7 @@ SELECT * FROM PART
<programlisting> <programlisting>
SELECT PNAME, PRICE SELECT PNAME, PRICE
FROM PART FROM PART
WHERE PRICE > 10; WHERE PRICE &gt; 10;
</programlisting> </programlisting>
In this case the result is: In this case the result is:
@ -939,7 +939,7 @@ SELECT PNAME, PRICE
SELECT PNAME, PRICE SELECT PNAME, PRICE
FROM PART FROM PART
WHERE PNAME = 'Bolt' AND WHERE PNAME = 'Bolt' AND
(PRICE = 0 OR PRICE <= 15); (PRICE = 0 OR PRICE &lt;= 15);
</programlisting> </programlisting>
will lead to the result: will lead to the result:
@ -959,7 +959,7 @@ SELECT PNAME, PRICE
<programlisting> <programlisting>
SELECT PNAME, PRICE * 2 AS DOUBLE SELECT PNAME, PRICE * 2 AS DOUBLE
FROM PART FROM PART
WHERE PRICE * 2 < 50; WHERE PRICE * 2 &lt; 50;
</programlisting> </programlisting>
and we get: and we get:
@ -1450,7 +1450,7 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
FROM SUPPLIER S, SELLS SE FROM SUPPLIER S, SELLS SE
WHERE S.SNO = SE.SNO WHERE S.SNO = SE.SNO
GROUP BY S.SNO, S.SNAME GROUP BY S.SNO, S.SNAME
HAVING COUNT(SE.PNO) > 1; HAVING COUNT(SE.PNO) &gt; 1;
</programlisting> </programlisting>
and get: and get:
@ -1487,7 +1487,7 @@ SELECT S.SNO, S.SNAME, COUNT(SE.PNO)
<programlisting> <programlisting>
SELECT * SELECT *
FROM PART FROM PART
WHERE PRICE > (SELECT PRICE FROM PART WHERE PRICE &gt; (SELECT PRICE FROM PART
WHERE PNAME='Screw'); WHERE PNAME='Screw');
</programlisting> </programlisting>
</para> </para>
@ -1617,11 +1617,11 @@ gives the result:
<programlisting> <programlisting>
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNO > 1 WHERE S.SNO &gt; 1
INTERSECT INTERSECT
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNO < 3; WHERE S.SNO &lt; 3;
</programlisting> </programlisting>
gives the result: gives the result:
@ -1641,11 +1641,11 @@ INTERSECT
<programlisting> <programlisting>
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNO > 1 WHERE S.SNO &gt; 1
EXCEPT EXCEPT
SELECT S.SNO, S.SNAME, S.CITY SELECT S.SNO, S.SNAME, S.CITY
FROM SUPPLIER S FROM SUPPLIER S
WHERE S.SNO > 3; WHERE S.SNO &gt; 3;
</programlisting> </programlisting>
gives the result: gives the result:

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.40 2005/01/22 22:06:27 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.41 2005/01/22 22:56:36 momjian Exp $
--> -->
<chapter id="triggers"> <chapter id="triggers">
@ -572,13 +572,13 @@ trigf(PG_FUNCTION_ARGS)
tupdesc = trigdata-&gt;tg_relation-&gt;rd_att; tupdesc = trigdata-&gt;tg_relation-&gt;rd_att;
/* connect to SPI manager */ /* connect to SPI manager */
if ((ret = SPI_connect()) < 0) if ((ret = SPI_connect()) &lt; 0)
elog(INFO, "trigf (fired %s): SPI_connect returned %d", when, ret); elog(INFO, "trigf (fired %s): SPI_connect returned %d", when, ret);
/* get number of rows in table */ /* get number of rows in table */
ret = SPI_exec("SELECT count(*) FROM ttest", 0); ret = SPI_exec("SELECT count(*) FROM ttest", 0);
if (ret < 0) if (ret &lt; 0)
elog(NOTICE, "trigf (fired %s): SPI_exec returned %d", when, ret); elog(NOTICE, "trigf (fired %s): SPI_exec returned %d", when, ret);
/* count(*) returns int8, so be careful to convert */ /* count(*) returns int8, so be careful to convert */
@ -622,57 +622,57 @@ CREATE TRIGGER tafter AFTER INSERT OR UPDATE OR DELETE ON ttest
<para> <para>
Now you can test the operation of the trigger: Now you can test the operation of the trigger:
<screen> <screen>
=> INSERT INTO ttest VALUES (NULL); =&gt; INSERT INTO ttest VALUES (NULL);
INFO: trigf (fired before): there are 0 rows in ttest INFO: trigf (fired before): there are 0 rows in ttest
INSERT 0 0 INSERT 0 0
-- Insertion skipped and AFTER trigger is not fired -- Insertion skipped and AFTER trigger is not fired
=> SELECT * FROM ttest; =&gt; SELECT * FROM ttest;
x x
--- ---
(0 rows) (0 rows)
=> INSERT INTO ttest VALUES (1); =&gt; INSERT INTO ttest VALUES (1);
INFO: trigf (fired before): there are 0 rows in ttest INFO: trigf (fired before): there are 0 rows in ttest
INFO: trigf (fired after ): there are 1 rows in ttest INFO: trigf (fired after ): there are 1 rows in ttest
^^^^^^^^ ^^^^^^^^
remember what we said about visibility. remember what we said about visibility.
INSERT 167793 1 INSERT 167793 1
vac=> SELECT * FROM ttest; vac=&gt; SELECT * FROM ttest;
x x
--- ---
1 1
(1 row) (1 row)
=> INSERT INTO ttest SELECT x * 2 FROM ttest; =&gt; INSERT INTO ttest SELECT x * 2 FROM ttest;
INFO: trigf (fired before): there are 1 rows in ttest INFO: trigf (fired before): there are 1 rows in ttest
INFO: trigf (fired after ): there are 2 rows in ttest INFO: trigf (fired after ): there are 2 rows in ttest
^^^^^^ ^^^^^^
remember what we said about visibility. remember what we said about visibility.
INSERT 167794 1 INSERT 167794 1
=> SELECT * FROM ttest; =&gt; SELECT * FROM ttest;
x x
--- ---
1 1
2 2
(2 rows) (2 rows)
=> UPDATE ttest SET x = NULL WHERE x = 2; =&gt; UPDATE ttest SET x = NULL WHERE x = 2;
INFO: trigf (fired before): there are 2 rows in ttest INFO: trigf (fired before): there are 2 rows in ttest
UPDATE 0 UPDATE 0
=> UPDATE ttest SET x = 4 WHERE x = 2; =&gt; UPDATE ttest SET x = 4 WHERE x = 2;
INFO: trigf (fired before): there are 2 rows in ttest INFO: trigf (fired before): there are 2 rows in ttest
INFO: trigf (fired after ): there are 2 rows in ttest INFO: trigf (fired after ): there are 2 rows in ttest
UPDATE 1 UPDATE 1
vac=> SELECT * FROM ttest; vac=&gt; SELECT * FROM ttest;
x x
--- ---
1 1
4 4
(2 rows) (2 rows)
=> DELETE FROM ttest; =&gt; DELETE FROM ttest;
INFO: trigf (fired before): there are 2 rows in ttest INFO: trigf (fired before): there are 2 rows in ttest
INFO: trigf (fired after ): there are 1 rows in ttest INFO: trigf (fired after ): there are 1 rows in ttest
INFO: trigf (fired before): there are 1 rows in ttest INFO: trigf (fired before): there are 1 rows in ttest
@ -680,7 +680,7 @@ INFO: trigf (fired after ): there are 0 rows in ttest
^^^^^^ ^^^^^^
remember what we said about visibility. remember what we said about visibility.
DELETE 2 DELETE 2
=> SELECT * FROM ttest; =&gt; SELECT * FROM ttest;
x x
--- ---
(0 rows) (0 rows)

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.25 2004/11/15 06:32:14 neilc Exp $ $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.26 2005/01/22 22:56:36 momjian Exp $
--> -->
<sect1 id="xaggr"> <sect1 id="xaggr">
@ -141,7 +141,7 @@ CREATE AGGREGATE array_accum (
<programlisting> <programlisting>
SELECT attrelid::regclass, array_accum(attname) SELECT attrelid::regclass, array_accum(attname)
FROM pg_attribute FROM pg_attribute
WHERE attnum > 0 AND attrelid = 'pg_user'::regclass WHERE attnum &gt; 0 AND attrelid = 'pg_user'::regclass
GROUP BY attrelid; GROUP BY attrelid;
attrelid | array_accum attrelid | array_accum
@ -151,7 +151,7 @@ SELECT attrelid::regclass, array_accum(attname)
SELECT attrelid::regclass, array_accum(atttypid) SELECT attrelid::regclass, array_accum(atttypid)
FROM pg_attribute FROM pg_attribute
WHERE attnum > 0 AND attrelid = 'pg_user'::regclass WHERE attnum &gt; 0 AND attrelid = 'pg_user'::regclass
GROUP BY attrelid; GROUP BY attrelid;
attrelid | array_accum attrelid | array_accum

View File

@ -1,5 +1,5 @@
<!-- <!--
$PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.97 2005/01/22 22:06:27 momjian Exp $ $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.98 2005/01/22 22:56:36 momjian Exp $
--> -->
<sect1 id="xfunc"> <sect1 id="xfunc">
@ -678,7 +678,7 @@ ERROR: could not determine "anyarray"/"anyelement" type because input has type
return type, but the converse is not. For example: return type, but the converse is not. For example:
<screen> <screen>
CREATE FUNCTION is_greater(anyelement, anyelement) RETURNS boolean AS $$ CREATE FUNCTION is_greater(anyelement, anyelement) RETURNS boolean AS $$
SELECT $1 > $2; SELECT $1 &gt; $2;
$$ LANGUAGE SQL; $$ LANGUAGE SQL;
SELECT is_greater(1, 2); SELECT is_greater(1, 2);