diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 2c131a4f08..cc25948e59 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -18,9 +18,9 @@ Modifies table properties
ALTER TABLE table
- [*] ADD [COLUMN] columntype
+ [ * ] ADD [ COLUMN ] columntype
ALTER TABLE table
- [*] RENAME [COLUMN] column TO newcolumn
+ [ * ] RENAME [ COLUMN ] column TO newcolumn
ALTER TABLE table
RENAME TO newtable
@@ -103,14 +103,14 @@ Outputs
-status
+status
-ALTER
+ALTER
@@ -121,7 +121,7 @@ Outputs
-NEW
+NEW
@@ -156,9 +156,9 @@ Outputs
Description
- ALTER TABLE changes the definition of an existing table.
+ ALTER TABLE changes the definition of an existing table.
The new columns and their types are specified in the same style
- and with the the same restrictions as in CREATE TABLE.
+ and with the the same restrictions as in CREATE TABLE.
The RENAME clause causes the name of a table or column
to change without changing any of the data contained in
the affected table. Thus, the table or column will
@@ -178,18 +178,15 @@ Notes
The keyword COLUMN is noise and can be omitted.
-
-ALTER TABLE/RENAME is a PostgreSQL language extension.
-
[*] following a name of a table indicates that statement
should be run over that table and all tables below it in the
inheritance hierarchy.
- Refer to PostgreSQL User's Guide for further
+ The PostgreSQL User's Guide has further
information on inheritance.
- Refer to the CREATE TABLE reference for further description
+ Refer to CREATE TABLE for a further description
of valid arguments.
@@ -232,23 +229,30 @@ Compatibility
SQL92
- SQL92 specifies some additional capabilities for ALTER TABLE
- statement which are not yet directly supported by Postgres:
+ALTER TABLE/RENAME
+ is a Postgres language extension.
+
+
+ SQL92 specifies some additional capabilities for ALTER TABLE
+ statement which are not yet directly supported by
+ Postgres:
-ALTER TABLE table ALTER [COLUMN] column
+ALTER TABLE table ALTER [ COLUMN ] column
SET DEFAULT default
-ALTER TABLE table ALTER [COLUMN] column
- ADD [CONSTRAINT constraint] table-constraint
+
+ALTER TABLE table ALTER [ COLUMN ] column
+ ADD [ CONSTRAINT constraint ] table-constraint
Puts the default value or constraint specified into the
- definition of column in the table. See CREATE TABLE for the
+ definition of column in the table.
+ See CREATE TABLE for the
syntax of the default and table-constraint clauses.
If a default clause already exists, it will be replaced by
the new definition. If any constraints on this column already
@@ -307,7 +311,7 @@ DROP TABLE temp;
ALTER TABLE table
- DROP [COLUMN] column { RESTRICT | CASCADE }
+ DROP [ COLUMN ] column { RESTRICT | CASCADE }
@@ -335,23 +339,3 @@ DROP TABLE temp;
-
-
diff --git a/doc/src/sgml/ref/alter_user.sgml b/doc/src/sgml/ref/alter_user.sgml
index fc57cd9849..674fdcff99 100644
--- a/doc/src/sgml/ref/alter_user.sgml
+++ b/doc/src/sgml/ref/alter_user.sgml
@@ -14,26 +14,26 @@
- 1998-04-15
+ 1998-09-08
- ALTER USER username
- [WITH PASSWORD password]
- [CREATEDB | NOCREATEDB]
- [CREATEUSER | NOCREATEUSER]
- [IN GROUP groupname [, ...] ]
- [VALID UNTIL 'abstime']
+ALTER USER username
+ [ WITH PASSWORD password ]
+ [ CREATEDB | NOCREATEDB ]
+ [ CREATEUSER | NOCREATEUSER ]
+ [ IN GROUP groupname [, ...] ]
+ [ VALID UNTIL 'abstime' ]
- 1998-04-15
+ 1998-09-08
Inputs
- Refer to CREATE USER statement for a detailed description of each
+ Refer to CREATE USER for a detailed description of each
clause.
@@ -47,6 +47,7 @@
+
password
@@ -57,6 +58,7 @@
+
groupname
@@ -67,13 +69,15 @@
+
abstime
- The date (and, optionally, the time) at which this user's access is to be terminated.
+ The date (and, optionally, the time)
+ at which this user's access is to be terminated.
@@ -82,7 +86,7 @@
- 1998-04-15
+ 1998-09-08
Outputs
@@ -92,14 +96,14 @@
- status
+ status
- ALTER USER
+ ALTER USER
@@ -110,7 +114,7 @@
- ERROR: alterUser: user "username" does not exist
+ ERROR: alterUser: user "username" does not exist
@@ -129,16 +133,18 @@
- 1998-04-15
+ 1998-09-08
Description
- ALTER USER is used to change the attributes of a user's
- PostgreSQL account. Please note that it is not possible
+ ALTER USER is used to change the attributes of a user's
+ Postgres account.
+ Please note that it is not possible
to alter a user's "usesysid" via the alter user
- statement. Also, it is only possible for the PostgreSQL
+ statement. Also, it is only possible for the
+ Postgres
user or any user with read and modify permissions on
"pg_shadow" to alter user passwords.
@@ -150,21 +156,24 @@
- 1998-04-15
+ 1998-09-08
Notes
- ALTER USER statement is a PostgreSQL language extension.
+ ALTER USER statement
+ is a Postgres
+ language extension.
- Refer to CREATE/DROP USER statements to create/remove an user
+ Refer to CREATE/DROP USER
+ to create or remove a user
account.
- At the current release (6.3.2), the IN GROUP clause is parsed
- but has no effect. When it is fully implemented, it is
+ In the current release (v6.4), the IN GROUP clause is parsed
+ but has no affect. When it is fully implemented, it is
intended to modify the pg_group relation.
@@ -178,13 +187,13 @@
Change a user password
- ALTER USER davide WITH PASSWORD hu8jmn3;
+ALTER USER davide WITH PASSWORD hu8jmn3;
Change a user's valid until date
- ALTER USER manuel VALID UNTIL 'Jan 31 2030';
+ALTER USER manuel VALID UNTIL 'Jan 31 2030';
Change a user's valid until date, specifying that his
@@ -192,19 +201,19 @@ authorisation should expire at midday on 4th May 1998 using
the time zone which is one hour ahead of UTC
- ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
+ALTER USER chris VALID UNTIL 'May 4 12:00:00 1998 +1';
Give a user the ability to create other users and new databases.
- ALTER USER miriam CREATEUSER CREATEDB;
+ALTER USER miriam CREATEUSER CREATEDB;
Place a user in two groups
- ALTER USER miriam IN GROUP sales, payroll;
+ALTER USER miriam IN GROUP sales, payroll;
@@ -217,13 +226,15 @@ the time zone which is one hour ahead of UTC
- 1998-04-15
+ 1998-09-08
SQL92
- There is no ALTER USER statement in SQL92. The standard leaves
+ There is no ALTER USER statement in
+ SQL92.
+ The standard leaves
the definition of users to the implementation.
diff --git a/doc/src/sgml/ref/begin.sgml b/doc/src/sgml/ref/begin.sgml
index e0fe23305d..279ed6db3a 100644
--- a/doc/src/sgml/ref/begin.sgml
+++ b/doc/src/sgml/ref/begin.sgml
@@ -16,38 +16,26 @@
- 1998-04-15
+ 1998-09-08
- BEGIN { WORK | TRANSACTION }
+BEGIN [ WORK | TRANSACTION ]
- 1998-04-15
+ 1998-09-08
Inputs
-
-
-
-
-
None
-
-
-
-
-
-
-
- 1998-04-15
+ 1998-09-08
Outputs
@@ -57,14 +45,14 @@
- status
+ status
- BEGIN
+ BEGIN
@@ -74,18 +62,12 @@
-
- NOTICE: BeginTransactionBlock and not in default state
-
+ NOTICE: BeginTransactionBlock and not in default state
This indicates that a transaction was already in progress.
-
- What happens to command queries already run
- in the transaction? Does this have no effect, or does
- it restart the transaction?
-
+The current transaction is not affected.
@@ -99,17 +81,20 @@
- 1998-04-15
+ 1998-09-08
Description
- BEGIN begins a user transaction which PostgreSQL will
- guarantee is serialisable with respect to all concurrently
- executing transactions. PostgreSQL uses two-phase locking
+ BEGIN initiates a user transaction
+ which Postgres will
+ guarantee is serializable with respect to all concurrently
+ executing transactions. Postgres uses two-phase
+ locking
to perform this task. If the transaction is committed,
- PostgreSQL will ensure either that all updates are done orelse
+ Postgres will ensure either that all updates are
+ done or else
that none of
them are done. Transactions have the standard ACID
(atomic, consistent, isolatable, and durable) property.
@@ -117,7 +102,7 @@
- 1998-04-15
+ 1998-09-08
Notes
@@ -126,18 +111,15 @@
The keyword TRANSACTION is just a cosmetic alternative to WORK.
Neither keyword need be specified.
-
+
- BEGIN statement is a PostgreSQL language extension.
+ Refer to the LOCK statement for further information
+ about locking tables inside a transaction.
- Refer to the LOCK statement for further information about locking
- tables inside a transaction.
-
-
-
- Use COMMIT or ROLLBACK to terminate a transaction.
+ Use COMMIT or ROLLBACK
+ to terminate a transaction.
@@ -146,9 +128,9 @@
Usage
To begin a user transaction:
-
+
- BEGIN WORK;
+BEGIN WORK;
@@ -157,17 +139,19 @@
Compatibility
-
+ BEGIN
+ is a Postgres language extension.
- 1998-04-15
+ 1998-09-08
SQL92
- There is no explicit "BEGIN WORK" in SQL92; transaction initiation
+ There is no explicit BEGIN WORK command in SQL92;
+ transaction initiation
is always implicit and it terminates either with a COMMIT or with
a ROLLBACK statement.
diff --git a/doc/src/sgml/ref/close.sgml b/doc/src/sgml/ref/close.sgml
index b1a755957d..4c8c3f2032 100644
--- a/doc/src/sgml/ref/close.sgml
+++ b/doc/src/sgml/ref/close.sgml
@@ -15,7 +15,7 @@
- 1998-04-15
+ 1998-09-08
CLOSE cursor
@@ -23,25 +23,16 @@ CLOSE cursor
- 1998-04-15
+ 1998-09-08
Inputs
-
-
-
-
-
-
-
- cursor
-
@@ -50,14 +41,11 @@ CLOSE cursor
-
-
-
- 1998-04-15
+ 1998-09-08
Outputs
@@ -67,15 +55,16 @@ CLOSE cursor
+
+ status
+
-
- CLOSE
-
+CLOSE
@@ -85,9 +74,7 @@ CLOSE cursor
-
- NOTICE PerformPortalClose: portal "cursor" not found
-
+NOTICE PerformPortalClose: portal "cursor" not found
@@ -107,33 +94,35 @@ CLOSE cursor
- 1998-04-15
+ 1998-09-08
Description
- CLOSE frees the resources associated with an open cursor.
+ CLOSE frees the resources associated with an open cursor.
After the cursor is closed, no subsequent operations
are allowed on it. A cursor should be closed when it is
no longer needed.
An implicit close is executed for every open cursor when a
- transaction is terminated by COMMIT or ROLLBACK.
+ transaction is terminated by COMMIT
+ or ROLLBACK.
- 1998-04-15
+ 1998-09-08
Notes
- PostgreSQL does not have an explicit OPEN cursor statement;
- a cursor is considered open when it is DECLAREd.
- Use DECLARE to declare a cursor.
+Postgres does not have
+ an explicit OPEN cursor statement;
+ a cursor is considered open when it is declared.
+ Use the DECLARE statement to declare a cursor.
@@ -146,7 +135,7 @@ CLOSE cursor
Close the cursor liahona:
- CLOSE liahona;
+CLOSE liahona;
@@ -159,13 +148,13 @@ CLOSE cursor
- 1998-04-15
+ 1998-09-08
SQL92
- CLOSE is fully compatibile with SQL92.
+ CLOSE is fully compatible with SQL92.
diff --git a/doc/src/sgml/ref/cluster.sgml b/doc/src/sgml/ref/cluster.sgml
index 3a6e469ba5..b195cb4dc3 100644
--- a/doc/src/sgml/ref/cluster.sgml
+++ b/doc/src/sgml/ref/cluster.sgml
@@ -15,15 +15,15 @@
- 1998-04-15
+ 1998-09-08
- CLUSTER indexname ON table
+CLUSTER indexname ON table
- 1998-04-15
+ 1998-09-08
Inputs
@@ -33,9 +33,7 @@
- indexname
-
@@ -45,9 +43,7 @@
- table
-
@@ -60,7 +56,7 @@
- 1998-04-15
+ 1998-09-08
Outputs
@@ -70,13 +66,14 @@
+status
- CLUSTER
+ CLUSTER
@@ -86,11 +83,11 @@
- ERROR: relation <tablerelation_number> inherits "invoice"
+ERROR: relation <tablerelation_number> inherits "invoice"
- ???
+
This is not documented anywhere. It seems not to be possible to
cluster a table that is inherited.
@@ -100,11 +97,11 @@
- ERROR: Relation x does not exist!
+ ERROR: Relation x does not exist!
- ???
+
The relation complained of was not shown in the error message,
which contained a random string instead of the relation name.
@@ -122,27 +119,37 @@
- 1998-04-15
+ 1998-09-08
Description
- This command instructs PostgreSQL to cluster the class specified
+ CLUSTER instructs Postgres
+to cluster the class specified
by classname approximately
based on the index specified by
indexname. The index must
- already have been defined on classname.
+ already have been defined on
+classname.
When a class is clustered, it is physically reordered
based on the index information. The clustering is static.
In other words, as the class is updated, the changes are
not clustered. No attempt is made to keep new instances or
- updated tuples clustered. If he wishes, the user can
+ updated tuples clustered. If one wishes, one can
recluster manually by issuing the command again.
+
+
+ 1998-09-08
+
+
+ Notes
+
+
The table is actually copied to a temporary table in index
order, then renamed back to the original name. For this
@@ -155,16 +162,15 @@
within a table, the actual order of the data in the heap
table is unimportant. However, if you tend to access some
data more than others, and there is an index that groups
- them together, you will benefit from using the CLUSTER
- command.
+ them together, you will benefit from using CLUSTER.
- Another place CLUSTER is good is in cases where you use an
+ Another place CLUSTER is helpful is in cases where you use an
index to pull out several rows from a table. If you are
requesting a range of indexed values from a table, or a
single indexed value that has multiple rows that match,
- CLUSTER will help because once the index identifies the
+ CLUSTER will help because once the index identifies the
heap page for the first row that matches, all other rows
that match are probably already on the same heap page,
saving disk accesses and speeding up the query.
@@ -172,25 +178,27 @@
There are two ways to cluster data. The first is with the
- CLUSTER command, which reorders the original table with
+ CLUSTER command, which reorders the original table with
the ordering of the index you specify. This can be slow
on large tables because the rows are fetched from the heap
in index order, and if the heap table is unordered, the
entries are on random pages, so there is one disk page
- retrieved for every row moved. PostgreSQL has a cache,
+ retrieved for every row moved. Postgres has a cache,
but the majority of a big table will not fit in the cache.
- Another way is to use
- SELECT ... INTO TABLE temp FROM ... ORDER BY ...
- This uses the PostgreSQL sorting code in
+ Another way to cluster data is to use
+
+SELECT ... INTO TABLE temp FROM ... ORDER BY ...
+
+ This uses the Postgres sorting code in
ORDER BY to match the index, and is much faster for
unordered data. You then drop the old table, use
-ALTER TABLE RENAME
- to rename 'temp' to the old name, and
- recreate the b bindexes. The only problem is that oids
- will not be preserved. From then on, CLUSTER should be
+ALTER TABLE/RENAME
+ to rename temp to the old name, and
+ recreate any indexes. The only problem is that OIDs
+ will not be preserved. From then on, CLUSTER should be
fast because most of the heap data has already been
ordered, and the existing index is used.
@@ -204,7 +212,7 @@
Cluster the employees relation on the basis of its salary attribute
- CLUSTER emp_ind ON emp
+CLUSTER emp_ind ON emp
@@ -217,13 +225,13 @@
- 1998-04-15
+ 1998-09-08
SQL92
- There is no CLUSTER statement in SQL92.
+ There is no CLUSTER statement in SQL92.
diff --git a/doc/src/sgml/ref/commit.sgml b/doc/src/sgml/ref/commit.sgml
index a631b7f9b8..0ffc07effe 100644
--- a/doc/src/sgml/ref/commit.sgml
+++ b/doc/src/sgml/ref/commit.sgml
@@ -16,63 +16,43 @@
- 1998-04-15
+ 1998-09-08
- COMMIT [ WORK ]
+COMMIT [ WORK | TRANSACTION ]
- 1998-04-15
+ 1998-09-08
Inputs
-
-
-
-
-
-
-
-
-
-
- None
-
-
-
-
-
-
-
-
-
-
+None
- 1998-04-15
+ 1998-09-08
Outputs
-
+status
- END
+ END
@@ -82,8 +62,7 @@ Message returned if the transaction is successfully committed.
- NOTICE EndTransactionBlock and not inprogress/abort state
-
+ NOTICE EndTransactionBlock and not inprogress/abort state
@@ -100,29 +79,29 @@ If there is no transaction in progress.
- 1998-04-15
+ 1998-09-08
Description
- COMMIT commits the current transaction. All
+ COMMIT commits the current transaction. All
changes made by the transaction become visible to others
and are guaranteed to be durable if a crash occurs.
- 1998-04-15
+ 1998-09-08
Notes
- The keyword WORK is noise and can be omitted.
+ The keywords WORK and TRANSACTION are noise and can be omitted.
- Refer to ROLLBACK statements to abort a transaction.
+ Use the ROLLBACK statement to abort a transaction.
@@ -135,7 +114,7 @@ If there is no transaction in progress.
To make all changes permanent:
- COMMIT WORK;
+COMMIT WORK;
@@ -148,7 +127,7 @@ To make all changes permanent:
- 1998-04-15
+ 1998-09-08
SQL92
diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml
index 216d2abf1e..174fd26078 100644
--- a/doc/src/sgml/ref/copy.sgml
+++ b/doc/src/sgml/ref/copy.sgml
@@ -14,69 +14,112 @@
- 1998-04-15
+ 1998-09-08
- COPY [BINARY] table [WITH OIDS]
- TO|FROM 'filename'|stdin|stdout
- [USING DELIMITERS 'delimiter']
+COPY [ BINARY ] table [ WITH OIDS ]
+ FROM { 'filename' | stdin }
+ [ USING DELIMITERS 'delimiter' ]
+COPY [ BINARY ] table [ WITH OIDS ]
+ TO { 'filename' | stdout }
+ [ USING DELIMITERS 'delimiter' ]
- 1998-04-15
+ 1998-09-08
Inputs
-
-
-
-
-
-
-
- table
+BINARY
- The name of a table.
+ Changes the behavior of field formatting, forcing all data to be
+ stored or read as binary objects rather than as text.
- delimiter
+table
- A character that delimits fields.
+The name of an existing table.
+
+
+
+
+
+WITH OIDS
+
+
+
+Copies the internal unique object id (OID) for each row.
+
+
+
+
+
+filename
+
+
+
+The absolute Unix pathname of the input or output file.
+
+
+
+
+
+stdin
+
+
+
+Specifies that input comes from a pipe or terminal.
+
+
+
+
+
+stdout
+
+
+
+Specifies that output goes to a pipe or terminal.
+
+
+
+
+
+ delimiter
+
+
+
+ A character that delimits the input or output fields.
-
-
-
- 1998-04-15
+ 1998-09-08
Outputs
-
- Status
+ status
@@ -110,84 +153,82 @@
- 1998-04-15
+ 1998-09-08
Description
- COPY moves data between PostgreSQL tables and
- standard Unix files. The keyword BINARY
- changes the behavior of field formatting, as described
- below. Table is the
- name of an existing table. The keyword WITH
- OIDS copies the internal unique object id (OID) for each
- row. Filename is the
- absolute Unix pathname of the file. In place of a filename, the
- keywords stdin and stdout
- can be used, so that input to COPY can be written
- by a libpq application and output from COPY can
- be read by a libpq application.
-
-
- The BINARY keyword will force all data to be
- stored/read as binary objects rather than as ASCII text. It is
- somewhat faster than the normal copy command, but is not
- generally portable, and the files generated are somewhat larger,
- although this factor is highly dependent on the data itself. By
- default, an ASCII copy uses a tab (\t) character as a delimiter.
- The delimiter may also be changed to any other single character
- with the keyword USING DELIMITERS. Characters
- in data fields which happen to match the delimiter character will
- be quoted.
-
+ COPY moves data between
+ Postgres tables and
+ standard Unix files.
+
+
+COPY instructs
+ the Postgres backend
+to directly read from or write to a file. The file must be directly visible to
+the backend and the name must be specified from the viewpoint of the backend.
+If stdin or stdout are specified, data flows through the client frontend to
+the backend.
- 1998-04-15
+ 1998-09-08
Notes
+
+ The BINARY keyword will force all data to be
+ stored/read as binary objects rather than as text. It is
+ somewhat faster than the normal copy command, but is not
+ generally portable, and the files generated are somewhat larger,
+ although this factor is highly dependent on the data itself. By
+ default, a text copy uses a tab ("\t") character as a delimiter.
+ The delimiter may also be changed to any other single character
+ with the keyword phrase USING DELIMITERS. Characters
+ in data fields which happen to match the delimiter character will
+ be quoted.
+
+
You must have select access on any table whose values are read by
COPY, and either insert or update access to a
table into which values are being inserted by COPY.
The backend also needs appropriate Unix permissions for any file read
or written by COPY.
-
-Is this right? The man page talked of read, write and append access, which
-is neither SQL nor Unix terminology.
-
- The keyword USING DELIMITERS is inaptly
- named, since only a single character may be specified. (If a
- group of characters is specified, only the first character is
- used.)
-
-
- WARNING: do not confuse COPY with the
- psql instruction \copy.
-
+ The keyword phrase USING DELIMITERS specifies a single character
+to be used for all delimiters between columns. If multiple characters
+are specified in the delimiter string, only the first character is
+ used.
+
+
+
+ Do not confuse COPY with the
+ psql instruction \copy.
+
+
+
1998-05-04
- Format of output files
+ File Formats1998-05-04
- ASCII copy format
+ Text Format
- When COPY is used without BINARY,
- the file generated will have each instance on a single line, with each
- attribute separated by the delimiter character. Embedded
+ When COPY TO is used without the BINARY option,
+ the file generated will have each row (instance) on a single line, with each
+ column (attribute) separated by the delimiter character. Embedded
delimiter characters will be preceded by a backslash character
- (\). The attribute values themselves are strings generated by the
+ ("\"). The attribute values themselves are strings generated by the
output function associated with each attribute type. The output
function for a type should not try to generate the backslash
character; this will be handled by COPY itself.
@@ -195,29 +236,31 @@ is neither SQL nor Unix terminology.
The actual format for each instance is
- <attr1><separator><attr2><separator>...<separator><attrn><newline>
+<attr1><separator><attr2><separator>...<separator><attrn><newline>
+
The oid is placed on the beginning of the line
- if WITH OIDS is specified.
+ if WITH OIDS is specified.
If COPY is sending its output to standard
- output instead of a file, it will send a backslash(\) and a period
- (.) followed immediately by a newline, on a separate line,
+ output instead of a file, it will send a backslash("\") and a period
+ (".") followed immediately by a newline, on a separate line,
when it is done. Similarly, if COPY is reading
- from standard input, it will expect a backslash (\) and a period
- (.) followed by a newline, as the first three characters on a
- line, to denote end-of-file. However, COPY
+ from standard input, it will expect a backslash ("\") and a period
+ (".") followed by a newline, as the first three characters on a
+ line to denote end-of-file. However, COPY
will terminate (followed by the backend itself) if a true EOF is
- encountered.
+ encountered before this special end-of-file pattern is found.
- The backslash character has special meaning. NULL attributes are
- output as \N. A literal backslash character is output as two
- consecutive backslashes. A literal tab character is represented
+ The backslash character has other special meanings. NULL attributes are
+ output as "\N". A literal backslash character is output as two
+ consecutive backslashes ("\\"). A literal tab character is represented
as a backslash and a tab. A literal newline character is
- represented as a backslash and a newline. When loading ASCII data
- not generated by PostgreSQL, you will need to convert backslash
- characters (\) to double-backslashes (\\) to ensure that they are loaded
+ represented as a backslash and a newline. When loading text data
+ not generated by Postgres,
+ you will need to convert backslash
+ characters ("\") to double-backslashes ("\\") to ensure that they are loaded
properly.
@@ -225,7 +268,7 @@ is neither SQL nor Unix terminology.
1998-05-04
- Binary copy format
+ Binary Format
In the case of COPY BINARY, the first four
bytes in the file will be the number of instances in the file. If
@@ -270,16 +313,8 @@ is neither SQL nor Unix terminology.
number of null attributes
- [uint32
- attribute number of first null attribute, counting from 0
-
-
- ...
- ...
-
-
- uint32
- attribute number of last null attribute]
+ [uint32,...,uint32]
+ attribute numbers of attributes, counting from 0-
@@ -294,12 +329,12 @@ is neither SQL nor Unix terminology.
1998-05-04
- Alignment of binary data
+ Alignment of Binary Data
On Sun-3s, 2-byte attributes are aligned on two-byte boundaries,
and all larger attributes are aligned on four-byte boundaries.
Character attributes are aligned on single-byte boundaries. On
- other machines, all attributes larger than 1 byte are aligned on
+ most other machines, all attributes larger than 1 byte are aligned on
four-byte boundaries. Note that variable length attributes are
preceded by the attribute's length; arrays are simply contiguous
streams of the array element type.
@@ -313,19 +348,22 @@ is neither SQL nor Unix terminology.
Usage
-To copy a table to standard output, using | as a delimiter
+The following example copies a table to standard output,
+ using a vertical bar ("|") as the field
+ delimiter:
- COPY country TO stdout USING DELIMITERS '|';
+COPY country TO stdout USING DELIMITERS '|';
- To copy data from a Unix file into a table:
+ To copy data from a Unix file into a table "country":
- COPY country FROM '/usr1/proj/bray/sql/country_data';
+COPY country FROM '/usr1/proj/bray/sql/country_data';
- A sample of data suitable for copying into a table from stdin (so it
+ Here is a sample of data suitable for copying into a table
+ from stdin (so it
has the termination sequence on the last line):
@@ -338,10 +376,13 @@ has the termination sequence on the last line):
\.
- The same data, output in binary format on a Linux Intel machine.
- The data is shown after filtering through the Unix utility od -c. The table has
- three fields; the first is char(2) and the second is text. All the
- rows have a null value in the third field). Notice how the char(2)
+ The same data, output in binary format on a Linux/i586 machine.
+ The data is shown after filtering through
+ the Unix utility od -c. The table has
+ three fields; the first is char(2)
+ and the second is text. All the
+ rows have a null value in the third field.
+ Notice how the char(2)
field is padded with nulls to four bytes and the text field is
preceded by its length:
@@ -359,32 +400,32 @@ has the termination sequence on the last line):
-
- See also
-
- insert(l), create table(l), vacuum(l), libpq.
-
-
-
BugsCOPY stops operation at the first error. This
- should not lead to problems in the event of a copy from, but the
- target relation will, of course, be partially modified in a copy
- to. The VACUUM query should be used to clean up
+ should not lead to problems in the event of
+ a COPY FROM, but the
+ target relation will, of course, be partially modified in a
+COPY TO.
+ The VACUUM query should be used to clean up
after a failed copy.
- Because Postgres' current directory is not the same as the user's
- working directory, the result of copying to a file "foo" (without
+ Because the Postgres backend's current working directory
+ is not usually the same as the user's
+ working directory, the result of copying to a file
+ "foo" (without
additional path information) may yield unexpected results for the
- naive user. In this case, "foo" will wind up in $PGDATA/foo. In
- general, the full pathname should be used when specifying files to
+ naive user. In this case, foo
+ will wind up in $PGDATA/foo. In
+ general, the full pathname as it would appear to the backend server machine
+should be used when specifying files to
be copied.
- Files used as arguments to the copy command must reside on or be
+ Files used as arguments to COPY
+must reside on or be
accessible to the database server machine by being either on
local disks or on a networked file system.
@@ -405,13 +446,13 @@ has the termination sequence on the last line):
- 1998-04-15
+ 1998-09-08
SQL92
- There is no COPY statement in SQL92.
+ There is no COPY statement in SQL92.
diff --git a/doc/src/sgml/ref/create_aggregate.sgml b/doc/src/sgml/ref/create_aggregate.sgml
index 9dc3ba950f..a5b04daa26 100644
--- a/doc/src/sgml/ref/create_aggregate.sgml
+++ b/doc/src/sgml/ref/create_aggregate.sgml
@@ -6,10 +6,6 @@
SQL - Language Statements
-This entry needs a lot of work, especially some
-usefully complex examples. Since I don't yet understand it, I
-haven't done this.
-
CREATE AGGREGATE
@@ -19,32 +15,28 @@ haven't done this.
- 1998-04-15
+ 1998-09-09
- CREATE AGGREGATE name [AS]
- ([ SFUNC1 = state_transition_function1
- , BASETYPE = data_type
- , STYPE1 = sfunc1_return_type ]
- [, SFUNC2 = state_transition_function2
- , STYPE2 = sfunc2_return_type ]
- [, FINALFUNC = final_function ]
- [, INITCOND1 = initial_condition1 ]
- [, INITCOND2 = initial_condition2 ]
- )
+CREATE AGGREGATE name [ AS ]
+ ( BASETYPE = data_type
+ [ , SFUNC1 = sfunc1
+ , STYPE1 = sfunc1_return_type ]
+ [ , SFUNC2 = sfunc2
+ , STYPE2 = sfunc2_return_type ]
+ [ , FINALFUNC = ffunc ]
+ [ , INITCOND1 = initial_condition1 ]
+ [ , INITCOND2 = initial_condition2 ]
+ )
- 1998-04-15
+ 1998-09-09
Inputs
-
-
-
-
@@ -57,88 +49,115 @@ haven't done this.
-
-
- state_transition_function1
-
-
-
-
-
-
+
data_type
+The fundamental data type on which this aggregate function operates.
+
+
+
+ sfunc1
+
+
+
+The state transition function
+ to be called for every non-NULL field from the source column.
+ It takes a variable of
+type sfunc1_return_type as
+the first argument and that field as the
+second argument.
+
+
+
+
sfunc1_return_type
+The return type of the first transition function.
+
- state-transition_function2
+ sfunc2
+The state transition function
+ to be called for every non-NULL field from the source column.
+It takes a variable
+of type sfunc2_return_type
+as the only argument and returns a variable of the same type.
+
sfunc2_return_type
+The return type of the second transition function.
+
- final_function
+ ffunc
+The final function
+ called after traversing all input fields. This function must
+take two arguments of types
+ sfunc1_return_type
+and
+sfunc2_return_type.
+
initial_condition1
+The initial value for the first transition function argument.
+
initial_condition2
+The initial value for the second transition function argument.
-
-
-
-
+
- 1998-04-15
+ 1998-09-09
Outputs
@@ -148,6 +167,7 @@ haven't done this.
+status
@@ -172,82 +192,130 @@ haven't done this.
- 1998-04-15
+ 1998-09-09
Description
+
+ CREATE AGGREGATE
+allows a user or programmer to extend Postgres
+functionality by defining new aggregate functions. Some aggregate functions
+for base types such as min(int4)
+ and avg(float8) are already provided in the base
+distribution. If one defines new types or needs an aggregate function not
+already provided then CREATE AGGREGATE
+can be used to provide the desired features.
+
- An aggregate function can use up to three functions, two
- state transition functions, X1 and X2:
- X1( internal-state1, next-data_item ) ---> next-internal-state1
- X2( internal-state2 ) ---> next-internal-state2
- and a final calculation function, F:
- F(internal-state1, internal-state2) ---> aggregate-value
- These functions are required to have the following properties:
+ An aggregate function can require up to three functions, two
+ state transition functions,
+sfunc1
+ and sfunc2:
+
+sfunc1( internal-state1, next-data_item ) ---> next-internal-state1
+sfunc2( internal-state2 ) ---> next-internal-state2
+
+ and a final calculation function,
+ ffunc:
+
+ffunc(internal-state1, internal-state2) ---> aggregate-value
+
+
+
+Postgres creates up to two temporary variables
+(referred to here as temp1
+and temp2)
+to hold intermediate results used as arguments to the transition functions.
+
+
+ These transition functions are required to have the following properties:
- The arguments to state-transition-function-1 must
- be (stype1,basetype), and its return value must be
- stype1.
+ The arguments to
+sfunc1
+ must be
+temp1
+of type
+sfunc1_return_type
+and
+column_value
+of type data_type.
+The return value must be of type
+sfunc1_return_type
+and will be used as the first argument in the next call to
+sfunc1.
+
- The argument and return value of state-transition-
- function-2 must be stype2.
+ The argument and return value of
+sfunc2
+must be
+temp2
+of type
+sfunc2_return_type.
The arguments to the final-calculation-function
- must be (stype1,stype2), and its return value must
- be a POSTGRES base type (not necessarily the same
- as basetype.
+ must be
+temp1
+and
+temp2
+and its return value must
+ be a Postgres
+ base type (not necessarily
+ data_type
+which had been specified for BASETYPE).
- The final-calculation-function should be specified
+ FINALFUNC should be specified
if and only if both state-transition functions are
specified.
-
- Note that it is possible to specify aggregate functions
- that have varying combinations of state and final functions.
- For example, the "count" aggregate requires sfunc2
- (an incrementing function) but not sfunc1 or finalfunc,
- whereas the "sum" aggregate requires sfunc1 (an addition
- function) but not sfunc2 or finalfunc and the "average"
- aggregate requires both of the above state functions as
- well as a finalfunc (a division function) to produce its
- answer. In any case, at least one state function must be
- defined, and any sfunc2 must have a corresponding initcond2.
-
+
- Aggregates also require two initial conditions, one for
+ An aggregate function may also require one or two initial conditions,
+ one for
each transition function. These are specified and stored
- in the database as fields of type text.
+ in the database as fields of type text.
- 1998-04-15
+ 1998-09-09
Notes
-
- CREATE AGGREGATE function is a PostgreSQL language extension.
-
-
- Refer to DROP AGGREGATE function to drop aggregate functions.
+ Use DROP AGGREGATE
+ to drop aggregate functions.
+
+
+ It is possible to specify aggregate functions
+ that have varying combinations of state and final functions.
+ For example, the count aggregate requires SFUNC2
+ (an incrementing function) but not SFUNC1 or FINALFUNC,
+ whereas the sum aggregate requires SFUNC1 (an addition
+ function) but not SFUNC2 or FINALFUNC and the avg
+ aggregate requires
+ both of the above state functions as
+ well as a FINALFUNC (a division function) to produce its
+ answer. In any case, at least one state function must be
+ defined, and any SFUNC2 must have a corresponding INITCOND2.
+
+
@@ -255,10 +323,10 @@ haven't done this.
Usage
-
-
-
-
+Refer to the chapter on aggregate functions
+ in the PostgreSQL Programmer's Guide
+ on aggregate functions for
+complete examples of usage.
@@ -267,17 +335,18 @@ haven't done this.
Compatibility
-
-
+
-1998-04-15
+1998-09-09
SQL92
- There is no CREATE AGGREGATE function on SQL92.
+ CREATE AGGREGATE
+is a Postgres language extension.
+ There is no CREATE AGGREGATE in SQL92.
diff --git a/doc/src/sgml/ref/create_database.sgml b/doc/src/sgml/ref/create_database.sgml
index bd302599e6..c6fff50184 100644
--- a/doc/src/sgml/ref/create_database.sgml
+++ b/doc/src/sgml/ref/create_database.sgml
@@ -17,7 +17,7 @@
1998-04-15
- CREATE DATABASE name [WITH LOCATION = 'dbpath']
+CREATE DATABASE name [ WITH LOCATION = 'dbpath' ]
@@ -28,13 +28,6 @@
Inputs
-
-
-
-
-
-
-
@@ -62,9 +55,6 @@
-
-
-
@@ -79,6 +69,7 @@
+ status
@@ -142,10 +133,11 @@ There was a problem with creating the required directory; this operation will
Notes
- CREATE DATABASE statement is a Postgres language extension.
+ CREATE DATABASE is a Postgres
+ language extension.
- Refer to DROP DATABASE statement to remove a database.
+ Use DROP DATABASE to remove a database.
@@ -157,26 +149,26 @@ There was a problem with creating the required directory; this operation will
To create a new database:
- olly=>create database lusiadas;
+olly=>create database lusiadas;
To create a new database in an alternate area ~/private_db:
- $mkdir private_db
- $initlocation ~/private_db
- Creating Postgres database system directory /home/olly/private_db/base
+$mkdir private_db
+$initlocation ~/private_db
+Creating Postgres database system directory /home/olly/private_db/base
- $psql olly
- Welcome to the POSTGRESQL interactive sql monitor:
- Please read the file COPYRIGHT for copyright terms of POSTGRESQL
+$psql olly
+Welcome to the POSTGRESQL interactive sql monitor:
+ Please read the file COPYRIGHT for copyright terms of POSTGRESQL
- type \? for help on slash commands
- type \q to quit
- type \g or terminate with semicolon to execute query
- You are currently connected to the database: template1
+ type \? for help on slash commands
+ type \q to quit
+ type \g or terminate with semicolon to execute query
+ You are currently connected to the database: template1
- olly=>create database elsewhere with location = '/home/olly/private_db';
+olly=>create database elsewhere with location = '/home/olly/private_db';CREATEDB
@@ -186,8 +178,12 @@ There was a problem with creating the required directory; this operation will
Bugs
- There are security and data integrity issues involved with using alternate database locations
- specified with absolute path names. See the Administrator's Guide for more information.
+ There are security and data integrity issues
+ involved with using alternate database locations
+ specified with absolute path names, and by default
+only an environment variable known to the backend may be
+specified for an alternate location.
+ See the Administrator's Guide for more information.
@@ -207,7 +203,6 @@ Not sure if the dump/reload would guarantee that the alternate data area gets re
Compatibility
-
@@ -217,7 +212,7 @@ Not sure if the dump/reload would guarantee that the alternate data area gets re
SQL92
- There is no CREATE DATABASE statement on SQL92.
+ There is no CREATE DATABASE statement in SQL92.
The equivalent command in standard SQL is CREATE SCHEMA.
diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml
index 62fe39652f..96cce89bd9 100644
--- a/doc/src/sgml/ref/create_function.sgml
+++ b/doc/src/sgml/ref/create_function.sgml
@@ -15,30 +15,23 @@
- 1998-04-15
+ 1998-09-09
- CREATE FUNCTION name ([ftype [, ...]])
- RETURNS rtype
- AS path
- LANGUAGE 'langname'
+CREATE FUNCTION name ( [ ftype [, ...] ] )
+ RETURNS rtype
+ AS path
+ LANGUAGE 'langname'
- 1998-04-15
+ 1998-09-09
Inputs
-
-
-
-
-
-
-
@@ -87,21 +80,21 @@
- may be 'c', 'sql', 'internal' or 'plname'.
- (where 'plname' is the language name of a created procedural
- language. See CREATE LANGUAGE for details).
+ may be 'C', 'sql',
+ 'internal'
+ or 'plname',
+ where 'plname'
+ is the name of a created procedural
+ language. See CREATE LANGUAGE for details.
-
-
-
- 1998-04-15
+ 1998-09-09
Outputs
@@ -111,6 +104,7 @@
+status
@@ -134,32 +128,34 @@
- 1998-04-15
+ 1998-09-09
Description
- With this command, a PostgreSQL user can register a function
- with PostgreSQL. Subsequently, this user is treated as the
+ CREATE FUNCTION allows a
+Postgres user
+to register a function
+ with a database. Subsequently, this user is treated as the
owner of the function.
- 1998-04-15
+ 1998-09-09
Notes
- Refer to PostgreSQL User's Guide chapter 6 for further information.
- This reference needs to be corrected.
+ Refer to the chapter on functions
+in the PostgreSQL Programmer's Guide
+ for further information.
- Refer to the
- DROP FUNCTION
- statement to drop functions.
+ Use DROP FUNCTION
+ to drop user-defined functions.
@@ -171,15 +167,17 @@
To create a simple SQL function:
- CREATE FUNCTION one() RETURNS int4
- AS 'SELECT 1 AS RESULT'
- LANGUAGE 'sql';
+CREATE FUNCTION one() RETURNS int4
+ AS 'SELECT 1 AS RESULT'
+ LANGUAGE 'sql';
- SELECT one() AS answer;
+SELECT one() AS answer;
- answer
- ------
- 1
+
+answer
+------
+1
+
To create a C function, calling a routine from a user-created
@@ -188,17 +186,18 @@
is correct. It is intended for use in a CHECK contraint.
- CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
- AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c';
+
+CREATE FUNCTION ean_checkdigit(bpchar, bpchar) RETURNS bool
+ AS '/usr1/proj/bray/sql/funcs.so' LANGUAGE 'c';
- CREATE TABLE product
- (
- id char(8) PRIMARY KEY,
- eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}')
- REFERENCES brandname(ean_prefix),
- eancode char(6) CHECK (eancode ~ '[0-9]{6}'),
- CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode))
- );
+CREATE TABLE product
+(
+ id char(8) PRIMARY KEY,
+ eanprefix char(8) CHECK (eanprefix ~ '[0-9]{2}-[0-9]{5}')
+ REFERENCES brandname(ean_prefix),
+ eancode char(6) CHECK (eancode ~ '[0-9]{6}'),
+ CONSTRAINT ean CHECK (ean_checkdigit(eanprefix, eancode))
+);
@@ -216,39 +215,44 @@
Compatibility
- The CREATE FUNCTION statement is a PostgreSQL language extension.
+ CREATE FUNCTION is
+ a Postgres language extension.
- 1998-04-15
+ 1998-09-09
- SQL/PSM
-
- PSM stands for Persistent Stored Modules, it is a procedural
- language and it was originally hoped that PSM would be ratified
- as an official standard by late 1996. However PSM will
- eventually become a standard.
-
-
+ SQL/PSM
- The SQL/PSM CREATE FUNCTION statement has the following syntax:
-
- CREATE FUNCTION name
- ( [ [IN|OUT|INOUT] parmtype [, ...] ])
- RETURNS rtype
- LANGUAGE 'langname'
- ESPECIFIC routine
- SQL-statement
-
+
+
+
+ PSM stands for Persistent Stored Modules. It is a procedural
+ language and it was originally hoped that PSM would be ratified
+ as an official standard by late 1996. As of mid-1998, this
+has not yet happened, but it is hoped that PSM will
+ eventually become a standard.
+
+
+
+SQL/PSM CREATE FUNCTION has the following syntax:
+
+CREATE FUNCTION name
+ ( [ [ IN | OUT | INOUT ] parmtype [, ...] ] )
+ RETURNS rtype
+ LANGUAGE 'langname'
+ ESPECIFIC routine
+ SQL-statement
+
+
-
+
@@ -296,16 +298,16 @@ Is this example correct?
- 1998-04-15
+ 1998-09-09
SQL92
- CREATE INDEX is a PostgreSQL language extension.
+ CREATE INDEX is a Postgres language extension.
- There is no CREATE INDEX command in SQL92.
+ There is no CREATE INDEX command in SQL92.
diff --git a/doc/src/sgml/ref/create_language.sgml b/doc/src/sgml/ref/create_language.sgml
index b35d8b7c92..73e409c42a 100644
--- a/doc/src/sgml/ref/create_language.sgml
+++ b/doc/src/sgml/ref/create_language.sgml
@@ -15,29 +15,22 @@
- 1998-04-15
+ 1998-09-09
- CREATE [TRUSTED] PROCEDURAL LANGUAGE 'langname'
- HANDLER call_handler
- LANCOMPILER 'comment'
+CREATE [ TRUSTED ] PROCEDURAL LANGUAGE 'langname'
+ HANDLER call_handler
+ LANCOMPILER 'comment'
- 1998-04-15
+ 1998-09-09
Inputs
-
-
-
-
-
-
-
@@ -99,14 +92,12 @@
-
-
-
+
- 1998-04-15
+ 1998-09-09
Outputs
@@ -116,6 +107,7 @@
+status
@@ -152,22 +144,25 @@
- 1998-04-15
+ 1998-09-09
Description
- Using CREATE LANGUAGE, a PostgreSQL user can register
- a new language with PostgreSQL. Subsequently, functions and
+ Using CREATE LANGUAGE, a
+Postgres user can register
+ a new language with Postgres.
+Subsequently, functions and
trigger procedures can be defined in this new language.
- The user must have the PostgreSQL superuser privilege to
+ The user must have the Postgres
+ superuser privilege to
register a new language.
- 1998-04-15
+ 1998-09-09
Writing PL handlers
@@ -175,9 +170,9 @@
The call handler for a procedural language must be written
in a compiler language such as 'C' and registered with
- PostgreSQL as a function taking no arguments and returning
- opaque type.
- What does `opaque type' mean?
+ Postgres as a function taking
+ no arguments and returning the
+ opaque type, a placeholder for unspecified or undefined types..
This prevents the call handler from being
called directly as a function from queries.
@@ -214,11 +209,11 @@
It's up to the call handler to fetch the
pg_proc entry and
to analyze the argument and return types of the called
- procedure. The AS clause from the
+ procedure. The AS clause from the
CREATE FUNCTION of
the procedure will be found in the prosrc
attribute of the
- pg_proc entry. This may be the
+ pg_proc table entry. This may be the
source text in the procedural
language itself (like for PL/Tcl), a pathname to a
file or anything else that tells the call handler what to
@@ -227,43 +222,40 @@
- 1998-04-15
+ 1998-09-09
Notes
- Use
- CREATE FUNCTION
-
+ Use CREATE FUNCTION
to create a function.
- Use
- DROP LANGUAGE
- to drop procedural languages.
+ Use DROP LANGUAGE to drop procedural languages.
Refer to the table pg_language
for further information:
-
-
- Table = pg_language
- +--------------------------+--------------------------+-------+
- | Field | Type | Length|
- +--------------------------+--------------------------+-------+
- | lanname | name | 32 |
- | lancompiler | text | var |
- +--------------------------+--------------------------+-------+
+
+
+Table = pg_language
++--------------------------+--------------------------+-------+
+| Field | Type | Length|
++--------------------------+--------------------------+-------+
+| lanname | name | 32 |
+| lancompiler | text | var |
++--------------------------+--------------------------+-------+
+
+lanname |lancompiler
+--------+--------------
+internal|n/a
+lisp |/usr/ucb/liszt
+C |/bin/cc
+sql |postgres
+
+
- lanname |lancompiler
- --------+--------------
- internal|n/a
- lisp |/usr/ucb/liszt
- C |/bin/cc
- sql |postgres
-
-
@@ -274,11 +266,9 @@
Since the call handler for a procedural language must be
- registered with PostgreSQL in the 'C' language, it inherits
- all the restrictions of 'C' functions.
-
- What are these restrictions?
-
+ registered with Postgres in the 'C' language,
+ it inherits
+ all the capabilities and restrictions of 'C' functions.
@@ -340,22 +330,21 @@
Only a few thousand lines of code have to be added instead
- of the dots to complete the PL call handler. See
- CREATE FUNCTION
- for information on how to compile
+ of the dots to complete the PL call handler.
+See CREATE FUNCTION for information on how to compile
it into a loadable module
.
The following commands then register the sample procedural
- language.
+ language:
- CREATE FUNCTION plsample_call_handler () RETURNS opaque
- AS '/usr/local/pgsql/lib/plsample.so'
- LANGUAGE 'C';
+CREATE FUNCTION plsample_call_handler () RETURNS opaque
+ AS '/usr/local/pgsql/lib/plsample.so'
+ LANGUAGE 'C';
- CREATE PROCEDURAL LANGUAGE 'plsample'
- HANDLER plsample_call_handler
- LANCOMPILER 'PL/Sample';
+CREATE PROCEDURAL LANGUAGE 'plsample'
+ HANDLER plsample_call_handler
+ LANCOMPILER 'PL/Sample';
@@ -364,18 +353,18 @@
Compatibility
- CREATE LANGUAGE is a PostgreSQL extension.
+ CREATE LANGUAGE is a Postgres extension.
- 1998-04-15
+ 1998-09-09
SQL92
- There is no CREATE LANGUAGE statement in SQL92.
+ There is no CREATE LANGUAGE statement in SQL92.
diff --git a/doc/src/sgml/ref/create_operator.sgml b/doc/src/sgml/ref/create_operator.sgml
index febe709769..5322927fac 100644
--- a/doc/src/sgml/ref/create_operator.sgml
+++ b/doc/src/sgml/ref/create_operator.sgml
@@ -15,37 +15,31 @@
- 1998-04-15
+ 1998-09-09
- CREATE OPERATOR name
- ([ LEFTARG = type1 ]
- [, RIGHTARG = type2 ]
- , PROCEDURE = func_name
- [, COMMUTATOR = com_op ]
- [, NEGATOR = neg_op ]
- [, RESTRICT = res_proc ]
- [, HASHES ]
- [, JOIN = join_proc ]
- [, SORT = sort_op [, ...] ]
- )
+CREATE OPERATOR name
+ ( PROCEDURE = func_name
+ [, LEFTARG = type1 ]
+ [, RIGHTARG = type2 ]
+ [, COMMUTATOR = com_op ]
+ [, NEGATOR = neg_op ]
+ [, RESTRICT = res_proc ]
+ [, HASHES ]
+ [, JOIN = join_proc ]
+ [, SORT = sort_op [, ...] ]
+ )
- 1998-04-15
+ 1998-09-09
Inputs
-
-
-
-
-
-
@@ -53,25 +47,7 @@
- The name of an existing aggregate function.
-
-
-
-
-
- type1
-
-
-
-
-
-
-
-
- type2
-
-
-
+ The operator to be defined. See below for allowable characters.
@@ -81,6 +57,29 @@
+The function used to implement this operator.
+
+
+
+
+
+ type1
+
+
+
+The type for the left-hand side of the operator, if any. This option would be
+omitted for a right-unary operator.
+
+
+
+
+
+ type2
+
+
+
+The type for the right-hand side of the operator, if any. This option would be
+omitted for a left-unary operator.
@@ -90,6 +89,7 @@
+The corresponding commutative operator.
@@ -99,6 +99,7 @@
+The corresponding negation operator.
@@ -108,6 +109,17 @@
+The corresponding restriction operator.
+
+
+
+
+
+HASHES
+
+
+
+This operator can support a hash-join algorithm.
@@ -117,6 +129,7 @@
+Procedure supporting table joins.
@@ -126,18 +139,17 @@
+Operator to use for sorting.
-
-
-
+
- 1998-04-15
+ 1998-09-09
Outputs
@@ -147,6 +159,7 @@
+status
@@ -170,59 +183,62 @@
- 1998-04-15
+ 1998-09-09
Description
- This command defines a new user operator, operator_name.
+CREATE OPERATOR defines a new operator,
+ name.
The user who defines an operator becomes its owner.
- The operator_name is a sequence of up to sixteen punctua
- tion characters. The following characters are valid for
- single-character operator names:
+ The operator name
+ is a sequence of up to thirty two (32) characters in any combination
+from the following:
+
+ + - * / < > = ~ ! @ # % ^ & | ` ? $ :
+
+
+
+No alphabetic characters are allowed in an operator name.
+This enables Postgres to parse SQL input
+into tokens without requiring spaces between each token.
+
- ~ ! @ # % ^ & ` ?
-
-
- If the operator name is more than one character long, it
- may consist of any combination of the above characters or
- the following additional characters:
-
- | $ : + - * / < > =
- The operator "!=" is mapped to "<>" on input, and they are
+ The operator "!=" is mapped to "<>" on input, so they are
therefore equivalent.
- At least one of leftarg and rightarg must be defined. For
+ At least one of LEFTARG and RIGHTARG must be defined. For
binary operators, both should be defined. For right unary
- operators, only arg1 should be defined, while for left
- unary operators only arg2 should be defined.
+ operators, only LEFTARG should be defined, while for left
+ unary operators only RIGHTARG should be defined.
- The name of the operator, operator_name, can be composed
- of symbols only. Also, the func_name procedure must have
- been previously defined using create function(l) and must
- have one or two arguments.
+Also, the
+ func_name procedure must have
+ been previously defined using CREATE FUNCTION and must
+ be defined to accept the correct number of arguments
+ (either one or two).
- The commutator operator is present so that Postgres can
- reverse the order of the operands if it wishes. For exam
- ple, the operator area-less-than, >>>, would have a commu
- tator operator, area-greater-than, <<<. Suppose that an
- operator, area-equal, ===, exists, as well as an area not
- equal, !==. Hence, the query optimizer could freely con
- vert:
+ The commutator operator is present so that
+ Postgres can
+ reverse the order of the operands if it wishes.
+ For example, the operator area-less-than, <<<,
+ would have a commutator
+ operator, area-greater-than, >>>.
+ Hence, the query optimizer could freely convert:
- "0,0,1,1"::box >>> MYBOXES.description
+"0,0,1,1"::box >>> MYBOXES.description
to
- MYBOXES.description <<< "0,0,1,1"::box
+MYBOXES.description <<< "0,0,1,1"::box
This allows the execution code to always use the latter
@@ -230,17 +246,21 @@
what.
+ Suppose that an
+ operator, area-equal, ===, exists, as well as an area not
+ equal, !==.
The negator operator allows the query optimizer to convert
- NOT MYBOXES.description === "0,0,1,1"::box
+NOT MYBOXES.description === "0,0,1,1"::box
to
- MYBOXES.description !== "0,0,1,1"::box
+MYBOXES.description !== "0,0,1,1"::box
- If a commutator operator name is supplied, Postgres
+ If a commutator operator name is supplied,
+Postgres
searches for it in the catalog. If it is found and it
does not yet have a commutator itself, then the commutator's
entry is updated to have the current (new) operator
@@ -256,22 +276,25 @@
The next two specifications are present to support the
- query optimizer in performing joins. Postgres can always
+ query optimizer in performing joins.
+Postgres can always
evaluate a join (i.e., processing a clause with two tuple
variables separated by an operator that returns a boolean)
- by iterative substitution [WONG76]. In addition, Postgres
+ by iterative substitution [WONG76].
+In addition, Postgres
is planning on implementing a hash-join algorithm along
the lines of [SHAP86]; however, it must know whether this
- strategy is applicable. For example, a hash-join
+ strategy is applicable.
+For example, a hash-join
algorithm is usable for a clause of the form:
- MYBOXES.description === MYBOXES2.description
+MYBOXES.description === MYBOXES2.description
but not for a clause of the form:
- MYBOXES.description <<< MYBOXES2.description.
+MYBOXES.description <<< MYBOXES2.description.
- The hashes flag gives the needed information to the query
+ The HASHES flag gives the needed information to the query
optimizer concerning whether a hash join strategy is
usable for the operator in question.
@@ -279,15 +302,16 @@
optimizer whether merge-sort is a usable join strategy and
what operators should be used to sort the two operand
classes. For the === clause above, the optimizer must
- sort both relations using the operator, <<<. On the other
+ sort both relations using the operator, <<<. On the other
hand, merge-sort is not usable with the clause:
- MYBOXES.description <<< MYBOXES2.description
+MYBOXES.description <<< MYBOXES2.description
- If other join strategies are found to be practical, Post
- gres will change the optimizer and run-time system to use
+ If other join strategies are found to be practical,
+Postgres
+ will change the optimizer and run-time system to use
them and will require additional specification when an
operator is defined. Fortunately, the research community
invents new join strategies infrequently, and the added
@@ -299,12 +323,14 @@
the query optimizer can estimate result sizes. If a
clause of the form:
- MYBOXES.description <<< "0,0,1,1"::box
+MYBOXES.description <<< "0,0,1,1"::box
- is present in the qualification, then Postgres may have to
+ is present in the qualification,
+ then Postgres may have to
estimate the fraction of the instances in MYBOXES that
- satisfy the clause. The function res_proc must be a reg
- istered function (meaning it is already defined using
+ satisfy the clause. The function
+ res_proc
+ must be a registered function (meaning it is already defined using
define function(l)) which accepts one argument of the correct
data type and returns a floating point number. The
query optimizer simply calls this function, passing the
@@ -322,13 +348,14 @@
The difference between the function
- my_procedure_1 (MYBOXES.description, "0,0,1,1"::box)
+my_procedure_1 (MYBOXES.description, "0,0,1,1"::box)
and the operator
- MYBOXES.description === "0,0,1,1"::box
+MYBOXES.description === "0,0,1,1"::box
- is that Postgres attempts to optimize operators and can
+ is that Postgres
+ attempts to optimize operators and can
decide to use an index to restrict the search space when
operators are involved. However, there is no attempt to
optimize functions, and they are performed by brute force.
@@ -338,18 +365,17 @@
- 1998-04-15
+ 1998-09-09
Notes
- Refer to PostgreSQL User's Guide chapter 5
-
- This reference must be corrected.
-
+ Refer to the chapter on operators in the
+PostgreSQL User's Guide
for further information.
- Refer to DROP OPERATOR statement to drop operators.
+ Refer to DROP OPERATOR to delete
+user-defined operators from a database.
@@ -361,16 +387,16 @@
area-equality, for the BOX data type.
- CREATE OPERATOR === (
- LEFTARG = box,
- RIGHTARG = box,
- PROCEDURE = area_equal_procedure,
- COMMUTATOR = ===,
- NEGATOR = !==,
- RESTRICT = area_restriction_procedure,
- HASHES,
- JOIN = area-join-procedure,
- SORT = <<<, <<<)
+CREATE OPERATOR === (
+ LEFTARG = box,
+ RIGHTARG = box,
+ PROCEDURE = area_equal_procedure,
+ COMMUTATOR = ===,
+ NEGATOR = !==,
+ RESTRICT = area_restriction_procedure,
+ HASHES,
+ JOIN = area-join-procedure,
+ SORT = <<<, <<<)
@@ -381,18 +407,18 @@
Compatibility
- CREATE OPERATOR is a PostgreSQL extension of SQL.
+ CREATE OPERATOR is a Postgres extension.
- 1998-04-15
+ 1998-09-09
SQL92
- There is no CREATE OPERATOR statement on SQL92.
+ There is no CREATE OPERATOR statement in SQL92.
diff --git a/doc/src/sgml/ref/create_rule.sgml b/doc/src/sgml/ref/create_rule.sgml
index 887632061e..67215937c2 100644
--- a/doc/src/sgml/ref/create_rule.sgml
+++ b/doc/src/sgml/ref/create_rule.sgml
@@ -14,35 +14,28 @@
- 1998-04-15
+ 1998-09-11
- CREATE RULE name
- AS ON event
- TO object [WHERE condition]
- DO [INSTEAD]
- [action | NOTHING ]
+CREATE RULE name
+ AS ON event
+ TO object [ WHERE condition ]
+ DO [ INSTEAD ] [ action | NOTHING ]
- 1998-04-15
+ 1998-09-11
Inputs
-
-
-
-
-
-
- name
+name
@@ -52,31 +45,34 @@
- event
+event
- Event is one of select, update, delete or insert.
+ Event is one of select,
+ update, delete
+ or insert.
- object
+object
- Object is either table or table.column.
+ Object is either table
+ or table.column.
- condition
+condition
- Any SQL where clause. new or
+ Any SQL WHERE clause. new or
current can appear instead of an instance
variable whenever an instance variable is permissible in SQL.
@@ -84,25 +80,23 @@
- action
+action
- Any SQL-statement. new or
+ Any SQL statement. new or
current can appear instead of an instance
variable whenever an instance variable is permissible in SQL.
-
-
-
+
- 1998-04-15
+ 1998-09-11
Outputs
@@ -112,6 +106,7 @@
+status
@@ -136,7 +131,7 @@
- 1998-04-15
+ 1998-09-11
Description
@@ -146,13 +141,13 @@
accessed, updated, inserted or deleted, there is a current instance (for
retrieves, updates and deletes) and a new instance (for updates and
appends). If the event
- specified in the on clause and the
+ specified in the ON clause and the
condition specified in the
- where clause are true for the current instance, the
+ WHERE clause are true for the current instance, the
action part of the rule is
executed. First, however, values from fields in the current instance
and/or the new instance are substituted for
- current.attribute-name
+ current.attribute-name
and new.attribute-name.
@@ -163,13 +158,13 @@
- 1998-04-15
+ 1998-09-11
Notes
- A note of caution about SQL rules is in order. If the same class name
+ A caution about SQL rules is in order. If the same class name
or instance variable appears in the
event, the
condition and the
@@ -179,13 +174,14 @@
variables that are shared between these clauses. For example, the following
two rules have the same semantics:
- on update to EMP.salary where EMP.name = "Joe"
- do update EMP ( ... ) where ...
+on update to EMP.salary where EMP.name = "Joe"
+ do update EMP ( ... ) where ...
- on update to EMP-1.salary where EMP-2.name = "Joe"
- do update EMP-3 ( ... ) where ...
+on update to EMP-1.salary where EMP-2.name = "Joe"
+ do update EMP-3 ( ... ) where ...
- Each rule can have the optional tag instead. Without
+ Each rule can have the optional tag INSTEAD.
+Without
this tag, action will be
performed in addition to the user command when the
event in the
@@ -194,7 +190,7 @@
action part will be done
instead of the user command. In this later case, the
action can be the keyword
- nothing.
+ NOTHING.
When choosing between the rewrite and instance rule systems for a
@@ -205,32 +201,33 @@
It is very important to note that the rewrite rule system
will neither detect nor process circular rules. For example, though each
- of the following two rule definitions are accepted by Postgres, the
- retrieve command will cause Postgres to crash:
+ of the following two rule definitions are accepted by
+ Postgres, the
+ retrieve command will cause Postgres to crash:
Example of a circular rewrite rule combination.
- create rule bad_rule_combination_1 is
- on select to EMP
- do instead select to TOYEMP
+create rule bad_rule_combination_1 is
+ on select to EMP
+ do instead select to TOYEMP
- create rule bad_rule_combination_2 is
- on select to TOYEMP
- do instead select to EMP
+create rule bad_rule_combination_2 is
+ on select to TOYEMP
+ do instead select to EMP
- This attempt to retrieve from EMP will cause Postgres to crash.
+ This attempt to retrieve from EMP will cause
+ Postgres to crash.
- select * from EMP
+select * from EMP
You must have rule definition access to a class in order
- to define a rule on it (see change acl(l)).
-
- There is no manpage change or change_acl. What is intended?
-
+ to define a rule on it. Use GRANT
+and REVOKE to change permissions.
+
@@ -240,13 +237,13 @@
Usage
- Make Sam get the same salary adjustment as Joe
+ Make Sam get the same salary adjustment as Joe:
- create rule example_1 is
- on update EMP.salary where current.name = "Joe"
- do update EMP (salary = new.salary)
- where EMP.name = "Sam"
+create rule example_1 is
+ on update EMP.salary where current.name = "Joe"
+ do update EMP (salary = new.salary)
+ where EMP.name = "Sam"
At the time Joe receives a salary adjustment, the event
@@ -257,44 +254,45 @@
Joe's salary on to Sam.
- Make Bill get Joe's salary when it is accessed
+ Make Bill get Joe's salary when it is accessed:
- create rule example_2 is
-
- on select to EMP.salary
- where current.name = "Bill"
- do instead
- select (EMP.salary) from EMP where EMP.name = "Joe"
+create rule example_2 is
+ on select to EMP.salary
+ where current.name = "Bill"
+ do instead
+ select (EMP.salary) from EMP
+ where EMP.name = "Joe"
Deny Joe access to the salary of employees in the shoe
- department. (pg_username() returns the name of
- the current user)
+ department (current_user returns the name of
+ the current user):
- create rule example_3 is
- on select to EMP.salary
- where current.dept = "shoe" and pg_username() = "Joe"
- do instead nothing
+create rule example_3 is
+ on select to EMP.salary
+ where current.dept = "shoe" and current_user = "Joe"
+ do instead nothing
Create a view of the employees working in the toy department.
- create TOYEMP(name = char16, salary = int4)
+create TOYEMP(name = char16, salary = int4)
- create rule example_4 is
- on select to TOYEMP
- do instead select (EMP.name, EMP.salary) from EMP
- where EMP.dept = "toy"
+create rule example_4 is
+ on select to TOYEMP
+ do instead
+ select (EMP.name, EMP.salary) from EMP
+ where EMP.dept = "toy"
All new employees must make 5,000 or less
- create rule example_5 is
- on insert to EMP where new.salary > 5000
- do update newset salary = 5000
+create rule example_5 is
+ on insert to EMP where new.salary > 5000
+ do update newset salary = 5000
@@ -303,9 +301,6 @@
Bugs
-
- instead rules do not work properly.
-
The object in a SQL rule cannot be an array reference and
cannot have parameters.
@@ -328,18 +323,19 @@
Compatibility
- CREATE RULE statement is a PostgreSQL language extension.
+ CREATE RULE statement is a Postgres
+ language extension.
- 1998-04-15
+ 1998-09-11
SQL92
- There is no CREATE RULE statement in SQL92.
+ There is no CREATE RULE statement in SQL92.
diff --git a/doc/src/sgml/ref/create_sequence.sgml b/doc/src/sgml/ref/create_sequence.sgml
index 20d03240e3..d678bb319c 100644
--- a/doc/src/sgml/ref/create_sequence.sgml
+++ b/doc/src/sgml/ref/create_sequence.sgml
@@ -18,34 +18,28 @@
1998-04-15
- CREATE SEQUENCE seqname
- [INCREMENT increment]
- [MINVALUE minvalue]
- [MAXVALUE maxvalue]
- [START start]
- [CACHE cache]
- [CYCLE]
+CREATE SEQUENCE seqname
+ [ INCREMENT increment ]
+ [ MINVALUE minvalue ]
+ [ MAXVALUE maxvalue ]
+ [ START start ]
+ [ CACHE cache ]
+ [ CYCLE ]
- 1998-04-15
+ 1998-09-11
Inputs
-
-
-
-
-
-
- seqname
+ seqname
@@ -55,19 +49,19 @@
- increment
+ increment
The clause is optional. A positive value will make an
- ascending sequence, a negative one a descending sequence. The default value
- is 1.
+ ascending sequence, a negative one a descending sequence.
+ The default value is one (1).
- minvalue
+ minvalue
@@ -81,7 +75,7 @@
- maxvalue
+ maxvalue
@@ -95,7 +89,7 @@
- start
+ start
@@ -107,15 +101,12 @@
for ascending sequences and
maxvalue
for descending ones.
-
- What happens if the user specifies start outside the range?
-
- cache
+ cache
@@ -128,7 +119,7 @@
- CYCLE
+ CYCLE
@@ -146,14 +137,11 @@
-
-
-
- 1998-04-15
+ 1998-09-11
Outputs
@@ -163,6 +151,7 @@
+status
@@ -179,7 +168,7 @@
- ERROR: amcreate: ' seqname' relation already exists
+ERROR: amcreate: 'seqname' relation already exists
@@ -187,6 +176,36 @@
+
+
+ERROR: DefineSequence: START value (start) can't be > MAXVALUE (maxvalue)
+
+
+
+ If the specified starting value is out of range.
+
+
+
+
+
+ERROR: DefineSequence: START value (start) can't be < MINVALUE (minvalue)
+
+
+
+ If the specified starting value is out of range.
+
+
+
+
+
+ERROR: DefineSequence: MINVALUE (minvalue) can't be >= MAXVALUE (maxvalue)
+
+
+
+ If the minimum and maximum values are inconsistant.
+
+
+
@@ -196,7 +215,7 @@
- 1998-04-15
+ 1998-09-11
Description
@@ -210,18 +229,20 @@
After the sequence is created, you may use the function
- nextval() with the
- sequence name as the argument to get a new number from the sequence.
- The function currval('sequence_name') may be used
+nextval(seqname)
+to get a new number from the sequence.
+The function
+currval('seqname')
+ may be used
to determine the number returned by the last call to
- nextval() for the
- specified sequence in the current session.
+nextval(seqname)
+ for the specified sequence in the current session.
Use a query like
- SELECT * FROM sequence_name;
+SELECT * FROM sequence_name;
to get the parameters of a sequence.
@@ -232,7 +253,7 @@
- 1998-04-15
+ 1998-09-11
Notes
@@ -243,7 +264,7 @@
Each backend uses its own cache to store allocated numbers.
Numbers that are cached but not used in the current session will be
- lost.
+ lost, resulting in "holes" in the sequence.
@@ -253,25 +274,25 @@
Usage
- Create an ascending sequence called serial, starting at 101:
+ Create an ascending sequence called serial, starting at 101:
- CREATE SEQUENCE serial START 101;
+CREATE SEQUENCE serial START 101;
Select the next number from this sequence
- SELECT NEXTVAL ('serial');
+SELECT NEXTVAL ('serial');
- nextval
- -------
- 114
+nextval
+-------
+ 114
Use this sequence in an INSERT:
- INSERT INTO distributors VALUES (NEXTVAL ('serial'),'nothing');
+INSERT INTO distributors VALUES (NEXTVAL('serial'),'nothing');
@@ -281,18 +302,20 @@
Compatibility
- CREATE SEQUENCE statement is a PostgreSQL language extension.
+ CREATE SEQUENCE is a Postgres
+ language extension.
- 1998-04-15
+ 1998-09-11
SQL92
- There is no CREATE SEQUENCE statement on SQL92.
+ There is no CREATE SEQUENCE statement
+ in SQL92.
diff --git a/doc/src/sgml/ref/drop_index.sgml b/doc/src/sgml/ref/drop_index.sgml
index 726487356e..39ebe9f5d4 100644
--- a/doc/src/sgml/ref/drop_index.sgml
+++ b/doc/src/sgml/ref/drop_index.sgml
@@ -84,8 +84,8 @@
- This message occurs if it is impossible to drop the index
- because it does not exist.
+ This message occurs if "index_name"
+ is not an index in the database.
@@ -121,7 +121,7 @@
Refer to the CREATE INDEX statement for
- inforamtion on how to create indexes.
+ information on how to create indices.
@@ -152,7 +152,9 @@
SQL92
- There is no DROP INDEX statement on SQL92.
+SQL92 defines commands by which to access a generic relational database.
+Indices are an implementation-dependent feature and hence
+there is no DROP INDEX statement in SQL92.
diff --git a/doc/src/sgml/ref/drop_language.sgml b/doc/src/sgml/ref/drop_language.sgml
index 09f0cc34d7..60a4376025 100644
--- a/doc/src/sgml/ref/drop_language.sgml
+++ b/doc/src/sgml/ref/drop_language.sgml
@@ -172,7 +172,7 @@
SQL92
- There is no DROP PROCEDURAL LANGUAGE statement on SQL92.
+ There is no DROP PROCEDURAL LANGUAGE statement in SQL92.
diff --git a/doc/src/sgml/ref/drop_user.sgml b/doc/src/sgml/ref/drop_user.sgml
index a99e5005b7..f0dce27293 100644
--- a/doc/src/sgml/ref/drop_user.sgml
+++ b/doc/src/sgml/ref/drop_user.sgml
@@ -158,7 +158,7 @@
SQL92
- There is no DROP USER statement on SQL92.
+ There is no DROP USER statement in SQL92.