Commit 7ac541da authored by Marc G. Fournier's avatar Marc G. Fournier

moved man pages here, as requested by Bryan

parent 389fe48c
The page.5 source should be run through pic when generating troff
output. nroff doesn't handle pic.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/abort.l,v 1.1 1996/11/14 10:15:07 scrappy Exp $
.TH ABORT SQL 01/23/93 Postgres95 Postgres95
.\" XXX This .XA has to go after the .TH so that the index page number goes
.\" in the right place...
.SH Abort
.SH NAME
abort \(em abort the current transaction
.SH SYNOPSIS
.nf
\fBabort\fP \fB[transaction]\fR
.fi
.SH DESCRIPTION
This command aborts the current transaction and causes all the
updates made by the transaction to be discarded.
.IR "abort"
is functionally equivalent to
.IR "rollback".
.SH "SEE ALSO"
begin(l),
end(l),
rollback(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/alter_table.l,v 1.1 1996/11/14 10:15:09 scrappy Exp $
.TH "ALTER TABLE" SQL 11/5/95 Postgres95 Postgres95
.SH NAME
alter table \(em add attributes to a class
.SH SYNOPSIS
.nf
\fBalter table\fR classname [*]
\fBadd column\fR attname type
.fi
.SH DESCRIPTION
The
.BR "alter table"
command
causes a new attribute to be added to an existing class,
.IR classname .
The new attributes and their types are specified
in the same style and with the the same restrictions as in
.IR create table (l).
.PP
In order to add an attribute to each class in an entire inheritance
hierarchy, use the
.IR classname
of the superclass and append a \*(lq*\*(rq. (By default, the
attribute will not be added to any of the subclasses.) This should
.BR always
be done when adding an attribute to a superclass. If it is not,
queries on the inheritance hierarchy such as
.nf
select * from super* s
.fi
will not work because the subclasses will be missing an attribute
found in the superclass.
.PP
For efficiency reasons, default values for added attributes are not
placed in existing instances of a class. That is, existing instances
will have NULL values in the new attributes. If non-NULL values are
desired, a subsequent
.IR update (l)
query should be run.
.PP
You must own the class in order to change its schema.
.SH EXAMPLE
.nf
--
-- add the date of hire to the emp class
--
alter table emp add column hiredate abstime
.fi
.nf
--
-- add a health-care number to all persons
-- (including employees, students, ...)
--
alter table person * add column health_care_id int4
.fi
.SH "SEE ALSO"
create table (l),
update (l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/begin.l,v 1.1 1996/11/14 10:15:11 scrappy Exp $
.TH BEGIN SQL 11/05/95 Postgres95 Postgres95
.SH NAME
begin \(em begins a transaction
.SH SYNOPSIS
.nf
\fBbegin\fP \fB[transaction|work]\fR
.fi
.SH DESCRIPTION
This command begins 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, Postgres will ensure that all updates are done or none of
them are done. Transactions have the standard ACID (atomic,
consistent, isolatable, and durable) property.
.SH "SEE ALSO"
abort(l),
end(l).
.\" This is -*-nroff-*-
.\" $Header: /cvsroot/pgsql/src/man/Attic/bki.5,v 1.1 1996/11/14 10:15:12 scrappy Exp $
.TH BKI 5 11/04/96 Postgres Postgres
.SH NAME
*.bki
.SH DESCRIPTION
Backend Interface (BKI) files are scripts that are input to the postgres
backend running in the special "bootstrap" mode that allows it to perform
database functions without a database system already existing. BKI files
can therefore be used to create the database system in the first place.
.PP
.IR Initdb
uses BKI files to do just that -- create a database system. However,
.IR initdb's
BKI files are generated internally. It generates them using the files
global1.bki.source and local1.template1.bki.source, which it finds in the
Postgres "library" directory. They get installed there as part of installing
Postgres. These .source files get build as part of the Postgres build
process, by a build program called
.IR genbki. Genbki
takes as input Postgres source files that double as
.IR genbki
input that builds tables and C header files that describe those
tables.
.PP
The Postgres backend interprets BKI files as described below. This
description will be easier to understand if the global1.bki.source file is
at hand as an example. (As explained above, this .source file isn't quite
a BKI file, but you'll be able to guess what the resulting BKI file would be
anyway).
.PP
Commands are composed of a command name followed by space separated
arguments. Arguments to a command which begin with a \*(lq$\*(rq are
treated specially. If \*(lq$$\*(rq are the first two characters, then
the first \*(lq$\*(rq is ignored and the argument is then processed
normally. If the \*(lq$\*(rq is followed by space, then it is treated
as a
.SM NULL
value. Otherwise, the characters following the \*(lq$\*(rq are
interpreted as the name of a macro causing the argument to be replaced
with the macro's value. It is an error for this macro to be
undefined.
.PP
Macros are defined using
.nf
define macro macro_name = macro_value
.fi
and are undefined using
.nf
undefine macro macro_name
.fi
and redefined using the same syntax as define.
.PP
Lists of general commands and macro commands
follow.
.SH "GENERAL COMMANDS"
.TP 5n
.BR "open" " classname"
Open the class called
.IR classname
for further manipulation.
.TP
.BR "close" " [classname]"
Close the open class called
.IR classname.
It is an error if
.IR classname
is not already opened. If no
.IR classname
is given, then the currently open class is closed.
.TP
.BR print
Print the currently open class.
.TP
.BR "insert" " [oid=oid_value] " "(" " value1 value2 ... " ")"
Insert a new instance to the open class using
.IR value1 ,
.IR value2 ,
etc., for its attribute values and
.IR oid_value
for its OID. If
.IR oid_value
is not \*(lq0\*(rq, then this value will be used as the instance's
object identifier. Otherwise, it is an error.
.TP
.BR "insert (" " value1 value2 ... " ")"
As above, but the system generates a unique object identifier.
.TP
.BR "create" " classname " "(" " name1 = type1, name2 = type2, ... " ")"
Create a class named
.IR classname
with the attributes given in parentheses.
.TP
.BR "open (" " name1 = type1, name2 = type2,... " ") as" " classname"
Open a class named
.IR classname
for writing but do not record its existence in the system catalogs.
(This is primarily to aid in bootstrapping.)
.TP
.BR "destroy" " classname"
Destroy the class named
.IR classname .
.TP
.BR "define index" " index-name " "on" " class-name " "using" " amname "
( opclass attr | function({attr}) )
.br
Create an index named
.IR index_name
on the class named
.IR classname
using the
.IR amname
access method. The fields to index are called
.IR name1 ,
.IR name2 ,
etc., and the operator collections to use are
.IR collection_1 ,
.IR collection_2 ,
etc., respectively.
.SH "MACRO COMMANDS"
.TP
.BR "define function" " macro_name " "as" " rettype function_name ( args )"
Define a function prototype for a function named
.IR macro_name
which has its value of type
.IR rettype
computed from the execution
.IR function_name
with the arguments
.IR args
declared in a C-like manner.
.TP
.BR "define macro" " macro_name " "from file" " filename"
Define a macro named
.IR macname
which has its value
read from the file called
.IR filename .
.\" .uh "DEBUGGING COMMANDS"
.\" .sp
.\" .in .5i
.\" r
.\" .br
.\" Randomly print the open class.
.\" .sp
.\" m -1
.\" .br
.\" Toggle display of time information.
.\" .sp
.\" m 0
.\" .br
.\" Set retrievals to now.
.\" .sp
.\" m 1 Jan 1 01:00:00 1988
.\" .br
.\" Set retrievals to snapshots of the specfied time.
.\" .sp
.\" m 2 Jan 1 01:00:00 1988, Feb 1 01:00:00 1988
.\" .br
.\" Set retrievals to ranges of the specified times.
.\" Either time may be replaced with space
.\" if an unbounded time range is desired.
.\" .sp
.\" \&.A classname natts name1 type1 name2 type2 ...
.\" .br
.\" Add attributes named
.\" .ul
.\" name1,
.\" .ul
.\" name2,
.\" etc. of
.\" types
.\" .ul
.\" type1,
.\" .ul
.\" type2,
.\" etc. to the
.\" .ul
.\" class
.\" classname.
.\" .sp
.\" \&.RR oldclassname newclassname
.\" .br
.\" Rename the
.\" .ul
.\" oldclassname
.\" class to
.\" .ul
.\" newclassname.
.\" .sp
.\" \&.RA classname oldattname newattname
.\" .br
.\" Rename the
.\" .ul
.\" oldattname
.\" attribute in the class named
.\" .ul
.\" classname
.\" to
.\" .ul
.\" newattname.
.SH EXAMPLE
The following set of commands will create the \*(lqpg_opclass\*(rq
class containing the
.IR int_ops
collection as object
.IR 421,
print out the class, and then close it.
.nf
create pg_opclass (opcname=char16)
open pg_opclass
insert oid=421 (int_ops)
print
close pg_opclass
.fi
.SH "SEE ALSO"
initdb(1),
createdb(1),
create_database(l).
This diff is collapsed.
This diff is collapsed.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/cleardbdir.1,v 1.1 1996/11/14 10:15:24 scrappy Exp $
.TH CLEARDBDIR UNIX 11/05/95 Postgres95 Postgres95
.SH NAME
cleardbdir \(em completely destroys all database files
.SH SYNOPSIS
.BR "cleardbdir"
.SH DESCRIPTION
.IR cleardbdir
destroys all the database files. It is used only by the
Postgres super-user
before re-initializing the entire installation for a particular site. Normal
database users should never use this command.
.PP
The
Postgres super-user
should ensure the
.IR postmaster
process is not running before running cleardbdir.
.SH "SEE ALSO"
initdb(1)
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/close.l,v 1.1 1996/11/14 10:15:27 scrappy Exp $
.TH CLOSE SQL 11/05/95 Postgres95 Postgres95
.SH NAME
close \(em close a cursor
.SH SYNOPSIS
.nf
\fBclose\fP [cursor_name]
.fi
.SH DESCRIPTION
.BR Close
frees the resources associated with a cursor,
.IR cursor_name.
After this cursor is closed, no subsequent operations are allowed on
it. A cursor should be closed when it is no longer needed. If
.IR cursor_name.
is not specified, then the blank cursor is closed.
.SH EXAMPLE
.nf
/*
* close the cursor FOO
*/
close FOO
.fi
.SH "SEE ALSO"
fetch(l),
select(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/cluster.l,v 1.1 1996/11/14 10:15:32 scrappy Exp $
.TH CLUSTER SQL 01/23/93 Postgres95 Postgres95
.SH NAME
cluster \(em give storage clustering advice to Postgres
.SH SYNOPSIS
.nf
\fBcluster\fR indexname \fBon\fR attname
.fi
.SH DESCRIPTION
This command instructs Postgres to cluster the class specified by
.IR classname
approximately based on the index specified by
.IR indexname.
The index must already have been defined on
.IR classname.
.PP
When a class is clustered, it is physically reordered based on the index
information. The clustering is static. In other words, if the class is
updated, it may become unclustered. No attempt is made to keep new
instances or updated tuples clustered. If desired, the user can
recluster manually by issuing the command again.
.SH EXAMPLE
.nf
/*
* cluster employees in based on its salary attribute
*/
create index emp_ind on emp using btree (salary int4_ops);
cluster emp_ind on emp
.fi
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/commit.l,v 1.1 1996/11/14 10:15:36 scrappy Exp $
.TH COMMIT SQL 01/23/93 Postgres95 Postgres95
.SH NAME
commit \(em commit the current transaction
.SH SYNOPSIS
.nf
\fBcommit [transaction|work]\fR
.fi
.SH DESCRIPTION
This commands commits the current transaction. All changes made by
the transaction become visible to others and are guaranteed to be
durable if a crash occurs.
.IR "commit"
is functionally equivalent to the
.IR "end"
command
.SH "SEE ALSO"
abort(l),
begin(l),
end(l),
rollback(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/copy.l,v 1.1 1996/11/14 10:15:39 scrappy Exp $
.TH COPY SQL 11/05/95 Postgres95 Postgres95
.SH NAME
copy \(em copy data to or from a class from or to a Unix file.
.SH SYNOPSIS
.nf
\fBcopy\fP [\fBbinary\fP] classname [\fBwith oids\fP]
\fBto\fP|\fBfrom '\fPfilename\fB'\fP|\fBstdin\fR|\fBstdout\fR
[\fBusing delimiters '\fPdelim\fB'\fP]
.fi
.SH DESCRIPTION
.BR Copy
moves data between Postgres classes and standard Unix files. The
keyword
.BR binary
changes the behavior of field formatting, as described below.
.IR Classname
is the name of an existing class.
The keyword
.BR "with oids"
copies the internal unique object id (OID) for each row.
.IR Classname
is the name of an existing class.
.IR Filename
is the absolute Unix pathname of the file. In place of a filename, the
keywords
.BR "stdin" " and " "stdout"
can be used so that input to
.BR copy
can be written by a Libpq application and output from the
.BR copy
command can be read by a Libpq application.
.PP
The
.BR 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
.BR copy
command, but is not generally portable, and the files generated are
somewhat larger, although this factor is highly dependent on the data
itself.
When copying in, the
.BR "with oids"
keyword should only be used on an empty database because
the loaded oids could conflict with existing oids.
By default, a ASCII
.BR copy
uses a tab (\\t) character as a delimiter. The delimiter may also be changed
to any other single-character with the use of
.BR "using delimiters" .
Characters in data fields which happen to match the delimiter character
will be quoted.
.PP
You must have read access on any class whose values are read by the
.BR copy
command, and either write or append access to a class to which values
are being appended by the
.BR copy
command.
.SH FORMAT OF OUTPUT FILES
.SS "ASCII COPY FORMAT"
When
.BR copy
is used without the
.BR binary
keyword, the file generated will have each instance on a line, with
each attribute separated by the delimiter character. Embedded delimiter
characters will be preceeded by a backslash character (\\). 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
.BR copy
itself.
.PP
The actual format for each instance is
.nf
<attr1><tab><attr2><tab>...<tab><attrn><newline>
.fi
The oid is placed on the beginning of the line if specified.
.PP
If
.BR 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 line by themselves, when it is done. Similarly, if
.BR 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,
.BR copy
will terminate (followed by the backend itself) if a true EOF is
encountered.
.PP
The backslash character has special meaning.
.BR 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 Postgres95, you will need to
convert backslash characters (\\) to double-backslashes (\\\\) so
they are loaded properly.
.SS "BINARY COPY FORMAT"
In the case of
.BR "copy binary" ,
the first four bytes in the file will be the number of instances in
the file. If this number is
.IR zero,
the
.BR "copy binary"
command will read until end of file is encountered. Otherwise, it
will stop reading when this number of instances has been read.
Remaining data in the file will be ignored.
.PP
The format for each instance in the file is as follows. Note that
this format must be followed
.BR EXACTLY .
Unsigned four-byte integer quantities are called uint32 in the below
description.
.nf
The first value is:
uint32 number of tuples
then for each tuple:
uint32 total length of data segment
uint32 oid (if specified)
uint32 number of null attributes
[uint32 attribute number of first null attribute
...
uint32 attribute number of nth null attribute],
<data segment>
.fi
.bp
.SS "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 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.
.SH "SEE ALSO"
insert(l), create table(l), vacuum(l), libpq.
.SH BUGS
Files used as arguments to the
.BR copy
command must reside on or be accessible to the the database server
machine by being either on local disks or a networked file system.
.PP
.BR Copy
stops operation at the first error. This should not lead to problems
in the event of a
.BR "copy from" ,
but the target relation will, of course, be partially modified in a
.BR "copy to" .
The
.IR vacuum (l)
query should be used to clean up after a failed
.BR "copy" .
.PP
Because Postgres operates out of a different directory than the user's
working directory at the time Postgres is invoked, the result of copying
to a file \*(lqfoo\*(rq (without additional path information) may
yield unexpected results for the naive user. In this case,
\*(lqfoo\*(rq will wind up in
.SM $PGDATA\c
/foo. In general, the full pathname should be used when specifying
files to be copied.
.PP
.BR Copy
has virtually no error checking, and a malformed input file will
likely cause the backend to crash. You should avoid using
.BR copy
for input whenever possible.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_aggregate.l,v 1.1 1996/11/14 10:15:42 scrappy Exp $
.TH "CREATE AGGREGATE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
create aggregate \(em define a new aggregate
.SH SYNOPSIS
.nf
\fBcreate aggregate\fR agg-name [\fBas\fR]
\fB(\fP[\fBsfunc1\fR \fB=\fR state-transition-function-1
,\fP \fBbasetype\fR \fB=\fR data-type
,\fP \fBstype1\fR \fB=\fR sfunc1-return-type]
[\fB,\fP \fBsfunc2\fR \fB=\fR state-transition-function-2
,\fP \fBstype2\fR \fB=\fR sfunc2-return-type]
[\fB,\fP \fBfinalfunc\fR \fB=\fR final-function]
[\fB,\fP \fBinitcond1\fR \fB=\fR initial-condition-1]
[\fB,\fP \fBinitcond2\fR \fB=\fR initial-condition-2]\fB)\fR
.fi
.SH DESCRIPTION
An aggregate function can use up to three functions, two
.IR "state transition"
functions, X1 and X2:
.nf
X1( internal-state1, next-data_item ) ---> next-internal-state1
X2( internal-state2 ) ---> next-internal-state2
.fi
and a
.BR "final calculation"
function, F:
.nf
F(internal-state1, internal-state2) ---> aggregate-value
.fi
These functions are required to have the following properties:
.IP
The arguments to state-transition-function-1 must be
.BR ( stype1 , basetype ) ,
and its return value must be stype1.
.IP
The argument and return value of state-transition-function-2 must be
.BR stype2 .
.IP
The arguments to the final-calculation-function must be
.BR ( stype1 , stype2 ) ,
and its return value must be a POSTGRES base type (not
necessarily the same as basetype.
.IP
The final-calculation-function should be specified if and only if both
state-transition functions are specified.
.PP
Note that it is possible to specify aggregate functions that have
varying combinations of state and final functions. For example, the
\*(lqcount\*(rq aggregate requires
.BR sfunc2
(an incrementing function) but not
.BR sfunc1 " or " finalfunc ,
whereas the \*(lqsum\*(rq aggregate requires
.BR sfunc1
(an addition function) but not
.BR sfunc2 " or " finalfunc
and the \*(lqaverage\*(rq aggregate requires both of the above state
functions as well as a
.BR finalfunc
(a division function) to produce its answer. In any case, at least
one state function must be defined, and any
.BR sfunc2
must have a corresponding
.BR initcond2 .
.PP
Aggregates also require two initial conditions, one for each
transition function. These are specified and stored in the database
as fields of type
.IR text .
.SH EXAMPLE
This
.IR avg
aggregate consists of two state transition functions, a addition
function and a incrementing function. These modify the internal state
of the aggregate through a running sum and and the number of values
seen so far. It accepts a new employee salary, increments the count,
and adds the new salary to produce the next state. The state
transition functions must be passed correct initialization values.
The final calculation then divides the sum by the count to produce the
final answer.
.nf
--
--Create an aggregate for int4 average
--
create aggregate avg (sfunc1 = int4add, basetype = int4,
stype1 = int4, sfunc2 = int4inc, stype2 = int4,
finalfunc = int4div, initcond1 = "0", initcond2 = "0")
.fi
.SH "SEE ALSO"
create function(l),
remove aggregate(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_database.l,v 1.1 1996/11/14 10:15:45 scrappy Exp $
.TH "CREATE DATABASE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
create database \(em create a new database
.SH SYNOPSIS
.nf
\fBcreate database\fP dbname
.fi
.SH DESCRIPTION
.BR "Create database"
creates a new Postgres database. The creator becomes the administrator
of the new database.
.SH "SEE ALSO"
createdb(1),
drop database(l),
destroydb(1),
initdb(1).
.SH BUGS
This command should
.BR NOT
be executed interactively. The
.IR createdb (1)
script should be used instead.
This diff is collapsed.
This diff is collapsed.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_operator.l,v 1.1 1996/11/14 10:15:58 scrappy Exp $
.TH "CREATE OPERATOR" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
create operator \(em define a new user operator
.SH SYNOPSIS
.nf
\fBcreate operator\fR operator_name
\fB(\fR[ \fBleftarg\fR \fB=\fR type-1 ]
[ \fB,\fR \fBrightarg\fR \fB=\fR type-2 ]
, \fBprocedure =\fR func_name
[\fB, commutator =\fR com_op ]
[\fB, negator =\fR neg_op ]
[\fB, restrict =\fR res_proc ]
[\fB, hashes\fR]
[\fB, join =\fR join_proc ]
[\fB, sort =\fR sor_op1 {\fB,\fR sor_op2 } ]
\fB)\fR
.\" \fB"arg is ("
.\" type [
.\" \fB,
.\" type ]
.\" \fB)
.fi
.SH DESCRIPTION
This command defines a new user operator,
.IR "operator_name" .
The user who defines an operator becomes its owner.
.PP
The
.IR "operator_name"
is a sequence of up to sixteen punctuation characters. The following
characters are valid for single-character operator names:
.nf
~ ! @ # % ^ & ` ?
.fi
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:
.nf
| $ : + - * / < > =
.fi
.PP
At least one of
.IR leftarg
and
.IR rightarg
must be defined. For binary operators, both should be defined. For
right unary operators, only
.IR arg1
should be defined, while for left unary operators only
.IR arg2
should be defined.
.PP
The name of the operator,
.IR operator_name ,
can be composed of symbols only. Also, the
.IR func_name
procedure must have been previously defined using
.IR "create function" (l)
and must have one or two arguments.
.PP
.\" that multiple instances of the
.\" operator must be be evaluated
.\" For example, consider the area-intersection operator,
.\" .q A,
.\" and the following expression:
.\" .(l
.\" MYBOXES2.description A \*(lq0,0,1,1\*(rq A MYBOXES.description
.\" .)l
.\" .in .5i
.\" The associativity flag indicates that
.\" .(l
.\" (MYBOXES2.description A \*(lq0,0,1,1\*(rq) A MYBOXES.description
.\" .)l
.\" .in .5i
.\" is the same as
.\" .(l
.\" MYBOXES2.description A (\*(lq0,0,1,1\*(rq A MYBOXES.description).
.\" .)l
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, <<<. Suppose that an operator, area-equal, ===,
exists, as well as an area not equal, !==. Hence, the query optimizer
could freely convert:
.nf
"0,0,1,1"::box >>> MYBOXES.description
.fi
to
.nf
MYBOXES.description <<< "0,0,1,1"::box
.fi
This allows the execution code to always use the latter representation
and simplifies the query optimizer somewhat.
.PP
The negator operator allows the query optimizer to convert
.nf
not MYBOXES.description === "0,0,1,1"::box
.fi
to
.nf
MYBOXES.description !== "0,0,1,1"::box
.fi
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 as its commutator. This applies to the negator, as
well.
.PP
This is to allow the definition of two operators that are the
commutators or the negators of each other. The first operator should
be defined without a commutator or negator (as appropriate). When the
second operator is defined, name the first as the commutator or
negator. The first will be updated as a side effect.
.PP
The next two specifications are present to support the 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 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 algorithm is usable
for a clause of the form:
.nf
MYBOXES.description === MYBOXES2.description
.fi
but not for a clause of the form:
.nf
MYBOXES.description <<< MYBOXES2.description.
.fi
The
.BR hashes
flag gives the needed information to the query optimizer concerning
whether a hash join strategy is usable for the operator in question.
.PP
Similarly, the two sort operators indicate to the query 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 hand, merge-sort is not usable with the clause:
.nf
MYBOXES.description <<< MYBOXES2.description
.fi
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 generality of user-defined join strategies was not felt to
be worth the complexity involved.
.PP
The last two pieces of the specification are present so the query
optimizer can estimate result sizes. If a clause of the form:
.nf
MYBOXES.description <<< "0,0,1,1"::box
.fi
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 registered function (meaning it is already
defined using
.IR "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 parameter
.nf
"0,0,1,1"
.fi
and multiplies the result by the relation size to get the desired
expected number of instances.
.PP
Similarly, when the operands of the operator both contain instance
variables, the query optimizer must estimate the size of the resulting
join. The function join_proc will return another floating point
number which will be multiplied by the cardinalities of the two
classes involved to compute the desired expected result size.
.PP
The difference between the function
.nf
my_procedure_1 (MYBOXES.description, "0,0,1,1"::box)
.fi
and the operator
.nf
MYBOXES.description === "0,0,1,1"::box
.fi
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. Moreover, functions can have any number of
arguments while operators are restricted to one or two.
.SH EXAMPLE
.nf
--
--The following command defines a new operator,
--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 = <<<, <<<)
.\" arg is (box, box)
.fi
.SH "SEE ALSO"
create function(l),
drop operator(l).
.SH BUGS
Operator names cannot be composed of alphabetic characters in
Postgres.
.PP
If an operator is defined before its commuting operator has been defined
(a case specifically warned against above), a dummy operator with invalid
fields will be placed in the system catalogs. This may interfere with
the definition of later operators.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_rule.l,v 1.1 1996/11/14 10:16:03 scrappy Exp $
.TH "CREATE RULE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
create rule \(em define a new rule
.SH SYNOPSIS
.nf
\fBcreate\fR \fBrule\fR rule_name
\fBas\fR \fBon\fR event
\fBto\fR object [\fBwhere\fR clause]
\fBdo\fR [\fBinstead\fR]
[action | nothing | \fB[\fPactions...\fB]\fP]
.fi
.SH DESCRIPTION
.IR "The current rule system implementation is very brittle and is unstable. Users are discouraged from using rules at this time."
.PP
.BR "Create rule"
is used to define a new rule.
.PP
Here,
.IR event
is one of
.IR select ,
.IR update ,
.IR delete
or
.IR insert .
.IR Object
is either:
.nf
a class name
\fIor\fR
class.column
.fi
The
.BR "from"
clause, the
.BR "where"
clause, and the
.IR action
are respectively normal SQL
.BR "from"
clauses,
.BR "where"
clauses and collections of SQL commands with the following change:
.IP
.BR new
or
.BR current
can appear instead of
an instance variable whenever an instance
variable is permissible in SQL.
.PP
The semantics of a rule is that at the time an individual instance is
accessed, updated, inserted or deleted, there is a
.BR current
instance
(for retrieves, updates and deletes) and a
.BR new
instance (for updates and appends). If the event specified in the
.BR "on"
clause and the condition specified in the
.BR "where"
clause are true for the current instance, then the
.IR action
part of the rule is executed. First, however, values from fields in
the current instance and/or the new instance are substituted for:
.nf
current.attribute-name
new.attribute-name
.fi
The
.IR action
part of the rule executes with same command and transaction identifier
as the user command that caused activation.
.PP
A note of caution about SQL rules is in order. If the same class
name or instance variable appears in the event,
.BR where
clause and the
.IR action
parts of a rule, they are all considered different tuple variables.
More accurately,
.BR new
and
.BR current
are the only tuple variables that are shared between these clauses.
For example, the following two rules have the same semantics:
.nf
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 ...
.fi
Each rule can have the optional tag
.BR "instead" .
Without this tag
.IR action
will be performed in addition to the user command when the event in
the condition part of the rule occurs. Alternately, the
.IR action
part will be done instead of the user command.
In this later case, the action can be the keyword
.BR nothing .
.PP
When choosing between the rewrite and instance rule systems for a
particular rule application, remember that in the rewrite system
.BR current
refers to a relation and some qualifiers whereas in the instance
system it refers to an instance (tuple).
.PP
It is very important to note that the
.BR 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
.IR retrieve
command will cause
Postgres to
.IR crash :
.nf
--
--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_2 is
on select to TOYEMP
do instead select to EMP
--
--This attempt to retrieve from EMP will cause Postgres to crash.
--
select * from EMP
.fi
.PP
You must have
.IR "rule definition"
access to a class in order to define a rule on it (see
.IR "change acl" (l).
.SH EXAMPLES
.nf
--
--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"
.fi
At the time Joe receives a salary adjustment, the event will become
true and Joe's current instance and proposed new instance are available
to the execution routines. Hence, his new salary is substituted into the
.IR action
part of the rule which is subsequently executed. This propagates
Joe's salary on to Sam.
.nf
--
--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"
.fi
.nf
--
--Deny Joe access to the salary of employees in the shoe
--department. (pg_username() 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
.fi
.nf
--
--Create a view of the employees working in the toy department.
--
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"
.fi
.nf
--
--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
.fi
.SH "SEE ALSO"
drop rule(l),
create view(l).
.SH BUGS
.PP
.BR "instead"
rules do not work properly.
.PP
The object in a SQL rule cannot be an array reference and cannot
have parameters.
.PP
Aside from the \*(lqoid\*(rq field, system attributes cannot be
referenced anywhere in a rule. Among other things, this means that
functions of instances (e.g., \*(lqfoo(emp)\*(rq where \*(lqemp\*(rq
is a class) cannot be called anywhere in a rule.
.PP
The rule system store the rule text and query plans as text
attributes. This implies that creation of rules may fail if the
rule plus its various internal representations exceed some value
that is on the order of one page (8KB).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_table.l,v 1.1 1996/11/14 10:16:08 scrappy Exp $
.TH "CREATE TABLE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
create table \(em create a new class
.SH SYNOPSIS
.nf
\fBcreate table \fR classname \fB(\fPattname-1 type-1 {\fB,\fP attname-i type-i}\fB)\fP
[\fBinherits\fR \fB(\fR classname-1 {\fB,\fR classname-i} \fB)\fR]
[\fBarchive\fR \fB=\fR archive_mode]
[\fBstore\fR \fB=\fR \*(lqsmgr_name\*(rq]
[\fBarch_store\fR \fB=\fR \*(lqsmgr_name\*(rq]
.fi
.SH DESCRIPTION
.BR "Create table"
will enter a new class into the current data base. The class will be
\*(lqowned\*(rq by the user issuing the command. The name of the
class is
.IR classname
and the attributes are as specified in the list of
.IR attname s.
The
.IR i th
attribute is created with the type specified by
.IR type "-i."
Each type may be a simple type, a complex type (set) or an array type.
.PP
Each array attribute stores arrays that must have the same number of
dimensions but may have different sizes and array index bounds. An
array of dimension
.IR n
is specified by appending
.IR n
pairs of square brackets:
.nf
att_name = type[][]..[]
.fi
.PP
The optional
.BR inherits
clause specifies a collection of class names from which this class
automatically inherits all fields. If any inherited field name
appears more than once, Postgres reports an error. Postgres automatically
allows the created class to inherit functions on classes above it in
the inheritance hierarchy. Inheritance of functions is done according
to the conventions of the Common Lisp Object System (CLOS).
.PP
Each new class
.IR classname
is automatically created as a type. Therefore, one or more instances
from the class are automatically a type and can be used in
.IR alter table(l)
or other
.BR "create table"
statements. See
.IR introduction (l)
for a further discussion of this point.
.PP
The optional
.BR store
and
.BR arch_store
keywords may be used to specify a storage manager to use for the new
class. The released version of Postgres supports only \*(lqmagnetic
disk\*(rq as a storage manager name; the research system at UC Berkeley
provides additional storage managers.
.BR Store
controls the location of current data,
and
.BR arch_store
controls the location of historical data.
.BR Arch_store
may only be specified if
.BR archive
is also specified. If either
.BR store
or
.BR arch_store
is not declared, it defaults to \*(lqmagnetic disk\*(rq.
.PP
The new class is created as a heap with no initial data. A class can
have no more than 1600 attributes (realistically, this is limited by the
fact that tuple sizes must be less than 8192 bytes), but this limit
may be configured lower at some sites. A class cannot have the same
name as a system catalog class.
.PP
The
.BR archive
keyword specifies whether historical data is to be saved or discarded.
.IR Arch_mode
may be one of:
.TP 10n
.IR none
No historical access is supported.
.TP 10n
.IR light
Historical access is allowed and optimized for light update activity.
.TP 10n
.IR heavy
Historical access is allowed and optimized for heavy update activity.
.PP
.IR Arch_mode
defaults to \*(lqnone\*(rq. Once the archive status is set, there is
no way to change it. For details of the optimization, see [STON87].
.SH EXAMPLES
.nf
--
-- Create class emp with attributes name, sal and bdate
--
create table emp (name char16, salary float4, bdate abstime)
.fi
.nf
--
--Create class permemp with pension information that
--inherits all fields of emp
--
create table permemp (plan char16) inherits (emp)
.fi
.nf
--
--Create class foo on magnetic disk and archive historical data
--
create table foo (bar int4) archive = heavy
store = "magnetic disk"
.fi
.nf
--
--Create class tictactoe to store noughts-and-crosses
--boards as a 2-dimensional array
--
create table tictactoe (game int4, board = char[][])
.fi
.nf
--
--Create a class newemp with a set attribute "manager". A
--set (complex) attribute may be of the same type as the
--relation being defined (as here) or of a different complex
--type. The type must exist in the "pg_type" catalog or be
--the one currently being defined.
--
create table newemp (name text, manager = newemp)
.fi
.SH "SEE ALSO"
drop table(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_type.l,v 1.1 1996/11/14 10:16:12 scrappy Exp $
.TH "CREATE TYPE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
create type \(em define a new base data type
.SH SYNOPSIS
.nf
\fBcreate type\fP typename \fB(\fR\fBinternallength\fR = (number | \fBvariable\fR),
[ \fBexternallength\fR = (number | \fBvariable\fR)\fB,\fR ]
\fBinput\fR = input_function,
\fBoutput\fR = output_function
[\fB,\fR \fBelement\fR = typename]
[\fB,\fR \fBdelimiter\fR = <character>]
[\fB,\fR \fBdefault\fR = "string" ]
[\fB,\fR \fBsend\fR = send_function ]
[\fB,\fR \fBreceive\fR = receive_function ]
[\fB,\fR \fBpassedbyvalue\fR]\fB)\fR
.fi
.\" \fBcreate type\fP typename as sql_commands
.SH DESCRIPTION
.BR "Create type"
allows the user to register a new user data type with Postgres for use in
the current data base. The user who defines a type becomes its owner.
.IR Typename
is the name of the new type and must be unique within the types
defined for this database.
.PP
.BR "Create type"
requires the registration of two functions (using
.IR "create function" (l))
before defining the type. The representation of a new base type is
determined by
.IR input_function ,
which converts the type's external representation to an internal
representation usable by the operators and functions defined for the
type. Naturally,
.IR "output_function"
performs the reverse transformation. Both the input and output
functions must be declared to take one or two arguments of type
\*(lqopaque\*(rq.
.PP
New base data types can be fixed length, in which case
.BR "internallength"
is a positive integer, or variable length, in which case Postgres assumes
that the new type has the same format as the Postgres-supplied data type,
\*(lqtext\*(rq. To indicate that a type is variable-length, set
.BR "internallength"
to
.IR "variable" .
The external representation is similarly specified using the
.IR "externallength"
keyword.
.PP
To indicate that a type is an array and to indicate that a type has
array elements, indicate the type of the array element using the
.BR "element"
keyword. For example, to define an array of 4 byte integers
(\*(lqint4\*(rq), specify
.nf
element = int4
.fi
.PP
To indicate the delimiter to be used on arrays of this type,
.BR "delimiter"
can be set to a specific character. The default delimiter is the
comma (\*(lq,\*(rq) character.
.PP
A
.BR "default"
value is optionally available in case a user wants some specific bit
pattern to mean \*(lqdata not present.\*(rq
.PP
The optional functions
.IR "send_function"
and
.IR "receive_function"
are used when the application program requesting Postgres services
resides on a different machine. In this case, the machine on which
Postgres runs may use a different format for the data type than used on
the remote machine. In this case it is appropriate to convert data
items to a standard form when
.BR send ing
from the server to the client and converting from the standard format
to the machine specific format when the server
.BR receive s
the data from the client. If these functions are not specified, then
it is assumed that the internal format of the type is acceptable on
all relevant machine architectures. For example, single characters do
not have to be converted if passed from a Sun-4 to a DECstation, but
many other types do.
.PP
The optional
.BR "passedbyvalue"
flag indicates that operators and functions which use this data type
should be passed an argument by value rather than by reference. Note
that only types whose internal representation is at most four bytes
may be passed by value.
.PP
For new base types, a user can define operators, functions and
aggregates using the appropriate facilities described in this section.
.SH "ARRAY TYPES"
Two generalized built-in functions,
.BR array_in
and
.BR array_out,
exist for quick creation of variable-length array types. These
functions operate on arrays of any existing Postgres type.
.SH "LARGE OBJECT TYPES"
A \*(lqregular\*(rq Postgres type can only be 8192 bytes in length. If
you need a larger type you must create a Large Object type. The
interface for these types is discussed at length in Section 7, the
large object interface. The length of all large object types
is always
.IR variable,
meaning the
.BR internallength
for large objects is always -1.
.SH EXAMPLES
.nf
--
--This command creates the box data type and then uses the
--type in a class definition
--
create type box (internallength = 8,
input = my_procedure_1, output = my_procedure_2)
create table MYBOXES (id = int4, description = box)
.fi
.nf
--
--This command creates a variable length array type with
--integer elements.
--
create type int4array
(input = array_in, output = array_out,
internallength = variable, element = int4)
create table MYARRAYS (id = int4, numbers = int4array)
.fi
.nf
--
--This command creates a large object type and uses it in
--a class definition.
--
create type bigobj
(input = lo_filein, output = lo_fileout,
internallength = variable)
create table BIG_OBJS (id = int4, obj = bigobj)
.fi
.SH "RESTRICTIONS"
Type names cannot begin with the underscore character (\*(lq_\*(rq)
and can only be 15 characters long. This is because Postgres silently
creates an array type for each base type with a name consisting of the
base type's name prepended with an underscore.
.SH "SEE ALSO"
create function(l),
create operator(l),
drop type(l),
introduction(large objects).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_version.l,v 1.1 1996/11/14 10:16:15 scrappy Exp $
.TH "CREATE VERSION" SQL 01/23/93 Postgres95 Postgres95
.SH NAME
create version \(em construct a version class
.SH SYNOPSIS
.nf
\fBcreate version\fP classname1 \fBfrom\fP classname2 [\fB[\fPabstime\fB]\fP]
.fi
.SH DESCRIPTION
.IR "Currently, the versioning facility is not working."
.PP
This command creates a version class
.IR classname1
which is related
to its parent class,
.IR classname2 .
Initially,
.IR classname1
has the same contents as
.IR classname2.
As updates to
.IR classname1
occur, however,
the content of
.IR classname1
diverges from
.IR classname2.
On the other hand, any updates to
.IR classname2
show transparently through to
.IR classname1 ,
unless the instance in question has already been updated in
.IR classname1 .
.PP
If the optional
.IR abstime
clause is specified, then the version is constructed relative to a
.BR snapshot
of
.IR classname2
as of the time specified.
.PP
Postgres uses the query rewrite rule system to ensure that
.IR classname1
is differentially encoded relative to
.IR classname2.
Moreover,
.IR classname1
is automatically constructed to have the same indexes as
.IR classname2 .
It is legal to cascade versions arbitrarily, so a tree of versions can
ultimately result. The algorithms that control versions are explained
in [ONG90].
.SH EXAMPLE
.nf
--
--create a version foobar from a snapshot of
--barfoo as of January 17, 1990
--
create version foobar from barfoo [ "Jan 17 1990" ]
.fi
.SH "SEE ALSO"
create view(l), merge(l).
.SH "BUGS"
Snapshots (i.e., the optional
.IR abstime
clause) are not implemented in Postgres.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/create_view.l,v 1.1 1996/11/14 10:16:17 scrappy Exp $
.TH "CREATE VIEW" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
create view \(em construct a virtual class
.SH SYNOPSIS
.nf
\fBcreate view\fR view_name \fBas\fR
\fBselect\fR expression1 [\fBas\fR attr_name1]
{, expression_i [\fBas\fR attr_namei]}
[\fBfrom\fR from.last]
[\fBwhere\fR qual]
.fi
.SH DESCRIPTION
.BR "create view"
will define a view of a class. This view is not physically
materialized; instead the rule system is used to support view
processing as in [STON90]. Specifically, a query rewrite retrieve
rule is automatically generated to support retrieve operations on
views. Then, the user can add as many update rules as desired to
specify the processing of update operations to views. See [STON90]
for a detailed discussion of this point.
.SH EXAMPLE
.nf
--
--create a view consisting of toy department employees
--
create view toyemp as
select e.name
from emp e
where e.dept = 'toy'
.fi
.nf
--
--Specify deletion semantics for toyemp
--
create rule example1 as
on delete to toyemp
do instead delete emp
where emp.oid = current.oid
.fi
.SH "SEE ALSO"
create table(l),
create rule(l),
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/createdb.1,v 1.1 1996/11/14 10:16:20 scrappy Exp $
.TH CREATEDB UNIX 11/05/95 Postgres95 Postgres95
.SH NAME
createdb \(em create a database
.SH SYNOPSIS
.BR createdb
[\c
.BR -a
system]
[\c
.BR -h
host]
[\c
.BR -p
port]
[dbname]
.SH DESCRIPTION
.IR Createdb
creates a new database. The person who executes this command becomes
the database administrator, or DBA, for this database and is the only
person, other than the Postgres super-user, who can destroy it.
.PP
.IR Createdb
is a shell script that invokes
.IR psql .
Hence, a
.IR postmaster
process must be running on the database server host before
.IR createdb
is executed. In addition, the
.SM PGOPTION
and
.SM PGREALM
environment variables will be passed on to
.IR psql
and processed as described in
.IR psql (1).
.PP
The optional argument
.IR dbname
specifies the name of the database to be created. The name must be
unique among all Postgres databases.
.IR Dbname
defaults to the value of the
.SM USER
environment variable.
.PP
.IR Createdb
understands the following command-line options:
.TP 5n
.BR "-a" " system"
Specifies an authentication system
.IR "system"
(see
.IR introduction (1))
to use in connecting to the
.IR postmaster
process. The default is site-specific.
.TP
.BR "-h" " host"
Specifies the hostname of the machine on which the
.IR postmaster
is running. Defaults to the name of the local host, or the value of
the
.SM PGHOST
environment variable (if set).
.TP
.BR "-p" " port"
Specifies the Internet TCP port on which the
.IR postmaster
is listening for connections. Defaults to 5432, or the value of the
.SM PGPORT
environment variable (if set).
.SH EXAMPLES
.nf
# create 5432 demo database
createdb demo
.fi
.nf
# create the demo database using the postmaster on host eden,
# port using the Kerberos authentication system.
createdb -a kerberos -p 5432 -h eden demo
.fi
.SH FILES
.TP 5n
\&$PGDATA/base/\fIdbname\fP
The location of the files corresponding to the database
.IR dbname .
.SH "SEE ALSO"
createdb(l),
destroydb(1),
initdb(1),
psql(1),
postmaster(1).
.SH DIAGNOSTICS
.TP 5n
.BI "Error: Failed to connect to backend (host=" "xxx" ", port=" "xxx" ")"
.IR Createdb
could not attach to the
.IR postmaster
process on the specified host and port. If you see this message,
ensure that the
.IR postmaster
is running on the proper host and that you have specified the proper
port. If your site uses an authentication system, ensure that you
have obtained the required authentication credentials.
.TP
.BI "user \*(lq" "username" "\*(rq is not in \*(lqpg_user\*(rq"
You do not have a valid entry in the relation \*(lqpg_user\*(rq and
cannot do anything with Postgres at all; contact your Postgres site
administrator.
.TP
.BI "user \*(lq" "username" "\*(rq is not allowed to create/destroy databases"
You do not have permission to create new databases; contact your Postgres
site administrator.
.TP
.IB "dbname" " already exists"
The database already exists.
.TP
.BI "database creation failed on" " dbname"
An internal error occurred in
.IR psql
or the backend server. Ensure that your Postgres site administrator has
properly installed Postgres and initialized the site with
.IR initdb .
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/createuser.1,v 1.1 1996/11/14 10:16:23 scrappy Exp $
.TH CREATEUSER UNIX 11/05/95 Postgres95 Postgres95
.SH NAME
createuser \(em create a Postgres user
.SH SYNOPSIS
.BR createuser
[\c
.BR -a
system]
[\c
.BR -h
host]
[\c
.BR -p
port]
[username]
.SH DESCRIPTION
.IR Createuser
creates a new Postgres user. Only users with \*(lqusesuper\*(rq set in
the \*(lqpg_user\*(rq class can create new Postgres users. As shipped,
the user \*(lqpostgres\*(rq can create users.
.PP
.IR Createuser
is a shell script that invokes
.IR psql .
Hence, a
.IR postmaster
process must be running on the database server host before
.IR createuser
is executed. In addition, the
.SM PGOPTION
and
.SM PGREALM
environment
variables will be passed on to
.IR psql
and processed as described in
.IR psql (1).
.PP
The optional argument
.IR username
specifies the name of the Postgres user to be created. (The invoker will
be prompted for a name if none is specified on the command line.)
This name must be unique among all Postgres users.
.PP
.IR Createuser
understands the following command-line options:
.TP 5n
.BR "-a" " system"
Specifies an authentication system
.IR "system"
(see
.IR introduction (1))
to use in connecting to the
.IR postmaster
process. The default is site-specific.
.TP
.BR "-h" " host"
Specifies the hostname of the machine on which the
.IR postmaster
is running. Defaults to the name of the local host, or the value of
the
.SM PGHOST
environment variable (if set).
.TP
.BR "-p" " port"
Specifies the Internet TCP port on which the
.IR postmaster
is listening for connections. Defaults to 5432, or the value of the
.SM PGPORT
environment variable (if set).
.SH "INTERACTIVE QUESTIONS"
Once invoked with the above options,
.IR createuser
will ask a series of questions. The new users's login name (if not
given on the command line) and user-id must be specified. (Note that
the Postgres user-id must be the same as the user's Unix user-id.) In
addition, you must describe the security capabilities of the new user.
Specifically, you will be asked whether the new user should be able to
act as Postgres super-user, create new databases and update the system
catalogs manually.
.SH "SEE ALSO"
destroyuser(1),
psql(1),
postmaster(1).
.SH DIAGNOSTICS
.TP 5n
.BI "Error: Failed to connect to backend (host=" "xxx" ", port=" "xxx" ")"
.IR Createuser
could not attach to the
.IR postmaster
process on the specified host and port. If you see this message,
ensure that the
.IR postmaster
is running on the proper host and that you have specified the proper
port. If your site uses an authentication system, ensure that you
have obtained the required authentication credentials.
.TP
.BI "user \*(lq" "username" "\*(rq is not in \*(lqpg_user\*(rq"
You do not have a valid entry in the relation \*(lqpg_user\*(rq and
cannot do anything with Postgres at all; contact your Postgres site
administrator.
.TP
.IB "username" " cannot create users."
You do not have permission to create new users; contact your Postgres
site administrator.
.TP
.BI "user \*(lq" "username" "\*(rq already exists"
The user to be added already has an entry in the \*(lqpg_user\*(rq
class.
.TP
.BR "database access failed"
An internal error occurred in
.IR psql
or the backend server. Ensure that your Postgres site administrator has
properly installed Postgres and initialized the site with
.IR initdb .
.SH BUGS
Postgres user-ids and user names should not have anything to do with the
constraints of Unix.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/delete.l,v 1.1 1996/11/14 10:16:29 scrappy Exp $
.TH DELETE SQL 11/05/95 Postgres95 Postgres95
.SH NAME
delete \(em delete instances from a class
.SH SYNOPSIS
.nf
\fBdelete\fR \fBfrom\fR class_name [ \fBwhere\fR qual ]
.fi
.SH DESCRIPTION
.BR Delete
removes instances which satisfy the qualification,
.IR qual
from the specified class.
If the qualification is absent, the effect is to delete all instances
in the class. The result is a valid, but empty class.
.PP
You must have write access to the class in order to modify it, as well
as read access to any class whose values are read in the qualification
(see
.IR "change acl" (l).
.SH EXAMPLE
.nf
--
--Remove all employees who make over $30,000
--
delete from emp where emp.sal > 30000
.fi
.nf
--
--Clear the hobbies class
--
delete from hobbies
.fi
.SH "SEE ALSO"
drop(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/destroydb.1,v 1.1 1996/11/14 10:16:32 scrappy Exp $
.TH DESTROYDB UNIX 11/05/95 Postgres95 Postgres95
.SH NAME
destroydb \(em destroy an existing database
.SH SYNOPSIS
.BR destroydb
[\c
.BR -a
system]
[\c
.BR -h
host]
[\c
.BR -p
port]
[dbname]
.SH DESCRIPTION
.IR Destroydb
destroys an existing database. To execute this command, the user must
be the database administrator, or DBA, for this database.
The program runs silently; no confirmation message will be displayed.
After the database is destroyed, a Unix shell prompt will reappear.
.PP
.IR Destroydb
is a shell script that invokes
.IR psql .
Hence, a
.IR postmaster
process must be running on the database server host before
.IR destroydb
is executed. In addition, the
.SM PGOPTION
and
.SM PGREALM
environment
variables will be passed on to
.IR psql
and processed as described in
.IR psql (1).
.PP
The optional argument
.IR dbname
specifies the name of the database to be destroyed. All references to
the database are removed, including the directory containing this
database and its associated files.
.IR Dbname
defaults to the value of the
.SM USER
environment variable.
.PP
.IR Destroydb
understands the following command-line options:
.TP 5n
.BR "-a" " system"
Specifies an authentication system
.IR "system"
(see
.IR introduction (1))
to use in connecting to the
.IR postmaster
process. The default is site-specific.
.TP
.BR "-h" " host"
Specifies the hostname of the machine on which the
.IR postmaster
is running. Defaults to the name of the local host, or the value of
the
.SM PGHOST
environment variable (if set).
.TP
.BR "-p" " port"
Specifies the Internet TCP port on which the
.IR postmaster
is listening for connections. Defaults to 5432, or the value of the
.SM PGPORT
environment variable (if set).
.SH EXAMPLES
.nf
# destroy the demo database
destroydb demo
.fi
.nf
# destroy 5432 demo database using the postmaster on host eden,
# port using the Kerberos authentication system.
destroydb -a kerberos -p 5432 -h eden demo
.fi
.SH FILES
.TP 5n
\&$PGDATA/base/\fIdbname\fP
The location of the files corresponding to the database
.IR dbname .
.SH "SEE ALSO"
destroydb(l),
createdb(1),
initdb(1),
psql(1).
postmaster(1).
.SH DIAGNOSTICS
.TP 5n
.BI "Error: Failed to connect to backend (host=" "xxx" ", port=" "xxx" ")"
.IR Destroydb
could not attach to the
.IR postmaster
process on the specified host and port. If you see this message,
ensure that the
.IR postmaster
is running on the proper host and that you have specified the proper
port. If your site uses an authentication system, ensure that you
have obtained the required authentication credentials.
.TP
.BI "user \*(lq" "username" "\*(rq is not in \*(lqpg_user\*(rq"
You do not have a valid entry in the relation \*(lqpg_user\*(rq and
cannot do anything with Postgres at all; contact your Postgres site
administrator.
.TP
.BI "user \*(lq" "username" "\*(rq is not allowed to create/destroy databases"
You do not have permission to destroy databases; contact your Postgres
site administrator.
.TP
.BR "database \*(lqdbname\*(rq does not exist"
The database to be removed does not have an entry in the
\*(lqpg_database\*(rq class.
.TP
.BI "database \*(lq" "dbname" "\*(rq is not owned by you"
You are not DBA for the specified database.
.TP
.BI "database destroy failed on" " dbname"
An internal error occurred in
.IR psql
or the backend server. Contact your Postgres site administrator to
ensure that ensure that the files and database entries associated with
the database are completely removed.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/destroydb.l,v 1.1 1996/11/14 10:16:35 scrappy Exp $
.TH DESTROYDB SQL 01/23/93 Postgres95 Postgres95
.SH NAME
drop database \(em destroy an existing database
.SH SYNOPSIS
.nf
\fBdrop database\fR dbname
.fi
.SH DESCRIPTION
.BR "Drop database"
removes the catalog entries for an existing database and deletes the
directory containing the data. It can only be executed by the
database administrator (see
.IR createdb (l)
for details).
.SH "SEE ALSO"
create database(l),
destroydb(1).
.SH BUGS
This query should
.BR NOT
be executed interactively. The
.IR destroydb (1)
script should be used instead.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/destroyuser.1,v 1.1 1996/11/14 10:16:39 scrappy Exp $
.TH DESTROYUSER UNIX 11/05/95 Postgres95 Postgres95
.SH NAME
destroyuser \(em destroy a Postgres user and associated databases
.SH SYNOPSIS
.BR destroyuser
[\c
.BR -a
system]
[\c
.BR -h
host]
[\c
.BR -p
port]
[username]
.SH DESCRIPTION
.PP
.IR Destroyuser
destroys an existing Postgres user and the databases for which that user
is database administrator. Only users with \*(lqusesuper\*(rq set in
the \*(lqpg_user\*(rq class can destroy new Postgres users. As shipped,
the user \*(lqpostgres\*(rq can destroy users.
.PP
.IR Destroyuser
is a shell script that invokes
.IR psql .
Hence, a
.IR postmaster
process must be running on the database server host before
.IR destroyuser
is executed. In addition, the
.SM PGOPTION
and
.SM PGREALM
environment variables will be passed on to
.IR psql
and processed as described in
.IR psql (1).
.PP
The optional argument
.IR username
specifies the name of the Postgres user to be destroyed. (The invoker will
be prompted for a name if none is specified on the command line.)
.PP
.IR Destroyuser
understands the following command-line options:
.TP 5n
.BR "-a" " system"
Specifies an authentication system
.IR "system"
(see
.IR introduction (1))
to use in connecting to the
.IR postmaster
process. The default is site-specific.
.TP
.BR "-h" " host"
Specifies the hostname of the machine on which the
.IR postmaster
is running. Defaults to the name of the local host, or the value of
the
.SM PGHOST
environment variable (if set).
.TP
.BR "-p" " port"
Specifies the Internet TCP port on which the
.IR postmaster
is listening for connections. Defaults to 5432, or the value of the
.SM PGPORT
environment variable (if set).
.SH "INTERACTIVE QUESTIONS"
.PP
Once invoked with the above options,
.IR destroyuser
will warn you about the databases that will be destroyed in the
process and permit you to abort the removal of the user if desired.
.SH "SEE ALSO"
createuser(1),
psql(1),
postmaster(1).
.SH DIAGNOSTICS
.TP 5n
.BI "Error: Failed to connect to backend (host=" "xxx" ", port=" "xxx" ")"
.IR Destroyuser
could not attach to the
.IR postmaster
process on the specified host and port. If you see this message,
ensure that the
.IR postmaster
is running on the proper host and that you have specified the proper
port. If your site uses an authentication system, ensure that you
have obtained the required authentication credentials.
.TP
.BI "user \*(lq" "username" "\*(rq is not in \*(lqpg_user\*(rq"
You do not have a valid entry in the relation \*(lqpg_user\*(rq and
cannot do anything with Postgres at all; contact your Postgres site
administrator.
.TP
.IB "username" " cannot delete users."
You do not have permission to delete users; contact your Postgres site
administrator.
.TP
.BI "user \*(lq" "username" "\*(rq does not exist"
The user to be removed does not have an entry in the \*(lqpg_user\*(rq
class.
.TP
.BR "database access failed"
.TP
.BI "destroydb on" " dbname" " failed - exiting"
.TP
.BI "delete of user" " username" " was UNSUCCESSFUL"
An internal error occurred in
.IR psql
or the backend server. Contact your Postgres site administrator to
ensure that the files and database entries associated with the user
and his/her associated databases are completely removed.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/drop.l,v 1.1 1996/11/14 10:16:43 scrappy Exp $
.TH "DROP TABLE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
drop table \(em destroy existing classes
.SH SYNOPSIS
.nf
\fBdrop table\fR classname-1 { \fB,\fR classname-i }
.fi
.SH DESCRIPTION
.BR "Drop Table"
removes classes from the data base. Only its owner may destroy a
class. A class may be emptied of instances, but not destroyed, by
using
.IR delete (l).
.PP
If a class being destroyed has secondary indices on it, then they will
be removed first. The removal of just a secondary index will not
affect the indexed class.
.PP
The destruction of classes is not reversable. Thus, a destroyed class
will not be recovered if a transaction which destroys this class fails
to commit. In addition, historical access to instances in a destroyed
class is not possible.
.SH EXAMPLE
.nf
--
--Destroy the emp class
--
drop table emp
.fi
.nf
--
--Destroy the emp and parts classes
--
drop table emp, parts
.fi
.SH "SEE ALSO"
delete(l),
drop index(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/drop_aggregate.l,v 1.1 1996/11/14 10:16:47 scrappy Exp $
.TH "DROP AGGREGATE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
drop aggregate \(em remove the definition of an aggregate
.SH SYNOPSIS
.nf
\fBdrop aggregate\fR aggname
.fi
.SH DESCRIPTION
.BR "drop aggregate"
will remove all reference to an existing aggregate definition. To
execute this command the current user must be the the owner of the
aggregate.
.SH EXAMPLE
.nf
--
--Remove the average aggregate
--
drop aggregate avg
.fi
.SH "SEE ALSO"
create aggregate(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/drop_function.l,v 1.1 1996/11/14 10:16:53 scrappy Exp $
.TH "DROP FUNCTION" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
drop function \(em remove a user-defined C function
.SH SYNOPSIS
.nf
\fBdrop function \fRfunction_name ( \fP[ type-1 { \fB,\fP type-n } ] \fB)
.fi
.SH DESCRIPTION
.BR "drop function"
will remove references to an existing C function. To execute this
command the user must be the owner of the function. The input
argument types to the function must be specified, as only the
function with the given name and argument types will be removed.
.SH EXAMPLE
.nf
--
--this command removes the square root function
--
drop function sqrt(int4)
.fi
.SH "SEE ALSO"
create function(l).
.SH BUGS
No checks are made to ensure that types, operators or access methods
that rely on the function have been removed first.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/drop_index.l,v 1.1 1996/11/14 10:17:01 scrappy Exp $
.TH "DROP INDEX" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
drop index \(em removes an index from Postgres
.SH SYNOPSIS
.nf
\fBdrop index\fR index_name
.fi
.SH DESCRIPTION
This command drops an existing index from the Postgres system. To
execute this command you must be the owner of the index.
.SH EXAMPLE
.nf
--
--this command will remove the "emp_index" index
--
drop index emp_index
.fi
.SH "SEE ALSO"
create index(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/drop_operator.l,v 1.1 1996/11/14 10:17:04 scrappy Exp $
.TH "DROP OPERATOR" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
drop operator \(em remove an operator from the system
.SH SYNOPSIS
.nf
\fBdrop operator\fR opr_desc
.fi
.SH DESCRIPTION
This command drops an existing operator from the database. To execute
this command you must be the owner of the operator.
.PP
.IR Opr_desc
is the name of the operator to be removed followed by a parenthesized
list of the operand types for the operator. The left or right type
of a left or right unary operator, respectively, may be specified
as
.IR none .
.PP
It is the user's responsibility to remove any access methods, operator
classes, etc. that rely on the deleted operator.
.SH EXAMPLE
.nf
--
--Remove power operator a^n for int4
--
drop operator ^ (int4, int4)
.fi
.nf
--
--Remove left unary operator !a for booleans
--
drop operator ! (none, bool)
.fi
.nf
--
--Remove right unary factorial operator a! for int4
--
drop operator ! (int4, none)
.fi
.SH "SEE ALSO"
create operator(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/drop_rule.l,v 1.1 1996/11/14 10:17:07 scrappy Exp $
.TH "DROP RULE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
drop rule \- removes a current rule from Postgres
.SH SYNOPSIS
.nf
\fBdrop rule\fR rule_name
.fi
.SH DESCRIPTION
This command drops the rule named rule_name from the specified Postgres
rule system. Postgres will immediately cease enforcing it and will purge
its definition from the system catalogs.
.SH EXAMPLE
.nf
--
--This example drops the rewrite rule example_1
--
drop rule example_1
.fi
.SH "SEE ALSO"
create rule(l),
drop view(l).
.SH BUGS
Once a rule is dropped, access to historical information the rule has
written may disappear.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/drop_type.l,v 1.1 1996/11/14 10:17:09 scrappy Exp $
.TH "DROP TYPE" SQL 11/05/95 Postgres95 Postgres95
.SH NAME
drop type \(em remove a user-defined type from the system catalogs
.SH SYNOPSIS
.nf
\fBdrop type\fR typename
.fi
.SH DESCRIPTION
This command removes a user type from the system catalogs. Only the
owner of a type can remove it.
.PP
It is the user's responsibility to remove any operators, functions,
aggregates, access methods, subtypes, classes, etc. that use a
deleted type.
.SH EXAMPLE
.nf
--
--remove the box type
--
drop type box
.fi
.SH "SEE ALSO"
introduction(l),
create type(l),
drop operator(l).
.SH "BUGS"
If a built-in type is removed, the behavior of the backend is unpredictable.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/end.l,v 1.1 1996/11/14 10:17:10 scrappy Exp $
.TH END SQL 01/23/93 Postgres95 Postgres95
.SH NAME
end \(em commit the current transaction
.SH SYNOPSIS
.nf
\fBend [transaction]\fR
.fi
.SH DESCRIPTION
This commands commits the current transaction. All changes made by
the transaction become visible to others and are guaranteed to be
durable if a crash occurs.
.SH "SEE ALSO"
abort(l),
begin(l).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/fetch.l,v 1.1 1996/11/14 10:17:13 scrappy Exp $
.TH FETCH SQL 01/23/93 Postgres95 Postgres95
.SH NAME
fetch \(em fetch instance(s) from a cursor
.SH SYNOPSIS
.nf
\fBfetch\fR [ (\fBforward\fR | \fBbackward\fR) ] [ ( number | \fBall\fR) ] [\fBin\fR cursor_name]
.fi
.SH DESCRIPTION
.BR Fetch
allows a user to retrieve instances from a cursor named
.IR cursor_name.
The number of instances retrieved is specified by
.IR number .
If the number of instances remaining in the cursor is less than
.IR number ,
then only those available are fetched. Substituting the keyword
.IR all
in place of a number will cause all remaining instances in the cursor
to be retrieved. Instances may be fetched in both
.IR forward
and
.IR backward
directions. The default direction is
.IR forward .
.PP
Updating data in a cursor is not supported by Postgres, because mapping
cursor updates back to base classes is impossible in general as with
view updates. Consequently, users must issue explicit replace
commands to update data.
.PP
Cursors may only be used inside of transaction blocks marked by
.IR begin (l)
and
.IR end (l)
because the data that they store spans multiple user queries.
.SH EXAMPLE
.nf
--
--set up and use a cursor
--
begin
declare mycursor cursor for
select * from pg-user
end
.fi
.nf
--
--Fetch all the instances available in the cursor FOO
--
fetch all in FOO
.fi
.nf
--
--Fetch 5 instances backward in the cursor FOO
--
fetch backward 5 in FOO
.fi
.SH "SEE ALSO"
begin(l),
end(l),
close(l),
move(l),
select(l).
.SH BUGS
Currently, the smallest transaction in Postgres is a single SQL
command. It should be possible for a single fetch to be a
transaction.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/grant.l,v 1.1 1996/11/14 10:17:15 scrappy Exp $
.TH GRANT SQL 11/05/95 Postgres95 Postgres95
.SH NAME
grant \(em grant access control to a user or group
.SH SYNOPSIS
.nf
\fBgrant\fR <privilege[,privilege,...]>
\fBon\fR <rel1>[,...<reln>]
\fBto\fR [\fBpublic\fR | group <group> | <username>]
\fBprivilege\fR is {\fBALL\fR | \fBSELECT\fR | \fBINSERT\fR | \fBUPDATE\fR | \fBDELETE\fR | \fBRULE\fR}
.fi
.SH DESCRIPTION
.PP
.B Grant
allows you to give specified permissions to all users or
a certain user or group.
By default, a table grants read-only (\fBSELECT\fR) to all Postgres users.
You must specifically revoke this privilege if this is not desired.
.SH EXAMPLES
.nf
--
--Example of a grant
--
grant insert
on mytab
to public
.fi
.SH "SEE ALSO"
revoke(l)
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/initdb.1,v 1.1 1996/11/14 10:17:17 scrappy Exp $
.TH INITDB UNIX 11/05/95 Postgres95 Postgres95
.SH NAME
initdb \(em initalize the database templates and primary directories
.SH SYNOPSIS
.BR "initdb"
[\c
.BR "-d"
]
[\c
.BR "-n"
]
[\c
.BR "-r directory"
]
[\c
.BR "-t"
]
[\c
.BR "-u username"
]
[\c
.BR "-v"
]
.SH DESCRIPTION
.IR Initdb
sets up the initial template databases and is normally executed as
part of the installation process. The template database is created
under the directory specified by the the environment variable
.SM PGDATA,
or to a default specified at compile-time. The template database
is then
.BR vacuum ed.
.PP
.IR Initdb
is a shell script that invokes the backend server directly. Hence, it
must be executed by the Postgres super-user.
.PP
.IR Initdb
understands the following command-line options:
.TP
.BR "-d"
Print debugging output from the backend server. This option generates
a tremendous amount of information. This option also turns off the
final vacuuming step.
.TP
.BR "-n"
Run in \*(lqnoclean\*(rq mode. By default,
.IR initdb
cleans up (recursively unlinks) the data directory if any error
occurs, which also removes any core files left by the backend server.
This option inhibits any tidying-up.
.TP
.BR "-r directory"
Use the specified data directory.
.TP
.BR "-t"
Update template database only.
.TP
.BR "-u username"
Run as the specified username.
.TP
.BR "-v"
Produce verbose output, printing messages stating where the
directories are being created, etc.
.SH FILES
.TP
\&$PGDATA/base
The location of global (shared) classes.
.TP
\&$PGDATA/base/template1
The location of the template database.
.TP
\&$PGDATA/files/{global1,local1_template1}.bki
Command files used to generate the global and template databases,
generated and installed by the initial compilation process.
.SH "SEE ALSO"
createdb(1),
vacuum(l),
bki(files),
template(files).
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/insert.l,v 1.1 1996/11/14 10:17:19 scrappy Exp $
.TH INSERT SQL 11/05/95 Postgres95 Postgres95
.SH NAME
insert \(em insert tuples to a relation
.SH SYNOPSIS
.nf
\fBinsert\fR into classname
[(att.expr-1,{att_expr.i})]
{\fBvalues\fR (expression1 {,expression-i}) |
\fBselect\fR expression1,{expression-i}
[\fBfrom\fR from-list] [\fBwhere\fR qual]
.fi
.SH DESCRIPTION
.BR Insert
adds instances that satisfy the qualification,
.IR qual ,
to
.IR classname .
.IR Classname
must be the name of an existing class. The target list specifies the
values of the fields to be appended to
.IR classname .
That is, each
.IR att_expr
specifies a field (either an attribute name or an attribute name plus
an array specification) to which the corresponding
.IR expression
should be assigned. The fields in the target list may be listed in
any order. Fields of the result class which do not appear in the
target list default to NULL. If the expression for each field is not
of the correct data type, automatic type coercion will be attempted.
.PP
An array initialization may take exactly one of the following forms:
.nf
--
-- Specify a lower and upper index for each dimension
--
att_name[lIndex-1:uIndex-1]..[lIndex-i:uIndex-i] = array_str
--
--Specify only the upper index for each dimension
--(each lower index defaults to 1)
--
att_name[uIndex-1]..[uIndex-i] = array_str
--
--Use the upper index bounds as specified within array_str
--(each lower index defaults to 1)
--
att_name = array_str
.fi
where each
.IR lIndex
or
.IR uIndex
is an integer constant and
.IR array_str
is an array constant (see
.IR introduction (l)).
.PP
If the user does not specify any array bounds (as in the third form)
then Postgres will attempt to deduce the actual array bounds from the
contents of
.IR array_str .
If the user does specify explicit array bounds (as in the first and
second forms) then the array may be initialized partly or fully
using a C-like syntax for array initialization.
However, the uninitialized array elements will
contain garbage.
.PP
You must have write or append access to a class in order to append to
it, as well as read access on any class whose values are read in the
target list or qualification (see
.IR "change acl" (l)).
.SH EXAMPLES
.nf
--
--Make a new employee Jones work for Smith
--
insert into emp
select newemp.name, newemp.salary,
"Smith", 1990-newemp.age
from newemp
where name = "Jones"
.fi
.nf
--
--Insert into newemp class to newemp
--
insert into newemp
select * from newemp1
.fi
.nf
--
--Create an empty 3x3 gameboard for noughts-and-crosses
--(all of these queries create the same board attribute)
--
insert into tictactoe (game, board[1:3][1:3])
values(1,'{{"","",""},{},{"",""}}')
insert into tictactoe (game, board[3][3])
values (2,'{}')
insert into tictactoe (game, board)
values (3,'{{,,},{,,},{,,}}')
.fi
.SH "SEE ALSO"
create table(l),
create type(l),
update(l),
select(l)
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/ipcclean.1,v 1.1 1996/11/14 10:17:22 scrappy Exp $
.TH IPCCLEAN UNIX 11/05/95 Postgres95 Postgres95
.SH NAME
ipcclean \(em clean up shared memory and semaphores from aborted backends
.SH SYNOPSIS
.BR "ipcclean"
.SH DESCRIPTION
.IR Ipcclean
cleans up shared memory and semaphore space from aborted backends by
deleting all instances owned by user \*(lqpostgres\*(rq. Only the DBA
should execute this program as it can cause bizarre behavior (i.e.,
crashes) if run during multi-user execution. This program should be
executed if messages such as
.BR "semget: No space left on device"
are encountered when starting up the
.IR postmaster
or the backend server.
.SH BUGS
If this command is executed while a
.IR postmaster
is running, the shared memory and semaphores allocated by the
.IR postmaster
will be deleted. This will result in a general failure of the
backends servers started by that
.IR postmaster .
.PP
This script is a hack, but in the many years since it was written, no
one has come up with an equally effective and portable solution.
Suggestions are welcome.
.PP
The script makes assumption about the format of output of the
.BR ipcs
utility which may not be true across different operating systems.
Therefore, it may not work on your particular OS.
This diff is collapsed.
This diff is collapsed.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/listen.l,v 1.1 1996/11/14 10:17:28 scrappy Exp $
.TH "LISTEN" SQL 03/12/94 Postgres95 Postgres95
.SH NAME
listen \(em listen for notification on a relation
.SH SYNOPSIS
.nf
\fBlisten\fR class_name
.fi
.SH DESCRIPTION
.BR listen
is used to register the current backend as a listener on the relation
.IR class_name .
When the command
.BI notify " class_name"
is called either from within a rule or at the query level, the
frontend applications corresponding to the listening backends
are notified. When the backend process exits, this registration
is cleared.
.PP
This event notification is performed through the Libpq protocol
and frontend application interface. The application program
must explicitly poll a Libpq global variable,
.IR PQAsyncNotifyWaiting ,
and call the routine
.IR PQnotifies
in order to find out the name of the class to which a given
notification corresponds. If this code is not included in
the application, the event notification will be queued and
never be processed.
.SH "SEE ALSO"
create rule(l),
notify(l),
select(l),
libpq.
.SH BUGS
There is no way to un-\c
.BR listen
except to drop the connection (i.e., restart the backend server).
.PP
The
.IR monitor (1)
command does not poll for asynchronous events.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/load.l,v 1.1 1996/11/14 10:17:30 scrappy Exp $
.TH LOAD SQL 01/23/93 Postgres95 Postgres95
.SH NAME
load \(em dynamically load an object file
.SH SYNOPSIS
.nf
\fBload\fR "filename"
.fi
.SH DESCRIPTION
.BR Load
loads an object (or ".o") file into Postgres's address space. Once a
file is loaded, all functions in that file can be accessed. This
function is used in support of ADT's.
.PP
If a file is not loaded using the
.BR load
command, the file will be loaded automatically the first time the
function is called by Postgres.
.BR Load
can also be used to reload an object file if it has been edited and
recompiled. Only objects created from C language files are supported
at this time.
.SH EXAMPLE
.nf
--
--Load the file /usr/postgres/demo/circle.o
--
load "/usr/postgres/demo/circle.o"
.fi
.SH CAVEATS
Functions in loaded object files should not call functions in other
object files loaded through the
.BR load
command, meaning, for example, that all functions in file A should
call each other, functions in the standard or math libraries, or in
Postgres itself. They should not call functions defined in a different
loaded file B. This is because if B is reloaded, the Postgres loader is
not \*(lqsmart\*(rq enough to relocate the calls from the functions in A into
the new address space of B. If B is not reloaded, however, there will
not be a problem.
.PP
On DECstations, you must use
.IR /bin/cc
with the \*(lq-G 0\*(rq option when compiling object files to be
loaded.
.PP
Note that if you are porting Postgres to a new platform, the
.BR load
command will have to work in order to support ADTs.
.\" This is -*-nroff-*-
.\" XXX standard disclaimer belongs here....
.\" $Header: /cvsroot/pgsql/src/man/Attic/monitor.1,v 1.1 1996/11/14 10:17:32 scrappy Exp $
.TH MONITOR UNIX 11/05/95 Postgres95 Postgres95
.SH NAME
monitor \(em run the interactive terminal monitor
.SH SYNOPSIS
.BR monitor
[\c
.BR "-N"
]
[\c
.BR "-Q"
]
[\c
.BR "-T"
]
[\c
.BR "-a"
system]
[\c
.BR "-c"
query]
[\c
.BR "-d"
path]
.br
.in +5n
[\c
.BR "-h"
hostname]
[\c
.BR "-p"
port]
[\c
.BR "-q"
]
[\c
.BR "-t"
tty_device]
[dbname]
.in -5n
.SH DESCRIPTION
The interactive terminal monitor is a simple frontend to Postgres retained
for backwards compatiblity. Users are encouraged to the use the
.IR "psql"
interface instead.
.PP
.IR "monitor"
enables you to formulate, edit and review queries before issuing them
to Postgres. If changes must be made, a Unix editor may be called
to edit the
.BR "query buffer"
managed by the terminal monitor. The editor used is determined by the
value of the
.SM EDITOR
environment variable. If
.SM EDITOR
is not set, then
.BR "vi"
is used by default.
.PP
.IR "Monitor"
is a frontend application, like any other. Hence, a
.IR "postmaster"
process must be running on the database server host before
.IR "monitor"
is executed. In addition, the correct
.IR "postmaster"
port number must be specified
as described below.
.PP
The optional argument
.IR dbname
specifies the name of the database to be accessed. This database must
already have been created using
.IR createdb .
.IR Dbname
defaults to the value of the
.SM USER
environment variable.
.PP
.IR "Monitor"
understands the following command-line options:
.TP 5n
.BR "-N"
Specifies that query results will be dumped to the screen without any
attempt at formatting. This is useful in with the
.BR -c
option in shell scripts.
.TP
.BR "-Q"
Produces extremely unverbose output.
This is useful
with the
.BR -c
option in shell scripts.
.TP
.BR "-T"
Specifies that attribute names will not be printed.
This is useful
with the
.BR -c
option in shell scripts.
.TP
.BR "-a" " system"
Specifies an authentication system
.IR "system"
(see
.IR introduction (1))
to use in connecting to the
.IR postmaster
process. The default is site-specific.
.TP
.BR "-c" " query"
Specifies that
.IR "monitor"
is to execute one query string,
.IR "query" ,
and then exit. This is useful for shell scripts, typically in
conjunction with the
.BR -N
and
.BR -T
options. Examples of shell scripts in the Postgres distribution using
.IB "monitor" " -c"
include
.IR createdb ,
.IR destroydb ,
.IR createuser ,
and
.IR destroyuser ,
.TP
.BR "-d" " path"
.IR path
specifies the path name of the file or tty to which frontend (i.e.,
.IR monitor )
debugging messages are to be written; the default is not to generate
any debugging messages.
.TP
.BR "-h" " hostname"
Specifies the hostname of the machine on which the
.IR postmaster
is running. Defaults to the name of the local host, or the value of
the
.SM PGHOST
environment variable (if set).
.TP
.BR "-p" " port"
Specifies the Internet TCP port on which the
.IR postmaster
is listening for connections. Defaults to 5432, or the value of the
.SM PGPORT
environment variable (if set).
.TP
.BR "-q"
Specifies that the monitor should do its work quietly. By default, it
prints welcome and exit messages and the queries it sends to the
backend. If this option is used, none of this happens.
.TP
.BR "-t" " tty_device"
.IR "tty_device"
specifies the path name to the file or tty
to which backend (i.e.,
.IR postgres )
debugging messages are to be written; the default is
.IR "/dev/null" .
.TP
.BR "-s"
parses after each query (enables "single step" mode).
.TP
.BR "-S"
Turns off sending query when ";" is encountered.
.PP
You may set environment variables to avoid typing some of the above
options. See the
.SM "ENVIRONMENT VARIABLES"
section below.
.SH "MESSAGES AND PROMPTS"
The terminal monitor gives a variety of messages to keep the user
informed of the status of the monitor and the query buffer.
.PP
The terminal monitor displays two kinds of messages:
.IP go
The query buffer is empty and the terminal monitor is ready for input.
Anything typed will be added to the buffer.
.IP *
This prompt is typed at the beginning of each line when the terminal
monitor is waiting for input.
.SH "TERMINAL MONITOR COMMANDS"
.IP \ee
Enter the editor to edit the query buffer.
.IP \eg
Submit query buffer to Postgres for execution.
.IP \eh
Get on-line help.
.IP "\ei \fIfilename\fR"
Include the file
.IR filename
into the query buffer.
.IP \ep
Print the current contents of the query buffer.
.IP \eq
Exit from the terminal monitor.
.IP \er
Reset (clear) the query buffer.
.IP \es
Escape to a Unix subshell. To return to the terminal monitor, type
\*(lqexit\*(rq at the shell prompt.
.IP \et
Print the current time.
.IP "\ew \fIfilename\fR"
Store (write) the query buffer to an external file
.IR filename .
.IP \e\e
Produce a single backslash at the current location in query buffer.
.IP \e;
Produce a single semi-colon at the current location in query buffer.
.SH "ENVIRONMENT VARIABLES"
You may set any of the following environment variables to avoid
specifying command-line options:
.nf
hostname: PGHOST
port: PGPORT
tty: PGTTY
options: PGOPTION
realm: PGREALM
.fi
.PP
If
.SM PGOPTION
is specified, then the options it contains are parsed
.BR before
any command-line options.
.PP
.SM PGREALM
only applies if
.IR Kerberos
authentication is in use. If this environment variable is set, Postgres
will attempt authentication with servers for this realm and use
separate ticket files to avoid conflicts with local ticket files. See
.IR introduction (1)
for additional information on
.IR Kerberos .
.PP
See
.IR introduction (libpq)
for additional details.
.SH "RETURN VALUE"
When executed with the
.BR "-c"
option,
.IR monitor
returns 0 to the shell on successful query completion, 1 otherwise.
.SH "SEE ALSO"
introduction(libpq),
createdb(1),
createuser(1),
postgres(1),
postmaster(1).
.SH BUGS
Does not poll for asynchronous notification events generated by
.IR listen (l)
and
.IR notify (l).
.PP
Escapes (backslash characters) cannot be commented out.
.SH "SEE ALSO"
psql(1)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
.\" This is -*-nroff-*-
.\" $Header: /cvsroot/pgsql/src/man/Attic/pg_hba.conf.5,v 1.1 1996/11/14 10:17:44 scrappy Exp $
.TH pg_hba.conf 5 11/04/96 Postgres Postgres
.SH NAME
$PGDATA/pg_hba.conf
.SH DESCRIPTION
"Host-based access control" is the name for the basic controls Postgres
exercises on what clients are allowed to access a database system.
It is called that because one of the factors that can control access is
from what host the client is connecting.
.PP
Each database system contains a file named "pg_hba.conf", in its PGDATA
directory, that controls who can connect to that database system.
.PP
The exact format of the pg_hba.conf file is described in the comments at
the top of the sample file pg_hba.conf.sample, which resides in the
Postgres "library" directory.
.SH "SEE ALSO"
introduction(1).
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment