+ Lounge section of the PostgreSQL web site for details.
+ As such, it depends on the user community for ongoing support.
+ features to the code, contribute it.
- <chapter id="intro">
-
Introduction
+ <preface id="preface">
+
Preface
- This document is the user manual for the
- database management system, originally developed at the University
- of California at Berkeley.
+
- led by Professor Michael Stonebraker, was sponsored by the
- Defense Advanced Research Projects Agency
- Army Research Office (
ARO), the National Science
- Foundation (
NSF), and ESL, Inc.
-
+
PostgreSQL is an object-relational
+ database management system (
ORDBMS) based on
+ developed at the University of California at Berkeley Computer
+ Science Department. The
POSTGRES
+ project, led by Professor Michael Stonebraker, was sponsored by
+ the Defense Advanced Research Projects Agency
+ (
DARPA), the Army Research Office
+ (
ARO), the National Science Foundation
+
-
+
PostgreSQL is an open-source descendant of
+ this original Berkeley code. It provides SQL92/SQL99 language support
+ and other modern features.
+
+
POSTGRES pioneered many of the
+ object-relational concepts now becoming available in some commercial
+ databases.
Traditional relational database management systems
- (DBMSs) support a data model consisting of a collection
+ (
RDBMS) support a data model consisting of a collection
of named relations, containing attributes of a specific
type. In current commercial systems, possible types
include floating point numbers, integers, character
that this model is inadequate for future data
processing applications.
The relational model successfully replaced previous
- models in part because of its "Spartan simplicity".
+ models in part because of its Spartan simplicity
.
However, as mentioned, this simplicity often makes the
implementation of certain applications very difficult.
Postgres offers substantial additional
- power by incorporating the following four additional
- basic concepts in such a way that users can easily
+ power by incorporating the following additional
+ concepts in such a way that users can easily
extend the system:
- tables
inheritance
- types
+ data types
functions
&history;
- &about;
&info;
¬ation;
&problems;
&y2k;
- &legal;
- chapter>
+ preface>
-
-
Copyrights and Trademarks
+
+ 1996-2001
+ PostgreSQL Global Development Group
+
+
+
+
Legal Notice
PostgreSQL is Copyright © 1996-2001
- by PostgreSQL Global Development Group
- and is distributed under the terms of the Berkeley license.
+ by the PostgreSQL Global Development Group and is distributed under
+ the terms of the license of the University of California below.
Postgres95 is Copyright © 1994-5
by the Regents of the University of California.
- Permission to use, copy, modify, and distribute this software and its documentation
- for any purpose, without fee, and without a written agreement is hereby granted,
- provided that the above copyright notice and this paragraph and the following two
- paragraphs appear in all copies.
+
- In no event shall the University of California be liable to
- any party for direct, indirect, special, incidental, or consequential
- damages, including lost profits, arising out of the use of this
- software and its documentation, even if the University of California
- has been advised of the possibility of such damage.
+ Permission to use, copy, modify, and distribute this software and
+ its documentation for any purpose, without fee, and without a
+ written agreement is hereby granted, provided that the above
+ copyright notice and this paragraph and the following two paragraphs
+ appear in all copies.
+
- The University of California specifically disclaims any
- warranties, including, but not limited to, the implied warranties
- of merchantability and fitness for a particular purpose.
- The software provided hereunder is on an "as-is" basis, and
- the University of California has no obligations to provide
- maintainance, support, updates, enhancements, or modifications.
+ IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY
+ PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
+ DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS
+ SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA
+ HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+ THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+ PROVIDED HEREUNDER IS ON AN "AS-IS" BASIS, AND THE UNIVERSITY OF
+ CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTAINANCE, SUPPORT,
+ UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+
-
-
Terminology
-
- The
- is the user named postgres
- binaries and database files. As the database superuser, all
- protection mechanisms may be bypassed and any data accessed
- arbitrarily.
- In addition, the
Postgres superuser is
- allowed to execute
- some support programs which are generally not available to all users.
- Note that the
Postgres superuser is
- not
- the same as the Unix superuser (which will be referred to as
- root).
- The superuser should have a non-zero user identifier
- (UID) for security reasons.
-
+
+
Terminology and Notation
- The
- database administrator
- or
DBA, is the person who is responsible for installing
-
Postgres with mechanisms to
- enforce a security policy for a site. The DBA can add new users by
- the method described below
- and maintain a set of template databases for use by
+ The terms Postgres
and PostgreSQL
will be
+ used interchangeably to refer to the software that accompanies this
+ documentation.
- is the process that acts as a clearing-house for requests
- to the
Postgres system.
- Frontend applications connect to the
postmaster,
- which keeps tracks of any system errors and communication between the
- backend processes. The
postmaster
- can take several command-line arguments to tune its behavior.
- However, supplying arguments is necessary only if you intend to run multiple
- sites or a non-default site.
+ An administrator is generally a person who is
+ in charge of installing and running the server. A user
+ could be anyone who is using, or wants to use, any part of the
+
PostgreSQL system. These terms should not
+ be interpreted too narrowly; this documentation set does not have fixed
+ presumptions about system administration procedures.
- (the actual executable program
postgres) may be executed
- directly from the user shell by the
- (with the database name as an argument). However,
- doing this bypasses the shared buffer pool and lock table associated
- with a postmaster/site, therefore this is not recommended in a multiuser
- site.
-
-
-
-
-
Notation
-
- "..." or /usr/local/pgsql/
- at the front of a file name is used to represent the
- path to the
Postgres superuser's home directory.
+ /usr/local/pgsql/ is generally used as the root
+ directory of the installation and /usr/local/pgsql/data
+ as the directory with the database files. These directories may vary
+ on your site, details can be derived in the Administrator's Guide.
indicates that you must choose one.
- In examples, parentheses ("(" and ")") are
- used to group boolean
- expressions. "|" is the boolean operator OR.
-
-
Examples will show commands executed from various accounts and programs.
- Commands executed from the root account will be preceeded with
- ">".
- Commands executed from the
Postgres
- superuser account will be preceeded with "%", while commands
- executed from an unprivileged user's account will be preceeded with
- "$".
-
SQL commands will be preceeded with "
=>"
+ Commands executed from a Unix shell may be preceeded with a dollar sign
+ ($
). Commands executed from particular user
+ accounts such as root or postgres are specially flagged and explained.
+
SQL commands may be preceeded with
+ =>
or will have no leading prompt, depending on the context.
- At the time of writing (
Postgres 7.0)
- the notation for
+ The notation for
flagging commands is not universally consistant throughout the
documentation set.
Please report problems to the documentation mailing list
The PostgreSQL Global Development Group
+ &legal;
&tutorial;
-problem-reporting">
-
Problem Reporting Guidelines
+bug-reporting">
+
Bug Reporting Guidelines
- When you
encounter a problem in
PostgreSQL we want to
- hear about it. Your bug reports are an important part in making
+ When you
find a bug in
PostgreSQL we want to
+ hear about it. Your bug reports play an important part in making
PostgreSQL more reliable because even the utmost
care cannot guarantee that every part of PostgreSQL will work on every
platform under every circumstance.
could also happen that we tell you to update to a newer version to see if the
bug happens there. Or we might decide that the bug
cannot be fixed before some major rewrite we might be planning is done. Or
- perhaps it's simply too hard and there are more important things on the agenda.
+ perhaps it is simply too hard and there are more important things on the agenda.
If you need help immediately, consider obtaining a commercial support contract.
Identifying Bugs
- Before you ask "Is this a bug?", please read and re-read the
+ Before you report a bug, please read and re-read the
documentation to verify that you can really do whatever it is you are
trying. If it is not clear from the documentation whether you can do
- something or not, please report that too; it's a bug in the documentation.
+ something or not, please report that too; it is a bug in the documentation.
If it turns out that the program does something different from what the
- documentation says, that's a bug. That might include, but is not limited to,
+ documentation says, that is a bug. That might include, but is not limited to,
the following circumstances:
A program terminates with a fatal signal or an operating system
- error message that would point to a problem in the program (a
- counterexample might be a "disk full" message,
- since
that must be fixed outside of Postgres).
+ error message that would point to a problem in the program. (A
+ counterexample might be a disk full
message,
+ since you have to fix that yourself.)
- A program refuses to accept valid input.
+ A program refuses to accept valid input (as defined in the documentation).
A program accepts invalid input without a notice or error message.
+ Keep in mind that your idea of invalid input might be our idea of
+ an extension or compatibility with traditional practice.
- Here "program" refers to any executable, not only the backend server.
+ Here program
refers to any executable, not only the backend server.
Before you continue, check on the TODO list and in the FAQ to see if your bug is
- already known. If you can't decode the information on the TODO list, report your
+ already known. If you cannot decode the information on the TODO list, report your
problem. The least we can do is make the TODO list clearer.
Reporting the bare facts
is relatively straightforward (you can probably copy and paste them from the
screen) but all too often important details are left out because someone
- thought it doesn't matter or the report would be understood
+ thought it does not matter or the report would be understood
anyway.
that shows the problem. (Be sure to not have anything in your
~/.psqlrc start-up file.) You are encouraged to
minimize the size of your example, but this is not absolutely necessary.
- If the bug is reproduceable, we'll find it either way.
+ If the bug is reproduceable, we will find it either way.
If your application uses some other client interface, such as PHP, then
- please try to isolate the offending queries. We probably won't set up a
+ please try to isolate the offending queries. We will probably not set up a
web server to reproduce your problem. In any case remember to provide
the exact input files, do not guess that the problem happens for
"large files" or "mid-size databases", etc. since this
- The output you got. Please do not say that it "didn't work" or
- "failed". If there is an error message,
- show it, even if you don't understand it. If the program terminates with
+ The output you got. Please do not say that it didn't work
or
+ crashed
. If there is an error message,
+ show it, even if you do not understand it. If the program terminates with
an operating system error, say which. If nothing at all happens, say so.
Even if the result of your test case is a program crash or otherwise obvious
it might not happen on our platform. The easiest thing is to copy the output
The output you expected is very important to state. If you just write
"This command gives me that output." or "This is not
what I expected.", we might run it ourselves, scan the output, and
- think it looks okay and is exactly what we expected. We shouldn't have to
+ think it looks okay and is exactly what we expected. We should not have to
spend the time to decode the exact semantics behind your commands.
Especially refrain from merely saying that "This is not what SQL says/Oracle
does." Digging out the correct behavior from
SQL
The
PostgreSQL version. You can run the command
SELECT version(); to
- find out what version you are currently running.
- If this function does not exist, say so, then we know that
- your version is old enough. If you can't start up the server or a
- client, look into the README file in the source directory or at the
- name of your distribution file or package name. If your version is older
- than 7.0 we will almost certainly tell you to upgrade. There are tons
- of bug fixes in each new version, that's why we write them.
-
+ find out the version of the server you are connected to. Most executable
+ programs also support a option; at least
+ postmaster --version and psql --version
+ should work.
+ If the function or the options do not exist then your version is probably
+ old enough. You can also look into the README file
+ in the source directory or at the
+ name of your distribution file or package name.
If you run a pre-packaged version, such as RPMs, say so, including any
subversion the package may have. If you are talking about a CVS
snapshot, mention that, including its date and time.
+
+ If your version is older than &version; we will almost certainly tell
+ you to upgrade. There are tons
+ of bug fixes in each new release, that is why we make new releases.
+
+
Do not be afraid if your bug report becomes rather lengthy. That is a fact of life.
- It's better to report everything the first time than us having to squeeze the
+ It is better to report everything the first time than us having to squeeze the
facts out of you. On the other hand, if your input files are huge, it is
fair to ask first whether somebody is interested in looking into it.
Do not spend all your time to figure out which changes in the input make
the problem go away. This will probably not help solving it. If it turns
- out that the bug can't be fixed right away, you will still have time to
+ out that the bug cannot be fixed right away, you will still have time to
find and share your work around. Also, once again, do not waste your time
- guessing why the bug exists. We'll find that out soon enough.
+ guessing why the bug exists. We will find that out soon enough.
The software package as such is called "PostgreSQL",
sometimes "Postgres" for short. (Sometimes
the abbreviation "Pgsql" is used but don't do that.) When you
- are specifically talking about the backend server, mention that, don't
+ are specifically talking about the backend server, mention that, do not
just say "Postgres crashes". The interactive frontend is called
"psql" and is for all intends and purposes completely separate
from the backend.
-
Programmer's Guide
+
PostgreSQL &version; Programmer's Guide
The PostgreSQL Global Development Group
+ &legal;
+
-
- Thomas
- Lockhart
- Caltech/JPL
-
-
-
-
-
PostgreSQL is Copyright © 1996-2001
- by PostgreSQL Global Development Group
-
-
+
+ &intro;
+]]>
-
+
Organization
-
Summary
+ The first part of this manual is the description of the client-side
+ programming interfaces and support libraries for various languages.
+ The second part explains the
PostgreSQL
+ approach to extensibility and describe how users can extend
+
PostgreSQL by adding user-defined types,
+ operators, aggregates, and both query language and programming
+ language functions. After a discussion of the
+
PostgreSQL rule system, we discuss the
+ trigger and SPI interfaces.
+
- developed originally in the UC Berkeley Computer Science Department,
- pioneered many of the object-relational concepts
- now becoming available in some commercial databases.
- It provides SQL92/SQL99 language support,
- transaction integrity, and type extensibility.
- open-source descendant of this original Berkeley code.
+ Proficiency with Unix and C programming is assumed.
-
- &intro-pg;
-]]>
-
Client Interfaces
&libpq;
-
Reference Manual
+
PostgreSQL &version; Reference Manual
The PostgreSQL Global Development Group
-
-
-
PostgreSQL is © 1998-2000
- by PostgreSQL Global Development Group
-
-
+ &legal;
-
Tutorial
+
PostgreSQL &version; Tutorial
The PostgreSQL Global Development Group
-
-
- Thomas
- Lockhart
- Caltech/JPL
-
-
-
-
-
PostgreSQL is Copyright © 1996-2001
- by PostgreSQL Global Development Group
-
-
-
+ &legal;
-
Summary
-
- developed originally in the UC Berkeley Computer Science Department,
- pioneered many of the object-relational concepts
- now becoming available in some commercial databases.
- It provides SQL92/SQL99 language support,
- transaction integrity, and type extensibility.
-
PostgreSQL is an open-source descendant
- of this original Berkeley code.
-
-
-
-
User's Guide
-
- The PostgreSQL Development Team
-
-
- Thomas
- Lockhart
- Caltech/JPL
-
-
-
-
-
PostgreSQL is Copyright © 1996-2001
- by PostgreSQL Global Development Group
-
-
+
PostgreSQL &version; User's Guide
+
+ The PostgreSQL Global Development Group
+ &legal;
-
Summary
-
- developed originally in the UC Berkeley Computer Science Department,
- pioneered many of the object-relational concepts
- now becoming available in some commercial databases.
- It provides SQL92/SQL99 language support,
- transaction integrity, and type extensibility.
-
PostgreSQL is an open-source descendant
- of this original Berkeley code.
-
-
-
&intro;
+
&syntax;
&queries;
&datatype;
- The
PostgreSQL Global Development
Team provides
- the
Postgres software code tree as a public service,
+ The
PostgreSQL Global Development
Group provides
+ the
PostgreSQL software code tree as a public service,
without warranty and without liability for it's behavior or performance.
However, at the time of writing:
To the best of the author's knowledge, the
assumptions Postgres makes about dates specified with a two-digit year
- are documented in the current
+ are documented in the current User's Guide
in the chapter on data types.
For two-digit years, the significant transition year is 1970, not 2000;
e.g. "70-01-01" is interpreted as 1970-01-01,