Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
09a9f10e
Commit
09a9f10e
authored
Feb 01, 2007
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Consistenly use colons before '<programlisting>' blocks, where
appropriate.
parent
e81c138e
Changes
62
Show whitespace changes
Inline
Side-by-side
Showing
62 changed files
with
402 additions
and
405 deletions
+402
-405
doc/src/sgml/advanced.sgml
doc/src/sgml/advanced.sgml
+6
-6
doc/src/sgml/array.sgml
doc/src/sgml/array.sgml
+6
-6
doc/src/sgml/backup.sgml
doc/src/sgml/backup.sgml
+12
-12
doc/src/sgml/bki.sgml
doc/src/sgml/bki.sgml
+2
-2
doc/src/sgml/config.sgml
doc/src/sgml/config.sgml
+2
-2
doc/src/sgml/cvs.sgml
doc/src/sgml/cvs.sgml
+8
-8
doc/src/sgml/datatype.sgml
doc/src/sgml/datatype.sgml
+12
-12
doc/src/sgml/ddl.sgml
doc/src/sgml/ddl.sgml
+27
-27
doc/src/sgml/dfunc.sgml
doc/src/sgml/dfunc.sgml
+5
-5
doc/src/sgml/dml.sgml
doc/src/sgml/dml.sgml
+4
-4
doc/src/sgml/docguide.sgml
doc/src/sgml/docguide.sgml
+3
-3
doc/src/sgml/ecpg.sgml
doc/src/sgml/ecpg.sgml
+17
-17
doc/src/sgml/func.sgml
doc/src/sgml/func.sgml
+3
-3
doc/src/sgml/indices.sgml
doc/src/sgml/indices.sgml
+6
-6
doc/src/sgml/information_schema.sgml
doc/src/sgml/information_schema.sgml
+2
-2
doc/src/sgml/installation.sgml
doc/src/sgml/installation.sgml
+8
-8
doc/src/sgml/libpq.sgml
doc/src/sgml/libpq.sgml
+4
-4
doc/src/sgml/maintenance.sgml
doc/src/sgml/maintenance.sgml
+3
-3
doc/src/sgml/manage-ag.sgml
doc/src/sgml/manage-ag.sgml
+6
-6
doc/src/sgml/monitoring.sgml
doc/src/sgml/monitoring.sgml
+3
-3
doc/src/sgml/nls.sgml
doc/src/sgml/nls.sgml
+9
-9
doc/src/sgml/perform.sgml
doc/src/sgml/perform.sgml
+8
-8
doc/src/sgml/plperl.sgml
doc/src/sgml/plperl.sgml
+4
-4
doc/src/sgml/plpgsql.sgml
doc/src/sgml/plpgsql.sgml
+14
-14
doc/src/sgml/plpython.sgml
doc/src/sgml/plpython.sgml
+4
-4
doc/src/sgml/pltcl.sgml
doc/src/sgml/pltcl.sgml
+7
-8
doc/src/sgml/queries.sgml
doc/src/sgml/queries.sgml
+17
-19
doc/src/sgml/query.sgml
doc/src/sgml/query.sgml
+6
-6
doc/src/sgml/ref/alter_table.sgml
doc/src/sgml/ref/alter_table.sgml
+2
-2
doc/src/sgml/ref/cluster.sgml
doc/src/sgml/ref/cluster.sgml
+2
-2
doc/src/sgml/ref/create_aggregate.sgml
doc/src/sgml/ref/create_aggregate.sgml
+3
-3
doc/src/sgml/ref/create_cast.sgml
doc/src/sgml/ref/create_cast.sgml
+4
-4
doc/src/sgml/ref/create_domain.sgml
doc/src/sgml/ref/create_domain.sgml
+2
-2
doc/src/sgml/ref/create_operator.sgml
doc/src/sgml/ref/create_operator.sgml
+2
-2
doc/src/sgml/ref/create_rule.sgml
doc/src/sgml/ref/create_rule.sgml
+2
-2
doc/src/sgml/ref/create_sequence.sgml
doc/src/sgml/ref/create_sequence.sgml
+2
-2
doc/src/sgml/ref/create_table.sgml
doc/src/sgml/ref/create_table.sgml
+2
-2
doc/src/sgml/ref/create_type.sgml
doc/src/sgml/ref/create_type.sgml
+2
-2
doc/src/sgml/ref/create_view.sgml
doc/src/sgml/ref/create_view.sgml
+3
-3
doc/src/sgml/ref/delete.sgml
doc/src/sgml/ref/delete.sgml
+3
-3
doc/src/sgml/ref/fetch.sgml
doc/src/sgml/ref/fetch.sgml
+2
-2
doc/src/sgml/ref/grant.sgml
doc/src/sgml/ref/grant.sgml
+2
-2
doc/src/sgml/ref/pg_restore.sgml
doc/src/sgml/ref/pg_restore.sgml
+3
-3
doc/src/sgml/ref/psql-ref.sgml
doc/src/sgml/ref/psql-ref.sgml
+8
-8
doc/src/sgml/ref/select.sgml
doc/src/sgml/ref/select.sgml
+3
-3
doc/src/sgml/ref/update.sgml
doc/src/sgml/ref/update.sgml
+2
-2
doc/src/sgml/ref/values.sgml
doc/src/sgml/ref/values.sgml
+2
-2
doc/src/sgml/regress.sgml
doc/src/sgml/regress.sgml
+3
-3
doc/src/sgml/release.sgml
doc/src/sgml/release.sgml
+9
-9
doc/src/sgml/rowtypes.sgml
doc/src/sgml/rowtypes.sgml
+7
-7
doc/src/sgml/rules.sgml
doc/src/sgml/rules.sgml
+41
-41
doc/src/sgml/runtime.sgml
doc/src/sgml/runtime.sgml
+8
-8
doc/src/sgml/sources.sgml
doc/src/sgml/sources.sgml
+8
-8
doc/src/sgml/spi.sgml
doc/src/sgml/spi.sgml
+3
-3
doc/src/sgml/syntax.sgml
doc/src/sgml/syntax.sgml
+19
-19
doc/src/sgml/trigger.sgml
doc/src/sgml/trigger.sgml
+3
-3
doc/src/sgml/user-manag.sgml
doc/src/sgml/user-manag.sgml
+8
-8
doc/src/sgml/xaggr.sgml
doc/src/sgml/xaggr.sgml
+2
-2
doc/src/sgml/xfunc.sgml
doc/src/sgml/xfunc.sgml
+20
-20
doc/src/sgml/xindex.sgml
doc/src/sgml/xindex.sgml
+6
-6
doc/src/sgml/xoper.sgml
doc/src/sgml/xoper.sgml
+3
-3
doc/src/sgml/xplang.sgml
doc/src/sgml/xplang.sgml
+3
-3
No files found.
doc/src/sgml/advanced.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/advanced.sgml,v 1.5
3 2007/01/31 20:56
:16 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/advanced.sgml,v 1.5
4 2007/02/01 00:28
:16 momjian Exp $ -->
<chapter id="tutorial-advanced">
<chapter id="tutorial-advanced">
<title>Advanced Features</title>
<title>Advanced Features</title>
...
@@ -42,7 +42,7 @@
...
@@ -42,7 +42,7 @@
is of particular interest to your application, but you do not want
is of particular interest to your application, but you do not want
to type the query each time you need it. You can create a
to type the query each time you need it. You can create a
<firstterm>view</firstterm> over the query, which gives a name to
<firstterm>view</firstterm> over the query, which gives a name to
the query that you can refer to like an ordinary table
.
the query that you can refer to like an ordinary table
:
<programlisting>
<programlisting>
CREATE VIEW myview AS
CREATE VIEW myview AS
...
@@ -158,7 +158,7 @@ DETAIL: Key (city)=(Berkeley) is not present in table "cities".
...
@@ -158,7 +158,7 @@ DETAIL: Key (city)=(Berkeley) is not present in table "cities".
customer accounts, as well as total deposit balances for branches.
customer accounts, as well as total deposit balances for branches.
Suppose that we want to record a payment of $100.00 from Alice's account
Suppose that we want to record a payment of $100.00 from Alice's account
to Bob's account. Simplifying outrageously, the SQL commands for this
to Bob's account. Simplifying outrageously, the SQL commands for this
might look like
might look like
:
<programlisting>
<programlisting>
UPDATE accounts SET balance = balance - 100.00
UPDATE accounts SET balance = balance - 100.00
...
@@ -219,7 +219,7 @@ UPDATE branches SET balance = balance + 100.00
...
@@ -219,7 +219,7 @@ UPDATE branches SET balance = balance + 100.00
In <productname>PostgreSQL</>, a transaction is set up by surrounding
In <productname>PostgreSQL</>, a transaction is set up by surrounding
the SQL commands of the transaction with
the SQL commands of the transaction with
<command>BEGIN</> and <command>COMMIT</> commands. So our banking
<command>BEGIN</> and <command>COMMIT</> commands. So our banking
transaction would actually look like
transaction would actually look like
:
<programlisting>
<programlisting>
BEGIN;
BEGIN;
...
@@ -392,7 +392,7 @@ CREATE TABLE capitals (
...
@@ -392,7 +392,7 @@ CREATE TABLE capitals (
<para>
<para>
For example, the following query finds the names of all cities,
For example, the following query finds the names of all cities,
including state capitals, that are located at an altitude
including state capitals, that are located at an altitude
over 500 f
t.
:
over 500 f
eet
:
<programlisting>
<programlisting>
SELECT name, altitude
SELECT name, altitude
...
@@ -415,7 +415,7 @@ SELECT name, altitude
...
@@ -415,7 +415,7 @@ SELECT name, altitude
<para>
<para>
On the other hand, the following query finds
On the other hand, the following query finds
all the cities that are not state capitals and
all the cities that are not state capitals and
are situated at an altitude of 500 f
t.
or higher:
are situated at an altitude of 500 f
eet
or higher:
<programlisting>
<programlisting>
SELECT name, altitude
SELECT name, altitude
...
...
doc/src/sgml/array.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.5
5 2007/01/31 20:56
:16 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/array.sgml,v 1.5
6 2007/02/01 00:28
:16 momjian Exp $ -->
<sect1 id="arrays">
<sect1 id="arrays">
<title>Arrays</title>
<title>Arrays</title>
...
@@ -102,7 +102,7 @@ CREATE TABLE tictactoe (
...
@@ -102,7 +102,7 @@ CREATE TABLE tictactoe (
<literal>box</> uses a semicolon (<literal>;</>) but all the others
<literal>box</> uses a semicolon (<literal>;</>) but all the others
use comma (<literal>,</>). Each <replaceable>val</replaceable> is
use comma (<literal>,</>). Each <replaceable>val</replaceable> is
either a constant of the array element type, or a subarray. An example
either a constant of the array element type, or a subarray. An example
of an array constant is
of an array constant is
:
<programlisting>
<programlisting>
'{{1,2,3},{4,5,6},{7,8,9}}'
'{{1,2,3},{4,5,6},{7,8,9}}'
</programlisting>
</programlisting>
...
@@ -126,7 +126,7 @@ CREATE TABLE tictactoe (
...
@@ -126,7 +126,7 @@ CREATE TABLE tictactoe (
</para>
</para>
<para>
<para>
Now we can show some <command>INSERT</command> statements
.
Now we can show some <command>INSERT</command> statements
:
<programlisting>
<programlisting>
INSERT INTO sal_emp
INSERT INTO sal_emp
...
@@ -302,7 +302,7 @@ SELECT array_dims(schedule) FROM sal_emp WHERE name = 'Carol';
...
@@ -302,7 +302,7 @@ SELECT array_dims(schedule) FROM sal_emp WHERE name = 'Carol';
for programs. Dimensions can also be retrieved with
for programs. Dimensions can also be retrieved with
<function>array_upper</function> and <function>array_lower</function>,
<function>array_upper</function> and <function>array_lower</function>,
which return the upper and lower bound of a
which return the upper and lower bound of a
specified array dimension, respectively
.
specified array dimension, respectively
:
<programlisting>
<programlisting>
SELECT array_upper(schedule, 1) FROM sal_emp WHERE name = 'Carol';
SELECT array_upper(schedule, 1) FROM sal_emp WHERE name = 'Carol';
...
@@ -368,7 +368,7 @@ UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
...
@@ -368,7 +368,7 @@ UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
<para>
<para>
New array values can also be constructed by using the concatenation operator,
New array values can also be constructed by using the concatenation operator,
<literal>||</literal>
.
<literal>||</literal>
:
<programlisting>
<programlisting>
SELECT ARRAY[1,2] || ARRAY[3,4];
SELECT ARRAY[1,2] || ARRAY[3,4];
?column?
?column?
...
@@ -623,7 +623,7 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
...
@@ -623,7 +623,7 @@ SELECT f1[1][-2][3] AS e1, f1[1][-1][5] AS e2
Remember that what you write in an SQL command will first be interpreted
Remember that what you write in an SQL command will first be interpreted
as a string literal, and then as an array. This doubles the number of
as a string literal, and then as an array. This doubles the number of
backslashes you need. For example, to insert a <type>text</> array
backslashes you need. For example, to insert a <type>text</> array
value containing a backslash and a double quote, you'd need to write
value containing a backslash and a double quote, you'd need to write
:
<programlisting>
<programlisting>
INSERT ... VALUES (E'{"\\\\","\\""}');
INSERT ... VALUES (E'{"\\\\","\\""}');
</programlisting>
</programlisting>
...
...
doc/src/sgml/backup.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.9
6 2007/01/31 20:56
:16 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/backup.sgml,v 2.9
7 2007/02/01 00:28
:16 momjian Exp $ -->
<chapter id="backup">
<chapter id="backup">
<title>Backup and Restore</title>
<title>Backup and Restore</title>
...
@@ -221,20 +221,20 @@ psql -f <replaceable class="parameter">infile</replaceable> postgres
...
@@ -221,20 +221,20 @@ psql -f <replaceable class="parameter">infile</replaceable> postgres
<title>Use compressed dumps.</title>
<title>Use compressed dumps.</title>
<para>
<para>
You can use your favorite compression program, for example
You can use your favorite compression program, for example
<application>gzip</application>
.
<application>gzip</application>
:
<programlisting>
<programlisting>
pg_dump <replaceable class="parameter">dbname</replaceable> | gzip > <replaceable class="parameter">filename</replaceable>.gz
pg_dump <replaceable class="parameter">dbname</replaceable> | gzip > <replaceable class="parameter">filename</replaceable>.gz
</programlisting>
</programlisting>
Reload with
Reload with
:
<programlisting>
<programlisting>
createdb <replaceable class="parameter">dbname</replaceable>
createdb <replaceable class="parameter">dbname</replaceable>
gunzip -c <replaceable class="parameter">filename</replaceable>.gz | psql <replaceable class="parameter">dbname</replaceable>
gunzip -c <replaceable class="parameter">filename</replaceable>.gz | psql <replaceable class="parameter">dbname</replaceable>
</programlisting>
</programlisting>
or
or
:
<programlisting>
<programlisting>
cat <replaceable class="parameter">filename</replaceable>.gz | gunzip | psql <replaceable class="parameter">dbname</replaceable>
cat <replaceable class="parameter">filename</replaceable>.gz | gunzip | psql <replaceable class="parameter">dbname</replaceable>
...
@@ -254,7 +254,7 @@ cat <replaceable class="parameter">filename</replaceable>.gz | gunzip | psql <re
...
@@ -254,7 +254,7 @@ cat <replaceable class="parameter">filename</replaceable>.gz | gunzip | psql <re
pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 1m - <replaceable class="parameter">filename</replaceable>
pg_dump <replaceable class="parameter">dbname</replaceable> | split -b 1m - <replaceable class="parameter">filename</replaceable>
</programlisting>
</programlisting>
Reload with
Reload with
:
<programlisting>
<programlisting>
createdb <replaceable class="parameter">dbname</replaceable>
createdb <replaceable class="parameter">dbname</replaceable>
...
@@ -296,7 +296,7 @@ pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceabl
...
@@ -296,7 +296,7 @@ pg_dump -Fc <replaceable class="parameter">dbname</replaceable> > <replaceabl
<xref linkend="creating-cluster"> it is explained where these files
<xref linkend="creating-cluster"> it is explained where these files
are located, but you have probably found them already if you are
are located, but you have probably found them already if you are
interested in this method. You can use whatever method you prefer
interested in this method. You can use whatever method you prefer
for doing usual file system backups, for example
for doing usual file system backups, for example
:
<programlisting>
<programlisting>
tar -cf backup.tar /usr/local/pgsql/data
tar -cf backup.tar /usr/local/pgsql/data
...
@@ -528,7 +528,7 @@ tar -cf backup.tar /usr/local/pgsql/data
...
@@ -528,7 +528,7 @@ tar -cf backup.tar /usr/local/pgsql/data
i.e., the cluster's data directory.)
i.e., the cluster's data directory.)
Write <literal>%%</> if you need to embed an actual <literal>%</>
Write <literal>%%</> if you need to embed an actual <literal>%</>
character in the command. The simplest useful command is something
character in the command. The simplest useful command is something
like
like
:
<programlisting>
<programlisting>
archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null'
archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null'
</programlisting>
</programlisting>
...
@@ -568,7 +568,7 @@ archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null'
...
@@ -568,7 +568,7 @@ archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null'
this correctly on some platforms but not others. If the chosen command
this correctly on some platforms but not others. If the chosen command
does not itself handle this case correctly, you should add a command
does not itself handle this case correctly, you should add a command
to test for pre-existence of the archive file. For example, something
to test for pre-existence of the archive file. For example, something
like
like
:
<programlisting>
<programlisting>
archive_command = 'test ! -f .../%f && cp %p .../%f'
archive_command = 'test ! -f .../%f && cp %p .../%f'
</programlisting>
</programlisting>
...
@@ -657,7 +657,7 @@ archive_command = 'test ! -f .../%f && cp %p .../%f'
...
@@ -657,7 +657,7 @@ archive_command = 'test ! -f .../%f && cp %p .../%f'
</listitem>
</listitem>
<listitem>
<listitem>
<para>
<para>
Connect to the database as a superuser, and issue the command
Connect to the database as a superuser, and issue the command
:
<programlisting>
<programlisting>
SELECT pg_start_backup('label');
SELECT pg_start_backup('label');
</programlisting>
</programlisting>
...
@@ -685,7 +685,7 @@ SELECT pg_start_backup('label');
...
@@ -685,7 +685,7 @@ SELECT pg_start_backup('label');
</listitem>
</listitem>
<listitem>
<listitem>
<para>
<para>
Again connect to the database as a superuser, and issue the command
Again connect to the database as a superuser, and issue the command
:
<programlisting>
<programlisting>
SELECT pg_stop_backup();
SELECT pg_stop_backup();
</programlisting>
</programlisting>
...
@@ -924,7 +924,7 @@ SELECT pg_stop_backup();
...
@@ -924,7 +924,7 @@ SELECT pg_stop_backup();
i.e., the cluster's data directory.)
i.e., the cluster's data directory.)
Write <literal>%%</> if you need to embed an actual <literal>%</>
Write <literal>%%</> if you need to embed an actual <literal>%</>
character in the command. The simplest useful command is
character in the command. The simplest useful command is
something like
something like
:
<programlisting>
<programlisting>
restore_command = 'cp /mnt/server/archivedir/%f %p'
restore_command = 'cp /mnt/server/archivedir/%f %p'
</programlisting>
</programlisting>
...
@@ -1669,7 +1669,7 @@ if (!triggered)
...
@@ -1669,7 +1669,7 @@ if (!triggered)
<para>
<para>
The least downtime can be achieved by installing the new server in
The least downtime can be achieved by installing the new server in
a different directory and running both the old and the new servers
a different directory and running both the old and the new servers
in parallel, on different ports. Then you can use something like
in parallel, on different ports. Then you can use something like
:
<programlisting>
<programlisting>
pg_dumpall -p 5432 | psql -d postgres -p 6543
pg_dumpall -p 5432 | psql -d postgres -p 6543
...
...
doc/src/sgml/bki.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.2
0 2007/01/31 20:56
:16 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/bki.sgml,v 1.2
1 2007/02/01 00:28
:16 momjian Exp $ -->
<chapter id="bki">
<chapter id="bki">
<title><acronym>BKI</acronym> Backend Interface</title>
<title><acronym>BKI</acronym> Backend Interface</title>
...
@@ -338,7 +338,7 @@
...
@@ -338,7 +338,7 @@
table <literal>test_table</literal> with OID 420, having two columns
table <literal>test_table</literal> with OID 420, having two columns
<literal>cola</literal> and <literal>colb</literal> of type
<literal>cola</literal> and <literal>colb</literal> of type
<type>int4</type> and <type>text</type>, respectively, and insert
<type>int4</type> and <type>text</type>, respectively, and insert
two rows into the table
.
two rows into the table
:
<programlisting>
<programlisting>
create test_table 420 (cola = int4, colb = text)
create test_table 420 (cola = int4, colb = text)
open test_table
open test_table
...
...
doc/src/sgml/config.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.10
7 2007/01/31 20:56
:16 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.10
8 2007/02/01 00:28
:16 momjian Exp $ -->
<chapter Id="runtime-config">
<chapter Id="runtime-config">
<title>Server Configuration</title>
<title>Server Configuration</title>
...
@@ -71,7 +71,7 @@ shared_buffers = 128MB
...
@@ -71,7 +71,7 @@ shared_buffers = 128MB
In addition to parameter settings, the <filename>postgresql.conf</>
In addition to parameter settings, the <filename>postgresql.conf</>
file can contain <firstterm>include directives</>, which specify
file can contain <firstterm>include directives</>, which specify
another file to read and process as if it were inserted into the
another file to read and process as if it were inserted into the
configuration file at this point. Include directives simply look like
configuration file at this point. Include directives simply look like
:
<programlisting>
<programlisting>
include 'filename'
include 'filename'
</programlisting>
</programlisting>
...
...
doc/src/sgml/cvs.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/cvs.sgml,v 1.4
0 2007/01/31 20:56
:16 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/cvs.sgml,v 1.4
1 2007/02/01 00:28
:16 momjian Exp $ -->
<appendix id="cvs">
<appendix id="cvs">
<appendixinfo>
<appendixinfo>
...
@@ -109,7 +109,7 @@ cvs -z3 -d :pserver:anoncvs@anoncvs.postgresql.org:/projects/cvsroot co -P pgsql
...
@@ -109,7 +109,7 @@ cvs -z3 -d :pserver:anoncvs@anoncvs.postgresql.org:/projects/cvsroot co -P pgsql
<para>
<para>
Whenever you want to update to the latest <productname>CVS</productname> sources,
Whenever you want to update to the latest <productname>CVS</productname> sources,
<command>cd</command> into
<command>cd</command> into
the <filename>pgsql</filename> subdirectory, and issue
the <filename>pgsql</filename> subdirectory, and issue
:
<programlisting>
<programlisting>
cvs -z3 update -d -P
cvs -z3 update -d -P
</programlisting>
</programlisting>
...
@@ -123,7 +123,7 @@ cvs -z3 update -d -P
...
@@ -123,7 +123,7 @@ cvs -z3 update -d -P
<step>
<step>
<para>
<para>
You can save yourself some typing by making a file <filename>.cvsrc</filename>
You can save yourself some typing by making a file <filename>.cvsrc</filename>
in your home directory that contains
in your home directory that contains
:
<programlisting>
<programlisting>
cvs -z3
cvs -z3
...
@@ -132,7 +132,7 @@ update -d -P
...
@@ -132,7 +132,7 @@ update -d -P
This supplies the <option>-z3</option> option to all <command>cvs</> commands, and the
This supplies the <option>-z3</option> option to all <command>cvs</> commands, and the
<option>-d</option> and <option>-P</option> options to <command>cvs update</>. Then you just have
<option>-d</option> and <option>-P</option> options to <command>cvs update</>. Then you just have
to say
to say
:
<programlisting>
<programlisting>
cvs update
cvs update
</programlisting>
</programlisting>
...
@@ -252,14 +252,14 @@ cvs checkout -P pgsql
...
@@ -252,14 +252,14 @@ cvs checkout -P pgsql
</para>
</para>
<para>
<para>
After you've done the initial checkout on a branch
After you've done the initial checkout on a branch
:
<programlisting>
<programlisting>
cvs checkout -r REL6_4
cvs checkout -r REL6_4
</programlisting>
</programlisting>
anything you do within that directory structure is restricted to that
anything you do within that directory structure is restricted to that
branch. If you apply a patch to that directory structure and do a
branch. If you apply a patch to that directory structure and do a
:
<programlisting>
<programlisting>
cvs commit
cvs commit
...
@@ -312,7 +312,7 @@ cvs commit
...
@@ -312,7 +312,7 @@ cvs commit
but had formerly kept it under a
but had formerly kept it under a
<productname>PostgreSQL</productname> development tree in
<productname>PostgreSQL</productname> development tree in
<filename>/opt/postgres/cvs/</filename>. If you intend to keep your
<filename>/opt/postgres/cvs/</filename>. If you intend to keep your
repository in <filename>/home/cvs/</filename>, then put
repository in <filename>/home/cvs/</filename>, then put
:
<programlisting>
<programlisting>
setenv CVSROOT /home/cvs
setenv CVSROOT /home/cvs
...
@@ -349,7 +349,7 @@ CVSROOT/
...
@@ -349,7 +349,7 @@ CVSROOT/
<para>
<para>
Verify that
Verify that
<application>cvsup</application> is in your path; on most systems
<application>cvsup</application> is in your path; on most systems
you can do this by typing
you can do this by typing
:
<programlisting>
<programlisting>
which cvsup
which cvsup
...
...
doc/src/sgml/datatype.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.1
89 2007/01/31 20:56
:16 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/datatype.sgml,v 1.1
90 2007/02/01 00:28
:16 momjian Exp $ -->
<chapter id="datatype">
<chapter id="datatype">
<title id="datatype-title">Data Types</title>
<title id="datatype-title">Data Types</title>
...
@@ -476,16 +476,16 @@
...
@@ -476,16 +476,16 @@
Both the maximum precision and the maximum scale of a
Both the maximum precision and the maximum scale of a
<type>numeric</type> column can be
<type>numeric</type> column can be
configured. To declare a column of type <type>numeric</type> use
configured. To declare a column of type <type>numeric</type> use
the syntax
the syntax
:
<programlisting>
<programlisting>
NUMERIC(<replaceable>precision</replaceable>, <replaceable>scale</replaceable>)
NUMERIC(<replaceable>precision</replaceable>, <replaceable>scale</replaceable>)
</programlisting>
</programlisting>
The precision must be positive, the scale zero or positive.
The precision must be positive, the scale zero or positive.
Alternatively
,
Alternatively
:
<programlisting>
<programlisting>
NUMERIC(<replaceable>precision</replaceable>)
NUMERIC(<replaceable>precision</replaceable>)
</programlisting>
</programlisting>
selects a scale of 0. Specifying
selects a scale of 0. Specifying
:
<programlisting>
<programlisting>
NUMERIC
NUMERIC
</programlisting>
</programlisting>
...
@@ -741,7 +741,7 @@ NUMERIC
...
@@ -741,7 +741,7 @@ NUMERIC
a notational convenience for setting up unique identifier columns
a notational convenience for setting up unique identifier columns
(similar to the <literal>AUTO_INCREMENT</literal> property
(similar to the <literal>AUTO_INCREMENT</literal> property
supported by some other databases). In the current
supported by some other databases). In the current
implementation, specifying
implementation, specifying
:
<programlisting>
<programlisting>
CREATE TABLE <replaceable class="parameter">tablename</replaceable> (
CREATE TABLE <replaceable class="parameter">tablename</replaceable> (
...
@@ -1787,18 +1787,18 @@ SELECT b, char_length(b) FROM test2;
...
@@ -1787,18 +1787,18 @@ SELECT b, char_length(b) FROM test2;
followed by an optional <literal>AD</literal> or <literal>BC</literal>.
followed by an optional <literal>AD</literal> or <literal>BC</literal>.
(Alternatively, <literal>AD</literal>/<literal>BC</literal> can appear
(Alternatively, <literal>AD</literal>/<literal>BC</literal> can appear
before the time zone, but this is not the preferred ordering.)
before the time zone, but this is not the preferred ordering.)
Thus
Thus
:
<programlisting>
<programlisting>
1999-01-08 04:05:06
1999-01-08 04:05:06
</programlisting>
</programlisting>
and
and
:
<programlisting>
<programlisting>
1999-01-08 04:05:06 -8:00
1999-01-08 04:05:06 -8:00
</programlisting>
</programlisting>
are valid values, which follow the <acronym>ISO</acronym> 8601
are valid values, which follow the <acronym>ISO</acronym> 8601
standard. In addition, the wide-spread format
standard. In addition, the wide-spread format
:
<programlisting>
<programlisting>
January 8 04:05:06 1999 PST
January 8 04:05:06 1999 PST
</programlisting>
</programlisting>
...
@@ -2113,7 +2113,7 @@ January 8 04:05:06 1999 PST
...
@@ -2113,7 +2113,7 @@ January 8 04:05:06 1999 PST
that units like <literal>century</literal> or
that units like <literal>century</literal> or
<literal>week</literal> are converted to years and days and
<literal>week</literal> are converted to years and days and
<literal>ago</literal> is converted to an appropriate sign. In
<literal>ago</literal> is converted to an appropriate sign. In
ISO mode the output looks like
ISO mode the output looks like
:
<programlisting>
<programlisting>
<optional> <replaceable>quantity</> <replaceable>unit</> <optional> ... </> </> <optional> <replaceable>days</> </> <optional> <replaceable>hours</>:<replaceable>minutes</>:<replaceable>seconds</> </optional>
<optional> <replaceable>quantity</> <replaceable>unit</> <optional> ... </> </> <optional> <replaceable>days</> </> <optional> <replaceable>hours</>:<replaceable>minutes</>:<replaceable>seconds</> </optional>
...
@@ -3115,11 +3115,11 @@ SELECT * FROM test;
...
@@ -3115,11 +3115,11 @@ SELECT * FROM test;
the raw numeric value that type <type>oid</> would use. The alias
the raw numeric value that type <type>oid</> would use. The alias
types allow simplified lookup of OID values for objects. For example,
types allow simplified lookup of OID values for objects. For example,
to examine the <structname>pg_attribute</> rows related to a table
to examine the <structname>pg_attribute</> rows related to a table
<literal>mytable</>, one could write
<literal>mytable</>, one could write
:
<programlisting>
<programlisting>
SELECT * FROM pg_attribute WHERE attrelid = 'mytable'::regclass;
SELECT * FROM pg_attribute WHERE attrelid = 'mytable'::regclass;
</programlisting>
</programlisting>
rather than
rather than
:
<programlisting>
<programlisting>
SELECT * FROM pg_attribute
SELECT * FROM pg_attribute
WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'mytable');
WHERE attrelid = (SELECT oid FROM pg_class WHERE relname = 'mytable');
...
@@ -3444,7 +3444,7 @@ XMLPARSE (CONTENT 'abc<foo>bar</bar><bar>foo</foo>')
...
@@ -3444,7 +3444,7 @@ XMLPARSE (CONTENT 'abc<foo>bar</bar><bar>foo</foo>')
]]></programlisting>
]]></programlisting>
While this is the only way to convert character strings into XML
While this is the only way to convert character strings into XML
values according to the SQL standard, the PostgreSQL-specific
values according to the SQL standard, the PostgreSQL-specific
syntaxes
syntaxes
:
<programlisting><![CDATA[
<programlisting><![CDATA[
xml '<foo>bar</foo>'
xml '<foo>bar</foo>'
'<foo>bar</foo>'::xml
'<foo>bar</foo>'::xml
...
...
doc/src/sgml/ddl.sgml
View file @
09a9f10e
<
!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.7
2 2007/01/31 20:56
:16 momjian Exp $ -->
<
!-- $PostgreSQL: pgsql/doc/src/sgml/ddl.sgml,v 1.7
3 2007/02/01 00:28
:16 momjian Exp $ -->
<
chapter
id
=
"ddl"
>
<
chapter
id
=
"ddl"
>
<
title
>
Data
Definition
</
title
>
<
title
>
Data
Definition
</
title
>
...
@@ -210,7 +210,7 @@ CREATE TABLE products (
...
@@ -210,7 +210,7 @@ CREATE TABLE products (
so
that
it
gets
set
to
the
time
of
row
insertion
.
Another
common
so
that
it
gets
set
to
the
time
of
row
insertion
.
Another
common
example
is
generating
a
<
quote
>
serial
number
</>
for
each
row
.
example
is
generating
a
<
quote
>
serial
number
</>
for
each
row
.
In
<
productname
>
PostgreSQL
</
productname
>
this
is
typically
done
by
In
<
productname
>
PostgreSQL
</
productname
>
this
is
typically
done
by
something
like
something
like
:
<
programlisting
>
<
programlisting
>
CREATE
TABLE
products
(
CREATE
TABLE
products
(
product_no
integer
<
emphasis
>
DEFAULT
nextval
(
'products_product_no_seq'
)</
emphasis
>,
product_no
integer
<
emphasis
>
DEFAULT
nextval
(
'products_product_no_seq'
)</
emphasis
>,
...
@@ -319,7 +319,7 @@ CREATE TABLE products (
...
@@ -319,7 +319,7 @@ CREATE TABLE products (
<
para
>
<
para
>
A
check
constraint
can
also
refer
to
several
columns
.
Say
you
A
check
constraint
can
also
refer
to
several
columns
.
Say
you
store
a
regular
price
and
a
discounted
price
,
and
you
want
to
store
a
regular
price
and
a
discounted
price
,
and
you
want
to
ensure
that
the
discounted
price
is
lower
than
the
regular
price
.
ensure
that
the
discounted
price
is
lower
than
the
regular
price
:
<
programlisting
>
<
programlisting
>
CREATE
TABLE
products
(
CREATE
TABLE
products
(
product_no
integer
,
product_no
integer
,
...
@@ -348,7 +348,7 @@ CREATE TABLE products (
...
@@ -348,7 +348,7 @@ CREATE TABLE products (
column
it
is
attached
to
.
(<
productname
>
PostgreSQL
</
productname
>
doesn
't
column
it
is
attached
to
.
(<
productname
>
PostgreSQL
</
productname
>
doesn
't
enforce that rule, but you should follow it if you want your table
enforce that rule, but you should follow it if you want your table
definitions to work with other database systems.) The above example could
definitions to work with other database systems.) The above example could
also be written as
also be written as
:
<programlisting>
<programlisting>
CREATE TABLE products (
CREATE TABLE products (
product_no integer,
product_no integer,
...
@@ -360,7 +360,7 @@ CREATE TABLE products (
...
@@ -360,7 +360,7 @@ CREATE TABLE products (
CHECK (price > discounted_price)
CHECK (price > discounted_price)
);
);
</programlisting>
</programlisting>
or even
or even
:
<programlisting>
<programlisting>
CREATE TABLE products (
CREATE TABLE products (
product_no integer,
product_no integer,
...
@@ -463,7 +463,7 @@ CREATE TABLE products (
...
@@ -463,7 +463,7 @@ CREATE TABLE products (
only added to <productname>PostgreSQL</productname> to be
only added to <productname>PostgreSQL</productname> to be
compatible with some other database systems.) Some users, however,
compatible with some other database systems.) Some users, however,
like it because it makes it easy to toggle the constraint in a
like it because it makes it easy to toggle the constraint in a
script file. For example, you could start with
script file. For example, you could start with
:
<programlisting>
<programlisting>
CREATE TABLE products (
CREATE TABLE products (
product_no integer NULL,
product_no integer NULL,
...
@@ -497,7 +497,7 @@ CREATE TABLE products (
...
@@ -497,7 +497,7 @@ CREATE TABLE products (
<para>
<para>
Unique constraints ensure that the data contained in a column or a
Unique constraints ensure that the data contained in a column or a
group of columns is unique with respect to all the rows in the
group of columns is unique with respect to all the rows in the
table. The syntax is
table. The syntax is
:
<programlisting>
<programlisting>
CREATE TABLE products (
CREATE TABLE products (
product_no integer <emphasis>UNIQUE</emphasis>,
product_no integer <emphasis>UNIQUE</emphasis>,
...
@@ -505,7 +505,7 @@ CREATE TABLE products (
...
@@ -505,7 +505,7 @@ CREATE TABLE products (
price numeric
price numeric
);
);
</programlisting>
</programlisting>
when written as a column constraint, and
when written as a column constraint, and
:
<programlisting>
<programlisting>
CREATE TABLE products (
CREATE TABLE products (
product_no integer,
product_no integer,
...
@@ -691,7 +691,7 @@ CREATE TABLE orders (
...
@@ -691,7 +691,7 @@ CREATE TABLE orders (
</para>
</para>
<para>
<para>
You can also shorten the above command to
You can also shorten the above command to
:
<programlisting>
<programlisting>
CREATE TABLE orders (
CREATE TABLE orders (
order_id integer PRIMARY KEY,
order_id integer PRIMARY KEY,
...
@@ -781,7 +781,7 @@ CREATE TABLE order_items (
...
@@ -781,7 +781,7 @@ CREATE TABLE order_items (
many
-
to
-
many
relationship
example
above
:
when
someone
wants
to
many
-
to
-
many
relationship
example
above
:
when
someone
wants
to
remove
a
product
that
is
still
referenced
by
an
order
(
via
remove
a
product
that
is
still
referenced
by
an
order
(
via
<
literal
>
order_items
</
literal
>),
we
disallow
it
.
If
someone
<
literal
>
order_items
</
literal
>),
we
disallow
it
.
If
someone
removes
an
order
,
the
order
items
are
removed
as
well
.
removes
an
order
,
the
order
items
are
removed
as
well
:
<
programlisting
>
<
programlisting
>
CREATE
TABLE
products
(
CREATE
TABLE
products
(
product_no
integer
PRIMARY
KEY
,
product_no
integer
PRIMARY
KEY
,
...
@@ -1230,7 +1230,7 @@ ALTER TABLE products DROP CONSTRAINT some_name;
...
@@ -1230,7 +1230,7 @@ ALTER TABLE products DROP CONSTRAINT some_name;
<para>
<para>
This works the same for all constraint types except not-null
This works the same for all constraint types except not-null
constraints. To drop a not null constraint use
constraints. To drop a not null constraint use
:
<programlisting>
<programlisting>
ALTER TABLE products ALTER COLUMN product_no DROP NOT NULL;
ALTER TABLE products ALTER COLUMN product_no DROP NOT NULL;
</programlisting>
</programlisting>
...
@@ -1256,7 +1256,7 @@ ALTER TABLE products ALTER COLUMN price SET DEFAULT 7.77;
...
@@ -1256,7 +1256,7 @@ ALTER TABLE products ALTER COLUMN price SET DEFAULT 7.77;
</para>
</para>
<para>
<para>
To remove any default value, use
To remove any default value, use
:
<programlisting>
<programlisting>
ALTER TABLE products ALTER COLUMN price DROP DEFAULT;
ALTER TABLE products ALTER COLUMN price DROP DEFAULT;
</programlisting>
</programlisting>
...
@@ -1383,7 +1383,7 @@ ALTER TABLE products RENAME TO items;
...
@@ -1383,7 +1383,7 @@ ALTER TABLE products RENAME TO items;
To
assign
privileges
,
the
<
command
>
GRANT
</
command
>
command
is
To
assign
privileges
,
the
<
command
>
GRANT
</
command
>
command
is
used
.
For
example
,
if
<
literal
>
joe
</
literal
>
is
an
existing
user
,
and
used
.
For
example
,
if
<
literal
>
joe
</
literal
>
is
an
existing
user
,
and
<
literal
>
accounts
</
literal
>
is
an
existing
table
,
the
privilege
to
<
literal
>
accounts
</
literal
>
is
an
existing
table
,
the
privilege
to
update
the
table
can
be
granted
with
update
the
table
can
be
granted
with
:
<
programlisting
>
<
programlisting
>
GRANT
UPDATE
ON
accounts
TO
joe
;
GRANT
UPDATE
ON
accounts
TO
joe
;
</
programlisting
>
</
programlisting
>
...
@@ -1545,7 +1545,7 @@ CREATE SCHEMA myschema;
...
@@ -1545,7 +1545,7 @@ CREATE SCHEMA myschema;
</para>
</para>
<para>
<para>
So to create a table in the new schema, use
So to create a table in the new schema, use
:
<programlisting>
<programlisting>
CREATE TABLE myschema.mytable (
CREATE TABLE myschema.mytable (
...
...
...
@@ -1560,11 +1560,11 @@ CREATE TABLE myschema.mytable (
...
@@ -1560,11 +1560,11 @@ CREATE TABLE myschema.mytable (
<para>
<para>
To drop a schema if it'
s
empty
(
all
objects
in
it
have
been
To drop a schema if it'
s
empty
(
all
objects
in
it
have
been
dropped
),
use
dropped
),
use
:
<
programlisting
>
<
programlisting
>
DROP
SCHEMA
myschema
;
DROP
SCHEMA
myschema
;
</
programlisting
>
</
programlisting
>
To
drop
a
schema
including
all
contained
objects
,
use
To
drop
a
schema
including
all
contained
objects
,
use
:
<
programlisting
>
<
programlisting
>
DROP
SCHEMA
myschema
CASCADE
;
DROP
SCHEMA
myschema
CASCADE
;
</
programlisting
>
</
programlisting
>
...
@@ -1606,7 +1606,7 @@ CREATE SCHEMA <replaceable>schemaname</replaceable> AUTHORIZATION <replaceable>u
...
@@ -1606,7 +1606,7 @@ CREATE SCHEMA <replaceable>schemaname</replaceable> AUTHORIZATION <replaceable>u
<
programlisting
>
<
programlisting
>
CREATE
TABLE
products
(
...
);
CREATE
TABLE
products
(
...
);
</
programlisting
>
</
programlisting
>
and
and
:
<
programlisting
>
<
programlisting
>
CREATE
TABLE
public
.
products
(
...
);
CREATE
TABLE
public
.
products
(
...
);
</
programlisting
>
</
programlisting
>
...
@@ -1686,7 +1686,7 @@ SHOW search_path;
...
@@ -1686,7 +1686,7 @@ SHOW search_path;
</para>
</para>
<para>
<para>
To put our new schema in the path, we use
To put our new schema in the path, we use
:
<programlisting>
<programlisting>
SET search_path TO myschema,public;
SET search_path TO myschema,public;
</programlisting>
</programlisting>
...
@@ -1701,7 +1701,7 @@ DROP TABLE mytable;
...
@@ -1701,7 +1701,7 @@ DROP TABLE mytable;
</para>
</para>
<para>
<para>
We could also have written
We could also have written
:
<programlisting>
<programlisting>
SET search_path TO myschema;
SET search_path TO myschema;
</programlisting>
</programlisting>
...
@@ -1724,7 +1724,7 @@ SET search_path TO myschema;
...
@@ -1724,7 +1724,7 @@ SET search_path TO myschema;
<synopsis>
<synopsis>
<literal>OPERATOR(</><replaceable>schema</><literal>.</><replaceable>operator</><literal>)</>
<literal>OPERATOR(</><replaceable>schema</><literal>.</><replaceable>operator</><literal>)</>
</synopsis>
</synopsis>
This is needed to avoid syntactic ambiguity. An example is
This is needed to avoid syntactic ambiguity. An example is
:
<programlisting>
<programlisting>
SELECT 3 OPERATOR(pg_catalog.+) 4;
SELECT 3 OPERATOR(pg_catalog.+) 4;
</programlisting>
</programlisting>
...
@@ -1946,7 +1946,7 @@ CREATE TABLE capitals (
...
@@ -1946,7 +1946,7 @@ CREATE TABLE capitals (
The
latter
behavior
is
the
default
.
The
latter
behavior
is
the
default
.
For
example
,
the
following
query
finds
the
names
of
all
cities
,
For
example
,
the
following
query
finds
the
names
of
all
cities
,
including
state
capitals
,
that
are
located
at
an
altitude
over
including
state
capitals
,
that
are
located
at
an
altitude
over
500
f
t
:
500
fee
t
:
<
programlisting
>
<
programlisting
>
SELECT
name
,
altitude
SELECT
name
,
altitude
...
@@ -1968,7 +1968,7 @@ SELECT name, altitude
...
@@ -1968,7 +1968,7 @@ SELECT name, altitude
<
para
>
<
para
>
On
the
other
hand
,
the
following
query
finds
all
the
cities
that
On
the
other
hand
,
the
following
query
finds
all
the
cities
that
are
not
state
capitals
and
are
situated
at
an
altitude
over
500
f
t
:
are
not
state
capitals
and
are
situated
at
an
altitude
over
500
fee
t
:
<
programlisting
>
<
programlisting
>
SELECT
name
,
altitude
SELECT
name
,
altitude
...
@@ -2511,7 +2511,7 @@ CREATE INDEX measurement_y2006m01_logdate ON measurement_y2006m01 (logdate);
...
@@ -2511,7 +2511,7 @@ CREATE INDEX measurement_y2006m01_logdate ON measurement_y2006m01 (logdate);
If
data
will
be
added
only
to
the
latest
partition
,
we
can
If
data
will
be
added
only
to
the
latest
partition
,
we
can
set
up
a
very
simple
rule
to
insert
data
.
We
must
set
up
a
very
simple
rule
to
insert
data
.
We
must
redefine
this
each
month
so
that
it
always
points
to
the
redefine
this
each
month
so
that
it
always
points
to
the
current
partition
.
current
partition
:
<
programlisting
>
<
programlisting
>
CREATE
OR
REPLACE
RULE
measurement_current_partition
AS
CREATE
OR
REPLACE
RULE
measurement_current_partition
AS
...
@@ -2525,7 +2525,7 @@ DO INSTEAD
...
@@ -2525,7 +2525,7 @@ DO INSTEAD
We
might
want
to
insert
data
and
have
the
server
automatically
We
might
want
to
insert
data
and
have
the
server
automatically
locate
the
partition
into
which
the
row
should
be
added
.
We
locate
the
partition
into
which
the
row
should
be
added
.
We
could
do
this
with
a
more
complex
set
of
rules
as
shown
below
.
could
do
this
with
a
more
complex
set
of
rules
as
shown
below
:
<
programlisting
>
<
programlisting
>
CREATE
RULE
measurement_insert_y2004m02
AS
CREATE
RULE
measurement_insert_y2004m02
AS
...
@@ -2632,7 +2632,7 @@ ALTER TABLE measurement_y2003m02 NO INHERIT measurement;
...
@@ -2632,7 +2632,7 @@ ALTER TABLE measurement_y2003m02 NO INHERIT measurement;
<para>
<para>
Similarly we can add a new partition to handle new data. We can create an
Similarly we can add a new partition to handle new data. We can create an
empty partition in the partitioned table just as the original partitions
empty partition in the partitioned table just as the original partitions
were created above
.
were created above
:
<programlisting>
<programlisting>
CREATE TABLE measurement_y2006m02 (
CREATE TABLE measurement_y2006m02 (
...
@@ -2643,7 +2643,7 @@ CREATE TABLE measurement_y2006m02 (
...
@@ -2643,7 +2643,7 @@ CREATE TABLE measurement_y2006m02 (
As an alternative, it is sometimes more convenient to create the
As an alternative, it is sometimes more convenient to create the
new table outside the partition structure, and make it a proper
new table outside the partition structure, and make it a proper
partition later. This allows the data to be loaded, checked, and
partition later. This allows the data to be loaded, checked, and
transformed prior to it appearing in the partitioned table
.
transformed prior to it appearing in the partitioned table
:
<programlisting>
<programlisting>
CREATE TABLE measurement_y2006m02
CREATE TABLE measurement_y2006m02
...
@@ -2795,7 +2795,7 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate >= DATE '2006-01-01';
...
@@ -2795,7 +2795,7 @@ EXPLAIN SELECT count(*) FROM measurement WHERE logdate >= DATE '2006-01-01';
<
listitem
>
<
listitem
>
<
para
>
<
para
>
Don
't forget that you still need to run <command>ANALYZE</command>
Don
't forget that you still need to run <command>ANALYZE</command>
on each partition individually. A command like
on each partition individually. A command like
:
<programlisting>
<programlisting>
ANALYZE measurement;
ANALYZE measurement;
</programlisting>
</programlisting>
...
...
doc/src/sgml/dfunc.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/dfunc.sgml,v 1.3
4 2006/09/16 00:30:12
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/dfunc.sgml,v 1.3
5 2007/02/01 00:28:16
momjian Exp $ -->
<sect2 id="dfunc">
<sect2 id="dfunc">
<title id="dfunc-title">Compiling and Linking Dynamically-Loaded Functions</title>
<title id="dfunc-title">Compiling and Linking Dynamically-Loaded Functions</title>
...
@@ -99,15 +99,15 @@ gcc -shared -o foo.so foo.o
...
@@ -99,15 +99,15 @@ gcc -shared -o foo.so foo.o
The compiler flag of the system compiler to create
The compiler flag of the system compiler to create
<acronym>PIC</acronym> is <option>+z</option>. When using
<acronym>PIC</acronym> is <option>+z</option>. When using
<application>GCC</application> it's <option>-fpic</option>. The
<application>GCC</application> it's <option>-fpic</option>. The
linker flag for shared libraries is <option>-b</option>. So
linker flag for shared libraries is <option>-b</option>. So
:
<programlisting>
<programlisting>
cc +z -c foo.c
cc +z -c foo.c
</programlisting>
</programlisting>
or
or
:
<programlisting>
<programlisting>
gcc -fpic -c foo.c
gcc -fpic -c foo.c
</programlisting>
</programlisting>
and then
and then
:
<programlisting>
<programlisting>
ld -b -o foo.sl foo.o
ld -b -o foo.sl foo.o
</programlisting>
</programlisting>
...
@@ -233,7 +233,7 @@ gcc -G -o foo.so foo.o
...
@@ -233,7 +233,7 @@ gcc -G -o foo.so foo.o
<para>
<para>
<acronym>PIC</acronym> is the default, so the compilation command
<acronym>PIC</acronym> is the default, so the compilation command
is the usual one. <command>ld</command> with special options is
is the usual one. <command>ld</command> with special options is
used to do the linking
:
used to do the linking
.
<programlisting>
<programlisting>
cc -c foo.c
cc -c foo.c
ld -shared -expect_unresolved '*' -o foo.so foo.o
ld -shared -expect_unresolved '*' -o foo.so foo.o
...
...
doc/src/sgml/dml.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/dml.sgml,v 1.1
5 2007/01/31 20:56
:16 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/dml.sgml,v 1.1
6 2007/02/01 00:28
:16 momjian Exp $ -->
<chapter id="dml">
<chapter id="dml">
<title>Data Manipulation</title>
<title>Data Manipulation</title>
...
@@ -74,7 +74,7 @@ INSERT INTO products (name, price, product_no) VALUES ('Cheese', 9.99, 1);
...
@@ -74,7 +74,7 @@ INSERT INTO products (name, price, product_no) VALUES ('Cheese', 9.99, 1);
<para>
<para>
If you don't have values for all the columns, you can omit some of
If you don't have values for all the columns, you can omit some of
them. In that case, the columns will be filled with their default
them. In that case, the columns will be filled with their default
values. For example
,
values. For example
:
<programlisting>
<programlisting>
INSERT INTO products (product_no, name) VALUES (1, 'Cheese');
INSERT INTO products (product_no, name) VALUES (1, 'Cheese');
INSERT INTO products VALUES (1, 'Cheese');
INSERT INTO products VALUES (1, 'Cheese');
...
@@ -237,14 +237,14 @@ UPDATE mytable SET a = 5, b = 3, c = 1 WHERE a > 0;
...
@@ -237,14 +237,14 @@ UPDATE mytable SET a = 5, b = 3, c = 1 WHERE a > 0;
You use the <xref linkend="sql-delete" endterm="sql-delete-title">
You use the <xref linkend="sql-delete" endterm="sql-delete-title">
command to remove rows; the syntax is very similar to the
command to remove rows; the syntax is very similar to the
<command>UPDATE</command> command. For instance, to remove all
<command>UPDATE</command> command. For instance, to remove all
rows from the products table that have a price of 10, use
rows from the products table that have a price of 10, use
:
<programlisting>
<programlisting>
DELETE FROM products WHERE price = 10;
DELETE FROM products WHERE price = 10;
</programlisting>
</programlisting>
</para>
</para>
<para>
<para>
If you simply write
If you simply write
:
<programlisting>
<programlisting>
DELETE FROM products;
DELETE FROM products;
</programlisting>
</programlisting>
...
...
doc/src/sgml/docguide.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/docguide.sgml,v 1.
69 2007/01/31 20:56:17
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/docguide.sgml,v 1.
70 2007/02/01 00:28:16
momjian Exp $ -->
<appendix id="docguide">
<appendix id="docguide">
<title>Documentation</title>
<title>Documentation</title>
...
@@ -558,7 +558,7 @@ checking for sgmlspl... sgmlspl
...
@@ -558,7 +558,7 @@ checking for sgmlspl... sgmlspl
To allow for easier handling in the final distribution, the files
To allow for easier handling in the final distribution, the files
comprising the HTML documentation can be stored in a tar archive that
comprising the HTML documentation can be stored in a tar archive that
is unpacked at installation time. To create the
is unpacked at installation time. To create the
<acronym>HTML</acronym> documentation package, use the commands
<acronym>HTML</acronym> documentation package, use the commands
:
<programlisting>
<programlisting>
cd doc/src
cd doc/src
gmake postgres.tar.gz
gmake postgres.tar.gz
...
@@ -578,7 +578,7 @@ gmake postgres.tar.gz
...
@@ -578,7 +578,7 @@ gmake postgres.tar.gz
<sgmltag>refentry</sgmltag> pages to *roff output suitable for man
<sgmltag>refentry</sgmltag> pages to *roff output suitable for man
pages. The man pages are also distributed as a tar archive,
pages. The man pages are also distributed as a tar archive,
similar to the <acronym>HTML</acronym> version. To create the man
similar to the <acronym>HTML</acronym> version. To create the man
page package, use the commands
page package, use the commands
:
<programlisting>
<programlisting>
cd doc/src
cd doc/src
gmake man.tar.gz
gmake man.tar.gz
...
...
doc/src/sgml/ecpg.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/ecpg.sgml,v 1.7
8 2007/01/31 20:56:17
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/ecpg.sgml,v 1.7
9 2007/02/01 00:28:16
momjian 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>
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
As already stated, programs written for the embedded
As already stated, programs written for the embedded
<acronym>SQL</acronym> interface are normal C programs with special
<acronym>SQL</acronym> interface are normal C programs with special
code inserted to perform database-related actions. This special
code inserted to perform database-related actions. This special
code always has the form
code always has the form
:
<programlisting>
<programlisting>
EXEC SQL ...;
EXEC SQL ...;
</programlisting>
</programlisting>
...
@@ -346,7 +346,7 @@ EXEC SQL COMMIT;
...
@@ -346,7 +346,7 @@ EXEC SQL COMMIT;
<para>
<para>
The first option is to explicitly choose a connection for each SQL
The first option is to explicitly choose a connection for each SQL
statement, for example
statement, for example
:
<programlisting>
<programlisting>
EXEC SQL AT <replaceable>connection-name</replaceable> SELECT ...;
EXEC SQL AT <replaceable>connection-name</replaceable> SELECT ...;
</programlisting>
</programlisting>
...
@@ -428,16 +428,16 @@ EXEC SQL INSERT INTO sometable VALUES (:v1, 'foo', :v2);
...
@@ -428,16 +428,16 @@ EXEC SQL INSERT INTO sometable VALUES (:v1, 'foo', :v2);
</para>
</para>
<para>
<para>
This section starts with
This section starts with
:
<programlisting>
<programlisting>
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL BEGIN DECLARE SECTION;
</programlisting>
</programlisting>
and ends with
and ends with
:
<programlisting>
<programlisting>
EXEC SQL END DECLARE SECTION;
EXEC SQL END DECLARE SECTION;
</programlisting>
</programlisting>
Between those lines, there must be normal C variable declarations,
Between those lines, there must be normal C variable declarations,
such as
such as
:
<programlisting>
<programlisting>
int x = 4;
int x = 4;
char foo[16], bar[16];
char foo[16], bar[16];
...
@@ -483,7 +483,7 @@ EXEC SQL int i = 4;
...
@@ -483,7 +483,7 @@ EXEC SQL int i = 4;
<listitem>
<listitem>
<para>
<para>
One of the most common uses of an array declaration is probably the
One of the most common uses of an array declaration is probably the
allocation of a char array as in
allocation of a char array as in
:
<programlisting>
<programlisting>
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL BEGIN DECLARE SECTION;
char str[50];
char str[50];
...
@@ -508,7 +508,7 @@ EXEC SQL BEGIN DECLARE SECTION;
...
@@ -508,7 +508,7 @@ EXEC SQL BEGIN DECLARE SECTION;
typedef long serial_t;
typedef long serial_t;
EXEC SQL END DECLARE SECTION;
EXEC SQL END DECLARE SECTION;
</programlisting>
</programlisting>
Note that you could also use
Note that you could also use
:
<programlisting>
<programlisting>
EXEC SQL TYPE serial_t IS long;
EXEC SQL TYPE serial_t IS long;
</programlisting>
</programlisting>
...
@@ -549,11 +549,11 @@ EXEC SQL END DECLARE SECTION;
...
@@ -549,11 +549,11 @@ EXEC SQL END DECLARE SECTION;
<para>
<para>
The special type <type>VARCHAR</type>
The special type <type>VARCHAR</type>
is converted into a named <type>struct</> for every variable. A
is converted into a named <type>struct</> for every variable. A
declaration like
declaration like
:
<programlisting>
<programlisting>
VARCHAR var[180];
VARCHAR var[180];
</programlisting>
</programlisting>
is converted into
is converted into
:
<programlisting>
<programlisting>
struct varchar_var { int len; char arr[180]; } var;
struct varchar_var { int len; char arr[180]; } var;
</programlisting>
</programlisting>
...
@@ -2381,7 +2381,7 @@ void PGTYPESdecimal_free(decimal *var);
...
@@ -2381,7 +2381,7 @@ void PGTYPESdecimal_free(decimal *var);
this mode is active, it tries to behave as if it were the <productname>Informix</productname>
this mode is active, it tries to behave as if it were the <productname>Informix</productname>
precompiler for <productname>Informix</productname> E/SQL. Generally spoken this will allow you to use
precompiler for <productname>Informix</productname> E/SQL. Generally spoken this will allow you to use
the dollar sign instead of the <literal>EXEC SQL</> primitive to introduce
the dollar sign instead of the <literal>EXEC SQL</> primitive to introduce
embedded SQL commands.
embedded SQL commands.
:
<programlisting>
<programlisting>
$int j = 3;
$int j = 3;
$CONNECT TO :dbname;
$CONNECT TO :dbname;
...
@@ -2426,7 +2426,7 @@ void PGTYPESdecimal_free(decimal *var);
...
@@ -2426,7 +2426,7 @@ void PGTYPESdecimal_free(decimal *var);
<listitem>
<listitem>
<para>
<para>
This statement closes the current connection. In fact, this is a
This statement closes the current connection. In fact, this is a
synonym for ecpg's <literal>DISCONNECT CURRENT</>.
synonym for ecpg's <literal>DISCONNECT CURRENT</>.
:
<programlisting>
<programlisting>
$CLOSE DATABASE; /* close the current connection */
$CLOSE DATABASE; /* close the current connection */
EXEC SQL CLOSE DATABASE;
EXEC SQL CLOSE DATABASE;
...
@@ -3991,7 +3991,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
...
@@ -3991,7 +3991,7 @@ EXEC SQL WHENEVER <replaceable>condition</replaceable> <replaceable>action</repl
<para>
<para>
Here is an example that you might want to use in a simple program.
Here is an example that you might want to use in a simple program.
It prints a simple message when a warning occurs and aborts the
It prints a simple message when a warning occurs and aborts the
program when an error happens
.
program when an error happens
:
<programlisting>
<programlisting>
EXEC SQL WHENEVER SQLWARNING SQLPRINT;
EXEC SQL WHENEVER SQLWARNING SQLPRINT;
EXEC SQL WHENEVER SQLERROR STOP;
EXEC SQL WHENEVER SQLERROR STOP;
...
@@ -4007,7 +4007,7 @@ EXEC SQL WHENEVER SQLERROR STOP;
...
@@ -4007,7 +4007,7 @@ EXEC SQL WHENEVER SQLERROR STOP;
<literal>EXEC SQL WHENEVER</literal> and the SQL statement causing
<literal>EXEC SQL WHENEVER</literal> and the SQL statement causing
the condition, regardless of the flow of control in the C program.
the condition, regardless of the flow of control in the C program.
So neither of the two following C program excerpts will have the
So neither of the two following C program excerpts will have the
desired effect
.
desired effect
:
<programlisting>
<programlisting>
/*
/*
* WRONG
* WRONG
...
@@ -4493,7 +4493,7 @@ EXEC SQL INCLUDE <replaceable>filename</replaceable>;
...
@@ -4493,7 +4493,7 @@ EXEC SQL INCLUDE <replaceable>filename</replaceable>;
</para>
</para>
<para>
<para>
Note that this is <emphasis>not</emphasis> the same as
Note that this is <emphasis>not</emphasis> the same as
:
<programlisting>
<programlisting>
#include <<replaceable>filename</replaceable>.h>
#include <<replaceable>filename</replaceable>.h>
</programlisting>
</programlisting>
...
@@ -4654,7 +4654,7 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER;
...
@@ -4654,7 +4654,7 @@ EXEC SQL UPDATE Tbl SET col = MYNUMBER;
Embedded SQL programs are typically named with an extension
Embedded SQL programs are typically named with an extension
<filename>.pgc</filename>. If you have a program file called
<filename>.pgc</filename>. If you have a program file called
<filename>prog1.pgc</filename>, you can preprocess it by simply
<filename>prog1.pgc</filename>, you can preprocess it by simply
calling
calling
:
<programlisting>
<programlisting>
ecpg prog1.pgc
ecpg prog1.pgc
</programlisting>
</programlisting>
...
@@ -4938,7 +4938,7 @@ ECPG = ecpg
...
@@ -4938,7 +4938,7 @@ ECPG = ecpg
<para>
<para>
Note that not all SQL commands are treated in this way. For
Note that not all SQL commands are treated in this way. For
instance, an open cursor statement like
instance, an open cursor statement like
:
<programlisting>
<programlisting>
EXEC SQL OPEN <replaceable>cursor</replaceable>;
EXEC SQL OPEN <replaceable>cursor</replaceable>;
</programlisting>
</programlisting>
...
...
doc/src/sgml/func.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.35
6 2007/01/31 20:56:17
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.35
7 2007/02/01 00:28:16
momjian Exp $ -->
<chapter id="functions">
<chapter id="functions">
<title>Functions and Operators</title>
<title>Functions and Operators</title>
...
@@ -7194,7 +7194,7 @@ SELECT pg_sleep(1.5);
...
@@ -7194,7 +7194,7 @@ SELECT pg_sleep(1.5);
in single quotes, so that it looks like a literal constant. To
in single quotes, so that it looks like a literal constant. To
achieve some compatibility with the handling of ordinary
achieve some compatibility with the handling of ordinary
<acronym>SQL</acronym> names, the string will be converted to lowercase
<acronym>SQL</acronym> names, the string will be converted to lowercase
unless it contains double quotes around the sequence name. Thus
unless it contains double quotes around the sequence name. Thus
:
<programlisting>
<programlisting>
nextval('foo') <lineannotation>operates on sequence <literal>foo</literal></>
nextval('foo') <lineannotation>operates on sequence <literal>foo</literal></>
nextval('FOO') <lineannotation>operates on sequence <literal>foo</literal></>
nextval('FOO') <lineannotation>operates on sequence <literal>foo</literal></>
...
@@ -9713,7 +9713,7 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
...
@@ -9713,7 +9713,7 @@ SELECT relname FROM pg_class WHERE pg_table_is_visible(oid);
All these functions require object OIDs to identify the object to be
All these functions require object OIDs to identify the object to be
checked. If you want to test an object by name, it is convenient to use
checked. If you want to test an object by name, it is convenient to use
the OID alias types (<type>regclass</>, <type>regtype</>,
the OID alias types (<type>regclass</>, <type>regtype</>,
<type>regprocedure</>, or <type>regoperator</>), for example
<type>regprocedure</>, or <type>regoperator</>), for example
:
<programlisting>
<programlisting>
SELECT pg_type_is_visible('myschema.widget'::regtype);
SELECT pg_type_is_visible('myschema.widget'::regtype);
</programlisting>
</programlisting>
...
...
doc/src/sgml/indices.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.6
8 2007/01/31 20:56
:17 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/indices.sgml,v 1.6
9 2007/02/01 00:28
:17 momjian Exp $ -->
<chapter id="indexes">
<chapter id="indexes">
<title id="indexes-title">Indexes</title>
<title id="indexes-title">Indexes</title>
...
@@ -27,7 +27,7 @@ CREATE TABLE test1 (
...
@@ -27,7 +27,7 @@ CREATE TABLE test1 (
content varchar
content varchar
);
);
</programlisting>
</programlisting>
and the application requires a lot of queries of the form
and the application requires a lot of queries of the form
:
<programlisting>
<programlisting>
SELECT content FROM test1 WHERE id = <replaceable>constant</replaceable>;
SELECT content FROM test1 WHERE id = <replaceable>constant</replaceable>;
</programlisting>
</programlisting>
...
@@ -292,13 +292,13 @@ CREATE TABLE test2 (
...
@@ -292,13 +292,13 @@ CREATE TABLE test2 (
);
);
</programlisting>
</programlisting>
(say, you keep your <filename class="directory">/dev</filename>
(say, you keep your <filename class="directory">/dev</filename>
directory in a database...) and you frequently make queries like
directory in a database...) and you frequently make queries like
:
<programlisting>
<programlisting>
SELECT name FROM test2 WHERE major = <replaceable>constant</replaceable> AND minor = <replaceable>constant</replaceable>;
SELECT name FROM test2 WHERE major = <replaceable>constant</replaceable> AND minor = <replaceable>constant</replaceable>;
</programlisting>
</programlisting>
then it might be appropriate to define an index on the columns
then it might be appropriate to define an index on the columns
<structfield>major</structfield> and
<structfield>major</structfield> and
<structfield>minor</structfield> together, e.g.
,
<structfield>minor</structfield> together, e.g.
:
<programlisting>
<programlisting>
CREATE INDEX test2_mm_idx ON test2 (major, minor);
CREATE INDEX test2_mm_idx ON test2 (major, minor);
</programlisting>
</programlisting>
...
@@ -666,12 +666,12 @@ CREATE INDEX orders_unbilled_index ON orders (order_nr)
...
@@ -666,12 +666,12 @@ CREATE INDEX orders_unbilled_index ON orders (order_nr)
</para>
</para>
<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 < 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 > 5000.00;
</programlisting>
</programlisting>
...
...
doc/src/sgml/information_schema.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/information_schema.sgml,v 1.3
0 2007/01/31 20:56
:17 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/information_schema.sgml,v 1.3
1 2007/02/01 00:28
:17 momjian Exp $ -->
<chapter id="information-schema">
<chapter id="information-schema">
<title>The Information Schema</title>
<title>The Information Schema</title>
...
@@ -1871,7 +1871,7 @@
...
@@ -1871,7 +1871,7 @@
<literal>data_type</literal>. To obtain information on the element
<literal>data_type</literal>. To obtain information on the element
type of the array, you can join the respective view with this view.
type of the array, you can join the respective view with this view.
For example, to show the columns of a table with data types and
For example, to show the columns of a table with data types and
array element types, if applicable, you could do
array element types, if applicable, you could do
:
<programlisting>
<programlisting>
SELECT c.column_name, c.data_type, e.data_type AS element_type
SELECT c.column_name, c.data_type, e.data_type AS element_type
FROM information_schema.columns c LEFT JOIN information_schema.element_types e
FROM information_schema.columns c LEFT JOIN information_schema.element_types e
...
...
doc/src/sgml/installation.sgml
View file @
09a9f10e
<
!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.2
79 2007/01/31 20:56
:17 momjian Exp $ -->
<
!-- $PostgreSQL: pgsql/doc/src/sgml/installation.sgml,v 1.2
80 2007/02/01 00:28
:17 momjian Exp $ -->
<
chapter
id
=
"installation"
>
<
chapter
id
=
"installation"
>
<
title
><
![%standalone-include[<productname>PostgreSQL</>]]>
<
title
><
![%standalone-include[<productname>PostgreSQL</>]]>
...
@@ -1446,12 +1446,12 @@ All of PostgreSQL is successfully made. Ready to install.
...
@@ -1446,12 +1446,12 @@ All of PostgreSQL is successfully made. Ready to install.
The
method
to
set
the
shared
library
search
path
varies
between
The
method
to
set
the
shared
library
search
path
varies
between
platforms
,
but
the
most
widely
usable
method
is
to
set
the
platforms
,
but
the
most
widely
usable
method
is
to
set
the
environment
variable
<
envar
>
LD_LIBRARY_PATH
</>
like
so
:
In
Bourne
environment
variable
<
envar
>
LD_LIBRARY_PATH
</>
like
so
:
In
Bourne
shells
(<
command
>
sh
</>,
<
command
>
ksh
</>,
<
command
>
bash
</>,
<
command
>
zsh
</>)
shells
(<
command
>
sh
</>,
<
command
>
ksh
</>,
<
command
>
bash
</>,
<
command
>
zsh
</>)
:
<
programlisting
>
<
programlisting
>
LD_LIBRARY_PATH
=/
usr
/
local
/
pgsql
/
lib
LD_LIBRARY_PATH
=/
usr
/
local
/
pgsql
/
lib
export
LD_LIBRARY_PATH
export
LD_LIBRARY_PATH
</
programlisting
>
</
programlisting
>
or
in
<
command
>
csh
</>
or
<
command
>
tcsh
</>
or
in
<
command
>
csh
</>
or
<
command
>
tcsh
</>
:
<
programlisting
>
<
programlisting
>
setenv
LD_LIBRARY_PATH
/
usr
/
local
/
pgsql
/
lib
setenv
LD_LIBRARY_PATH
/
usr
/
local
/
pgsql
/
lib
</
programlisting
>
</
programlisting
>
...
@@ -1494,7 +1494,7 @@ libpq.so.2.1: cannot open shared object file: No such file or directory
...
@@ -1494,7 +1494,7 @@ libpq.so.2.1: cannot open shared object file: No such file or directory
</
indexterm
>
</
indexterm
>
If
you
are
on
<
systemitem
class
=
"osname"
>
BSD
/
OS
</>,
<
systemitem
If
you
are
on
<
systemitem
class
=
"osname"
>
BSD
/
OS
</>,
<
systemitem
class
=
"osname"
>
Linux
</>,
or
<
systemitem
class
=
"osname"
>
SunOS
4
</>
class
=
"osname"
>
Linux
</>,
or
<
systemitem
class
=
"osname"
>
SunOS
4
</>
and
you
have
root
access
you
can
run
and
you
have
root
access
you
can
run
:
<
programlisting
>
<
programlisting
>
/
sbin
/
ldconfig
/
usr
/
local
/
pgsql
/
lib
/
sbin
/
ldconfig
/
usr
/
local
/
pgsql
/
lib
</
programlisting
>
</
programlisting
>
...
@@ -1503,7 +1503,7 @@ libpq.so.2.1: cannot open shared object file: No such file or directory
...
@@ -1503,7 +1503,7 @@ libpq.so.2.1: cannot open shared object file: No such file or directory
manual
page
of
<
command
>
ldconfig
</>
for
more
information
.
On
manual
page
of
<
command
>
ldconfig
</>
for
more
information
.
On
<
systemitem
class
=
"osname"
>
FreeBSD
</>,
<
systemitem
<
systemitem
class
=
"osname"
>
FreeBSD
</>,
<
systemitem
class
=
"osname"
>
NetBSD
</>,
and
<
systemitem
class
=
"osname"
>
NetBSD
</>,
and
<
systemitem
class
=
"osname"
>
OpenBSD
</>
the
command
is
class
=
"osname"
>
OpenBSD
</>
the
command
is
:
<
programlisting
>
<
programlisting
>
/
sbin
/
ldconfig
-
m
/
usr
/
local
/
pgsql
/
lib
/
sbin
/
ldconfig
-
m
/
usr
/
local
/
pgsql
/
lib
</
programlisting
>
</
programlisting
>
...
@@ -1550,7 +1550,7 @@ set path = ( /usr/local/pgsql/bin $path )
...
@@ -1550,7 +1550,7 @@ set path = ( /usr/local/pgsql/bin $path )
To
enable
your
system
to
find
the
<
application
>
man
</>
To
enable
your
system
to
find
the
<
application
>
man
</>
documentation
,
you
need
to
add
lines
like
the
following
to
a
documentation
,
you
need
to
add
lines
like
the
following
to
a
shell
start
-
up
file
unless
you
installed
into
a
location
that
is
shell
start
-
up
file
unless
you
installed
into
a
location
that
is
searched
by
default
.
searched
by
default
:
<
programlisting
>
<
programlisting
>
MANPATH
=/
usr
/
local
/
pgsql
/
man
:$
MANPATH
MANPATH
=/
usr
/
local
/
pgsql
/
man
:$
MANPATH
export
MANPATH
export
MANPATH
...
@@ -1623,12 +1623,12 @@ postgres$ <userinput>/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data</>
...
@@ -1623,12 +1623,12 @@ postgres$ <userinput>/usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data</>
<para>
<para>
The previous step should have told you how to start up the
The previous step should have told you how to start up the
database server. Do so now. The command should look something
database server. Do so now. The command should look something
like
like
:
<programlisting>
<programlisting>
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
/usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data
</programlisting>
</programlisting>
This will start the server in the foreground. To put the server
This will start the server in the foreground. To put the server
in the background use something like
in the background use something like
:
<programlisting>
<programlisting>
nohup /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data \
nohup /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data \
</dev/null >>server.log 2>&1 </dev/null &
</dev/null >>server.log 2>&1 </dev/null &
...
...
doc/src/sgml/libpq.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.22
3 2007/01/31 20:56
:17 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/libpq.sgml,v 1.22
4 2007/02/01 00:28
:17 momjian Exp $ -->
<chapter id="libpq">
<chapter id="libpq">
<title><application>libpq</application> - C Library</title>
<title><application>libpq</application> - C Library</title>
...
@@ -1267,7 +1267,7 @@ not to hard-wire particular OID values into your program. However, you can
...
@@ -1267,7 +1267,7 @@ not to hard-wire particular OID values into your program. However, you can
avoid doing so even in cases where the server by itself cannot determine the
avoid doing so even in cases where the server by itself cannot determine the
type of the parameter, or chooses a different type than you want. In the
type of the parameter, or chooses a different type than you want. In the
SQL command text, attach an explicit cast to the parameter symbol to show what
SQL command text, attach an explicit cast to the parameter symbol to show what
data type you will send. For example
,
data type you will send. For example
:
<programlisting>
<programlisting>
select * from mytable where x = $1::bigint;
select * from mytable where x = $1::bigint;
</programlisting>
</programlisting>
...
@@ -1920,7 +1920,7 @@ int PQfnumber(const PGresult *res,
...
@@ -1920,7 +1920,7 @@ int PQfnumber(const PGresult *res,
<para>
<para>
The given name is treated like an identifier in an SQL command,
The given name is treated like an identifier in an SQL command,
that is, it is downcased unless double-quoted. For example,
that is, it is downcased unless double-quoted. For example,
given a query result generated from the SQL command
given a query result generated from the SQL command
:
<programlisting>
<programlisting>
select 1 as FOO, 2 as "BAR";
select 1 as FOO, 2 as "BAR";
</programlisting>
</programlisting>
...
@@ -3982,7 +3982,7 @@ a void pointer that is the same one passed to
...
@@ -3982,7 +3982,7 @@ a void pointer that is the same one passed to
</para>
</para>
<para>
<para>
The default notice processor is simply
The default notice processor is simply
:
<programlisting>
<programlisting>
static void
static void
defaultNoticeProcessor(void *arg, const char *message)
defaultNoticeProcessor(void *arg, const char *message)
...
...
doc/src/sgml/maintenance.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.6
8 2007/01/31 20:56
:17 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/maintenance.sgml,v 1.6
9 2007/02/01 00:28
:17 momjian Exp $ -->
<chapter id="maintenance">
<chapter id="maintenance">
<title>Routine Database Maintenance Tasks</title>
<title>Routine Database Maintenance Tasks</title>
...
@@ -408,7 +408,7 @@
...
@@ -408,7 +408,7 @@
appearing in that database — it is just the minimum of the
appearing in that database — it is just the minimum of the
per-table <structfield>relfrozenxid</> values within the database.
per-table <structfield>relfrozenxid</> values within the database.
A convenient way to
A convenient way to
examine this information is to execute queries such as
examine this information is to execute queries such as
:
<programlisting>
<programlisting>
SELECT relname, age(relfrozenxid) FROM pg_class WHERE relkind = 'r';
SELECT relname, age(relfrozenxid) FROM pg_class WHERE relkind = 'r';
...
@@ -511,7 +511,7 @@ vacuum threshold = vacuum base threshold + vacuum scale factor * number of tuple
...
@@ -511,7 +511,7 @@ vacuum threshold = vacuum base threshold + vacuum scale factor * number of tuple
collector; it is a semi-accurate count updated by each
collector; it is a semi-accurate count updated by each
<command>UPDATE</command> and <command>DELETE</command> operation. (It
<command>UPDATE</command> and <command>DELETE</command> operation. (It
is only semi-accurate because some information might be lost under heavy
is only semi-accurate because some information might be lost under heavy
load.) For analyze, a similar condition is used: the threshold, defined as
load.) For analyze, a similar condition is used: the threshold, defined as
:
<programlisting>
<programlisting>
analyze threshold = analyze base threshold + analyze scale factor * number of tuples
analyze threshold = analyze base threshold + analyze scale factor * number of tuples
</programlisting>
</programlisting>
...
...
doc/src/sgml/manage-ag.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.5
2 2007/01/31 20:56
:17 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/manage-ag.sgml,v 2.5
3 2007/02/01 00:28
:17 momjian Exp $ -->
<chapter id="managing-databases">
<chapter id="managing-databases">
<title>Managing Databases</title>
<title>Managing Databases</title>
...
@@ -162,7 +162,7 @@ createdb <replaceable class="parameter">dbname</replaceable>
...
@@ -162,7 +162,7 @@ createdb <replaceable class="parameter">dbname</replaceable>
<programlisting>
<programlisting>
CREATE DATABASE <replaceable>dbname</> OWNER <replaceable>rolename</>;
CREATE DATABASE <replaceable>dbname</> OWNER <replaceable>rolename</>;
</programlisting>
</programlisting>
from the SQL environment, or
from the SQL environment, or
:
<programlisting>
<programlisting>
createdb -O <replaceable>rolename</> <replaceable>dbname</>
createdb -O <replaceable>rolename</> <replaceable>dbname</>
</programlisting>
</programlisting>
...
@@ -208,11 +208,11 @@ createdb -O <replaceable>rolename</> <replaceable>dbname</>
...
@@ -208,11 +208,11 @@ createdb -O <replaceable>rolename</> <replaceable>dbname</>
</para>
</para>
<para>
<para>
To create a database by copying <literal>template0</literal>, use
To create a database by copying <literal>template0</literal>, use
:
<programlisting>
<programlisting>
CREATE DATABASE <replaceable>dbname</> TEMPLATE template0;
CREATE DATABASE <replaceable>dbname</> TEMPLATE template0;
</programlisting>
</programlisting>
from the SQL environment, or
from the SQL environment, or
:
<programlisting>
<programlisting>
createdb -T template0 <replaceable>dbname</>
createdb -T template0 <replaceable>dbname</>
</programlisting>
</programlisting>
...
@@ -286,7 +286,7 @@ createdb -T template0 <replaceable>dbname</>
...
@@ -286,7 +286,7 @@ createdb -T template0 <replaceable>dbname</>
ordinarily have to either disable it for all databases or make sure
ordinarily have to either disable it for all databases or make sure
that every connecting client is careful to issue <literal>SET geqo
that every connecting client is careful to issue <literal>SET geqo
TO off;</literal>. To make this setting the default within a particular
TO off;</literal>. To make this setting the default within a particular
database, you can execute the command
database, you can execute the command
:
<programlisting>
<programlisting>
ALTER DATABASE mydb SET geqo TO off;
ALTER DATABASE mydb SET geqo TO off;
</programlisting>
</programlisting>
...
@@ -373,7 +373,7 @@ dropdb <replaceable class="parameter">dbname</replaceable>
...
@@ -373,7 +373,7 @@ dropdb <replaceable class="parameter">dbname</replaceable>
<para>
<para>
To define a tablespace, use the <xref
To define a tablespace, use the <xref
linkend="sql-createtablespace" endterm="sql-createtablespace-title">
linkend="sql-createtablespace" endterm="sql-createtablespace-title">
command, for example:<indexterm><primary>CREATE TABLESPACE</></>
command, for example:<indexterm><primary>CREATE TABLESPACE</></>
:
<programlisting>
<programlisting>
CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data';
CREATE TABLESPACE fastspace LOCATION '/mnt/sda1/postgresql/data';
</programlisting>
</programlisting>
...
...
doc/src/sgml/monitoring.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.4
4 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.4
5 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="monitoring">
<chapter id="monitoring">
<title>Monitoring Database Activity</title>
<title>Monitoring Database Activity</title>
...
@@ -934,7 +934,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS procpid,
...
@@ -934,7 +934,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS procpid,
<para>
<para>
The example below shows a DTrace script for analyzing transaction
The example below shows a DTrace script for analyzing transaction
counts on the system, as an alternative to snapshotting
counts on the system, as an alternative to snapshotting
<structname>pg_stat_database</> before and after a performance test
.
<structname>pg_stat_database</> before and after a performance test
:
<programlisting>
<programlisting>
#!/usr/sbin/dtrace -qs
#!/usr/sbin/dtrace -qs
...
@@ -992,7 +992,7 @@ Total time (ns) 2312105013
...
@@ -992,7 +992,7 @@ Total time (ns) 2312105013
trace macros. These are chosen according to how many variables will
trace macros. These are chosen according to how many variables will
be made available for inspection at that trace point. Tracing the
be made available for inspection at that trace point. Tracing the
occurrence of an event can be achieved with a single line, using
occurrence of an event can be achieved with a single line, using
just the trace point name, e.g.
just the trace point name, e.g.
:
<programlisting>
<programlisting>
PG_TRACE (my__new__trace__point);
PG_TRACE (my__new__trace__point);
</programlisting>
</programlisting>
...
...
doc/src/sgml/nls.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/nls.sgml,v 1.1
5 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/nls.sgml,v 1.1
6 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="nls">
<chapter id="nls">
<chapterinfo>
<chapterinfo>
...
@@ -170,7 +170,7 @@ msgstr "another translated"
...
@@ -170,7 +170,7 @@ msgstr "another translated"
<para>
<para>
If you need to start a new translation effort, then first run the
If you need to start a new translation effort, then first run the
command
command
:
<programlisting>
<programlisting>
gmake init-po
gmake init-po
</programlisting>
</programlisting>
...
@@ -193,7 +193,7 @@ AVAIL_LANGUAGES := de fr
...
@@ -193,7 +193,7 @@ AVAIL_LANGUAGES := de fr
<para>
<para>
As the underlying program or library changes, messages might be
As the underlying program or library changes, messages might be
changed or added by the programmers. In this case you do not need
changed or added by the programmers. In this case you do not need
to start from scratch. Instead, run the command
to start from scratch. Instead, run the command
:
<programlisting>
<programlisting>
gmake update-po
gmake update-po
</programlisting>
</programlisting>
...
@@ -340,11 +340,11 @@ textdomain("<replaceable>progname</replaceable>");
...
@@ -340,11 +340,11 @@ textdomain("<replaceable>progname</replaceable>");
<step>
<step>
<para>
<para>
Wherever a message that is a candidate for translation is found,
Wherever a message that is a candidate for translation is found,
a call to <function>gettext()</function> needs to be inserted. E.g.
,
a call to <function>gettext()</function> needs to be inserted. E.g.
:
<programlisting>
<programlisting>
fprintf(stderr, "panic level %d\n", lvl);
fprintf(stderr, "panic level %d\n", lvl);
</programlisting>
</programlisting>
would be changed to
would be changed to
:
<programlisting>
<programlisting>
fprintf(stderr, gettext("panic level %d\n"), lvl);
fprintf(stderr, gettext("panic level %d\n"), lvl);
</programlisting>
</programlisting>
...
@@ -353,7 +353,7 @@ fprintf(stderr, gettext("panic level %d\n"), lvl);
...
@@ -353,7 +353,7 @@ fprintf(stderr, gettext("panic level %d\n"), lvl);
</para>
</para>
<para>
<para>
This tends to add a lot of clutter. One common shortcut is to use
This tends to add a lot of clutter. One common shortcut is to use
:
<programlisting>
<programlisting>
#define _(x) gettext(x)
#define _(x) gettext(x)
</programlisting>
</programlisting>
...
@@ -447,7 +447,7 @@ fprintf(stderr, gettext("panic level %d\n"), lvl);
...
@@ -447,7 +447,7 @@ fprintf(stderr, gettext("panic level %d\n"), lvl);
<itemizedlist>
<itemizedlist>
<listitem>
<listitem>
<para>
<para>
Do not construct sentences at run-time, like
Do not construct sentences at run-time, like
:
<programlisting>
<programlisting>
printf("Files were %s.\n", flag ? "copied" : "removed");
printf("Files were %s.\n", flag ? "copied" : "removed");
</programlisting>
</programlisting>
...
@@ -468,7 +468,7 @@ printf("Files were %s.\n", flag ? "copied" : "removed");
...
@@ -468,7 +468,7 @@ printf("Files were %s.\n", flag ? "copied" : "removed");
printf("copied %d file%s", n, n!=1 ? "s" : "");
printf("copied %d file%s", n, n!=1 ? "s" : "");
</programlisting>
</programlisting>
because it assumes how the plural is formed. If you figured you
because it assumes how the plural is formed. If you figured you
could solve it like this
could solve it like this
:
<programlisting>
<programlisting>
if (n==1)
if (n==1)
printf("copied 1 file");
printf("copied 1 file");
...
@@ -490,7 +490,7 @@ printf("number of copied files: %d", n);
...
@@ -490,7 +490,7 @@ printf("number of copied files: %d", n);
If you want to communicate something to the translator, such as
If you want to communicate something to the translator, such as
about how a message is intended to line up with other output,
about how a message is intended to line up with other output,
precede the occurrence of the string with a comment that starts
precede the occurrence of the string with a comment that starts
with <literal>translator</literal>, e.g.
,
with <literal>translator</literal>, e.g.
:
<programlisting>
<programlisting>
/* translator: This message is not what it seems to be. */
/* translator: This message is not what it seems to be. */
</programlisting>
</programlisting>
...
...
doc/src/sgml/perform.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/perform.sgml,v 1.6
1 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/perform.sgml,v 1.6
2 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="performance-tips">
<chapter id="performance-tips">
<title>Performance Tips</title>
<title>Performance Tips</title>
...
@@ -157,7 +157,7 @@ EXPLAIN SELECT * FROM tenk1;
...
@@ -157,7 +157,7 @@ EXPLAIN SELECT * FROM tenk1;
</para>
</para>
<para>
<para>
This is about as straightforward as it gets. If you do
This is about as straightforward as it gets. If you do
:
<programlisting>
<programlisting>
SELECT relpages, reltuples FROM pg_class WHERE relname = 'tenk1';
SELECT relpages, reltuples FROM pg_class WHERE relname = 'tenk1';
...
@@ -588,7 +588,7 @@ SELECT attname, n_distinct, most_common_vals FROM pg_stats WHERE tablename = 'ro
...
@@ -588,7 +588,7 @@ SELECT attname, n_distinct, most_common_vals FROM pg_stats WHERE tablename = 'ro
</para>
</para>
<para>
<para>
In a simple join query, such as
In a simple join query, such as
:
<programlisting>
<programlisting>
SELECT * FROM a, b, c WHERE a.id = b.id AND b.ref = c.id;
SELECT * FROM a, b, c WHERE a.id = b.id AND b.ref = c.id;
</programlisting>
</programlisting>
...
@@ -628,7 +628,7 @@ SELECT * FROM a, b, c WHERE a.id = b.id AND b.ref = c.id;
...
@@ -628,7 +628,7 @@ SELECT * FROM a, b, c WHERE a.id = b.id AND b.ref = c.id;
<para>
<para>
When the query involves outer joins, the planner has less freedom
When the query involves outer joins, the planner has less freedom
than it does for plain (inner) joins. For example, consider
than it does for plain (inner) joins. For example, consider
:
<programlisting>
<programlisting>
SELECT * FROM a LEFT JOIN (b JOIN c ON (b.ref = c.id)) ON (a.id = b.id);
SELECT * FROM a LEFT JOIN (b JOIN c ON (b.ref = c.id)) ON (a.id = b.id);
</programlisting>
</programlisting>
...
@@ -639,7 +639,7 @@ SELECT * FROM a LEFT JOIN (b JOIN c ON (b.ref = c.id)) ON (a.id = b.id);
...
@@ -639,7 +639,7 @@ SELECT * FROM a LEFT JOIN (b JOIN c ON (b.ref = c.id)) ON (a.id = b.id);
B to C and then join A to that result. Accordingly, this query takes
B to C and then join A to that result. Accordingly, this query takes
less time to plan than the previous query. In other cases, the planner
less time to plan than the previous query. In other cases, the planner
might be able to determine that more than one join order is safe.
might be able to determine that more than one join order is safe.
For example, given
For example, given
:
<programlisting>
<programlisting>
SELECT * FROM a LEFT JOIN b ON (a.bid = b.id) LEFT JOIN c ON (a.cid = c.id);
SELECT * FROM a LEFT JOIN b ON (a.bid = b.id) LEFT JOIN c ON (a.cid = c.id);
</programlisting>
</programlisting>
...
@@ -683,7 +683,7 @@ SELECT * FROM a JOIN (b JOIN c ON (b.ref = c.id)) ON (a.id = b.id);
...
@@ -683,7 +683,7 @@ SELECT * FROM a JOIN (b JOIN c ON (b.ref = c.id)) ON (a.id = b.id);
<para>
<para>
You do not need to constrain the join order completely in order to
You do not need to constrain the join order completely in order to
cut search time, because it's OK to use <literal>JOIN</> operators
cut search time, because it's OK to use <literal>JOIN</> operators
within items of a plain <literal>FROM</> list. For example, consider
within items of a plain <literal>FROM</> list. For example, consider
:
<programlisting>
<programlisting>
SELECT * FROM a CROSS JOIN b, c, d, e WHERE ...;
SELECT * FROM a CROSS JOIN b, c, d, e WHERE ...;
</programlisting>
</programlisting>
...
@@ -704,7 +704,7 @@ SELECT * FROM a CROSS JOIN b, c, d, e WHERE ...;
...
@@ -704,7 +704,7 @@ SELECT * FROM a CROSS JOIN b, c, d, e WHERE ...;
<para>
<para>
A closely related issue that affects planning time is collapsing of
A closely related issue that affects planning time is collapsing of
subqueries into their parent query. For example, consider
subqueries into their parent query. For example, consider
:
<programlisting>
<programlisting>
SELECT *
SELECT *
FROM x, y,
FROM x, y,
...
@@ -714,7 +714,7 @@ WHERE somethingelse;
...
@@ -714,7 +714,7 @@ WHERE somethingelse;
This situation might arise from use of a view that contains a join;
This situation might arise from use of a view that contains a join;
the view's <literal>SELECT</> rule will be inserted in place of the view
the view's <literal>SELECT</> rule will be inserted in place of the view
reference, yielding a query much like the above. Normally, the planner
reference, yielding a query much like the above. Normally, the planner
will try to collapse the subquery into the parent, yielding
will try to collapse the subquery into the parent, yielding
:
<programlisting>
<programlisting>
SELECT * FROM x, y, a, b, c WHERE something AND somethingelse;
SELECT * FROM x, y, a, b, c WHERE something AND somethingelse;
</programlisting>
</programlisting>
...
...
doc/src/sgml/plperl.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.6
1 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/plperl.sgml,v 2.6
2 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="plperl">
<chapter id="plperl">
<title>PL/Perl - Perl Procedural Language</title>
<title>PL/Perl - Perl Procedural Language</title>
...
@@ -175,7 +175,7 @@ SELECT name, empcomp(employee.*) FROM employee;
...
@@ -175,7 +175,7 @@ SELECT name, empcomp(employee.*) FROM employee;
<para>
<para>
A PL/Perl function can return a composite-type result using the same
A PL/Perl function can return a composite-type result using the same
approach: return a reference to a hash that has the required attributes.
approach: return a reference to a hash that has the required attributes.
For example
,
For example
:
<programlisting>
<programlisting>
CREATE TYPE testrowperl AS (f1 integer, f2 text, f3 text);
CREATE TYPE testrowperl AS (f1 integer, f2 text, f3 text);
...
@@ -259,13 +259,13 @@ SELECT * FROM perl_set();
...
@@ -259,13 +259,13 @@ SELECT * FROM perl_set();
</para>
</para>
<para>
<para>
Another way to use the <literal>strict</> pragma is to put
Another way to use the <literal>strict</> pragma is to put
:
<programlisting>
<programlisting>
use strict;
use strict;
</programlisting>
</programlisting>
in the function body. But this only works in <application>PL/PerlU</>
in the function body. But this only works in <application>PL/PerlU</>
functions, since <literal>use</> is not a trusted operation. In
functions, since <literal>use</> is not a trusted operation. In
<application>PL/Perl</> functions you can instead do
<application>PL/Perl</> functions you can instead do
:
<programlisting>
<programlisting>
BEGIN { strict->import(); }
BEGIN { strict->import(); }
</programlisting>
</programlisting>
...
...
doc/src/sgml/plpgsql.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.10
4 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpgsql.sgml,v 1.10
5 2007/02/01 00:28:17
momjian 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>
...
@@ -264,7 +264,7 @@ $$ LANGUAGE plpgsql;
...
@@ -264,7 +264,7 @@ $$ LANGUAGE plpgsql;
<para>
<para>
While running <application>psql</application>, you can load or reload such
While running <application>psql</application>, you can load or reload such
a function definition file with
a function definition file with
:
<programlisting>
<programlisting>
\i filename.sql
\i filename.sql
</programlisting>
</programlisting>
...
@@ -299,7 +299,7 @@ $$ LANGUAGE plpgsql;
...
@@ -299,7 +299,7 @@ $$ LANGUAGE plpgsql;
approach, you never double any quote marks, but instead take care to
approach, you never double any quote marks, but instead take care to
choose a different dollar-quoting delimiter for each level of
choose a different dollar-quoting delimiter for each level of
nesting you need. For example, you might write the <command>CREATE
nesting you need. For example, you might write the <command>CREATE
FUNCTION</command> command as
FUNCTION</command> command as
:
<programlisting>
<programlisting>
CREATE OR REPLACE FUNCTION testfunc(integer) RETURNS integer AS $PROC$
CREATE OR REPLACE FUNCTION testfunc(integer) RETURNS integer AS $PROC$
....
....
...
@@ -343,7 +343,7 @@ CREATE FUNCTION foo() RETURNS integer AS '
...
@@ -343,7 +343,7 @@ CREATE FUNCTION foo() RETURNS integer AS '
a_output := ''Blah'';
a_output := ''Blah'';
SELECT * FROM users WHERE f_name=''foobar'';
SELECT * FROM users WHERE f_name=''foobar'';
</programlisting>
</programlisting>
In the dollar-quoting approach, you'd just write
In the dollar-quoting approach, you'd just write
:
<programlisting>
<programlisting>
a_output := 'Blah';
a_output := 'Blah';
SELECT * FROM users WHERE f_name='foobar';
SELECT * FROM users WHERE f_name='foobar';
...
@@ -367,7 +367,7 @@ a_output := a_output || '' AND name LIKE ''''foobar'''' AND xyz''
...
@@ -367,7 +367,7 @@ a_output := a_output || '' AND name LIKE ''''foobar'''' AND xyz''
<literal> AND name LIKE 'foobar' AND xyz</literal>.
<literal> AND name LIKE 'foobar' AND xyz</literal>.
</para>
</para>
<para>
<para>
In the dollar-quoting approach, you'd write
In the dollar-quoting approach, you'd write
:
<programlisting>
<programlisting>
a_output := a_output || $$ AND name LIKE 'foobar' AND xyz$$
a_output := a_output || $$ AND name LIKE 'foobar' AND xyz$$
</programlisting>
</programlisting>
...
@@ -390,7 +390,7 @@ a_output := a_output || '' AND name LIKE ''''foobar''''''
...
@@ -390,7 +390,7 @@ a_output := a_output || '' AND name LIKE ''''foobar''''''
<literal> AND name LIKE 'foobar'</literal>.
<literal> AND name LIKE 'foobar'</literal>.
</para>
</para>
<para>
<para>
In the dollar-quoting approach, this becomes
In the dollar-quoting approach, this becomes
:
<programlisting>
<programlisting>
a_output := a_output || $$ AND name LIKE 'foobar'$$
a_output := a_output || $$ AND name LIKE 'foobar'$$
</programlisting>
</programlisting>
...
@@ -421,7 +421,7 @@ if v_... like ''...'' then return ''...''; end if;
...
@@ -421,7 +421,7 @@ if v_... like ''...'' then return ''...''; end if;
</programlisting>
</programlisting>
</para>
</para>
<para>
<para>
In the dollar-quoting approach, this becomes
In the dollar-quoting approach, this becomes
:
<programlisting>
<programlisting>
a_output := a_output || $$ if v_$$ || referrer_keys.kind || $$ like '$$
a_output := a_output || $$ if v_$$ || referrer_keys.kind || $$ like '$$
|| referrer_keys.key_string || $$'
|| referrer_keys.key_string || $$'
...
@@ -625,7 +625,7 @@ $$ LANGUAGE plpgsql;
...
@@ -625,7 +625,7 @@ $$ LANGUAGE plpgsql;
<replaceable>name</replaceable> ALIAS FOR $<replaceable>n</replaceable>;
<replaceable>name</replaceable> ALIAS FOR $<replaceable>n</replaceable>;
</synopsis>
</synopsis>
The same example in this style looks like
The same example in this style looks like
:
<programlisting>
<programlisting>
CREATE FUNCTION sales_tax(real) RETURNS real AS $$
CREATE FUNCTION sales_tax(real) RETURNS real AS $$
DECLARE
DECLARE
...
@@ -943,7 +943,7 @@ CREATE FUNCTION logfunc1(logtxt text) RETURNS timestamp AS $$
...
@@ -943,7 +943,7 @@ CREATE FUNCTION logfunc1(logtxt text) RETURNS timestamp AS $$
$$ LANGUAGE plpgsql;
$$ LANGUAGE plpgsql;
</programlisting>
</programlisting>
and
and
:
<programlisting>
<programlisting>
CREATE FUNCTION logfunc2(logtxt text) RETURNS timestamp AS $$
CREATE FUNCTION logfunc2(logtxt text) RETURNS timestamp AS $$
...
@@ -1069,7 +1069,7 @@ tax := subtotal * 0.06;
...
@@ -1069,7 +1069,7 @@ tax := subtotal * 0.06;
This two-step process allows
This two-step process allows
<application>PL/pgSQL</application> to plan the query just once
<application>PL/pgSQL</application> to plan the query just once
and re-use the plan on subsequent executions. As an example,
and re-use the plan on subsequent executions. As an example,
if you write
if you write
:
<programlisting>
<programlisting>
DECLARE
DECLARE
key TEXT;
key TEXT;
...
@@ -1078,7 +1078,7 @@ BEGIN
...
@@ -1078,7 +1078,7 @@ BEGIN
...
...
UPDATE mytab SET val = val + delta WHERE id = key;
UPDATE mytab SET val = val + delta WHERE id = key;
</programlisting>
</programlisting>
the query text seen by the main SQL engine will look like
the query text seen by the main SQL engine will look like
:
<programlisting>
<programlisting>
UPDATE mytab SET val = val + $1 WHERE id = $2;
UPDATE mytab SET val = val + $1 WHERE id = $2;
</programlisting>
</programlisting>
...
@@ -1430,7 +1430,7 @@ EXECUTE 'UPDATE tbl SET '
...
@@ -1430,7 +1430,7 @@ EXECUTE 'UPDATE tbl SET '
<para>
<para>
Note that dollar quoting is only useful for quoting fixed text.
Note that dollar quoting is only useful for quoting fixed text.
It would be a very bad idea to try to do the above example as
It would be a very bad idea to try to do the above example as
:
<programlisting>
<programlisting>
EXECUTE 'UPDATE tbl SET '
EXECUTE 'UPDATE tbl SET '
|| quote_ident(colname)
|| quote_ident(colname)
...
@@ -2296,7 +2296,7 @@ END;
...
@@ -2296,7 +2296,7 @@ END;
<para>
<para>
This example uses exception handling to perform either
This example uses exception handling to perform either
<command>UPDATE</> or <command>INSERT</>, as appropriate
.
<command>UPDATE</> or <command>INSERT</>, as appropriate
:
<programlisting>
<programlisting>
CREATE TABLE db (a INT PRIMARY KEY, b TEXT);
CREATE TABLE db (a INT PRIMARY KEY, b TEXT);
...
@@ -3718,7 +3718,7 @@ $$ LANGUAGE plpgsql;
...
@@ -3718,7 +3718,7 @@ $$ LANGUAGE plpgsql;
In <application>PL/pgSQL</>, when an exception is caught by an
In <application>PL/pgSQL</>, when an exception is caught by an
<literal>EXCEPTION</> clause, all database changes since the block's
<literal>EXCEPTION</> clause, all database changes since the block's
<literal>BEGIN</> are automatically rolled back. That is, the behavior
<literal>BEGIN</> are automatically rolled back. That is, the behavior
is equivalent to what you'd get in Oracle with
is equivalent to what you'd get in Oracle with
:
<programlisting>
<programlisting>
BEGIN
BEGIN
...
...
doc/src/sgml/plpython.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpython.sgml,v 1.3
7 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/plpython.sgml,v 1.3
8 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="plpython">
<chapter id="plpython">
<title>PL/Python - Python Procedural Language</title>
<title>PL/Python - Python Procedural Language</title>
...
@@ -83,7 +83,7 @@ $$ LANGUAGE plpythonu;
...
@@ -83,7 +83,7 @@ $$ LANGUAGE plpythonu;
</programlisting>
</programlisting>
The Python code that is given as the body of the function definition
The Python code that is given as the body of the function definition
is transformed into a Python function. For example, the above results in
is transformed into a Python function. For example, the above results in
:
<programlisting>
<programlisting>
def __plpython_procedure_pymax_23456():
def __plpython_procedure_pymax_23456():
...
@@ -459,13 +459,13 @@ $$ LANGUAGE plpythonu;
...
@@ -459,13 +459,13 @@ $$ LANGUAGE plpythonu;
</para>
</para>
<para>
<para>
For example
,
For example
:
<programlisting>
<programlisting>
rv = plpy.execute("SELECT * FROM my_table", 5)
rv = plpy.execute("SELECT * FROM my_table", 5)
</programlisting>
</programlisting>
returns up to 5 rows from <literal>my_table</literal>. If
returns up to 5 rows from <literal>my_table</literal>. If
<literal>my_table</literal> has a column
<literal>my_table</literal> has a column
<literal>my_column</literal>, it would be accessed as
<literal>my_column</literal>, it would be accessed as
:
<programlisting>
<programlisting>
foo = rv[i]["my_column"]
foo = rv[i]["my_column"]
</programlisting>
</programlisting>
...
...
doc/src/sgml/pltcl.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/pltcl.sgml,v 2.4
4 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/pltcl.sgml,v 2.4
5 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="pltcl">
<chapter id="pltcl">
<title>PL/Tcl - Tcl Procedural Language</title>
<title>PL/Tcl - Tcl Procedural Language</title>
...
@@ -281,8 +281,7 @@ $$ LANGUAGE pltcl;
...
@@ -281,8 +281,7 @@ $$ LANGUAGE pltcl;
Tcl variables; remaining rows, if any, are ignored. No storing occurs
Tcl variables; remaining rows, if any, are ignored. No storing occurs
if the
if the
query returns no rows. (This case can be detected by checking the
query returns no rows. (This case can be detected by checking the
result of <function>spi_exec</function>.) For example,
result of <function>spi_exec</function>.) For example:
<programlisting>
<programlisting>
spi_exec "SELECT count(*) AS cnt FROM pg_proc"
spi_exec "SELECT count(*) AS cnt FROM pg_proc"
</programlisting>
</programlisting>
...
@@ -295,7 +294,7 @@ spi_exec "SELECT count(*) AS cnt FROM pg_proc"
...
@@ -295,7 +294,7 @@ spi_exec "SELECT count(*) AS cnt FROM pg_proc"
a piece of Tcl script that is executed once for each row in the
a piece of Tcl script that is executed once for each row in the
query result. (<replaceable>loop-body</> is ignored if the given
query result. (<replaceable>loop-body</> is ignored if the given
command is not a <command>SELECT</>.) The values of the current row's columns
command is not a <command>SELECT</>.) The values of the current row's columns
are stored into Tcl variables before each iteration. For example
,
are stored into Tcl variables before each iteration. For example
:
<programlisting>
<programlisting>
spi_exec -array C "SELECT * FROM pg_class" {
spi_exec -array C "SELECT * FROM pg_class" {
...
@@ -421,7 +420,7 @@ $$ LANGUAGE pltcl;
...
@@ -421,7 +420,7 @@ $$ LANGUAGE pltcl;
that are to be inserted into SQL commands given
that are to be inserted into SQL commands given
to <function>spi_exec</function> or
to <function>spi_exec</function> or
<function>spi_prepare</function>.
<function>spi_prepare</function>.
For example, think about an SQL command string like
For example, think about an SQL command string like
:
<programlisting>
<programlisting>
"SELECT '$val' AS ret"
"SELECT '$val' AS ret"
...
@@ -429,7 +428,7 @@ $$ LANGUAGE pltcl;
...
@@ -429,7 +428,7 @@ $$ LANGUAGE pltcl;
where the Tcl variable <literal>val</> actually contains
where the Tcl variable <literal>val</> actually contains
<literal>doesn't</literal>. This would result
<literal>doesn't</literal>. This would result
in the final command string
in the final command string
:
<programlisting>
<programlisting>
SELECT 'doesn't' AS ret
SELECT 'doesn't' AS ret
...
@@ -438,13 +437,13 @@ SELECT 'doesn't' AS ret
...
@@ -438,13 +437,13 @@ SELECT 'doesn't' AS ret
which would cause a parse error during
which would cause a parse error during
<function>spi_exec</function> or
<function>spi_exec</function> or
<function>spi_prepare</function>.
<function>spi_prepare</function>.
To work properly, the submitted command should contain
To work properly, the submitted command should contain
:
<programlisting>
<programlisting>
SELECT 'doesn''t' AS ret
SELECT 'doesn''t' AS ret
</programlisting>
</programlisting>
which can be formed in PL/Tcl using
which can be formed in PL/Tcl using
:
<programlisting>
<programlisting>
"SELECT '[ quote $val ]' AS ret"
"SELECT '[ quote $val ]' AS ret"
...
...
doc/src/sgml/queries.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/queries.sgml,v 1.4
2 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/queries.sgml,v 1.4
3 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="queries">
<chapter id="queries">
<title>Queries</title>
<title>Queries</title>
...
@@ -35,7 +35,7 @@ SELECT <replaceable>select_list</replaceable> FROM <replaceable>table_expression
...
@@ -35,7 +35,7 @@ SELECT <replaceable>select_list</replaceable> FROM <replaceable>table_expression
</para>
</para>
<para>
<para>
A simple kind of query has the form
A simple kind of query has the form
:
<programlisting>
<programlisting>
SELECT * FROM table1;
SELECT * FROM table1;
</programlisting>
</programlisting>
...
@@ -357,7 +357,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
...
@@ -357,7 +357,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
</para>
</para>
<para>
<para>
To put this together, assume we have tables <literal>t1</literal>
To put this together, assume we have tables <literal>t1</literal>
:
<programlisting>
<programlisting>
num | name
num | name
-----+------
-----+------
...
@@ -365,7 +365,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
...
@@ -365,7 +365,7 @@ FROM <replaceable>table_reference</replaceable> <optional>, <replaceable>table_r
2 | b
2 | b
3 | c
3 | c
</programlisting>
</programlisting>
and <literal>t2</literal>
and <literal>t2</literal>
:
<programlisting>
<programlisting>
num | value
num | value
-----+-------
-----+-------
...
@@ -507,7 +507,7 @@ SELECT * FROM some_very_long_table_name s JOIN another_fairly_long_name a ON s.i
...
@@ -507,7 +507,7 @@ SELECT * FROM some_very_long_table_name s JOIN another_fairly_long_name a ON s.i
<para>
<para>
The alias becomes the new name of the table reference for the
The alias becomes the new name of the table reference for the
current query — it is no longer possible to refer to the table
current query — 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 > 5;
</programlisting>
</programlisting>
...
@@ -517,7 +517,7 @@ SELECT * FROM my_table AS m WHERE my_table.a > 5;
...
@@ -517,7 +517,7 @@ SELECT * FROM my_table AS m WHERE my_table.a > 5;
<literal>off</> (as it is by default). If it is <literal>on</>,
<literal>off</> (as it is by default). If it is <literal>on</>,
an implicit table reference will be added to the
an implicit table reference will be added to the
<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 > 5;
</programlisting>
</programlisting>
...
@@ -526,7 +526,7 @@ SELECT * FROM my_table AS m, my_table AS my_table WHERE my_table.a > 5;
...
@@ -526,7 +526,7 @@ SELECT * FROM my_table AS m, my_table AS my_table WHERE my_table.a > 5;
<para>
<para>
Table aliases are mainly for notational convenience, but it is
Table aliases are mainly for notational convenience, but it is
necessary to use them when joining a table to itself, e.g.
,
necessary to use them when joining a table to itself, e.g.
:
<programlisting>
<programlisting>
SELECT * FROM people AS mother JOIN people AS child ON mother.id = child.mother_id;
SELECT * FROM people AS mother JOIN people AS child ON mother.id = child.mother_id;
</programlisting>
</programlisting>
...
@@ -559,11 +559,11 @@ FROM <replaceable>table_reference</replaceable> <optional>AS</optional> <replace
...
@@ -559,11 +559,11 @@ FROM <replaceable>table_reference</replaceable> <optional>AS</optional> <replace
<para>
<para>
When an alias is applied to the output of a <literal>JOIN</>
When an alias is applied to the output of a <literal>JOIN</>
clause, using any of these forms, the alias hides the original
clause, using any of these forms, the alias hides the original
names within the <literal>JOIN</>. For example
,
names within the <literal>JOIN</>. For example
:
<programlisting>
<programlisting>
SELECT a.* FROM my_table AS a JOIN your_table AS b ON ...
SELECT a.* FROM my_table AS a JOIN your_table AS b ON ...
</programlisting>
</programlisting>
is valid SQL, but
is valid SQL, but
:
<programlisting>
<programlisting>
SELECT a.* FROM (my_table AS a JOIN your_table AS b ON ...) AS c
SELECT a.* FROM (my_table AS a JOIN your_table AS b ON ...) AS c
</programlisting>
</programlisting>
...
@@ -724,11 +724,11 @@ WHERE <replaceable>search_condition</replaceable>
...
@@ -724,11 +724,11 @@ WHERE <replaceable>search_condition</replaceable>
<programlisting>
<programlisting>
FROM a, b WHERE a.id = b.id AND b.val > 5
FROM a, b WHERE a.id = b.id AND b.val > 5
</programlisting>
</programlisting>
and
and
:
<programlisting>
<programlisting>
FROM a INNER JOIN b ON (a.id = b.id) WHERE b.val > 5
FROM a INNER JOIN b ON (a.id = b.id) WHERE b.val > 5
</programlisting>
</programlisting>
or perhaps even
or perhaps even
:
<programlisting>
<programlisting>
FROM a NATURAL JOIN b WHERE b.val > 5
FROM a NATURAL JOIN b WHERE b.val > 5
</programlisting>
</programlisting>
...
@@ -867,7 +867,7 @@ SELECT <replaceable>select_list</replaceable>
...
@@ -867,7 +867,7 @@ SELECT <replaceable>select_list</replaceable>
<para>
<para>
Here is another example: it calculates the total sales for each
Here is another example: it calculates the total sales for each
product (rather than the total sales on all products)
.
product (rather than the total sales on all products)
:
<programlisting>
<programlisting>
SELECT product_id, p.name, (sum(s.units) * p.price) AS sales
SELECT product_id, p.name, (sum(s.units) * p.price) AS sales
FROM products p LEFT JOIN sales s USING (product_id)
FROM products p LEFT JOIN sales s USING (product_id)
...
@@ -997,7 +997,7 @@ SELECT a, b, c FROM ...
...
@@ -997,7 +997,7 @@ SELECT a, b, c FROM ...
<para>
<para>
If more than one table has a column of the same name, the table
If more than one table has a column of the same name, the table
name must also be given, as in
name must also be given, as in
:
<programlisting>
<programlisting>
SELECT tbl1.a, tbl2.a, tbl1.b FROM ...
SELECT tbl1.a, tbl2.a, tbl1.b FROM ...
</programlisting>
</programlisting>
...
@@ -1228,7 +1228,7 @@ SELECT <replaceable>select_list</replaceable>
...
@@ -1228,7 +1228,7 @@ SELECT <replaceable>select_list</replaceable>
<optional>, <replaceable>sort_expression2</replaceable> <optional>ASC | DESC</optional> <optional>NULLS { FIRST | LAST }</optional> ...</optional>
<optional>, <replaceable>sort_expression2</replaceable> <optional>ASC | DESC</optional> <optional>NULLS { FIRST | LAST }</optional> ...</optional>
</synopsis>
</synopsis>
The sort expression(s) can be any expression that would be valid in the
The sort expression(s) can be any expression that would be valid in the
query's select list. An example is
query's select list. An example is
:
<programlisting>
<programlisting>
SELECT a, b FROM table1 ORDER BY a + b, c;
SELECT a, b FROM table1 ORDER BY a + b, c;
</programlisting>
</programlisting>
...
@@ -1272,7 +1272,7 @@ SELECT a, b FROM table1 ORDER BY a + b, c;
...
@@ -1272,7 +1272,7 @@ SELECT a, b FROM table1 ORDER BY a + b, c;
<para>
<para>
For backwards compatibility with the SQL92 version of the standard,
For backwards compatibility with the SQL92 version of the standard,
a <replaceable>sort_expression</> can instead be the name or number
a <replaceable>sort_expression</> can instead be the name or number
of an output column, as in
of an output column, as in
:
<programlisting>
<programlisting>
SELECT a + b AS sum, c FROM table1 ORDER BY sum;
SELECT a + b AS sum, c FROM table1 ORDER BY sum;
SELECT a, max(b) FROM table1 GROUP BY a ORDER BY 1;
SELECT a, max(b) FROM table1 GROUP BY a ORDER BY 1;
...
@@ -1392,15 +1392,13 @@ VALUES ( <replaceable class="PARAMETER">expression</replaceable> [, ...] ) [, ..
...
@@ -1392,15 +1392,13 @@ VALUES ( <replaceable class="PARAMETER">expression</replaceable> [, ...] ) [, ..
</para>
</para>
<para>
<para>
As an example,
As an example:
<programlisting>
<programlisting>
VALUES (1, 'one'), (2, 'two'), (3, 'three');
VALUES (1, 'one'), (2, 'two'), (3, 'three');
</programlisting>
</programlisting>
will return a table of two columns and three rows. It's effectively
will return a table of two columns and three rows. It's effectively
equivalent to
equivalent to:
<programlisting>
<programlisting>
SELECT 1 AS column1, 'one' AS column2
SELECT 1 AS column1, 'one' AS column2
UNION ALL
UNION ALL
...
...
doc/src/sgml/query.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/query.sgml,v 1.
49 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/query.sgml,v 1.
50 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="tutorial-sql">
<chapter id="tutorial-sql">
<title>The <acronym>SQL</acronym> Language</title>
<title>The <acronym>SQL</acronym> Language</title>
...
@@ -383,7 +383,7 @@ SELECT * FROM weather
...
@@ -383,7 +383,7 @@ SELECT * FROM weather
In this example, the sort order isn't fully specified, and so you
In this example, the sort order isn't fully specified, and so you
might get the San Francisco rows in either order. But you'd always
might get the San Francisco rows in either order. But you'd always
get the results shown above if you do
get the results shown above if you do
:
<programlisting>
<programlisting>
SELECT * FROM weather
SELECT * FROM weather
...
@@ -663,7 +663,7 @@ SELECT *
...
@@ -663,7 +663,7 @@ SELECT *
<para>
<para>
As an example, we can find the highest low-temperature reading anywhere
As an example, we can find the highest low-temperature reading anywhere
with
with
:
<programlisting>
<programlisting>
SELECT max(temp_lo) FROM weather;
SELECT max(temp_lo) FROM weather;
...
@@ -681,7 +681,7 @@ SELECT max(temp_lo) FROM weather;
...
@@ -681,7 +681,7 @@ SELECT max(temp_lo) FROM weather;
<indexterm><primary>subquery</primary></indexterm>
<indexterm><primary>subquery</primary></indexterm>
If we wanted to know what city (or cities) that reading occurred in,
If we wanted to know what city (or cities) that reading occurred in,
we might try
we might try
:
<programlisting>
<programlisting>
SELECT city FROM weather WHERE temp_lo = max(temp_lo); <lineannotation>WRONG</lineannotation>
SELECT city FROM weather WHERE temp_lo = max(temp_lo); <lineannotation>WRONG</lineannotation>
...
@@ -720,7 +720,7 @@ SELECT city FROM weather
...
@@ -720,7 +720,7 @@ SELECT city FROM weather
Aggregates are also very useful in combination with <literal>GROUP
Aggregates are also very useful in combination with <literal>GROUP
BY</literal> clauses. For example, we can get the maximum low
BY</literal> clauses. For example, we can get the maximum low
temperature observed in each city with
temperature observed in each city with
:
<programlisting>
<programlisting>
SELECT city, max(temp_lo)
SELECT city, max(temp_lo)
...
@@ -758,7 +758,7 @@ SELECT city, max(temp_lo)
...
@@ -758,7 +758,7 @@ SELECT city, max(temp_lo)
which gives us the same results for only the cities that have all
which gives us the same results for only the cities that have all
<literal>temp_lo</> values below 40. Finally, if we only care about
<literal>temp_lo</> values below 40. Finally, if we only care about
cities whose
cities whose
names begin with <quote><literal>S</literal></quote>, we might do
names begin with <quote><literal>S</literal></quote>, we might do
:
<programlisting>
<programlisting>
SELECT city, max(temp_lo)
SELECT city, max(temp_lo)
...
...
doc/src/sgml/ref/alter_table.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.9
3 2007/01/31 23:26:02
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/alter_table.sgml,v 1.9
4 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -636,7 +636,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
...
@@ -636,7 +636,7 @@ where <replaceable class="PARAMETER">action</replaceable> is one of:
The fact that <literal>ALTER TYPE</> requires rewriting the whole table
The fact that <literal>ALTER TYPE</> requires rewriting the whole table
is sometimes an advantage, because the rewriting process eliminates
is sometimes an advantage, because the rewriting process eliminates
any dead space in the table. For example, to reclaim the space occupied
any dead space in the table. For example, to reclaim the space occupied
by a dropped column immediately, the fastest way is
by a dropped column immediately, the fastest way is
:
<programlisting>
<programlisting>
ALTER TABLE table ALTER COLUMN anycol TYPE anytype;
ALTER TABLE table ALTER COLUMN anycol TYPE anytype;
</programlisting>
</programlisting>
...
...
doc/src/sgml/ref/cluster.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/cluster.sgml,v 1.
39 2007/01/31 23:26:02
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/cluster.sgml,v 1.
40 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -144,7 +144,7 @@ CLUSTER
...
@@ -144,7 +144,7 @@ CLUSTER
entries are on random pages, so there is one disk page
entries are on random pages, so there is one disk page
retrieved for every row moved. (<productname>PostgreSQL</productname> has
retrieved for every row moved. (<productname>PostgreSQL</productname> has
a cache, but the majority of a big table will not fit in the cache.)
a cache, but the majority of a big table will not fit in the cache.)
The other way to cluster a table is to use
The other way to cluster a table is to use
:
<programlisting>
<programlisting>
CREATE TABLE <replaceable class="parameter">newtable</replaceable> AS
CREATE TABLE <replaceable class="parameter">newtable</replaceable> AS
...
...
doc/src/sgml/ref/create_aggregate.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_aggregate.sgml,v 1.3
7 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_aggregate.sgml,v 1.3
8 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -145,11 +145,11 @@ CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> (
...
@@ -145,11 +145,11 @@ CREATE AGGREGATE <replaceable class="PARAMETER">name</replaceable> (
input row. If this aggregate can be so optimized, indicate it by
input row. If this aggregate can be so optimized, indicate it by
specifying a <firstterm>sort operator</>. The basic requirement is that
specifying a <firstterm>sort operator</>. The basic requirement is that
the aggregate must yield the first element in the sort ordering induced by
the aggregate must yield the first element in the sort ordering induced by
the operator; in other words
the operator; in other words
:
<programlisting>
<programlisting>
SELECT agg(col) FROM tab;
SELECT agg(col) FROM tab;
</programlisting>
</programlisting>
must be equivalent to
must be equivalent to
:
<programlisting>
<programlisting>
SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;
SELECT col FROM tab ORDER BY col USING sortop LIMIT 1;
</programlisting>
</programlisting>
...
...
doc/src/sgml/ref/create_cast.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/create_cast.sgml,v 1.2
4 2007/01/31 23:26:03
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/create_cast.sgml,v 1.2
5 2007/02/01 00:28:18
momjian Exp $ -->
<refentry id="SQL-CREATECAST">
<refentry id="SQL-CREATECAST">
<refmeta>
<refmeta>
...
@@ -33,7 +33,7 @@ CREATE CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</r
...
@@ -33,7 +33,7 @@ CREATE CAST (<replaceable>sourcetype</replaceable> AS <replaceable>targettype</r
<para>
<para>
<command>CREATE CAST</command> defines a new cast. A cast
<command>CREATE CAST</command> defines a new cast. A cast
specifies how to perform a conversion between
specifies how to perform a conversion between
two data types. For example
,
two data types. For example
:
<programlisting>
<programlisting>
SELECT CAST(42 AS text);
SELECT CAST(42 AS text);
</programlisting>
</programlisting>
...
@@ -64,7 +64,7 @@ SELECT CAST(42 AS text);
...
@@ -64,7 +64,7 @@ SELECT CAST(42 AS text);
If the cast is marked <literal>AS ASSIGNMENT</> then it can be invoked
If the cast is marked <literal>AS ASSIGNMENT</> then it can be invoked
implicitly when assigning a value to a column of the target data type.
implicitly when assigning a value to a column of the target data type.
For example, supposing that <literal>foo.f1</literal> is a column of
For example, supposing that <literal>foo.f1</literal> is a column of
type <type>text</type>, then
type <type>text</type>, then
:
<programlisting>
<programlisting>
INSERT INTO foo (f1) VALUES (42);
INSERT INTO foo (f1) VALUES (42);
</programlisting>
</programlisting>
...
@@ -85,7 +85,7 @@ SELECT 'The time is ' || now();
...
@@ -85,7 +85,7 @@ SELECT 'The time is ' || now();
</programlisting>
</programlisting>
will be allowed only if the cast from type <type>timestamp</> to
will be allowed only if the cast from type <type>timestamp</> to
<type>text</type> is marked <literal>AS IMPLICIT</>. Otherwise it
<type>text</type> is marked <literal>AS IMPLICIT</>. Otherwise it
will be necessary to write the cast explicitly, for example
will be necessary to write the cast explicitly, for example
:
<programlisting>
<programlisting>
SELECT 'The time is ' || CAST(now() AS text);
SELECT 'The time is ' || CAST(now() AS text);
</programlisting>
</programlisting>
...
...
doc/src/sgml/ref/create_domain.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.3
0 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_domain.sgml,v 1.3
1 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -166,7 +166,7 @@ where <replaceable class="PARAMETER">constraint</replaceable> is:
...
@@ -166,7 +166,7 @@ where <replaceable class="PARAMETER">constraint</replaceable> is:
<para>
<para>
This example creates the <type>us_postal_code</type> data type and
This example creates the <type>us_postal_code</type> data type and
then uses the type in a table definition. A regular expression test
then uses the type in a table definition. A regular expression test
is used to verify that the value looks like a valid US postal code
.
is used to verify that the value looks like a valid US postal code
:
<programlisting>
<programlisting>
CREATE DOMAIN us_postal_code AS TEXT
CREATE DOMAIN us_postal_code AS TEXT
...
...
doc/src/sgml/ref/create_operator.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.4
7 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.4
8 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -205,7 +205,7 @@ CREATE OPERATOR <replaceable>name</replaceable> (
...
@@ -205,7 +205,7 @@ CREATE OPERATOR <replaceable>name</replaceable> (
<para>
<para>
To give a schema-qualified operator name in <replaceable
To give a schema-qualified operator name in <replaceable
class="parameter">com_op</replaceable> or the other optional
class="parameter">com_op</replaceable> or the other optional
arguments, use the <literal>OPERATOR()</> syntax, for example
arguments, use the <literal>OPERATOR()</> syntax, for example
:
<programlisting>
<programlisting>
COMMUTATOR = OPERATOR(myschema.===) ,
COMMUTATOR = OPERATOR(myschema.===) ,
</programlisting>
</programlisting>
...
...
doc/src/sgml/ref/create_rule.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.
49 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_rule.sgml,v 1.
50 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -248,7 +248,7 @@ SELECT * FROM t1;
...
@@ -248,7 +248,7 @@ SELECT * FROM t1;
command, the <command>NOTIFY</command> command will be executed
command, the <command>NOTIFY</command> command will be executed
unconditionally, that is, the <command>NOTIFY</command> will be
unconditionally, that is, the <command>NOTIFY</command> will be
issued even if there are not any rows that the rule should apply
issued even if there are not any rows that the rule should apply
to. For example, in
to. For example, in
:
<programlisting>
<programlisting>
CREATE RULE notify_me AS ON UPDATE TO mytable DO ALSO NOTIFY mytable;
CREATE RULE notify_me AS ON UPDATE TO mytable DO ALSO NOTIFY mytable;
...
...
doc/src/sgml/ref/create_sequence.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.4
6 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_sequence.sgml,v 1.4
7 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -57,7 +57,7 @@ CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">name</replac
...
@@ -57,7 +57,7 @@ CREATE [ TEMPORARY | TEMP ] SEQUENCE <replaceable class="parameter">name</replac
</para>
</para>
<para>
<para>
Although you cannot update a sequence directly, you can use a query like
Although you cannot update a sequence directly, you can use a query like
:
<programlisting>
<programlisting>
SELECT * FROM <replaceable>name</replaceable>;
SELECT * FROM <replaceable>name</replaceable>;
...
...
doc/src/sgml/ref/create_table.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.10
6 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_table.sgml,v 1.10
7 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -792,7 +792,7 @@ CREATE TABLE array_int (
...
@@ -792,7 +792,7 @@ CREATE TABLE array_int (
<para>
<para>
Define a unique table constraint for the table
Define a unique table constraint for the table
<literal>films</literal>. Unique table constraints can be defined
<literal>films</literal>. Unique table constraints can be defined
on one or more columns of the table
.
on one or more columns of the table
:
<programlisting>
<programlisting>
CREATE TABLE films (
CREATE TABLE films (
...
...
doc/src/sgml/ref/create_type.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.6
7 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_type.sgml,v 1.6
8 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -591,7 +591,7 @@ CREATE TABLE myboxes (
...
@@ -591,7 +591,7 @@ CREATE TABLE myboxes (
<para>
<para>
If the internal structure of <type>box</type> were an array of four
If the internal structure of <type>box</type> were an array of four
<type>float4</> elements, we might instead use
<type>float4</> elements, we might instead use
:
<programlisting>
<programlisting>
CREATE TYPE box (
CREATE TYPE box (
INTERNALLENGTH = 16,
INTERNALLENGTH = 16,
...
...
doc/src/sgml/ref/create_view.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.3
4 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/create_view.sgml,v 1.3
5 2007/02/01 00:28:18
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -126,13 +126,13 @@ CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW <replaceable class="PARAMETER">n
...
@@ -126,13 +126,13 @@ CREATE [ OR REPLACE ] [ TEMP | TEMPORARY ] VIEW <replaceable class="PARAMETER">n
<para>
<para>
Be careful that the names and types of the view's columns will be
Be careful that the names and types of the view's columns will be
assigned the way you want. For example
,
assigned the way you want. For example
:
<programlisting>
<programlisting>
CREATE VIEW vista AS SELECT 'Hello World';
CREATE VIEW vista AS SELECT 'Hello World';
</programlisting>
</programlisting>
is bad form in two ways: the column name defaults to <literal>?column?</>,
is bad form in two ways: the column name defaults to <literal>?column?</>,
and the column data type defaults to <type>unknown</>. If you want a
and the column data type defaults to <type>unknown</>. If you want a
string literal in a view's result, use something like
string literal in a view's result, use something like
:
<programlisting>
<programlisting>
CREATE VIEW vista AS SELECT text 'Hello World' AS hello;
CREATE VIEW vista AS SELECT text 'Hello World' AS hello;
</programlisting>
</programlisting>
...
...
doc/src/sgml/ref/delete.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/delete.sgml,v 1.
29 2007/01/31 23:26:03
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/delete.sgml,v 1.
30 2007/02/01 00:28:19
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -197,7 +197,7 @@ DELETE <replaceable class="parameter">count</replaceable>
...
@@ -197,7 +197,7 @@ DELETE <replaceable class="parameter">count</replaceable>
<productname>PostgreSQL</productname> lets you reference columns of
<productname>PostgreSQL</productname> lets you reference columns of
other tables in the <literal>WHERE</> condition by specifying the
other tables in the <literal>WHERE</> condition by specifying the
other tables in the <literal>USING</literal> clause. For example,
other tables in the <literal>USING</literal> clause. For example,
to delete all films produced by a given producer, one can do
to delete all films produced by a given producer, one can do
:
<programlisting>
<programlisting>
DELETE FROM films USING producers
DELETE FROM films USING producers
WHERE producer_id = producers.id AND producers.name = 'foo';
WHERE producer_id = producers.id AND producers.name = 'foo';
...
@@ -205,7 +205,7 @@ DELETE FROM films USING producers
...
@@ -205,7 +205,7 @@ DELETE FROM films USING producers
What is essentially happening here is a join between <structname>films</>
What is essentially happening here is a join between <structname>films</>
and <structname>producers</>, with all successfully joined
and <structname>producers</>, with all successfully joined
<structname>films</> rows being marked for deletion.
<structname>films</> rows being marked for deletion.
This syntax is not standard. A more standard way to do it is
This syntax is not standard. A more standard way to do it is
:
<programlisting>
<programlisting>
DELETE FROM films
DELETE FROM films
WHERE producer_id IN (SELECT id FROM producers WHERE name = 'foo');
WHERE producer_id IN (SELECT id FROM producers WHERE name = 'foo');
...
...
doc/src/sgml/ref/fetch.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/fetch.sgml,v 1.
39 2006/09/16 00:30:18
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/fetch.sgml,v 1.
40 2007/02/01 00:28:19
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -343,7 +343,7 @@ FETCH <replaceable class="parameter">count</replaceable>
...
@@ -343,7 +343,7 @@ FETCH <replaceable class="parameter">count</replaceable>
<title>Examples</title>
<title>Examples</title>
<para>
<para>
The following example traverses a table using a cursor
.
The following example traverses a table using a cursor
:
<programlisting>
<programlisting>
BEGIN WORK;
BEGIN WORK;
...
...
doc/src/sgml/ref/grant.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.6
3 2007/01/31 23:26:04
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/grant.sgml,v 1.6
4 2007/02/01 00:28:19
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -436,7 +436,7 @@ GRANT <replaceable class="PARAMETER">role</replaceable> [, ...] TO <replaceable
...
@@ -436,7 +436,7 @@ GRANT <replaceable class="PARAMETER">role</replaceable> [, ...] TO <replaceable
</programlisting>
</programlisting>
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
:
<programlisting>
<programlisting>
GRANT SELECT ON mytable TO PUBLIC;
GRANT SELECT ON mytable TO PUBLIC;
...
...
doc/src/sgml/ref/pg_restore.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.6
5 2007/01/31 23:26:04
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/ref/pg_restore.sgml,v 1.6
6 2007/02/01 00:28:19
momjian Exp $ -->
<refentry id="APP-PGRESTORE">
<refentry id="APP-PGRESTORE">
<refmeta>
<refmeta>
...
@@ -623,7 +623,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
...
@@ -623,7 +623,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
<screen>
<screen>
<prompt>$</prompt> <userinput>pg_restore -l db.dump > db.list</userinput>
<prompt>$</prompt> <userinput>pg_restore -l db.dump > db.list</userinput>
</screen>
</screen>
The listing file consists of a header and one line for each item, e.g.
,
The listing file consists of a header and one line for each item, e.g.
:
<programlisting>
<programlisting>
;
;
; Archive created at Fri Jul 28 22:28:36 2000
; Archive created at Fri Jul 28 22:28:36 2000
...
@@ -654,7 +654,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
...
@@ -654,7 +654,7 @@ CREATE DATABASE foo WITH TEMPLATE template0;
</para>
</para>
<para>
<para>
Lines in the file can be commented out, deleted, and reordered. For example
,
Lines in the file can be commented out, deleted, and reordered. For example
:
<programlisting>
<programlisting>
10; 145433 TABLE map_resolutions postgres
10; 145433 TABLE map_resolutions postgres
;2; 145344 TABLE species postgres
;2; 145344 TABLE species postgres
...
...
doc/src/sgml/ref/psql-ref.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.18
1 2007/01/31 23:26:04
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/psql-ref.sgml,v 1.18
2 2007/02/01 00:28:19
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -563,7 +563,7 @@ PostgreSQL documentation
...
@@ -563,7 +563,7 @@ PostgreSQL documentation
An alternative way to specify connection parameters is in a
An alternative way to specify connection parameters is in a
<parameter>conninfo</parameter> string, which is used instead of a
<parameter>conninfo</parameter> string, which is used instead of a
database name. This mechanism give you very wide control over the
database name. This mechanism give you very wide control over the
connection. For example
,
connection. For example
:
<programlisting>
<programlisting>
$ <userinput>psql "service=myservice sslmode=require"</userinput>
$ <userinput>psql "service=myservice sslmode=require"</userinput>
</programlisting>
</programlisting>
...
@@ -585,7 +585,7 @@ $ <userinput>psql "service=myservice sslmode=require"</userinput>
...
@@ -585,7 +585,7 @@ $ <userinput>psql "service=myservice sslmode=require"</userinput>
In normal operation, <application>psql</application> provides a
In normal operation, <application>psql</application> provides a
prompt with the name of the database to which
prompt with the name of the database to which
<application>psql</application> is currently connected, followed by
<application>psql</application> is currently connected, followed by
the string <literal>=></literal>. For example
,
the string <literal>=></literal>. For example
:
<programlisting>
<programlisting>
$ <userinput>psql testdb</userinput>
$ <userinput>psql testdb</userinput>
Welcome to psql &version;, the PostgreSQL interactive terminal.
Welcome to psql &version;, the PostgreSQL interactive terminal.
...
@@ -2134,7 +2134,7 @@ bar
...
@@ -2134,7 +2134,7 @@ bar
<listitem>
<listitem>
<para>
<para>
The file name that will be used to store the history list. The default
The file name that will be used to store the history list. The default
value is <filename>~/.psql_history</filename>. For example, putting
value is <filename>~/.psql_history</filename>. For example, putting
:
<programlisting>
<programlisting>
\set HISTFILE ~/.psql_history- :DBNAME
\set HISTFILE ~/.psql_history- :DBNAME
</programlisting>
</programlisting>
...
@@ -2344,7 +2344,7 @@ bar
...
@@ -2344,7 +2344,7 @@ bar
variables is that you can substitute (<quote>interpolate</quote>)
variables is that you can substitute (<quote>interpolate</quote>)
them into regular <acronym>SQL</acronym> statements. The syntax for
them into regular <acronym>SQL</acronym> statements. The syntax for
this is again to prepend the variable name with a colon
this is again to prepend the variable name with a colon
(<literal>:</literal>)
.
(<literal>:</literal>)
:
<programlisting>
<programlisting>
testdb=> <userinput>\set foo 'my_table'</userinput>
testdb=> <userinput>\set foo 'my_table'</userinput>
testdb=> <userinput>SELECT * FROM :foo;</userinput>
testdb=> <userinput>SELECT * FROM :foo;</userinput>
...
@@ -2361,7 +2361,7 @@ testdb=> <userinput>SELECT * FROM :foo;</userinput>
...
@@ -2361,7 +2361,7 @@ testdb=> <userinput>SELECT * FROM :foo;</userinput>
inserted <acronym>OID</acronym> in subsequent statements to build a
inserted <acronym>OID</acronym> in subsequent statements to build a
foreign key scenario. Another possible use of this mechanism is to
foreign key scenario. Another possible use of this mechanism is to
copy the contents of a file into a table column. First load the file into a
copy the contents of a file into a table column. First load the file into a
variable and then proceed as above
.
variable and then proceed as above
:
<programlisting>
<programlisting>
testdb=> <userinput>\set content '''' `cat my_file.txt` ''''</userinput>
testdb=> <userinput>\set content '''' `cat my_file.txt` ''''</userinput>
testdb=> <userinput>INSERT INTO my_table VALUES (:content);</userinput>
testdb=> <userinput>INSERT INTO my_table VALUES (:content);</userinput>
...
@@ -2566,7 +2566,7 @@ testdb=> <userinput>\set content '''' `sed -e "s/'/''/g" -e 's/\\/\\\\/g' <
...
@@ -2566,7 +2566,7 @@ testdb=> <userinput>\set content '''' `sed -e "s/'/''/g" -e 's/\\/\\\\/g' <
non-printing control characters must be designated as invisible
non-printing control characters must be designated as invisible
by surrounding them with <literal>%[</literal> and
by surrounding them with <literal>%[</literal> and
<literal>%]</literal>. Multiple pairs of these can occur within
<literal>%]</literal>. Multiple pairs of these can occur within
the prompt. For example
,
the prompt. For example
:
<programlisting>
<programlisting>
testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '
testdb=> \set PROMPT1 '%[%033[1;33;40m%]%n@%/%R%[%033[0m%]%# '
</programlisting>
</programlisting>
...
@@ -2759,7 +2759,7 @@ $endif
...
@@ -2759,7 +2759,7 @@ $endif
compatibility this is still supported to some extent,
compatibility this is still supported to some extent,
but we are not going to explain the details here as this use is
but we are not going to explain the details here as this use is
discouraged. If you get strange messages, keep this in mind.
discouraged. If you get strange messages, keep this in mind.
For example
For example
:
<programlisting>
<programlisting>
testdb=> <userinput>\foo</userinput>
testdb=> <userinput>\foo</userinput>
Field separator is "oo".
Field separator is "oo".
...
...
doc/src/sgml/ref/select.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.9
7 2007/01/31 23:26:04
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/select.sgml,v 1.9
8 2007/02/01 00:28:19
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -749,7 +749,7 @@ SELECT name FROM distributors ORDER BY code;
...
@@ -749,7 +749,7 @@ SELECT name FROM distributors ORDER BY code;
<literal>ORDER BY</> (see above). Note that the <quote>first
<literal>ORDER BY</> (see above). Note that the <quote>first
row</quote> of each set is unpredictable unless <literal>ORDER
row</quote> of each set is unpredictable unless <literal>ORDER
BY</> is used to ensure that the desired row appears first. For
BY</> is used to ensure that the desired row appears first. For
example
,
example
:
<programlisting>
<programlisting>
SELECT DISTINCT ON (location) location, time, report
SELECT DISTINCT ON (location) location, time, report
FROM weather_reports
FROM weather_reports
...
@@ -900,7 +900,7 @@ FOR SHARE [ OF <replaceable class="parameter">table_name</replaceable> [, ...] ]
...
@@ -900,7 +900,7 @@ FOR SHARE [ OF <replaceable class="parameter">table_name</replaceable> [, ...] ]
<para>
<para>
Avoid locking a row and then modifying it within a later savepoint or
Avoid locking a row and then modifying it within a later savepoint or
<application>PL/pgSQL</application> exception block. A subsequent
<application>PL/pgSQL</application> exception block. A subsequent
rollback would cause the lock to be lost. For example
,
rollback would cause the lock to be lost. For example
:
<programlisting>
<programlisting>
BEGIN;
BEGIN;
SELECT * FROM mytable WHERE key = 1 FOR UPDATE;
SELECT * FROM mytable WHERE key = 1 FOR UPDATE;
...
...
doc/src/sgml/ref/update.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.4
2 2007/01/31 23:26:04
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/update.sgml,v 1.4
3 2007/02/01 00:28:19
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -295,7 +295,7 @@ UPDATE employees SET sales_count = sales_count + 1 WHERE id =
...
@@ -295,7 +295,7 @@ UPDATE employees SET sales_count = sales_count + 1 WHERE id =
<para>
<para>
Attempt to insert a new stock item along with the quantity of stock. If
Attempt to insert a new stock item along with the quantity of stock. If
the item already exists, instead update the stock count of the existing
the item already exists, instead update the stock count of the existing
item. To do this without failing the entire transaction, use savepoints
.
item. To do this without failing the entire transaction, use savepoints
:
<programlisting>
<programlisting>
BEGIN;
BEGIN;
-- other operations
-- other operations
...
...
doc/src/sgml/ref/values.sgml
View file @
09a9f10e
<!--
<!--
$PostgreSQL: pgsql/doc/src/sgml/ref/values.sgml,v 1.
3 2007/01/31 23:26:05
momjian Exp $
$PostgreSQL: pgsql/doc/src/sgml/ref/values.sgml,v 1.
4 2007/02/01 00:28:19
momjian Exp $
PostgreSQL documentation
PostgreSQL documentation
-->
-->
...
@@ -143,7 +143,7 @@ VALUES (1, 'one'), (2, 'two'), (3, 'three');
...
@@ -143,7 +143,7 @@ VALUES (1, 'one'), (2, 'two'), (3, 'three');
</programlisting>
</programlisting>
This will return a table of two columns and three rows. It's effectively
This will return a table of two columns and three rows. It's effectively
equivalent to
equivalent to
:
<programlisting>
<programlisting>
SELECT 1 AS column1, 'one' AS column2
SELECT 1 AS column1, 'one' AS column2
...
...
doc/src/sgml/regress.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/regress.sgml,v 1.5
6 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/regress.sgml,v 1.5
7 2007/02/01 00:28:17
momjian Exp $ -->
<chapter id="regress">
<chapter id="regress">
<title id="regress-title">Regression Tests</title>
<title id="regress-title">Regression Tests</title>
...
@@ -315,7 +315,7 @@ exclusion of those that don't.
...
@@ -315,7 +315,7 @@ exclusion of those that don't.
<para>
<para>
The <literal>random</literal> test script is intended to produce
The <literal>random</literal> test script is intended to produce
random results. In rare cases, this causes the random regression
random results. In rare cases, this causes the random regression
test to fail. Typing
test to fail. Typing
:
<programlisting>
<programlisting>
diff results/random.out expected/random.out
diff results/random.out expected/random.out
</programlisting>
</programlisting>
...
@@ -370,7 +370,7 @@ testname/platformpattern=comparisonfilename
...
@@ -370,7 +370,7 @@ testname/platformpattern=comparisonfilename
<filename>float8-small-is-zero.out</filename>, which includes
<filename>float8-small-is-zero.out</filename>, which includes
the results to be expected on these systems. To silence the bogus
the results to be expected on these systems. To silence the bogus
<quote>failure</quote> message on <systemitem>OpenBSD</systemitem>
<quote>failure</quote> message on <systemitem>OpenBSD</systemitem>
platforms, <filename>resultmap</filename> includes
platforms, <filename>resultmap</filename> includes
:
<programlisting>
<programlisting>
float8/i.86-.*-openbsd=float8-small-is-zero
float8/i.86-.*-openbsd=float8-small-is-zero
</programlisting>
</programlisting>
...
...
doc/src/sgml/release.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.49
2 2007/01/31 20:56:18
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.49
3 2007/02/01 00:28:17
momjian Exp $ -->
<!--
<!--
Typical markup:
Typical markup:
...
@@ -9399,7 +9399,7 @@ WHERE pronamespace = 11 AND pronargs = 5
...
@@ -9399,7 +9399,7 @@ WHERE pronamespace = 11 AND pronargs = 5
COMMIT;
COMMIT;
</programlisting>
</programlisting>
Next, if you have installed <filename>contrib/tsearch2</>, do
Next, if you have installed <filename>contrib/tsearch2</>, do
:
<programlisting>
<programlisting>
BEGIN;
BEGIN;
...
@@ -9428,12 +9428,12 @@ COMMIT;
...
@@ -9428,12 +9428,12 @@ COMMIT;
template databases then any subsequently created databases will contain
template databases then any subsequently created databases will contain
the same errors. <literal>template1</> can be fixed in the same way
the same errors. <literal>template1</> can be fixed in the same way
as any other database, but fixing <literal>template0</> requires
as any other database, but fixing <literal>template0</> requires
additional steps. First, from any database issue
additional steps. First, from any database issue
:
<programlisting>
<programlisting>
UPDATE pg_database SET datallowconn = true WHERE datname = 'template0';
UPDATE pg_database SET datallowconn = true WHERE datname = 'template0';
</programlisting>
</programlisting>
Next connect to <literal>template0</> and perform the above repair
Next connect to <literal>template0</> and perform the above repair
procedures. Finally, do
procedures. Finally, do
:
<programlisting>
<programlisting>
-- re-freeze template0:
-- re-freeze template0:
VACUUM FREEZE;
VACUUM FREEZE;
...
@@ -9871,12 +9871,12 @@ GRANT SELECT, UPDATE ON pg_settings TO PUBLIC;
...
@@ -9871,12 +9871,12 @@ GRANT SELECT, UPDATE ON pg_settings TO PUBLIC;
template databases then any subsequently created databases will contain
template databases then any subsequently created databases will contain
the same errors. <literal>template1</> can be fixed in the same way
the same errors. <literal>template1</> can be fixed in the same way
as any other database, but fixing <literal>template0</> requires
as any other database, but fixing <literal>template0</> requires
additional steps. First, from any database issue
additional steps. First, from any database issue
:
<programlisting>
<programlisting>
UPDATE pg_database SET datallowconn = true WHERE datname = 'template0';
UPDATE pg_database SET datallowconn = true WHERE datname = 'template0';
</programlisting>
</programlisting>
Next connect to <literal>template0</> and perform the above repair
Next connect to <literal>template0</> and perform the above repair
procedures. Finally, do
procedures. Finally, do
:
<programlisting>
<programlisting>
-- re-freeze template0:
-- re-freeze template0:
VACUUM FREEZE;
VACUUM FREEZE;
...
@@ -12370,12 +12370,12 @@ COMMIT;
...
@@ -12370,12 +12370,12 @@ COMMIT;
template databases then any subsequently created databases will contain
template databases then any subsequently created databases will contain
the same error. <literal>template1</> can be fixed in the same way
the same error. <literal>template1</> can be fixed in the same way
as any other database, but fixing <literal>template0</> requires
as any other database, but fixing <literal>template0</> requires
additional steps. First, from any database issue
additional steps. First, from any database issue
:
<programlisting>
<programlisting>
UPDATE pg_database SET datallowconn = true WHERE datname = 'template0';
UPDATE pg_database SET datallowconn = true WHERE datname = 'template0';
</programlisting>
</programlisting>
Next connect to <literal>template0</> and perform the above repair
Next connect to <literal>template0</> and perform the above repair
procedure. Finally, do
procedure. Finally, do
:
<programlisting>
<programlisting>
-- re-freeze template0:
-- re-freeze template0:
VACUUM FREEZE;
VACUUM FREEZE;
...
@@ -17777,7 +17777,7 @@ If you do, you must create a file name <literal>pg_hba</literal> in your top-lev
...
@@ -17777,7 +17777,7 @@ If you do, you must create a file name <literal>pg_hba</literal> in your top-lev
<step>
<step>
<para>
<para>
If you do not want host-based authentication, you can comment out
If you do not want host-based authentication, you can comment out
the line
the line
:
<programlisting>
<programlisting>
HBA = 1
HBA = 1
</programlisting>
</programlisting>
...
...
doc/src/sgml/rowtypes.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/rowtypes.sgml,v 2.
8 2007/01/31 20:56
:18 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/rowtypes.sgml,v 2.
9 2007/02/01 00:28
:18 momjian Exp $ -->
<sect1 id="rowtypes">
<sect1 id="rowtypes">
<title>Composite Types</title>
<title>Composite Types</title>
...
@@ -70,7 +70,7 @@ SELECT price_extension(item, 10) FROM on_hand;
...
@@ -70,7 +70,7 @@ SELECT price_extension(item, 10) FROM on_hand;
<para>
<para>
Whenever you create a table, a composite type is also automatically
Whenever you create a table, a composite type is also automatically
created, with the same name as the table, to represent the table's
created, with the same name as the table, to represent the table's
row type. For example, had we said
row type. For example, had we said
:
<programlisting>
<programlisting>
CREATE TABLE inventory_item (
CREATE TABLE inventory_item (
name text,
name text,
...
@@ -106,7 +106,7 @@ CREATE TABLE inventory_item (
...
@@ -106,7 +106,7 @@ CREATE TABLE inventory_item (
<synopsis>
<synopsis>
'( <replaceable>val1</replaceable> , <replaceable>val2</replaceable> , ... )'
'( <replaceable>val1</replaceable> , <replaceable>val2</replaceable> , ... )'
</synopsis>
</synopsis>
An example is
An example is
:
<programlisting>
<programlisting>
'("fuzzy dice",42,1.99)'
'("fuzzy dice",42,1.99)'
</programlisting>
</programlisting>
...
@@ -143,7 +143,7 @@ ROW('fuzzy dice', 42, 1.99)
...
@@ -143,7 +143,7 @@ ROW('fuzzy dice', 42, 1.99)
ROW('', 42, NULL)
ROW('', 42, NULL)
</programlisting>
</programlisting>
The ROW keyword is actually optional as long as you have more than one
The ROW keyword is actually optional as long as you have more than one
field in the expression, so these can simplify to
field in the expression, so these can simplify to
:
<programlisting>
<programlisting>
('fuzzy dice', 42, 1.99)
('fuzzy dice', 42, 1.99)
('', 42, NULL)
('', 42, NULL)
...
@@ -189,7 +189,7 @@ SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price > 9.99;
...
@@ -189,7 +189,7 @@ SELECT (on_hand.item).name FROM on_hand WHERE (on_hand.item).price > 9.99;
<para>
<para>
Similar syntactic issues apply whenever you select a field from a composite
Similar syntactic issues apply whenever you select a field from a composite
value. For instance, to select just one field from the result of a function
value. For instance, to select just one field from the result of a function
that returns a composite value, you'd need to write something like
that returns a composite value, you'd need to write something like
:
<programlisting>
<programlisting>
SELECT (my_func(...)).field FROM ...
SELECT (my_func(...)).field FROM ...
...
@@ -254,7 +254,7 @@ INSERT INTO mytab (complex_col.r, complex_col.i) VALUES(1.1, 2.2);
...
@@ -254,7 +254,7 @@ INSERT INTO mytab (complex_col.r, complex_col.i) VALUES(1.1, 2.2);
items. Whitespace outside the parentheses is ignored, but within the
items. Whitespace outside the parentheses is ignored, but within the
parentheses it is considered part of the field value, and might or might not be
parentheses it is considered part of the field value, and might or might not be
significant depending on the input conversion rules for the field data type.
significant depending on the input conversion rules for the field data type.
For example, in
For example, in
:
<programlisting>
<programlisting>
'( 42)'
'( 42)'
</programlisting>
</programlisting>
...
@@ -297,7 +297,7 @@ INSERT INTO mytab (complex_col.r, complex_col.i) VALUES(1.1, 2.2);
...
@@ -297,7 +297,7 @@ INSERT INTO mytab (complex_col.r, complex_col.i) VALUES(1.1, 2.2);
backslashes you need (assuming escape string syntax is used).
backslashes you need (assuming escape string syntax is used).
For example, to insert a <type>text</> field
For example, to insert a <type>text</> field
containing a double quote and a backslash in a composite
containing a double quote and a backslash in a composite
value, you'd need to write
value, you'd need to write
:
<programlisting>
<programlisting>
INSERT ... VALUES (E'("\\"\\\\")');
INSERT ... VALUES (E'("\\"\\\\")');
</programlisting>
</programlisting>
...
...
doc/src/sgml/rules.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/rules.sgml,v 1.
49 2007/01/31 20:56
:18 momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/rules.sgml,v 1.
50 2007/02/01 00:28
:18 momjian Exp $ -->
<chapter id="rules">
<chapter id="rules">
<title>The Rule System</title>
<title>The Rule System</title>
...
@@ -278,13 +278,13 @@
...
@@ -278,13 +278,13 @@
<para>
<para>
Views in <productname>PostgreSQL</productname> are implemented
Views in <productname>PostgreSQL</productname> are implemented
using the rule system. In fact, there is essentially no difference
using the rule system. In fact, there is essentially no difference
between
between
:
<programlisting>
<programlisting>
CREATE VIEW myview AS SELECT * FROM mytab;
CREATE VIEW myview AS SELECT * FROM mytab;
</programlisting>
</programlisting>
compared against the two commands
compared against the two commands
:
<programlisting>
<programlisting>
CREATE TABLE myview (<replaceable>same column list as mytab</replaceable>);
CREATE TABLE myview (<replaceable>same column list as mytab</replaceable>);
...
@@ -340,7 +340,7 @@ CREATE RULE "_RETURN" AS ON SELECT TO myview DO INSTEAD
...
@@ -340,7 +340,7 @@ CREATE RULE "_RETURN" AS ON SELECT TO myview DO INSTEAD
<para>
<para>
For the example, we need a little <literal>min</literal> function that
For the example, we need a little <literal>min</literal> function that
returns the lower of 2 integer values. We create that as
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 $$
...
@@ -381,7 +381,7 @@ CREATE TABLE unit (
...
@@ -381,7 +381,7 @@ CREATE TABLE unit (
</para>
</para>
<para>
<para>
The views are created as
The views are created as
:
<programlisting>
<programlisting>
CREATE VIEW shoe AS
CREATE VIEW shoe AS
...
@@ -485,7 +485,7 @@ SELECT * FROM shoelace;
...
@@ -485,7 +485,7 @@ SELECT * FROM shoelace;
This is the simplest <command>SELECT</command> you can do on our
This is the simplest <command>SELECT</command> you can do on our
views, so we take this opportunity to explain the basics of view
views, so we take this opportunity to explain the basics of view
rules. The <literal>SELECT * FROM shoelace</literal> was
rules. The <literal>SELECT * FROM shoelace</literal> was
interpreted by the parser and produced the query tree
interpreted by the parser and produced the query tree
:
<programlisting>
<programlisting>
SELECT shoelace.sl_name, shoelace.sl_avail,
SELECT shoelace.sl_name, shoelace.sl_avail,
...
@@ -498,7 +498,7 @@ SELECT shoelace.sl_name, shoelace.sl_avail,
...
@@ -498,7 +498,7 @@ SELECT shoelace.sl_name, shoelace.sl_avail,
range table and checks if there are rules
range table and checks if there are rules
for any relation. When processing the range table entry for
for any relation. When processing the range table entry for
<literal>shoelace</literal> (the only one up to now) it finds the
<literal>shoelace</literal> (the only one up to now) it finds the
<literal>_RETURN</literal> rule with the query tree
<literal>_RETURN</literal> rule with the query tree
:
<programlisting>
<programlisting>
SELECT s.sl_name, s.sl_avail,
SELECT s.sl_name, s.sl_avail,
...
@@ -514,7 +514,7 @@ SELECT s.sl_name, s.sl_avail,
...
@@ -514,7 +514,7 @@ SELECT s.sl_name, s.sl_avail,
To expand the view, the rewriter simply creates a subquery range-table
To expand the view, the rewriter simply creates a subquery range-table
entry containing the rule's action query tree, and substitutes this
entry containing the rule's action query tree, and substitutes this
range table entry for the original one that referenced the view. The
range table entry for the original one that referenced the view. The
resulting rewritten query tree is almost the same as if you had typed
resulting rewritten query tree is almost the same as if you had typed
:
<programlisting>
<programlisting>
SELECT shoelace.sl_name, shoelace.sl_avail,
SELECT shoelace.sl_name, shoelace.sl_avail,
...
@@ -569,7 +569,7 @@ SELECT * FROM shoe_ready WHERE total_avail >= 2;
...
@@ -569,7 +569,7 @@ SELECT * FROM shoe_ready WHERE total_avail >= 2;
</para>
</para>
<para>
<para>
The output of the parser this time is the query tree
The output of the parser this time is the query tree
:
<programlisting>
<programlisting>
SELECT shoe_ready.shoename, shoe_ready.sh_avail,
SELECT shoe_ready.shoename, shoe_ready.sh_avail,
...
@@ -581,7 +581,7 @@ SELECT shoe_ready.shoename, shoe_ready.sh_avail,
...
@@ -581,7 +581,7 @@ SELECT shoe_ready.shoename, shoe_ready.sh_avail,
The first rule applied will be the one for the
The first rule applied will be the one for the
<literal>shoe_ready</literal> view and it results in the
<literal>shoe_ready</literal> view and it results in the
query tree
query tree
:
<programlisting>
<programlisting>
SELECT shoe_ready.shoename, shoe_ready.sh_avail,
SELECT shoe_ready.shoename, shoe_ready.sh_avail,
...
@@ -668,7 +668,7 @@ SELECT shoe_ready.shoename, shoe_ready.sh_avail,
...
@@ -668,7 +668,7 @@ SELECT shoe_ready.shoename, shoe_ready.sh_avail,
relation points to the range-table entry where the result should
relation points to the range-table entry where the result should
go. Everything else is absolutely the same. So having two tables
go. Everything else is absolutely the same. So having two tables
<literal>t1</> and <literal>t2</> with columns <literal>a</> and
<literal>t1</> and <literal>t2</> with columns <literal>a</> and
<literal>b</>, the query trees for the two statements
<literal>b</>, the query trees for the two statements
:
<programlisting>
<programlisting>
SELECT t2.b FROM t1, t2 WHERE t1.a = t2.a;
SELECT t2.b FROM t1, t2 WHERE t1.a = t2.a;
...
@@ -712,14 +712,14 @@ UPDATE t1 SET b = t2.b FROM t2 WHERE t1.a = t2.a;
...
@@ -712,14 +712,14 @@ UPDATE t1 SET b = t2.b FROM t2 WHERE t1.a = t2.a;
execution plans: They are both joins over the two tables. For the
execution plans: They are both joins over the two tables. For the
<command>UPDATE</command> the missing columns from <literal>t1</> are added to
<command>UPDATE</command> the missing columns from <literal>t1</> are added to
the target list by the planner and the final query tree will read
the target list by the planner and the final query tree will read
as
as
:
<programlisting>
<programlisting>
UPDATE t1 SET a = t1.a, b = t2.b FROM t2 WHERE t1.a = t2.a;
UPDATE t1 SET a = t1.a, b = t2.b FROM t2 WHERE t1.a = t2.a;
</programlisting>
</programlisting>
and thus the executor run over the join will produce exactly the
and thus the executor run over the join will produce exactly the
same result set as a
same result set as a
:
<programlisting>
<programlisting>
SELECT t1.a, t2.b FROM t1, t2 WHERE t1.a = t2.a;
SELECT t1.a, t2.b FROM t1, t2 WHERE t1.a = t2.a;
...
@@ -746,7 +746,7 @@ SELECT t1.a, t2.b FROM t1, t2 WHERE t1.a = t2.a;
...
@@ -746,7 +746,7 @@ SELECT t1.a, t2.b FROM t1, t2 WHERE t1.a = t2.a;
file block number and position in the block for the row. Knowing
file block number and position in the block for the row. Knowing
the table, the <acronym>CTID</> can be used to retrieve the
the table, the <acronym>CTID</> can be used to retrieve the
original row of <literal>t1</> to be updated. After adding the
original row of <literal>t1</> to be updated. After adding the
<acronym>CTID</> to the target list, the query actually looks like
<acronym>CTID</> to the target list, the query actually looks like
:
<programlisting>
<programlisting>
SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
...
@@ -884,7 +884,7 @@ SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
...
@@ -884,7 +884,7 @@ SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
<title>How Update Rules Work</title>
<title>How Update Rules Work</title>
<para>
<para>
Keep the syntax
Keep the syntax
:
<programlisting>
<programlisting>
CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS ON <replaceable class="parameter">event</replaceable>
CREATE [ OR REPLACE ] RULE <replaceable class="parameter">name</replaceable> AS ON <replaceable class="parameter">event</replaceable>
...
@@ -1054,7 +1054,7 @@ SELECT * FROM shoelace_log;
...
@@ -1054,7 +1054,7 @@ SELECT * FROM shoelace_log;
<para>
<para>
That's what we expected. What happened in the background is the following.
That's what we expected. What happened in the background is the following.
The parser created the query tree
The parser created the query tree
:
<programlisting>
<programlisting>
UPDATE shoelace_data SET sl_avail = 6
UPDATE shoelace_data SET sl_avail = 6
...
@@ -1063,13 +1063,13 @@ UPDATE shoelace_data SET sl_avail = 6
...
@@ -1063,13 +1063,13 @@ UPDATE shoelace_data SET sl_avail = 6
</programlisting>
</programlisting>
There is a rule <literal>log_shoelace</literal> that is <literal>ON UPDATE</> with the rule
There is a rule <literal>log_shoelace</literal> that is <literal>ON UPDATE</> with the rule
qualification expression
qualification expression
:
<programlisting>
<programlisting>
NEW.sl_avail <> OLD.sl_avail
NEW.sl_avail <> OLD.sl_avail
</programlisting>
</programlisting>
and the action
and the action
:
<programlisting>
<programlisting>
INSERT INTO shoelace_log VALUES (
INSERT INTO shoelace_log VALUES (
...
@@ -1188,7 +1188,7 @@ UPDATE shoelace_data SET sl_avail = 6
...
@@ -1188,7 +1188,7 @@ UPDATE shoelace_data SET sl_avail = 6
<para>
<para>
The substitutions and the added qualifications
The substitutions and the added qualifications
ensure that, if the original query would be, say
,
ensure that, if the original query would be, say
:
<programlisting>
<programlisting>
UPDATE shoelace_data SET sl_color = 'green'
UPDATE shoelace_data SET sl_color = 'green'
...
@@ -1199,7 +1199,7 @@ UPDATE shoelace_data SET sl_color = 'green'
...
@@ -1199,7 +1199,7 @@ UPDATE shoelace_data SET sl_color = 'green'
tree does not contain a target list entry for
tree does not contain a target list entry for
<literal>sl_avail</>, so <literal>NEW.sl_avail</> will get
<literal>sl_avail</>, so <literal>NEW.sl_avail</> will get
replaced by <literal>shoelace_data.sl_avail</>. Thus, the extra
replaced by <literal>shoelace_data.sl_avail</>. Thus, the extra
command generated by the rule is
command generated by the rule is
:
<programlisting>
<programlisting>
INSERT INTO shoelace_log VALUES (
INSERT INTO shoelace_log VALUES (
...
@@ -1215,7 +1215,7 @@ INSERT INTO shoelace_log VALUES (
...
@@ -1215,7 +1215,7 @@ INSERT INTO shoelace_log VALUES (
<para>
<para>
It will also work if the original query modifies multiple rows. So
It will also work if the original query modifies multiple rows. So
if someone issued the command
if someone issued the command
:
<programlisting>
<programlisting>
UPDATE shoelace_data SET sl_avail = 0
UPDATE shoelace_data SET sl_avail = 0
...
@@ -1225,7 +1225,7 @@ UPDATE shoelace_data SET sl_avail = 0
...
@@ -1225,7 +1225,7 @@ UPDATE shoelace_data SET sl_avail = 0
four rows in fact get updated (<literal>sl1</>, <literal>sl2</>, <literal>sl3</>, and <literal>sl4</>).
four rows in fact get updated (<literal>sl1</>, <literal>sl2</>, <literal>sl3</>, and <literal>sl4</>).
But <literal>sl3</> already has <literal>sl_avail = 0</>. In this case, the original
But <literal>sl3</> already has <literal>sl_avail = 0</>. In this case, the original
query trees qualification is different and that results
query trees qualification is different and that results
in the extra query tree
in the extra query tree
:
<programlisting>
<programlisting>
INSERT INTO shoelace_log
INSERT INTO shoelace_log
...
@@ -1260,7 +1260,7 @@ SELECT shoelace_data.sl_name, 0,
...
@@ -1260,7 +1260,7 @@ SELECT shoelace_data.sl_name, 0,
A simple way to protect view relations from the mentioned
A simple way to protect view relations from the mentioned
possibility that someone can try to run <command>INSERT</command>,
possibility that someone can try to run <command>INSERT</command>,
<command>UPDATE</command>, or <command>DELETE</command> on them is
<command>UPDATE</command>, or <command>DELETE</command> on them is
to let those query trees get thrown away. So we could create the rules
to let those query trees get thrown away. So we could create the rules
:
<programlisting>
<programlisting>
CREATE RULE shoe_ins_protect AS ON INSERT TO shoe
CREATE RULE shoe_ins_protect AS ON INSERT TO shoe
...
@@ -1320,7 +1320,7 @@ CREATE RULE shoelace_del AS ON DELETE TO shoelace
...
@@ -1320,7 +1320,7 @@ CREATE RULE shoelace_del AS ON DELETE TO shoelace
you need to make the rules include <literal>RETURNING</> clauses that
you need to make the rules include <literal>RETURNING</> clauses that
compute the view rows. This is usually pretty trivial for views on a
compute the view rows. This is usually pretty trivial for views on a
single table, but it's a bit tedious for join views such as
single table, but it's a bit tedious for join views such as
<literal>shoelace</literal>. An example for the insert case is
<literal>shoelace</literal>. An example for the insert case is
:
<programlisting>
<programlisting>
CREATE RULE shoelace_ins AS ON INSERT TO shoelace
CREATE RULE shoelace_ins AS ON INSERT TO shoelace
...
@@ -1440,7 +1440,7 @@ SELECT * FROM shoelace_log;
...
@@ -1440,7 +1440,7 @@ SELECT * FROM shoelace_log;
It's a long way from the one <literal>INSERT ... SELECT</literal>
It's a long way from the one <literal>INSERT ... SELECT</literal>
to these results. And the description of the query-tree
to these results. And the description of the query-tree
transformation will be the last in this chapter. First, there is
transformation will be the last in this chapter. First, there is
the parser's output
the parser's output
:
<programlisting>
<programlisting>
INSERT INTO shoelace_ok
INSERT INTO shoelace_ok
...
@@ -1449,7 +1449,7 @@ SELECT shoelace_arrive.arr_name, shoelace_arrive.arr_quant
...
@@ -1449,7 +1449,7 @@ SELECT shoelace_arrive.arr_name, shoelace_arrive.arr_quant
</programlisting>
</programlisting>
Now the first rule <literal>shoelace_ok_ins</literal> is applied and turns this
Now the first rule <literal>shoelace_ok_ins</literal> is applied and turns this
into
into
:
<programlisting>
<programlisting>
UPDATE shoelace
UPDATE shoelace
...
@@ -1463,7 +1463,7 @@ UPDATE shoelace
...
@@ -1463,7 +1463,7 @@ UPDATE shoelace
and throws away the original <command>INSERT</command> on
and throws away the original <command>INSERT</command> on
<literal>shoelace_ok</literal>. This rewritten query is passed to
<literal>shoelace_ok</literal>. This rewritten query is passed to
the rule system again, and the second applied rule
the rule system again, and the second applied rule
<literal>shoelace_upd</literal> produces
<literal>shoelace_upd</literal> produces
:
<programlisting>
<programlisting>
UPDATE shoelace_data
UPDATE shoelace_data
...
@@ -1483,7 +1483,7 @@ UPDATE shoelace_data
...
@@ -1483,7 +1483,7 @@ UPDATE shoelace_data
Again it's an <literal>INSTEAD</> rule and the previous query tree is trashed.
Again it's an <literal>INSTEAD</> rule and the previous query tree is trashed.
Note that this query still uses the view <literal>shoelace</literal>.
Note that this query still uses the view <literal>shoelace</literal>.
But the rule system isn't finished with this step, so it continues
But the rule system isn't finished with this step, so it continues
and applies the <literal>_RETURN</literal> rule on it, and we get
and applies the <literal>_RETURN</literal> rule on it, and we get
:
<programlisting>
<programlisting>
UPDATE shoelace_data
UPDATE shoelace_data
...
@@ -1503,7 +1503,7 @@ UPDATE shoelace_data
...
@@ -1503,7 +1503,7 @@ UPDATE shoelace_data
</programlisting>
</programlisting>
Finally, the rule <literal>log_shoelace</literal> gets applied,
Finally, the rule <literal>log_shoelace</literal> gets applied,
producing the extra query tree
producing the extra query tree
:
<programlisting>
<programlisting>
INSERT INTO shoelace_log
INSERT INTO shoelace_log
...
@@ -1530,7 +1530,7 @@ SELECT s.sl_name,
...
@@ -1530,7 +1530,7 @@ SELECT s.sl_name,
<para>
<para>
So we end up with two final query trees that are equivalent to the
So we end up with two final query trees that are equivalent to the
<acronym>SQL</acronym> statements
<acronym>SQL</acronym> statements
:
<programlisting>
<programlisting>
INSERT INTO shoelace_log
INSERT INTO shoelace_log
...
@@ -1612,7 +1612,7 @@ INSERT INTO shoelace VALUES ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0);
...
@@ -1612,7 +1612,7 @@ INSERT INTO shoelace VALUES ('sl10', 1000, 'magenta', 40.0, 'inch', 0.0);
We would like to make a view to check which
We would like to make a view to check which
<literal>shoelace</literal> entries do not fit any shoe in color.
<literal>shoelace</literal> entries do not fit any shoe in color.
The view for this is
The view for this is
:
<programlisting>
<programlisting>
CREATE VIEW shoelace_mismatch AS
CREATE VIEW shoelace_mismatch AS
...
@@ -1620,7 +1620,7 @@ CREATE VIEW shoelace_mismatch AS
...
@@ -1620,7 +1620,7 @@ CREATE VIEW shoelace_mismatch AS
(SELECT shoename FROM shoe WHERE slcolor = sl_color);
(SELECT shoename FROM shoe WHERE slcolor = sl_color);
</programlisting>
</programlisting>
Its output is
Its output is
:
<programlisting>
<programlisting>
SELECT * FROM shoelace_mismatch;
SELECT * FROM shoelace_mismatch;
...
@@ -1636,7 +1636,7 @@ SELECT * FROM shoelace_mismatch;
...
@@ -1636,7 +1636,7 @@ SELECT * FROM shoelace_mismatch;
Now we want to set it up so that mismatching shoelaces that are
Now we want to set it up so that mismatching shoelaces that are
not in stock are deleted from the database.
not in stock are deleted from the database.
To make it a little harder for <productname>PostgreSQL</productname>,
To make it a little harder for <productname>PostgreSQL</productname>,
we don't delete it directly. Instead we create one more view
we don't delete it directly. Instead we create one more view
:
<programlisting>
<programlisting>
CREATE VIEW shoelace_can_delete AS
CREATE VIEW shoelace_can_delete AS
...
@@ -1918,7 +1918,7 @@ DELETE FROM software WHERE hostname = $1;
...
@@ -1918,7 +1918,7 @@ DELETE FROM software WHERE hostname = $1;
Since the trigger is called for each individual row deleted from
Since the trigger is called for each individual row deleted from
<literal>computer</>, it can prepare and save the plan for this
<literal>computer</>, it can prepare and save the plan for this
command and pass the <structfield>hostname</> value in the
command and pass the <structfield>hostname</> value in the
parameter. The rule would be written as
parameter. The rule would be written as
:
<programlisting>
<programlisting>
CREATE RULE computer_del AS ON DELETE TO computer
CREATE RULE computer_del AS ON DELETE TO computer
...
@@ -1927,7 +1927,7 @@ CREATE RULE computer_del AS ON DELETE TO computer
...
@@ -1927,7 +1927,7 @@ CREATE RULE computer_del AS ON DELETE TO computer
</para>
</para>
<para>
<para>
Now we look at different types of deletes. In the case of a
Now we look at different types of deletes. In the case of a
:
<programlisting>
<programlisting>
DELETE FROM computer WHERE hostname = 'mypc.local.net';
DELETE FROM computer WHERE hostname = 'mypc.local.net';
...
@@ -1935,7 +1935,7 @@ DELETE FROM computer WHERE hostname = 'mypc.local.net';
...
@@ -1935,7 +1935,7 @@ DELETE FROM computer WHERE hostname = 'mypc.local.net';
the table <literal>computer</> is scanned by index (fast), and the
the table <literal>computer</> is scanned by index (fast), and the
command issued by the trigger would also use an index scan (also fast).
command issued by the trigger would also use an index scan (also fast).
The extra command from the rule would be
The extra command from the rule would be
:
<programlisting>
<programlisting>
DELETE FROM software WHERE computer.hostname = 'mypc.local.net'
DELETE FROM software WHERE computer.hostname = 'mypc.local.net'
...
@@ -1959,14 +1959,14 @@ Nestloop
...
@@ -1959,14 +1959,14 @@ Nestloop
With the next delete we want to get rid of all the 2000 computers
With the next delete we want to get rid of all the 2000 computers
where the <structfield>hostname</> starts with
where the <structfield>hostname</> starts with
<literal>old</>. There are two possible commands to do that. One
<literal>old</>. There are two possible commands to do that. One
is
is
:
<programlisting>
<programlisting>
DELETE FROM computer WHERE hostname >= 'old'
DELETE FROM computer WHERE hostname >= 'old'
AND hostname < 'ole'
AND hostname < '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 >= 'old' AND computer.hostname < 'ole'
...
@@ -1982,7 +1982,7 @@ Hash Join
...
@@ -1982,7 +1982,7 @@ Hash Join
-> Index Scan using comp_hostidx on computer
-> Index Scan using comp_hostidx on computer
</literallayout>
</literallayout>
The other possible command is
The other possible command is
:
<programlisting>
<programlisting>
DELETE FROM computer WHERE hostname ~ '^old';
DELETE FROM computer WHERE hostname ~ '^old';
...
@@ -2014,7 +2014,7 @@ Nestloop
...
@@ -2014,7 +2014,7 @@ Nestloop
</para>
</para>
<para>
<para>
The last command we look at is
The last command we look at is
:
<programlisting>
<programlisting>
DELETE FROM computer WHERE manufacturer = 'bim';
DELETE FROM computer WHERE manufacturer = 'bim';
...
@@ -2022,7 +2022,7 @@ DELETE FROM computer WHERE manufacturer = 'bim';
...
@@ -2022,7 +2022,7 @@ DELETE FROM computer WHERE manufacturer = 'bim';
Again this could result in many rows to be deleted from
Again this could result in many rows to be deleted from
<literal>computer</>. So the trigger will again run many commands
<literal>computer</>. So the trigger will again run many commands
through the executor. The command generated by the rule will be
through the executor. The command generated by the rule will be
:
<programlisting>
<programlisting>
DELETE FROM software WHERE computer.manufacturer = 'bim'
DELETE FROM software WHERE computer.manufacturer = 'bim'
...
...
doc/src/sgml/runtime.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.37
5 2007/01/31 20:56:19
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.37
6 2007/02/01 00:28:18
momjian Exp $ -->
<chapter Id="runtime">
<chapter Id="runtime">
<title>Operating System Environment</title>
<title>Operating System Environment</title>
...
@@ -901,7 +901,7 @@ sysctl -w kern.sysv.shmall
...
@@ -901,7 +901,7 @@ sysctl -w kern.sysv.shmall
<para>
<para>
In OS X 10.3.9 and later, instead of editing <filename>/etc/rc</>
In OS X 10.3.9 and later, instead of editing <filename>/etc/rc</>
you can create a file named <filename>/etc/sysctl.conf</>,
you can create a file named <filename>/etc/sysctl.conf</>,
containing variable assignments such as
containing variable assignments such as
:
<programlisting>
<programlisting>
kern.sysv.shmmax=4194304
kern.sysv.shmmax=4194304
kern.sysv.shmmin=1
kern.sysv.shmmin=1
...
@@ -940,11 +940,11 @@ kern.sysv.shmall=1024
...
@@ -940,11 +940,11 @@ kern.sysv.shmall=1024
In the default configuration, only 512 kB of shared memory per
In the default configuration, only 512 kB of shared memory per
segment is allowed. To increase the setting, first change to the
segment is allowed. To increase the setting, first change to the
directory <filename>/etc/conf/cf.d</>. To display the current value of
directory <filename>/etc/conf/cf.d</>. To display the current value of
<varname>SHMMAX</>, run
<varname>SHMMAX</>, run
:
<programlisting>
<programlisting>
./configure -y SHMMAX
./configure -y SHMMAX
</programlisting>
</programlisting>
To set a new value for <varname>SHMMAX</>, run
To set a new value for <varname>SHMMAX</>, run
:
<programlisting>
<programlisting>
./configure SHMMAX=<replaceable>value</>
./configure SHMMAX=<replaceable>value</>
</programlisting>
</programlisting>
...
@@ -1019,13 +1019,13 @@ set semsys:seminfo_semmsl=32
...
@@ -1019,13 +1019,13 @@ set semsys:seminfo_semmsl=32
<para>
<para>
On <productname>UnixWare</> 7, the maximum size for shared
On <productname>UnixWare</> 7, the maximum size for shared
memory segments is only 512 kB in the default configuration.
memory segments is only 512 kB in the default configuration.
To display the current value of <varname>SHMMAX</>, run
To display the current value of <varname>SHMMAX</>, run
:
<programlisting>
<programlisting>
/etc/conf/bin/idtune -g SHMMAX
/etc/conf/bin/idtune -g SHMMAX
</programlisting>
</programlisting>
which displays the current, default, minimum, and maximum
which displays the current, default, minimum, and maximum
values. To set a new value for <varname>SHMMAX</>,
values. To set a new value for <varname>SHMMAX</>,
run
run
:
<programlisting>
<programlisting>
/etc/conf/bin/idtune SHMMAX <replaceable>value</>
/etc/conf/bin/idtune SHMMAX <replaceable>value</>
</programlisting>
</programlisting>
...
@@ -1533,12 +1533,12 @@ openssl req -new -text -out server.req
...
@@ -1533,12 +1533,12 @@ openssl req -new -text -out server.req
password can be left blank. The program will generate a key that is
password can be left blank. The program will generate a key that is
passphrase protected; it will not accept a passphrase that is less
passphrase protected; it will not accept a passphrase that is less
than four characters long. To remove the passphrase (as you must if
than four characters long. To remove the passphrase (as you must if
you want automatic start-up of the server), run the commands
you want automatic start-up of the server), run the commands
:
<programlisting>
<programlisting>
openssl rsa -in privkey.pem -out server.key
openssl rsa -in privkey.pem -out server.key
rm privkey.pem
rm privkey.pem
</programlisting>
</programlisting>
Enter the old passphrase to unlock the existing key. Now do
Enter the old passphrase to unlock the existing key. Now do
:
<programlisting>
<programlisting>
openssl req -x509 -in server.req -text -key server.key -out server.crt
openssl req -x509 -in server.req -text -key server.key -out server.crt
chmod og-rwx server.key
chmod og-rwx server.key
...
...
doc/src/sgml/sources.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/sources.sgml,v 2.2
2 2007/01/31 21:03:37
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/sources.sgml,v 2.2
3 2007/02/01 00:28:18
momjian Exp $ -->
<chapter id="source">
<chapter id="source">
<title>PostgreSQL Coding Conventions</title>
<title>PostgreSQL Coding Conventions</title>
...
@@ -30,7 +30,7 @@
...
@@ -30,7 +30,7 @@
<para>
<para>
The text browsing tools <application>more</application> and
The text browsing tools <application>more</application> and
<application>less</application> can be invoked as
<application>less</application> can be invoked as
:
<programlisting>
<programlisting>
more -x4
more -x4
less -x4
less -x4
...
@@ -211,11 +211,11 @@ ereport(ERROR,
...
@@ -211,11 +211,11 @@ ereport(ERROR,
<para>
<para>
There is an older function <function>elog</> that is still heavily used.
There is an older function <function>elog</> that is still heavily used.
An <function>elog</> call
An <function>elog</> call
:
<programlisting>
<programlisting>
elog(level, "format string", ...);
elog(level, "format string", ...);
</programlisting>
</programlisting>
is exactly equivalent to
is exactly equivalent to
:
<programlisting>
<programlisting>
ereport(level, (errmsg_internal("format string", ...)));
ereport(level, (errmsg_internal("format string", ...)));
</programlisting>
</programlisting>
...
@@ -260,12 +260,12 @@ ereport(level, (errmsg_internal("format string", ...)));
...
@@ -260,12 +260,12 @@ ereport(level, (errmsg_internal("format string", ...)));
</para>
</para>
<para>
<para>
For example, instead of
For example, instead of
:
<programlisting>
<programlisting>
IpcMemoryCreate: shmget(key=%d, size=%u, 0%o) failed: %m
IpcMemoryCreate: shmget(key=%d, size=%u, 0%o) failed: %m
(plus a long addendum that is basically a hint)
(plus a long addendum that is basically a hint)
</programlisting>
</programlisting>
write
write
:
<programlisting>
<programlisting>
Primary: could not create shared memory segment: %m
Primary: could not create shared memory segment: %m
Detail: Failed syscall was shmget(key=%d, size=%u, 0%o).
Detail: Failed syscall was shmget(key=%d, size=%u, 0%o).
...
@@ -424,11 +424,11 @@ Hint: the addendum
...
@@ -424,11 +424,11 @@ Hint: the addendum
</para>
</para>
<para>
<para>
There is a nontrivial semantic difference between sentences of the form
There is a nontrivial semantic difference between sentences of the form
:
<programlisting>
<programlisting>
could not open file "%s": %m
could not open file "%s": %m
</programlisting>
</programlisting>
and
and
:
<programlisting>
<programlisting>
cannot open file "%s"
cannot open file "%s"
</programlisting>
</programlisting>
...
...
doc/src/sgml/spi.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.5
0 2007/01/31 20:56:19
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/spi.sgml,v 1.5
1 2007/02/01 00:28:18
momjian Exp $ -->
<chapter id="spi">
<chapter id="spi">
<title>Server Programming Interface</title>
<title>Server Programming Interface</title>
...
@@ -313,7 +313,7 @@ int SPI_execute(const char * <parameter>command</parameter>, bool <parameter>rea
...
@@ -313,7 +313,7 @@ int SPI_execute(const char * <parameter>command</parameter>, bool <parameter>rea
for all rows that it applies to. If <parameter>count</parameter>
for all rows that it applies to. If <parameter>count</parameter>
is greater than 0, then the number of rows for which the command
is greater than 0, then the number of rows for which the command
will be executed is restricted (much like a
will be executed is restricted (much like a
<literal>LIMIT</literal> clause). For example
,
<literal>LIMIT</literal> clause). For example
:
<programlisting>
<programlisting>
SPI_execute("INSERT INTO foo SELECT * FROM bar", false, 5);
SPI_execute("INSERT INTO foo SELECT * FROM bar", false, 5);
</programlisting>
</programlisting>
...
@@ -2931,7 +2931,7 @@ int SPI_freeplan(void *<parameter>plan</parameter>)
...
@@ -2931,7 +2931,7 @@ int SPI_freeplan(void *<parameter>plan</parameter>)
<para>
<para>
During the execution of an SQL command, any data changes made by
During the execution of an SQL command, any data changes made by
the command are invisible to the command itself. For
the command are invisible to the command itself. For
example, in
example, in
:
<programlisting>
<programlisting>
INSERT INTO a SELECT * FROM a;
INSERT INTO a SELECT * FROM a;
</programlisting>
</programlisting>
...
...
doc/src/sgml/syntax.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.11
2 2007/01/31 20:56:19
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/syntax.sgml,v 1.11
3 2007/02/01 00:28:18
momjian Exp $ -->
<chapter id="sql-syntax">
<chapter id="sql-syntax">
<title>SQL Syntax</title>
<title>SQL Syntax</title>
...
@@ -144,16 +144,16 @@ INSERT INTO MY_TABLE VALUES (3, 'hi there');
...
@@ -144,16 +144,16 @@ INSERT INTO MY_TABLE VALUES (3, 'hi there');
<primary>case sensitivity</primary>
<primary>case sensitivity</primary>
<secondary>of SQL commands</secondary>
<secondary>of SQL commands</secondary>
</indexterm>
</indexterm>
Identifier and key word names are case insensitive. Therefore
Identifier and key word names are case insensitive. Therefore
:
<programlisting>
<programlisting>
UPDATE MY_TABLE SET A = 5;
UPDATE MY_TABLE SET A = 5;
</programlisting>
</programlisting>
can equivalently be written as
can equivalently be written as
:
<programlisting>
<programlisting>
uPDaTE my_TabLE SeT a = 5;
uPDaTE my_TabLE SeT a = 5;
</programlisting>
</programlisting>
A convention often used is to write key words in upper
A convention often used is to write key words in upper
case and names in lower case, e.g.
,
case and names in lower case, e.g.
:
<programlisting>
<programlisting>
UPDATE my_table SET a = 5;
UPDATE my_table SET a = 5;
</programlisting>
</programlisting>
...
@@ -257,11 +257,11 @@ UPDATE "my_table" SET "a" = 5;
...
@@ -257,11 +257,11 @@ UPDATE "my_table" SET "a" = 5;
SELECT 'foo'
SELECT 'foo'
'bar';
'bar';
</programlisting>
</programlisting>
is equivalent to
is equivalent to
:
<programlisting>
<programlisting>
SELECT 'foobar';
SELECT 'foobar';
</programlisting>
</programlisting>
but
but
:
<programlisting>
<programlisting>
SELECT 'foo' 'bar';
SELECT 'foo' 'bar';
</programlisting>
</programlisting>
...
@@ -506,7 +506,7 @@ $function$
...
@@ -506,7 +506,7 @@ $function$
force a numeric value to be interpreted as a specific data type
force a numeric value to be interpreted as a specific data type
by casting it.<indexterm><primary>type cast</primary></indexterm>
by casting it.<indexterm><primary>type cast</primary></indexterm>
For example, you can force a numeric value to be treated as type
For example, you can force a numeric value to be treated as type
<type>real</> (<type>float4</>) by writing
<type>real</> (<type>float4</>) by writing
:
<programlisting>
<programlisting>
REAL '1.23' -- string style
REAL '1.23' -- string style
...
@@ -771,18 +771,18 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
...
@@ -771,18 +771,18 @@ CAST ( '<replaceable>string</replaceable>' AS <replaceable>type</replaceable> )
<literal>></> have a different precedence than the Boolean
<literal>></> have a different precedence than the Boolean
operators <literal><=</> and <literal>>=</>. Also, you will
operators <literal><=</> and <literal>>=</>. Also, you will
sometimes need to add parentheses when using combinations of
sometimes need to add parentheses when using combinations of
binary and unary operators. For instance
binary and unary operators. For instance
:
<programlisting>
<programlisting>
SELECT 5 ! - 6;
SELECT 5 ! - 6;
</programlisting>
</programlisting>
will be parsed as
will be parsed as
:
<programlisting>
<programlisting>
SELECT 5 ! (- 6);
SELECT 5 ! (- 6);
</programlisting>
</programlisting>
because the parser has no idea — until it is too late
because the parser has no idea — until it is too late
— that <token>!</token> is defined as a postfix operator,
— that <token>!</token> is defined as a postfix operator,
not an infix one. To get the desired behavior in this case, you
not an infix one. To get the desired behavior in this case, you
must write
must write
:
<programlisting>
<programlisting>
SELECT (5 !) - 6;
SELECT (5 !) - 6;
</programlisting>
</programlisting>
...
@@ -936,7 +936,7 @@ SELECT (5 !) - 6;
...
@@ -936,7 +936,7 @@ SELECT (5 !) - 6;
<para>
<para>
When a schema-qualified operator name is used in the
When a schema-qualified operator name is used in the
<literal>OPERATOR</> syntax, as for example in
<literal>OPERATOR</> syntax, as for example in
:
<programlisting>
<programlisting>
SELECT 3 OPERATOR(pg_catalog.+) 4;
SELECT 3 OPERATOR(pg_catalog.+) 4;
</programlisting>
</programlisting>
...
@@ -1133,7 +1133,7 @@ $<replaceable>number</replaceable>
...
@@ -1133,7 +1133,7 @@ $<replaceable>number</replaceable>
<para>
<para>
For example, consider the definition of a function,
For example, consider the definition of a function,
<function>dept</function>, as
<function>dept</function>, as
:
<programlisting>
<programlisting>
CREATE FUNCTION dept(text) RETURNS dept
CREATE FUNCTION dept(text) RETURNS dept
...
@@ -1175,7 +1175,7 @@ CREATE FUNCTION dept(text) RETURNS dept
...
@@ -1175,7 +1175,7 @@ CREATE FUNCTION dept(text) RETURNS dept
to be subscripted is just a column reference or positional parameter.
to be subscripted is just a column reference or positional parameter.
Also, multiple subscripts can be concatenated when the original array
Also, multiple subscripts can be concatenated when the original array
is multidimensional.
is multidimensional.
For example
,
For example
:
<programlisting>
<programlisting>
mytable.arraycolumn[4]
mytable.arraycolumn[4]
...
@@ -1208,7 +1208,7 @@ $1[10:42]
...
@@ -1208,7 +1208,7 @@ $1[10:42]
In general the row <replaceable>expression</replaceable> must be
In general the row <replaceable>expression</replaceable> must be
parenthesized, but the parentheses can be omitted when the expression
parenthesized, but the parentheses can be omitted when the expression
to be selected from is just a table reference or positional parameter.
to be selected from is just a table reference or positional parameter.
For example
,
For example
:
<programlisting>
<programlisting>
mytable.mycolumn
mytable.mycolumn
...
@@ -1494,7 +1494,7 @@ SELECT name, (SELECT max(pop) FROM cities WHERE cities.state = states.name)
...
@@ -1494,7 +1494,7 @@ SELECT name, (SELECT max(pop) FROM cities WHERE cities.state = states.name)
consists of the key word <literal>ARRAY</literal>, a left square bracket
consists of the key word <literal>ARRAY</literal>, a left square bracket
<literal>[</>, one or more expressions (separated by commas) for the
<literal>[</>, one or more expressions (separated by commas) for the
array element values, and finally a right square bracket <literal>]</>.
array element values, and finally a right square bracket <literal>]</>.
For example
,
For example
:
<programlisting>
<programlisting>
SELECT ARRAY[1,2,3+4];
SELECT ARRAY[1,2,3+4];
array
array
...
@@ -1597,7 +1597,7 @@ SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%');
...
@@ -1597,7 +1597,7 @@ SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%');
for its member fields. A row constructor consists of the key word
for its member fields. A row constructor consists of the key word
<literal>ROW</literal>, a left parenthesis, zero or more
<literal>ROW</literal>, a left parenthesis, zero or more
expressions (separated by commas) for the row field values, and finally
expressions (separated by commas) for the row field values, and finally
a right parenthesis. For example
,
a right parenthesis. For example
:
<programlisting>
<programlisting>
SELECT ROW(1,2.5,'this is a test');
SELECT ROW(1,2.5,'this is a test');
</programlisting>
</programlisting>
...
@@ -1675,7 +1675,7 @@ SELECT getf1(CAST(ROW(11,'this is a test',2.5) AS myrowtype));
...
@@ -1675,7 +1675,7 @@ SELECT getf1(CAST(ROW(11,'this is a test',2.5) AS myrowtype));
in a composite-type table column, or to be passed to a function that
in a composite-type table column, or to be passed to a function that
accepts a composite parameter. Also,
accepts a composite parameter. Also,
it is possible to compare two row values or test a row with
it is possible to compare two row values or test a row with
<literal>IS NULL</> or <literal>IS NOT NULL</>, for example
<literal>IS NULL</> or <literal>IS NOT NULL</>, for example
:
<programlisting>
<programlisting>
SELECT ROW(1,2.5,'this is a test') = ROW(1, 3, 'not the same');
SELECT ROW(1,2.5,'this is a test') = ROW(1, 3, 'not the same');
...
@@ -1705,12 +1705,12 @@ SELECT ROW(table.*) IS NULL FROM table; -- detect all-null rows
...
@@ -1705,12 +1705,12 @@ SELECT ROW(table.*) IS NULL FROM table; -- detect all-null rows
<para>
<para>
Furthermore, if the result of an expression can be determined by
Furthermore, if the result of an expression can be determined by
evaluating only some parts of it, then other subexpressions
evaluating only some parts of it, then other subexpressions
might not be evaluated at all. For instance, if one wrote
might not be evaluated at all. For instance, if one wrote
:
<programlisting>
<programlisting>
SELECT true OR somefunc();
SELECT true OR somefunc();
</programlisting>
</programlisting>
then <literal>somefunc()</literal> would (probably) not be called
then <literal>somefunc()</literal> would (probably) not be called
at all. The same would be the case if one wrote
at all. The same would be the case if one wrote
:
<programlisting>
<programlisting>
SELECT somefunc() OR true;
SELECT somefunc() OR true;
</programlisting>
</programlisting>
...
...
doc/src/sgml/trigger.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.4
8 2007/01/31 20:56:19
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/trigger.sgml,v 1.4
9 2007/02/01 00:28:18
momjian Exp $ -->
<chapter id="triggers">
<chapter id="triggers">
<title>Triggers</title>
<title>Triggers</title>
...
@@ -282,11 +282,11 @@
...
@@ -282,11 +282,11 @@
any normal arguments, but it is passed a <quote>context</>
any normal arguments, but it is passed a <quote>context</>
pointer pointing to a <structname>TriggerData</> structure. C
pointer pointing to a <structname>TriggerData</> structure. C
functions can check whether they were called from the trigger
functions can check whether they were called from the trigger
manager or not by executing the macro
manager or not by executing the macro
:
<programlisting>
<programlisting>
CALLED_AS_TRIGGER(fcinfo)
CALLED_AS_TRIGGER(fcinfo)
</programlisting>
</programlisting>
which expands to
which expands to
:
<programlisting>
<programlisting>
((fcinfo)->context != NULL && IsA((fcinfo)->context, TriggerData))
((fcinfo)->context != NULL && IsA((fcinfo)->context, TriggerData))
</programlisting>
</programlisting>
...
...
doc/src/sgml/user-manag.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/user-manag.sgml,v 1.3
8 2007/01/31 20:56:19
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/user-manag.sgml,v 1.3
9 2007/02/01 00:28:18
momjian Exp $ -->
<chapter id="user-manag">
<chapter id="user-manag">
<title>Database Roles and Privileges</title>
<title>Database Roles and Privileges</title>
...
@@ -154,7 +154,7 @@ SELECT rolname FROM pg_roles;
...
@@ -154,7 +154,7 @@ SELECT rolname FROM pg_roles;
as the initial role name for a database connection. A role with
as the initial role name for a database connection. A role with
the <literal>LOGIN</> attribute can be considered the same thing
the <literal>LOGIN</> attribute can be considered the same thing
as a <quote>database user</>. To create a role with login privilege,
as a <quote>database user</>. To create a role with login privilege,
use either
use either
:
<programlisting>
<programlisting>
CREATE ROLE <replaceable>name</replaceable> LOGIN;
CREATE ROLE <replaceable>name</replaceable> LOGIN;
CREATE USER <replaceable>name</replaceable>;
CREATE USER <replaceable>name</replaceable>;
...
@@ -248,7 +248,7 @@ CREATE USER <replaceable>name</replaceable>;
...
@@ -248,7 +248,7 @@ CREATE USER <replaceable>name</replaceable>;
configuration settings described in <xref
configuration settings described in <xref
linkend="runtime-config">. For example, if for some reason you
linkend="runtime-config">. For example, if for some reason you
want to disable index scans (hint: not a good idea) anytime you
want to disable index scans (hint: not a good idea) anytime you
connect, you can use
connect, you can use
:
<programlisting>
<programlisting>
ALTER ROLE myname SET enable_indexscan TO off;
ALTER ROLE myname SET enable_indexscan TO off;
</programlisting>
</programlisting>
...
@@ -305,7 +305,7 @@ ALTER ROLE myname SET enable_indexscan TO off;
...
@@ -305,7 +305,7 @@ ALTER ROLE myname SET enable_indexscan TO off;
To assign privileges, the <command>GRANT</command> command is
To assign privileges, the <command>GRANT</command> command is
used. So, if <literal>joe</literal> is an existing role, and
used. So, if <literal>joe</literal> is an existing role, and
<literal>accounts</literal> is an existing table, the privilege to
<literal>accounts</literal> is an existing table, the privilege to
update the table can be granted with
update the table can be granted with
:
<programlisting>
<programlisting>
GRANT UPDATE ON accounts TO joe;
GRANT UPDATE ON accounts TO joe;
</programlisting>
</programlisting>
...
@@ -390,7 +390,7 @@ REVOKE <replaceable>group_role</replaceable> FROM <replaceable>role1</replaceabl
...
@@ -390,7 +390,7 @@ REVOKE <replaceable>group_role</replaceable> FROM <replaceable>role1</replaceabl
considered owned by the group role not the login role. Second, member
considered owned by the group role not the login role. Second, member
roles that have the <literal>INHERIT</> attribute automatically have use of
roles that have the <literal>INHERIT</> attribute automatically have use of
privileges of roles they are members of. As an example, suppose we have
privileges of roles they are members of. As an example, suppose we have
done
done
:
<programlisting>
<programlisting>
CREATE ROLE joe LOGIN INHERIT;
CREATE ROLE joe LOGIN INHERIT;
CREATE ROLE admin NOINHERIT;
CREATE ROLE admin NOINHERIT;
...
@@ -405,19 +405,19 @@ GRANT wheel TO admin;
...
@@ -405,19 +405,19 @@ GRANT wheel TO admin;
granted to <literal>wheel</> are not available, because even though
granted to <literal>wheel</> are not available, because even though
<literal>joe</> is indirectly a member of <literal>wheel</>, the
<literal>joe</> is indirectly a member of <literal>wheel</>, the
membership is via <literal>admin</> which has the <literal>NOINHERIT</>
membership is via <literal>admin</> which has the <literal>NOINHERIT</>
attribute. After
attribute. After
:
<programlisting>
<programlisting>
SET ROLE admin;
SET ROLE admin;
</programlisting>
</programlisting>
the session would have use of only those privileges granted to
the session would have use of only those privileges granted to
<literal>admin</>, and not those granted to <literal>joe</>. After
<literal>admin</>, and not those granted to <literal>joe</>. After
:
<programlisting>
<programlisting>
SET ROLE wheel;
SET ROLE wheel;
</programlisting>
</programlisting>
the session would have use of only those privileges granted to
the session would have use of only those privileges granted to
<literal>wheel</>, and not those granted to either <literal>joe</>
<literal>wheel</>, and not those granted to either <literal>joe</>
or <literal>admin</>. The original privilege state can be restored
or <literal>admin</>. The original privilege state can be restored
with any of
with any of
:
<programlisting>
<programlisting>
SET ROLE joe;
SET ROLE joe;
SET ROLE NONE;
SET ROLE NONE;
...
...
doc/src/sgml/xaggr.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.3
4 2007/01/31 20:56:20
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/xaggr.sgml,v 1.3
5 2007/02/01 00:28:18
momjian Exp $ -->
<sect1 id="xaggr">
<sect1 id="xaggr">
<title>User-Defined Aggregates</title>
<title>User-Defined Aggregates</title>
...
@@ -165,7 +165,7 @@ SELECT attrelid::regclass, array_accum(atttypid)
...
@@ -165,7 +165,7 @@ SELECT attrelid::regclass, array_accum(atttypid)
A function written in C can detect that it is being called as an
A function written in C can detect that it is being called as an
aggregate transition or final function by seeing if it was passed
aggregate transition or final function by seeing if it was passed
an <structname>AggState</> node as the function call <quote>context</>,
an <structname>AggState</> node as the function call <quote>context</>,
for example by
for example by
:
<programlisting>
<programlisting>
if (fcinfo->context && IsA(fcinfo->context, AggState))
if (fcinfo->context && IsA(fcinfo->context, AggState))
</programlisting>
</programlisting>
...
...
doc/src/sgml/xfunc.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.12
3 2007/01/31 20:56:20
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/xfunc.sgml,v 1.12
4 2007/02/01 00:28:18
momjian Exp $ -->
<sect1 id="xfunc">
<sect1 id="xfunc">
<title>User-Defined Functions</title>
<title>User-Defined Functions</title>
...
@@ -244,7 +244,7 @@ SELECT tf1(17, 100.0);
...
@@ -244,7 +244,7 @@ SELECT tf1(17, 100.0);
<para>
<para>
In practice one would probably like a more useful result from the
In practice one would probably like a more useful result from the
function than a constant 1, so a more likely definition
function than a constant 1, so a more likely definition
is
is
:
<programlisting>
<programlisting>
CREATE FUNCTION tf1 (integer, numeric) RETURNS numeric AS $$
CREATE FUNCTION tf1 (integer, numeric) RETURNS numeric AS $$
...
@@ -811,7 +811,7 @@ SELECT * FROM dup(22);
...
@@ -811,7 +811,7 @@ SELECT * FROM dup(22);
<para>
<para>
When creating a family of overloaded functions, one should be
When creating a family of overloaded functions, one should be
careful not to create ambiguities. For instance, given the
careful not to create ambiguities. For instance, given the
functions
functions
:
<programlisting>
<programlisting>
CREATE FUNCTION test(int, real) RETURNS ...
CREATE FUNCTION test(int, real) RETURNS ...
CREATE FUNCTION test(smallint, double precision) RETURNS ...
CREATE FUNCTION test(smallint, double precision) RETURNS ...
...
@@ -845,7 +845,7 @@ CREATE FUNCTION test(smallint, double precision) RETURNS ...
...
@@ -845,7 +845,7 @@ CREATE FUNCTION test(smallint, double precision) RETURNS ...
(usually the internal one). The alternative form of the
(usually the internal one). The alternative form of the
<literal>AS</> clause for the SQL <command>CREATE
<literal>AS</> clause for the SQL <command>CREATE
FUNCTION</command> command decouples the SQL function name from
FUNCTION</command> command decouples the SQL function name from
the function name in the C source code. For instance
,
the function name in the C source code. For instance
:
<programlisting>
<programlisting>
CREATE FUNCTION test(int) RETURNS int
CREATE FUNCTION test(int) RETURNS int
AS '<replaceable>filename</>', 'test_1arg'
AS '<replaceable>filename</>', 'test_1arg'
...
@@ -1740,11 +1740,11 @@ CREATE FUNCTION concat_text(text, text) RETURNS text
...
@@ -1740,11 +1740,11 @@ CREATE FUNCTION concat_text(text, text) RETURNS text
<para>
<para>
The version-1 calling convention relies on macros to suppress most
The version-1 calling convention relies on macros to suppress most
of the complexity of passing arguments and results. The C declaration
of the complexity of passing arguments and results. The C declaration
of a version-1 function is always
of a version-1 function is always
:
<programlisting>
<programlisting>
Datum funcname(PG_FUNCTION_ARGS)
Datum funcname(PG_FUNCTION_ARGS)
</programlisting>
</programlisting>
In addition, the macro call
In addition, the macro call
:
<programlisting>
<programlisting>
PG_FUNCTION_INFO_V1(funcname);
PG_FUNCTION_INFO_V1(funcname);
</programlisting>
</programlisting>
...
@@ -2274,7 +2274,7 @@ include $(PGXS)
...
@@ -2274,7 +2274,7 @@ include $(PGXS)
</para>
</para>
<para>
<para>
Suppose we want to write a function to answer the query
Suppose we want to write a function to answer the query
:
<programlisting>
<programlisting>
SELECT name, c_overpaid(emp, 1500) AS overpaid
SELECT name, c_overpaid(emp, 1500) AS overpaid
...
@@ -2397,7 +2397,7 @@ CREATE FUNCTION c_overpaid(emp, integer) RETURNS boolean
...
@@ -2397,7 +2397,7 @@ CREATE FUNCTION c_overpaid(emp, integer) RETURNS boolean
<para>
<para>
Several helper functions are available for setting up the needed
Several helper functions are available for setting up the needed
<structname>TupleDesc</>. The recommended way to do this in most
<structname>TupleDesc</>. The recommended way to do this in most
functions returning composite values is to call
functions returning composite values is to call
:
<programlisting>
<programlisting>
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo,
TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo,
Oid *resultTypeId,
Oid *resultTypeId,
...
@@ -2443,12 +2443,12 @@ TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo,
...
@@ -2443,12 +2443,12 @@ TypeFuncClass get_call_result_type(FunctionCallInfo fcinfo,
<para>
<para>
Older, now-deprecated functions for obtaining
Older, now-deprecated functions for obtaining
<structname>TupleDesc</>s are
<structname>TupleDesc</>s are
:
<programlisting>
<programlisting>
TupleDesc RelationNameGetTupleDesc(const char *relname)
TupleDesc RelationNameGetTupleDesc(const char *relname)
</programlisting>
</programlisting>
to get a <structname>TupleDesc</> for the row type of a named relation,
to get a <structname>TupleDesc</> for the row type of a named relation,
and
and
:
<programlisting>
<programlisting>
TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases)
TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases)
</programlisting>
</programlisting>
...
@@ -2460,11 +2460,11 @@ TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases)
...
@@ -2460,11 +2460,11 @@ TupleDesc TypeGetTupleDesc(Oid typeoid, List *colaliases)
</para>
</para>
<para>
<para>
Once you have a <structname>TupleDesc</>, call
Once you have a <structname>TupleDesc</>, call
:
<programlisting>
<programlisting>
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
TupleDesc BlessTupleDesc(TupleDesc tupdesc)
</programlisting>
</programlisting>
if you plan to work with Datums, or
if you plan to work with Datums, or
:
<programlisting>
<programlisting>
AttInMetadata *TupleDescGetAttInMetadata(TupleDesc tupdesc)
AttInMetadata *TupleDescGetAttInMetadata(TupleDesc tupdesc)
</programlisting>
</programlisting>
...
@@ -2476,7 +2476,7 @@ AttInMetadata *TupleDescGetAttInMetadata(TupleDesc tupdesc)
...
@@ -2476,7 +2476,7 @@ AttInMetadata *TupleDescGetAttInMetadata(TupleDesc tupdesc)
</para>
</para>
<para>
<para>
When working with Datums, use
When working with Datums, use
:
<programlisting>
<programlisting>
HeapTuple heap_form_tuple(TupleDesc tupdesc, Datum *values, bool *isnull)
HeapTuple heap_form_tuple(TupleDesc tupdesc, Datum *values, bool *isnull)
</programlisting>
</programlisting>
...
@@ -2484,7 +2484,7 @@ HeapTuple heap_form_tuple(TupleDesc tupdesc, Datum *values, bool *isnull)
...
@@ -2484,7 +2484,7 @@ HeapTuple heap_form_tuple(TupleDesc tupdesc, Datum *values, bool *isnull)
</para>
</para>
<para>
<para>
When working with C strings, use
When working with C strings, use
:
<programlisting>
<programlisting>
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
</programlisting>
</programlisting>
...
@@ -2500,7 +2500,7 @@ HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
...
@@ -2500,7 +2500,7 @@ HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values)
<para>
<para>
Once you have built a tuple to return from your function, it
Once you have built a tuple to return from your function, it
must be converted into a <type>Datum</>. Use
must be converted into a <type>Datum</>. Use
:
<programlisting>
<programlisting>
HeapTupleGetDatum(HeapTuple tuple)
HeapTupleGetDatum(HeapTuple tuple)
</programlisting>
</programlisting>
...
@@ -2610,17 +2610,17 @@ typedef struct
...
@@ -2610,17 +2610,17 @@ typedef struct
<para>
<para>
An <acronym>SRF</> uses several functions and macros that
An <acronym>SRF</> uses several functions and macros that
automatically manipulate the <structname>FuncCallContext</>
automatically manipulate the <structname>FuncCallContext</>
structure (and expect to find it via <literal>fn_extra</>). Use
structure (and expect to find it via <literal>fn_extra</>). Use
:
<programlisting>
<programlisting>
SRF_IS_FIRSTCALL()
SRF_IS_FIRSTCALL()
</programlisting>
</programlisting>
to determine if your function is being called for the first or a
to determine if your function is being called for the first or a
subsequent time. On the first call (only) use
subsequent time. On the first call (only) use
:
<programlisting>
<programlisting>
SRF_FIRSTCALL_INIT()
SRF_FIRSTCALL_INIT()
</programlisting>
</programlisting>
to initialize the <structname>FuncCallContext</>. On every function call,
to initialize the <structname>FuncCallContext</>. On every function call,
including the first, use
including the first, use
:
<programlisting>
<programlisting>
SRF_PERCALL_SETUP()
SRF_PERCALL_SETUP()
</programlisting>
</programlisting>
...
@@ -2630,14 +2630,14 @@ SRF_PERCALL_SETUP()
...
@@ -2630,14 +2630,14 @@ SRF_PERCALL_SETUP()
</para>
</para>
<para>
<para>
If your function has data to return, use
If your function has data to return, use
:
<programlisting>
<programlisting>
SRF_RETURN_NEXT(funcctx, result)
SRF_RETURN_NEXT(funcctx, result)
</programlisting>
</programlisting>
to return it to the caller. (<literal>result</> must be of type
to return it to the caller. (<literal>result</> must be of type
<type>Datum</>, either a single value or a tuple prepared as
<type>Datum</>, either a single value or a tuple prepared as
described above.) Finally, when your function is finished
described above.) Finally, when your function is finished
returning data, use
returning data, use
:
<programlisting>
<programlisting>
SRF_RETURN_DONE(funcctx)
SRF_RETURN_DONE(funcctx)
</programlisting>
</programlisting>
...
...
doc/src/sgml/xindex.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/xindex.sgml,v 1.5
7 2007/01/31 20:56:20
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/xindex.sgml,v 1.5
8 2007/02/01 00:28:18
momjian Exp $ -->
<sect1 id="xindex">
<sect1 id="xindex">
<title>Interfacing Extensions To Indexes</title>
<title>Interfacing Extensions To Indexes</title>
...
@@ -490,7 +490,7 @@
...
@@ -490,7 +490,7 @@
is to write the B-tree comparison support function first, and then write the
is to write the B-tree comparison support function first, and then write the
other functions as one-line wrappers around the support function. This
other functions as one-line wrappers around the support function. This
reduces the odds of getting inconsistent results for corner cases.
reduces the odds of getting inconsistent results for corner cases.
Following this approach, we first write
Following this approach, we first write
:
<programlisting>
<programlisting>
#define Mag(c) ((c)->x*(c)->x + (c)->y*(c)->y)
#define Mag(c) ((c)->x*(c)->x + (c)->y*(c)->y)
...
@@ -509,7 +509,7 @@ complex_abs_cmp_internal(Complex *a, Complex *b)
...
@@ -509,7 +509,7 @@ complex_abs_cmp_internal(Complex *a, Complex *b)
}
}
</programlisting>
</programlisting>
Now the less-than function looks like
Now the less-than function looks like
:
<programlisting>
<programlisting>
PG_FUNCTION_INFO_V1(complex_abs_lt);
PG_FUNCTION_INFO_V1(complex_abs_lt);
...
@@ -628,7 +628,7 @@ CREATE OPERATOR CLASS complex_abs_ops
...
@@ -628,7 +628,7 @@ CREATE OPERATOR CLASS complex_abs_ops
</para>
</para>
<para>
<para>
We could have written the operator entries more verbosely, as in
We could have written the operator entries more verbosely, as in
:
<programlisting>
<programlisting>
OPERATOR 1 < (complex, complex) ,
OPERATOR 1 < (complex, complex) ,
</programlisting>
</programlisting>
...
@@ -899,7 +899,7 @@ ALTER OPERATOR FAMILY integer_ops USING btree ADD
...
@@ -899,7 +899,7 @@ ALTER OPERATOR FAMILY integer_ops USING btree ADD
Normally, declaring an operator as a member of an operator class
Normally, declaring an operator as a member of an operator class
(or family) means
(or family) means
that the index method can retrieve exactly the set of rows
that the index method can retrieve exactly the set of rows
that satisfy a <literal>WHERE</> condition using the operator. For example
,
that satisfy a <literal>WHERE</> condition using the operator. For example
:
<programlisting>
<programlisting>
SELECT * FROM table WHERE integer_column < 4;
SELECT * FROM table WHERE integer_column < 4;
</programlisting>
</programlisting>
...
@@ -925,7 +925,7 @@ SELECT * FROM table WHERE integer_column < 4;
...
@@ -925,7 +925,7 @@ SELECT * FROM table WHERE integer_column < 4;
case there's not much value in storing the whole polygon in the index
case there's not much value in storing the whole polygon in the index
entry — we might as well store just a simpler object of type
entry — we might as well store just a simpler object of type
<type>box</>. This situation is expressed by the <literal>STORAGE</>
<type>box</>. This situation is expressed by the <literal>STORAGE</>
option in <command>CREATE OPERATOR CLASS</>: we'd write something like
option in <command>CREATE OPERATOR CLASS</>: we'd write something like
:
<programlisting>
<programlisting>
CREATE OPERATOR CLASS polygon_ops
CREATE OPERATOR CLASS polygon_ops
...
...
doc/src/sgml/xoper.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/xoper.sgml,v 1.
39 2007/01/31 20:56:20
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/xoper.sgml,v 1.
40 2007/02/01 00:28:18
momjian Exp $ -->
<sect1 id="xoper">
<sect1 id="xoper">
<title>User-Defined Operators</title>
<title>User-Defined Operators</title>
...
@@ -222,7 +222,7 @@ SELECT (a + b) AS c FROM test_complex;
...
@@ -222,7 +222,7 @@ SELECT (a + b) AS c FROM test_complex;
name, not an operator name.) <literal>RESTRICT</> clauses only make sense for
name, not an operator name.) <literal>RESTRICT</> clauses only make sense for
binary operators that return <type>boolean</>. The idea behind a restriction
binary operators that return <type>boolean</>. The idea behind a restriction
selectivity estimator is to guess what fraction of the rows in a
selectivity estimator is to guess what fraction of the rows in a
table will satisfy a <literal>WHERE</literal>-clause condition of the form
table will satisfy a <literal>WHERE</literal>-clause condition of the form
:
<programlisting>
<programlisting>
column OP constant
column OP constant
</programlisting>
</programlisting>
...
@@ -294,7 +294,7 @@ column OP constant
...
@@ -294,7 +294,7 @@ column OP constant
name, not an operator name.) <literal>JOIN</> clauses only make sense for
name, not an operator name.) <literal>JOIN</> clauses only make sense for
binary operators that return <type>boolean</type>. The idea behind a join
binary operators that return <type>boolean</type>. The idea behind a join
selectivity estimator is to guess what fraction of the rows in a
selectivity estimator is to guess what fraction of the rows in a
pair of tables will satisfy a <literal>WHERE</>-clause condition of the form
pair of tables will satisfy a <literal>WHERE</>-clause condition of the form
:
<programlisting>
<programlisting>
table1.column1 OP table2.column2
table1.column1 OP table2.column2
</programlisting>
</programlisting>
...
...
doc/src/sgml/xplang.sgml
View file @
09a9f10e
<!-- $PostgreSQL: pgsql/doc/src/sgml/xplang.sgml,v 1.3
3 2007/01/31 20:56:20
momjian Exp $ -->
<!-- $PostgreSQL: pgsql/doc/src/sgml/xplang.sgml,v 1.3
4 2007/02/01 00:28:18
momjian Exp $ -->
<chapter id="xplang">
<chapter id="xplang">
<title id="xplang-title">Procedural Languages</title>
<title id="xplang-title">Procedural Languages</title>
...
@@ -60,7 +60,7 @@
...
@@ -60,7 +60,7 @@
linkend="app-createlang"> can be used to do this from the shell
linkend="app-createlang"> can be used to do this from the shell
command line. For example, to install the language
command line. For example, to install the language
<application>PL/pgSQL</application> into the database
<application>PL/pgSQL</application> into the database
<literal>template1</>, use
<literal>template1</>, use
:
<programlisting>
<programlisting>
createlang plpgsql template1
createlang plpgsql template1
</programlisting>
</programlisting>
...
@@ -183,7 +183,7 @@ CREATE FUNCTION plpgsql_validator(oid) RETURNS void AS
...
@@ -183,7 +183,7 @@ CREATE FUNCTION plpgsql_validator(oid) RETURNS void AS
</para>
</para>
<para>
<para>
The command
The command
:
<programlisting>
<programlisting>
CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql
CREATE TRUSTED PROCEDURAL LANGUAGE plpgsql
HANDLER plpgsql_call_handler
HANDLER plpgsql_call_handler
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment