aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--COPYRIGHT22
-rw-r--r--HISTORY283
-rw-r--r--INSTALL256
-rw-r--r--MAKE_CTAGS10
-rw-r--r--MIGRATION_to_1.02.173
-rw-r--r--README36
-rw-r--r--contrib/array/array_iterator.c251
-rw-r--r--contrib/array/array_iterator.doc26
-rw-r--r--contrib/array/array_iterator.sql137
-rw-r--r--contrib/datetime/datetime_functions.c147
-rw-r--r--contrib/datetime/datetime_functions.doc25
-rw-r--r--contrib/datetime/datetime_functions.sql69
-rw-r--r--contrib/pginterface/Makefile19
-rw-r--r--contrib/pginterface/README42
-rw-r--r--contrib/pginterface/halt.c58
-rw-r--r--contrib/pginterface/halt.h7
-rw-r--r--contrib/pginterface/pginsert.c98
-rw-r--r--contrib/pginterface/pginterface.c177
-rw-r--r--contrib/pginterface/pginterface.h13
-rw-r--r--contrib/soundex/soundex.c83
-rw-r--r--contrib/soundex/soundex.sql57
-rw-r--r--contrib/string/string_io.c361
-rw-r--r--contrib/string/string_io.sql111
-rw-r--r--contrib/zap_ltv/README180
-rw-r--r--contrib/zap_ltv/zap_ltv.pl93
-rw-r--r--doc/1.0_to_1.01.sql44
-rw-r--r--doc/FAQ827
-rw-r--r--doc/MIGRATION_from_1.0_to_1.0150
-rw-r--r--doc/Makefile32
-rw-r--r--doc/README.OPENLINK28
-rw-r--r--doc/README.flex147
-rw-r--r--doc/README.support35
-rw-r--r--doc/RELEASE.patchlevel24
-rw-r--r--doc/TODO121
-rw-r--r--doc/bug.template41
-rw-r--r--doc/libpgtcl.doc181
-rw-r--r--doc/man/README3
-rw-r--r--doc/man/abort.l23
-rw-r--r--doc/man/alter_table.l61
-rw-r--r--doc/man/begin.l20
-rw-r--r--doc/man/bki.5224
-rw-r--r--doc/man/built-in.3700
-rw-r--r--doc/man/catalogs.3446
-rw-r--r--doc/man/cleardbdir.123
-rw-r--r--doc/man/close.l28
-rw-r--r--doc/man/cluster.l33
-rw-r--r--doc/man/commit.l23
-rw-r--r--doc/man/copy.l162
-rw-r--r--doc/man/create_aggregate.l94
-rw-r--r--doc/man/create_function.l417
-rw-r--r--doc/man/create_index.l314
-rw-r--r--doc/man/create_operator.l219
-rw-r--r--doc/man/create_rule.l221
-rw-r--r--doc/man/create_table.l145
-rw-r--r--doc/man/create_type.l161
-rw-r--r--doc/man/create_version.l69
-rw-r--r--doc/man/create_view.l45
-rw-r--r--doc/man/createdb.1127
-rw-r--r--doc/man/createdb.l25
-rw-r--r--doc/man/createuser.1122
-rw-r--r--doc/man/delete.l41
-rw-r--r--doc/man/destroydb.1134
-rw-r--r--doc/man/destroydb.l26
-rw-r--r--doc/man/destroyuser.1119
-rw-r--r--doc/man/drop.l41
-rw-r--r--doc/man/drop_aggregate.l24
-rw-r--r--doc/man/drop_function.l28
-rw-r--r--doc/man/drop_index.l22
-rw-r--r--doc/man/drop_operator.l44
-rw-r--r--doc/man/drop_rule.l27
-rw-r--r--doc/man/drop_type.l30
-rw-r--r--doc/man/end.l17
-rw-r--r--doc/man/fetch.l70
-rw-r--r--doc/man/files.537
-rw-r--r--doc/man/grant.l33
-rw-r--r--doc/man/initdb.165
-rw-r--r--doc/man/insert.l113
-rw-r--r--doc/man/ipcclean.136
-rw-r--r--doc/man/large_objects.3499
-rw-r--r--doc/man/libpq.3962
-rw-r--r--doc/man/listen.l44
-rw-r--r--doc/man/load.l51
-rw-r--r--doc/man/monitor.1269
-rw-r--r--doc/man/notify.l48
-rw-r--r--doc/man/page.5130
-rw-r--r--doc/man/pg_dump.173
-rw-r--r--doc/man/pg_hba.543
-rw-r--r--doc/man/postgres.1163
-rw-r--r--doc/man/postmaster.1323
-rw-r--r--doc/man/psql.1359
-rw-r--r--doc/man/purge.l61
-rw-r--r--doc/man/remove_view.l23
-rw-r--r--doc/man/rename.l63
-rw-r--r--doc/man/revoke.l29
-rw-r--r--doc/man/rollback.l24
-rw-r--r--doc/man/select.l133
-rw-r--r--doc/man/sql.l349
-rw-r--r--doc/man/template.565
-rw-r--r--doc/man/unix.1279
-rw-r--r--doc/man/update.l41
-rw-r--r--doc/man/vacuum.l34
-rw-r--r--doc/userguide.ps7346
102 files changed, 20187 insertions, 0 deletions
diff --git a/COPYRIGHT b/COPYRIGHT
new file mode 100644
index 00000000000..d35f1266038
--- /dev/null
+++ b/COPYRIGHT
@@ -0,0 +1,22 @@
+
+POSTGRES95 Data Base Management System
+
+Copyright (c) 1994-6 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.
+
+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 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
diff --git a/HISTORY b/HISTORY
new file mode 100644
index 00000000000..b4c295641fc
--- /dev/null
+++ b/HISTORY
@@ -0,0 +1,283 @@
+Postgres95 1.02 Thu Aug 1 18:00:00 EDT 1996
+-------------------------------------------------------------
+
+Source code maintainenance and development
+ * worldwide team of volunteers
+ * the source tree now in CVS at ftp.ki.net
+ * developers mailing list - pg95-dev@ki.net
+
+Enhancements
+ * psql (and underlying libpq library) now has many more options for
+ formatting output, including HTML
+ * pg_dump now output the schema and/or the data, with many fixes to
+ enhance completeness.
+ * psql used in place of monitor in administration shell scripts.
+ monitor to be depreciated in next release.
+ * date/time functions enhanced
+ * NULL insert/update/comparison fixed/enhanced
+ * TCL/TK lib and shell fixed to work with both tck7.4/tk4.0 and tcl7.5/tk4.1
+
+Bug Fixes (almost too numerous to mention)
+ * indexes
+ * storage management
+ * check for NULL pointer before dereferencing
+ * Makefile fixes
+
+New Ports
+ * added SolarisX86 port
+ * added BSDI 2.1 port
+ * added DGUX port
+
+Contributors (appologies to any missed)
+ * Kurt J. Lidl <lidl@va.pubnix.com>
+ (missed in first run, but no less important)
+ * Erich Stamberger <eberger@gewi.kfunigraz.ac.at>
+ * Jason Wright <jason@shiloh.vnet.net>
+ * Cees de Groot <C.deGroot@inter.NL.net>
+ * ernst.molitor@uni-bonn.de
+ * michael.siebenborn@ae3.Hypo.DE (Michael Siebenborn (6929))
+ * Brian E. Gallew <geek+@cmu.edu>
+ * Vadim B. Mikheev <vadim@sable.krasnoyarsk.su>
+ * Adam Sussman <myddryn@vidya.com>
+ * Chris Dunlop <chris@onthe.net.au>
+ * Marc G. Fournier <scrappy@ki.net>
+ * Dan McGuirk <mcguirk@indirect.com>
+ * Dr_George_D_Detlefsen <drgeorge@ilt.com>
+ * Erich Stamberger <eberger@gewi.kfunigraz.ac.at>
+ * Massimo Dal Zotto <dz@cs.unitn.it>
+ * Randy Kunkee <kunkee@Starbase.NeoSoft.COM>
+ * Rick Weldon <rick@wisetech.com>
+ * Thomas van Reimersdahl <reimersd@dali.techinfo.rwth-aachen.de>
+ * david bennett <dave@bensoft.com>
+ * ernst.molitor@uni-bonn.de
+ * Julian Assange <proff@suburbia.net>
+ * Bruce Momjian <maillist@candle.pha.pa.us>
+ * Paul "Shag" Walmsley <ccshag@cclabs.missouri.edu>
+ * "Alistair G. Crooks" <azcb0@sde.uts.amdahl.com>
+
+Postgres95 1.01 Fri Feb 23 18:20:36 PST 1996
+-------------------------------------------------------------
+Incompatibilities:
+ * 1.01 is backwards compatible with 1.0 database provided the user
+ follow the steps outlined in the MIGRATION_from_1.0_to_1.01 file.
+ If those steps are not taken, 1.01 is not compatible with 1.0 database.
+
+Enhancements:
+ * added PQdisplayTuples() to libpq and changed monitor and psql to use it
+ * added NeXT port (requires SysVIPC implementation)
+ * added CAST .. AS ... syntax
+ * added ASC and DESC keywords
+ * added 'internal' as a possible language for CREATE FUNCTION
+ internal functions are C functions which have been statically linked
+ into the postgres backend.
+ * a new type "name" has been added for system identifiers (table names,
+ attribute names, etc.) This replaces the old char16 type. The
+ of name is set by the NAMEDATALEN #define in src/Makefile.global
+ * a readable reference manual that describes the query language.
+ * added host-based access control. A configuration file ($PGDATA/pg_hba)
+ is used to hold the configuration data. If host-based access control
+ is not desired, comment out HBA=1 in src/Makefile.global.
+ * changed regex handling to be uniform use of Henry Spencer's regex code
+ regardless of platform. The regex code is included in the distribution
+ * added functions and operators for case-insensitive regular expressions.
+ The operators are ~* and !~*.
+ * pg_dump uses COPY instead of SELECT loop for better performance
+
+Bug fixes:
+ * fixed an optimizer bug that was causing core dumps when
+ functions calls were used in comparisons in the WHERE clause
+ * changed all uses of getuid to geteuid so that effective uids are used
+ * psql now returns non-zero status on errors when using -c
+ * applied public patches 1-14
+
+Postgres95 1.0 Tue Sep 5 11:24:11 PDT 1995
+-------------------------------------------------------------
+
+Copyright change:
+ * The copyright of Postgres 1.0 has been loosened to be freely modifiable
+ and modifiable for any purpose. Please read the COPYRIGHT file.
+ Thanks to Professor Michael Stonebraker for making this possible.
+
+Incompatibilities:
+ * date formats have to be MM-DD-YYYY (or DD-MM-YYYY if you're using
+ EUROPEAN STYLE). This follows SQL-92 specs.
+ * "delimiters" is now a keyword
+
+Enhancements:
+ * sql LIKE syntax has been added
+ * copy command now takes an optional USING DELIMITER specification.
+ delimiters can be any single-character string.
+ * IRIX 5.3 port has been added.
+ Thanks to Paul Walmsley (ccshag@everest.cclabs.missouri.edu) and others.
+ * updated pg_dump to work with new libpq
+ * \d has been added psql
+ Thanks to Keith Parks (emkxp01@mtcc.demon.co.uk)
+ * regexp performance for architectures that use POSIX regex has been
+ improved due to caching of precompiled patterns.
+ Thanks to Alistair Crooks (agc@uts.amdahl.com)
+ * a new version of libpq++
+ Thanks to William Wanders (wwanders@sci.kun.nl)
+
+Bug fixes:
+ * arbitrary userids can be specified in the createuser script
+ * \c to connect to other databases in psql now works.
+ * bad pg_proc entry for float4inc() is fixed
+ * users with usecreatedb field set can now create databases without
+ having to be usesuper
+ * remove access control entries when the entry no longer has any
+ permissions
+ * fixed non-portable datetimes implementation
+ * added kerberos flags to the src/backend/Makefile
+ * libpq now works with kerberos
+ * typographic errors in the user manual have been corrected.
+ * btrees with multiple index never worked, now we tell you they don't
+ work when you try to use them
+
+
+Postgres95 Beta 0.03 Fri Jul 21 14:49:31 PDT 1995
+------------------------------------------------------
+Incompatible changes:
+ * BETA-0.3 IS INCOMPATIBLE WITH DATABASES CREATED WITH PREVIOUS VERSIONS
+ (due to system catalog changes and indexing structure changes).
+ * double-quote (") is deprecated as a quoting character for string literals;
+ you need to convert them to single quotes (').
+ * name of aggregates (eg. int4sum) are renamed in accordance with the
+ SQL standard (eg. sum).
+ * CHANGE ACL syntax is replaced by GRANT/REVOKE syntax.
+ * float literals (eg. 3.14) are now of type float4 (instead of float8 in
+ previous releases); you might have to do typecasting if you depend on it
+ being of type float8. If you neglect to do the typecasting and you assign
+ a float literal to a field of type float8, you may get incorrect values
+ stored!
+ * LIBPQ has been totally revamped so that frontend applications
+ can connect to multiple backends
+ * the usesysid field in pg_user has been changed from int2 to int4 to
+ allow wider range of Unix user ids.
+ * the netbsd/freebsd/bsd o/s ports have been consolidated into a
+ single BSD44_derived port. (thanks to Alistair Crooks)
+
+SQL standard-compliance (the following details changes that makes postgres95
+more compliant to the SQL-92 standard):
+ * the following SQL types are now built-in: smallint, int(eger), float, real,
+ char(N), varchar(N), date and time.
+
+ The following are aliases to existing postgres types:
+ smallint -> int2
+ integer, int -> int4
+ float, real -> float4
+ char(N) and varchar(N) are implemented as truncated text types. In
+ addition, char(N) does blank-padding.
+ * single-quote (') is used for quoting string literals; '' (in addition to
+ \') is supported as means of inserting a single quote in a string
+ * SQL standard aggregate names (MAX, MIN, AVG, SUM, COUNT) are used
+ (Also, aggregates can now be overloaded, i.e. you can define your
+ own MAX aggregate to take in a user-defined type.)
+ * CHANGE ACL removed. GRANT/REVOKE syntax added.
+ - Privileges can be given to a group using the "GROUP" keyword.
+ For example:
+ GRANT SELECT ON foobar TO GROUP my_group;
+ The keyword 'PUBLIC' is also supported to mean all users.
+
+ Privileges can only be granted or revoked to one user or group
+ at a time.
+
+ "WITH GRANT OPTION" is not supported. Only class owners can change
+ access control
+ - The default access control is to to grant users readonly access.
+ You must explicitly grant insert/update access to users. To change
+ this, modify the line in
+ src/backend/utils/acl.h
+ that defines ACL_WORLD_DEFAULT
+
+Bug fixes:
+ * the bug where aggregates of empty tables were not run has been fixed. Now,
+ aggregates run on empty tables will return the initial conditions of the
+ aggregates. Thus, COUNT of an empty table will now properly return 0.
+ MAX/MIN of an empty table will return a tuple of value NULL.
+ * allow the use of \; inside the monitor
+ * the LISTEN/NOTIFY asynchronous notification mechanism now work
+ * NOTIFY in rule action bodies now work
+ * hash indices work, and access methods in general should perform better.
+ creation of large btree indices should be much faster. (thanks to Paul
+ Aoki)
+
+Other changes and enhancements:
+ * addition of an EXPLAIN statement used for explaining the query execution
+ plan (eg. "EXPLAIN SELECT * FROM EMP" prints out the execution plan for
+ the query).
+ * WARN and NOTICE messages no longer have timestamps on them. To turn on
+ timestamps of error messages, uncomment the line in
+ src/backend/utils/elog.h:
+ /* define ELOG_TIMESTAMPS */
+ * On an access control violation, the message
+ "Either no such class or insufficient privilege"
+ will be given. This is the same message that is returned when
+ a class is not found. This dissuades non-privileged users from
+ guessing the existence of privileged classes.
+ * some additional system catalog changes have been made that are not
+ visible to the user.
+
+libpgtcl changes:
+ * The -oid option has been added to the "pg_result" tcl command.
+ pg_result -oid returns oid of the last tuple inserted. If the
+ last command was not an INSERT, then pg_result -oid returns "".
+ * the large object interface is available as pg_lo* tcl commands:
+ pg_lo_open, pg_lo_close, pg_lo_creat, etc.
+
+Portability enhancements and New Ports:
+ * flex/lex problems have been cleared up. Now, you should be able to use
+ flex instead of lex on any platforms. We no longer make assumptions of
+ what lexer you use based on the platform you use.
+ * The Linux-ELF port is now supported. Various configuration have been
+ tested: The following configuration is known to work:
+ kernel 1.2.10, gcc 2.6.3, libc 4.7.2, flex 2.5.2, bison 1.24
+ with everything in ELF format,
+
+New utilities:
+ * ipcclean added to the distribution
+ ipcclean usually does not need to be run, but if your backend crashes
+ and leaves shared memory segments hanging around, ipcclean will
+ clean them up for you.
+
+New documentation:
+ * the user manual has been revised and libpq documentation added.
+
+Postgres95 Beta 0.02 (Thu May 25 16:54:46 PDT 1995)
+------------------------------------------------------
+Incompatible changes:
+ * The SQL statement for creating a database is 'CREATE DATABASE' instead
+ of 'CREATEDB'. Similarly, dropping a database is 'DROP DATABASE' instead
+ of 'DESTROYDB'. However, the names of the executables 'createdb' and
+ 'destroydb' remain the same.
+
+New tools:
+ * pgperl - a Perl (4.036) interface to Postgres95
+ * pg_dump - a utility for dumping out a postgres database into a
+ script file containing query commands. The script files are in a ASCII
+ format and can be used to reconstruct the database, even on other
+ machines and other architectures. (Also good for converting
+ a Postgres 4.2 database to Postgres95 database.)
+
+The following ports have been incorporated into postgres95-beta-0.02:
+ * the NetBSD port by Alistair Crooks
+ * the AIX port by Mike Tung
+ * the Windows NT port by Jon Forrest (more stuff but not done yet)
+ * the Linux ELF port by Brian Gallew
+
+The following bugs have been fixed in postgres95-beta-0.02:
+ * new lines not escaped in COPY OUT and problem with COPY OUT when first
+ attribute is a '.'
+ * cannot type return to use the default user id in createuser
+ * SELECT DISTINCT on big tables crashes
+ * Linux installation problems
+ * monitor doesn't allow use of 'localhost' as PGHOST
+ * psql core dumps when doing \c or \l
+ * the "pgtclsh" target missing from src/bin/pgtclsh/Makefile
+ * libpgtcl has a hard-wired default port number
+ * SELECT DISTINCT INTO TABLE hangs
+ * CREATE TYPE doesn't accept 'variable' as the internallength
+ * wrong result using more than 1 aggregate in a SELECT
+
+Postgres95 Beta 0.01 (Mon May 1 19:03:10 PDT 1995)
+------------------------------------------------------
+Initial release.
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 00000000000..60d0fe6e417
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,256 @@
+
+POSTGRES95 INSTALLATION INSTRUCTIONS
+Copyright (c) 1996 Regents of the University of California
+
+This directory contains the source and documentation for Postgres95
+(version 1.02) Postgres95 is a derivative of POSTGRES 4.2 (the last
+release of the UC Berkeley research project). For copyright terms
+for postgres95, please see the file named COPYRIGHT. This version
+was developed by a team of developers on the postgres developers
+mailing list. Version 1.01 was developed by Jolly Chen and Andrew Yu.
+
+Postgres95 has been tested on the following platforms:
+
+ alpha - DEC Alpha AXP on OSF/1 2.0
+ hpux - HP PA-RISC on HP-UX 9.0
+ i386_solaris - i386 Solaris
+ sparc_solaris - SUN SPARC on Solaris 2.4
+ sparc - SUN SPARC on SunOS 4.1.3
+ ultrix4 - DEC MIPS on Ultrix 4.4
+ linux - Intel x86 on Linux 1.2 and Linux ELF
+ BSD44_derived - OSs derived from 4.4-lite BSD (NetBSD, FreeBSD)
+ bsdi - BSD/OS 2.0 and 2.01
+ bsdi_2_1 - BSD/OS 2.1
+ aix - IBM on AIX 3.2.5
+ irix5 - SGI MIPS on IRIX 5.3
+ dgux - DG/UX 5.4R3.10
+ Some hooks are provided for
+ svr4 - Intel x86 on Intel SVR4
+ next - Motorola MC68K or Intel x86 on NeXTSTEP 3.2
+ but these are guaranteed not to work as of yet.
+
+Postgres95 is also known to work on a number of other platforms that
+the authors have not personally tested.
+
+You should have at least 8 MB of memory and at least 30 MB of disk space to
+hold the source, binaries, and user databases.
+
+If you would like to migrate your databases from postgres 1.0 to
+postgres 1.02, see the directory called MIGRATION_1.0_TO_1.02. People
+upgrading from version 1.01 do not have to make any database changes.
+
+----------------------------------------------------------------------
+To install Postgres95 on UNIX platforms:
+
+1. Create the postgres login.
+
+ Create a login called postgres (this requires root privileges). We
+ recommend that you run the postmaster as the user postgres for security
+ reasons.
+
+ If you run the postmaster as yourself, be warned that you essentially
+ grant all database users the ability to execute arbitrary C functions
+ as you without your password. (In any case, DO NOT run the postmaster
+ as root.)
+
+2. Compile and install Postgres95.
+
+ If you have earlier versions of Postgres installed, you might want
+ to install Postgres95 in a different place.
+
+ If you're installing Postgres95 on Ultrix 4.x or Linux, see the
+ porting notes at the end for additional packages that you need to install
+ before installing Postgres95.
+
+ Our Makefiles require GNU make (called gmake in this document) and
+ also assume that "install" accepts BSD options. The INSTALL
+ variable in the Makefiles is set to the BSD-compatible version of
+ install. On some systems, you will have to find a BSD-compatible
+ install to the location of this program. (eg. bsdinst, which comes
+ with the MIT X Window System distribution)
+
+ Customization can be done by editing src/Makefile.global. You may change
+ the various configuration options here, such as where the Postgres95
+ executable files are installed and where postgres looks for the database
+ directory. The configuration switches are fairly self-explanatory, but we
+ will go over some of the more commonly-changed options:
+
+ - PORTNAME specifies the platform on which Postgres95 is being build
+ (linux is the default). You might need to change it to reflect your
+ platform. (sparc for SunOS 4.1.x, sparc_solaris for Solaris 2.4,
+ ultrix4 for Ultrix 4.4, and hpux for HP-UX 9.0)
+
+ - SRCDIR specifies where the source files are located. (defaults
+ to $(POSTGRESDIR)/src.)
+
+ - POSTSGRESDIR specifies the top-level directory where Postgres95
+ binaries, header files, libraries, and databases are installed.
+
+ - POSTGRESLOGIN specifies the user who will be doing initdb and
+ running the postmaster (defaults to postgres). Do not set
+ this to root, or any users with UID = 0!
+
+ - NAMEDATALEN and OIDNAMELEN allows you to set the maximum
+ length of system identifiers (table names, function names, etc.)
+ It defaults to 32. You may alter this if you like, but
+ be aware that databases created with different NAMEDATALEN's
+ do not interoperate.
+
+ - USE_READLINE specifies whether you want to use the GNU
+ readline and history libraries for the psql interactive
+ frontend program.
+ GNU readline is not supplied with postgres95 and can be found
+ in the usual ftp sites for GNU software.
+
+ - HBA specifies whether you wish to use host-based
+ authentication for postgres95. If you do use host-based
+ authentication, after installing, modify the file
+ $PGDATA/pg_hba accordingly.
+
+ After editing src/Makefile.global, you are ready to compile and
+ install Postgres95 (it takes about 10 minutes on a 133Mhz Pentium
+ running linux):
+
+ % cd src
+ % gmake
+ % gmake install
+
+ The first gmake ultimately issues the message "All of Postgres95 is
+ successfully made. Ready to install." If you don't get that, the make
+ failed, and there should be error messages at the end detailing why.
+
+ After the installation is complete, check that you have the following files
+ in the top level Postgres95 directory (eg. /usr/local/postgres95).
+
+ You will find the following executables in the bin directory (which
+ should be included in the search path of your shell):
+
+ % ls /usr/local/postgres95/bin
+ cleardbdir* destroydb* pg_dump* postgres*
+ createdb* destroyuser* pg_id* postmaster@
+ createuser* initdb* pg_version* psql*
+
+ You will find the following in the database directory:
+
+ % ls -R /usr/local/postgres95/data
+ files/
+ pg_hba
+
+ data/files:
+ global1.bki local1_template1.bki
+ global1.bki.source local1_template1.bki.source
+
+3. Initialize the database.
+
+ After you have installed Postgres95, initialize the database by typing:
+
+ % initdb
+
+4. Start the postmaster.
+
+ Now, you are ready to make the system operational by running the
+ postmaster daemon. There are a few environment variables which affect
+ its operation:
+ PGDATA - location of the database (eg. /usr/local/postgres95/data)
+ PGPORT - TCP port where it listens for connection (eg. 5432)
+ You don't have to set these variables if you use the (compile time)
+ default.
+
+ % postmaster -S
+
+
+5. Testing.
+
+ We suggest you run the regression tests to make sure the release
+ was installed successfully. The regression tests can be found in
+ src/test/regress. (see src/test/regress/README for more details)
+
+ % cd /usr/local/postgres95/src/test/regress
+ % gmake all runtest
+
+ This will run a whole slew of regression tests and might take a long
+ time to run. When it's done, the output is in the file obj/regress.out.
+ You can compare this to a sample run that we supply in the file
+ sample.regress.out. (You should get roughly the same output except
+ for some pathnames.)
+
+ % diff obj/regress.out sample.regress.out
+
+ The regression test takes about half an hour to run on a Sparc 10.
+ You may want to use 'grep -v' to remove unsignificant differences.
+
+6. Run queries.
+
+ After the database is initialized, you can create a new database. To
+ create a database, do the following:
+
+ % createdb foo
+
+ To connect to the postmaster, you have a choice of two front-end programs.
+ ("psql" is recommended. "monitor" is the old terminal monitor
+ supplied in earlier versions of Postgres)
+
+ % psql foo
+Please read the file COPYRIGHT for copyright terms of POSTGRES95
+
+ type \? for help on slash commands
+ type \q to quit
+ type \g or terminate with semicolon to execute query
+You are currently connected to the database: foo
+
+foo=>
+
+----------------------------------------------------------------------
+Questions? Bugs? Feedback?
+
+First, please read the Frequently Asked Questions and answers
+in the file called FAQ.
+
+If you still have questions, please send them to
+postgres95@postgres95.vnet.net.
+
+If you have a bug report to make, please send a filled out version of
+the file named "bug.template" to pg95-dev@ki.net.
+
+If you would like to help out with the development and maintenance of
+postgres95, send subscribe to the developers mailing list. See
+README.support for more information
+
+----------------------------------------------------------------------
+
+Porting Notes:
+-------------
+Ultrix4.x:
+ You need to install the libdl-1.1 package since Ultrix 4.x doesn't
+ have a dynamic loader. It's available in
+ s2k-ftp.CS.Berkeley.EDU:pub/personal/andrew/libdl-1.1.tar.Z
+
+Linux:
+ The linux port defaults to the ELF binary format. (Note that if you're
+ using ELF, you don't need dld because you'll be using the dl library
+ that comes with Linux ELF instead.)
+
+ To compile on non-ELF Linux, comment out the LINUX_ELF line in
+ src/mk/port/postgres.mk.linux. Also, the dld library MUST be obtained
+ and installed on the system. It enables dynamic link loading capability
+ to the postgres port. The dld library can be obtained from the sunsite
+ linux distributions. The current name is dld-3.2.5.
+ (Jalon Q. Zimmerman
+ <sneaker@powergrid.electriciti.com> 5/11/95)
+
+ To compile with flex, you need a recent version (2.5.2 or
+ later). Otherwise, you will get a 'yy_flush_buffer' undefined error.
+
+BSD/OS:
+ For BSD/OS 2.0 and 2.01, you will need to get flex version 2.5.2
+ as well as the GNU dld library. Flex version 2.5.3 has a known bug.
+
+NeXT:
+ The NeXT port was supplied by Tom R. Hageman <tom@basil.icce.rug.nl>.
+ It requires a SysV IPC emulation library and header files for
+ shared libary and semaphore stuff. Tom just happens to sell such
+ a product so contact him for information. He has also indicated that
+ binary releases of postgres95 for NEXTSTEP will be made available to
+ the general public. Contact Info@RnA.nl for information.
+
+
diff --git a/MAKE_CTAGS b/MAKE_CTAGS
new file mode 100644
index 00000000000..ef99564694c
--- /dev/null
+++ b/MAKE_CTAGS
@@ -0,0 +1,10 @@
+#!/bin/sh
+trap "rm -f /tmp/$$" 0 1 2 3 15
+rm -f ./tags
+find `pwd`/ -type f -name '*.[chyl]' -print|xargs ctags -t -a -f tags
+sort tags >/tmp/$$ && mv /tmp/$$ tags
+
+find . -type d -print |while read DIR
+do
+ [ "$DIR" != "." ] && ln -f -s `pwd`/tags $DIR/tags
+done
diff --git a/MIGRATION_to_1.02.1 b/MIGRATION_to_1.02.1
new file mode 100644
index 00000000000..859a94570a8
--- /dev/null
+++ b/MIGRATION_to_1.02.1
@@ -0,0 +1,73 @@
+From scrappy@ki.net Wed Aug 14 20:41:08 1996
+Status: RO
+X-Status:
+Received: from candle.pha.pa.us (maillist@s1-03.ppp.op.net [206.84.209.132]) by quagmire.ki.net (8.7.5/8.7.5) with ESMTP id UAA01234 for <scrappy@ki.net>; Wed, 14 Aug 1996 20:41:00 -0400 (EDT)
+Received: (from maillist@localhost) by candle.pha.pa.us (8.7.4/8.7.3) id UAA13966 for scrappy@ki.net; Wed, 14 Aug 1996 20:40:48 -0400 (EDT)
+From: Bruce Momjian <maillist@candle.pha.pa.us>
+Message-Id: <199608150040.UAA13966@candle.pha.pa.us>
+Subject: New migration file
+To: scrappy@ki.net (Marc G. Fournier)
+Date: Wed, 14 Aug 1996 20:40:47 -0400 (EDT)
+X-Mailer: ELM [version 2.4 PL25]
+MIME-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+
+Here is a new migratoin file for 1.02.1. It includes the 'copy' change
+and a script to convert old ascii files.
+
+---------------------------------------------------------------------------
+
+The following notes are for the benefit of users who want to migrate
+databases from postgres95 1.01 and 1.02 to postgres95 1.02.1.
+
+If you are starting afresh with postgres95 1.02.1 and do not need
+to migrate old databases, you do not need to read any further.
+
+----------------------------------------------------------------------
+
+In order to upgrade older postgres95 version 1.01 or 1.02 databases to
+version 1.02.1, the following steps are required:
+
+1) start up a new 1.02.1 postmaster
+
+2) Add the new built-in functions and operators of 1.02.1 to 1.01 or 1.02
+ databases. This is done by running the new 1.02.1 server against
+ your own 1.01 or 1.02 database and applying the queries attached at
+ the end of thie file. This can be done easily through psql. If your
+ 1.01 or 1.02 database is named "testdb" and you have cut the commands
+ from the end of this file and saved them in addfunc.sql:
+
+ % psql testdb -f addfunc.sql
+
+Those upgrading 1.02 databases will get a warning when executing the
+last two statements because they are already present in 1.02. This is
+not a cause for concern.
+
+ * * *
+
+If you are trying to reload a pg_dump or text-mode 'copy tablename to
+stdout' generated with a previous version, you will need to run the
+attached sed script on the ASCII file before loading it into the
+database. The old format used '.' as end-of-data, while '\.' is now the
+end-of-data marker. Also, empty strings are now loaded in as '' rather
+than NULL. See the copy manual page for full details.
+
+ sed 's/^\.$/\\./g' <in_file >out_file
+
+If you are loading an older binary copy or non-stdout copy, there is no
+end-of-data character, and hence no conversion necessary.
+
+---------------------------------------------------------------------------
+
+-- following lines added by agc to reflect the case-insensitive
+-- regexp searching for varchar (in 1.02), and bpchar (in 1.02.1)
+create operator ~* (leftarg = bpchar, rightarg = text, procedure = texticregexeq);
+create operator !~* (leftarg = bpchar, rightarg = text, procedure = texticregexne);
+create operator ~* (leftarg = varchar, rightarg = text, procedure = texticregexeq);
+create operator !~* (leftarg = varchar, rightarg = text, procedure = texticregexne);
+
+
+
+
+
diff --git a/README b/README
new file mode 100644
index 00000000000..63fc0080efa
--- /dev/null
+++ b/README
@@ -0,0 +1,36 @@
+
+POSTGRES95 Data Base Management System
+
+This directory contains the 1.02 release of Postgres95. See INSTALL for
+the installation notes and HISTORY for the changes.
+
+We also have a WWW home page located at:
+ http://www.ki.net/postgres95
+
+Postgres95 is not public domain software. It is copyrighted by the
+University of California but may be used according to the licensing
+terms of the the copyright below:
+
+------------------------------------------------------------------------
+
+POSTGRES95 Data Base Management System
+
+Copyright (c) 1994-6 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.
+
+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 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
diff --git a/contrib/array/array_iterator.c b/contrib/array/array_iterator.c
new file mode 100644
index 00000000000..95ab119f853
--- /dev/null
+++ b/contrib/array/array_iterator.c
@@ -0,0 +1,251 @@
+/*
+ * array_iterator.c --
+ *
+ * This file defines a new group of operators which take an
+ * array and a scalar value, iterate a scalar operator over the
+ * elements of the array and the value and compute a result as
+ * the logical OR or AND of the results.
+ * For example array_int4eq returns true if some of the elements
+ * of an array of int4 is equal to the given value:
+ *
+ * array_int4eq({1,2,3}, 1) --> true
+ * array_int4eq({1,2,3}, 4) --> false
+ *
+ * If we have defined T array types and O scalar operators
+ * we can define T x O array operators, each of them has a name
+ * like "array_<basetype><operation>" and takes an array of type T
+ * iterating the operator O over all the elements. Note however
+ * that some of the possible combination are invalid, for example
+ * the array_int4_like because there is no like operator for int4.
+ * It is now possible to write queries which look inside the arrays:
+ *
+ * create table t(id int4[], txt text[]);
+ * select * from t where t.id *= 123;
+ * select * from t where t.txt *~ '[a-z]';
+ * select * from t where t.txt[1:3] **~ '[a-z]';
+ *
+ * Copyright (c) 1996, Massimo Dal Zotto <dz@cs.unitn.it>
+ */
+
+#include <ctype.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <string.h>
+
+#include "postgres.h"
+#include "pg_type.h"
+#include "miscadmin.h"
+#include "syscache.h"
+#include "access/xact.h"
+#include "utils/builtins.h"
+#include "utils/elog.h"
+
+static int32
+array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
+{
+ HeapTuple typ_tuple;
+ TypeTupleForm typ_struct;
+ bool typbyval;
+ int typlen;
+ func_ptr proc_fn;
+ int pronargs;
+ int nitems, i, result;
+ int ndim, *dim;
+ char *p;
+
+ /* Sanity checks */
+ if ((array == (ArrayType *) NULL)
+ || (ARR_IS_LO(array) == true)) {
+ /* elog(NOTICE, "array_iterator: array is null"); */
+ return (0);
+ }
+ ndim = ARR_NDIM(array);
+ dim = ARR_DIMS(array);
+ nitems = getNitems(ndim, dim);
+ if (nitems == 0) {
+ /* elog(NOTICE, "array_iterator: nitems = 0"); */
+ return (0);
+ }
+
+ /* Lookup element type information */
+ typ_tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(elemtype),0,0,0);
+ if (!HeapTupleIsValid(typ_tuple)) {
+ elog(WARN,"array_iterator: cache lookup failed for type %d", elemtype);
+ return 0;
+ }
+ typ_struct = (TypeTupleForm) GETSTRUCT(typ_tuple);
+ typlen = typ_struct->typlen;
+ typbyval = typ_struct->typbyval;
+
+ /* Lookup the function entry point */
+ proc_fn == (func_ptr) NULL;
+ fmgr_info(proc, &proc_fn, &pronargs);
+ if ((proc_fn == NULL) || (pronargs != 2)) {
+ elog(WARN, "array_iterator: fmgr_info lookup failed for oid %d", proc);
+ return (0);
+ }
+
+ /* Scan the array and apply the operator to each element */
+ result = 0;
+ p = ARR_DATA_PTR(array);
+ for (i = 0; i < nitems; i++) {
+ if (typbyval) {
+ switch(typlen) {
+ case 1:
+ result = (int) (*proc_fn)(*p, value);
+ break;
+ case 2:
+ result = (int) (*proc_fn)(* (int16 *) p, value);
+ break;
+ case 3:
+ case 4:
+ result = (int) (*proc_fn)(* (int32 *) p, value);
+ break;
+ }
+ p += typlen;
+ } else {
+ result = (int) (*proc_fn)(p, value);
+ if (typlen > 0) {
+ p += typlen;
+ } else {
+ p += INTALIGN(* (int32 *) p);
+ }
+ }
+ if (result) {
+ if (!and) {
+ return (1);
+ }
+ } else {
+ if (and) {
+ return (0);
+ }
+ }
+ }
+
+ if (and && result) {
+ return (1);
+ } else {
+ return (0);
+ }
+}
+
+/*
+ * Iterators for type _text
+ */
+
+int32
+array_texteq(ArrayType *array, char* value)
+{
+ return array_iterator((Oid) 25, /* text */
+ (Oid) 67, /* texteq */
+ 0, /* logical or */
+ array, (Datum)value);
+}
+
+int32
+array_all_texteq(ArrayType *array, char* value)
+{
+ return array_iterator((Oid) 25, /* text */
+ (Oid) 67, /* texteq */
+ 1, /* logical and */
+ array, (Datum)value);
+}
+
+int32
+array_textregexeq(ArrayType *array, char* value)
+{
+ return array_iterator((Oid) 25, /* text */
+ (Oid) 81, /* textregexeq */
+ 0, /* logical or */
+ array, (Datum)value);
+}
+
+int32
+array_all_textregexeq(ArrayType *array, char* value)
+{
+ return array_iterator((Oid) 25, /* text */
+ (Oid) 81, /* textregexeq */
+ 1, /* logical and */
+ array, (Datum)value);
+}
+
+/*
+ * Iterators for type _char16. Note that the regexp operators
+ * take the second argument of type text.
+ */
+
+int32
+array_char16eq(ArrayType *array, char* value)
+{
+ return array_iterator((Oid) 20, /* char16 */
+ (Oid) 490, /* char16eq */
+ 0, /* logical or */
+ array, (Datum)value);
+}
+
+int32
+array_all_char16eq(ArrayType *array, char* value)
+{
+ return array_iterator((Oid) 20, /* char16 */
+ (Oid) 490, /* char16eq */
+ 1, /* logical and */
+ array, (Datum)value);
+}
+
+int32
+array_char16regexeq(ArrayType *array, char* value)
+{
+ return array_iterator((Oid) 20, /* char16 */
+ (Oid) 700, /* char16regexeq */
+ 0, /* logical or */
+ array, (Datum)value);
+}
+
+int32
+array_all_char16regexeq(ArrayType *array, char* value)
+{
+ return array_iterator((Oid) 20, /* char16 */
+ (Oid) 700, /* char16regexeq */
+ 1, /* logical and */
+ array, (Datum)value);
+}
+
+/*
+ * Iterators for type _int4
+ */
+
+int32
+array_int4eq(ArrayType *array, int4 value)
+{
+ return array_iterator((Oid) 23, /* int4 */
+ (Oid) 65, /* int4eq */
+ 0, /* logical or */
+ array, (Datum)value);
+}
+
+int32
+array_all_int4eq(ArrayType *array, int4 value)
+{
+ return array_iterator((Oid) 23, /* int4 */
+ (Oid) 65, /* int4eq */
+ 1, /* logical and */
+ array, (Datum)value);
+}
+
+int32
+array_int4gt(ArrayType *array, int4 value)
+{
+ return array_iterator((Oid) 23, /* int4 */
+ (Oid) 147, /* int4gt */
+ 0, /* logical or */
+ array, (Datum)value);
+}
+
+int32
+array_all_int4gt(ArrayType *array, int4 value)
+{
+ return array_iterator((Oid) 23, /* int4 */
+ (Oid) 147, /* int4gt */
+ 1, /* logical and */
+ array, (Datum)value);
+}
diff --git a/contrib/array/array_iterator.doc b/contrib/array/array_iterator.doc
new file mode 100644
index 00000000000..01c1b2195cf
--- /dev/null
+++ b/contrib/array/array_iterator.doc
@@ -0,0 +1,26 @@
+From: Massimo Dal Zotto <dz@cs.unitn.it>
+Date: Mon, 6 May 1996 01:03:37 +0200 (MET DST)
+Subject: [PG95]: new operators for arrays
+
+- -----BEGIN PGP SIGNED MESSAGE-----
+
+Hi,
+
+I have written an extension to Postgres95 which allows to use qualification
+clauses based on the values of single elements of arrays.
+For example I can now select rows having some or all element of an array
+attribute equal to a given value or matching a regular expression:
+
+select * from t where t.foo *= 'bar';
+select * from t where t.foo **~ '^ba[rz]';
+
+The scheme is quite general, each operator which operates on a base type can
+be iterated over the elements of an array. It seem to work well but defining
+each new operators requires writing a different C function. Furthermore in
+each function there are two hardcoded OIDs which reference a base type and
+a procedure. Not very portable. Can anyone suggest a better and more portable
+way to do it ? Do you think this could be a useful feature for next release ?
+Here is my code, it can be compiled and loaded as a dynamic module without
+need to recompile the backend. I have defined only the few operators I needed,
+the list can be extended. Feddback is welcome.
+
diff --git a/contrib/array/array_iterator.sql b/contrib/array/array_iterator.sql
new file mode 100644
index 00000000000..7a3356266c1
--- /dev/null
+++ b/contrib/array/array_iterator.sql
@@ -0,0 +1,137 @@
+/*
+ * SQL code
+
+- - -- load the new functions
+- - --
+load '/home/dz/lib/postgres/array_iterator.so';
+
+- - -- define the array operators *=, **=, *~ and **~ for type _text
+- - --
+create function array_texteq(_text, text)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_all_texteq(_text, text)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_textregexeq(_text, text)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_all_textregexeq(_text, text)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create operator *= (
+ leftarg=_text,
+ rightarg=text,
+ procedure=array_texteq);
+
+create operator **= (
+ leftarg=_text,
+ rightarg=text,
+ procedure=array_all_texteq);
+
+create operator *~ (
+ leftarg=_text,
+ rightarg=text,
+ procedure=array_textregexeq);
+
+create operator **~ (
+ leftarg=_text,
+ rightarg=text,
+ procedure=array_all_textregexeq);
+
+- - -- define the array operators *=, **=, *~ and **~ for type _char16
+- - --
+create function array_char16eq(_char16, char16)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_all_char16eq(_char16, char16)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_char16regexeq(_char16, text)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_all_char16regexeq(_char16, text)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create operator *= (
+ leftarg=_char16,
+ rightarg=char16,
+ procedure=array_char16eq);
+
+create operator **= (
+ leftarg=_char16,
+ rightarg=char16,
+ procedure=array_all_char16eq);
+
+create operator *~ (
+ leftarg=_char16,
+ rightarg=text,
+ procedure=array_char16regexeq);
+
+create operator **~ (
+ leftarg=_char16,
+ rightarg=text,
+ procedure=array_all_char16regexeq);
+
+- - -- define the array operators *=, **=, *> and **> for type _int4
+- - --
+create function array_int4eq(_int4, int4)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_all_int4eq(_int4, int4)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_int4gt(_int4, int4)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create function array_all_int4gt(_int4, int4)
+ returns bool
+ as '/home/dz/lib/postgres/array_iterator.so'
+ language 'c';
+
+create operator *= (
+ leftarg=_int4,
+ rightarg=int4,
+ procedure=array_int4eq);
+
+create operator **= (
+ leftarg=_int4,
+ rightarg=int4,
+ procedure=array_all_int4eq);
+
+create operator *> (
+ leftarg=_int4,
+ rightarg=int4,
+ procedure=array_int4gt);
+
+create operator **> (
+ leftarg=_int4,
+ rightarg=int4,
+ procedure=array_all_int4gt);
+
+*/
+
+/* end of file */
+
diff --git a/contrib/datetime/datetime_functions.c b/contrib/datetime/datetime_functions.c
new file mode 100644
index 00000000000..dc1fec8bd20
--- /dev/null
+++ b/contrib/datetime/datetime_functions.c
@@ -0,0 +1,147 @@
+/*
+ * datetime_functions.c --
+ *
+ * This file defines new functions for the time and date data types.
+ *
+ * Copyright (c) 1996, Massimo Dal Zotto <dz@cs.unitn.it>
+ */
+
+#include <time.h>
+
+#include "postgres.h"
+#include "pg_type.h"
+#include "utils/palloc.h"
+
+typedef struct DateADT {
+ char day;
+ char month;
+ short year;
+} DateADT;
+
+typedef struct TimeADT {
+ short hr;
+ short min;
+ float sec;
+} TimeADT;
+
+TimeADT *
+time_difference(TimeADT *time1, TimeADT *time2)
+{
+ TimeADT *time = (TimeADT*)palloc(sizeof(TimeADT));
+
+ time->sec = time1->sec - time2->sec;
+ time->min = time1->min - time2->min;
+ time->hr = time1->hr - time2->hr;
+
+ if (time->sec < 0) {
+ time->sec += 60.0;
+ time->min--;
+ } else if (time->sec >= 60.0) {
+ time->sec -= 60.0;
+ time->min++;
+ }
+
+ if (time->min < 0) {
+ time->min += 60;
+ time->hr--;
+ } else if (time->min >= 60) {
+ time->min -= 60;
+ time->hr++;
+ }
+
+ if (time->hr < 0) {
+ time->hr += 24;
+ } else if (time->hr >= 24) {
+ time->hr -= 24;
+ }
+
+ return (time);
+}
+
+TimeADT *
+currentTime()
+{
+ time_t current_time;
+ struct tm *tm;
+ TimeADT *result = (TimeADT*)palloc(sizeof(TimeADT));
+
+ current_time = time(NULL);
+ tm = localtime(&current_time);
+ result->sec = tm->tm_sec;
+ result->min = tm->tm_min;
+ result->hr = tm->tm_hour;
+
+ return (result);
+}
+
+int4
+currentDate()
+{
+ time_t current_time;
+ struct tm *tm;
+ int4 result;
+ DateADT *date = (DateADT*)&result;
+
+ current_time = time(NULL);
+ tm = localtime(&current_time);
+ date->day = tm->tm_mday;
+ date->month = tm->tm_mon+1;
+ date->year = tm->tm_year+1900;
+
+ return (result);
+}
+
+int4
+hours(TimeADT *time)
+{
+ return (time->hr);
+}
+
+int4
+minutes(TimeADT *time)
+{
+ return (time->min);
+}
+
+int4
+seconds(TimeADT *time)
+{
+ int seconds = (int)time->sec;
+ return (seconds);
+}
+
+int4
+day(int4 val)
+{
+ DateADT *date = (DateADT*)&val;
+ return (date->day);
+}
+
+int4
+month(int4 val)
+{
+ DateADT *date = (DateADT*)&val;
+ return (date->month);
+}
+
+int4
+year(int4 val)
+{
+ DateADT *date = (DateADT*)&val;
+ return (date->year);
+}
+
+int4
+asMinutes(TimeADT *time)
+{
+ int seconds = (int)time->sec;
+ return (time->min + 60*time->hr);
+}
+
+int4
+asSeconds(TimeADT *time)
+{
+ int seconds = (int)time->sec;
+ return (seconds + 60*time->min + 3600*time->hr);
+}
+
diff --git a/contrib/datetime/datetime_functions.doc b/contrib/datetime/datetime_functions.doc
new file mode 100644
index 00000000000..0c7a01819a5
--- /dev/null
+++ b/contrib/datetime/datetime_functions.doc
@@ -0,0 +1,25 @@
+From: Massimo Dal Zotto <dz@cs.unitn.it>
+Date: Tue, 14 May 1996 14:31:18 +0200 (MET DST)
+Subject: [PG95]: new postgres functions
+
+- -----BEGIN PGP SIGNED MESSAGE-----
+
+Some time ago I read in the mailing list requests of people looking
+for more time and date functions. I have now written some of them:
+
+ time_difference(time1, time2) ,also defined as operator '-'
+ hour(time)
+ minutes(time)
+ seconds(time)
+ asMinutes(time)
+ asSeconds(time)
+ currentTime()
+ currentDate()
+
+The file can be compiled as shared library and loaded as dynamic module
+without need to recompile the backend. This can also be taken as an example
+of the extensibility of postgres (user-defined functions, operators, etc).
+I would be nice to see more of these user contributed modules posted to this
+list and hopefully accessible from the Postgres home page.
+
+
diff --git a/contrib/datetime/datetime_functions.sql b/contrib/datetime/datetime_functions.sql
new file mode 100644
index 00000000000..2e50a4a19fd
--- /dev/null
+++ b/contrib/datetime/datetime_functions.sql
@@ -0,0 +1,69 @@
+
+-- SQL code to load and define 'datetime' functions
+
+-- load the new functions
+
+load '/home/dz/lib/postgres/datetime_functions.so';
+
+-- define the new functions in postgres
+
+create function time_difference(time,time)
+ returns time
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function currentDate()
+ returns date
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function currentTime()
+ returns time
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function hours(time)
+ returns int4
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function minutes(time)
+ returns int4
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function seconds(time)
+ returns int4
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function day(date)
+ returns int4
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function month(date)
+ returns int4
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function year(date)
+ returns int4
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function asMinutes(time)
+ returns int4
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create function asSeconds(time)
+ returns int4
+ as '/home/dz/lib/postgres/datetime_functions.so'
+ language 'c';
+
+create operator - (
+ leftarg=time,
+ rightarg=time,
+ procedure=time_difference);
+
diff --git a/contrib/pginterface/Makefile b/contrib/pginterface/Makefile
new file mode 100644
index 00000000000..7759ef8d28f
--- /dev/null
+++ b/contrib/pginterface/Makefile
@@ -0,0 +1,19 @@
+#
+# Makefile
+#
+#
+TARGET = pginsert
+CFLAGS = -g -Wall -I/u/postgres95/include
+LIBS = -L/u/postgres95/lib -lpq
+
+$(TARGET) : pginsert.o pginterface.o halt.o
+ $(CC) -o $(TARGET) $(XFLAGS) $(CFLAGS) \
+ pginsert.o pginterface.o halt.o $(LIBS)
+
+clean:
+ rm -f *.o $(TARGET) log core
+
+install:
+ make clean
+ make CFLAGS=-O
+ install -s -o bin -g bin $(TARGET) /usr/local/bin
diff --git a/contrib/pginterface/README b/contrib/pginterface/README
new file mode 100644
index 00000000000..5062431f096
--- /dev/null
+++ b/contrib/pginterface/README
@@ -0,0 +1,42 @@
+
+
+ Pginterface 1.0
+
+Attached is a copy of the Postgres support routines I wrote to allow me
+to more cleanly interface to the libpg library, more like a 4gl SQL
+interface.
+
+It has several features that may be useful for others:
+
+I have simplified the C code that calls libpq by wrapping all the
+functionality of libpq in calls to connectdb(), doquery(), fetch(), and
+disconnectdb(). Each call returns a structure or value, so if you need
+to do more work with the result, you can. Also, I have a global
+variable that allows you to disable the error checking I have added to
+the doquery() routine.
+
+I have added a function called fetch(), which allows you to pass
+pointers as parameters, and on return the variables are filled with the
+data from the binary cursor you opened. These binary cursors are not
+useful if you are running the query engine on a system with a different
+architecture than the database server. If you pass a NULL pointer, the
+column is skipped, and you can use libpq to handle it as you wish.
+
+I have used sigprocmask() to block the reception of certain signals
+while the program is executing SQL queries. This prevents a user
+pressing Control-C from stopping all the back ends. It blocks SIGHUP,
+SIGINT, and SIGTERM, but does not block SIGQUIT or obviously kill -9.
+If your platform does not support sigprocmask(), you can remove those
+function calls. ( Am I correct that abnormal termination can cause
+shared memory resynchronization?)
+
+There is a demo program called pginsert that demonstrates how the
+library can be used.
+
+You can create a library of pginterface.c and halt.c, and just include
+pginterface.h in your source code.
+
+I am willing to maintain this if people find problems or want additional
+functionality.
+
+Bruce Momjian (root@candle.pha.pa.us)
diff --git a/contrib/pginterface/halt.c b/contrib/pginterface/halt.c
new file mode 100644
index 00000000000..58ca11a5878
--- /dev/null
+++ b/contrib/pginterface/halt.c
@@ -0,0 +1,58 @@
+/*
+**
+** halt.c
+**
+** This is used to print out error messages and exit
+*/
+
+#include <varargs.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+
+/*-------------------------------------------------------------------------
+**
+** halt - print error message, and call clean up routine or exit
+**
+**------------------------------------------------------------------------*/
+
+/*VARARGS*/
+void halt(va_alist)
+va_dcl
+{
+ va_list arg_ptr;
+ char *format, *pstr;
+ void (*sig_func)();
+
+ va_start(arg_ptr);
+ format = va_arg(arg_ptr,char *);
+ if (strncmp(format,"PERROR", 6) != 0)
+ vfprintf(stderr,format,arg_ptr);
+ else
+ {
+ for (pstr=format+6; *pstr == ' ' || *pstr == ':'; pstr++)
+ ;
+ vfprintf(stderr,pstr,arg_ptr);
+ perror("");
+ }
+ va_end(arg_ptr);
+ fflush(stderr);
+
+ /* call one clean up function if defined */
+ if ( (sig_func = signal(SIGTERM, SIG_DFL)) != SIG_DFL &&
+ sig_func != SIG_IGN)
+ (*sig_func)(0);
+ else if ( (sig_func = signal(SIGHUP, SIG_DFL)) != SIG_DFL &&
+ sig_func != SIG_IGN)
+ (*sig_func)(0);
+ else if ( (sig_func = signal(SIGINT, SIG_DFL)) != SIG_DFL &&
+ sig_func != SIG_IGN)
+ (*sig_func)(0);
+ else if ( (sig_func = signal(SIGQUIT, SIG_DFL)) != SIG_DFL &&
+ sig_func != SIG_IGN)
+ (*sig_func)(0);
+ exit(1);
+}
diff --git a/contrib/pginterface/halt.h b/contrib/pginterface/halt.h
new file mode 100644
index 00000000000..cb4ea545b9b
--- /dev/null
+++ b/contrib/pginterface/halt.h
@@ -0,0 +1,7 @@
+/*
+** halt.h
+**
+*/
+
+void halt();
+
diff --git a/contrib/pginterface/pginsert.c b/contrib/pginterface/pginsert.c
new file mode 100644
index 00000000000..b49d3449c66
--- /dev/null
+++ b/contrib/pginterface/pginsert.c
@@ -0,0 +1,98 @@
+/*
+ * insert.c
+ *
+*/
+
+#include <stdio.h>
+#include <signal.h>
+#include <time.h>
+#include "halt.h"
+#include <libpq-fe.h>
+#include "pginterface.h"
+
+int main(int argc, char **argv)
+{
+ char query[4000];
+ int row =1;
+ int aint;
+ float afloat;
+ double adouble;
+ char achar[11], achar16[17], abpchar[11], avarchar[51], atext[51];
+ time_t aabstime;
+
+ if (argc != 2)
+ halt("Usage: %s database\n",argv[0]);
+
+ connectdb(argv[1],NULL,NULL,NULL,NULL);
+
+ on_error_continue();
+ doquery("DROP TABLE testfetch");
+ on_error_stop();
+
+ doquery("\
+ CREATE TABLE testfetch( \
+ aint int4, \
+ afloat float4, \
+ adouble float8, \
+ achar char, \
+ achar16 char16, \
+ abpchar char(10), \
+ avarchar varchar(50), \
+ atext text, \
+ aabstime abstime) \
+ ");
+
+ while(1)
+ {
+ sprintf(query,"INSERT INTO testfetch VALUES ( \
+ %d, \
+ 2322.12, \
+ '923121.0323'::float8, \
+ 'A', \
+ 'Betty', \
+ 'Charley', \
+ 'Doug', \
+ 'Ernie', \
+ 'now' )", row);
+ doquery(query);
+
+ doquery("BEGIN WORK");
+ doquery("DECLARE c_testfetch BINARY CURSOR FOR \
+ SELECT * FROM testfetch");
+
+ doquery("FETCH ALL IN c_testfetch");
+
+ while (fetch(
+ &aint,
+ &afloat,
+ &adouble,
+ achar,
+ achar16,
+ abpchar,
+ avarchar,
+ atext,
+ &aabstime) != END_OF_TUPLES)
+ printf("int %d\nfloat %f\ndouble %f\nchar %s\nchar16 %s\n\
+bpchar %s\nvarchar %s\ntext %s\nabstime %s",
+ aint,
+ afloat,
+ adouble,
+ achar,
+ achar16,
+ abpchar,
+ avarchar,
+ atext,
+ ctime(&aabstime));
+
+
+ doquery("CLOSE c_testfetch");
+ doquery("COMMIT WORK");
+ printf("--- %-d rows inserted so far\n",row);
+
+ row++;
+ }
+
+ disconnectdb();
+ return 0;
+}
+
diff --git a/contrib/pginterface/pginterface.c b/contrib/pginterface/pginterface.c
new file mode 100644
index 00000000000..9df7021eb71
--- /dev/null
+++ b/contrib/pginterface/pginterface.c
@@ -0,0 +1,177 @@
+/*
+ * pginterface.c
+ *
+*/
+
+#include <stdio.h>
+#include <signal.h>
+#include <string.h>
+#include <stdarg.h>
+
+#include "halt.h"
+#include <libpq-fe.h>
+#include "pginterface.h"
+
+static void sig_disconnect();
+static void set_signals();
+
+#define NUL '\0'
+
+/* GLOBAL VARIABLES */
+static PGconn* conn;
+static PGresult* res = NULL;
+
+#define ON_ERROR_STOP 0
+#define ON_ERROR_CONTINUE 1
+
+static int on_error_state = ON_ERROR_STOP;
+
+/* LOCAL VARIABLES */
+static sigset_t block_sigs, unblock_sigs;
+static int tuple;
+
+/*
+**
+** connectdb - returns PGconn structure
+**
+*/
+PGconn *connectdb( char *dbName,
+ char *pghost,
+ char *pgport,
+ char *pgoptions,
+ char *pgtty)
+{
+ /* make a connection to the database */
+ conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
+ if (PQstatus(conn) == CONNECTION_BAD)
+ halt("Connection to database '%s' failed.\n%s\n", dbName,
+ PQerrorMessage(conn));
+ set_signals();
+ return conn;
+}
+
+/*
+**
+** disconnectdb
+**
+*/
+void disconnectdb()
+{
+ PQfinish(conn);
+}
+
+/*
+**
+** doquery - returns PGresult structure
+**
+*/
+PGresult *doquery(char *query)
+{
+ if (res != NULL)
+ PQclear(res);
+
+ sigprocmask(SIG_SETMASK,&block_sigs,NULL);
+ res = PQexec(conn, query);
+ sigprocmask(SIG_SETMASK,&unblock_sigs,NULL);
+
+ if (on_error_state == ON_ERROR_STOP &&
+ (res == NULL ||
+ PQresultStatus(res) == PGRES_BAD_RESPONSE ||
+ PQresultStatus(res) == PGRES_NONFATAL_ERROR ||
+ PQresultStatus(res) == PGRES_FATAL_ERROR))
+ {
+ if (res != NULL)
+ fprintf(stderr,"query error: %s\n",PQcmdStatus(res));
+ else fprintf(stderr,"connection error: %s\n",PQerrorMessage(conn));
+ PQfinish(conn);
+ halt("failed request: %s\n", query);
+ }
+ tuple = 0;
+ return res;
+}
+
+/*
+**
+** fetch - returns tuple number (starts at 0), or the value END_OF_TUPLES
+** NULL pointers are skipped
+**
+*/
+int fetch(void *param, ...)
+{
+ va_list ap;
+ int arg, num_args;
+
+ num_args = PQnfields(res);
+
+ if (tuple >= PQntuples(res))
+ return END_OF_TUPLES;
+ va_start(ap, param);
+ for (arg = 0; arg < num_args; arg++)
+ {
+ if (param != NULL)
+ {
+ if (PQfsize(res, arg) == -1)
+ {
+ memcpy(param,PQgetvalue(res,tuple,arg),PQgetlength(res,tuple,arg));
+ ((char *)param)[PQgetlength(res,tuple,arg)] = NUL;
+ }
+ else
+ memcpy(param,PQgetvalue(res,tuple,arg),PQfsize(res,arg));
+ }
+ param = va_arg(ap, char *);
+ }
+ va_end(ap);
+ return tuple++;
+}
+
+/*
+**
+** on_error_stop
+**
+*/
+void on_error_stop()
+{
+ on_error_state = ON_ERROR_STOP;
+}
+
+/*
+**
+** on_error_continue
+**
+*/
+void on_error_continue()
+{
+ on_error_state = ON_ERROR_CONTINUE;
+}
+
+/*
+**
+** sig_disconnect
+**
+*/
+static void sig_disconnect()
+{
+ fprintf(stderr,"exiting...\n");
+ PQfinish(conn);
+ exit(1);
+}
+
+/*
+**
+** set_signals
+**
+*/
+static void set_signals()
+{
+ sigemptyset(&block_sigs);
+ sigemptyset(&unblock_sigs);
+ sigaddset(&block_sigs,SIGTERM);
+ sigaddset(&block_sigs,SIGHUP);
+ sigaddset(&block_sigs,SIGINT);
+/* sigaddset(&block_sigs,SIGQUIT); no block */
+ sigprocmask(SIG_SETMASK,&unblock_sigs,NULL);
+ signal(SIGTERM,sig_disconnect);
+ signal(SIGHUP,sig_disconnect);
+ signal(SIGINT,sig_disconnect);
+ signal(SIGQUIT,sig_disconnect);
+}
diff --git a/contrib/pginterface/pginterface.h b/contrib/pginterface/pginterface.h
new file mode 100644
index 00000000000..6e074ff2349
--- /dev/null
+++ b/contrib/pginterface/pginterface.h
@@ -0,0 +1,13 @@
+/*
+ * pglib.h
+ *
+*/
+
+PGresult *doquery(char *query);
+PGconn *connectdb();
+void disconnectdb();
+int fetch(void *param, ...);
+void on_error_continue();
+void on_error_stop();
+
+#define END_OF_TUPLES (-1)
diff --git a/contrib/soundex/soundex.c b/contrib/soundex/soundex.c
new file mode 100644
index 00000000000..2ce6ef510f6
--- /dev/null
+++ b/contrib/soundex/soundex.c
@@ -0,0 +1,83 @@
+/*****************************************************************************/
+/* soundex.c */
+/*****************************************************************************/
+
+#include <string.h>
+#include <stdio.h>
+#include "postgres.h" /* for char16, etc. */
+#include "utils/palloc.h" /* for palloc */
+#include "libpq-fe.h" /* for TUPLE */
+#include <stdio.h>
+#include <ctype.h>
+
+/* prototype for soundex function */
+char *soundex(char *instr, char *outstr);
+
+text *text_soundex(text *t)
+{
+ /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
+ char *table = "01230120022455012623010202";
+ int count = 0;
+ text *new_t;
+
+ char outstr[6+1]; /* max length of soundex is 6 */
+ char *instr;
+
+ /* make a null-terminated string */
+ instr=palloc(VARSIZE(t)+1);
+ memcpy(instr,VARDATA(t),VARSIZE(t)-VARHDRSZ);
+ instr[VARSIZE(t)-VARHDRSZ] = (char)0;
+
+ /* load soundex into outstr */
+ soundex(instr, outstr);
+
+ /* Now the outstr contains the soundex of instr */
+ /* copy outstr to new_t */
+ new_t = (text *) palloc(strlen(outstr)+VARHDRSZ);
+ memset(new_t, 0, strlen(outstr)+1);
+ VARSIZE(new_t) = strlen(outstr)+VARHDRSZ;
+ memcpy((void *) VARDATA(new_t),
+ (void *) outstr,
+ strlen(outstr));
+
+ /* free instr */
+ pfree(instr);
+
+ return(new_t);
+}
+
+char *soundex(char *instr, char *outstr)
+{ /* ABCDEFGHIJKLMNOPQRSTUVWXYZ */
+ char *table = "01230120022455012623010202";
+ int count = 0;
+
+ while(!isalpha(instr[0]) && instr[0])
+ ++instr;
+
+ if(!instr[0]) { /* Hey! Where'd the string go? */
+ outstr[0]=(char)0;
+ return outstr;
+ }
+
+ if(toupper(instr[0]) == 'P' && toupper(instr[1]) == 'H') {
+ instr[0] = 'F';
+ instr[1] = 'A';
+ }
+
+ *outstr++ = (char)toupper(*instr++);
+
+ while(*instr && count < 5) {
+ if(isalpha(*instr) && *instr != *(instr-1)) {
+ *outstr = table[toupper(instr[0]) - 'A'];
+ if(*outstr != '0') {
+ ++outstr;
+ ++count;
+ }
+ }
+ ++instr;
+ }
+
+ *outstr = '\0';
+ return(outstr);
+}
+
diff --git a/contrib/soundex/soundex.sql b/contrib/soundex/soundex.sql
new file mode 100644
index 00000000000..af8ea41fd2f
--- /dev/null
+++ b/contrib/soundex/soundex.sql
@@ -0,0 +1,57 @@
+--------------- soundex.sql:
+
+CREATE FUNCTION text_soundex(text) RETURNS text
+ AS '/usr/local/postgres/postgres95/src/funcs/soundex.so' LANGUAGE 'c';
+
+SELECT text_soundex('hello world!');
+
+CREATE TABLE s (nm text)\g
+
+insert into s values ('john')\g
+insert into s values ('joan')\g
+insert into s values ('wobbly')\g
+
+select * from s
+where text_soundex(nm) = text_soundex('john')\g
+
+select nm from s a, s b
+where text_soundex(a.nm) = text_soundex(b.nm)
+and a.oid <> b.oid\g
+
+CREATE FUNCTION text_sx_eq(text, text) RETURNS bool AS
+'select text_soundex($1) = text_soundex($2)'
+LANGUAGE 'sql'\g
+
+CREATE FUNCTION text_sx_lt(text,text) RETURNS bool AS
+'select text_soundex($1) < text_soundex($2)'
+LANGUAGE 'sql'\g
+
+CREATE FUNCTION text_sx_gt(text,text) RETURNS bool AS
+'select text_soundex($1) > text_soundex($2)'
+LANGUAGE 'sql';
+
+CREATE FUNCTION text_sx_le(text,text) RETURNS bool AS
+'select text_soundex($1) <= text_soundex($2)'
+LANGUAGE 'sql';
+
+CREATE FUNCTION text_sx_ge(text,text) RETURNS bool AS
+'select text_soundex($1) >= text_soundex($2)'
+LANGUAGE 'sql';
+
+CREATE FUNCTION text_sx_ne(text,text) RETURNS bool AS
+'select text_soundex($1) <> text_soundex($2)'
+LANGUAGE 'sql';
+
+DROP OPERATOR #= (text,text)\g
+
+CREATE OPERATOR #= (leftarg=text, rightarg=text, procedure=text_sx_eq,
+commutator=text_sx_eq)\g
+
+SELECT *
+FROM s
+WHERE text_sx_eq(nm,'john')\g
+
+SELECT *
+from s
+where s.nm #= 'john';
+
diff --git a/contrib/string/string_io.c b/contrib/string/string_io.c
new file mode 100644
index 00000000000..ab49c5321a3
--- /dev/null
+++ b/contrib/string/string_io.c
@@ -0,0 +1,361 @@
+/*
+ * string_io.c --
+ *
+ * This file defines new input/output conversion routines for strings.
+ *
+ * Copyright (c) 1996, Massimo Dal Zotto <dz@cs.unitn.it>
+ */
+
+#include <ctype.h>
+#include <string.h>
+
+#include "postgres.h"
+#include "utils/elog.h"
+#include "utils/palloc.h"
+#include "utils/builtins.h"
+
+/* define this if you want to see iso-8859 characters */
+#define ISO8859
+
+#define MIN(x, y) ((x) < (y) ? (x) : (y))
+#define VALUE(char) ((char) - '0')
+#define DIGIT(val) ((val) + '0')
+#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
+#ifndef ISO8859
+#define NOTPRINTABLE(c) (!isprint(c))
+#else
+#define NOTPRINTABLE(c) (!isprint(c) && ((c) < 0xa0))
+#endif
+
+/*
+ * string_output() --
+ *
+ * This function takes a pointer to a string data and an optional
+ * data size and returns a printable representation of the data
+ * translating all escape sequences to C-like \nnn or \c escapes.
+ * The function is used by output methods of various string types.
+ *
+ * Arguments:
+ * data - input data (can be NULL)
+ * size - optional size of data. A negative value indicates
+ * that data is a null terminated string.
+ *
+ * Returns:
+ * a pointer to a new string containing the printable
+ * representation of data.
+ */
+
+char *
+string_output(char *data, int size)
+{
+ register unsigned char c, *p, *r, *result;
+ register int l, len;
+
+ if (data == NULL) {
+ result = (char *) palloc(2);
+ result[0] = '-';
+ result[1] = '\0';
+ return (result);
+ }
+
+ if (size < 0) {
+ size = strlen(data);
+ }
+
+ /* adjust string length for escapes */
+ len = size;
+ for (p=data,l=size; l>0; p++,l--) {
+ switch (*p) {
+ case '\\':
+ case '"' :
+ case '{':
+ case '}':
+ case '\b':
+ case '\f':
+ case '\n':
+ case '\r':
+ case '\t':
+ case '\v':
+ len++;
+ break;
+ default:
+ if (NOTPRINTABLE(c)) {
+ len += 3;
+ }
+ }
+ }
+ len++;
+
+ result = (char *) palloc(len);
+
+ for (p=data,r=result,l=size; (l > 0) && (c = *p); p++,l--) {
+ switch (c) {
+ case '\\':
+ case '"' :
+ case '{':
+ case '}':
+ *r++ = '\\';
+ *r++ = c;
+ break;
+ case '\b':
+ *r++ = '\\';
+ *r++ = 'b';
+ break;
+ case '\f':
+ *r++ = '\\';
+ *r++ = 'f';
+ break;
+ case '\n':
+ *r++ = '\\';
+ *r++ = 'n';
+ break;
+ case '\r':
+ *r++ = '\\';
+ *r++ = 'r';
+ break;
+ case '\t':
+ *r++ = '\\';
+ *r++ = 't';
+ break;
+ case '\v':
+ *r++ = '\\';
+ *r++ = 'v';
+ break;
+ default:
+ if (NOTPRINTABLE(c)) {
+ *r = '\\';
+ r += 3;
+ *r-- = DIGIT(c & 07);
+ c >>= 3;
+ *r-- = DIGIT(c & 07);
+ c >>= 3;
+ *r = DIGIT(c & 03);
+ r += 3;
+ } else {
+ *r++ = c;
+ }
+ }
+ }
+ *r = '\0';
+
+ return((char *) result);
+}
+
+/*
+ * string_input() --
+ *
+ * This function accepts a C string in input and copies it into a new
+ * object allocated with palloc() translating all escape sequences.
+ * An optional header can be allocatd before the string, for example
+ * to hold the length of a varlena object.
+ * This function is not necessary for input from sql commands because
+ * the parser already does escape translation, all data input routines
+ * receive strings in internal form.
+ *
+ * Arguments:
+ * str - input string possibly with escapes
+ * size - the required size of new data. A value of 0
+ * indicates a variable size string, while a
+ * negative value indicates a variable size string
+ * of size not greater than this absolute value.
+ * hdrsize - size of an optional header to be allocated before
+ * the data. It must then be filled by the caller.
+ * rtn_size - an optional pointer to an int variable where the
+ * size of the new string is stored back.
+ *
+ * Returns:
+ * a pointer to the new string or the header.
+ */
+
+char *
+string_input(char *str, int size, int hdrsize, int *rtn_size)
+{
+ register unsigned char *p, *r;
+ unsigned char *result;
+ int len;
+
+ if ((str == NULL) || (hdrsize < 0)) {
+ return (char *) NULL;
+ }
+
+ /* Compute result size */
+ len = strlen(str);
+ for (p=str; *p; ) {
+ if (*p++ == '\\') {
+ if (ISOCTAL(*p)) {
+ if (ISOCTAL(*(p+1))) {
+ p++;
+ len--;
+ }
+ if (ISOCTAL(*(p+1))) {
+ p++;
+ len--;
+ }
+ }
+ if (*p) p++;
+ len--;
+ }
+ }
+
+ /* result has variable length */
+ if (size == 0) {
+ size = len+1;
+ } else
+
+ /* result has variable length with maximum size */
+ if (size < 0) {
+ size = MIN(len, - size)+1;
+ }
+
+ result = (char *) palloc(hdrsize+size);
+ memset(result, 0, hdrsize+size);
+ if (rtn_size) {
+ *rtn_size = size;
+ }
+
+ r = result + hdrsize;
+ for (p=str; *p; ) {
+ register unsigned char c;
+ if ((c = *p++) == '\\') {
+ switch (c = *p++) {
+ case '\0':
+ p--;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ c = VALUE(c);
+ if (isdigit(*p)) {
+ c = (c<<3) + VALUE(*p++);
+ }
+ if (isdigit(*p)) {
+ c = (c<<3) + VALUE(*p++);
+ }
+ *r++ = c;
+ break;
+ case 'b':
+ *r++ = '\b';
+ break;
+ case 'f':
+ *r++ = '\f';
+ break;
+ case 'n':
+ *r++ = '\n';
+ break;
+ case 'r':
+ *r++ = '\r';
+ break;
+ case 't':
+ *r++ = '\t';
+ break;
+ case 'v':
+ *r++ = '\v';
+ break;
+ default:
+ *r++ = c;
+ }
+ } else {
+ *r++ = c;
+ }
+ }
+
+ return((char *) result);
+}
+
+char *
+c_charout(int32 c)
+{
+ char str[2];
+
+ str[0] = (char) c;
+ str[1] = '\0';
+
+ return (string_output(str, 1));
+}
+
+char *
+c_char2out(uint16 s)
+{
+ return (string_output((char *) &s, 2));
+}
+
+char *
+c_char4out(uint32 s)
+{
+ return (string_output((char *) &s, 4));
+}
+
+char *
+c_char8out(char *s)
+{
+ return (string_output(s, 8));
+}
+
+char *
+c_char16out(char *s)
+{
+ return (string_output(s, 16));
+}
+
+/*
+ * This can be used for text, bytea, SET and unknown data types
+ */
+
+char *
+c_textout(struct varlena *vlena)
+{
+ int len = 0;
+ char *s = NULL;
+
+ if (vlena) {
+ len = VARSIZE(vlena) - VARHDRSZ;
+ s = VARDATA(vlena);
+ }
+ return (string_output(s, len));
+}
+
+/*
+ * This can be used for varchar and bpchar strings
+ */
+
+char *
+c_varcharout(char *s)
+{
+ int len;
+
+ if (s) {
+ len = *(int32*)s - 4;
+ s += 4;
+ }
+ return (string_output(s, len));
+}
+
+#ifdef 0
+struct varlena *
+c_textin(char *str)
+{
+ struct varlena *result;
+ int len;
+
+ if (str == NULL) {
+ return ((struct varlena *) NULL);
+ }
+
+ result = (struct varlena *) string_input(str, 0, VARHDRSZ, &len);
+ VARSIZE(result) = len;
+
+ return (result);
+}
+
+char *
+c_char16in(char *str)
+{
+ return (string_input(str, 16, 0, NULL));
+}
+#endif
+
diff --git a/contrib/string/string_io.sql b/contrib/string/string_io.sql
new file mode 100644
index 00000000000..011371707d5
--- /dev/null
+++ b/contrib/string/string_io.sql
@@ -0,0 +1,111 @@
+
+- - -- load the new functions
+- - --
+load '/home/dz/lib/postgres/string_output.so';
+
+- - -- create function c_textin(opaque)
+- - -- returns text
+- - -- as '/home/dz/lib/postgres/string_output.so'
+- - -- language 'c';
+
+create function c_charout(opaque)
+ returns int4
+ as '/home/dz/lib/postgres/string_output.so'
+ language 'c';
+
+create function c_char2out(opaque)
+ returns int4
+ as '/home/dz/lib/postgres/string_output.so'
+ language 'c';
+
+create function c_char4out(opaque)
+ returns int4
+ as '/home/dz/lib/postgres/string_output.so'
+ language 'c';
+
+create function c_char8out(opaque)
+ returns int4
+ as '/home/dz/lib/postgres/string_output.so'
+ language 'c';
+
+create function c_char16out(opaque)
+ returns int4
+ as '/home/dz/lib/postgres/string_output.so'
+ language 'c';
+
+create function c_textout(opaque)
+ returns int4
+ as '/home/dz/lib/postgres/string_output.so'
+ language 'c';
+
+create function c_varcharout(opaque)
+ returns int4
+ as '/home/dz/lib/postgres/string_output.so'
+ language 'c';
+
+- - -- define a function which sets the new output routines for char types
+- - --
+- - -- select c_mode();
+- - --
+create function c_mode()
+ returns text
+ as 'update pg_type set typoutput=''c_charout'' where typname=''char''\;
+ update pg_type set typoutput=''c_char2out'' where typname=''char2''\;
+ update pg_type set typoutput=''c_char4out'' where typname=''char4''\;
+ update pg_type set typoutput=''c_char8out'' where typname=''char8''\;
+ update pg_type set typoutput=''c_char16out'' where typname=''char16''\;
+ update pg_type set typoutput=''c_textout'' where typname=''text''\;
+ update pg_type set typoutput=''c_textout'' where typname=''bytea''\;
+ update pg_type set typoutput=''c_textout'' where typname=''unknown''\;
+ update pg_type set typoutput=''c_textout'' where typname=''SET''\;
+ update pg_type set typoutput=''c_varcharout'' where typname=''varchar''\;
+ update pg_type set typoutput=''c_varcharout'' where typname=''bpchar''\;
+ select ''c_mode''::text'
+ language 'sql';
+
+- - -- define a function which restores the original routines for char types
+- - --
+- - -- select pg_mode();
+- - --
+create function pg_mode()
+ returns text
+ as 'update pg_type set typoutput=''charout'' where typname=''char''\;
+ update pg_type set typoutput=''char2out'' where typname=''char2''\;
+ update pg_type set typoutput=''char4out'' where typname=''char4''\;
+ update pg_type set typoutput=''char8out'' where typname=''char8''\;
+ update pg_type set typoutput=''char16out'' where typname=''char16''\;
+ update pg_type set typoutput=''textout'' where typname=''text''\;
+ update pg_type set typoutput=''textout'' where typname=''bytea''\;
+ update pg_type set typoutput=''textout'' where typname=''unknown''\;
+ update pg_type set typoutput=''textout'' where typname=''SET''\;
+ update pg_type set typoutput=''varcharout'' where typname=''varchar''\;
+ update pg_type set typoutput=''varcharout'' where typname=''bpchar''\;
+ select ''pg_mode''::text'
+ language 'sql';
+
+- - -- or do the changes manually
+- - --
+- - -- update pg_type set typoutput='charout' where typname='char';
+- - -- update pg_type set typoutput='char2out' where typname='char2';
+- - -- update pg_type set typoutput='char4out' where typname='char4';
+- - -- update pg_type set typoutput='char8out' where typname='char8';
+- - -- update pg_type set typoutput='char16out' where typname='char16';
+- - -- update pg_type set typoutput='textout' where typname='text';
+- - -- update pg_type set typoutput='textout' where typname='bytea';
+- - -- update pg_type set typoutput='textout' where typname='unknown';
+- - -- update pg_type set typoutput='textout' where typname='SET';
+- - -- update pg_type set typoutput='varcharout' where typname='varchar';
+- - -- update pg_type set typoutput='varcharout' where typname='bpchar';
+- - --
+- - -- update pg_type set typoutput='c_charout' where typname='char';
+- - -- update pg_type set typoutput='c_char2out' where typname='char2';
+- - -- update pg_type set typoutput='c_char4out' where typname='char4';
+- - -- update pg_type set typoutput='c_char8out' where typname='char8';
+- - -- update pg_type set typoutput='c_char16out' where typname='char16';
+- - -- update pg_type set typoutput='c_textout' where typname='text';
+- - -- update pg_type set typoutput='c_textout' where typname='bytea';
+- - -- update pg_type set typoutput='c_textout' where typname='unknown';
+- - -- update pg_type set typoutput='c_textout' where typname='SET';
+- - -- update pg_type set typoutput='c_varcharout' where typname='varchar';
+- - -- update pg_type set typoutput='c_varcharout' where typname='bpchar';
+
diff --git a/contrib/zap_ltv/README b/contrib/zap_ltv/README
new file mode 100644
index 00000000000..22559e85836
--- /dev/null
+++ b/contrib/zap_ltv/README
@@ -0,0 +1,180 @@
+From ccshag@cclabs.missouri.edu Wed Jul 10 04:27:16 1996
+Received: from realtime.cc.missouri.edu (realtime.cc.missouri.edu [128.206.212.69]) by ki.net (8.7.5/8.7.5) with ESMTP id EAA12722 for <scrappy@ki.net>; Wed, 10 Jul 1996 04:27:13 -0400 (EDT)
+Received: from localhost (ccshag@localhost) by realtime.cc.missouri.edu (8.7.1/8.7.1) with SMTP id DAA00915; Wed, 10 Jul 1996 03:26:42 -0500 (CDT)
+X-Authentication-Warning: realtime.cc.missouri.edu: ccshag owned process doing -bs
+Date: Wed, 10 Jul 1996 03:26:41 -0500 (CDT)
+From: "Paul 'Shag' Walmsley" <ccshag@cclabs.missouri.edu>
+Sender: ccshag@cclabs.missouri.edu
+To: postgres95-hackers@oozoo.vnet.net
+cc: pixel@tiger.coe.missouri.edu, michael.siebenborn@ae3.Hypo.DE,
+ scrappy@ki.net
+Subject: Workaround for database corruption problems [long]
+Message-ID: <Pine.SGI.3.93.960710023021.673B-100000@realtime.cc.missouri.edu>
+X-Disclaimer: The opinions of this writer do not necessarily represent those of the University of Missouri-Columbia.
+MIME-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+Status: RO
+X-Status:
+
+
+I've been poking through the guts of POSTGRES95 in pursuit of the
+previously-mentioned "database corruption" problem, and I think that I
+have some preliminary answers and a workaround for people to play around
+with.
+
+Specifically, the problem that I'm referring to is manifested by
+pg_log, pg_time, or pg_variable either growing to huge sizes (usually
+128MB) or showing evidence of internal corruption. Symptoms that appear
+to the user include receiving messages like the following in psql or
+monitor:
+ "WARN:cannot open segment 1 of relation pg_time"
+ "WARN:cannot write block 16384 of pg_log"
+.. which are followed up in a 'postmaster -d 3' debug log by a
+ "NOTICE:AbortTransaction and not in in-progress state"
+
+It's been my experience that this problem is difficult to reproduce on
+demand; I've tried several different ways and haven't succeeded. (If
+anyone knows how to reliably reproduce this, please E-mail me.) I was,
+however, able to obtain a database in a corrupted state from one of the
+fellows on campus here running POSTGRES95; and following is something of a
+post-mortem.
+
+----------
+The problem with the database is that after any query, POSTGRES95 attempts
+to generate a huge pg_log file and fails (running out of disk space) with
+a "WARN:cannot write block 16384 of pg_log" message. The contents of the
+database and its internal structure were reasonably intact - I discovered
+that I was able to execute a single SQL query per-backend, and could
+therefore back the contents of the database up with a COPY command. (I
+wasn't able to use pg_dump; it failed on its BEGIN TRANSACTION step.)
+Inspection of data/pg_log, data/pg_variable, and data/pg_time revealed the
+following;
+
+realtime /usr/postgres95 > od -x data/pg_log.old | head
+0000000 0060 2000 2000 2000 f680 0000 ed00 0000
+0000020 e300 0000 dc00 0000 ce00 0000 bc00 0000
+0000040 b140 0000 a740 0000 9dc0 0000 9180 0000
+0000060 8580 0000 7c80 0000 6fc0 0000 6480 0000
+0000100 58c0 0000 4fc0 0000 4640 0000 3a80 0000
+0000120 30c0 0000 23c0 0000 1900 0000 0c40 0000
+0000140 0000 0000 0000 0000 0000 0000 0000 0000
+*
+0000200 8800 0000 0000 0000 0800 0000 0000 0000
+0000220 0800 0000 0000 0000 0800 0000 0000 0000
+
+
+Now, already something is obviously wrong: pg_log shouldn't have any
+values other than 0, 1, 2, 4, 8, a, c, or e for each nybble (see the XID_
+... definitions in src/backend/access/transam.h:35; two of these can be
+stored per nybble.)
+
+
+realtime /usr/postgres95 > od -x data/pg_variable.old | head
+0000000 0058 2000 2000 2740 f240 0000 e400 0000
+0000020 d780 0000 cac0 0000 b840 0000 a900 0000
+0000040 9f80 0000 9280 0000 8580 0000 78c0 0000
+0000060 6c80 0000 6200 0000 5800 0000 4f80 0000
+0000100 44c0 0000 39c0 0000 2d80 0000 2600 0000
+0000120 1c00 0000 0e00 0000 0000 0000 0000 0000
+0000140 0000 0000 0000 0000 0000 0000 0000 0000
+*
+0000700 0000 01bc 0000 009c 0014 ffff ffff 0000
+0000720 0004 5f0b 0000 0000 0000 0ba3 0000 0c23
+
+
+This is obviously broken too; the only bytes that should be non-zero in
+pg_variable are the first 16 (see src/backend/access/transam.h:99).
+
+
+realtime /usr/postgres95 > od -x data/pg_time.old | head -10
+0000000 0000 0000 0000 0000 0000 0000 0000 0000
+*
+0004000 31c6 09ae 0000 0000 31c6 09b3 31a9 79a6
+0004020 31a9 79a6 31a9 79a8 31a9 79a9 31a9 79a9
+0004040 31a9 79a9 31a9 79aa 31a9 79aa 31a9 79aa
+0004060 31a9 79aa 31a9 79aa 31a9 79ab 31a9 79ab
+0004100 31a9 79ab 31a9 79ac 31a9 79ac 31a9 79ac
+0004120 31a9 79ac 31a9 79ad 31a9 79ad 31a9 79ae
+0004140 31a9 79ae 31a9 79af 31a9 79af 31a9 79af
+0004160 31a9 79b0 31a9 79b0 31a9 79b4 31a9 79b4
+realtime /usr/postgres95 > od -x data/pg_time.old +32b | head -10
+0032000 6665 6520 666f 7220 31c5 cb61 696e 6720
+0032020 6465 7665 6c6f 7065 7273 2062 7579 2061
+0032040 206c 6f77 2d69 6e63 6f6d 6520 6170 6172
+0032060 746d 656e 7420 636f 6d70 6c65 7869 6e20
+0032100 7468 6520 7472 6561 7375 7265 7227 7320
+0032120 7761 7264 2066 726f 6d20 7468 6520 6665
+0032140 6465 7261 6c20 676f 7665 726e 6d65 6e74
+0032160 2066 6f72 2024 313b 2064 6576 656c 6f70
+0032200 6572 7361 6c73 6f20 31c5 cb7c 31be 91a2
+0032220 31be 91a2 31be 91a2 31be 91a2 31be 91a3
+
+The first part of pg_time looked okay -- filled with 4-byte time values
+with the occasional "00 00 00 00" here and there -- but inspection into
+pg_time's guts revealed some preposterous numbers.
+
+For your comparing pleasure, I include copies of what these files
+_should_ look like -- more or less -- from a newly initdb'd database
+directory:
+
+realtime /usr/postgres95 > od -x data-new-initdb/pg_log
+0000000 0000 0000 0000 0000 0000 0000 0000 0000
+*
+0000200 8aaa aaaa aaaa aaa8 0000 0000 0000 0000
+0000220 0000 0000 0000 0000 0000 0000 0000 0000
+*
+0020000
+realtime /usr/postgres95 > od -x data-new-initdb/pg_variable
+0000000 0000 0000 0000 0222 0000 021e 0000 5120
+0000020 0000 0000 0000 0000 0000 0000 0000 0000
+*
+0020000
+realtime /usr/postgres95 > od -x data-new-initdb/pg_time
+0000000 0000 0000 0000 0000 0000 0000 0000 0000
+*
+0004000 31e3 4fb3 0000 0000 31e3 4fb4 31e3 4fb4
+0004020 31e3 4fb4 31e3 4fb5 31e3 4fb5 31e3 4fb5
+0004040 31e3 4fb6 31e3 4fb6 31e3 4fb6 31e3 4fb6
+0004060 31e3 4fb7 31e3 4fb7 31e3 4fb7 31e3 4fb7
+0004100 31e3 4fb8 31e3 4fb8 31e3 4fb8 31e3 4fb9
+0004120 31e3 4fb9 31e3 4fb9 31e3 4fb9 31e3 4fba
+0004140 31e3 4fba 31e3 4fba 31e3 4fbb 31e3 4fbb
+0004160 31e3 4fbb 31e3 4fbb 31e3 4fbb 0000 0000
+0004200 0000 0000 0000 0000 0000 0000 0000 0000
+*
+0020000
+
+
+What's more, if I view pg_log, pg_variable, and pg_time with a text
+editor, I discover that the corrupted areas contain fragments of tuples
+from the database!
+----------
+
+
+Since I have been unable to reproduce this problem on demand (and
+therefore have a complete picture of all of the queries executed on the
+database), I've only been able to speculate on the original cause of the
+problem. One explanation would be some kind of buffer manager bug; or
+perhaps the backend is running low on file descriptors and bollixing
+existing ones? I intend to continue tracking this down as I have the
+time, but in the interim, I've created a quick Perl script that is
+designed to restore some sense of rationality to the
+pg_{log,time,variable} files. It's a horribly barbaric way to do this --
+at the very least, it almost certainly breaks time travel, and will
+almost certainly result in duplicate oid problems -- but it restored my
+pathological database here to a sufficiently working state such that I
+could run pg_dump on it and do various other queries with it. The script
+is included at the bottom of this message.
+
+Anyway, fellow posthackers, assuming that no one raises any red flags
+about this, I'll post it on postgres95@oozoo.vnet.net as a temporary
+stop-gap workaround to allow people to recover their databases when this
+sort of problem occurs.
+
+I wish I had more time to do this kind of thing.
+
+
+- Paul "Shag" Walmsley <ccshag@cclabs.missouri.edu>
+ "Knowing is not enough." -- Hal Hartley, "Surviving Desire"
+
+
diff --git a/contrib/zap_ltv/zap_ltv.pl b/contrib/zap_ltv/zap_ltv.pl
new file mode 100644
index 00000000000..d3709ffb93d
--- /dev/null
+++ b/contrib/zap_ltv/zap_ltv.pl
@@ -0,0 +1,93 @@
+#!/bin/perl
+#
+# zap_ltv - attempt to restore a POSTGRES95 database afflicted with
+# pg_log, pg_time, or pg_variable corruption to
+# minimal functionality
+#
+# Paul Walmsley <ccshag@cclabs.missouri.edu>
+#
+# Legalese:
+#
+# In no event shall Paul Walmsley be liable to any party for direct,
+# indirect, special, incidental, or consequential damages, including
+# lost profits, arising from the use of this software, even if Paul Walmsley
+# has been advised of the possibility of such damage. Paul Walmsley
+# 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 Paul Walmsley has no obligations to provide maintenance, support,
+# updates, enhancements, or modifications.
+#
+# Thanks, Berkeley ;-)
+
+print "This program should only be run if POSTGRES95 is not currently\n";
+print "running on this system. It should also not be run unless you \n";
+print "are having seemingly unrecoverable problems with your POSTGRES95\n";
+print "database related to pg_log, pg_time, or pg_variable corruption.\n\n";
+print "This program replaces the existing pg_log, pg_time, and pg_variable\n";
+print "files with \"clean\" copies of those files. This will almost \n";
+print "certainly result in duplicate IDs when any INSERTs are attempted,\n";
+print "and probably has other side-effects as well. Back up your databases\n"
+print "and re-initdb from scratch after using this!\n\n";
+print "This program will attempt to make a backup of your pg_time,\n";
+print "pg_log, and pg_variable files (to pg_time.backup, pg_log.backup,\n";
+print "and pg_variable.backup, respectively).\n\n";
+print "This program bears no guarantees nor any warranties whatsoever.\n";
+print "View the source for details.\n\n";
+print "Press ENTER to zap your pg_log, pg_time, and pg_variable files:";
+
+$trash=<STDIN>;
+
+$pg_log_data=pack('xxxx@8192',0);
+$pg_time_data=pack('xxxx@8192',0);
+# next_tid, last_tid, and oid are pulled from a fresh initdb
+$pg_variable_data=pack('xxxxxxCCxxCCxxCC@8192',2,34,2,30,81,32);
+
+if (length($pg_log_data)!=8192) {
+ die "pg_log_data must be exactly 8192 bytes long";
+}
+if (length($pg_time_data)!=8192) {
+ die "pg_time_data must be exactly 8192 bytes long";
+}
+if (length($pg_variable_data)!=8192) {
+ die "pg_variable_data must be exactly 8192 bytes long";
+}
+
+
+if (! -f 'pg_database') {
+ die "This program must be run from your POSTGRES95 data directory.";
+}
+
+system('cp pg_log pg_log.backup');
+open(PG_LOG,'>pg_log');
+binmode(PG_LOG);
+$written=syswrite(PG_LOG,$pg_log_data,8192);
+close(PG_LOG);
+
+if ($written!=8192) {
+ die "pg_log write failed: $!";
+}
+
+$written=0;
+system('cp pg_time pg_time.backup');
+open(PG_TIME,'>pg_time');
+binmode(PG_TIME);
+$written=syswrite(PG_TIME,$pg_time_data,8192);
+close(PG_TIME);
+
+if ($written!=8192) {
+ die "pg_time write failed: $!";
+}
+
+$written=0;
+system('cp pg_variable pg_variable.backup');
+open(PG_VARIABLE,'>pg_variable');
+binmode(PG_VARIABLE);
+$written=syswrite(PG_VARIABLE,$pg_variable_data,8192);
+close(PG_VARIABLE);
+
+if ($written!=8192) {
+ die "pg_variable write failed: $!";
+}
+
+print "Done.\n";
diff --git a/doc/1.0_to_1.01.sql b/doc/1.0_to_1.01.sql
new file mode 100644
index 00000000000..e136c83920d
--- /dev/null
+++ b/doc/1.0_to_1.01.sql
@@ -0,0 +1,44 @@
+-- add builtin functions that are new to 1.01
+
+create function int4eqoid (int4, oid) returns bool as 'foo'
+language 'internal';
+create function oideqint4 (oid, int4) returns bool as 'foo'
+language 'internal';
+create function char2icregexeq (char2, text) returns bool as 'foo'
+language 'internal';
+create function char2icregexne (char2, text) returns bool as 'foo'
+language 'internal';
+create function char4icregexeq (char4, text) returns bool as 'foo'
+language 'internal';
+create function char4icregexne (char4, text) returns bool as 'foo'
+language 'internal';
+create function char8icregexeq (char8, text) returns bool as 'foo'
+language 'internal';
+create function char8icregexne (char8, text) returns bool as 'foo'
+language 'internal';
+create function char16icregexeq (char16, text) returns bool as 'foo'
+language 'internal';
+create function char16icregexne (char16, text) returns bool as 'foo'
+language 'internal';
+create function texticregexeq (text, text) returns bool as 'foo'
+language 'internal';
+create function texticregexne (text, text) returns bool as 'foo'
+language 'internal';
+
+-- add builtin functions that are new to 1.01
+
+create operator = (leftarg = int4, rightarg = oid, procedure = int4eqoid);
+create operator = (leftarg = oid, rightarg = int4, procedure = oideqint4);
+create operator ~* (leftarg = char2, rightarg = text, procedure = char2icregexeq);
+create operator !~* (leftarg = char2, rightarg = text, procedure = char2icregexne);
+create operator ~* (leftarg = char4, rightarg = text, procedure = char4icregexeq);
+create operator !~* (leftarg = char4, rightarg = text, procedure = char4icregexne);
+create operator ~* (leftarg = char8, rightarg = text, procedure = char8icregexeq);
+create operator !~* (leftarg = char8, rightarg = text, procedure = char8icregexne);
+create operator ~* (leftarg = char16, rightarg = text, procedure = char16icregexeq);
+create operator !~* (leftarg = char16, rightarg = text, procedure = char16icregexne);
+create operator ~* (leftarg = text, rightarg = text, procedure = texticregexeq);
+create operator !~* (leftarg = text, rightarg = text, procedure = texticregexne);
+
+
+
diff --git a/doc/FAQ b/doc/FAQ
new file mode 100644
index 00000000000..42df6d34aa0
--- /dev/null
+++ b/doc/FAQ
@@ -0,0 +1,827 @@
+==================================================
+Frequently Asked Questions (FAQ) for Postgres95
+==================================================
+last updated: Sun Aug 11 01:35:34 EDT 1996
+
+current maintainer: Bruce Momjian (maillist@candle.pha.pa.us)
+original author: Jolly Chen (jolly@cs.berkeley.edu)
+
+changes in this version (* = modified, + = new):
+* 1.8) What documentation is available for Postgres95?
+* 3.13) What is the maximum size for a tuple?
+* 3.14) I defined indices but my queries don't seem to make use of them. Why?
+* 3.37) What is the time-warp feature and how does it relate to vacuum?
++ 3.38) How do I tune the database engine for better performace?
+
+This file is divided approximately as follows:
+1.*) General questions
+2.*) Installation questions
+3.*) Postgres95 Features questions
+4.*) Questions about extending Postgres95
+5.*) Bugs
+
+Questions answered:
+1.1) What is Postgres95?
+1.2) What does Postgres95 run on?
+1.3) Where can I get Postgres95?
+1.4) What's the copyright on Postgres95?
+1.5) Support for Postgres95
+1.6) Future releases of Postgres95
+1.7) Is there a commercial version of Postgres95?
+1.9) What version of SQL does Postgres95 use?
+1.10) Does Postgres95 work with databases from earlier versions of postgres?
+1.11) How many people use Postgres95?
+2.1) I get the error "cpp: command not found" when I try to compile
+2.2) I get 'yy_flush_buffer undefined' when I try to compile the backend
+2.3) initdb doesn't run
+2.4) when I start up the postmaster, I get
+2.5) The system seems to be confused about commas, decimal points, and
+2.6) How do I install postgres95 somewhere other than /usr/local/postgres95?
+2.7) The backend compiled successfully, but compiling libpq resulted
+ in a complaint: "libpq/pqcomm.h" not found when compiling fe-auth.c.
+2.8) Where can I find the bug fixes for postgres95?
+2.9) I can't apply the patches even though everything looks like it should
+ work.
+2.10) When I run postmaster, I get a Bad System Call core dumped message.
+2.11) I get the error message "obj/fmgr.h: No such file or directory"
+2.12) When I try to start the postmaster, I get IpcMemoryCreate errors.
+2.13) I get the strange make errors right at the beginning:
+2.14) I have changed a source file, but a recompile does not see the
+3.1) How do I specify a KEY or other constraints on a column?
+3.2) Does Postgres95 support nested subqueries?
+3.3) How do I define a unique indices?
+3.4) I've having a lot of problems with using rules.
+3.5) I can't seem to write into the middle of large objects reliably.
+3.6) Does postgres95 have a graphical user interface? A report
+3.7) How can I write client applications to Postgres95?
+3.8) How do I prevent other hosts from accessing my Postgres95
+3.9) How do I set up a pg_group?
+3.10) What is the exact difference between binary cursors and normal cursors?
+3.11) Why doesn't the != operator work?
+3.12) What is a R-tree index and what is it used for?
+3.13) What is the maximum size for a tuple?
+3.14) I defined indices but my queries don't seem to make use of them. Why?
+3.15) Are there ODBC drivers for Postgres95?
+3.16) How do I use postgres for multi-dimensional indexing (> 2 dimensions)?
+3.17) How do I do regular expression searches? case-insensitive
+ regexp searching?
+3.18) I can't access the database as the 'root' user.
+3.19) I experienced a server crash during a vacuum. How do I remove the
+ lock file?
+3.20) What is the difference between the various character types?
+3.21) In a query, how do I detect if a field is NULL?
+3.22) How do I see how the query optimizer is evaluating my query?
+3.23) How do I create a serial field?
+3.24) How do I create a multi-column index?
+3.25) What are the temp_XXX files in my database directory?
+3.26) Why are my table files not getting any smaller after a delete?
+3.27) Why can't I connect to my database from another machine?
+3.28) I get the error 'default index class unsupported' when creating an
+ index. How do I do it?
+3.29) Why does creating an index crash the backend server?
+3.30) How do I specify a decimal constant as a float8, or a string as a text?
+3.31) How do I find out what indexes or operations are defined in the
+ database?
+3.32) My database is corrupt. I can't do anything. What should I do?
+3.33) Createdb, destroydb, createuser,destroyuser don't run. Why?
+3.34) Why does 'createuser' return 'unexpected last match in input()'?
+3.35) All my servers crash under concurrent table access. Why?
+3.36) What tools are available for hooking postgres to Web pages?
+3.37) What is the time-warp feature and how does it relate to vacuum?
+3.38) How do I tune the database engine for better performace?
+4.1) I wrote a user-defined function and when I run it in psql, it
+ dumps core.
+4.2) I get messages of the type NOTICE:PortalHeapMemoryFree: 0x402251d0
+4.3) I've written some nifty new types and functions for Postgres95.
+4.4) How do I write a C function to return a tuple?
+5.1) How do I find out about bug fixes?
+5.2) How do I make a bug report?
+
+
+----------------------------------------------------------------------
+Section 1: General Questions
+----------------------------------------------------------------------
+
+1.1) What is Postgres95?
+
+ Postgres95 is an enhancement of the POSTGRES database
+ management system, a next-generation DBMS research prototype.
+ While Postgres95 retains the powerful data model and rich data
+ types of POSTGRES, it replaces the PostQuel query language with an
+ extended subset of SQL. Postgres95 is free and the complete
+ source is available.
+
+ Postgres95 development is being performed by a team of Internet
+ developers who all subscribe to the Postgres95 development mailing
+ list. The current coordinator is Marc G. Fournier (scrappy@ki.net).
+ (See below on how to join). This team is now responsible for all
+ current and future development of Postgres95.
+
+ The authors of Postgres95 1.01 were Andrew Yu and Jolly Chen.
+ Many others have contributed to the porting, testing, debugging and
+ enhancement of the code. The original Postgres code, from which
+ Postgres95 is derived, was the effort of many graduate
+ students, undergraduate students, and staff programmers
+ working under the direction of Professor Michael Stonebraker
+ at the University of California, Berkeley.
+
+1.2) What does Postgres95 run on?
+
+ The authors have compiled and tested Postgres95 on the following
+ platforms(some of these compiles require gcc 2.7.0):
+
+ - DEC Alpha AXP on OSF/1 2.0
+ - HP PA-RISC on HP-UX 9.0
+ - i386 Solaris
+ - SUN SPARC on Solaris 2.4
+ - SUN SPARC on SunOS 4.1.3
+ - DEC MIPS on Ultrix 4.4
+ - Intel x86 on Linux 1.2 and Linux ELF
+ - OSs derived from 4.4-lite BSD (NetBSD, FreeBSD)
+ - IBM on AIX 3.2.5
+ - BSD/OS 2.0, 2.01 & 2.1
+ - SGI MIPS on IRIX 5.3
+
+ The following ports are bundled with the Postgres95 distribution. The
+ authors do not have handy access to these platforms but the
+ ports have been tested by the others.
+
+ - Motorola MC68K or Intel x86 on NeXTSTEP 3.2
+ - Intel x86 on Intel SVR4
+
+1.3) Where can I get Postgres95?
+
+ The primary anonymous ftp site for postgres95 is:
+
+ ftp://ftp.ki.net/pub/postgres95
+
+ A mirror site exists at:
+
+ ftp://postgres95.vnet.net/pub/postgres95
+
+1.4) What's the copyright on Postgres95?
+
+ Postgres95 is subject to the following COPYRIGHT.
+
+POSTGRES95 Data Base Management System
+
+Copyright (c) 1994-6 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.
+
+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 MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+1.5) Support for Postgres95
+
+ There is no official support for Postgres95 from the original
+ maintainers or from University of California, Berkeley. It is
+ maintained through volunteer effort only.
+
+ With the generosity of the Jason Wright and others at Vnet,
+ the postgres95 mailing list now has a new home --
+ postgres95@postgres95.vnet.net. It is available for
+ discussion of matters pertaining to Postgres95, including but
+ not limited to bug reports and fixes. For info on how to
+ subscribe, send a mail with the lines in the body (not the
+ subject line):
+ help
+ info postgres95
+ to
+ majordomo@postgres95.vnet.net
+
+ There is also a digest list available. To subscribe to this list,
+ send email to majordomo@postgres95.vnet.net with a BODY of:
+ subscribe postgres95-digest
+ Digests are sent out to members of this list whenever the main list has
+ received around 30k of messages.
+
+ Archives and digests of the new mailing list at Vnet can be found at:
+ ftp://postgres95.vnet.net/pub/postgres95/archives
+ ftp://postgres95.vnet.net/pub/postgres95/digests
+
+ There is also a developers mailing list available. To subscribe to
+ this list, send email to pg95-dev-request@ki.net with a BODY of:
+
+ subscribe pg95-dev
+
+ Additional information about Postgres95 can be found via the
+ postgres95 WWW home page at:
+ http://www.ki.net/postgres95
+
+1.6) Future releases of Postgres95
+
+ The latest release of postgres95 is version 1.02.
+
+1.7) Is there a commercial version of Postgres95?
+
+ Illustra Information Technology (a wholly owned subsidiary of
+ Informix Software, Inc.) sells an object-relational
+ DBMS called Illustra that was originally based on postgres.
+ Illustra has cosmetic similarities to postgres95 but has more
+ features, is more robust, performs better, and offers real
+ documentation and support. On the flip side, it costs money.
+ For more information, contact sales@illustra.com
+
+1.8) What documentation is available for Postgres95?
+
+ A user manual, manual pages, and some small test examples
+ are included in the distribution. The www page contains
+ pointers to an implementation guide and five papers written
+ about postgres design concepts and features.
+
+1.9) What version of SQL does Postgres95 use?
+
+ Postgres95 supports a subset of SQL-92. It has most of the
+ important constructs but lacks some of the functionality.
+ The most visible differences are:
+ - no support for primary keys or column constraints
+ - no support for nested subqueries
+ - no HAVING clause under a GROUP BY
+
+ On the other hand, you get to create user-defined types,
+ functions, inheritance etc. If you're willing to help with
+ postgres95 coding, eventually we can also add the missing
+ features listed above.
+
+1.10) Does Postgres95 work with databases from earlier versions of postgres?
+
+ Postgres95 v1.02 is compatible with databases created with v1.01.
+ Those upgrading from 1.0 to 1.02 should read the directions in the
+ MIGRATION_1.0_TO_1.02 directory.
+
+1.11) How many people use Postgres95?
+
+ Since we don't have any licensing or registration scheme, it's
+ impossible to tell. We do know hundreds copies of postgres95
+ v1.* have been downloaded, and that there many hundreds of
+ subscribers to the mailing lists.
+
+----------------------------------------------------------------------
+Section 2: Installation Questions
+----------------------------------------------------------------------
+
+2.1) I get the error "cpp: command not found" when I try to compile
+the backend.
+
+ Edit the src/backend/utils/Gen_fmgrtab.sh script to include the path
+ for the cpp for your particular site.
+
+2.2) I get 'yy_flush_buffer undefined' when I try to compile the backend
+
+ Use a more recent version of flex, version 2.5.2. Version 2.5.3
+ has a known bug.
+
+2.3) initdb doesn't run
+
+ * check to see that you have the proper paths set
+ * check that the 'postgres' user owns all the right files
+ * ensure that there are files in $PGDATA/files, and that they
+ are non-empty. If they aren't, then "gmake install" failed for
+ some reason
+
+2.4) when I start up the postmaster, I get
+ "FindBackend: could not find a backend to execute..."
+ "postmaster: could not find backend to execute..."
+
+ You probably do not have the right path set up. the 'postgres'
+ executable needs to be in your path.
+
+2.5) The system seems to be confused about commas, decimal points, and
+date formats.
+
+ Check your locale configuration. postgres95 uses the locale
+ settings of the user that ran the postmaster process. Set those
+ accordingly for your operating environment.
+
+2.6) How do I install postgres95 somewhere other than /usr/local/postgres95?
+
+ You need to manually edit the paths in src/Makefile.global to
+ your site configuration.
+
+2.7) The backend compiled successfully, but compiling libpq resulted
+ in a complaint: "libpq/pqcomm.h" not found when compiling fe-auth.c.
+
+ You've probably installed postgres95 somewhere other than
+ /usr/local/postgres, but didn't edit the src/Makefile.global
+ accordingly. See question 2.6.
+
+2.8) Where can I find the bug fixes for postgres95?
+
+ The patches should be applied in the order listed. The patch files
+ can be ftp'ed directly from the directory:
+ ftp://ftp.ki.net/pub/postgres95
+
+2.9) I can't apply the patches even though everything looks like it should
+ work.
+
+ If you cut and paste directly off your web browser, tabs and
+ whitespaces may not be preserved properly. Use the 'save as file'
+ option from your web browser instead.
+
+2.10) When I run postmaster, I get a Bad System Call core dumped message.
+
+ It could be a variety of problems, but first check to see that you
+ have system V extensions installed on your kernel. Postgres95
+ requires kernel support for shared memory.
+
+2.11) I get the error message "obj/fmgr.h: No such file or directory"
+
+ This indicates that you did not generate the file fmgr.h
+ properly. Something failed in the running of the
+ src/backend/utils/Gen_fmgrtab.sh script. Check to see the
+ paths used in that script is appropriate to your system.
+
+2.12) When I try to start the postmaster, I get IpcMemoryCreate errors.
+
+ You either do not have shared memory configured properly in kernel
+ or you need to enlarge the shared memory available in the kernel.
+ The exact amount you need depends on your architecture and how
+ many buffers you configure postmaster to run with. For most
+ systems, with default buffer sizes, you need a minimum of ~760K.
+
+2.13) I get the strange make errors right at the beginning:
+ warning: NUL character seen; rest of line ignored
+ *** missing separator. Stop.
+ or
+ Is a directory. Stop.
+
+ Eliminate any whitespaces at the end of the PORTNAME line in
+ Makefile.global. Extraneous tabs or spaces will confuse the make
+ templates.
+
+2.14) I have changed a source file, but a recompile does not see the
+change?
+
+ The Makefiles do not have the proper dependencies. You have to
+ do a 'make clean' and then another 'make'.
+
+----------------------------------------------------------------------
+Section 3: Postgres95 Features
+----------------------------------------------------------------------
+
+3.1) How do I specify a KEY or other constraints on a column?
+
+ Column constraints are not supported in postgres95.
+ As a consequence, the system does not check for duplicates.
+
+3.2) Does Postgres95 support nested subqueries?
+
+ Subqueries are not implemented, but they can be simulated using sql
+ functions.
+
+3.3) How do I define a unique indices?
+
+ Postgres95 does not support unique indices. Defining an index does
+ not preclude insertion of duplicate index key values.
+
+3.4) I've having a lot of problems with using rules.
+
+ Currently, the rule system in postgres95 is mostly broken. It
+ works enough to support the view mechanism, but that's about it. Use
+ postgres95 rules at your own peril.
+
+3.5) I can't seem to write into the middle of large objects reliably.
+
+ The Inversion large object system in postgres95 is also
+ mostly broken. It works well enough for storing large wads
+ of data and reading them back out, but the implementation has
+ some underlying problems. Use postgres95 large objects at
+ your own peril.
+
+3.6) Does postgres95 have a graphical user interface? A report
+generator? A embedded query language interface?
+
+ No. No. No. Not in the official distribution at least. Some
+ users have reported some success at using 'pgbrowse' and 'onyx' as
+ frontends to postgres95. Several contributions are working on
+ tk based frontend tools. Ask on the mailing list.
+
+3.7) How can I write client applications to Postgres95?
+
+ Postgres95 supports a C-callable library interface called libpq
+ as well as a Tcl-based library interface called libtcl.
+
+ Others have contributed a perl interface and a WWW gateway
+ to postgres95. See the postgres95 home pages for more details.
+
+3.8) How do I prevent other hosts from accessing my Postgres95
+ backend?
+
+ Use host-based authentication by modifying the file
+ $PGDATA/pg_hba accordingly.
+
+3.9) How do I set up a pg_group?
+
+ Currently, there is no easy interface to set up user groups.
+ You have to explicitly insert/update the pg_group table. For example:
+
+ jolly=> insert into pg_group (groname, grosysid, grolist)
+ jolly=> values ('posthackers', '1234', '{5443, 8261}');
+ INSERT 548224
+ jolly=> grant insert on foo to group posthackers;
+ CHANGE
+ jolly=>
+
+ The fields in pg_group are:
+ groname: the group name. This a char16 and should
+ be purely alphanumeric. Do not include underscores
+ or other punctuation.
+ grosysid: the group id. This is an int4.
+ This should be unique for each group.
+ grolist: the list of pg_user id's that belong in the group.
+ This is an int4[].
+
+3.10) What is the exact difference between binary cursors and normal cursors?
+
+ Normal cursors return data back in ASCII format. Since data is stored
+ natively in binary format, the system must do a conversion to produce
+ the ASCII format. In addition, ASCII formats are often large in size
+ than binary format. Once the attributes come back in ASCII, often the
+ client application then has to convert it to a binary format to
+ manipulate it anyway.
+
+ Binary cursors give you back the data in the native binary
+ representation. Thus, binary cursors will tend to be a little faster
+ since there's less overhead of conversion.
+
+ However, ASCII is architectural neutral whereas binary representation
+ can differ between different machine architecture. Thus, if your client
+ machine uses a different representation than you server machine, getting
+ back attributes in binary format is probably not what you want. Also,
+ if your main purpose is displaying the data in ASCII, then getting it
+ back in ASCII will save you some effort on the client side.
+
+3.11) Why doesn't the != operator work?
+
+ SQL specifies <> as the inequality operator, and that is what
+ we have defined for the built-in types. You are free, however, to
+ extend postgres95 to include the != operator if you like.
+
+3.12) What is a R-tree index and what is it used for?
+
+ An r-tree index is used for indexing spatial data. A hash index can't
+ handle range searches. A B-tree index only handles range searches in a
+ single dimension. R-tree's can handle multi-dimensional data. For
+ example, if a R-tree index can be built on an attribute of type
+ 'point', the system can more efficient answer queries like select all
+ points within a bounding rectangle.
+
+ The canonical paper that describes the original R-Tree design is:
+
+ Guttman, A. "R-Trees: A Dynamic Index Structure for Spatial Searching."
+ Proc of the 1984 ACM SIGMOD Int'l Conf on Mgmt of Data, 45-57.
+
+ You can also find this paper in Stonebraker's "Readings in Database
+ Systems"
+
+3.13) What is the maximum size for a tuple?
+
+ Tuples are limited to 8K bytes. Taking into account system attributes
+ and other overhead, one should stay well shy of 8,000 bytes to be on
+ the safe side. To use attributes larger than 8K, try using the large
+ objects interface.
+
+ Tuples do not cross 8k boundaries so a 5k tuple will require 8k
+ of storage.
+
+3.14) I defined indices but my queries don't seem to make use of them. Why?
+
+ Postgres95 does not automatically maintain statistics. One has to
+ make an explicit 'vacuum' call to update the statistics. After
+ statistics are updated, the optimizer has a better shot at using
+ indices. Note that the optimizer is limited and does not use indices
+ in some circumstances (such as OR clauses).
+
+ If the system still does not see the index, it is probably because you
+ have created an index on a field with the improper *_ops type. For
+ example, you have created a CHAR(4) field, but have specified a
+ char_ops index type_class.
+
+ See the create_index manual page for information on what type classes
+ are available. It must match the field type.
+
+ Postgres does not warn the user when the improper index is created.
+
+ Indexes not used for ORDER BY operations.
+
+3.15) Are there ODBC drivers for Postgres95?
+
+ PostODBC is available as an ODBC driver for Postgres95.
+
+ For all people being interested in PostODBC, a freely available ODBC
+ driver for Postgres95, there are now two mailing lists devoted to the
+ discussion of PostODBC. The mailing lists are:
+
+ postodbc-users@listserv.direct.net
+ and
+ postodbc-developers@listserv.direct.net
+
+ these lists are ordinary majordomo mailing lists. You can subscribe
+ by sending a mail to
+
+ majordomo@listserv.direct.net
+
+3.16) How do I use postgres for multi-dimensional indexing (> 2 dimensions)?
+
+ Builtin R-Trees can handle polygons and boxes. In theory, R-trees can
+ be extended to handle higher number of dimensions. In practice,
+ extending R-trees require a bit of work and we don't currently have
+ any documentation on how to do it.
+
+3.17) How do I do regular expression searches? case-insensitive
+regexp searching?
+
+ Postgres95 supports the SQL LIKE syntax as well as more general
+ regular expression searching with the ~ operator. The !~ is the
+ negated regexp operator. ~* and !~* are the case-insensitive regular
+ expression operators.
+
+3.18) I can't access the database as the 'root' user.
+
+ You should not create database users with user id 0(root). They will
+ be unable to access the database. This is a security precaution
+ because of the ability of any user to dynamically link object modules
+ into the database engine.
+
+3.19) I experienced a server crash during a vacuum. How do I remove the
+lock file?
+
+ If the server crashes during a vacuum command, chances are it will
+ leave a lock file hanging around. Attempts to re-run the vacuum
+ command result in
+ WARN:can't create lock file -- another vacuum cleaner running?
+
+ If you are sure that no vacuum is actually running, you can remove the
+ file called "pg_vlock" in your database directory (which is
+ $PGDATA/base/<dbName>)
+
+3.20) What is the difference between the various character types?
+
+Type Internal Name Notes
+--------------------------------------------------
+CHAR char 1 character }
+CHAR2 char2 2 characters }
+CHAR4 char4 4 characters } optimized for a fixed length
+CHAR8 char8 8 characters }
+CHAR16 char16 16 characters }
+CHAR(#) bpchar blank padded to the specified fixed length
+VARCHAR(#) varchar size specifies maximum length, no padding
+TEXT text length limited only by maximum tuple length
+BYTEA bytea variable-length array of bytes
+
+ Remember, you need to use the internal name when creating indexes
+ on these fields or when doing other internal operations.
+
+ The last four types above are "varlena" types (i.e. the first
+ four bytes is the length, followed by the data). CHAR(#) and
+ VARCHAR(#) allocate the maximum number of bytes no matter how
+ much data is stored in the field. TEXT and BYTEA are the only
+ character types that have variable length on the disk.
+
+3.21) In a query, how do I detect if a field is NULL?
+
+ Postgres95 has two builtin keywords, "isnull" and "notnull" (note no
+ spaces). For example:
+ select * from tbl where field isnull
+ will return rows from tbl where the field is null valued.
+
+3.22) How do I see how the query optimizer is evaluating my query?
+
+ Place the word 'EXPLAIN' at the beginning of the query, for example:
+
+ EXPLAIN SELECT * FROM table1 WHERE age = 23;
+
+3.23) How do I create a serial field?
+
+ There is no way to create a serial or unique field in Postgres95. You
+ can use each row's oid field as a unique value. However, if you need
+ to dump and reload the database, you will be assigned new oid's.
+ There is no way to restore the original oids.
+
+ One valid way of doing this is to create a function:
+
+ create table my_oids (f1 int4);
+ insert into my_oids values (1);
+ create function new_oid () returns int4 as
+ 'update my_oids set f1 = f1 + 1; select f1 from my_oids; '
+ language 'sql';
+
+ then:
+
+ create table my_stuff (my_key int4, value text);
+ insert into my_stuff values (new_oid(), 'hello');
+
+ However, keep in mind there is a race condition here where one
+ server could do the update, then another one do an update, and
+ they both could select the same new id. This statement should
+ be performed within a transaction.
+
+3.24) How do I create a multi-column index?
+
+ You can not directly create a multi-column index using create index.
+ You need to define a function which acts on the multiple columns, then
+ use create index with that function.
+
+3.25) What are the temp_XXX files in my database directory?
+
+ They are temp_ files generated by the query executor. For example,
+ if a sort needs to be done to satisfy an ORDER BY, some temp files are
+ generated as a result of the sort.
+
+ If you have no transactions or sorts running at the time, it is safe to
+ delete the temp_ files.
+
+3.26) Why are my table files not getting any smaller after a delete?
+
+ If you run vacuum, unused rows will be marked for reuse, but the file
+ blocks are not released. We could move the unused rows to the end of
+ the file and use ftruncate() to decrease the file size, but no one has
+ implemented this yet.
+
+3.27) Why can't I connect to my database from another machine?
+
+ The default configuration allows only connections from tcp/ip host
+ localhost. You need to add a host entry to the file
+ postgres95/data/pg_hba.
+
+3.28) I get the error 'default index class unsupported' when creating an
+index. How do I do it?
+
+ You probably used:
+
+ create index idx1 on person using btree (name);
+
+ Postgres95 indexes are extensible, and therefore you must specify a
+ class_type when creating an index. Read the manual page for create
+ index (called create_index).
+
+3.29) Why does creating an index crash the backend server?
+
+ You have probably defined an incorrect *_ops type class for the field
+ you are indexing.
+
+3.30) How do I specify a decimal constant as a float8, or a string as a text?
+
+ Use the :: operator. It is needed only when the default promotion
+ rules fail. i.e.:
+
+ insert into tab1 values (4.23::float8, '2343'::text)
+
+3.31) How do I find out what indexes or operations are defined in the
+database?
+
+ Run the file postgres95/src/tutorial/syscat.source. It illustrates
+ many of the 'select's needed to get information out of the database
+ system tables.
+
+3.32) My database is corrupt. I can't do anything. What should I do?
+
+ The 1.02 release has a README file and utility that describes a
+ possible cause of the problem and a workaround. See the file
+ postgres95/contrib/zap_ltv/README for more information. Also
+ please contact the README author to help generate a complete
+ fix for this bug.
+
+ This bug may be fixed in 1.02.
+
+3.33) Createdb, destroydb, createuser,destroyuser don't run. Why?
+
+ Release 1.02 does not have this problem.
+
+ The 1.01 release of postgres95 uses a variable called PAGER to
+ filter the output of SELECT statements. Unfortunately, this
+ PAGER is used even when the standard output is not a terminal.
+ Upgrade to 1.02, due out August 1996, or undefine your PAGER
+ variable. There is also a patch located in the July archives of
+ the mailing list that fixes this problem on 1.01.
+
+3.34) Why does 'createuser' return 'unexpected last match in input()'?
+
+ You have compile postgres with flex version 2.5.3. There is bug
+ in this version of flex. Use flex version 2.5.2 instead. There
+ is a doc/README.flex file which will properly patch the flex 2.5.3
+ source code.
+
+3.35) All my servers crash under concurrent table access. Why?
+
+ This problem can be caused by a kernel that is not configured to
+ support semaphores.
+
+3.36) What tools are available for hooking postgres to Web pages?
+
+ For web integration, PHP/FI is an excellent interface. The URL for
+ that is http://www.vex.net/php/
+
+ PHP is great for simple stuff, but for more complex stuff, some
+ still use the perl interface and CGI.pm.
+
+ An example of using WWW with C to talk to Postgres is can be
+ tried at:
+
+ http://www.ki.net/~mlc
+
+3.37) What is the time-warp feature and how does it relate to vacuum?
+
+ Postgres95 handles data changes differently than most database
+ systems. When a row is changed in a table, the original row
+ is marked with the time it was changed, and a new row is created
+ with the current data. By default, only current rows are used
+ in a table. If you specify a date/time after the table name in
+ a FROM clause, you can access the data that was current at that
+ time, i.e.
+
+ SELECT *
+ FROM employees ['July 24, 1996 09:00:00']
+
+ displays employee rows in the table at the specified time.
+ You can specify intervals like [date,date], [date,], [,date],
+ or [,]. This last option accesses all rows that ever existed.
+
+ INSERTed rows get a timestamp too, so rows that were not in
+ the table at the desired time will not appear.
+
+ Vacuum removes rows that are no longer current. This time-warp
+ feature is used by the engine for rollback and crash recovery.
+
+3.38) How do I tune the database engine for better performace?
+
+ There are two things that can be done. You can use Openlink's
+ option to disable fsync() by starting the postmaster with a
+ '-o -F' option. This will prevent fsync()'s from flushing to
+ disk after every transaction.
+
+ You can also use the postmaster -B option to increase the number
+ of shared memory buffers shared among the backend processes. If
+ you make this parameter too high, the process will not start or
+ crash unexpectedly. Each buffer is 8K and the defualt is 64
+ buffers.
+
+
+
+----------------------------------------------------------------------
+Section 4: Extending Postgres95
+----------------------------------------------------------------------
+
+4.1) I wrote a user-defined function and when I run it in psql, it
+dumps core.
+
+ The problem could be a number of things. Try testing your
+ user-defined function in a stand alone test program first.
+ Also, make sure you are not sending elog NOTICES when the front-end
+ is expecting data, such as during a type_in() or type_out()
+ functions
+
+4.2) I get messages of the type
+ NOTICE:PortalHeapMemoryFree: 0x402251d0 not in alloc set!
+
+ You are pfree'ing something that was not palloc'ed. When writing
+ user-defined functions, do not include the file
+ "libpq-fe.h". Doing so will cause your palloc to be a malloc
+ instead of a free. Then, when the backend pfrees the storage,
+ you get the notice message.
+
+4.3) I've written some nifty new types and functions for Postgres95.
+
+ Please share them with other postgres95 users. Send your
+ extensions to mailing list, and they will eventually end up in
+ the contrib/ subdirectory.
+
+4.4) How do I write a C function to return a tuple?
+
+ This requires extreme wizardry, so extreme that the authors
+ have not ever tried it, though in principle it can be done.
+ The short answer is ... you can't. This capability is
+ forthcoming in the future.
+
+----------------------------------------------------------------------
+Section 5: Bugs
+----------------------------------------------------------------------
+
+5.1) How do I find out about bug fixes?
+
+ The directory ftp.ki.net:/pub/postgres95 contains patches for
+ the latest release.
+
+5.2) How do I make a bug report?
+
+ First, check to see that your bug is not one that has already
+ been fixed (question 5.1). Then, fill out the "bug-template"
+ file and send it to:
+
+ pg95-dev@ki.net
+
+ This is the address of the developers mailing list.
+
diff --git a/doc/MIGRATION_from_1.0_to_1.01 b/doc/MIGRATION_from_1.0_to_1.01
new file mode 100644
index 00000000000..324184c3572
--- /dev/null
+++ b/doc/MIGRATION_from_1.0_to_1.01
@@ -0,0 +1,50 @@
+The following notes are for the benefit of users who want to migrate
+databases from postgres95 1.0 to postgres95 1.01.
+
+If you are starting afresh with postgres95 1.01 and do not need
+to migrate old databases, you do not need to read any further.
+
+----------------------------------------------------------------------
+
+In order to postgres95 version 1.01 with databases created with
+postgres95 version 1.0, the following steps are required:
+
+1) Set the definition of NAMEDATALEN in src/Makefile.global to 16
+ and OIDNAMELEN to 20.
+
+2) Decide whether you want to use Host based authentication.
+
+ A) If you do, you must create a file name "pg_hba" in your top-level data
+ directory (typically the value of your $PGDATA). src/libpq/pg_hba
+ shows an example syntax.
+
+ B) If you do not want host-based authentication, you can comment out
+ the line
+ HBA = 1
+ in src/Makefile.global
+
+ Note that host-based authentication is turned on by default, and if
+ you do not take steps A or B above, the out-of-the-box 1.01 will
+ not allow you to connect to 1.0 databases.
+
+3) compile and install 1.01, but DO NOT do the initdb step.
+
+4) before doing anything else, terminate your 1.0 postmaster, and
+ backup your existing $PGDATA directory.
+
+5) set your PGDATA environment variable to your 1.0 databases, but set up
+ path up so that 1.01 binaries are being used.
+
+6) modify the file $PGDATA/PG_VERSION from 5.0 to 5.1
+
+7) start up a new 1.01 postmaster
+
+5) Add the new built-in functions and operators of 1.01 to 1.0
+ databases. This is done by running the new 1.01 server against
+ your own 1.0 database and applying the queries in the file
+ 1.0_to_1.01.sql. This can be done easily through psql. If your
+ 1.0 database is name "testdb":
+
+ % psql testdb -f 1.0_to_1.01.sql
+
+
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 00000000000..829a64dadcd
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,32 @@
+#-------------------------------------------------------------------------
+#
+# Makefile
+# Makefile for doc directory to install man pages
+#
+# Copyright (c) 1994, Regents of the University of California
+# Copyright (c) 1996, Dr George D Detlefsen
+#
+#
+# IDENTIFICATION
+# $Header: /cvsroot/pgsql/doc/Makefile,v 1.1.1.1 1996/08/18 22:14:17 scrappy Exp $
+#
+#-------------------------------------------------------------------------
+
+MKDIR= ../src/mk
+include $(MKDIR)/postgres.mk
+
+CLEANFILES=*
+
+install-man:
+ -mkdir -p $(POSTMANDIR)
+ -mkdir $(POSTMANDIR)/man1
+ -mkdir $(POSTMANDIR)/man3
+ -mkdir $(POSTMANDIR)/man5
+ -mkdir $(POSTMANDIR)/manl
+ cp man/*.1* $(POSTMANDIR)/man1
+ cp man/*.3* $(POSTMANDIR)/man3
+ cp man/*.5* $(POSTMANDIR)/man5
+ cp man/*.l* $(POSTMANDIR)/manl
+
+install:: install-man
+
diff --git a/doc/README.OPENLINK b/doc/README.OPENLINK
new file mode 100644
index 00000000000..3a522672166
--- /dev/null
+++ b/doc/README.OPENLINK
@@ -0,0 +1,28 @@
+varchar.diff
+------------
+This patch was necessary for the OpenLink Postgres Database Agent.
+I think this fixes a bug anyway.
+
+The following query demonstrates this bug:
+
+ create table foo (bar varchar);
+ insert into foo values (''); -- no problem
+ select * from foo where bar = ''; -- fails
+
+
+fsync.diff
+----------
+This patch adds an option to disable synchronous writes.
+It adds an extra option to postgres: -F
+
+When started with -F, all fsync() calls will be no-ops,
+so you'll be in big trouble when your machine suddenly crashes and your disk
+cache is not flushed.
+
+Use at your own risk (but it is *much* faster with large inserts)
+
+This also speeds up initdb for initial database bootstrapping
+
+To start postmaster with this "feature" enabled, type
+ postmaster -o -F -S
+
diff --git a/doc/README.flex b/doc/README.flex
new file mode 100644
index 00000000000..ab3c34948fd
--- /dev/null
+++ b/doc/README.flex
@@ -0,0 +1,147 @@
+From: ernst.molitor@uni-bonn.de
+
+Hi,
+
+thank you for the latest Postgres95 distribution!
+
+>does the createuser bug still persist, or have
+>we finally worked that one out?
+
+As has been indication by Bruce Momjian, the createuser problem was
+caused by a bug in flex 2.5.3 (which has been confirmed by Vern
+Paxson, the flex maintainer - many thanks to them); the bug will be
+fixed in flex 2.5.4. Vern Paxson has been so kind as to supply me with
+a patch that will be part of the 2.5.4 release; I'm including it below
+in case someone has installed flex 2.5.3 and doesn't want to go
+back to 2.5.2...
+
+Regards,
+
+Ernst
+---
+*** flex-2.5.3/flex.skl Sat May 25 21:02:33 1996
+--- flex.skl Tue Jul 2 16:35:49 1996
+***************
+*** 1,7 ****
+ /* A lexical scanner generated by flex */
+
+ /* Scanner skeleton version:
+! * $Header: /cvsroot/pgsql/doc/Attic/README.flex,v 1.1.1.1 1996/08/18 22:14:17 scrappy Exp $
+ */
+
+ #define FLEX_SCANNER
+--- 1,7 ----
+ /* A lexical scanner generated by flex */
+
+ /* Scanner skeleton version:
+! * $Header: /cvsroot/pgsql/doc/Attic/README.flex,v 1.1.1.1 1996/08/18 22:14:17 scrappy Exp $
+ */
+
+ #define FLEX_SCANNER
+***************
+*** 783,789 ****
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+! yy_n_chars = 0;
+
+ else
+ {
+--- 783,789 ----
+ /* don't do the read, it's not guaranteed to return an EOF,
+ * just force an EOF
+ */
+! yy_current_buffer->yy_n_chars = yy_n_chars = 0;
+
+ else
+ {
+***************
+*** 838,843 ****
+--- 838,845 ----
+ /* Read in more data. */
+ YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
+ yy_n_chars, num_to_read );
++
++ yy_current_buffer->yy_n_chars = yy_n_chars;
+ }
+
+ if ( yy_n_chars == 0 )
+***************
+*** 947,953 ****
+
+ yy_cp += (int) (dest - source);
+ yy_bp += (int) (dest - source);
+! yy_n_chars = yy_current_buffer->yy_buf_size;
+
+ if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
+--- 949,956 ----
+
+ yy_cp += (int) (dest - source);
+ yy_bp += (int) (dest - source);
+! yy_current_buffer->yy_n_chars =
+! yy_n_chars = yy_current_buffer->yy_buf_size;
+
+ if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
+***************
+*** 997,1009 ****
+
+ switch ( yy_get_next_buffer() )
+ {
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap() )
+- {
+- yy_c_buf_p = yytext_ptr + offset;
+ return EOF;
+- }
+
+ if ( ! yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+--- 1000,1025 ----
+
+ switch ( yy_get_next_buffer() )
+ {
++ case EOB_ACT_LAST_MATCH:
++ /* This happens because yy_g_n_b()
++ * sees that we've accumulated a
++ * token and flags that we need to
++ * try matching the token before
++ * proceeding. But for input(),
++ * there's no matching to consider.
++ * So convert the EOB_ACT_LAST_MATCH
++ * to EOB_ACT_END_OF_FILE.
++ */
++
++ /* Reset buffer status. */
++ yyrestart( yyin );
++
++ /* fall through */
++
+ case EOB_ACT_END_OF_FILE:
+ {
+ if ( yywrap() )
+ return EOF;
+
+ if ( ! yy_did_buffer_switch_on_eof )
+ YY_NEW_FILE;
+***************
+*** 1017,1031 ****
+ case EOB_ACT_CONTINUE_SCAN:
+ yy_c_buf_p = yytext_ptr + offset;
+ break;
+-
+- case EOB_ACT_LAST_MATCH:
+- #ifdef __cplusplus
+- YY_FATAL_ERROR(
+- "unexpected last match in yyinput()" );
+- #else
+- YY_FATAL_ERROR(
+- "unexpected last match in input()" );
+- #endif
+ }
+ }
+ }
+--- 1033,1038 ----
+
diff --git a/doc/README.support b/doc/README.support
new file mode 100644
index 00000000000..754b6caa123
--- /dev/null
+++ b/doc/README.support
@@ -0,0 +1,35 @@
+
+In order to co-ordinate both usage and development of Postgres95,
+there are currently two mailing lists available:
+
+
+General Discussion
+ - mainly geared towards usage of PostGres95 and associated
+ support & third-party software
+
+ - send a message of subscribe to postgres95-request@postgres95.vnet.net
+
+ - a digest version of this list is available. To subscribe, send
+ a message of subscribe to:
+ postgres95-digest-request@postgres95.vnet.net
+
+ - archives and back issues of these lists are stored on:
+ ftp://postgres95.vnet.net/pub/postgres95/archives
+ ftp://postgres95.vnet.net/pub/postgres95/digests
+
+Developers Mailling List
+ - those wishing to help improve Postgres95 and further develop it
+
+ - send a message of subscribe to pg95-dev-request@ki.net
+
+
+WWW: http://www.ki.net/postgres95
+FTP: ftp://ftp.ki.net/pub/postgres95
+
+ The current source tree, with all patches installed, is available
+via sup @ sup.ki.net, or in a .tar.gz file available at:
+
+ ftp://ftp.ki.net/pub/postgres95
+
+
+
diff --git a/doc/RELEASE.patchlevel b/doc/RELEASE.patchlevel
new file mode 100644
index 00000000000..29b1518c672
--- /dev/null
+++ b/doc/RELEASE.patchlevel
@@ -0,0 +1,24 @@
+From scrappy@ki.net Thu Aug 1 13:39:58 1996
+Status: RO
+X-Status:
+Received: from daemun.ilt.com ([204.247.102.21]) by ki.net (8.7.5/8.7.5) with ESMTP id NAA16984 for <scrappy@ki.net>; Thu, 1 Aug 1996 13:39:51 -0400 (EDT)
+From: postgres@madmax.ilt.com
+Received: from madmax.ilt.com (madmax [199.26.203.43]) by daemun.ilt.com (8.7.5/8.7.3) with SMTP id KAA02799 for <scrappy@ki.net>; Thu, 1 Aug 1996 10:39:31 -0700 (PDT)
+Received: by madmax.ilt.com (SMI-8.6/ILT-SVR4-1.1)
+ id KAA19226; Thu, 1 Aug 1996 10:34:46 -0700
+Date: Thu, 1 Aug 1996 10:34:46 -0700
+Message-Id: <199608011734.KAA19226@madmax.ilt.com>
+To: scrappy@ki.net
+Subject: RELEASE.patchlevel
+
+## Postgres95
+##
+## This file is used to maintain sequencing of patches
+
+version: 1.02
+patch level: 0
+patch date: Thu Aug 1 18:00:00 EDT 1996
+
+
+
+
diff --git a/doc/TODO b/doc/TODO
new file mode 100644
index 00000000000..a91b47a5b42
--- /dev/null
+++ b/doc/TODO
@@ -0,0 +1,121 @@
+From scrappy@ki.net Tue Aug 6 19:57:11 1996
+Status: RO
+X-Status:
+Received: from candle.pha.pa.us (maillist@s1-03.ppp.op.net [206.84.209.132]) by quagmire.ki.net (8.7.5/8.7.5) with ESMTP id TAA01576 for <scrappy@ki.net>; Tue, 6 Aug 1996 19:57:08 -0400 (EDT)
+Received: (from maillist@localhost) by candle.pha.pa.us (8.7.4/8.7.3) id TAA11618 for scrappy@ki.net; Tue, 6 Aug 1996 19:57:37 -0400 (EDT)
+From: Bruce Momjian <maillist@candle.pha.pa.us>
+Message-Id: <199608062357.TAA11618@candle.pha.pa.us>
+Subject: add TODO to distribution
+To: scrappy@ki.net (Marc G. Fournier)
+Date: Tue, 6 Aug 1996 19:57:36 -0400 (EDT)
+X-Mailer: ELM [version 2.4 PL25]
+MIME-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+
+Here is the current TODO list. Let's add it to the next distribution.
+This was not ready at the time of the 1.02 release.
+
+---------------------------------------------------------------------------
+
+
+=================================================
+TODO list (FAQ) for Postgres95
+==================================================
+last updated: Mon Aug 5 21:00:12 EDT 1996
+
+current maintainer: Bruce Momjian (maillist@candle.pha.pa.us)
+original author: Jolly Chen (jolly@cs.berkeley.edu)
+
+
+RELIABILITY
+-----------
+Overhaul mdmgr/smgr to fix double unlinking and double opens, cleanup
+Memory leaks (hunt and destroy with tools like Purify)
+ fix unitialized reads of memory
+ fix array over-runs of memory writes
+Re-visit and fix vacuum
+ can't vacuum large objects
+ can't shrink tables, pg_time and pg_log
+Fix all NULL features
+DROP AGGREGATE should take in basetype as an arg
+Add other language types for built-in functions
+ expand to allow tcl, perl, java,
+ generalize the function manager switch to pass
+ function sources to interpreter engines.
+Fix large object mapping scheme
+ not to stuff everything as files in a single directory
+Fix CLUSTER
+Prevent improper index creation
+Starting quote in insert string errors
+Change default decimal constant representation from float4 to float8
+ALTER TABLE bug - running postgress process needs to re-read table definition
+Allow libpq to distinguish between text value '' and null
+Allow non-postgres users with createdb privs to destroydb's
+
+PERFORMANCE
+-----------
+Optimizing disjunctive queries
+Other optimizer bugs
+Is fsync use optimized?
+Multi-representational types, a la Illustra. For example, have a
+ text type that is stored in-tuple when less than 8K and in large
+ objects, when greater than 8K.
+
+ENHANCEMENTS
+------------
+Add full ANSI SQL capabilities ( a vendor has offered to help)
+ add subselects
+ column constraints (using rules), esp. primary keys
+ add DEFAULT, UNIQUE, RESTRAINT, and CHECK capabilities
+ report "Not implemented" if valid syntax is supplied
+ add OUTER joins
+ make VIEWs updateable where possible
+ add UNIONS, INTERSECTS, SUBTRACTS
+ add temporary tables
+ add assertions
+ add domains
+ add sql3 recursive unions
+ add the concept of dataspaces
+ Implement HAVING clause
+ Implement IN qualifier
+Add a way to preserve oid's when doing dump and load
+ if not, make oid's accessable in insert rules
+Add word index for text fields, maybe with trigrams, i.e.:
+ ' (cat | dog) & ! fox ' meaning text has cat or dog, but not fox
+Allow compression of large fields or a compressed field type
+Fix the rules system
+ robust
+ making INSTEAD rules work
+Full set of text operations and functions
+ word searches, concat, upper/lower(), max() on text, char
+Replace table-level locking with row or page-level locking
+Large objects
+ overwriting blocks has problems
+ there are other problems, too.
+Better interface for adding to pg_group
+Make multi-field indexes easier to create
+ allow optimizer to effectively use parameters without accessing table
+Improve debugging output
+Add int8 type
+Add table comments
+Add support for tables >2G
+Incorporate the PERL PG95 interface library into source tree
+Threaded version of the server or libpq
+Add REGEX internationalization
+
+DOCUMENTATION
+-------------
+Better documentation. Write a real book on postgres, perhaps?
+Document OPENLINK fsync patch
+Update usermanual source
+Reduce size of regression diffs
+
+PORTABILITY
+-----------
+Windows NT port
+ Mariposa project at Berkeley has a person who's working on this
+Binary distributions for linux
+Merge bsdi_2_1 to bsdi
+Merge i386_solaris and sparc_solaris into solaris
+
diff --git a/doc/bug.template b/doc/bug.template
new file mode 100644
index 00000000000..6c78804acf5
--- /dev/null
+++ b/doc/bug.template
@@ -0,0 +1,41 @@
+To report a bug, please complete the following form and send it by
+email to pg95-dev@ki.net
+
+============================================================================
+ POSTGRES95 BUG REPORT TEMPLATE
+============================================================================
+
+
+Your name :
+Your email address :
+
+
+System Configuration
+---------------------
+ Architecture (example: Intel Pentium) :
+
+ Operating System (example: Linux 1.3.42 ELF) :
+
+ Postgres95 version (example: Postgres95-1.01) : Postgres95-1.02
+
+ Compiler used (example: gcc 2.7.0) :
+
+
+Please enter a FULL description of your problem:
+------------------------------------------------
+
+
+
+
+
+Please describe a way to repeat the problem. Please try to provide a
+concise reproducible example, if at all possible:
+----------------------------------------------------------------------
+
+
+
+
+
+If you know how this problem might be fixed, list the solution below:
+---------------------------------------------------------------------
+
diff --git a/doc/libpgtcl.doc b/doc/libpgtcl.doc
new file mode 100644
index 00000000000..3ee5c6dfc09
--- /dev/null
+++ b/doc/libpgtcl.doc
@@ -0,0 +1,181 @@
+
+pgtcl is a tcl package for front-end programs to interface with Postgres95
+backends. PgTcl does not use the libpq library but communicates to
+the backend directly via the frontend-backend protocol. Thus, it is
+more efficient than previous postgres->tcl bindings which are layered
+on top of libpq. In addition, pgtcl can handle multiple backend
+connections from a single frontend application.
+
+If you have any questions or bug reports, please send them to
+Jolly Chen at jolly@cs.berkeley.edu.
+
+-------------------------------------------------------------------
+
+
+The pgtcl package provides the following commands.
+
+ pg_connect - opens a connection to the backend server
+ pg_disconnect - closes a connection
+ pg_exec - send a query to the backend
+ pg_result - manipulate the results of a query
+
+ pg_lo_creat - create a large object
+ pg_lo_open - open a large object
+ pg_lo_close - close a large object
+ pg_lo_read - read a large object
+ pg_lo_write - write a large object
+ pg_lo_lseek - seek to a position on a large object
+ pg_lo_tell - return the current seek position of a large object
+ pg_lo_unlink - delete a large object
+ pg_lo_import - import a Unix file into a large object
+ pg_lo_export - export a large object into a Unix file
+
+1) pg_connect: opens a connection to the backend
+
+ syntax:
+ pg_connect dbName [-host hostName] [-port portNumber] [-tty pqtty] [-options optionalBackendArgs]]
+
+ the return result is either an error message or a handle for a database
+ connection. Handles start with the prefix "pgp"
+
+
+2) pg_disconnect: closes a connection
+
+ syntax:
+ pg_disconnect connection
+
+ The argument passed in must be a connection pointer.
+
+3) pg_exec: send a query string to the backend
+
+ syntax:
+ pg_exec connection query
+
+ the return result is either an error message or a handle for a query
+ result. Handles start with the prefix "pgp"
+
+4) pg_result: get information about a query result
+
+ syntax:
+ pg_result result ?option?
+
+ the options are:
+ -status
+ the status of the result
+ -oid
+ if the last query was an insert, returns the oid of the
+ inserted tuple
+ -conn
+ the connection that produced the result
+ -assign arrayName
+ assign the results to an array
+ -numTuples
+ the number of tuples in the query
+ -attributes
+ returns a list of the name/type pairs of the tuple attributes
+ -getTuple tupleNumber
+ returns the values of the tuple in a list
+ -clear
+ clear the result buffer. Do not reuse after this
+
+----------------------------------------------------------------------------
+The pg_lo* routines are interfaces to the Inversion large objects in postgres.
+The functions are designed to mimic the analogous file system functions in
+the standard Unix file system interface.
+
+The pg_lo* routines should typically be used within a BEGIN/END transaction
+block becaus the file descriptor returned by pg_lo_open is only valid for
+the current transaction. pg_lo_import and pg_lo_export MUST be used
+in a BEGIN/END transaction block.
+
+* pg_lo_creat: create a large object
+
+ syntax:
+ g_lo_creat conn mode
+
+mode can be any OR'ing together of INV_READ, INV_WRITE, and INV_ARCHIVE.
+The OR delimiter character is "|".
+ e.g. [pg_lo_creat $conn "INV_READ|INV_WRITE"]
+
+returns the oid of the large object created.
+
+* pg_lo_open: open a large object
+
+ syntax:
+ pg_lo_open conn objOid mode
+
+ where mode can be either "r", "w", or "rw"
+
+ returns a file descriptor for use in later pg_lo* routines
+
+* pg_lo_close: close a large object
+
+ syntax:
+ pg_lo_close conn fd
+
+* pg_lo_read: read a large object
+
+ syntax:
+ pg_lo_read conn fd bufVar len
+
+reads at most len bytes from a large object into a variable named bufVar.
+Note that the third argument should be a variable name.
+
+* pg_lo_write: write a large object
+
+ syntax:
+ pg_lo_write conn fd buf len
+
+write at most len bytes to a large object.
+The third argument should be the actual string to write, not a variable name.
+
+* pg_lo_lseek: seek to a position on a large object
+
+ syntax:
+ pg_lo_lseek conn fd offset whence
+
+whence can be "SEEK_CUR", "SEEK_END", or "SEEK_SET"
+
+* pg_lo_tell: return the current seek position of a large object
+
+ syntax:
+ pg_lo_tell conn fd
+
+* pg_lo_unlink: delete a large object
+
+ syntax:
+ pg_lo_unlink conn lobjId
+
+* pg_lo_import: import a Unix file into a large object
+
+ syntax:
+ pg_lo_import conn filename
+
+ pg_lo_import must be called within a BEGIN/END transaction block
+
+* pg_lo_export: export a large object into a Unix file
+
+ syntax:
+ pg_lo_export conn lobjId filename
+
+ pg_lo_export must be called within a BEGIN/END transaction block
+
+------------------------------------------------------------------
+Here's a small example of how to use the routines:
+
+# getDBs :
+# get the names of all the databases at a given host and port number
+# with the defaults being the localhost and port 5432
+# return them in alphabetical order
+proc getDBs { {host "localhost"} {port "5432"} } {
+ # datnames is the list to be result
+ set conn [pg_connect template1 -host $host -port $port]
+ set res [pg_exec $conn "SELECT datname FROM pg_database ORDER BY datname"]
+ set ntups [pg_result $res -numTuples]
+ for {set i 0} {$i < $ntups} {incr i} {
+ lappend datnames [pg_result $res -getTuple $i]
+ }
+ pg_disconnect $conn
+ return $datnames
+}
+
diff --git a/doc/man/README b/doc/man/README
new file mode 100644
index 00000000000..ef98aebfd63
--- /dev/null
+++ b/doc/man/README
@@ -0,0 +1,3 @@
+
+The page.5 source should be run through pic when generating troff
+output. nroff doesn't handle pic.
diff --git a/doc/man/abort.l b/doc/man/abort.l
new file mode 100644
index 00000000000..d2f552c1c25
--- /dev/null
+++ b/doc/man/abort.l
@@ -0,0 +1,23 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/abort.l,v 1.1.1.1 1996/08/18 22:14:19 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).
diff --git a/doc/man/alter_table.l b/doc/man/alter_table.l
new file mode 100644
index 00000000000..245533a03c4
--- /dev/null
+++ b/doc/man/alter_table.l
@@ -0,0 +1,61 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/alter_table.l,v 1.1.1.1 1996/08/18 22:14:19 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).
diff --git a/doc/man/begin.l b/doc/man/begin.l
new file mode 100644
index 00000000000..f7340c549ac
--- /dev/null
+++ b/doc/man/begin.l
@@ -0,0 +1,20 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/begin.l,v 1.1.1.1 1996/08/18 22:14:20 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).
diff --git a/doc/man/bki.5 b/doc/man/bki.5
new file mode 100644
index 00000000000..4c6f68c7dea
--- /dev/null
+++ b/doc/man/bki.5
@@ -0,0 +1,224 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/bki.5,v 1.1.1.1 1996/08/18 22:14:20 scrappy Exp $
+.TH BKI FILES 01/23/93 Postgres95 Postgres95
+.SH NAME
+\&.../src/backend/obj/{local,dbdb}.bki \(em template scripts
+.SH DESCRIPTION
+Backend Interface (BKI) files are scripts that describe the contents
+of the initial Postgres database. This database is constructed during
+system installation, by the
+.IR initdb
+command.
+.IR Initdb
+executes the Postgres backend with a special set of flags, that cause it
+to consume the BKI scripts and bootstrap a database.
+.PP
+These files are automatically generated from system header files
+during installation. They are not intended for use by humans, and you
+do not need to understand their contents in order to use Postgres. These
+files are copied to
+.nf
+\&.../files/{global1,local1_XXX}.bki
+.fi
+during system installation.
+.PP
+All new user databases will be created by copying the template
+database that Postgres constructs from the BKI files. Thus, a simple way
+to customize the template database is to let the Postgres initialization
+script create it for you, and then to run the terminal monitor to make
+the changes you want.
+.PP
+The Postgres backend interprets BKI files as described below. This
+description will be easier to understand if the example in
+\*(lq.../files/global1.bki\*(rq is at hand.
+.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),
+createdb(l),
+template(files).
diff --git a/doc/man/built-in.3 b/doc/man/built-in.3
new file mode 100644
index 00000000000..48af4cbe316
--- /dev/null
+++ b/doc/man/built-in.3
@@ -0,0 +1,700 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/built-in.3,v 1.1.1.1 1996/08/18 22:14:20 scrappy Exp $
+.TH BUILT-INS INTRO 11/05/95 Postgres95 Postgres95
+.SH "DESCRIPTION"
+This section describes the data types, functions and operators
+available to users in Postgres as it is distributed.
+.SH "Built-in and System Types"
+.SH "BUILT-IN TYPES"
+This section describes both
+.BR built-in
+data types.
+These Built-in types are
+are installed in every database.
+.PP
+Users may add new types to Postgres using the
+.IR "define type"
+command described in this manual. User-defined types are not
+described in this section.
+.SH "List of built-in types"
+.PP
+.if n .ta 5 +15 +40
+.if t .ta 0.5i +1.5i +3.0i
+.in 0
+.nf
+ \fBPOSTGRES Type\fP \fBMeaning\fP
+ abstime absolute date and time
+ aclitem access control list item
+ bool boolean
+ box 2-dimensional rectangle
+ bpchar blank-padded characters
+ bytea variable length array of bytes
+ char character
+ char2 array of 2 characters
+ char4 array of 4 characters
+ char8 array of 8 characters
+ char16 array of 16 characters
+ cid command identifier type
+ date ANSI SQL date type
+ filename large object filename
+ int alias for int4
+ integer alias for int4
+ int2 two-byte signed integer
+ int28 array of 8 int2
+ int4 four-byte signed integer
+ float alias for float4
+ float4 single-precision floating-point number
+ float8 double-precision floating-point number
+ lseg 2-dimensional line segment
+ name a multi-character type for storing system identifiers
+ oid object identifier type
+ oid8 array of 8 oid
+ oidchar16 oid and char16 composed
+ oidint2 oid and int2 composed
+ oidint4 oid and int4 composed
+ path variable-length array of lseg
+ point 2-dimensional geometric point
+ polygon 2-dimensional polygon
+ real alias for float4
+ regproc registered procedure
+ reltime relative date and time
+ smgr storage manager
+ smallint alias for int2
+ text variable length array of characters
+ tid tuple identifier type
+ time ANSI SQL time type
+ tinterval time interval
+ varchar variable-length characters
+ xid transaction identifier type
+
+.fi
+.in
+.PP
+As a rule, the built-in types are all either (1) internal types, in
+which case the user should not worry about their external format, or
+(2) have obvious formats. The exceptions to this rule are the three
+time types.
+.SH "Syntax of date and time types"
+.SH "ABSOLUTE TIME"
+Absolute time is specified using the following syntax:
+.nf
+Month Day [ Hour : Minute : Second ] Year [ Timezone ]
+.sp
+where
+ Month is Jan, Feb, ..., Dec
+ Day is 1, 2, ..., 31
+ Hour is 01, 02, ..., 24
+ Minute is 00, 01, ..., 59
+ Second is 00, 01, ..., 59
+ Year is 1901, 1902, ..., 2038
+.fi
+Valid dates are from Dec 13 20:45:53 1901 GMT to Jan 19 03:14:04
+2038 GMT. As of Version 3.0, times are no longer read and written
+using Greenwich Mean Time; the input and output routines default to
+the local time zone.
+.PP
+The special absolute time values \*(lqcurrent\*(rq,
+\*(lqinfinity\*(rq and \*(lq-infinity\*(rq are also provided.
+\*(lqinfinity\*(rq specifies a time later than any valid time, and
+\*(lq-infinity\*(rq specifies a time earlier than any valid time.
+\*(lqcurrent\*(rq indicates that the current time should be
+substituted whenever this value appears in a computation.
+.PP
+The strings \*(lqnow\*(rq and \*(lqepoch\*(rq can be used to specify
+time values. \*(lqnow\*(rq means the current time, and differs from
+\*(lqcurrent\*(rq in that the current time is immediately substituted
+for it. \*(lqepoch\*(rq means Jan 1 00:00:00 1970 GMT.
+.SH "RELATIVE TIME"
+Relative time is specified with the following syntax:
+.nf
+@ Quantity Unit [Direction]
+.sp
+where
+ Quantity is `1', `2', ...
+ Unit is ``second'', ``minute'', ``hour'', ``day'', ``week'',
+ ``month'' (30-days), or ``year'' (365-days),
+ or PLURAL of these units.
+ Direction is ``ago''
+.fi
+.PP
+.RB ( Note :
+Valid relative times are less than or equal to 68 years.)
+In addition, the special relative time \*(lqUndefined RelTime\*(rq is
+provided.
+.SH "TIME RANGES"
+Time ranges are specified as:
+.nf
+[ 'abstime' 'abstime']
+.fi
+where
+.IR abstime
+is a time in the absolute time format. Special abstime values such as
+\*(lqcurrent\*(rq, \*(lqinfinity\*(rq and \*(lq-infinity\*(rq can be used.
+.SH "Built-in operators and functions"
+.SH OPERATORS
+Postgres provides a large number of built-in operators on system types.
+These operators are declared in the system catalog
+\*(lqpg_operator\*(rq. Every entry in \*(lqpg_operator\*(rq includes
+the object ID of the procedure that implements the operator.
+.PP
+Users may invoke operators using the operator name, as in
+.nf
+select * from emp where salary < 40000;
+.fi
+Alternatively, users may call the functions that implement the
+operators directly. In this case, the query above would be expressed
+as
+.nf
+select * from emp where int4lt(salary, 40000);
+.fi
+The rest of this section provides a list of the built-in operators and
+the functions that implement them. Binary operators are listed first,
+followed by unary operators.
+.SH "BINARY OPERATORS"
+This list was generated from the Postgres system catalogs with the
+query:
+
+.nf
+SELECT
+ t0.typname AS result,
+ t1.typname AS left_type,
+ t2.typname AS right_type,
+ o.oprname AS operatr,
+ p.proname AS func_name
+FROM pg_proc p, pg_type t0,
+ pg_type t1, pg_type t2,
+ pg_operator o
+WHERE p.prorettype = t0.oid AND
+ RegprocToOid(o.oprcode) = p.oid AND
+ p.pronargs = 2 AND
+ o.oprleft = t1.oid AND
+ o.oprright = t2.oid
+ORDER BY result, left_type, right_type, operatr;
+.fi
+
+These operations are cast in terms of SQL types and so are
+.BR not
+directly usable as C function prototypes.
+
+.nf
+Operators:
+
+general
+ <\(eq less or equal
+ <> inequality
+ < less than
+ <\(eq greater or equal
+ >\(eq greater or equal
+ > greater than
+ \(eq equality
+ ~ A matches regular expression B, case-sensitive
+ !~ A does not match regular expression B, case-sensitive
+ ~* A matches regular expression B, case-insensitive.
+ !~* A does not match regular expression B, case-insensitive
+ ~~ A matches LIKE expression B, case-sensitive
+ !~~ A does not match LIKE expression B, case-sensitive
+
+ + addition
+ \(mi subtraction
+ * multiplication
+ / division
+ % modulus
+ @ absolute value
+
+float8
+ ^ exponentiation
+ % truncate to integer
+ |/ square root
+ ||/ cube root
+ : exponential function
+ ; natural logarithm
+
+point
+ !< A is left of B
+ !> A is right of B
+ !^ A is above B
+ !| A is below B
+ \(eq|\(eq equality
+ ===> point inside box
+ ===` point on path
+ <===> distance between points
+
+box
+ && boxes overlap
+ &< box A overlaps box B, but does not extend to right of box B
+ &> box A overlaps box B, but does not extend to left of box B
+ << A is left of B
+ \(eq area equal
+ < area less than
+ <\(eq area less or equal
+ >\(eq area greater or equal
+ > area greater than
+ >> A is right of B
+ @ A is contained in B
+ ~\(eq box equality
+ ~= A same as B
+ ~ A contains B
+ @@ center of box
+
+polygon
+ && polygons overlap
+ &< A overlaps B but does not extend to right of B
+ &> A overlaps B but does not extend to left of B
+ << A is left of B
+ >> A is right of B
+ @ A is contained by B
+ ~\(eq equality
+ ~= A same as B
+ ~ A contains B
+
+tinterval
+ #<\(eq interval length less or equal reltime
+ #<> interval length not equal to reltime.
+ #< interval length less than reltime
+ #\(eq interval length equal to reltime
+ #>\(eq interval length greater or equal reltime
+ #> interval length greater than reltime
+ && intervals overlap
+ << A contains B
+ \(eq equality
+ <> interval bounded by two abstimes
+ <?> abstime in tinterval
+ | start of interval
+ <#> convert to interval
+
+result |left_type |right_type|operatr|func_name
+---------+----------+----------+-------+---------------
+_aclitem |_aclitem |aclitem |+ |aclinsert
+_aclitem |_aclitem |aclitem |- |aclremove
+abstime |abstime |reltime |+ |timepl
+abstime |abstime |reltime |- |timemi
+bool |_abstime |_abstime |= |array_eq
+bool |_aclitem |_aclitem |= |array_eq
+bool |_aclitem |aclitem |~ |aclcontains
+bool |_bool |_bool |= |array_eq
+bool |_box |_box |= |array_eq
+bool |_bytea |_bytea |= |array_eq
+bool |_char |_char |= |array_eq
+bool |_char16 |_char16 |= |array_eq
+bool |_cid |_cid |= |array_eq
+bool |_filename |_filename |= |array_eq
+bool |_float4 |_float4 |= |array_eq
+bool |_float8 |_float8 |= |array_eq
+bool |_int2 |_int2 |= |array_eq
+bool |_int28 |_int28 |= |array_eq
+bool |_int4 |_int4 |= |array_eq
+bool |_lseg |_lseg |= |array_eq
+bool |_name |_name |= |array_eq
+bool |_oid |_oid |= |array_eq
+bool |_oid8 |_oid8 |= |array_eq
+bool |_path |_path |= |array_eq
+bool |_point |_point |= |array_eq
+bool |_polygon |_polygon |= |array_eq
+bool |_ref |_ref |= |array_eq
+bool |_regproc |_regproc |= |array_eq
+bool |_reltime |_reltime |= |array_eq
+bool |_stub |_stub |= |array_eq
+bool |_text |_text |= |array_eq
+bool |_tid |_tid |= |array_eq
+bool |_tinterval|_tinterval|= |array_eq
+bool |_xid |_xid |= |array_eq
+bool |abstime |abstime |< |abstimelt
+bool |abstime |abstime |<= |abstimele
+bool |abstime |abstime |<> |abstimene
+bool |abstime |abstime |= |abstimeeq
+bool |abstime |abstime |> |abstimegt
+bool |abstime |abstime |>= |abstimege
+bool |abstime |tinterval |<?> |ininterval
+bool |bool |bool |<> |boolne
+bool |bool |bool |= |booleq
+bool |box |box |&& |box_overlap
+bool |box |box |&< |box_overleft
+bool |box |box |&> |box_overright
+bool |box |box |< |box_lt
+bool |box |box |<< |box_left
+bool |box |box |<= |box_le
+bool |box |box |= |box_eq
+bool |box |box |> |box_gt
+bool |box |box |>= |box_ge
+bool |box |box |>> |box_right
+bool |box |box |@ |box_contained
+bool |box |box |~ |box_contain
+bool |box |box |~= |box_same
+bool |bpchar |bpchar |< |bpcharlt
+bool |bpchar |bpchar |<= |bpcharle
+bool |bpchar |bpchar |<> |bpcharne
+bool |bpchar |bpchar |= |bpchareq
+bool |bpchar |bpchar |> |bpchargt
+bool |bpchar |bpchar |>= |bpcharge
+bool |bpchar |text |!~ |textregexne
+bool |bpchar |text |!~* |texticregexne
+bool |bpchar |text |!~~ |textnlike
+bool |bpchar |text |~ |textregexeq
+bool |bpchar |text |~* |texticregexeq
+bool |bpchar |text |~~ |textlike
+bool |char |char |< |charlt
+bool |char |char |<= |charle
+bool |char |char |<> |charne
+bool |char |char |= |chareq
+bool |char |char |> |chargt
+bool |char |char |>= |charge
+bool |char16 |char16 |< |char16lt
+bool |char16 |char16 |<= |char16le
+bool |char16 |char16 |<> |char16ne
+bool |char16 |char16 |= |char16eq
+bool |char16 |char16 |> |char16gt
+bool |char16 |char16 |>= |char16ge
+bool |char16 |text |!~ |char16regexne
+bool |char16 |text |!~* |char16icregexne
+bool |char16 |text |!~~ |char16nlike
+bool |char16 |text |!~~ |char16nlike
+bool |char16 |text |~ |char16regexeq
+bool |char16 |text |~* |char16icregexeq
+bool |char16 |text |~~ |char16like
+bool |char16 |text |~~ |char16like
+bool |char2 |char2 |< |char2lt
+bool |char2 |char2 |<= |char2le
+bool |char2 |char2 |<> |char2ne
+bool |char2 |char2 |= |char2eq
+bool |char2 |char2 |> |char2gt
+bool |char2 |char2 |>= |char2ge
+bool |char2 |text |!~ |char2regexne
+bool |char2 |text |!~* |char2icregexne
+bool |char2 |text |!~~ |char2nlike
+bool |char2 |text |~ |char2regexeq
+bool |char2 |text |~* |char2icregexeq
+bool |char2 |text |~~ |char2like
+bool |char4 |char4 |< |char4lt
+bool |char4 |char4 |<= |char4le
+bool |char4 |char4 |<> |char4ne
+bool |char4 |char4 |= |char4eq
+bool |char4 |char4 |> |char4gt
+bool |char4 |char4 |>= |char4ge
+bool |char4 |text |!~ |char4regexne
+bool |char4 |text |!~* |char4icregexne
+bool |char4 |text |!~~ |char4nlike
+bool |char4 |text |~ |char4regexeq
+bool |char4 |text |~* |char4icregexeq
+bool |char4 |text |~~ |char4like
+bool |char8 |char8 |< |char8lt
+bool |char8 |char8 |<= |char8le
+bool |char8 |char8 |<> |char8ne
+bool |char8 |char8 |= |char8eq
+bool |char8 |char8 |> |char8gt
+bool |char8 |char8 |>= |char8ge
+bool |char8 |text |!~ |char8regexne
+bool |char8 |text |!~* |char8icregexne
+bool |char8 |text |!~~ |char8nlike
+bool |char8 |text |~ |char8regexeq
+bool |char8 |text |~* |char8icregexeq
+bool |char8 |text |~~ |char8like
+bool |date |date |< |date_lt
+bool |date |date |<= |date_le
+bool |date |date |<> |date_ne
+bool |date |date |= |date_eq
+bool |date |date |> |date_gt
+bool |date |date |>= |date_ge
+bool |float4 |float4 |< |float4lt
+bool |float4 |float4 |<= |float4le
+bool |float4 |float4 |<> |float4ne
+bool |float4 |float4 |= |float4eq
+bool |float4 |float4 |> |float4gt
+bool |float4 |float4 |>= |float4ge
+bool |float4 |float8 |< |float48lt
+bool |float4 |float8 |<= |float48le
+bool |float4 |float8 |<> |float48ne
+bool |float4 |float8 |= |float48eq
+bool |float4 |float8 |> |float48gt
+bool |float4 |float8 |>= |float48ge
+bool |float8 |float4 |< |float84lt
+bool |float8 |float4 |<= |float84le
+bool |float8 |float4 |<> |float84ne
+bool |float8 |float4 |= |float84eq
+bool |float8 |float4 |> |float84gt
+bool |float8 |float4 |>= |float84ge
+bool |float8 |float8 |< |float8lt
+bool |float8 |float8 |<= |float8le
+bool |float8 |float8 |<> |float8ne
+bool |float8 |float8 |= |float8eq
+bool |float8 |float8 |> |float8gt
+bool |float8 |float8 |>= |float8ge
+bool |int2 |int2 |< |int2lt
+bool |int2 |int2 |<= |int2le
+bool |int2 |int2 |<> |int2ne
+bool |int2 |int2 |= |int2eq
+bool |int2 |int2 |> |int2gt
+bool |int2 |int2 |>= |int2ge
+bool |int4 |int4 |< |int4lt
+bool |int4 |int4 |<= |int4le
+bool |int4 |int4 |<> |int4ne
+bool |int4 |int4 |= |int4eq
+bool |int4 |int4 |> |int4gt
+bool |int4 |int4 |>= |int4ge
+bool |int4 |name |!!= |int4notin
+bool |int4 |oid |= |int4eqoid
+bool |name |name |< |namelt
+bool |name |name |<= |namele
+bool |name |name |<> |namene
+bool |name |name |= |nameeq
+bool |name |name |> |namegt
+bool |name |name |>= |namege
+bool |name |text |!~ |nameregexne
+bool |name |text |!~* |nameicregexne
+bool |name |text |!~~ |namenlike
+bool |name |text |~ |nameregexeq
+bool |name |text |~* |nameicregexeq
+bool |name |text |~~ |namelike
+bool |oid |int4 |= |oideqint4
+bool |oid |name |!!= |oidnotin
+bool |oid |oid |< |int4lt
+bool |oid |oid |<= |int4le
+bool |oid |oid |<> |oidne
+bool |oid |oid |= |oideq
+bool |oid |oid |> |int4gt
+bool |oid |oid |>= |int4ge
+bool |oidint2 |oidint2 |< |oidint2lt
+bool |oidint2 |oidint2 |<= |oidint2le
+bool |oidint2 |oidint2 |<> |oidint2ne
+bool |oidint2 |oidint2 |= |oidint2eq
+bool |oidint2 |oidint2 |> |oidint2gt
+bool |oidint2 |oidint2 |>= |oidint2ge
+bool |oidint4 |oidint4 |< |oidint4lt
+bool |oidint4 |oidint4 |<= |oidint4le
+bool |oidint4 |oidint4 |<> |oidint4ne
+bool |oidint4 |oidint4 |= |oidint4eq
+bool |oidint4 |oidint4 |> |oidint4gt
+bool |oidint4 |oidint4 |>= |oidint4ge
+bool |oidname |oidname |< |oidnamelt
+bool |oidname |oidname |<= |oidnamele
+bool |oidname |oidname |<> |oidnamene
+bool |oidname |oidname |= |oidnameeq
+bool |oidname |oidname |> |oidnamegt
+bool |oidname |oidname |>= |oidnamege
+bool |point |box |===> |on_pb
+bool |point |path |===` |on_ppath
+bool |point |point |!< |point_left
+bool |point |point |!> |point_right
+bool |point |point |!^ |point_above
+bool |point |point |!\| |point_below
+bool |point |point |=\|= |point_eq
+bool |polygon |polygon |&& |poly_overlap
+bool |polygon |polygon |&< |poly_overleft
+bool |polygon |polygon |&> |poly_overright
+bool |polygon |polygon |<< |poly_left
+bool |polygon |polygon |>> |poly_right
+bool |polygon |polygon |@ |poly_contained
+bool |polygon |polygon |~ |poly_contain
+bool |polygon |polygon |~= |poly_same
+bool |reltime |reltime |< |reltimelt
+bool |reltime |reltime |<= |reltimele
+bool |reltime |reltime |<> |reltimene
+bool |reltime |reltime |= |reltimeeq
+bool |reltime |reltime |> |reltimegt
+bool |reltime |reltime |>= |reltimege
+bool |text |text |!~ |textregexne
+bool |text |text |!~* |texticregexne
+bool |text |text |!~~ |textnlike
+bool |text |text |< |text_lt
+bool |text |text |<= |text_le
+bool |text |text |<> |textne
+bool |text |text |= |texteq
+bool |text |text |> |text_gt
+bool |text |text |>= |text_ge
+bool |text |text |~ |textregexeq
+bool |text |text |~* |texticregexeq
+bool |text |text |~~ |textlike
+bool |time |time |< |time_lt
+bool |time |time |<= |time_le
+bool |time |time |<> |time_ne
+bool |time |time |= |time_eq
+bool |time |time |> |time_gt
+bool |time |time |>= |time_ge
+bool |tinterval |reltime |#< |intervallenlt
+bool |tinterval |reltime |#<= |intervallenle
+bool |tinterval |reltime |#<> |intervallenne
+bool |tinterval |reltime |#= |intervalleneq
+bool |tinterval |reltime |#> |intervallengt
+bool |tinterval |reltime |#>= |intervallenge
+bool |tinterval |tinterval |&& |intervalov
+bool |tinterval |tinterval |<< |intervalct
+bool |tinterval |tinterval |= |intervaleq
+bool |varchar |text |!~ |textregexne
+bool |varchar |text |!~* |texticregexne
+bool |varchar |text |!~~ |textnlike
+bool |varchar |text |~ |textregexeq
+bool |varchar |text |~* |texticregexeq
+bool |varchar |text |~~ |textlike
+bool |varchar |varchar |< |varcharlt
+bool |varchar |varchar |<= |varcharle
+bool |varchar |varchar |<> |varcharne
+bool |varchar |varchar |= |varchareq
+bool |varchar |varchar |> |varchargt
+bool |varchar |varchar |>= |varcharge
+char |char |char |* |charmul
+char |char |char |+ |charpl
+char |char |char |- |charmi
+char |char |char |/ |chardiv
+float4 |float4 |float4 |* |float4mul
+float4 |float4 |float4 |+ |float4pl
+float4 |float4 |float4 |- |float4mi
+float4 |float4 |float4 |/ |float4div
+float8 |float4 |float8 |* |float48mul
+float8 |float4 |float8 |+ |float48pl
+float8 |float4 |float8 |- |float48mi
+float8 |float4 |float8 |/ |float48div
+float8 |float8 |float4 |* |float84mul
+float8 |float8 |float4 |+ |float84pl
+float8 |float8 |float4 |- |float84mi
+float8 |float8 |float4 |/ |float84div
+float8 |float8 |float8 |* |float8mul
+float8 |float8 |float8 |+ |float8pl
+float8 |float8 |float8 |- |float8mi
+float8 |float8 |float8 |/ |float8div
+float8 |float8 |float8 |^ |dpow
+int2 |int2 |int2 |% |int2mod
+int2 |int2 |int2 |* |int2mul
+int2 |int2 |int2 |+ |int2pl
+int2 |int2 |int2 |- |int2mi
+int2 |int2 |int2 |/ |int2div
+int4 |int2 |int4 |% |int24mod
+int4 |int2 |int4 |* |int24mul
+int4 |int2 |int4 |+ |int24pl
+int4 |int2 |int4 |- |int24mi
+int4 |int2 |int4 |/ |int24div
+int4 |int2 |int4 |< |int24lt
+int4 |int2 |int4 |<= |int24le
+int4 |int2 |int4 |<> |int24ne
+int4 |int2 |int4 |= |int24eq
+int4 |int2 |int4 |> |int24gt
+int4 |int2 |int4 |>= |int24ge
+int4 |int4 |int2 |% |int42mod
+int4 |int4 |int2 |* |int42mul
+int4 |int4 |int2 |+ |int42pl
+int4 |int4 |int2 |- |int42mi
+int4 |int4 |int2 |/ |int42div
+int4 |int4 |int2 |< |int42lt
+int4 |int4 |int2 |<= |int42le
+int4 |int4 |int2 |<> |int42ne
+int4 |int4 |int2 |= |int42eq
+int4 |int4 |int2 |> |int42gt
+int4 |int4 |int2 |>= |int42ge
+int4 |int4 |int4 |% |int4mod
+int4 |int4 |int4 |* |int4mul
+int4 |int4 |int4 |+ |int4pl
+int4 |int4 |int4 |- |int4mi
+int4 |int4 |int4 |/ |int4div
+int4 |point |point |<===> |pointdist
+tinterval|abstime |abstime |<#> |mktinterval
+
+
+.fi
+.SH "LEFT UNARY OPERATORS"
+The table below gives the left unary operators that are
+registered in the system catalogs.
+
+This list was generated from the Postgres system catalogs with the query:
+
+.nf
+SELECT o.oprname AS left_unary,
+ right.typname AS operand,
+ result.typname AS return_type
+FROM pg_operator o, pg_type right, pg_type result
+WHERE o.oprkind = 'l' AND -- left unary
+ o.oprright = right.oid AND
+ o.oprresult = result.oid
+ORDER BY operand;
+
+left_unary|operand |return_type
+----------+---------+-----------
+@@ |box |point
+@ |float4 |float4
+- |float4 |float4
+; |float8 |float8
+: |float8 |float8
+% |float8 |float8
+\|\|/ |float8 |float8
+\|/ |float8 |float8
+@ |float8 |float8
+- |float8 |float8
+- |int2 |int2
+- |int4 |int4
+!! |int4 |int4
+\| |tinterval|abstime
+
+.fi
+.in
+.SH "RIGHT UNARY OPERATORS"
+The table below gives the right unary operators that are
+registered in the system catalogs.
+
+This list was generated from the Postgres system catalogs with the query:
+
+.nf
+SELECT o.oprname AS right_unary,
+ left.typname AS operand,
+ result.typname AS return_type
+FROM pg_operator o, pg_type left, pg_type result
+WHERE o.oprkind = 'r' AND -- right unary
+ o.oprleft = left.oid AND
+ o.oprresult = result.oid
+ORDER BY operand;
+
+right_unary|operand|return_type
+-----------+-------+-----------
+% |float8 |float8
+! |int4 |int4
+
+.fi
+.in
+.SH "AGGREGATE FUNCTIONS"
+The table below gives the aggregate functions that are
+registered in the system catalogs.
+
+This list was generated from the Postgres system catalogs with the query:
+
+.nf
+SELECT a.aggname, t.typname
+FROM pg_aggregate a, pg_type t
+WHERE a.aggbasetype = t.oid
+ORDER BY aggname, typname;
+
+aggname|typname
+-------+-------
+avg |float4
+avg |float8
+avg |int2
+avg |int4
+max |float4
+max |float8
+max |int2
+max |int4
+min |float4
+min |float8
+min |int2
+min |int4
+sum |float4
+sum |float8
+sum |int2
+sum |int4
+
+\fBcount\fR is also available.
+
+.fi
+.in
+.SH "SEE ALSO"
+For examples on specifying literals of built-in types, see
+.IR SQL(l).
+.SH BUGS
+.PP
+Although most of the input and output functions correponding to the
+base types (e.g., integers and floating point numbers) do some
+error-checking, none of them are particularly rigorous about it. More
+importantly, almost none of the operators and functions (e.g.,
+addition and multiplication) perform any error-checking at all.
+Consequently, many of the numeric operations will (for example)
+silently underflow or overflow.
+.PP
+Some of the input and output functions are not invertible. That is,
+the result of an output function may lose precision when compared to
+the original input.
diff --git a/doc/man/catalogs.3 b/doc/man/catalogs.3
new file mode 100644
index 00000000000..b46a2cb8f41
--- /dev/null
+++ b/doc/man/catalogs.3
@@ -0,0 +1,446 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/catalogs.3,v 1.1.1.1 1996/08/18 22:14:20 scrappy Exp $
+.TH "SYSTEM CATALOGS" INTRO 03/13/94 Postgres95 Postgres95
+.SH "Section 7 \(em System Catalogs"
+.de LS
+.PP
+.if n .ta 5 +13 +13
+.if t .ta 0.5i +1.3i +1.3i
+.in 0
+.nf
+..
+.de LE
+.fi
+.in
+..
+.SH "DESCRIPTION"
+In this
+section we list each of the attributes of the system catalogs and
+define their meanings.
+.SH "CLASS/TYPE SYSTEM CATALOGS"
+These catalogs form the core of the extensibility system:
+.LS
+ \fBname\fP \fBshared/local\fP \fBdescription\fP
+ pg_aggregate local aggregate functions
+ pg_am local access methods
+ pg_amop local operators usable with specific access methods
+ pg_amproc local procedures used with specific access methods
+ pg_attribute local class attributes
+ pg_class local classes
+ pg_index local secondary indices
+ pg_inherits local class inheritance hierarchy
+ pg_language local procedure implementation languages
+ pg_opclass local operator classes
+ pg_operator local query language operators
+ pg_proc local procedures (functions)
+ pg_type local data types
+.LE
+.SH "ENTITIES"
+These catalogs deal with identification of entities known throughout
+the site:
+.LS
+ \fBname\fP \fBshared/local\fP \fBdescription\fP
+ pg_database shared current databases
+ pg_group shared user groups
+ pg_user shared valid users
+.LE
+.SH "RULE SYSTEM CATALOGS"
+.LS
+ \fBname\fP \fBshared/local\fP \fBdescription\fP
+ pg_listener local processes waiting on alerters
+ pg_prs2plans local instance system procedures
+ pg_prs2rule local instance system rules
+ pg_prs2stub local instance system ``stubs''
+ pg_rewrite local rewrite system information
+.LE
+.SH "LARGE OBJECT CATALOGS"
+.PP
+These catalogs are specific to the Inversion file system and large
+objects in general:
+.LS
+ \fBname\fP \fBshared/local\fP \fBdescription\fP
+ pg_lobj local description of a large object
+ pg_naming local Inversion name space mapping
+ pg_platter local jukebox platter inventory
+ pg_plmap local jukebox platter extent map
+.LE
+.SH "INTERNAL CATALOGS"
+.PP
+These catalogs are internal classes that are not stored as normal
+heaps and cannot be accessed through normal means (attempting to do so
+causes an error).
+.LS
+ \fBname\fP \fBshared/local\fP \fBdescription\fP
+ pg_log shared transaction commit/abort log
+ pg_magic shared magic constant
+ pg_time shared commit/abort times
+ pg_variable shared special variable values
+.LE
+.PP
+There are several other classes defined with \*(lqpg_\*(rq names.
+Aside from those that end in \*(lqind\*(rq (secondary indices), these
+are all obsolete or otherwise deprecated.
+.SH "CLASS/TYPE SYSTEM CATALOGS"
+.PP
+The following catalogs relate to the class/type system.
+.nf M
+/*
+ * aggregates
+ *
+ * see DEFINE AGGREGATE for an explanation of transition functions
+ */
+pg_aggregate
+ NameData aggname /* aggregate name (e.g., "count") */
+ oid aggowner /* usesysid of creator */
+ regproc aggtransfn1 /* first transition function */
+ regproc aggtransfn2 /* second transition function */
+ regproc aggfinalfn /* final function */
+ oid aggbasetype /* type of data on which aggregate
+ operates */
+ oid aggtranstype1 /* type returned by aggtransfn1 */
+ oid aggtranstype2 /* type returned by aggtransfn2 */
+ oid aggfinaltype /* type returned by aggfinalfn */
+ text agginitval1 /* external format of initial
+ (starting) value of aggtransfn1 */
+ text agginitval2 /* external format of initial
+ (starting) value of aggtransfn2 */
+.fi
+.nf M
+pg_am
+ NameData amname /* access method name */
+ oid amowner /* usesysid of creator */
+ char amkind /* - deprecated */
+ /* originally:
+ h=hashed
+ o=ordered
+ s=special */
+ int2 amstrategies /* total NUMBER of strategies by which
+ we can traverse/search this AM */
+ int2 amsupport /* total NUMBER of support functions
+ that this AM uses */
+ regproc amgettuple /* "next valid tuple" function */
+ regproc aminsert /* "insert this tuple" function */
+ regproc amdelete /* "delete this tuple" function */
+ regproc amgetattr /* - deprecated */
+ regproc amsetlock /* - deprecated */
+ regproc amsettid /* - deprecated */
+ regproc amfreetuple /* - deprecated */
+ regproc ambeginscan /* "start new scan" function */
+ regproc amrescan /* "restart this scan" function */
+ regproc amendscan /* "end this scan" function */
+ regproc ammarkpos /* "mark current scan position"
+ function */
+ regproc amrestrpos /* "restore marked scan position"
+ function */
+ regproc amopen /* - deprecated */
+ regproc amclose /* - deprecated */
+ regproc ambuild /* "build new index" function */
+ regproc amcreate /* - deprecated */
+ regproc amdestroy /* - deprecated */
+.fi
+.nf M
+pg_amop
+ oid amopid /* access method with which this
+ operator be used */
+ oid amopclaid /* operator class with which this
+ operator can be used */
+ oid amopopr /* the operator */
+ int2 amopstrategy /* traversal/search strategy number
+ to which this operator applies */
+ regproc amopselect /* function to calculate the operator
+ selectivity */
+ regproc amopnpages /* function to calculate the number of
+ pages that will be examined */
+.fi
+.nf M
+pg_amproc
+ oid amid /* access method with which this
+ procedure is associated */
+ oid amopclaid /* operator class with which this
+ operator can be used */
+ oid amproc /* the procedure */
+ int2 amprocnum /* support function number to which
+ this operator applies */
+.fi
+.nf M
+pg_class
+ NameData relname /* class name */
+ oid relowner /* usesysid of owner */
+ oid relam /* access method */
+ int4 relpages /* # of 8KB pages */
+ int4 reltuples /* # of instances */
+ abstime relexpires /* time after which instances are
+ deleted from non-archival storage */
+ reltime relpreserved /* timespan after which instances are
+ deleted from non-archival storage */
+ bool relhasindex /* does the class have a secondary
+ index? */
+ bool relisshared /* is the class shared or local? */
+ char relkind /* type of relation:
+ i=index
+ r=relation (heap)
+ s=special
+ u=uncatalogued (temporary) */
+ char relarch /* archive mode:
+ h=heavy
+ l=light
+ n=none */
+ int2 relnatts /* current # of non-system
+ attributes */
+ int2 relsmgr /* storage manager:
+ 0=magnetic disk
+ 1=sony WORM jukebox
+ 2=main memory */
+ int28 relkey /* - unused */
+ oid8 relkeyop /* - unused */
+ aclitem relacl[1] /* access control lists */
+.fi
+.nf M
+pg_attribute
+ oid attrelid /* class containing this attribute */
+ NameData attname /* attribute name */
+ oid atttypid /* attribute type */
+ oid attdefrel /* - deprecated */
+ int4 attnvals /* - deprecated */
+ oid atttyparg /* - deprecated */
+ int2 attlen /* attribute length, in bytes
+ -1=variable */
+ int2 attnum /* attribute number
+ >0=user attribute
+ <0=system attribute */
+ int2 attbound /* - deprecated */
+ bool attbyval /* type passed by value? */
+ bool attcanindex /* - deprecated */
+ oid attproc /* - deprecated */
+ int4 attnelems /* # of array dimensions */
+ int4 attcacheoff /* cached offset into tuple */
+ bool attisset /* is attribute set-valued? */
+.fi
+.nf M
+pg_inherits
+ oid inhrel /* child class */
+ oid inhparent /* parent class */
+ int4 inhseqno /* - deprecated */
+.fi
+.nf M
+ oid indexrelid /* oid of secondary index class */
+ oid indrelid /* oid of indexed heap class */
+ oid indproc /* function to compute index key from
+ attribute(s) in heap
+ 0=not a functional index */
+ int28 indkey /* attribute numbers of key
+ attribute(s) */
+ oid8 indclass /* opclass of each key */
+ bool indisclustered /* is the index clustered?
+ - unused */
+ bool indisarchived /* is the index archival?
+ - unused */
+ text indpred /* query plan for partial index
+ predicate */
+.fi
+.nf M
+pg_type
+ NameData typname /* type name */
+ oid typowner /* usesysid of owner */
+ int2 typlen /* length in internal form
+ -1=variable-length */
+ int2 typprtlen /* length in external form */
+ bool typbyval /* type passed by value? */
+ char typtype /* kind of type:
+ c=catalog (composite)
+ b=base */
+ bool typisdefined /* defined or still a shell? */
+ char typdelim /* delimiter for array external form */
+ oid typrelid /* class (if composite) */
+ oid typelem /* type of each array element */
+ regproc typinput /* external-internal conversion
+ function */
+ regproc typoutput /* internal-external conversion
+ function */
+ regproc typreceive /* client-server conversion function */
+ regproc typsend /* server-client conversion function */
+ text typdefault /* default value */
+.fi
+.nf M
+pg_operator
+ NameData oprname /* operator name */
+ oid oprowner /* usesysid of owner */
+ int2 oprprec /* - deprecated */
+ char oprkind /* kind of operator:
+ b=binary
+ l=left unary
+ r=right unary */
+ bool oprisleft /* is operator left/right associative? */
+ bool oprcanhash /* is operator usable for hashjoin? */
+ oid oprleft /* left operand type */
+ oid oprright /* right operand type */
+ oid oprresult /* result type */
+ oid oprcom /* commutator operator */
+ oid oprnegate /* negator operator */
+ oid oprlsortop /* sort operator for left operand */
+ oid oprrsortop /* sort operator for right operand */
+ regproc oprcode /* function implementing this operator */
+ regproc oprrest /* function to calculate operator
+ restriction selectivity */
+ regproc oprjoin /* function to calculate operator
+ join selectivity */
+.fi
+.nf M
+pg_opclass
+ NameData opcname /* operator class name */
+.fi
+.nf M
+pg_proc
+ NameData proname /* function name */
+ oid proowner /* usesysid of owner */
+ oid prolang /* function implementation language */
+ bool proisinh /* - deprecated */
+ bool proistrusted /* run in server or untrusted function
+ process? */
+ bool proiscachable /* can the function return values be
+ cached? */
+ int2 pronargs /* # of arguments */
+ bool proretset /* does the function return a set?
+ - unused */
+ oid prorettype /* return type */
+ oid8 proargtypes /* argument types */
+ int4 probyte_pct /* % of argument size (in bytes) that
+ needs to be examined in order to
+ compute the function */
+ int4 properbyte_cpu /* sensitivity of the function's
+ running time to the size of its
+ inputs */
+ int4 propercall_cpu /* overhead of the function's
+ invocation (regardless of input
+ size) */
+ int4 prooutin_ratio /* size of the function's output as a
+ percentage of the size of the input */
+ text prosrc /* function definition (postquel only) */
+ bytea probin /* path to object file (C only) */
+.fi
+.nf M
+pg_language
+ NameData lanname /* language name */
+ text lancompiler /* - deprecated */
+.fi
+.SH "ENTITIES"
+.nf M
+pg_database
+ NameData datname /* database name */
+ oid datdba /* usesysid of database administrator */
+ text datpath /* directory of database under
+ $PGDATA */
+.fi
+.nf M
+pg_group
+ NameData groname /* group name */
+ int2 grosysid /* group's UNIX group id */
+ int2 grolist[1] /* list of usesysids of group members */
+.fi
+.nf M
+pg_user
+ NameData usename /* user's name */
+ int2 usesysid /* user's UNIX user id */
+ bool usecreatedb /* can user create databases? */
+ bool usetrace /* can user set trace flags? */
+ bool usesuper /* can user be POSTGRES superuser? */
+ bool usecatupd /* can user update catalogs? */
+.fi
+.SH "RULE SYSTEM CATALOGS"
+.nf M
+pg_listener
+ NameData relname /* class for which asynchronous
+ notification is desired */
+ int4 listenerpid /* process id of server corresponding
+ to a frontend program waiting for
+ asynchronous notification */
+ int4 notification /* whether an event notification for
+ this process id still pending */
+
+.fi
+.nf M
+pg_prs2rule
+ NameData prs2name /* rule name */
+ char prs2eventtype /* rule event type:
+ R=retrieve
+ U=update (replace)
+ A=append
+ D=delete */
+ oid prs2eventrel /* class to which event applies */
+ int2 prs2eventattr /* attribute to which event applies */
+ float8 necessary /* - deprecated */
+ float8 sufficient /* - deprecated */
+ text prs2text /* text of original rule definition */
+.fi
+.nf M
+pg_prs2plans
+ oid prs2ruleid /* prs2rule instance for which this
+ plan is used */
+ int2 prs2planno /* plan number (one rule may invoke
+ multiple plans) */
+ text prs2code /* external representation of the plan */
+.fi
+.nf M
+pg_prs2stub
+ oid prs2relid /* class to which this rule applies */
+ bool prs2islast /* is this the last stub fragment? */
+ int4 prs2no /* stub fragment number */
+ stub prs2stub /* stub fragment */
+.fi
+.nf M
+pg_rewrite
+ NameData rulename /* rule name */
+ char ev_type /* event type:
+ RETRIEVE, REPLACE, APPEND, DELETE
+ codes are parser-dependent (!?) */
+ oid ev_class /* class to which this rule applies */
+ int2 ev_attr /* attribute to which this rule applies */
+ bool is_instead /* is this an "instead" rule? */
+ text ev_qual /* qualification with which to modify
+ (rewrite) the plan that triggered this
+ rule */
+ text action /* parse tree of action */
+.fi
+.SH "LARGE OBJECT CATALOGS"
+.nf M
+pg_lobj
+ oid ourid /* 'ourid' from pg_naming that
+ identifies this object in the
+ Inversion file system namespace */
+ int4 objtype /* storage type code:
+ 0=Inversion
+ 1=Unix
+ 2=External
+ 3=Jaquith */
+ bytea object_descripto/* opaque object-handle structure */
+.fi
+.nf M
+pg_naming
+ NameData filename /* filename component */
+ oid ourid /* random oid used to identify this
+ instance in other instances (can't
+ use the actual oid for obscure
+ reasons */
+ oid parentid /* pg_naming instance of parent
+ Inversion file system directory */
+.fi
+.nf M
+pg_platter
+ NameData plname /* platter name */
+ int4 plstart /* the highest OCCUPIED extent */
+.fi
+.nf M
+pg_plmap
+ oid plid /* platter (in pg_platter) on which
+ this extent (of blocks) resides */
+ oid pldbid /* database of the class to which this
+ extent (of blocks) belongs */
+ oid plrelid /* class to which this extend (of
+ blocks) belongs */
+ int4 plblkno /* starting block number within the
+ class */
+ int4 ploffset /* offset within the platter at which
+ this extent begins */
+ int4 plextentsz /* length of this extent */
+.fi
diff --git a/doc/man/cleardbdir.1 b/doc/man/cleardbdir.1
new file mode 100644
index 00000000000..151434ce06b
--- /dev/null
+++ b/doc/man/cleardbdir.1
@@ -0,0 +1,23 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/cleardbdir.1,v 1.1.1.1 1996/08/18 22:14:20 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)
+
diff --git a/doc/man/close.l b/doc/man/close.l
new file mode 100644
index 00000000000..1638cc322d7
--- /dev/null
+++ b/doc/man/close.l
@@ -0,0 +1,28 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/close.l,v 1.1.1.1 1996/08/18 22:14:20 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).
diff --git a/doc/man/cluster.l b/doc/man/cluster.l
new file mode 100644
index 00000000000..a10e83bc2d7
--- /dev/null
+++ b/doc/man/cluster.l
@@ -0,0 +1,33 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/cluster.l,v 1.1.1.1 1996/08/18 22:14:20 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
+
diff --git a/doc/man/commit.l b/doc/man/commit.l
new file mode 100644
index 00000000000..461e981156c
--- /dev/null
+++ b/doc/man/commit.l
@@ -0,0 +1,23 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/commit.l,v 1.1.1.1 1996/08/18 22:14:20 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).
diff --git a/doc/man/copy.l b/doc/man/copy.l
new file mode 100644
index 00000000000..f2d00b64b7b
--- /dev/null
+++ b/doc/man/copy.l
@@ -0,0 +1,162 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/copy.l,v 1.1.1.1 1996/08/18 22:14:21 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] [\fBnonulls\fP] classname
+ \fBto\fP|\fBfrom\fP "filename"|\fBstdin\fR|\fBstdout\fR
+ [\fBUSING DELIMITERS\fP delim]
+.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.
+.IR Filename
+is the 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. 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.
+.PP
+By default,
+.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
+.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
+uint32 totallength (not including itself),
+uint32 number of null attributes
+[uint32 attribute number of first null attribute
+ ...
+ uint32 attribute number of nth null attribute],
+<data>
+.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.
diff --git a/doc/man/create_aggregate.l b/doc/man/create_aggregate.l
new file mode 100644
index 00000000000..645c54f8a51
--- /dev/null
+++ b/doc/man/create_aggregate.l
@@ -0,0 +1,94 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_aggregate.l,v 1.1.1.1 1996/08/18 22:14:21 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).
diff --git a/doc/man/create_function.l b/doc/man/create_function.l
new file mode 100644
index 00000000000..2eaa148e119
--- /dev/null
+++ b/doc/man/create_function.l
@@ -0,0 +1,417 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_function.l,v 1.1.1.1 1996/08/18 22:14:21 scrappy Exp $
+.TH "CREATE FUNCTION" SQL 11/05/95 Postgres95 Postgres95
+.SH "NAME"
+create function \(em define a new function
+.SH "SYNOPSIS"
+.nf
+\fBcreate function\fP function_name \fB(\fP
+ ([type1 {, type-n}])
+ \fBreturns\fP type-r
+ \fBas\fP {'/full/path/to/objectfile' | 'sql-queries'}
+ \fBlanguage\fP {'c' \ 'sql' \ 'internal'}
+.fi
+.SH "DESCRIPTION"
+With this command, a Postgres user can register a function with Postgres.
+Subsequently, this user is treated as the owner of the function.
+.PP
+When defining a function with arguments, the input data types,
+.IR type-1 ,
+.IR type-2 ,
+\&...,
+.IR type-n ,
+and the return data type,
+.IR type-r
+must be specified, along with the language, which may be
+.IR "\*(lqc\*(rq"
+or
+.IR "\*(lqsql\*(rq" .
+or
+.IR "\*(lqinternal\*(rq" .
+(The
+.IR "arg is"
+clause may be left out if the function has no arguments, or
+alternatively the argument list may be left empty.)
+The input types may be base or complex types, or
+.IR opaque .
+.IR Opaque
+indicates that the function accepts arguments of an
+invalid type such as (char *).
+The output type may be specified as a base type, complex type,
+.IR "setof <type>",
+or
+.IR opaque .
+The
+.IR setof
+modifier indicates that the function will return a set of items,
+rather than a single item.
+The
+.IR as
+clause of the command is treated differently for C and SQL
+functions, as explained below.
+.SH "C FUNCTIONS"
+Functions written in C can be defined to Postgres, which will dynamically
+load them into its address space. The loading happens either using
+.IR load (l)
+or automatically the first time the function is necessary for
+execution. Repeated execution of a function will cause negligible
+additional overhead, as the function will remain in a main memory
+cache.
+.PP
+Internal functions are functions written in C which have been statically
+linked into the postgres backend process. The
+.BR as
+clause must still be specified when defining an internal function but
+the contents are ignored.
+.SH "Writing C Functions"
+The body of a C function following
+.BR as
+should be the
+.BR "FULL PATH"
+of the object code (.o file) for the function, bracketed by quotation
+marks. (Postgres will not compile a function automatically \(em it must
+be compiled before it is used in a
+.BR "define function"
+command.)
+.PP
+C functions with base type arguments can be written in a
+straightforward fashion. The C equivalents of built-in Postgres types
+are accessible in a C file if
+.nf
+\&.../src/backend/utils/builtins.h
+.fi
+is included as a header file. This can be achieved by having
+.nf
+\&#include <utils/builtins.h>
+.fi
+at the top of the C source file and by compiling all C files with the
+following include options:
+.nf
+-I.../src/backend
+-I.../src/backend/port/<portname>
+-I.../src/backend/obj
+.fi
+before any \*(lq.c\*(rq programs in the
+.IR cc
+command line, e.g.:
+.nf
+cc -I.../src/backend \e
+ -I.../src/backend/port/<portname> \e
+ -I.../src/backend/obj \e
+ -c progname.c
+.fi
+where \*(lq...\*(rq is the path to the installed Postgres source tree and
+\*(lq<portname>\*(rq is the name of the port for which the source tree
+has been built.
+.PP
+The convention for passing arguments to and from the user's C
+functions is to use pass-by-value for data types that are 32 bits (4
+bytes) or smaller, and pass-by-reference for data types that require
+more than 32 bits.
+.if t \{
+The following table gives the C type required for parameters in the C
+functions that will be loaded into Postgres. The \*(lqDefined In\*(rq
+column gives the actual header file (in the
+.nf
+\&.../src/backend
+.fi
+directory) that the equivalent C type is defined. However, if you
+include \*(lqutils/builtins.h\*(rq, these files will automatically be
+included.
+.SH "Equivalent C Types for Built-In Postgres Types"
+.PP
+.TS
+center;
+l l l
+l l l.
+\fBBuilt-In Type\fP \fBC Type\fP \fBDefined In\fP
+_
+abstime AbsoluteTime utils/nabstime.h
+bool bool include/c.h
+box (BOX *) utils/geo-decls.h
+bytea (bytea *) include/postgres.h
+char char N/A
+char16 Char16 or (char16 *) include/postgres.h
+cid CID include/postgres.h
+int2 int2 include/postgres.h
+int28 (int28 *) include/postgres.h
+int4 int4 include/postgres.h
+float4 float32 or (float4 *) include/c.h or include/postgres.h
+float8 float64 or (float8 *) include/c.h or include/postgres.h
+lseg (LSEG *) include/geo-decls.h
+name (Name) include/postgres.h
+oid oid include/postgres.h
+oid8 (oid8 *) include/postgres.h
+path (PATH *) utils/geo-decls.h
+point (POINT *) utils/geo-decls.h
+regproc regproc or REGPROC include/postgres.h
+reltime RelativeTime utils/nabstime.h
+text (text *) include/postgres.h
+tid ItemPointer storage/itemptr.h
+tinterval TimeInterval utils/nabstime.h
+uint2 uint16 include/c.h
+uint4 uint32 include/c.h
+xid (XID *) include/postgres.h
+.TE
+\}
+.PP
+Complex arguments to C functions are passed into the C function as a
+special C type, TUPLE, defined in
+.nf
+\&.../src/libpq/libpq-fe.h.
+.fi
+Given a variable
+.IR t
+of this type, the C function may extract attributes from the function
+using the function call:
+.nf
+GetAttributeByName(t, "fieldname", &isnull)
+.fi
+where
+.IR isnull
+is a pointer to a
+.IR bool ,
+which the function sets to
+.IR true
+if the field is null. The result of this function should be cast
+appropriately as shown in the examples below.
+.SH "Compiling Dynamically-Loaded C Functions"
+.PP
+Different operating systems require different procedures for compiling
+C source files so that Postgres can load them dynamically. This section
+discusses the required compiler and loader options on each system.
+.PP
+Under Linux ELF, object files can be generated by specifing the compiler
+flag -fpic.
+.PP
+Under Ultrix, all object files that Postgres is expected to load
+dynamically must be compiled using
+.IR /bin/cc
+with the \*(lq-G 0\*(rq option turned on. The object file name in the
+.IR as
+clause should end in \*(lq.o\*(rq.
+.PP
+Under HP-UX, DEC OSF/1, AIX and SunOS 4, all object files must be
+turned into
+.IR "shared libraries"
+using the operating system's native object file loader,
+.IR ld (1).
+.PP
+Under HP-UX, an object file must be compiled using the native HP-UX C
+compiler,
+.IR /bin/cc ,
+with both the \*(lq+z\*(rq and \*(lq+u\*(rq flags turned on. The
+first flag turns the object file into \*(lqposition-independent
+code\*(rq (PIC); the second flag removes some alignment restrictions
+that the PA-RISC architecture normally enforces. The object file must
+then be turned into a shared library using the HP-UX loader,
+.IR /bin/ld .
+The command lines to compile a C source file, \*(lqfoo.c\*(rq, look
+like:
+.nf
+cc <other flags> +z +u -c foo.c
+ld <other flags> -b -o foo.sl foo.o
+.fi
+The object file name in the
+.BR as
+clause should end in \*(lq.sl\*(rq.
+.PP
+An extra step is required under versions of HP-UX prior to 9.00. If
+the Postgres header file
+.nf
+include/c.h
+.fi
+is not included in the source file, then the following line must also
+be added at the top of every source file:
+.nf
+#pragma HP_ALIGN HPUX_NATURAL_S500
+.fi
+However, this line must not appear in programs compiled under HP-UX
+9.00 or later.
+.PP
+Under DEC OSF/1, an object file must be compiled and then turned
+into a shared library using the OSF/1 loader,
+.IR /bin/ld .
+In this case, the command lines look like:
+.nf
+cc <other flags> -c foo.c
+ld <other flags> -shared -expect_unresolved '*' -o foo.so foo.o
+.fi
+The object file name in the
+.BR as
+clause should end in \*(lq.so\*(rq.
+.PP
+Under SunOS 4, an object file must be compiled and then turned into a
+shared library using the SunOS 4 loader,
+.IR /bin/ld .
+The command lines look like:
+.nf
+cc <other flags> -PIC -c foo.c
+ld <other flags> -dc -dp -Bdynamic -o foo.so foo.o
+.fi
+The object file name in the
+.BR as
+clause should end in \*(lq.so\*(rq.
+.PP
+Under AIX, object files are compiled normally but building the shared
+library requires a couple of steps. First, create the object file:
+.nf
+cc <other flags> -c foo.c
+.fi
+You must then create a symbol \*(lqexports\*(rq file for the object
+file:
+.nf
+mkldexport foo.o `pwd` > foo.exp
+.fi
+Finally, you can create the shared library:
+.nf
+ld <other flags> -H512 -T512 -o foo.so -e _nostart \e
+ -bI:.../lib/postgres.exp -bE:foo.exp foo.o \e
+ -lm -lc 2>/dev/null
+.fi
+You should look at the Postgres User's Manual for an explanation of this
+procedure.
+.SH "SQL FUNCTIONS"
+SQL functions execute an arbitrary list of SQL queries, returning
+the results of the last query in the list. SQL functions in general
+return sets. If their returntype is not specified as a
+.IR setof ,
+then an arbitrary element of the last query's result will be returned.
+.PP
+The body of a SQL function following
+.BR as
+should be a list of queries separated by whitespace characters and
+bracketed within quotation marks. Note that quotation marks used in
+the queries must be escaped, by preceding them with two backslashes
+(i.e. \e\e").
+.PP
+Arguments to the SQL function may be referenced in the queries using
+a $n syntax: $1 refers to the first argument, $2 to the second, and so
+on. If an argument is complex, then a \*(lqdot\*(rq notation may be
+used to access attributes of the argument (e.g. \*(lq$1.emp\*(rq), or
+to invoke functions via a nested-dot syntax.
+.SH "EXAMPLES: C Functions"
+The following command defines a C function, overpaid, of two basetype
+arguments.
+.nf
+create function overpaid (float8, int4) returns bool
+ as '/usr/postgres/src/adt/overpaid.o'
+ language 'c'
+.fi
+The C file "overpaid.c" might look something like:
+.nf
+#include <utils/builtins.h>
+
+bool overpaid(salary, age)
+ float8 *salary;
+ int4 age;
+{
+ if (*salary > 200000.00)
+ return(TRUE);
+ if ((age < 30) & (*salary > 100000.00))
+ return(TRUE);
+ return(FALSE);
+}
+.fi
+The overpaid function can be used in a query, e.g:
+.nf
+select name from EMP where overpaid(salary, age)
+.fi
+One can also write this as a function of a single argument of type
+EMP:
+.nf
+create function overpaid_2 (EMP)
+ returns bool
+ as '/usr/postgres/src/adt/overpaid_2.o'
+ language 'c'
+.fi
+The following query is now accepted:
+.nf
+select name from EMP where overpaid_2(EMP)
+.fi
+In this case, in the body of the overpaid_2 function, the fields in the EMP
+record must be extracted. The C file "overpaid_2.c" might look
+something like:
+.nf
+#include <utils/builtins.h>
+#include <libpq-fe.h>
+
+bool overpaid_2(t)
+TUPLE t;
+{
+ float8 *salary;
+ int4 age;
+ bool salnull, agenull;
+
+ salary = (float8 *)GetAttributeByName(t, "salary",
+ &salnull);
+ age = (int4)GetAttributeByName(t, "age", &agenull);
+ if (!salnull && *salary > 200000.00)
+ return(TRUE);
+ if (!agenull && (age<30) && (*salary > 100000.00))
+ return(TRUE);
+ return(FALSE)
+}
+.fi
+.SH "EXAMPLES: SQL Functions"
+To illustrate a simple SQL function, consider the following,
+which might be used to debit a bank account:
+.nf
+create function TP1 (int4, float8) returns int4
+ as 'update BANK set balance = BANK.balance - $2
+ where BANK.acctountno = $1
+ select(x = 1)'
+ language 'sql'
+.fi
+A user could execute this function to debit account 17 by $100.00 as
+follows:
+.nf
+select (x = TP1( 17,100.0))
+.fi
+The following more interesting examples take a single argument of type
+EMP, and retrieve multiple results:
+.nf
+select function hobbies (EMP) returns set of HOBBIES
+ as 'select (HOBBIES.all) from HOBBIES
+ where $1.name = HOBBIES.person'
+ language 'sql'
+.SH "SEE ALSO"
+.PP
+information(1), load(l), drop function(l).
+.SH "NOTES"
+.SH "Name Space Conflicts"
+More than one function may be defined with the same name, as long as
+the arguments they take are different. In other words, function names
+can be
+.IR overloaded .
+A function may also have the same name as an attribute. In the case
+that there is an ambiguity between a function on a complex type and
+an attribute of the complex type, the attribute will always be used.
+.SH "RESTRICTIONS"
+The name of the C function must be a legal C function name, and the
+name of the function in C code must be exactly the same as the name
+used in
+.BR "create function" .
+There is a subtle implication of this restriction: while the
+dynamic loading routines in most operating systems are more than
+happy to allow you to load any number of shared libraries that
+contain conflicting (identically-named) function names, they may
+in fact botch the load in interesting ways. For example, if you
+define a dynamically-loaded function that happens to have the
+same name as a function built into Postgres, the DEC OSF/1 dynamic
+loader causes Postgres to call the function within itself rather than
+allowing Postgres to call your function. Hence, if you want your
+function to be used on different architectures, we recommend that
+you do not overload C function names.
+.PP
+There is a clever trick to get around the problem just described.
+Since there is no problem overloading SQL functions, you can
+define a set of C functions with different names and then define
+a set of identically-named SQL function wrappers that take the
+appropriate argument types and call the matching C function.
+.PP
+.IR opaque
+cannot be given as an argument to a SQL function.
+.SH "BUGS"
+C functions cannot return a set of values.
diff --git a/doc/man/create_index.l b/doc/man/create_index.l
new file mode 100644
index 00000000000..3b3bd58e997
--- /dev/null
+++ b/doc/man/create_index.l
@@ -0,0 +1,314 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_index.l,v 1.1.1.1 1996/08/18 22:14:21 scrappy Exp $
+.TH "CREATE INDEX" SQL 11/05/95 Postgres95 Postgres95
+.SH NAME
+create index \(em construct a secondary index
+.SH SYNOPSIS
+.nf
+\fBcreate\fR \fBindex\fR index-name
+ \fBon\fR classname \fBusing\fR am-name
+ \fB(\fR attname type_class \fB)\fR
+
+\fBcreate\fR \fBindex\fR index-name
+ \fBon\fR classname \fBusing\fR am-name
+ \fB(\fR funcname \fB(\fR attname\-1 { , attname\-i } \fB)\fR type_class \fB)\fR
+.fi
+.SH DESCRIPTION
+This command constructs an index called
+.IR index-name.
+.PP
+.IR Am-name
+is the name of the access method which is used for the index.
+.PP
+In the first syntax shown above, the key field for the index is
+specified as an attribute name and an associated
+.IR "operator class" .
+An operator class is used to specify the operators to be used for a
+particular index. For example, a btree index on four-byte integers
+would use the
+.IR int4_ops
+class; this operator class includes comparison functions for four-byte
+integers.
+.PP
+In the second syntax shown above, an index can be defined on the
+result of a user-defined function
+.IR funcname
+applied to one or more attributes of a single class. These
+.IR "functional indices"
+are primarily useful in two situations. First, functional indices can
+be used to simulate multikey indices. That is, the user can define a
+new base type (a simple combination of, say, \*(lqoid\*(rq and
+\*(lqint2\*(rq) and the associated functions and operators on this new
+type such that the access method can use it. Once this has been done,
+the standard techniques for interfacing new types to access methods
+(described in the Postgres user manual) can be applied. Second,
+functional indices can be used to obtain fast access to data based on
+operators that would normally require some transformation to be
+applied to the base data. For example, say you have an attribute in
+class \*(lqmyclass\*(rq called \*(lqpt\*(rq that consists of a 2D
+point type. Now, suppose that you would like to index this attribute
+but you only have index operator classes for 2D polygon types. You
+can define an index on the point attribute using a function that you
+write (call it \*(lqpoint_to_polygon\*(rq) and your existing polygon
+operator class; after that, queries using existing polygon operators
+that reference \*(lqpoint_to_polygon(myclass.pt)\*(rq on one side will
+use the precomputed polygons stored in the functional index instead of
+computing a polygon for each and every instance in \*(lqmyclass\*(rq
+and then comparing it to the value on the other side of the operator.
+Obviously, the decision to build a functional index represents a
+tradeoff between space (for the index) and execution time.
+.PP
+Postgres provides btree, rtree and hash access methods for
+secondary indices. The btree access method is an implementation of
+the Lehman-Yao high-concurrency btrees. The rtree access method
+implements standard rtrees using Guttman's quadratic split algorithm.
+The hash access method is an implementation of Litwin's linear
+hashing. We mention the algorithms used solely to indicate that all
+of these access methods are fully dynamic and do not have to be
+optimized periodically (as is the case with, for example, static hash
+access methods).
+.PP
+This list was generated from the Postgres system catalogs with the query:
+
+.nf
+SELECT am.amname AS acc_name,
+ opc.opcname AS ops_name,
+ opr.oprname AS ops_comp
+FROM pg_am am, pg_amop amop, pg_opclass opc, pg_operator opr
+WHERE amop.amopid = am.oid AND
+ amop.amopclaid = opc.oid AND
+ amop.amopopr = opr.oid
+ORDER BY acc_name, ops_name, ops_comp;
+
+acc_name|ops_name |ops_comp
+--------+-----------+--------
+btree |abstime_ops|<
+btree |abstime_ops|<=
+btree |abstime_ops|=
+btree |abstime_ops|>
+btree |abstime_ops|>=
+btree |bpchar_ops |<
+btree |bpchar_ops |<=
+btree |bpchar_ops |=
+btree |bpchar_ops |>
+btree |bpchar_ops |>=
+btree |char16_ops |<
+btree |char16_ops |<=
+btree |char16_ops |=
+btree |char16_ops |>
+btree |char16_ops |>=
+btree |char2_ops |<
+btree |char2_ops |<=
+btree |char2_ops |=
+btree |char2_ops |>
+btree |char2_ops |>=
+btree |char4_ops |<
+btree |char4_ops |<=
+btree |char4_ops |=
+btree |char4_ops |>
+btree |char4_ops |>=
+btree |char8_ops |<
+btree |char8_ops |<=
+btree |char8_ops |=
+btree |char8_ops |>
+btree |char8_ops |>=
+btree |char_ops |<
+btree |char_ops |<=
+btree |char_ops |=
+btree |char_ops |>
+btree |char_ops |>=
+btree |date_ops |<
+btree |date_ops |<=
+btree |date_ops |=
+btree |date_ops |>
+btree |date_ops |>=
+btree |float4_ops |<
+btree |float4_ops |<=
+btree |float4_ops |=
+btree |float4_ops |>
+btree |float4_ops |>=
+btree |float8_ops |<
+btree |float8_ops |<=
+btree |float8_ops |=
+btree |float8_ops |>
+btree |float8_ops |>=
+btree |int24_ops |<
+btree |int24_ops |<=
+btree |int24_ops |=
+btree |int24_ops |>
+btree |int24_ops |>=
+btree |int2_ops |<
+btree |int2_ops |<=
+btree |int2_ops |=
+btree |int2_ops |>
+btree |int2_ops |>=
+btree |int42_ops |<
+btree |int42_ops |<=
+btree |int42_ops |=
+btree |int42_ops |>
+btree |int42_ops |>=
+btree |int4_ops |<
+btree |int4_ops |<=
+btree |int4_ops |=
+btree |int4_ops |>
+btree |int4_ops |>=
+btree |name_ops |<
+btree |name_ops |<=
+btree |name_ops |=
+btree |name_ops |>
+btree |name_ops |>=
+btree |oid_ops |<
+btree |oid_ops |<=
+btree |oid_ops |=
+btree |oid_ops |>
+btree |oid_ops |>=
+btree |oidint2_ops|<
+btree |oidint2_ops|<=
+btree |oidint2_ops|=
+btree |oidint2_ops|>
+btree |oidint2_ops|>=
+btree |oidint4_ops|<
+btree |oidint4_ops|<=
+btree |oidint4_ops|=
+btree |oidint4_ops|>
+btree |oidint4_ops|>=
+btree |oidname_ops|<
+btree |oidname_ops|<=
+btree |oidname_ops|=
+btree |oidname_ops|>
+btree |oidname_ops|>=
+btree |text_ops |<
+btree |text_ops |<=
+btree |text_ops |=
+btree |text_ops |>
+btree |text_ops |>=
+btree |time_ops |<
+btree |time_ops |<=
+btree |time_ops |=
+btree |time_ops |>
+btree |time_ops |>=
+btree |varchar_ops|<
+btree |varchar_ops|<=
+btree |varchar_ops|=
+btree |varchar_ops|>
+btree |varchar_ops|>=
+hash |bpchar_ops |=
+hash |char16_ops |=
+hash |char2_ops |=
+hash |char4_ops |=
+hash |char8_ops |=
+hash |char_ops |=
+hash |date_ops |=
+hash |float4_ops |=
+hash |float8_ops |=
+hash |int2_ops |=
+hash |int4_ops |=
+hash |name_ops |=
+hash |oid_ops |=
+hash |text_ops |=
+hash |time_ops |=
+hash |varchar_ops|=
+rtree |bigbox_ops |&&
+rtree |bigbox_ops |&<
+rtree |bigbox_ops |&>
+rtree |bigbox_ops |<<
+rtree |bigbox_ops |>>
+rtree |bigbox_ops |@
+rtree |bigbox_ops |~
+rtree |bigbox_ops |~=
+rtree |box_ops |&&
+rtree |box_ops |&<
+rtree |box_ops |&>
+rtree |box_ops |<<
+rtree |box_ops |>>
+rtree |box_ops |@
+rtree |box_ops |~
+rtree |box_ops |~=
+rtree |poly_ops |&&
+rtree |poly_ops |&<
+rtree |poly_ops |&>
+rtree |poly_ops |<<
+rtree |poly_ops |>>
+rtree |poly_ops |@
+rtree |poly_ops |~
+rtree |poly_ops |~=
+
+.fi
+The
+.IR int24_ops
+operator class is useful for constructing indices on int2 data, and
+doing comparisons against int4 data in query qualifications.
+Similarly,
+.IR int42_ops
+support indices on int4 data that is to be compared against int2 data
+in queries.
+.PP
+The operator classes
+.IR oidint2_ops ,
+.IR oidint4_ops ,
+and
+.IR oidchar16_ops
+represent the use of
+.IR "functional indices"
+to simulate multi-key indices.
+.PP
+The Postgres query optimizer will consider using btree indices in a scan
+whenever an indexed attribute is involved in a comparison using one of:
+
+.nf
+< <= = >= >
+.fi
+
+Both box classes support indices on the \*(lqbox\*(rq datatype in
+Postgres. The difference between them is that
+.IR bigbox_ops
+scales box coordinates down, to avoid floating point exceptions from
+doing multiplication, addition, and subtraction on very large
+floating-point coordinates. If the field on which your rectangles lie
+is about 20,000 units square or larger, you should use
+.IR bigbox_ops .
+The
+.IR poly_ops
+operator class supports rtree indices on \*(lqpolygon\*(rq data.
+.PP
+The Postgres query optimizer will consider using an rtree index whenever
+an indexed attribute is involved in a comparison using one of:
+
+.nf
+<< &< &> >> @ ~= &&
+.fi
+
+The Postgres query optimizer will consider using a hash index whenever
+an indexed attribute is involved in a comparison using the \fB=\fR operator.
+.SH EXAMPLES
+.nf
+--
+--Create a btree index on the emp class using the age attribute.
+--
+create index empindex on emp using btree (age int4_ops)
+.fi
+.nf
+--
+--Create a btree index on employee name.
+--
+create index empname
+ on emp using btree (name char16_ops)
+.fi
+.nf
+--
+--Create an rtree index on the bounding rectangle of cities.
+--
+create index cityrect
+ on city using rtree (boundbox box_ops)
+.fi
+.nf
+--
+--Create a rtree index on a point attribute such that we
+--can efficiently use box operators on the result of the
+--conversion function. Such a qualification might look
+--like "where point2box(points.pointloc) = boxes.box".
+--
+create index pointloc
+ on points using rtree (point2box(location) box_ops)
+.nf
diff --git a/doc/man/create_operator.l b/doc/man/create_operator.l
new file mode 100644
index 00000000000..3c49dc004f4
--- /dev/null
+++ b/doc/man/create_operator.l
@@ -0,0 +1,219 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_operator.l,v 1.1.1.1 1996/08/18 22:14:21 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.
diff --git a/doc/man/create_rule.l b/doc/man/create_rule.l
new file mode 100644
index 00000000000..86bc53e8221
--- /dev/null
+++ b/doc/man/create_rule.l
@@ -0,0 +1,221 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_rule.l,v 1.1.1.1 1996/08/18 22:14:21 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).
diff --git a/doc/man/create_table.l b/doc/man/create_table.l
new file mode 100644
index 00000000000..ecb03a2de6c
--- /dev/null
+++ b/doc/man/create_table.l
@@ -0,0 +1,145 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_table.l,v 1.1.1.1 1996/08/18 22:14:22 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).
diff --git a/doc/man/create_type.l b/doc/man/create_type.l
new file mode 100644
index 00000000000..42f1e677654
--- /dev/null
+++ b/doc/man/create_type.l
@@ -0,0 +1,161 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_type.l,v 1.1.1.1 1996/08/18 22:14:22 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).
diff --git a/doc/man/create_version.l b/doc/man/create_version.l
new file mode 100644
index 00000000000..ca8bd4fac25
--- /dev/null
+++ b/doc/man/create_version.l
@@ -0,0 +1,69 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_version.l,v 1.1.1.1 1996/08/18 22:14:22 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.
diff --git a/doc/man/create_view.l b/doc/man/create_view.l
new file mode 100644
index 00000000000..24e31066d3f
--- /dev/null
+++ b/doc/man/create_view.l
@@ -0,0 +1,45 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/create_view.l,v 1.1.1.1 1996/08/18 22:14:22 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),
diff --git a/doc/man/createdb.1 b/doc/man/createdb.1
new file mode 100644
index 00000000000..832cc39dff8
--- /dev/null
+++ b/doc/man/createdb.1
@@ -0,0 +1,127 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/createdb.1,v 1.1.1.1 1996/08/18 22:14:22 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 .
diff --git a/doc/man/createdb.l b/doc/man/createdb.l
new file mode 100644
index 00000000000..6de86972d51
--- /dev/null
+++ b/doc/man/createdb.l
@@ -0,0 +1,25 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/createdb.l,v 1.1.1.1 1996/08/18 22:14:22 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.
diff --git a/doc/man/createuser.1 b/doc/man/createuser.1
new file mode 100644
index 00000000000..275e77db54d
--- /dev/null
+++ b/doc/man/createuser.1
@@ -0,0 +1,122 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/createuser.1,v 1.1.1.1 1996/08/18 22:14:22 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.
diff --git a/doc/man/delete.l b/doc/man/delete.l
new file mode 100644
index 00000000000..5836a4756e1
--- /dev/null
+++ b/doc/man/delete.l
@@ -0,0 +1,41 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/delete.l,v 1.1.1.1 1996/08/18 22:14:23 scrappy Exp $
+.TH DELETE SQL 11/05/95 Postgres95 Postgres95
+.SH NAME
+delete \(em delete instances from a class
+.SH SYNOPSIS
+.nf
+\fBdelete\fR instance_variable [ \fBfrom\fR from_list ] [ \fBwhere\fR qual ]
+.fi
+.SH DESCRIPTION
+.BR Delete
+removes instances which satisfy the qualification,
+.IR qual ,
+from the class specified by
+.IR instance_variable .
+.IR Instance_variable
+is either a class name or a variable assigned by
+.IR from_list .
+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).
diff --git a/doc/man/destroydb.1 b/doc/man/destroydb.1
new file mode 100644
index 00000000000..4fdcab80308
--- /dev/null
+++ b/doc/man/destroydb.1
@@ -0,0 +1,134 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/destroydb.1,v 1.1.1.1 1996/08/18 22:14:23 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.
diff --git a/doc/man/destroydb.l b/doc/man/destroydb.l
new file mode 100644
index 00000000000..01b96de8fc5
--- /dev/null
+++ b/doc/man/destroydb.l
@@ -0,0 +1,26 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/destroydb.l,v 1.1.1.1 1996/08/18 22:14:23 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.
diff --git a/doc/man/destroyuser.1 b/doc/man/destroyuser.1
new file mode 100644
index 00000000000..483fe7623f5
--- /dev/null
+++ b/doc/man/destroyuser.1
@@ -0,0 +1,119 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/destroyuser.1,v 1.1.1.1 1996/08/18 22:14:23 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.
diff --git a/doc/man/drop.l b/doc/man/drop.l
new file mode 100644
index 00000000000..d57bca0d3b4
--- /dev/null
+++ b/doc/man/drop.l
@@ -0,0 +1,41 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/drop.l,v 1.1.1.1 1996/08/18 22:14:23 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).
diff --git a/doc/man/drop_aggregate.l b/doc/man/drop_aggregate.l
new file mode 100644
index 00000000000..e315fc2439b
--- /dev/null
+++ b/doc/man/drop_aggregate.l
@@ -0,0 +1,24 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/drop_aggregate.l,v 1.1.1.1 1996/08/18 22:14:23 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).
diff --git a/doc/man/drop_function.l b/doc/man/drop_function.l
new file mode 100644
index 00000000000..6a8c33de85f
--- /dev/null
+++ b/doc/man/drop_function.l
@@ -0,0 +1,28 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/drop_function.l,v 1.1.1.1 1996/08/18 22:14:23 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.
diff --git a/doc/man/drop_index.l b/doc/man/drop_index.l
new file mode 100644
index 00000000000..7423556c2a7
--- /dev/null
+++ b/doc/man/drop_index.l
@@ -0,0 +1,22 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/drop_index.l,v 1.1.1.1 1996/08/18 22:14:23 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).
diff --git a/doc/man/drop_operator.l b/doc/man/drop_operator.l
new file mode 100644
index 00000000000..a5e0bd3b175
--- /dev/null
+++ b/doc/man/drop_operator.l
@@ -0,0 +1,44 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/drop_operator.l,v 1.1.1.1 1996/08/18 22:14:23 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).
diff --git a/doc/man/drop_rule.l b/doc/man/drop_rule.l
new file mode 100644
index 00000000000..1af37de11e0
--- /dev/null
+++ b/doc/man/drop_rule.l
@@ -0,0 +1,27 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/drop_rule.l,v 1.1.1.1 1996/08/18 22:14:24 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.
diff --git a/doc/man/drop_type.l b/doc/man/drop_type.l
new file mode 100644
index 00000000000..e2ab3d70c67
--- /dev/null
+++ b/doc/man/drop_type.l
@@ -0,0 +1,30 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/drop_type.l,v 1.1.1.1 1996/08/18 22:14:24 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.
diff --git a/doc/man/end.l b/doc/man/end.l
new file mode 100644
index 00000000000..e1ea684721b
--- /dev/null
+++ b/doc/man/end.l
@@ -0,0 +1,17 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/end.l,v 1.1.1.1 1996/08/18 22:14:24 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).
diff --git a/doc/man/fetch.l b/doc/man/fetch.l
new file mode 100644
index 00000000000..c5a867ac45e
--- /dev/null
+++ b/doc/man/fetch.l
@@ -0,0 +1,70 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/fetch.l,v 1.1.1.1 1996/08/18 22:14:24 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
+Portals 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 myportal cursor for
+ select * from pg-user
+end
+.fi
+.nf
+--
+--Fetch all the instances available in the portal FOO
+--
+fetch all in FOO
+.fi
+.nf
+--
+--Fetch 5 instances backward in the portal 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.
diff --git a/doc/man/files.5 b/doc/man/files.5
new file mode 100644
index 00000000000..52a17108f1c
--- /dev/null
+++ b/doc/man/files.5
@@ -0,0 +1,37 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/files.5,v 1.1.1.1 1996/08/18 22:14:24 scrappy Exp $
+.TH INFORMATION FILES 01/23/93 Postgres95 Postgres95
+.SH "Section 8 \(em Files"
+.SH "General Information"
+.SH OVERVIEW
+This section describes
+some of the important files used by Postgres.
+.SH NOTATION
+\*(lq.../\*(rq at the front of file names represents the path to the
+postgres user's home directory. Anything in square brackets
+.RB (\*(lq "[" \*(rq
+and
+.RB \*(lq "]" \*(rq)
+is optional.
+Anything in braces
+.RB (\*(lq "{" \*(rq
+and
+.RB \*(lq "}" \*(rq)
+can be repeated 0 or more times. Parentheses
+.BR (\*(lq "(" \*(rq
+and
+.BR \*(lq ")" \*(rq)
+are used to group boolean expressions.
+.BR |
+is the boolean operator
+.SM OR\c
+\&.
+.SH BUGS
+The descriptions of
+.nf
+ .../data/PG_VERSION,
+ .../data/base/*/PG_VERSION,
+.fi
+the temporary sort files, and the database debugging trace files are
+absent.
diff --git a/doc/man/grant.l b/doc/man/grant.l
new file mode 100644
index 00000000000..cebac49f031
--- /dev/null
+++ b/doc/man/grant.l
@@ -0,0 +1,33 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/grant.l,v 1.1.1.1 1996/08/18 22:14:24 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)
+
diff --git a/doc/man/initdb.1 b/doc/man/initdb.1
new file mode 100644
index 00000000000..6e286d9feac
--- /dev/null
+++ b/doc/man/initdb.1
@@ -0,0 +1,65 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/initdb.1,v 1.1.1.1 1996/08/18 22:14:24 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 "-v"
+]
+[\c
+.BR "-d"
+]
+[\c
+.BR "-n"
+]
+.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 "-v"
+Produce verbose output, printing messages stating where the
+directories are being created, etc.
+.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.
+.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).
diff --git a/doc/man/insert.l b/doc/man/insert.l
new file mode 100644
index 00000000000..4db474dd673
--- /dev/null
+++ b/doc/man/insert.l
@@ -0,0 +1,113 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/insert.l,v 1.1.1.1 1996/08/18 22:14:24 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)
diff --git a/doc/man/ipcclean.1 b/doc/man/ipcclean.1
new file mode 100644
index 00000000000..5fe533cc891
--- /dev/null
+++ b/doc/man/ipcclean.1
@@ -0,0 +1,36 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/ipcclean.1,v 1.1.1.1 1996/08/18 22:14:24 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.
diff --git a/doc/man/large_objects.3 b/doc/man/large_objects.3
new file mode 100644
index 00000000000..c253a90d093
--- /dev/null
+++ b/doc/man/large_objects.3
@@ -0,0 +1,499 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /usr/local/devel/postgres/src/ref/RCS/large_objects.3pqsrc,v 1.12 1
+993/08/23 09:03:16 aoki Exp $
+.TH "LARGE OBJECTS" INTRO 03/18/94 Postgres95 Postgres95
+.SH DESCRIPTION
+.PP
+In Postgres, data values are stored in tuples and individual tuples
+cannot span data pages. Since the size of a data page is 8192 bytes,
+the upper limit on the size of a data value is relatively low. To
+support the storage of larger atomic values, Postgres provides a large
+object interface. This interface provides file-oriented access to
+user data that has been declared to be a large type.
+.PP
+This section describes the implementation and the
+programmatic and query language interfaces to Postgres large object data.
+.PP
+.SH "Historical Note"
+.SH "Historical Note"
+.PP
+Originally, postgres 4.2 supports three standard implementations of large
+objects: as files external to Postgres, as Unix files managed by Postgres, and as
+data stored within the Postgres database. It causes considerable confusion
+among users. As a result, we only support large objects as data stored
+within the Postgres database in Postgres. Even though is is slower to access,
+it provides stricter data integrity and time travel. For historical reasons,
+they are called Inversion large objects. (We will use Inversion and large
+objects interchangeably to mean the same thing in this section.)
+.SH "Inversion Large Objects"
+.SH "Inversion Large Objects"
+.PP
+The Inversion large
+object implementation breaks large objects up into \*(lqchunks\*(rq and
+stores the chunks in tuples in the database. A B-tree index
+guarantees fast searches for the correct chunk number when doing
+random access reads and writes.
+.SH "Large Object Interfaces"
+.SH "Large Object Interfaces"
+.PP
+The facilities Postgres provides to access large objects, both in
+the backend as part of user-defined functions or the front end
+as part of an application using the \*(LQ interface, are described
+below. (For users familiar with postgres 4.2, Postgres has a new set of
+functions providing a more coherent interface. The interface is the same
+for dynamically-loaded C functions as well as for \*(LQ.
+.PP
+The Postgres large object interface is modeled after the Unix file
+system interface, with analogues of
+.I open (2),
+.I read (2),
+.I write (2),
+.I lseek (2),
+etc. User functions call these routines to retrieve only the data of
+interest from a large object. For example, if a large object type
+called
+.I mugshot
+existed that stored photographs of faces, then a function called
+.I beard
+could be declared on
+.I mugshot
+data.
+.I Beard
+could look at the lower third of a photograph, and determine the color
+of the beard that appeared there, if any. The entire large object
+value need not be buffered, or even examined, by the
+.I beard
+function.
+.\"As mentioned above, Postgres supports functional indices on
+.\"large object data. In this example, the results of the
+.\".I beard
+.\"function could be stored in a B-tree index to provide fast searches
+.\"for people with red beards.
+.PP
+Large objects may be accessed from dynamically-loaded C functions
+or database client programs that link the Libpq library.
+Postgres provides a set of routines that
+support opening, reading, writing, closing, and seeking on large
+objects.
+.SH "Creating a Large Object"
+.SH "Creating a Large Object"
+.PP
+The routine
+.nf
+Oid lo_creat(PGconn *conn, int mode)
+.fi
+creates a new large object. The
+.I mode
+is a bitmask describing several different attributes of the new
+object. The symbolic constants listed here are defined in
+.nf
+/usr/local/postgres95/src/backend/libpq/libpq-fs.h
+.fi
+The access type (read, write, or both) is controlled by
+.SM OR
+ing together the bits
+.SM INV_READ
+and
+.SM INV_WRITE .
+If the large object should be archived \(em that is, if
+historical versions of it should be moved periodically to a special
+archive relation \(em then the
+.SM INV_ARCHIVE
+bit should be set. The low-order sixteen bits of
+.I mask
+are the storage manager number on which the large object should
+reside. For sites other than Berkeley, these bits should always be
+zero.
+.\"At Berkeley, storage manager zero is magnetic disk, storage
+.\"manager one is a Sony optical disk jukebox, and storage manager two is
+.\"main memory.
+.PP
+The commands below create an (Inversion) large object:
+.nf
+inv_oid = lo_creat(INV_READ|INV_WRITE|INV_ARCHIVE);
+.fi
+.SH "Importing a Large Object"
+.SH "Importing a Large Object"
+To import a UNIX file as a large object, call
+.nf
+Oid
+lo_import(PGconn *conn, text *filename)
+.fi
+The
+.I filename
+argument specifies the UNIX pathname of the file to be imported as
+a large object.
+.SH "Exporting a Large Object"
+.SH "Exporting a Large Object"
+To export a large object into UNIX file, call
+.nf
+int
+lo_export(PGconn *conn, Oid lobjId, text *filename)
+.fi
+The
+.I lobjId
+argument specifies the Oid of the large object to export and
+the
+.I filename
+argument specifies the UNIX pathname of the file.
+.SH "Opening an Existing Large Object"
+.SH "Opening an Existing Large Object"
+.PP
+To open an existing large object, call
+.nf
+int
+lo_open(PGconn *conn, Oid lobjId, int mode, ...)
+.fi
+The
+.I lobjId
+argument specifies the Oid of the large object to open.
+The mode bits control whether the object is opened for reading
+.SM INV_READ ), (
+writing
+.SM INV_WRITE ), (
+or both.
+.PP
+A large object cannot be opened before it is created.
+.B lo_open
+returns a large object descriptor for later use in
+.B lo_read ,
+.B lo_write ,
+.B lo_lseek ,
+.B lo_tell ,
+and
+.B lo_close .
+.\"-----------
+.SH "Writing Data to a Large Object"
+.SH "Writing Data to a Large Object"
+.PP
+The routine
+.nf
+int
+lo_write(PGconn *conn, int fd, char *buf, int len)
+.fi
+writes
+.I len
+bytes from
+.I buf
+to large object
+.I fd .
+The
+.I fd
+argument must have been returned by a previous
+.I lo_open .
+.PP
+The number of bytes actually written is returned.
+In the event of an error,
+the return value is negative.
+.SH "Seeking on a Large Object"
+.SH "Seeking on a Large Object"
+.PP
+To change the current read or write location on a large object,
+call
+.nf
+int
+lo_lseek(PGconn *conn, int fd, int offset, int whence)
+.fi
+This routine moves the current location pointer for the large object
+described by
+.I fd
+to the new location specified by
+.I offset .
+The valid values for .I whence are
+.SM SEEK_SET
+.SM SEEK_CUR
+and
+.SM SEEK_END.
+.\"-----------
+.SH "Closing a Large Object Descriptor"
+.SH "Closing a Large Object Descriptor"
+.PP
+A large object may be closed by calling
+.nf
+int
+lo_close(PGconn *conn, int fd)
+.fi
+where
+.I fd
+is a large object descriptor returned by
+.I lo_open .
+On success,
+.I lo_close
+returns zero. On error, the return value is negative.
+.PP
+.SH "Built in registered functions"
+.SH "Built in registered functions"
+.PP
+There are two built-in registered functions,
+.I lo_import
+and
+.I lo_export
+which are convenient for use in SQL queries.
+.PP
+Here is an example of there use
+.nf
+CREATE TABLE image (
+ name text,
+ raster oid
+);
+
+INSERT INTO image (name, raster)
+ VALUES ('beautiful image', lo_import('/etc/motd'));
+
+SELECT lo_export(image.raster, "/tmp/motd") from image
+ WHERE name = 'beautiful image';
+.fi
+.PP
+.SH "Accessing Large Objects from LIBPQ"
+.SH "Accessing Large Objects from LIBPQ"
+Below is a sample program which shows how the large object interface in
+\*(LP can be used. Parts of the program are commented out but are left
+in the source for the readers benefit. This program can be found in
+.nf
+\&../src/test/examples
+.fi
+.PP
+Frontend applications which use the large object interface in \*(LP
+should include the header file
+.B "libpq/libpq-fs.h"
+and link with the
+.B libpq
+library.
+.bp
+.SH "Sample Program"
+.SH "Sample Program"
+.nf
+/*-------------------------------------------------------------------------
+ *
+ * testlo.c--
+ * test using large objects with libpq
+ *
+ * Copyright (c) 1994, Regents of the University of California
+ *
+ *
+ * IDENTIFICATION
+ * $Header: /cvsroot/pgsql/doc/man/Attic/large_objects.3,v 1.1.1.1 1996/08/18 22:14:25 scrappy Exp $
+ *
+ *-------------------------------------------------------------------------
+ */
+#include <stdio.h>
+#include "libpq-fe.h"
+#include "libpq/libpq-fs.h"
+
+#define BUFSIZE 1024
+
+/*
+ * importFile -
+ * import file "in_filename" into database as large object "lobjOid"
+ *
+ */
+Oid importFile(PGconn *conn, char *filename)
+{
+ Oid lobjId;
+ int lobj_fd;
+ char buf[BUFSIZE];
+ int nbytes, tmp;
+ int fd;
+
+ /*
+ * open the file to be read in
+ */
+ fd = open(filename, O_RDONLY, 0666);
+ if (fd < 0) { /* error */
+ fprintf(stderr, "can't open unix file\"%s\"\n", filename);
+ }
+
+ /*
+ * create the large object
+ */
+ lobjId = lo_creat(conn, INV_READ|INV_WRITE);
+ if (lobjId == 0) {
+ fprintf(stderr, "can't create large object");
+ }
+
+ lobj_fd = lo_open(conn, lobjId, INV_WRITE);
+ /*
+ * read in from the Unix file and write to the inversion file
+ */
+ while ((nbytes = read(fd, buf, BUFSIZE)) > 0) {
+ tmp = lo_write(conn, lobj_fd, buf, nbytes);
+ if (tmp < nbytes) {
+ fprintf(stderr, "error while reading \"%s\"", filename);
+ }
+ }
+
+ (void) close(fd);
+ (void) lo_close(conn, lobj_fd);
+
+ return lobjId;
+}
+
+void pickout(PGconn *conn, Oid lobjId, int start, int len)
+{
+ int lobj_fd;
+ char* buf;
+ int nbytes;
+ int nread;
+
+ lobj_fd = lo_open(conn, lobjId, INV_READ);
+ if (lobj_fd < 0) {
+ fprintf(stderr,"can't open large object %d",
+ lobjId);
+ }
+
+ lo_lseek(conn, lobj_fd, start, SEEK_SET);
+ buf = malloc(len+1);
+
+ nread = 0;
+ while (len - nread > 0) {
+ nbytes = lo_read(conn, lobj_fd, buf, len - nread);
+ buf[nbytes] = '\0';
+ fprintf(stderr,">>> %s", buf);
+ nread += nbytes;
+ }
+ fprintf(stderr,"\n");
+ lo_close(conn, lobj_fd);
+}
+
+void overwrite(PGconn *conn, Oid lobjId, int start, int len)
+{
+ int lobj_fd;
+ char* buf;
+ int nbytes;
+ int nwritten;
+ int i;
+
+ lobj_fd = lo_open(conn, lobjId, INV_READ);
+ if (lobj_fd < 0) {
+ fprintf(stderr,"can't open large object %d",
+ lobjId);
+ }
+
+ lo_lseek(conn, lobj_fd, start, SEEK_SET);
+ buf = malloc(len+1);
+
+ for (i=0;i<len;i++)
+ buf[i] = 'X';
+ buf[i] = '\0';
+
+ nwritten = 0;
+ while (len - nwritten > 0) {
+ nbytes = lo_write(conn, lobj_fd, buf + nwritten, len - nwritten);
+ nwritten += nbytes;
+ }
+ fprintf(stderr,"\n");
+ lo_close(conn, lobj_fd);
+}
+
+
+/*
+ * exportFile -
+ * export large object "lobjOid" to file "out_filename"
+ *
+ */
+void exportFile(PGconn *conn, Oid lobjId, char *filename)
+{
+ int lobj_fd;
+ char buf[BUFSIZE];
+ int nbytes, tmp;
+ int fd;
+
+ /*
+ * create an inversion "object"
+ */
+ lobj_fd = lo_open(conn, lobjId, INV_READ);
+ if (lobj_fd < 0) {
+ fprintf(stderr,"can't open large object %d",
+ lobjId);
+ }
+
+ /*
+ * open the file to be written to
+ */
+ fd = open(filename, O_CREAT|O_WRONLY, 0666);
+ if (fd < 0) { /* error */
+ fprintf(stderr, "can't open unix file\"%s\"",
+ filename);
+ }
+
+ /*
+ * read in from the Unix file and write to the inversion file
+ */
+ while ((nbytes = lo_read(conn, lobj_fd, buf, BUFSIZE)) > 0) {
+ tmp = write(fd, buf, nbytes);
+ if (tmp < nbytes) {
+ fprintf(stderr,"error while writing \"%s\"",
+ filename);
+ }
+ }
+
+ (void) lo_close(conn, lobj_fd);
+ (void) close(fd);
+
+ return;
+}
+
+void
+exit_nicely(PGconn* conn)
+{
+ PQfinish(conn);
+ exit(1);
+}
+
+int
+main(int argc, char **argv)
+{
+ char *in_filename, *out_filename;
+ char *database;
+ Oid lobjOid;
+ PGconn *conn;
+ PGresult *res;
+
+ if (argc != 4) {
+ fprintf(stderr, "Usage: %s database_name in_filename out_filename\n",
+ argv[0]);
+ exit(1);
+ }
+
+ database = argv[1];
+ in_filename = argv[2];
+ out_filename = argv[3];
+
+ /*
+ * set up the connection
+ */
+ conn = PQsetdb(NULL, NULL, NULL, NULL, database);
+
+ /* check to see that the backend connection was successfully made */
+ if (PQstatus(conn) == CONNECTION_BAD) {
+ fprintf(stderr,"Connection to database '%s' failed.\n", database);
+ fprintf(stderr,"%s",PQerrorMessage(conn));
+ exit_nicely(conn);
+ }
+
+ res = PQexec(conn, "begin");
+ PQclear(res);
+ printf("importing file \"%s\" ...\n", in_filename);
+/* lobjOid = importFile(conn, in_filename); */
+ lobjOid = lo_import(conn, in_filename);
+/*
+ printf("\tas large object %d.\n", lobjOid);
+
+ printf("picking out bytes 1000-2000 of the large object\n");
+ pickout(conn, lobjOid, 1000, 1000);
+
+ printf("overwriting bytes 1000-2000 of the large object with X's\n");
+ overwrite(conn, lobjOid, 1000, 1000);
+*/
+
+ printf("exporting large object to file \"%s\" ...\n", out_filename);
+/* exportFile(conn, lobjOid, out_filename); */
+ lo_export(conn, lobjOid,out_filename);
+
+ res = PQexec(conn, "end");
+ PQclear(res);
+ PQfinish(conn);
+ exit(0);
+}
+.fi
diff --git a/doc/man/libpq.3 b/doc/man/libpq.3
new file mode 100644
index 00000000000..01d731a1541
--- /dev/null
+++ b/doc/man/libpq.3
@@ -0,0 +1,962 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/libpq.3,v 1.1.1.1 1996/08/18 22:14:25 scrappy Exp $
+.TH LIBPQ INTRO 03/12/94 Postgres95 Postgres95
+.SH DESCRIPTION
+Libpq is the programmer's interface to Postgres. Libpq is a set of
+library routines that allows queries to pass to the Postgres backend and
+instances to return through an IPC channel.
+.PP
+This version of the documentation describes the C interface library.
+Three short programs are included at the end of this section to show how
+to write programs that use Libpq.
+.PP
+There are several examples of Libpq applications in the following
+directories:
+.nf
+\&../src/test/regress
+\&../src/test/examples
+\&../src/bin/psql
+.fi
+.PP
+Frontend programs which use Libpq must include the header file
+.B "libpq-fe.h"
+and must link with the
+.B libpq
+library.
+.SH "Control and Initialization"
+.PP
+The following environment variables can be used to set up default
+environment values to avoid hard-coding database names into
+an application program:
+.sp
+\(bu
+.B PGHOST
+sets the default server name.
+.sp
+\(bu
+.B PGOPTIONS
+sets additional runtime options for the Postgres backend.
+.sp
+\(bu
+.B PGPORT
+sets the default port for communicating with the Postgres backend.
+.sp
+\(bu
+.B PGTTY
+sets the file or tty on which debugging messages from the backend server
+are displayed.
+.sp
+\(bu
+.B PGDATABASE
+sets the default Postgres database name.
+.sp
+\(bu
+.B PGREALM
+sets the
+.I Kerberos
+realm to use with Postgres, if it is different from the local realm. If
+.B PGREALM
+is set, Postgres applications will attempt authentication with servers
+for this realm and use separate ticket files to avoid conflicts with
+local ticket files. This environment variable is only used if
+.I Kerberos
+authentication is enabled.
+.SH "Database Connection Functions"
+.PP
+The following routines deal with making a connection to a backend
+from a C program.
+.PP
+.B PQsetdb
+.IP
+Makes a new connection to a backend.
+.nf
+PGconn *PQsetdb(char *pghost,
+ char *pgport,
+ char *pgoptions,
+ char *pgtty,
+ char *dbName);
+.fi
+If any argument is NULL, then the corresponding environment variable
+is checked. If the environment variable is also not set, then hardwired
+defaults are used.
+.IP
+.I PQsetdb
+always returns a valid PGconn pointer. The
+.I PQstatus
+(see below) command should be called to ensure that a connection was
+properly made before queries are sent via the connection. Libpq
+programmers should be careful to maintain the PGconn abstraction. Use
+the accessor functions below to get at the contents of PGconn. Avoid
+directly referencing the fields of the PGconn structure as they are
+subject to change in the future.
+.IP
+.B PQdb
+returns the database name of the connection.
+.nf
+char *PQdb(PGconn *conn)
+.fi
+.B PQhost
+returns the host name of the connection.
+.nf
+char *PQhost(PGconn *conn)
+.fi
+.B PQoptions
+returns the pgoptions used in the connection.
+.nf
+char *PQoptions(PGconn *conn)
+.fi
+.B PQport
+returns the pgport of the connection.
+.nf
+char *PQport(PGconn *conn)
+.fi
+.B PQtty
+returns the pgtty of the connection.
+.nf
+char *PQtty(PGconn *conn)
+.fi
+.B PQstatus
+Returns the status of the connection. The status can be CONNECTION_OK or
+CONNECTION_BAD.
+.nf
+ConnStatusType *PQstatus(PGconn *conn)
+.fi
+.B PQerrorMessage
+returns the error message associated with the connection
+.nf
+char *PQerrorMessage(PGconn* conn);
+.fi
+.PP
+.B PQfinish
+.IP
+Close the connection to the backend. Also frees memory used by the
+PGconn structure. The PGconn pointer should not be used after PQfinish
+has been called.
+.nf
+void PQfinish(PGconn *conn)
+.fi
+.PP
+.B PQreset
+.IP
+Reset the communication port with the backend. This function will close
+the IPC socket connection to the backend and attempt to reestablish a
+new connection to the same backend.
+.nf
+void PQreset(PGconn *conn)
+.fi
+.PP
+.B PQtrace
+.IP
+Enables tracing of messages passed between the frontend and the backend.
+The messages are echoed to the debug_port file stream.
+.nf
+void PQtrace(PGconn *conn,
+ FILE* debug_port);
+.fi
+.PP
+.B PQuntrace
+.IP
+Disables tracing of messages passed between the frontend and the backend.
+.nf
+void PQuntrace(PGconn *conn);
+.fi
+.PP
+.SH "Query Execution Functions"
+.PP
+.B PQexec
+.IP
+Submit a query to Postgres. Returns a PGresult pointer if the query was
+successful or a NULL otherwise. If a NULL is returned,
+.I PQerrorMessage
+can be used to get more information about the error.
+.nf
+PGresult *PQexec(PGconn *conn,
+ char *query);
+.fi
+The PGresult structure encapsulates the query result returned by the
+backend. Libpq programmers should be careful to maintain the PGresult
+abstraction. Use the accessor functions described below to retrieve the
+results of the query. Avoid directly referencing the fields of the PGresult
+structure as they are subject to change in the future.
+.PP
+.B PQresultStatus
+.IP
+Returns the result status of the query.
+.I PQresultStatus
+can return one of the following values:
+.nf
+PGRES_EMPTY_QUERY,
+PGRES_COMMAND_OK, /* the query was a command */
+PGRES_TUPLES_OK, /* the query successfully returned tuples */
+PGRES_COPY_OUT,
+PGRES_COPY_IN,
+PGRES_BAD_RESPONSE, /* an unexpected response was received */
+PGRES_NONFATAL_ERROR,
+PGRES_FATAL_ERROR
+.fi
+.IP
+If the result status is PGRES_TUPLES_OK, then the following routines can
+be used to retrieve the tuples returned by the query.
+.IP
+
+.B PQntuples
+returns the number of tuples (instances) in the query result.
+.nf
+int PQntuples(PGresult *res);
+.fi
+
+.B PQnfields
+returns the number of fields (attributes) in the query result.
+.nf
+int PQnfields(PGresult *res);
+.fi
+
+.B PQfname
+returns the field (attribute) name associated with the given field index.
+Field indices start at 0.
+.nf
+char *PQfname(PGresult *res,
+ int field_index);
+.fi
+
+.B PQfnumber
+returns the field (attribute) index associated with the given field name.
+.nf
+int PQfnumber(PGresult *res,
+ char* field_name);
+.fi
+
+.B PQftype
+returns the field type associated with the given field index. The
+integer returned is an internal coding of the type. Field indices start
+at 0.
+.nf
+Oid PQftype(PGresult *res,
+ int field_num);
+.fi
+
+.B PQfsize
+returns the size in bytes of the field associated with the given field
+index. If the size returned is -1, the field is a variable length field.
+Field indices start at 0.
+.nf
+int2 PQfsize(PGresult *res,
+ int field_index);
+.fi
+
+.B PQgetvalue
+returns the field (attribute) value. For most queries, the value
+returned by
+.I PQgetvalue
+is a null-terminated ASCII string representation
+of the attribute value. If the query was a result of a
+.B BINARY
+cursor, then the value returned by
+.I PQgetvalue
+is the binary representation of the type in the internal format of the
+backend server. It is the programmer's responsibility to cast and
+convert the data to the correct C type. The value returned by
+.I PQgetvalue
+points to storage that is part of the PGresult structure. One must
+explicitly copy the value into other storage if it is to be used past
+the lifetime of the PGresult structure itself.
+.nf
+char* PQgetvalue(PGresult *res,
+ int tup_num,
+ int field_num);
+.fi
+
+.B PQgetlength
+returns the length of a field (attribute) in bytes. If the field
+is a
+.I "struct varlena" ,
+the length returned here does
+.B not
+include the size field of the varlena, i.e., it is 4 bytes less.
+.nf
+int PQgetlength(PGresult *res,
+ int tup_num,
+ int field_num);
+.fi
+
+.B PQgetisnull
+returns the NULL status of a field.
+.nf
+int PQgetisnull(PGresult *res,
+ int tup_num,
+ int field_num);
+.fi
+
+.PP
+.B PQcmdStatus
+.IP
+Returns the command status associated with the last query command.
+.nf
+char *PQcmdStatus(PGresult *res);
+.fi
+.PP
+.B PQoidStatus
+.IP
+Returns a string with the object id of the tuple inserted if the last
+query is an INSERT command. Otherwise, returns an empty string.
+.nf
+char* PQoidStatus(PGresult *res);
+.fi
+.PP
+.B PQprint
+.IP
++ Prints out all the tuples in an intelligent manner. The
+.B psql
++ program uses this function for its output.
+.nf
+void PQprint(
+ FILE* fout, /* output stream */
+ PGresult* res, /* query results */
+ PQprintOpt *ps /* option structure */
+ );
+
+.fi
+.I PQprintOpt
+is a typedef'ed structure as defined below.
+.(C
+typedef struct _PQprintOpt {
+ bool header; /* print table headings and row count */
+ bool align; /* fill align the fields */
+ bool standard; /* old brain dead format (needs align) */
+ bool html3; /* output html3+ tables */
+ bool expanded; /* expand tables */
+ bool pager; /* use pager if needed */
+ char *fieldSep; /* field separator */
+ char *caption; /* html table caption (or NULL) */
+ char **fieldName; /* null terminated array of field names (or NULL) */
+} PQprintOpt;
+.fi
+.LP
+.B PQclear
+.IP
+Frees the storage associated with the PGresult. Every query result
+should be properly freed when it is no longer used. Failure to do this
+will result in memory leaks in the frontend application. The PQresult*
+passed in should be a value which is returned from PQexec(). Calling
+PQclear() on an uninitialized PQresult pointer will very likely result
+in a core dump.
+.nf
+void PQclear(PQresult *res);
+.fi
+.PP
+.SH "Fast Path"
+.PP
+Postgres provides a
+.B "fast path"
+interface to send function calls to the backend. This is a trapdoor
+into system internals and can be a potential security hole. Most users
+will not need this feature.
+.nf
+PGresult* PQfn(PGconn* conn,
+ int fnid,
+ int *result_buf,
+ int *result_len,
+ int result_is_int,
+ PQArgBlock *args,
+ int nargs);
+.fi
+.PP
+The
+.I fnid
+argument is the object identifier of the function to be executed.
+.I result_buf
+is the buffer in which to load the return value. The caller must have
+allocated sufficient space to store the return value.
+The result length will be returned in the storage pointed to by
+.I result_len.
+If the result is to be an integer value, than
+.I result_is_int
+should be set to 1; otherwise it should be set to 0.
+.I args
+and
+.I nargs
+specify the arguments to the function.
+.nf
+typedef struct {
+ int len;
+ int isint;
+ union {
+ int *ptr;
+ int integer;
+ } u;
+} PQArgBlock;
+.fi
+.PP
+.I PQfn
+always returns a valid PGresult*. The resultStatus should be checked
+before the result is used. The caller is responsible for freeing the
+PGresult with
+.I PQclear
+when it is not longer needed.
+.PP
+.SH "Asynchronous Notification"
+.PP
+Postgres supports asynchronous notification via the
+.I LISTEN
+and
+.I NOTIFY
+commands. A backend registers its interest in a particular relation
+with the LISTEN command. All backends listening on a particular
+relation will be notified asynchronously when a NOTIFY of that relation
+name is executed by another backend. No additional information is
+passed from the notifier to the listener. Thus, typically, any actual
+data that needs to be communicated is transferred through the relation.
+.PP
+Libpq applications are notified whenever a connected backend has
+received an asynchronous notification. However, the communication from
+the backend to the frontend is not asynchronous. Notification comes
+piggy-backed on other query results. Thus, an application must submit
+queries, even empty ones, in order to receive notice of backend
+notification. In effect, the Libpq application must poll the backend to
+see if there is any pending notification information. After the
+execution of a query, a frontend may call
+.I PQNotifies
+to see if any notification data is available from the backend.
+.PP
+.B PQNotifies
+.IP
+returns the notification from a list of unhandled notifications from the
+backend. Returns NULL if there are no pending notifications from the
+backend.
+.I PQNotifies
+behaves like the popping of a stack. Once a notification is returned
+from
+.I PQnotifies,
+it is considered handled and will be removed from the list of
+notifications.
+.nf
+PGnotify* PQNotifies(PGconn *conn);
+.fi
+.PP
+The second sample program gives an example of the use of asynchronous
+notification.
+.PP
+.SH "Functions Associated with the COPY Command"
+.PP
+The
+.I copy
+command in Postgres has options to read from or write to the network
+connection used by Libpq. Therefore, functions are necessary to
+access this network connection directly so applications may take full
+advantage of this capability.
+.PP
+.B PQgetline
+.IP
+Reads a newline-terminated line of characters (transmitted by the
+backend server) into a buffer
+.I string
+of size
+.I length .
+Like
+.I fgets (3),
+this routine copies up to
+.I length "-1"
+characters into
+.I string .
+It is like
+.I gets (3),
+however, in that it converts the terminating newline into a null
+character.
+.IP
+.I PQgetline
+returns EOF at EOF, 0 if the entire line has been read, and 1 if the
+buffer is full but the terminating newline has not yet been read.
+.IP
+Notice that the application must check to see if a new line consists
+of the single character \*(lq.\*(rq, which indicates that the backend
+server has finished sending the results of the
+.I copy
+command. Therefore, if the application ever expects to receive lines
+that are more than
+.I length "-1"
+characters long, the application must be sure to check the return
+value of
+.I PQgetline
+very carefully.
+.IP
+The code in
+.nf
+\&../src/bin/psql/psql.c
+.fi
+contains routines that correctly handle the copy protocol.
+.nf
+int PQgetline(PGconn *conn,
+ char *string,
+ int length)
+.fi
+.PP
+.B PQputline
+.IP
+Sends a null-terminated
+.I string
+to the backend server.
+.IP
+The application must explicitly send the single character \*(lq.\*(rq
+to indicate to the backend that it has finished sending its data.
+.nf
+void PQputline(PGconn *conn,
+ char *string);
+.fi
+.PP
+.B PQendcopy
+.IP
+Syncs with the backend. This function waits until the backend has
+finished the copy. It should either be issued when the
+last string has been sent to the backend using
+.I PQputline
+or when the last string has been received from the backend using
+.I PGgetline .
+It must be issued or the backend may get \*(lqout of sync\*(rq with
+the frontend. Upon return from this function, the backend is ready to
+receive the next query.
+.IP
+The return value is 0 on successful completion, nonzero otherwise.
+.nf
+int PQendcopy(PGconn *conn);
+.fi
+As an example:
+.nf
+PQexec(conn, "create table foo (a int4, b char16, d float8)");
+PQexec(conn, "copy foo from stdin");
+PQputline(conn, "3<TAB>hello world<TAB>4.5\en");
+PQputline(conn,"4<TAB>goodbye world<TAB>7.11\en");
+\&...
+PQputline(conn,".\en");
+PQendcopy(conn);
+.fi
+.PP
+.SH "LIBPQ Tracing Functions"
+.PP
+.B PQtrace
+.IP
+Enable tracing of the frontend/backend communication to a debugging file
+stream.
+.nf
+void PQtrace(PGconn *conn
+ FILE *debug_port)
+.fi
+.PP
+.B PQuntrace
+.IP
+Disable tracing started by
+.I PQtrace
+.nf
+void PQuntrace(PGconn *conn)
+.fi
+.PP
+.SH "User Authentication Functions"
+.PP
+If the user has generated the appropriate authentication credentials
+(e.g., obtaining
+.I Kerberos
+tickets), the frontend/backend authentication process is handled by
+.I PQexec
+without any further intervention. The following routines may be
+called by Libpq programs to tailor the behavior of the authentication
+process.
+.PP
+.B fe_getauthname
+.IP
+Returns a pointer to static space containing whatever name the user
+has authenticated. Use of this routine in place of calls to
+.I getenv (3)
+or
+.I getpwuid (3)
+by applications is highly recommended, as it is entirely possible that
+the authenticated user name is
+.B not
+the same as value of the
+.B USER
+environment variable or the user's entry in
+.I /etc/passwd .
+.nf
+char *fe_getauthname(char* errorMessage)
+.fi
+.PP
+.B fe_setauthsvc
+.IP
+Specifies that Libpq should use authentication service
+.I name
+rather than its compiled-in default. This value is typically taken
+from a command-line switch.
+.nf
+void fe_setauthsvc(char *name,
+ char* errorMessage)
+.fi
+Any error messages from the authentication attempts are returned in the
+errorMessage argument.
+.PP
+.SH "BUGS"
+.PP
+The query buffer is 8192 bytes long, and queries over that length will
+be silently truncated.
+.PP
+.SH "Sample Programs"
+.bp
+.SH "Sample Program 1"
+.PP
+.nf M
+/*
+ * testlibpq.c
+ * Test the C version of Libpq, the Postgres frontend library.
+ *
+ *
+ */
+#include <stdio.h>
+#include "libpq-fe.h"
+
+void
+exit_nicely(PGconn* conn)
+{
+ PQfinish(conn);
+ exit(1);
+}
+
+main()
+{
+ char *pghost, *pgport, *pgoptions, *pgtty;
+ char* dbName;
+ int nFields;
+ int i,j;
+
+/* FILE *debug; */
+
+ PGconn* conn;
+ PGresult* res;
+
+ /* begin, by setting the parameters for a backend connection
+ if the parameters are null, then the system will try to use
+ reasonable defaults by looking up environment variables
+ or, failing that, using hardwired constants */
+ pghost = NULL; /* host name of the backend server */
+ pgport = NULL; /* port of the backend server */
+ pgoptions = NULL; /* special options to start up the backend server */
+ pgtty = NULL; /* debugging tty for the backend server */
+ dbName = "template1";
+
+ /* make a connection to the database */
+ conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
+
+ /* check to see that the backend connection was successfully made */
+ if (PQstatus(conn) == CONNECTION_BAD) {
+ fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
+ fprintf(stderr,"%s",PQerrorMessage(conn));
+ exit_nicely(conn);
+ }
+
+/* debug = fopen("/tmp/trace.out","w"); */
+/* PQtrace(conn, debug); */
+
+ /* start a transaction block */
+ res = PQexec(conn,"BEGIN");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ fprintf(stderr,"BEGIN command failed\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ /* should PQclear PGresult whenever it is no longer needed to avoid
+ memory leaks */
+ PQclear(res);
+
+ /* fetch instances from the pg_database, the system catalog of databases*/
+ res = PQexec(conn,"DECLARE myportal CURSOR FOR select * from pg_database");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ fprintf(stderr,"DECLARE CURSOR command failed\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ PQclear(res);
+
+ res = PQexec(conn,"FETCH ALL in myportal");
+ if (PQresultStatus(res) != PGRES_TUPLES_OK) {
+ fprintf(stderr,"FETCH ALL command didn't return tuples properly\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+
+ /* first, print out the attribute names */
+ nFields = PQnfields(res);
+ for (i=0; i < nFields; i++) {
+ printf("%-15s",PQfname(res,i));
+ }
+ printf("\n\n");
+
+ /* next, print out the instances */
+ for (i=0; i < PQntuples(res); i++) {
+ for (j=0 ; j < nFields; j++) {
+ printf("%-15s", PQgetvalue(res,i,j));
+ }
+ printf("\n");
+ }
+
+ PQclear(res);
+
+ /* close the portal */
+ res = PQexec(conn, "CLOSE myportal");
+ PQclear(res);
+
+ /* end the transaction */
+ res = PQexec(conn, "END");
+ PQclear(res);
+
+ /* close the connection to the database and cleanup */
+ PQfinish(conn);
+
+/* fclose(debug); */
+}
+.fi
+.bp
+.SH "Sample Program 2"
+.PP
+.nf M
+/*
+ * testlibpq2.c
+ * Test of the asynchronous notification interface
+ *
+ populate a database with the following:
+
+CREATE TABLE TBL1 (i int4);
+
+CREATE TABLE TBL2 (i int4);
+
+CREATE RULE r1 AS ON INSERT TO TBL1 DO [INSERT INTO TBL2 values (new.i); NOTIFY TBL2];
+
+ * Then start up this program
+ * After the program has begun, do
+
+INSERT INTO TBL1 values (10);
+
+ *
+ *
+ */
+#include <stdio.h>
+#include "libpq-fe.h"
+
+void exit_nicely(PGconn* conn)
+{
+ PQfinish(conn);
+ exit(1);
+}
+
+main()
+{
+ char *pghost, *pgport, *pgoptions, *pgtty;
+ char* dbName;
+ int nFields;
+ int i,j;
+
+ PGconn* conn;
+ PGresult* res;
+ PGnotify* notify;
+
+ /* begin, by setting the parameters for a backend connection
+ if the parameters are null, then the system will try to use
+ reasonable defaults by looking up environment variables
+ or, failing that, using hardwired constants */
+ pghost = NULL; /* host name of the backend server */
+ pgport = NULL; /* port of the backend server */
+ pgoptions = NULL; /* special options to start up the backend server */
+ pgtty = NULL; /* debugging tty for the backend server */
+ dbName = getenv("USER"); /* change this to the name of your test database*/
+
+ /* make a connection to the database */
+ conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
+
+ /* check to see that the backend connection was successfully made */
+ if (PQstatus(conn) == CONNECTION_BAD) {
+ fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
+ fprintf(stderr,"%s",PQerrorMessage(conn));
+ exit_nicely(conn);
+ }
+
+ res = PQexec(conn, "LISTEN TBL2");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ fprintf(stderr,"LISTEN command failed\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ /* should PQclear PGresult whenever it is no longer needed to avoid
+ memory leaks */
+ PQclear(res);
+
+ while (1) {
+ /* async notification only come back as a result of a query*/
+ /* we can send empty queries */
+ res = PQexec(conn, " ");
+/* printf("res->status = %s\n", pgresStatus[PQresultStatus(res)]); */
+ /* check for asynchronous returns */
+ notify = PQnotifies(conn);
+ if (notify) {
+ fprintf(stderr,
+ "ASYNC NOTIFY of '%s' from backend pid '%d' received\n",
+ notify->relname, notify->be_pid);
+ free(notify);
+ break;
+ }
+ PQclear(res);
+ }
+
+ /* close the connection to the database and cleanup */
+ PQfinish(conn);
+
+}
+.fi
+.bp
+.SH "Sample Program 3"
+.PP
+.nf M
+/*
+ * testlibpq3.c
+ * Test the C version of Libpq, the Postgres frontend library.
+ * tests the binary cursor interface
+ *
+ *
+ *
+ populate a database by doing the following:
+
+CREATE TABLE test1 (i int4, d float4, p polygon);
+
+INSERT INTO test1 values (1, 3.567, '(3.0, 4.0, 1.0, 2.0)'::polygon);
+
+INSERT INTO test1 values (2, 89.05, '(4.0, 3.0, 2.0, 1.0)'::polygon);
+
+ the expected output is:
+
+tuple 0: got
+ i = (4 bytes) 1,
+ d = (4 bytes) 3.567000,
+ p = (4 bytes) 2 points boundbox = (hi=3.000000/4.000000, lo = 1.000000,2.000000)
+tuple 1: got
+ i = (4 bytes) 2,
+ d = (4 bytes) 89.050003,
+ p = (4 bytes) 2 points boundbox = (hi=4.000000/3.000000, lo = 2.000000,1.000000)
+
+ *
+ */
+#include <stdio.h>
+#include "libpq-fe.h"
+#include "utils/geo-decls.h" /* for the POLYGON type */
+
+void exit_nicely(PGconn* conn)
+{
+ PQfinish(conn);
+ exit(1);
+}
+
+main()
+{
+ char *pghost, *pgport, *pgoptions, *pgtty;
+ char* dbName;
+ int nFields;
+ int i,j;
+ int i_fnum, d_fnum, p_fnum;
+
+ PGconn* conn;
+ PGresult* res;
+
+ /* begin, by setting the parameters for a backend connection
+ if the parameters are null, then the system will try to use
+ reasonable defaults by looking up environment variables
+ or, failing that, using hardwired constants */
+ pghost = NULL; /* host name of the backend server */
+ pgport = NULL; /* port of the backend server */
+ pgoptions = NULL; /* special options to start up the backend server */
+ pgtty = NULL; /* debugging tty for the backend server */
+
+ dbName = getenv("USER"); /* change this to the name of your test database*/
+
+ /* make a connection to the database */
+ conn = PQsetdb(pghost, pgport, pgoptions, pgtty, dbName);
+
+ /* check to see that the backend connection was successfully made */
+ if (PQstatus(conn) == CONNECTION_BAD) {
+ fprintf(stderr,"Connection to database '%s' failed.\n", dbName);
+ fprintf(stderr,"%s",PQerrorMessage(conn));
+ exit_nicely(conn);
+ }
+
+ /* start a transaction block */
+ res = PQexec(conn,"BEGIN");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ fprintf(stderr,"BEGIN command failed\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ /* should PQclear PGresult whenever it is no longer needed to avoid
+ memory leaks */
+ PQclear(res);
+
+ /* fetch instances from the pg_database, the system catalog of databases*/
+ res = PQexec(conn,"DECLARE mycursor BINARY CURSOR FOR select * from test1");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK) {
+ fprintf(stderr,"DECLARE CURSOR command failed\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ PQclear(res);
+
+ res = PQexec(conn,"FETCH ALL in mycursor");
+ if (PQresultStatus(res) != PGRES_TUPLES_OK) {
+ fprintf(stderr,"FETCH ALL command didn't return tuples properly\n");
+ PQclear(res);
+ exit_nicely(conn);
+ }
+
+ i_fnum = PQfnumber(res,"i");
+ d_fnum = PQfnumber(res,"d");
+ p_fnum = PQfnumber(res,"p");
+
+ for (i=0;i<3;i++) {
+ printf("type[%d] = %d, size[%d] = %d\n",
+ i, PQftype(res,i),
+ i, PQfsize(res,i));
+ }
+ for (i=0; i < PQntuples(res); i++) {
+ int *ival;
+ float *dval;
+ int plen;
+ POLYGON* pval;
+ /* we hard-wire this to the 3 fields we know about */
+ ival = (int*)PQgetvalue(res,i,i_fnum);
+ dval = (float*)PQgetvalue(res,i,d_fnum);
+ plen = PQgetlength(res,i,p_fnum);
+
+ /* plen doesn't include the length field so need to increment by VARHDSZ*/
+ pval = (POLYGON*) malloc(plen + VARHDRSZ);
+ pval->size = plen;
+ memmove((char*)&pval->npts, PQgetvalue(res,i,p_fnum), plen);
+ printf("tuple %d: got\n", i);
+ printf(" i = (%d bytes) %d,\n",
+ PQgetlength(res,i,i_fnum), *ival);
+ printf(" d = (%d bytes) %f,\n",
+ PQgetlength(res,i,d_fnum), *dval);
+ printf(" p = (%d bytes) %d points \tboundbox = (hi=%f/%f, lo = %f,%f)\n",
+ PQgetlength(res,i,d_fnum),
+ pval->npts,
+ pval->boundbox.xh,
+ pval->boundbox.yh,
+ pval->boundbox.xl,
+ pval->boundbox.yl);
+ }
+
+ PQclear(res);
+
+ /* close the portal */
+ res = PQexec(conn, "CLOSE mycursor");
+ PQclear(res);
+
+ /* end the transaction */
+ res = PQexec(conn, "END");
+ PQclear(res);
+
+ /* close the connection to the database and cleanup */
+ PQfinish(conn);
+
+}
+.fi
diff --git a/doc/man/listen.l b/doc/man/listen.l
new file mode 100644
index 00000000000..853dfdea202
--- /dev/null
+++ b/doc/man/listen.l
@@ -0,0 +1,44 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/listen.l,v 1.1.1.1 1996/08/18 22:14:25 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.
diff --git a/doc/man/load.l b/doc/man/load.l
new file mode 100644
index 00000000000..67600f26640
--- /dev/null
+++ b/doc/man/load.l
@@ -0,0 +1,51 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/load.l,v 1.1.1.1 1996/08/18 22:14:25 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.
diff --git a/doc/man/monitor.1 b/doc/man/monitor.1
new file mode 100644
index 00000000000..8b3cc1edc9c
--- /dev/null
+++ b/doc/man/monitor.1
@@ -0,0 +1,269 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/monitor.1,v 1.1.1.1 1996/08/18 22:14:25 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)
diff --git a/doc/man/notify.l b/doc/man/notify.l
new file mode 100644
index 00000000000..9566336bb01
--- /dev/null
+++ b/doc/man/notify.l
@@ -0,0 +1,48 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/notify.l,v 1.1.1.1 1996/08/18 22:14:26 scrappy Exp $
+.TH "NOTIFY" SQL 11/05/95 Postgres95 Postgres95
+.SH NAME
+notify \(em signal all frontends and backends listening on a class
+.SH SYNOPSIS
+.nf
+\fBnotify\fR class_name
+.fi
+.SH DESCRIPTION
+.BR notify
+is used to awaken all backends and consequently all frontends
+that have executed
+.IR listen (l)
+on
+.IR class_name .
+This can be used either within an instance-level rule as part of the
+action body or from a normal query. When used from within a normal
+query, this can be thought of as interprocess communication (IPC).
+When used from within a rule, this can be thought of as an alerter
+mechanism.
+.PP
+Notice that the mere fact that a
+.BR notify
+has been executed does not imply anything in particular about
+the state of the class (e.g., that it has been updated), nor
+does the notification protocol transmit any useful information
+other than the class name. Therefore, all
+.BR notify
+does is indicate that some backend wishes its peers to examine
+.IR class_name
+in some application-specific way.
+.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"
+define rule(l),
+listen(l),
+libpq.
diff --git a/doc/man/page.5 b/doc/man/page.5
new file mode 100644
index 00000000000..09b154bfc89
--- /dev/null
+++ b/doc/man/page.5
@@ -0,0 +1,130 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/page.5,v 1.1.1.1 1996/08/18 22:14:26 scrappy Exp $
+.TH PAGE FILES 01/23/93 Postgres95 Postgres95
+.SH NAME
+page structure \(em Postgres database file default page format
+.SH DESCRIPTION
+This section provides an overview of the page format used by Postgres
+classes. User-defined access methods need not use this page format.
+.PP
+In the following explanation, a
+.BR byte
+is assumed to contain 8 bits. In addition, the term
+.BR item
+refers to data which is stored in Postgres classes.
+.if t \{
+Diagram 1 shows how pages in both normal Postgres classes and Postgres index
+classes (e.g., a B-tree index) are structured.
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/page.5,v 1.1.1.1 1996/08/18 22:14:26 scrappy Exp $
+.in +0.5i
+.(b M
+.PS
+.ps 11
+box with .sw at (0.99,6.01) width 5.50 height 3.50
+line from 0.988,9.012 to 6.487,9.012
+line from 3.737,9.512 to 3.737,9.012
+line from 5.112,9.512 to 5.112,9.012
+dashwid = 0.050i
+line dashed from 2.362,9.512 to 2.362,9.012
+line dashed from 3.050,9.512 to 3.050,9.012
+line dashed from 1.675,9.512 to 1.675,9.012
+line from 3.737,6.013 to 3.737,6.513 to 6.487,6.513
+line from 0.988,7.763 to 2.362,7.763 to 2.362,8.262 to 6.487,8.262
+line from 0.988,7.263 to 5.112,7.263 to 5.112,7.763 to 6.487,7.763
+line dashed from 2.362,7.763 to 5.112,7.763
+line dashed from 5.112,8.262 to 5.112,7.763
+line dashed from 4.300,8.262 to 4.300,7.763
+dashwid = 0.037i
+line dotted <-> from 2.425,8.325 to 6.425,8.325
+line dotted <-> from 1.050,9.575 to 3.675,9.575
+line dotted <-> from 3.800,9.575 to 5.050,9.575
+line dotted <-> from 5.175,9.575 to 6.425,9.575
+"\s10\fRitemPointerData\fP" at 2.925,7.978 ljust
+"\s10\fRfiller\fP" at 4.562,7.978 ljust
+"\s10\fRitemData...\fP" at 5.513,7.978 ljust
+"\s10\fIUnallocated Space\fP" at 3.237,8.753 ljust
+"\s10\fBItemContinuationData\fP" at 3.663,8.415 ljust
+"\s10\fISpecial Space\fP" at 4.688,6.240 ljust
+"\s10\fI``ItemData 2''\fP" at 2.587,7.478 ljust
+"\s10\fI``ItemData 1''\fP" at 3.413,6.865 ljust
+"\s10\fBItemIdData\fP" at 4.775,9.715 ljust
+"\s10\fBPageHeaderData\fP" at 1.875,9.715 ljust
+.PE
+.ce
+.BR "Diagram 1: Sample Page Layout"
+.)b
+.in -0.5i
+\}
+.\" Running
+.\" .q .../bin/dumpbpages
+.\" or
+.\" .q .../src/support/dumpbpages
+.\" as the postgres superuser
+.\" with the file paths associated with
+.\" (heap or B-tree index) classes,
+.\" .q .../data/base/<database-name>/<class-name>,
+.\" will display the page structure used by the classes.
+.\" Specifying the
+.\" .q -r
+.\" flag will cause the classes to be
+.\" treated as heap classes and for more information to be displayed.
+.PP
+The first 8 bytes of each page consists of a page header
+.RB ( PageHeaderData ).
+Within the header, the first three 2-byte integer fields,
+.IR lower ,
+.IR upper ,
+and
+.IR special ,
+represent byte offsets to the start of unallocated space, to the end
+of unallocated space, and to the start of \*(lqspecial space.\*(rq
+Special space is a region at the end of the page which is allocated at
+page initialization time and which contains information specific to an
+access method. The last 2 bytes of the page header,
+.IR opaque ,
+encode the page size and information on the internal fragmentation of
+the page. Page size is stored in each page because frames in the
+buffer pool may be subdivided into equal sized pages on a frame by
+frame basis within a class. The internal fragmentation information is
+used to aid in determining when page reorganization should occur.
+.PP
+Following the page header are item identifiers
+.RB ( ItemIdData ).
+New item identifiers are allocated from the first four bytes of
+unallocated space. Because an item identifier is never moved until it
+is freed, its index may be used to indicate the location of an item on
+a page. In fact, every pointer to an item
+.RB ( ItemPointer )
+created by Postgres consists of a frame number and an index of an item
+identifier. An item identifier contains a byte-offset to the start of
+an item, its length in bytes, and a set of attribute bits which affect
+its interpretation.
+.PP
+The items, themselves, are stored in space allocated backwards from
+the end of unallocated space. Usually, the items are not interpreted.
+However when the item is too long to be placed on a single page or
+when fragmentation of the item is desired, the item is divided and
+each piece is handled as distinct items in the following manner. The
+first through the next to last piece are placed in an item
+continuation structure
+.BR ( ItemContinuationData ).
+This structure contains
+.IR itemPointerData
+which points to the next piece and the piece itself. The last piece
+is handled normally.
+.SH FILES
+.TP 5n
+\&.../data/...
+Location of shared (global) database files.
+.TP 5n
+\&.../data/base/...
+Location of local database files.
+.SH BUGS
+The page format may change in the future to provide more efficient
+access to large objects.
+.PP
+This section contains insufficient detail to be of any assistance in
+writing a new access method.
diff --git a/doc/man/pg_dump.1 b/doc/man/pg_dump.1
new file mode 100644
index 00000000000..e05c24180bf
--- /dev/null
+++ b/doc/man/pg_dump.1
@@ -0,0 +1,73 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/pg_dump.1,v 1.1.1.1 1996/08/18 22:14:26 scrappy Exp $
+.TH PG_DUMP UNIX 1/20/96 Postgres95 Postgres95
+.SH NAME
+pg_dump \(em dumps out a Postgres database into a script file
+.SH SYNOPSIS
+.BR pg_dump
+[\c
+.BR "-f"
+filename
+]
+[\c
+.BR "-H"
+hostname
+]
+[\c
+.BR "-p"
+port]
+[\c
+.BR "-v"
+]
+[\c
+.BR "-S"
+help]
+dbname
+.in -5n
+.SH DESCRIPTION
+.IR "pg_dump"
+is a utility for dumping out a
+Postgres database into a script file containing query commands. The script
+files are in a ASCII format and can be used to reconstruct the database,
+even on other machines and other architectures.
+.IR "pg_dump"
+will produce the queries necessary to re-generate all
+user-defined types, functions, tables, indices, aggregates, and
+operators. In addition, all the data is copied out in ASCII format so
+that it can be readily copied in again, as well, as imported into tools
+for textual editing.
+.PP
+.IR "pg_dump"
+is useful for dumping out the contents of a database to move from one
+postgres95 installation to another. After running
+.IR "pg_dump"
+, one should examine the output script file for any warnings, especially
+in light of the limitations listed below.
+.SH "CAVEATS AND LIMITATIONS"
+.IR pg_dump
+has a few limitations.
+The limitations mostly stem from
+difficulty in extracting certain meta-information from the system
+catalogs.
+.TP
+.BR "rules and views"
+pg_dump does not understand user-defined rules and views and
+will fail to dump them properly. (This is due to the fact that
+rules are stored as plans in the catalogs and not textually)
+.TP
+.BR "partial indices"
+pg_dump does not understand partial indices. (The reason is
+the same as above. Partial index predicates are stored as plans)
+.TP
+.BR "large objects"
+pg_dump does not handle large objects. Large objects are ignored and
+must be dealt with manually.
+.TP
+.BR "oid preservation"
+pg_dump does not preserve oid's while dumping. If you have
+stored oid's explicitly in tables in user-defined attributes,
+and are using them as keys, then the output scripts will not
+regenerate your database correctly.
+.SH "SEE ALSO"
+copy(l)
diff --git a/doc/man/pg_hba.5 b/doc/man/pg_hba.5
new file mode 100644
index 00000000000..1e08ba8ca6d
--- /dev/null
+++ b/doc/man/pg_hba.5
@@ -0,0 +1,43 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/pg_hba.5,v 1.1.1.1 1996/08/18 22:14:26 scrappy Exp $
+.TH PG_HBA FILES 01/20/96 Postgres95 Postgres95
+.SH NAME
+$PGDATA/pg_hba \(em host-based access control
+.SH DESCRIPTION
+Postgres provides host-based access control through the file
+.BR "pg_hba".
+This file is stored in $PGDATA and should have proper file permissions
+so that casual users cannot modify it. The file stores permissions
+information about which hosts are authorized to access databases.
+.PP
+The file consists of lines of three columns. The first column lists the
+name of the database. The second column lists the IP address of clients
+machines that are authorized to connect, and the third column provides a
+bit mask for the IP address. Lines which begin with '#' are considered
+comments.
+.PP
+The keyword "all" can be used to apply to all database names. Each
+column can contain strings of at most 80 characters, and each database
+may have up to 255 configuration lines that apply. (80 and 255 are
+constants that can be changed at Postgres compile time by altering the
+#defines MAX_TOKEN and MAX_LINES in src/backend/libpq/auth.c)
+.PP
+Below is the default pg_hba file that is installed.
+.nf
+#
+# Example config file for Postgres95 host based access
+#
+# Lines starting with "all" apply to all databases. Otherwise the first
+# column has to match the name of the database being connected to. Up to
+# ten config lines can apply to each database. Mask specifies bits that
+# aren't counted. After those bits are taken out, the connection address
+# must match the address in the middle column.
+#
+# <name> <address> <mask>
+#
+all 127.0.0.1 0.0.0.0
+.fi
+.SH "SEE ALSO"
+introduction(1).
+
diff --git a/doc/man/postgres.1 b/doc/man/postgres.1
new file mode 100644
index 00000000000..e4931149c28
--- /dev/null
+++ b/doc/man/postgres.1
@@ -0,0 +1,163 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/postgres.1,v 1.1.1.1 1996/08/18 22:14:26 scrappy Exp $
+.TH POSTGRES95 UNIX 11/05/95 Postgres95 Postgres95
+.SH NAME
+postgres \(em the Postgres backend server
+.SH SYNOPSIS
+.BR "postgres"
+[\c
+.BR "-B"
+n_buffers]
+[\c
+.BR "-E"
+]
+[\c
+.BR "-P"
+filedes]
+[\c
+.BR "-Q"
+]
+.br
+.in +5n
+[\c
+.BR "-d"
+debug_level]
+[\c
+.BR "-o"
+output_file]
+[\c
+.BR "-s"
+]
+[dbname]
+.in -5n
+.SH DESCRIPTION
+The Postgres backend server can be executed directly from the user shell.
+This should be done only while debugging by the DBA, and should not be
+done while other Postgres backends are being managed by a
+.IR postmaster
+on this set of databases.
+.PP
+The optional argument
+.IR dbname
+specifies the name of the database to be accessed.
+.IR Dbname
+defaults to the value of the
+.SM USER
+environment variable.
+.PP
+The
+.IR postgres
+server understands the following command-line options:
+.TP 5n
+.BR "-B" " n_buffers"
+If the backend is running under the
+.IR postmaster ,
+.IR "n_buffers"
+is the number of shared-memory buffers that the
+.IR "postmaster"
+has allocated for the backend server processes that it starts. If the
+backend is running standalone, this specifies the number of buffers to
+allocate. This value defaults to 64.
+.TP
+.BR "-E"
+Echo all queries.
+.TP
+.BR "-P" " filedes"
+.IR "filedes"
+specifies the file descriptor that corresponds to the socket (port) on
+which to communicate to the frontend process. This option is
+.BR not
+useful for interactive use.
+.TP
+.BR "-Q"
+Specifies \*(lqquiet\*(rq mode.
+.TP
+.BR "-d" " debug_level"
+Turns on debugging at the numeric level
+.IR "debug_level" .
+Turning on debugging will cause query parse trees and query plans to
+be displayed.
+.TP
+.BR "-o" " output_file"
+Sends all debugging and error output to
+.IR output_file .
+If the backend is running under the
+.IR postmaster ,
+error messages are still sent to the frontend process as well as to
+.IR output_file ,
+but debugging output is sent to the controlling tty of the
+.IR postmaster
+(since only one file descriptor can be sent to an actual file).
+.TP
+.BR "-s"
+Print time information and other statistics at the end of each query.
+This is useful for benchmarking or for use in tuning the number of
+buffers.
+.SH "DEPRECATED COMMAND OPTIONS"
+There are several other options that may be specified, used mainly
+for debugging purposes. These are listed here only for the use by
+Postgres system developers.
+.BR "Use of any of these options is highly discouraged" .
+Furthermore, any of these options may disappear or change at any time.
+.TP
+.BR "-A" "n|r|b|Q\fIn\fP|X\fIn\fP"
+.IP
+This option generates a tremendous amount of output.
+.TP
+.BR "-L"
+Turns off the locking system.
+.TP
+.BR "-N"
+Disables use of newline as a query delimiter.
+.TP
+.BR "-S"
+Indicates that the transaction system can run with the assumption of
+stable main memory, thereby avoiding the necessary flushing of data
+and log pages to disk at the end of each transaction system. This is
+only used for performance comparisons for stable vs. non-stable
+storage. Do not use this in other cases, as recovery after a system
+crash may be impossible when this option is specified in the absence
+of stable main memory.
+.TP
+.BR "-b"
+Enables generation of bushy query plan trees (as opposed to left-deep
+query plans trees). These query plans are not intended for actual
+execution; in addition, this flag often causes Postgres to run out of
+memory.
+.TP
+.BR "-f"
+Forbids the use of particular scan and join methods:
+.IR s " and " i
+disable sequential and index scans respectively, while
+.IR n ", " m " and " h
+disable nested-loop, merge and hash joins respectively.
+This is another feature that may not necessarily produce executable
+plans.
+.TP
+.BR "-p"
+Indicates to the backend server that it has been started by a
+.IR postmaster
+and make different assumptions about buffer pool management, file
+descriptors, etc.
+.TP
+.BR "-t" "pa[rser]|pl[anner]|e[xecutor]"
+Print timing statistics for each query relating to each of the major
+system modules. This option cannot be used with
+.BR "-s" .
+.SH "SEE ALSO"
+ipcclean(1),
+psql(1),
+postmaster(1).
+.SH "DIAGNOSTICS"
+Of the nigh-infinite number of error messages you may see when you
+execute the backend server directly, the most common will probably be:
+.TP
+.BR "semget: No space left on device"
+If you see this message, you should run the
+.IR ipcclean
+command. After doing this, try starting
+.IR postgres
+again. If this still doesn't work, you probably need to configure
+your kernel for shared memory and semaphores as described in the
+installation notes.
diff --git a/doc/man/postmaster.1 b/doc/man/postmaster.1
new file mode 100644
index 00000000000..3baf9c15b2f
--- /dev/null
+++ b/doc/man/postmaster.1
@@ -0,0 +1,323 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/postmaster.1,v 1.1.1.1 1996/08/18 22:14:26 scrappy Exp $
+.TH POSTMASTER UNIX 11/05/95 Postgres95 Postgres95
+.SH "NAME"
+postmaster \(em run the Postgres postmaster
+.SH "SYNOPSIS"
+.BR "postmaster"
+[\c
+.BR "-B"
+n_buffers]
+[\c
+.BR "-D"
+data_dir]
+[\c
+.BR "-S" \c
+]
+[\c
+.BR "-a"
+system]
+.br
+.in +5n
+[\c
+.BR "-b"
+backend_pathname]
+[\c
+.BR "-d"
+[debug_level]]
+[\c
+.BR "-n" \c
+]
+.br
+[\c
+.BR "-o"
+backend_options]
+[\c
+.BR "-p"
+port]
+[\c
+.BR "-s" \c
+]
+.in -5n
+.SH "DESCRIPTION"
+The
+.IR "postmaster"
+manages the communication between frontend and backend processes, as
+well as allocating the shared buffer pool and semaphores (on machines
+without a test-and-set instruction). The
+.IR postmaster
+does not itself interact with the user and should be started as a
+background process.
+.BR "Only one postmaster should be run on a machine."
+.PP
+The
+.IR "postmaster"
+understands the following command-line options:
+.TP 5n
+.BR "-B" " n_buffers"
+.IR "n_buffers"
+is the number of shared-memory buffers for the
+.IR "postmaster"
+to allocate and manage for the backend server processes that it
+starts. This value defaults to 64.
+.TP
+.BR "-D" " data_dir"
+Specifies the directory to use as the root of the tree of database
+directories. This directory uses the value of the environment
+variable
+.SM PGDATA.
+If
+.SM PGDATA
+is not set, then the directory used is
+.SM $POSTGRESHOME\c
+/data. If neither environment variable is set and this command-line
+option is not specified, the default directory that was
+set at compile-time is used.
+.TP
+.BR "-S"
+Specifies that the
+.IR "postmaster"
+process should start up in silent mode. That is, it will disassociate
+from the user's (controlling) tty and start its own process group.
+This should not be used in combination with debugging options because
+any messages printed to standard output and standard error are
+discarded.
+.TP
+.BR "-a" " system"
+Specifies whether or not to use the authentication system
+.IR "system"
+(see
+.IR introduction (1))
+for frontend applications to use in connecting to the
+.IR postmaster
+process. Specify
+.IR "system"
+to enable a system, or
+.BI "no" "system"
+to disable a system. For example, to permit users to use
+.IR Kerberos
+authentication, use
+.BR "-a kerberos" ;
+to deny any unauthenticated
+connections, use
+.BR "-a nounauth .
+The default is site-specific.
+.TP
+.BR "-b" " backend_pathname"
+.IR "backend_pathname"
+is the full pathname of the Postgres backend server executable file that
+the
+.IR "postmaster"
+will invoke when it receives a connection from a frontend application.
+If this option is not used, then the
+.IR postmaster
+tries to find this executable file in the directory in which its own
+executable is located (this is done by looking at the pathname under
+which the
+.IR "postmaster"
+was invoked. If no pathname was specified, then the
+.SM PATH
+environment variable is searched for an executable named
+\*(lqpostgres\*(rq).
+.TP
+.BR "-d" " [debug_level]"
+The optional argument
+.IR debug_level
+determines the amount of debugging output the backend servers will
+produce.
+If
+.I debug_level
+is one, the postmaster will trace all connection traffic,
+and nothing else.
+For levels two and higher,
+debugging is turned on in the backend process and the postmaster
+displays more information,
+including the backend environment and process traffic.
+Note that if no file is specified for backend servers to
+send their debugging output then this output will appear on the
+controlling tty of their parent
+.IR postmaster .
+.TP
+.BR "-n" ", " "-s"
+The
+.IR "-s" " and " "-n"
+options control the behavior of the
+.IR "postmaster"
+when a backend dies abnormally. \fBNeither option is intended for use in
+ordinary operation\fP.
+.IP
+The ordinary strategy for this situation is to notify all other
+backends that they must terminate and then reinitialize the shared
+memory and semaphores. This is because an errant backend could have
+corrupted some shared state before terminating.
+.IP
+If the
+.IR "-s"
+option is supplied, then the
+.IR "postmaster"
+will stop all other backend processes by sending the signal
+.SM SIGSTOP,
+but will not cause them to terminate. This permits system programmers
+to collect core dumps from all backend processes by hand.
+.IP
+If the
+.IR "-n"
+option is supplied, then the
+.IR "postmaster"
+does not reinitialize shared data structures. A knowledgable system
+programmer can then use the
+.IR shmemdoc
+program to examine shared memory and semaphore state.
+.TP
+.BR "-o" " backend_options"
+The
+.IR postgres (1)
+options specified in
+.IR "backend_options"
+are passed to all backend server processes started by this
+.IR postmaster .
+If the option string contains any spaces, the entire string must be
+quoted.
+.TP
+.BR "-p" " port"
+Specifies the Internet TCP port on which the
+.IR postmaster
+is to listen for connections from frontend applications. Defaults to
+5432, or the value of the
+.SM PGPORT
+environment variable (if set). If you specify a port other than the
+default port then all frontend application users must specify the same
+port (using command-line options or
+.SM PGPORT\c
+) when starting any libpq application, including psql.
+.SH "WARNINGS"
+If at all possible,
+.BR "do not"
+use
+.SM SIGKILL
+when killing the
+.IR "postmaster" "."
+.SM SIGHUP,
+.SM SIGINT,
+or
+.SM SIGTERM
+(the default signal for
+.IR "kill" "(1))"
+should be used instead. Hence, avoid
+.nf
+kill -KILL
+.fi
+or its alternative form
+.nf
+kill -9
+.fi
+as this will prevent the
+.IR postmaster
+from freeing the system resources (e.g., shared memory and semaphores)
+that it holds before dying. This prevents you from having to deal with
+the problem with
+.IR shmat (2)
+described below.
+.SH "EXAMPLES"
+.nf
+# start postmaster using default values
+postmaster -S
+.fi
+This command will start up
+.IR "postmaster"
+on the default port (5432) and will search
+.SM $PATH
+to find an executable file called \*(lqpostgres\*(rq. This is the
+simplest and most common way to start the
+.IR "postmaster" .
+.nf
+# start with specific port and executable name
+postmaster -p -b /usr/postgres/bin/postgres &
+.fi
+This command will start up a
+.IR "postmaster"
+communicating through the port 1234, and will attempt to use the
+backend located at \*(lq/usr/postgres/bin/postgres\*(rq. In order to
+connect to this
+.IR "postmaster"
+using psql, you would need to either
+specify
+.BR "-p 1234"
+on the
+.IR "psql"
+command-line or set the environment variable
+.SM PGPORT
+to 1234.
+.SH "SEE ALSO"
+ipcs(1),
+ipcrm(1),
+ipcclean(1),
+psql(1),
+postgres(1),
+.SH "DIAGNOSTICS"
+.TP
+.BR "FindBackend: could not find a backend to execute..."
+If you see this message, you do not have the
+.IR "postgres"
+executable in your path. Add the directoy in which postgres resides to
+your path.
+.TP
+.BR "semget: No space left on device"
+If you see this message, you should run the
+.IR "ipcclean"
+command. After doing this, try starting the
+.IR "postmaster"
+again. If this still doesn't work, you probably need to configure
+your kernel for shared memory and semaphores as described in the
+installation notes. If you run multiple
+.IR postmaster s
+on a single host, or have reduced the shared memory and semaphore
+parameters from the defaults in the generic kernel, you may have to
+go back and increase the shared memory and semaphores configured
+into your kernel.
+.TP
+.BR "StreamServerPort: cannot bind to port"
+If you see this message, you should be certain that there is no other
+.IR "postmaster"
+process already running. The easiest way to determine this is by
+using the command
+.nf
+ps -ax | grep postmaster
+.fi
+on BSD-based systems
+.nf
+ps -e | grep postmast
+.fi
+(the equivalent syntax is on System V-like or POSIX-compliant systems such as HP-UX). If you
+are sure that no other
+.IR "postmaster"
+processes are running and you still get this error, try specifying a
+different port using the
+.BR "-p"
+option. You may also get this error if you terminate the
+.IR "postmaster"
+and immediately restart it using the same port; in this case, you must
+simply wait a few seconds until the operating system closes the port
+before trying again. Finally, you may get this error if you specify
+a port number that your operating system considers to be reserved.
+For example, many versions of Unix consider port numbers under 1024 to
+be \*(lqtrusted\*(rq and only permit the Unix superuser to access them.
+.TP
+.BR "IpcMemoryAttach: shmat() failed: Permission denied"
+A likely explanation is that another user attempted to start a
+.IR "postmaster"
+process on the same port which acquired shared resources and then
+died. Since Postgres shared memory keys are based on the port number
+assigned to the
+.IR "postmaster" ,
+such conflicts are likely if there is more than one installation on
+a single host. If there are no other
+.IR "postmaster"
+processes currently running (see above), run
+.IR "ipcclean"
+and try again. If other
+.IR "postmaster" s
+are running, you will have to find the owners of those processes to
+coordinate the assignment of port numbers and/or removal of unused
+shared memory segments.
diff --git a/doc/man/psql.1 b/doc/man/psql.1
new file mode 100644
index 00000000000..6e3c72e0846
--- /dev/null
+++ b/doc/man/psql.1
@@ -0,0 +1,359 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/psql.1,v 1.1.1.1 1996/08/18 22:14:26 scrappy Exp $
+.TH PSQL UNIX 1/20/96 Postgres95 Postgres95
+.SH NAME
+psql \(em run the interactive query front-end
+.SH SYNOPSIS
+.BR psql
+[\c
+.BR "-a"
+authsvc
+]
+[\c
+.BR "-A"
+]
+[\c
+.BR "-c"
+query
+]
+[\c
+.BR "-d"
+dbName]
+[\c
+.BR "-e"
+]
+[\c
+.BR "-f"
+filename]
+[\c
+.BR "-h"
+hostname]
+[\c
+.BR "-H"
+]
+[\c
+.BR "-l"
+port]
+[\c
+.BR "-n"
+]
+[\c
+.BR "-o"
+filename
+]
+[\c
+.BR "-p"
+port]
+[\c
+.BR "-q"
+]
+[\c
+.BR "-s"
+]
+[\c
+.BR "-S"
+]
+[\c
+.BR "-t"
+]
+[\c
+.BR "-x"
+]
+[dbname]
+.in -5n
+.SH DESCRIPTION
+psql is a interactive query front-end to Postgres. It enables you to
+type in queries interactively, issue them to Postgres, and see the query
+results.
+.IR psql
+can be used in a pipe sequence, and automatically detects when it
+is not listening or talking to a real tty.
+.IR psql
+is designed to be an enhanced version of the older
+.IR "monitor"
+program.
+.PP
+.IR "psql"
+is a frontend application, like any other. Hence, a
+.IR "postmaster"
+process must be running on the database server host before
+.IR "psql"
+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.
+.IR dbname
+defaults to the value of the
+.SM USER
+environment variable or, if that's not set, to the Unix account name of the
+current user.
+.PP
+.IR "psql"
+understands the following command-line options:
+.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 "-A"
+Turn off fill justification when printing out attributes.
+.TP
+.BR "-c" " query"
+Specifies that
+.IR "psql"
+is to execute one query string,
+.IR "query" ,
+and then exit. This is useful for shell scripts, typically in
+conjunction with the
+.BR -q ""
+options.
+.BR -c
+option in shell scripts.
+.TP
+.BR "-d" " dbName"
+Specifies the name of the database to connect to.
+.TP
+.BR "-e" " "
+Echo the query sent to the backend
+.TP
+.BR "-f" " filename"
+Use the file
+.IR "filename"
+as the source of queries instead of reading queries interactively.
+.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 "-H"
+Turns on
+.SM HTML3.0
+tabular output.
+.TP
+.BR "-l"
+Lists all available databases
+.TP
+.BR "-n"
+Do not use the readline library for input line editing and command history.
+.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
+.IR psql
+should do its work quietly. By default, it
+prints welcome and exit messages and prompts for each query, and prints
+out the number of rows returned from a query.
+If this option is used, none of this happens. This is useful with the
+.BR -c
+option in shell scripts.
+.TP
+.BR "-s"
+Run in single-step mode where the user at prompted for each query before
+it is sent to the backend.
+.TP
+.BR "-S"
+Run ins single-line mode where each query is terminated by a newline,
+instead of a semicolon.
+.TP
+.BR "-t"
+Turn off printing of attributes names.
+This is useful with the
+.BR -c
+option in shell scripts.
+.TP
+.BR "-x"
+Turns on extended field mode. When enabled each tuple will have its field
+names printed on the left with the field values printed on the right.
+This is useful for tuples which are otherwise too long to fit into
+one screen line. HTML tuple output supports this mode also.
+.PP
+You may set environment variables to avoid typing some of the above
+options. See the
+.SM "ENVIRONMENT VARIABLES"
+section below.
+.SH "CONNECTING TO A DATABASE"
+.IR psql
+attempts to make a connection to the database at the hostname and
+port number specified on the command line. If the connection could not
+be made for any reason (e.g. insufficient privileges, postmaster is not
+running on the server, etc)
+.IR psql
+will return an error that says
+.nf
+Connection to database failed.
+.fi
+The reason for the connection failure is not provided.
+.SH "ENTERING QUERIES"
+In normal operation, psql provides a prompt with the name of the
+database that psql is current connected to followed by the string "=>".
+For example,
+.nf
+Welcome to the POSTGRES95 interactive sql monitor:
+ Please read the file COPYRIGHT for copyright terms of POSTGRES95
+
+ type \e? for help on slash commands
+ type \eq to quit
+ type \eg or terminate with semicolon to execute query
+ You are currently connected to the database: testdb
+
+testdb=>
+.fi
+.PP
+At the prompt, the user may type in SQL queries. Unless the -S option
+is set, input lines are sent to the backend when a query-terminating
+semicolon is reached.
+.PP
+Whenever a query is executed, psql also polls for asynchronous notification
+events generated by
+.IR listen (l)
+and
+.IR notify (l).
+.PP
+.SH "PSQL COMMANDS"
+.IP "\ea"
+Toggle field alignment when printing out attributes.
+.IP "\eC \fIcaption\fR"
+Set the HTML3.0 table caption.
+.IP "\ec \fIdbname\fR"
+Establish a connection to a new database. The previous connection is closed.
+.IP "\ed [\fItable\fR]"
+List tables in the database, or if
+.IR table
+is specified, list the columns in
+.IR table.
+If table name is
+.IR *,
+list all tables and column information for each tables.
+.IP "\ee [\fIfilename\fR]"
+Edit the current query buffer or \fIfile\fR.
+.IP "\eE [\fIfilename\fR]"
+Edit the current query buffer or \fIfile\fR and execute it
+upon editor exit.
+.IP "\ef [\fIseparator\fR]"
+Set the field separator. Default is a single blank space.
+.IP "\eg [\fI|command\fR] | [\fIfilename\fR]"
+Send the current query input buffer to the backend and optionally
+save the output in
+.IR filename
+or pipe the output into
+.IR "|command".
+.IP "\eh [\fIcommand\fR]"
+Give syntax help on the specified SQL command. If the
+.IR command
+is not specified, list all the commands for which syntax help is
+available. If the
+.IR command
+is
+.IR *,
+give syntax help on all SQL commands.
+.IP "\eH"
+Toggle html3 output.
+.IP "\ei \fIfilename\fR"
+Read queries from
+.IR filename
+into the query input buffer.
+.IP "\el"
+List all the databases in the server.
+.IP "\em"
+Toggle monitor-like table display.
+This is standard SQL output (i.e extra border characters).
+.IP "\eo [\fI|command\fR] | [\fIfilename\fR]"
+Send query results to
+.IR filename .
+Or pipe into
+.IR command .
+If no arguments are specified, send query results to
+.IR stdout .
+.IP "\ep"
+Print the current query buffer.
+.IP \eq
+Quit the psql program.
+.IP "\er"
+Reset(clear) the query buffer.
+.IP "\es [\fIfilename\fR]"
+Print or save the command line history to \fIfilename\fR. (Only available if psql is
+configured to use readline)
+.IP "\et"
+Toggle display of output attribute name headings and row count (defaults to on).
+.IP "\eT"
+Set html3.0 <table ...> options.
+.IP "\ex"
+Toggles extended field mode. When enabled each tuple will have its field
+names printed on the left with the field values printed on the right.
+This is useful for tuples which are otherwise too long to fit into
+one screen line. HTML tuple output mode supports this flag too.
+.IP "\e! [\fIcommand\fR]"
+Escape to shell or execute
+.IR command.
+.IP \e?
+Get help information about the \e commands.
+.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 psql
+returns 0 to the shell on successful query completion, 1 otherwise.
+.IR psql
+will also return 1 if the connection to a database could not be made for
+any reason.
+.SH "SEE ALSO"
+introduction(libpq),
+monitor(1)
+postgres(1),
+postmaster(1).
+.SH BUGS
+If multiple queries are sent to the backend at once without semicolon
+termination after each query, psql gets confused about the query
+results. The queries will still be processed correctly by the backend.
+
diff --git a/doc/man/purge.l b/doc/man/purge.l
new file mode 100644
index 00000000000..9e1f68a99f9
--- /dev/null
+++ b/doc/man/purge.l
@@ -0,0 +1,61 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.TH PURGE SQL 11/05/95 Postgres95 Postgres95
+.SH NAME
+purge \(em discard historical data
+.SH SYNOPSIS
+.nf
+\fBpurge\fR classname [ \fBbefore\fR abstime ] [ \fBafter\fR reltime ]
+.fi
+.SH DESCRIPTION
+.BR Purge
+allows a user to specify the historical retention properties of a
+class. If the date specified is an absolute time such as \*(lqJan 1
+1987\*(rq, Postgres will discard tuples whose validity expired before
+the indicated time.
+.BR Purge
+with no
+.IR before
+clause is equivalent to \*(lqpurge before now\*(rq. Until specified
+with a purge command, instance preservation defaults to
+\*(lqforever\*(rq.
+.PP
+The user may purge a class at any time as long as the purge date never
+decreases. Postgres will enforce this restriction, silently.
+.PP
+Note that the
+.BR purge
+command does not do anything except set a parameter for system
+operation. Use
+.IR vacuum (l)
+to enforce this parameter.
+.SH EXAMPLE
+.nf
+--
+--Always discard data in the EMP class
+--prior to January 1, 1989
+--
+purge EMP before "Jan 1 1989"
+.fi
+.nf
+--
+--Retain only the current data in EMP
+--
+purge EMP
+.fi
+.SH "SEE ALSO"
+vacuum(l).
+.SH "BUGS AND CAVEATS"
+Error messages are quite unhelpful. A complaint about
+\*(lqinconsistent times\*(rq followed by several nine-digit numbers
+indicates an attempt to \*(lqback up\*(rq a purge date on a relation.
+.PP
+You cannot purge certain system catalogs (namely, \*(lqpg_class\*(rq,
+\*(lqpg_attribute\*(rq, \*(lqpg_am\*(rq, and \*(lqpg_amop\*(rq) due
+to circularities in the system catalog code.
+.PP
+This definition of the
+.BR purge
+command is really only useful for non-archived relations, since
+tuples will not be discarded from archive relations (they are
+never vacuumed).
diff --git a/doc/man/remove_view.l b/doc/man/remove_view.l
new file mode 100644
index 00000000000..9f1d1013a5e
--- /dev/null
+++ b/doc/man/remove_view.l
@@ -0,0 +1,23 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/remove_view.l,v 1.1.1.1 1996/08/18 22:14:27 scrappy Exp $
+.TH "DROP VIEW" SQL 04/25/94 Postgres95 Postgres95
+.SH NAME
+drop view \(em removes a view from Postgres
+.SH SYNOPSIS
+.nf
+\fBdrop view\fR view_name
+.fi
+.SH DESCRIPTION
+This command drops an existing view from the Postgres system. To
+execute this command you must be the owner of the view.
+.SH EXAMPLE
+.nf
+/*
+ * this command will remove the "myview" view
+ */
+drop view myview
+.fi
+.SH "SEE ALSO"
+create view(l),
+drop rule(l),
diff --git a/doc/man/rename.l b/doc/man/rename.l
new file mode 100644
index 00000000000..0c1258d4723
--- /dev/null
+++ b/doc/man/rename.l
@@ -0,0 +1,63 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/rename.l,v 1.1.1.1 1996/08/18 22:14:27 scrappy Exp $
+.TH RENAME SQL 02/08/94 Postgres95 Postgres95
+.SH NAME
+rename \(em rename a class or an attribute in a class
+.SH SYNOPSIS
+.nf
+\fBalter table\fR classname1
+ \fBrename to\fR classname2
+\fBalter table\fR classname1 [\fB*\fR]
+ \fBrename [column]\fR attname1 \fBto\fR attname2
+.fi
+.SH DESCRIPTION
+The
+.BR rename
+command
+causes the name of a class or attribute to change without changing any
+of the data contained in the affected class. Thus, the class or
+attribute will remain of the same type and size after this command is
+executed.
+.PP
+In order to rename an attribute in 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 renamed in any of the subclasses.) This should
+.BR always
+be done when changing an attribute name in 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 (in effect) missing an
+attribute found in the superclass.
+.PP
+You must own the class being modified in order to rename it or part of
+its schema. Renaming any part of the schema of a system catalog is
+not permitted.
+.SH EXAMPLE
+.nf
+--
+-- change the emp class to personnel
+--
+alter table emp rename to personnel
+.fi
+.nf
+--
+-- change the sports attribute to hobbies
+--
+alter table emp rename column sports to hobbies
+.fi
+.nf
+--
+-- make a change to an inherited attribute
+--
+alter table person * rename column last_name to family_name
+.fi
+.SH BUGS
+Execution of historical queries using classes and attributes whose
+names have changed will produce incorrect results in many situations.
+.PP
+Renaming of types, operators, rules, etc., should also be supported.
diff --git a/doc/man/revoke.l b/doc/man/revoke.l
new file mode 100644
index 00000000000..e0450756df5
--- /dev/null
+++ b/doc/man/revoke.l
@@ -0,0 +1,29 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/revoke.l,v 1.1.1.1 1996/08/18 22:14:27 scrappy Exp $
+.TH REVOKE SQL 11/05/95 Postgres95 Postgres95
+.SH NAME
+revoke \(em revoke access privileges
+.SH SYNOPSIS
+.nf
+\fBrevoke\fR <privilege[,privilege,...]>
+ \fBon\fR <rel1>[,...<reln>]
+ \fBfrom\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 revoke
+allows you to revoke privileges given to all users or certain users or groups.
+.SH EXAMPLES
+.nf
+--
+--Example of a revoke
+--
+revoke insert
+ on mytab
+ from public
+.fi
+.SH "SEE ALSO"
+grant(l)
diff --git a/doc/man/rollback.l b/doc/man/rollback.l
new file mode 100644
index 00000000000..c6b673c3736
--- /dev/null
+++ b/doc/man/rollback.l
@@ -0,0 +1,24 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/rollback.l,v 1.1.1.1 1996/08/18 22:14:27 scrappy Exp $
+.TH ROLLBACK SQL 01/20/96 Postgres95 Postgres95
+.\" XXX This .XA has to go after the .TH so that the index page number goes
+.\" in the right place...
+.SH NAME
+rollback \(em rollback, e.g. aborts, the current transaction
+.SH SYNOPSIS
+.nf
+\fBrollback\fP \fB[transaction|work]\fR
+.fi
+.SH DESCRIPTION
+This command rolls back the current transaction and causes all the
+updates made by the transaction to be discarded.
+.PP
+.IR "rollback"
+is functionally equivalent to the
+.IR "abort"
+command.
+.SH "SEE ALSO"
+abort(l),
+begin(l),
+end(l).
diff --git a/doc/man/select.l b/doc/man/select.l
new file mode 100644
index 00000000000..8013cede3ca
--- /dev/null
+++ b/doc/man/select.l
@@ -0,0 +1,133 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/select.l,v 1.1.1.1 1996/08/18 22:14:27 scrappy Exp $
+.TH SELECT SQL 11/05/95 Postgres95 Postgres95
+.SH NAME
+select \(em retrieve instances from a class
+.SH SYNOPSIS
+.nf
+\fBselect\fR [distinct]
+ expression1 [\fBas\fR attr_name-1]
+ {, expression-1 [\fBas\fR attr_name-i]}
+ [\fBinto\fR \fBtable\fR classname]
+ [\fBfrom\fR from-last]
+ [\fBwhere\fR where-clause]
+ [\fBgroup by\fR attr_name1 {, attr_name-i....}
+ [\fBorder by\fR attr_name1
+ [\fBusing op1\fR] {, attr_namei [\fBusing opi\fR] }
+.fi
+.SH DESCRIPTION
+.BR Select
+will get all instances which satisfy the qualification,
+.IR qual ,
+compute the value of each element in the target list, and either (1)
+return them to an application program through one of two different
+kinds of portals or (2) store them in a new class.
+.PP
+If
+into table class name
+is specified, the result of the query will be stored in a new class
+with the indicated name.
+.PP
+The
+.BR "order by"
+clause allows a user to specify that he wishes the instances sorted
+according to the corresponding operator. This operator must be a
+binary one returning a boolean. Multiple sort fields are allowed and
+are applied from left to right.
+.PP
+The target list specifies the fields to be retrieved. Each
+.IR attr_name
+specifies the desired attribute or portion of an array attribute.
+Thus, each
+.IR attr_name
+takes the form
+.nf
+class_name.att_name
+.fi
+or, if the user only desires part of an array,
+.nf
+--
+--Specify a lower and upper index for each dimension
+--(i.e., clip a range of array elements)
+--
+class_name.att_name[lIndex-1:uIndex-1]..[lIndex-i:uIndex-i]
+
+--
+--Specify an exact array element
+--
+class_name.att_name[uIndex-1]..[uIndex-i]
+.fi
+where each
+.IR lIndex
+or
+.IR uIndex
+is an integer constant.
+.PP
+When you retrieve an attribute which is of a complex type, the behavior
+of the system depends on whether you used "nested dots" to project
+out attributes of the complex type or not. See the examples below.
+.PP
+You must have read access to a class to read its values (see
+.IR "grant/revoke" (l).
+.SH EXAMPLES
+.nf
+--
+--Find all employees who make more than their manager
+--
+select e.name
+ from emp e, emp m
+ where e.mgr = m.name
+ and e.sal > m.sal
+.fi
+.nf
+--
+--Retrieve all fields for those employees who make
+--more than the average salary
+--
+select avg(sal) as ave
+ into table avgsal from emp;
+.fi
+.nf
+--
+--Retrieve all employee names in sorted order
+--
+select distinct name
+ from emp
+ order by name using <
+.fi
+.nf
+--
+--Retrieve all employee names that were valid on 1/7/85
+--in sorted order
+--
+selec name
+ from emp['January 7 1985'] e
+ order by name using <
+.fi
+.nf
+--
+--Construct a new class, raise, containing 1.1
+--times all employee's salaries
+--
+select 1.1 * emp.salary as salary
+ into tables raise
+ from emp
+.fi
+.SH "SEE ALSO"
+insert(l),
+close(l),
+create table(l),
+fetch(l),
+update(l).
+.SH BUGS
+.BR "Select into"
+does not delete duplicates.
+.PP
+If the backend crashes in the course of executing a
+.BR "select into" ,
+the class file will remain on disk. It can be safely removed by the
+database DBA, but a subsequent
+.BR "select into"
+to the same name will fail with a cryptic error message about
+\*(lqBlockExtend\*(rq.
diff --git a/doc/man/sql.l b/doc/man/sql.l
new file mode 100644
index 00000000000..d6ad3eb6363
--- /dev/null
+++ b/doc/man/sql.l
@@ -0,0 +1,349 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/sql.l,v 1.1.1.1 1996/08/18 22:14:28 scrappy Exp $
+.TH INTRODUCTION SQL 11/5/95 Postgres95 Postgres95
+.SH "Section 4 \(em SQL Commands (COMMANDS)"
+.SH "General Information"
+.SH DESCRIPTION
+The following is a description of the general syntax of SQL.
+Individual SQL statements and commands are treated separately in the
+document; this section describes the syntactic classes from which the
+constituent parts of SQL statements are drawn.
+.SH Comments
+A
+.IR comment
+is an arbitrary sequence of characters following double dashes up to the end
+of the line e.g:
+.nf
+-- This is a comment
+.fi
+.SH "Names"
+.IR Names
+in SQL are sequences of not more than NAMEDATALEN alphanumeric characters,
+starting with an alphabetic character. By default, NAMEDATALEN is set
+to 16, but at the time the system is built, NAMEDATALEN can be changed
+by changing the #ifdef in src/backend/include/postgres.h. Underscore
+(\*(lq_\*(rq) is considered an alphabetic character.
+.SH "Keywords"
+The following identifiers are reserved for use as
+.IR keywords
+and may not be used otherwise:
+.PP
+.ft B
+.nf
+.if n .ta 5 +15 +15 +15
+.if t .ta 0.5i +1.5i +1.5i +1.5i
+.fi
+.ft
+.ft B
+.nf
+.if n .ta 5 +15 +15 +15
+.if t .ta 0.5i +1.5i +1.5i +1.5i
+.fi
+.ft
+.PP
+In addition, all Postgres classes have several predefined attributes used
+by the system.
+.SH "Constants"
+There are six types of
+.IR constants
+for use in SQL. They are described below.
+.SH "String Constants"
+.IR Strings
+in SQL are arbitrary sequences of ASCII characters bounded by single
+quotes (' '). Uppercase alphabetics within strings are accepted
+literally. Non-printing characters may be embedded within strings by
+prepending them with a backslash, e.g., `\en'. Also, in order to embed
+quotes within strings, it is necessary to prefix them with `\e' . The
+same convention applies to `\e' itself. Because of the limitations on
+instance sizes, string constants are currently limited to a length of
+a little less than 8192 bytes. Larger objects may be created using the
+Postgres Large Object interface.
+.SH "Integer Constants"
+.IR "Integer constants"
+in SQL are collection of ASCII digits with no decimal point. Legal
+values range from \(mi2147483647 to +2147483647. This will vary
+depending on the operating system and host machine.
+.SH "Floating Point Constants"
+.IR "Floating point constants"
+consist of an integer part, a decimal point, and a fraction part or
+scientific notation of the following format:
+.nf
+{<dig>} .{<dig>} [e [+-] {<dig>}]
+.fi
+Where <dig> is a digit. You must include at least one <dig> after the
+period and after the [+-] if you use those options. An exponent with
+a missing mantissa has a mantissa of 1 inserted. There may be no
+extra characters embedded in the string.
+Floating point constaints are of type float4.
+.SH "Constants of Postgres User-Defined Types"
+A constant of an
+.IR arbitrary
+type can be entered using the notation:
+.nf
+'string'::type-name
+.fi
+or
+.nf
+CAST 'string' AS type-name
+.fi
+The value inside the string is passed to the input
+conversion routine for the type called type-name. The result is a
+constant of the indicated type. The explicit typecast may be omitted
+if there is no ambiguity as to the type the constant must be, in which
+case it is automatically coerced.
+.SH "Array constants"
+.IR "Array constants"
+are arrays of any Postgres type, including other arrays, string
+constants, etc. The general format of an array constant is the
+following:
+.nf
+{<val1><delim><val2><delim>}
+.fi
+Where
+.IR "<delim>"
+is the delimiter for the type stored in the \*(lqpg_type\*(rq class.
+(For built-in types, this is the comma character, \*(lq,\*(rq.) An
+example of an array constant is
+.nf
+{{1,2,3},{4,5,6},{7,8,9}}
+.fi
+This constant is a two-dimensional, 3 by 3 array consisting of three
+sub-arrays of integers.
+.PP
+Individual array elements can and should be placed between quotation
+marks whenever possible to avoid ambiguity problems with respect to
+leading white space.
+.\" Elements of single-element arrays (e.g.,
+.\" \*(lq{"1"}\*(rq) must be quoted.
+.PP
+.SH "FIELDS AND COLUMNS"
+.SH "Fields"
+A
+.IR field
+is either an attribute of a given class or one of the following:
+.nf
+oid
+tmin
+tmax
+xmin
+xmax
+cmin
+cmax
+.fi
+.PP
+.IR Oid
+stands for the unique identifier of an instance which is added by
+Postgres to all instances automatically. Oids are not reused and are 32
+bit quantities.
+.PP
+.IR "Tmin, tmax, xmin, cmin, xmax"
+and
+.IR cmax
+stand respectively for the time that the instance was inserted, the
+time the instance was deleted, the identity of the inserting
+transaction, the command identifier within the transaction, the
+identity of the deleting transaction and its associated deleting
+command. For further information on these fields consult [STON87].
+Times are represented internally as instances of the \*(lqabstime\*(rq
+data type. Transaction identifiers are 32 bit quantities which are
+assigned sequentially starting at 512. Command identifiers are 16 bit
+objects; hence, it is an error to have more than 65535 SQL commands
+within one transaction.
+.SH "Columns"
+A
+.IR column
+is a construct of the form:
+.nf
+Instance-variable{.composite_field}.field `['number`]'
+.fi
+.IR Instance-variable
+identifies a particular class and can be thought of as standing for
+the instances of that class. An instance variable is either a class
+name, a surrogate for a class defined by means of a
+.IR from
+clause, or the keyword
+.BR new
+or
+.BR current.
+New and current can only appear in the action portion of a rule, while
+other instance variables can be used in any SQL statement.
+.IR Composite_field
+is a field of of one of the Postgres composite types indicated in the
+.IR information (l)
+section, while successive composite fields address attributes in the
+class(s) to which the composite field evaluates. Lastly,
+.IR field
+is a normal (base type) field in the class(s) last addressed. If
+.IR field
+is of type array, then the optional
+.IR number
+designator indicates a specific element in the array. If no number is
+indicated, then all array elements are returned.
+.SH "Operators"
+Any built-in system, or user-defined operator may be used in SQL.
+For the list of built-in and system operators consult
+.BR "introduction" "(3)."
+For a list of user-defined operators consult your system administrator
+or run a query on the pg_operator class. Parentheses may be used for
+arbitrary grouping of operators.
+.SH "Expressions (a_expr)"
+An
+.IR expression
+is one of the following:
+.nf
+( a_expr )
+constant
+attribute
+a_expr binary_operator a_expr
+a_expr right_unary_operator
+left_unary_operator a_expr
+parameter
+functional expressions
+aggregate expressions
+.fi
+We have already discussed constants and attributes. The two kinds of
+operator expressions indicate respectively binary and left_unary
+expressions. The following sections discuss the remaining options.
+.SH "Parameters"
+A
+.IR parameter
+is used to indicate a parameter in a SQL function. Typically this
+is used in SQL function definition statement. The form of a
+parameter is:
+.nf
+\'$' number
+.fi
+For example, consider the definition of a function, DEPT, as
+.nf
+create function DEPT (char16)
+ returns dept
+ as 'select * from
+ dept where name=$1'
+ language 'sql'
+.fi
+.SH "Functional Expressions"
+A
+.IR "functional expression"
+is the name of a legal SQL function, followed by its argument list
+enclosed in parentheses, e.g.:
+.nf
+fn-name (a_expr{ , a_expr})
+.fi
+For example, the following computes the square root of an employee
+salary.
+.nf
+sqrt(emp.salary)
+.fi
+.SH "Aggregate Expression"
+An
+.IR "aggregate expression"
+represents a simple aggregate (i.e., one that computes a single value)
+or an aggregate function (i.e., one that computes a set of values).
+The syntax is the following:
+.nf
+aggregate.name (attribute)
+.fi
+Here,
+.IR aggregate_name
+must be a previously defined aggregate.
+.SH "Target_list"
+A
+.IR "target list"
+is a parenthesized, comma-separated list of one or more elements, each
+of which must be of the form:
+.nf
+a_expr[AS result_attname]
+.fi
+Here, result_attname is the name of the attribute to be created (or an
+already existing attribute name in the case of update statements.) If
+.IR result_attname
+is not present, then
+.IR a_expr
+must contain only one attribute name which is assumed to be the name
+of the result field. In Postgres default naming is only used if
+.IR a_expr
+is an attribute.
+.SH‚‚ "Qualification"
+A
+.IR qualification
+consists of any number of clauses connected by the logical operators:
+.nf
+not
+and
+or
+.fi
+A clause is an
+.IR a_expr
+that evaluates to a Boolean over a set of instances.
+.SH "From List"
+The
+.IR "from list"
+is a comma-separated list of
+.IR "from expressions" .
+.PP
+Each
+.IR "from expression"
+is of the form:
+.nf
+[class_reference] instance_variable
+ {, [class_ref] instance_variable...}
+.fi
+where
+.IR class_reference
+is of the form
+.nf
+class_name [time_expression] [*]
+.fi
+The
+.IR "from expression"
+defines one or more instance variables to range over the class
+indicated in
+.IR class_reference .
+Adding a
+.IR time_expression
+will indicate that a historical class is desired. One can also request
+the instance variable to range over all classes that are beneath the
+indicated class in the inheritance hierarchy by postpending the
+designator \*(lq*\*(rq.
+.SH‚‚ "Time Expressions"
+A
+.IR "time expression"
+is in one of two forms:
+.nf
+ ['date']
+ ['date-1', 'date-2']
+.fi
+The first case requires instances that are valid at the indicated
+time. The second case requires instances that are valid at some time
+within the date range specified. If no time expression is indicated,
+the default is \*(lqnow\*(rq.
+.PP
+In each case, the date is a character string of the form
+.nf
+[MON-FRI] 'MMM DD [HH:MM:SS] YYYY' [Timezone]
+.fi
+where MMM is the month (Jan \- Dec), DD is a legal day number in the
+specified month, HH:MM:SS is an optional time in that day (24-hour
+clock), and YYYY is the year. If the time of day HH:MM:SS is not
+specified, it defaults to midnight at the start of the specified day.
+As of Version 3.0, times are no longer read and written using
+Greenwich Mean Time; the input and output routines default to the
+local time zone.
+.PP
+For example,
+.nf
+['Jan 1 1990']
+['Mar 3 00:00:00 1980', 'Mar 3 23:59:59 1981r']
+.fi
+are valid time specifications.
+.PP
+Note that this syntax is slightly different than that used by the
+time-range type.
+.SH "SEE ALSO"
+insert(l),
+delete(l),
+execute(l),
+update(l),
+select(l),
+monitor(1).
diff --git a/doc/man/template.5 b/doc/man/template.5
new file mode 100644
index 00000000000..739ef3bf061
--- /dev/null
+++ b/doc/man/template.5
@@ -0,0 +1,65 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/template.5,v 1.1.1.1 1996/08/18 22:14:28 scrappy Exp $
+.TH TEMPLATE FILES 01/23/93 Postgres95 Postgres95
+.SH Template
+.SH NAME
+\&.../data/files/global1.bki \(em global database template
+.br
+\&.../data/files/local1_XXX.bki \(em local database template
+.br
+\&.../data/files/template1/* \(em default database template
+.SH DESCRIPTION
+These files contain scripts which direct the construction of
+databases. Note that the \*(lqglobal1.bki\*(rq and
+\*(lqtemplate1_local.bki\*(rq files are installed automatically when
+the Postgres super-user runs
+.IR initdb .
+These files are copied from
+.nf
+\&.../src/backend/obj/{dbdb,local}.bki
+.fi
+The databases which are generated by the template scripts are normal
+databases. Consequently, you can use the terminal monitor or some
+other frontend on a template database to simplify the customization
+task. That is, there is no need to express everything about your
+desired initial database state using a BKI template script, because
+the database state can be tuned interactively.
+.PP
+The system catalogs consist of classes of two types: global and local.
+There is one copy of each global class that is shared among all
+databases at a site. Local classes, on the other hand, are not
+accessible except from their own database.
+.PP
+The file
+.nf
+\&.../data/files/global1.bki
+.fi
+specifies the process used in the creation of global (shared) classes
+by
+.IR createdb .
+Similarly, the
+.nf
+\&.../files/local1_XXX.bki
+.fi
+files specify the process used in the creation of local (unshared)
+catalog classes for the \*(lqXXX\*(rq template database.
+\*(lqXXX\*(rq may be any string of 16 or fewer printable characters.
+If no template is specified in a
+.IR createdb
+command,
+then the template in
+.nf
+\&.../files/local1_template1.bki
+.fi
+is used.
+.PP
+The .bki files are generated from C source code by an inscrutable set
+of AWK scripts.
+.SH BUGS
+Postgres Version \*(PV does not permit users to have separate template
+databases.
+.SH "SEE ALSO"
+bki(files),
+initdb(1),
+createdb(1).
diff --git a/doc/man/unix.1 b/doc/man/unix.1
new file mode 100644
index 00000000000..cc33492dfc1
--- /dev/null
+++ b/doc/man/unix.1
@@ -0,0 +1,279 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/unix.1,v 1.1.1.1 1996/08/18 22:14:28 scrappy Exp $
+.TH INTRODUCTION UNIX 11/05/95 Postgres95 Postgres95
+.SP INFORMATION UNIX 11/05/95
+.BH "SECTION 2 \(em Unix COMMANDS (Unix)"
+.SH "OVERVIEW"
+This section outlines the interaction between Postgres and
+the operating system. In particular, this section describes
+the Postgres support programs that are executable as Unix
+commands.
+.SH TERMINOLOGY
+In the following documentation, the term
+.IR site
+may be interpreted as the host machine on which Postgres is installed.
+Since it is possible to install more than one set of Postgres
+databases on a single host, this term more precisely denotes any
+particular set of installed Postgres binaries and databases.
+.PP
+The
+.IR "Postgres super-user"
+is the user named \*(lqpostgres\*(rq who owns the Postgres
+binaries and database files. As the database super-user, all
+protection mechanisms may be bypassed and any data accessed
+arbitrarily. In addition, the Postgres super-user is allowed to execute
+some support programs which are generally not available to all users.
+Note that the Postgres super-user is
+.IR not
+the same as the Unix super-user,
+.IR root ,
+and should have a non-zero userid for security reasons.
+.PP
+The
+.IR "database base administrator"
+or DBA, is the person who is responsible for installing Postgres 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
+.IR createdb (1).
+.PP
+The
+.IR postmaster
+is the process that acts as a clearing-house for requests to the Postgres
+system.
+Frontend applications connect to the
+.IR postmaster ,
+which keeps tracks of any system errors and communication between the
+backend processes. The
+.IR 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. See
+.IR postmaster (1)
+for details.
+.PP
+The
+.IR "Postgres backend"
+(the actual executable program called "postgres") may be executed
+directly from the user shell by the
+Postgres super-user (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.
+.SH NOTATION
+\*(lq.../\*(rq at the front of a file name is used to represent the
+path to the Postgres super-user's home directory. Anything in brackets
+(\*(lq[\*(rq and \*(lq]\*(rq) is optional. Anything in braces
+(\*(lq{\*(rq and \*(lq}\*(rq) can be repeated 0 or more times.
+Parentheses (\*(lq(\*(rq and \*(lq)\*(rq ) are used to group boolean
+expressions. \*(lq|\*(rq is the boolean operator
+.SM OR .
+.SH "USING Postgres FROM Unix"
+All Postgres commands that are executed directly from a Unix shell are
+found in the directory \*(lq.../bin\*(rq. Including this directory in
+your search path will make executing the commands easier.
+.PP
+A collection of system catalogs exist at each site. These include a
+class (\*(lqpg_user\*(rq) that contains an instance for each valid
+Postgres user. The instance specifies a set of Postgres privileges, such as
+the ability to act as Postgres super-user, the ability to create/destroy
+databases, and the ability to update the system catalogs. A Unix
+user cannot do anything with Postgres until an appropriate instance is
+installed in this class. Further information on the system catalogs
+is available by running queries on the appropriate classes.
+.SH "Security"
+.SP SECURITY UNIX 03/12/94
+.SH "USER AUTHENTICATION"
+.IR Authentication
+is the process by which the backend server and
+.IR postmaster
+ensure that the user requesting access to data is in fact who he/she
+claims to be. All users who invoke Postgres are checked against the
+contents of the \*(lqpg_user\*(rq class to ensure that they are
+authorized to do so. However, verification of the user's actual
+identity is performed in a variety of ways.
+.SS "From the user shell"
+A backend server started from a user shell notes the user's (effective)
+user-id before performing a
+.IR setuid (3)
+to the user-id of user \*(lqpostgres\*(rq. The effective user-id is used
+as the basis for access control checks. No other authentication is
+conducted.
+.SS "From the network"
+If the Postgres system is built as distributed, access to the Internet
+TCP port of the
+.IR postmaster
+process is available to anyone. However, Postgres offers optional
+host-based authentication where only access from certain hosts are
+allowed. Of course, host-based authentication is not fool-proof in
+Unix, either. It is possible for determined intruders to also
+masquerade the origination host. Those security issues are beyond the
+scope of Postgres.
+.PP
+If greater security is desired, Postgres and its clients may be
+modified to use a network authentication system. For example, the
+.IR postmaster ,
+.IR psql
+and the
+.IR libpq
+library have already been configured to use either Version 4 or Version 5 of
+the
+.IR Kerberos
+authentication system from the Massachusetts Institute of Technology.
+For more information on using
+.IR Kerberos
+with Postgres, see the appendix below.
+.SH "ACCESS CONTROL"
+Postgres provides mechanisms to allow users to limit the access to
+their data that is provided to other users.
+.SS "Database superusers"
+Database super-users (i.e., users who have \*(lqpg_user.usesuper\*(rq
+set) silently bypass all of the access controls described below with
+two exceptions: manual system catalog updates are not permitted if the
+user does not have \*(lqpg_user.usecatupd\*(rq set, and destruction of
+system catalogs (or modification of their schemas) is never allowed.
+.SS "Access Privilege
+The use of access privilege to limit reading, writing and setting
+of rules on classes is covered in
+.IR "grant/revoke" (l).
+.SS "Class removal and schema modification"
+Commands that destroy or modify the structure of an existing class,
+such as
+.IR "alter" ,
+.IR "drop table" ,
+and
+.IR "drop index" ,
+only operate for the owner of the class. As mentioned above, these
+operations are
+.BR never
+permitted on system catalogs.
+.SH "FUNCTIONS AND RULES"
+Functions and rules allow users to insert code into the backend server
+that other users may execute without knowing it. Hence, both
+mechanisms permit users to
+.BR "trojan horse"
+others with relative impunity. The only real protection is tight
+control over who can define functions (e.g., write to relations with
+SQL fields) and rules. Audit trails and alerters on
+\*(lqpg_class\*(rq, \*(lqpg_user\*(rq and \*(lqpg_group\*(rq are also
+recommended.
+.SS "Functions"
+Functions written in any language except SQL
+run inside the backend server
+process with the permissions of the user \*(lqpostgres\*(rq (the
+backend server runs with its real and effective user-id set to
+\*(lqpostgres\*(rq). It is possible for users to change the server's
+internal data structures from inside of trusted functions. Hence,
+among many other things, such functions can circumvent any system
+access controls. This is an inherent problem with user-defined C functions.
+.SS "Rules"
+Like SQL functions, rules always run with the identity and
+permissions of the user who invoked the backend server.
+.SH "SEE ALSO"
+postmaster(1),
+alter(l),
+insert(l),
+grant/revoke(l),
+copy(l),
+create(l),
+delete(l),
+drop table(l),
+drop index(l),
+drop rule(l),
+update(l),
+select(l),
+kerberos(1),
+kinit(1),
+kerberos(3)
+.SH CAVEATS
+.PP
+There are no plans to explicitly support encrypted data inside of
+Postgres (though there is nothing to prevent users from encrypting
+data within user-defined functions). There are no plans to explicitly
+support encrypted network connections, either, pending a total rewrite
+of the frontend/backend protocol.
+.PP
+User names, group names and associated system identifiers (e.g., the
+contents of \*(lqpg_user.usesysid\*(rq) are assumed to be unique
+throughout a database. Unpredictable results may occur if they are
+not.
+.SH "APPENDIX: USING KERBEROS"
+.SS "Availability"
+The
+.IR Kerberos
+authentication system is not distributed with Postgres, nor is it
+available from the University of California at Berkeley. Versions of
+.IR Kerberos
+are typically available as optional software from operating system
+vendors. In addition, a source code distribution may be obtained
+through MIT Project Athena by anonymous FTP from ATHENA-DIST.MIT.EDU
+(18.71.0.38). (You may wish to obtain the MIT version even if your
+vendor provides a version, since some vendor ports have been
+deliberately crippled or rendered non-interoperable with the MIT
+version.) Users located outside the United States of America and
+Canada are warned that distribution of the actual encryption code in
+.IR Kerberos
+is restricted by U. S. government export regulations.
+.PP
+Any additional inquiries should be directed to your vendor or MIT
+Project Athena (\*(lqinfo-kerberos@ATHENA.MIT.EDU\*(rq). Note that FAQLs
+(Frequently-Asked Questions Lists) are periodically posted to the
+.IR Kerberos
+mailing list, \*(lqkerberos@ATHENA.MIT.EDU\*(rq (send mail to
+\*(lqkerberos-request@ATHENA.MIT.EDU\*(rq to subscribe), and USENET
+news group, \*(lqcomp.protocols.kerberos\*(rq.
+.SS "Installation"
+Installation of
+.IR Kerberos
+itself is covered in detail in the
+.IR "Kerberos Installation Notes" .
+Make sure that the server key file (the
+.IR srvtab
+or
+.IR keytab )
+is somehow readable by user \*(lqpostgres\*(rq.
+.PP
+Postgres and its clients can be compiled to use either Version 4 or
+Version 5 of the MIT
+.IR Kerberos
+protocols by setting the
+.SM KRBVERS
+variable in the file \*(lq.../src/Makefile.global\*(rq to the
+appropriate value. You can also change the location where Postgres
+expects to find the associated libraries, header files and its own
+server key file.
+.PP
+After compilation is complete, Postgres must be registered as a
+.IR Kerberos
+service. See the
+.IR "Kerberos Operations Notes"
+and related manual pages for more details on registering services.
+.SS "Operation"
+After initial installation, Postgres should operate in all ways as a
+normal
+.IR Kerberos
+service. For details on the use of authentication, see the manual
+pages for
+.IR postmaster (1)
+and
+.IR psql (1).
+.PP
+In the
+.IR Kerberos
+Version 5 hooks, the following assumptions are made about user
+and service naming: (1) user principal names (anames) are assumed to
+contain the actual Unix/Postgres user name in the first component; (2)
+the Postgres service is assumed to be have two components, the service
+name and a hostname, canonicalized as in Version 4 (i.e., all domain
+suffixes removed).
+.PP
+.nf
+user example: frew@S2K.ORG
+user example: aoki/HOST=miyu.S2K.Berkeley.EDU@S2K.ORG
+host example: postgres_dbms/ucbvax@S2K.ORG
+.fi
+.PP
+Support for Version 4 will disappear sometime after the production
+release of Version 5 by MIT.
diff --git a/doc/man/update.l b/doc/man/update.l
new file mode 100644
index 00000000000..4b7bb25e386
--- /dev/null
+++ b/doc/man/update.l
@@ -0,0 +1,41 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/update.l,v 1.1.1.1 1996/08/18 22:14:28 scrappy Exp $
+.TH UPDATE SQL 11/05/95 Postgres95 Postgres95
+.SH NAME
+update \(em replace values of attributes in a class
+.SH SYNOPSIS
+.nf
+\fBupdate\fR classname \fBset\fR attname-1 = expression-1,
+ {attname-i = expression-i}
+ [\fBwhere\fR qual]
+.fi
+.SH DESCRIPTION
+.BR Update
+changes the values of the attributes specified in
+.IR target_list
+for all instances which satisfy the qualification,
+.IR qual .
+Only the attributes to be modified need appear in
+.IR target_list .
+.PP
+Array references use the same syntax found in
+.IR select(l).
+That is, either single array elements, a range of array elements or
+the entire array may be replaced with a single query.
+.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 mentioned in the target list
+or qualification.
+.SH EXAMPLES
+.nf
+--
+--Give all employees who work for Smith a 10% raise
+--
+update emp
+ set sal = 1.1 * sal
+ where mgr = 'Smith'
+.fi
+.SH "SEE ALSO"
+create table(l),
+select(l).
diff --git a/doc/man/vacuum.l b/doc/man/vacuum.l
new file mode 100644
index 00000000000..b7e17058829
--- /dev/null
+++ b/doc/man/vacuum.l
@@ -0,0 +1,34 @@
+.\" This is -*-nroff-*-
+.\" XXX standard disclaimer belongs here....
+.\" $Header: /cvsroot/pgsql/doc/man/Attic/vacuum.l,v 1.1.1.1 1996/08/18 22:14:28 scrappy Exp $
+.TH VACUUM SQL 11/05/95 Postgres95 Postgres95
+.SH NAME
+vacuum \(em vacuum a database
+.SH SYNOPSIS
+.nf
+\fBvacuum\fP
+.fi
+.SH DESCRIPTION
+.BR Vacuum
+is the Postgres vacuum cleaner. It opens every class in the database,
+moves deleted records to the archive for archived relations, cleans
+out records from aborted transactions, and updates statistics in the
+system catalogs. The statistics maintained include the number of
+tuples and number of pages stored in all classes. Running
+.BR vacuum
+periodically will increase Postgres's speed in processing user queries.
+.PP
+The open database is the one that is vacuumed.
+.PP
+We recommend that production databases be vacuumed nightly, in order
+to keep statistics relatively current. The
+.BR vacuum
+query may be executed at any time, however. In particular, after
+copying a large class into Postgres or deleting a large number of
+records, it may be a good idea to issue a
+.BR vacuum
+query. This will update the system catalogs with the results of all
+recent changes, and allow the Postgres query optimizer to make better
+choices in planning user queries.
+.SH "SEE ALSO"
+vacuum(1).
diff --git a/doc/userguide.ps b/doc/userguide.ps
new file mode 100644
index 00000000000..d7100d55a91
--- /dev/null
+++ b/doc/userguide.ps
@@ -0,0 +1,7346 @@
+%!PS-Adobe-3.0
+%%Creator: groff version 1.09
+%%CreationDate: Sat Feb 24 21:37:20 1996
+%%DocumentNeededResources: font Times-Bold
+%%+ font Times-Italic
+%%+ font Times-Roman
+%%+ font Courier
+%%+ font Symbol
+%%DocumentSuppliedResources: file manual-er.eps
+%%+ file manual-files.eps
+%%+ file manual-arch.eps
+%%+ procset grops 1.09 0
+%%Pages: 84
+%%PageOrder: Ascend
+%%Orientation: Portrait
+%%EndComments
+%%BeginProlog
+%%BeginResource: procset grops 1.09 0
+/setpacking where{
+pop
+currentpacking
+true setpacking
+}if
+/grops 120 dict dup begin
+/SC 32 def
+/A/show load def
+/B{0 SC 3 -1 roll widthshow}bind def
+/C{0 exch ashow}bind def
+/D{0 exch 0 SC 5 2 roll awidthshow}bind def
+/E{0 rmoveto show}bind def
+/F{0 rmoveto 0 SC 3 -1 roll widthshow}bind def
+/G{0 rmoveto 0 exch ashow}bind def
+/H{0 rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
+/I{0 exch rmoveto show}bind def
+/J{0 exch rmoveto 0 SC 3 -1 roll widthshow}bind def
+/K{0 exch rmoveto 0 exch ashow}bind def
+/L{0 exch rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
+/M{rmoveto show}bind def
+/N{rmoveto 0 SC 3 -1 roll widthshow}bind def
+/O{rmoveto 0 exch ashow}bind def
+/P{rmoveto 0 exch 0 SC 5 2 roll awidthshow}bind def
+/Q{moveto show}bind def
+/R{moveto 0 SC 3 -1 roll widthshow}bind def
+/S{moveto 0 exch ashow}bind def
+/T{moveto 0 exch 0 SC 5 2 roll awidthshow}bind def
+/SF{
+findfont exch
+[exch dup 0 exch 0 exch neg 0 0]makefont
+dup setfont
+[exch/setfont cvx]cvx bind def
+}bind def
+/MF{
+findfont
+[5 2 roll
+0 3 1 roll
+neg 0 0]makefont
+dup setfont
+[exch/setfont cvx]cvx bind def
+}bind def
+/level0 0 def
+/RES 0 def
+/PL 0 def
+/LS 0 def
+/PLG{
+gsave newpath clippath pathbbox grestore
+exch pop add exch pop
+}bind def
+/BP{
+/level0 save def
+1 setlinecap
+1 setlinejoin
+72 RES div dup scale
+LS{
+90 rotate
+}{
+0 PL translate
+}ifelse
+1 -1 scale
+}bind def
+/EP{
+level0 restore
+showpage
+}bind def
+/DA{
+newpath arcn stroke
+}bind def
+/SN{
+transform
+.25 sub exch .25 sub exch
+round .25 add exch round .25 add exch
+itransform
+}bind def
+/DL{
+SN
+moveto
+SN
+lineto stroke
+}bind def
+/DC{
+newpath 0 360 arc closepath
+}bind def
+/TM matrix def
+/DE{
+TM currentmatrix pop
+translate scale newpath 0 0 .5 0 360 arc closepath
+TM setmatrix
+}bind def
+/RC/rcurveto load def
+/RL/rlineto load def
+/ST/stroke load def
+/MT/moveto load def
+/CL/closepath load def
+/FL{
+currentgray exch setgray fill setgray
+}bind def
+/BL/fill load def
+/LW/setlinewidth load def
+/RE{
+findfont
+dup maxlength 1 index/FontName known not{1 add}if dict begin
+{
+1 index/FID ne{def}{ pop pop}ifelse
+}forall
+/Encoding exch def
+dup/FontName exch def
+currentdict end definefont pop
+}bind def
+/DEFS 0 def
+/EBEGIN{
+moveto
+DEFS begin
+}bind def
+/EEND/end load def
+/CNT 0 def
+/level1 0 def
+/PBEGIN{
+/level1 save def
+translate
+div 3 1 roll div exch scale
+neg exch neg exch translate
+0 setgray
+0 setlinecap
+1 setlinewidth
+0 setlinejoin
+10 setmiterlimit
+[] 0 setdash
+/setstrokeadjust where{
+pop
+false setstrokeadjust
+}if
+/setoverprint where{
+pop
+false setoverprint
+}if
+newpath
+/CNT countdictstack def
+userdict begin
+/showpage{} def
+}bind def
+/PEND{
+clear
+countdictstack CNT sub{end}repeat
+level1 restore
+}bind def
+end def
+/setpacking where{
+pop
+setpacking
+}if
+%%EndResource
+%%IncludeResource: font Times-Bold
+%%IncludeResource: font Times-Italic
+%%IncludeResource: font Times-Roman
+%%IncludeResource: font Courier
+%%IncludeResource: font Symbol
+grops begin/DEFS 1 dict def DEFS begin/u{.001 mul}bind def end/RES 72
+def/PL 792 def/LS false def/ENC0[/asciicircum/asciitilde/Scaron/Zcaron
+/scaron/zcaron/Ydieresis/trademark/quotesingle/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
+/.notdef/.notdef/space/exclam/quotedbl/numbersign/dollar/percent
+/ampersand/quoteright/parenleft/parenright/asterisk/plus/comma/hyphen
+/period/slash/zero/one/two/three/four/five/six/seven/eight/nine/colon
+/semicolon/less/equal/greater/question/at/A/B/C/D/E/F/G/H/I/J/K/L/M/N/O
+/P/Q/R/S/T/U/V/W/X/Y/Z/bracketleft/backslash/bracketright/circumflex
+/underscore/quoteleft/a/b/c/d/e/f/g/h/i/j/k/l/m/n/o/p/q/r/s/t/u/v/w/x/y
+/z/braceleft/bar/braceright/tilde/.notdef/quotesinglbase/guillemotleft
+/guillemotright/bullet/florin/fraction/perthousand/dagger/daggerdbl
+/endash/emdash/ff/fi/fl/ffi/ffl/dotlessi/dotlessj/grave/hungarumlaut
+/dotaccent/breve/caron/ring/ogonek/quotedblleft/quotedblright/oe/lslash
+/quotedblbase/OE/Lslash/.notdef/exclamdown/cent/sterling/currency/yen
+/brokenbar/section/dieresis/copyright/ordfeminine/guilsinglleft
+/logicalnot/minus/registered/macron/degree/plusminus/twosuperior
+/threesuperior/acute/mu/paragraph/periodcentered/cedilla/onesuperior
+/ordmasculine/guilsinglright/onequarter/onehalf/threequarters
+/questiondown/Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE
+/Ccedilla/Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex
+/Idieresis/Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis
+/multiply/Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn
+/germandbls/agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
+/egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
+/eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide/oslash
+/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis]def
+/Courier@0 ENC0/Courier RE/Times-Roman@0 ENC0/Times-Roman RE
+/Times-Italic@0 ENC0/Times-Italic RE/Times-Bold@0 ENC0/Times-Bold RE
+%%EndProlog
+%%Page: 1 1
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 20/Times-Bold@0 SF(The)167.817 255.4 Q/F1 19/Times-Bold@0 SF
+(POSTGRES)5 E F0(95 User Manual)A/F2 11/Times-Bold@0 SF -1.1(Ve)231.7
+268.6 S(rsion 1.0 \(September 5, 1995\))1.1 E/F3 11/Times-Italic@0 SF
+(Andr)247.958 308.2 Q .33 -.165(ew Y)-.407 H 2.75(ua)-.847 G(nd J)-2.75
+E(olly Chen)-.275 E(\(with the)243.736 321.4 Q/F4 10/Times-Italic@0 SF
+(POSTGRES)2.75 E F3(Gr)2.75 E(oup\))-.495 E(Computer Science Div)220.557
+334.6 Q(., Dept. of EECS)-.814 E(Univer)227.141 347.8 Q
+(sity of California at Berk)-.11 E(ele)-.11 E(y)-.33 E .32 LW 76 493.2
+72 493.2 DL 80 493.2 76 493.2 DL 84 493.2 80 493.2 DL 88 493.2 84 493.2
+DL 92 493.2 88 493.2 DL 96 493.2 92 493.2 DL 100 493.2 96 493.2 DL 104
+493.2 100 493.2 DL 108 493.2 104 493.2 DL 112 493.2 108 493.2 DL 116
+493.2 112 493.2 DL 120 493.2 116 493.2 DL 124 493.2 120 493.2 DL 128
+493.2 124 493.2 DL 132 493.2 128 493.2 DL 136 493.2 132 493.2 DL 140
+493.2 136 493.2 DL 144 493.2 140 493.2 DL 148 493.2 144 493.2 DL 152
+493.2 148 493.2 DL 156 493.2 152 493.2 DL 160 493.2 156 493.2 DL 164
+493.2 160 493.2 DL 168 493.2 164 493.2 DL 172 493.2 168 493.2 DL 176
+493.2 172 493.2 DL 180 493.2 176 493.2 DL 184 493.2 180 493.2 DL 188
+493.2 184 493.2 DL 192 493.2 188 493.2 DL 196 493.2 192 493.2 DL 200
+493.2 196 493.2 DL 204 493.2 200 493.2 DL 208 493.2 204 493.2 DL 212
+493.2 208 493.2 DL 216 493.2 212 493.2 DL/F5 7/Times-Roman@0 SF
+(POSTGRES)93.6 505.2 Q/F6 8/Times-Roman@0 SF .461(95 is cop)B .461
+(yright \251 1994-5 by the Re)-.08 F .461(gents of the Uni)-.12 F -.12
+(ve)-.2 G .461(rsity of California.).12 F .46(Permission to use, cop)
+4.461 F 1.5 -.52(y, m)-.08 H(odify).52 E 2.46(,a)-.52 G .46(nd dis-)
+-2.46 F(trib)72 514.8 Q .333(ute this softw)-.16 F .333
+(are and its documentation for an)-.08 F 2.333(yp)-.12 G .333(urpose, w\
+ithout fee, and without a written agreement is hereby granted, pro)
+-2.333 F(vided)-.12 E(that the abo)72 524.4 Q .24 -.12(ve c)-.12 H(op)
+.12 E(yright notice and this paragraph and the follo)-.08 E(wing tw)-.2
+E 2(op)-.08 G(aragraphs appear in all copies.)-2 E/F7 11/Times-Roman@0
+SF .886(IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE T)133
+541.5 R(O)-.198 E 3.598(ANY P)108 554.7 R(AR)-1.012 E 3.598
+(TY FOR DIRECT)-.66 F 6.348(,I)-.814 G(NDIRECT)-6.348 E 6.348(,S)-.814 G
+3.599(PECIAL, INCIDENT)-6.348 F 3.599(AL, OR CONSE-)-1.023 F -.11(QU)108
+567.9 S .13(ENTIAL D).11 F(AMA)-.44 E .13(GES, INCLUDING LOST PR)-.44 F
+.129(OFITS, ARISING OUT OF THE USE)-.44 F 1.216(OF THIS SOFTW)108 581.1
+R 1.216(ARE AND ITS DOCUMENT)-1.32 F -1.221(AT)-1.023 G 1.216
+(ION, EVEN IF THE UNIVERSITY)1.221 F 1.557(OF CALIFORNIA HAS BEEN AD)108
+594.3 R 1.556(VISED OF THE POSSIBILITY OF SUCH D)-.44 F(AM-)-.44 E -.44
+(AG)108 607.5 S(E.).44 E 4.677(THE UNIVERSITY OF CALIFORNIA SPECIFICALL)
+133 624.6 R 7.428(YD)-1.1 G 4.678(ISCLAIMS ANY)-7.428 F -1.32(WA)108
+637.8 S 4.519(RRANTIES, INCLUDING, B)1.32 F 4.518(UT NO)-.11 F 7.268(TL)
+-.44 G 4.518(IMITED T)-7.268 F 4.518(O, THE IMPLIED W)-.198 F(AR-)-1.32
+E 2.476(RANTIES OF MERCHANT)108 651 R 2.476(ABILITY AND FITNESS FOR A P)
+-1.023 F(AR)-1.012 E 2.477(TICULAR PUR-)-.66 F 2.847(POSE. THE)108 664.2
+R(SOFTW)2.847 E .097(ARE PR)-1.32 F -.55(OV)-.44 G .097
+(IDED HEREUNDER IS ON AN "AS IS" B).55 F .097(ASIS, AND)-.385 F 4.279
+(THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGA)108 677.4 R 4.279(TIONS T)
+-1.221 F 7.029(OP)-.198 G -.44(RO)-7.029 G(VIDE)-.11 E(MAINTEN)108 690.6
+Q .586(ANCE, SUPPOR)-.385 F 2.213 -.814(T, U)-.66 H(PD).814 E -1.221(AT)
+-.44 G .585(ES, ENHANCEMENTS, OR MODIFICA)1.221 F(TIONS.)-1.221 E F2(1)
+285.25 756 Q EP
+%%Page: 2 2
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(1. INTR)72 165.4 R(ODUCTION)-.57 E
+77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL
+91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL
+108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6
+DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130
+178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6
+146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5
+178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185
+178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL
+201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6
+DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5
+178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6
+240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6
+256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5
+178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295
+178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL
+311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6
+DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5
+178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6
+350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6
+366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5
+178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405
+178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL
+421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6
+DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5
+178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6
+460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6
+476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5
+178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF 1.763
+(This document is the user manual for the)108 208.9 R/F2 10
+/Times-Roman@0 SF(POSTGRES)4.514 E F1 1.764
+(95 database management system)B(de)108 222.1 Q -.165(ve)-.275 G 1.139
+(loped at the Uni).165 F -.165(ve)-.275 G 1.138
+(rsity of California at Berk).165 F(ele)-.11 E -.715(y.)-.165 G F2
+(POSTGRES)7.353 E F1 1.138(95 is based on)B F2(POST)3.888 E(-)-.92 E
+(GRES)108 235.3 Q F1 1.881(release 4.2. The)4.631 F F2(POSTGRES)4.631 E
+F1 1.881(project, led by Professor Michael Stonebrak)4.631 F(er)-.11 E
+4.631(,h)-.44 G(as)-4.631 E .07(been sponsored by the Defense Adv)108
+248.5 R .07(anced Research Projects Agenc)-.275 F 2.82(y\()-.165 G -.44
+(DA)-2.82 G(RP).44 E .07(A\), the Army)-1.012 F(Research Of)108 261.7 Q
+(\214ce \(AR)-.275 E(O\), the National Science F)-.44 E
+(oundation \(NSF\), and ESL, Inc.)-.165 E/F3 12/Times-Bold@0 SF 3
+(1.1. What)72 287.9 R(is)3 E/F4 11/Times-Bold@0 SF(POSTGRES)3 E F3(?)A
+F1 -.385(Tr)108 305 S .35(aditional relational database management syst\
+ems \(DBMSs\) support a data model con-).385 F .45
+(sisting of a collection of named relations, containing attrib)108 318.2
+R .45(utes of a speci\214c type.)-.22 F .45(In cur)5.95 F(-)-.22 E .357
+(rent commercial systems, possible types include \215oating point numbe\
+rs, inte)108 331.4 R .358(gers, charac-)-.165 F .066(ter strings, mone)
+108 344.6 R 1.496 -.715(y, a)-.165 H .066(nd dates.).715 F .066
+(It is commonly recognized that this model is inadequate for)5.566 F
+(future data processing applications.)108 357.8 Q .659
+(The relational model successfully replaced pre)108 374.9 R .659
+(vious models in part because of its \231Spar)-.275 F(-)-.22 E .74
+(tan simplicity\232.)108 388.1 R(Ho)6.24 E(we)-.275 E -.165(ve)-.275 G
+1.619 -.44(r, a).165 H 3.489(sm).44 G .739
+(entioned, this simplicity often mak)-3.489 F .739
+(es the implementation)-.11 F 1.613(of certain applications v)108 401.3
+R 1.613(ery dif)-.165 F 1.613(\214cult to implement.)-.275 F F2
+(POSTGRES)7.113 E F1(of)4.364 E 1.614(fers substantial addi-)-.275 F
+.032(tional po)108 414.5 R .032(wer by incorporating the follo)-.275 F
+.031(wing four additional basic constructs in such a w)-.275 F(ay)-.11 E
+(that users can easily e)108 427.7 Q(xtend the system:)-.165 E(classes)
+148 453.9 Q(inheritance)148 467.1 Q(types)148 480.3 Q(functions)148
+493.5 Q(In addition,)108 519.7 Q F2(POSTGRES)2.75 E F1(supports a po)
+2.75 E(werful production rule system.)-.275 E F3 3(1.2. A)72 545.9 R
+(Short History of the)3 E F4(POSTGRES)3 E F3(Pr)3 E(oject)-.216 E F1
+1.658(Implementation of the)108 563 R F2(POSTGRES)4.409 E F1 1.659
+(DBMS be)4.409 F -.055(ga)-.165 G 4.409(ni).055 G 4.409(n1)-4.409 G
+4.409(986. The)-4.409 F 1.659(initial concepts for the)4.409 F .42
+(system were presented in [ST)108 576.2 R .42
+(ON86] and the de\214nition of the initial data model appeared)-.198 F
+.805(in [R)108 589.4 R -.385(OW)-.44 G 3.555(E87]. The).385 F .805
+(design of the rule system at that time w)3.555 F .806
+(as described in [ST)-.11 F(ON87a].)-.198 E(The rationale and architect\
+ure of the storage manager were detailed in [ST)108 602.6 Q(ON87b].)
+-.198 E F2(POSTGRES)108 619.7 Q F1 .861(has under)3.611 F .861(gone se)
+-.198 F -.165(ve)-.275 G .861(ral major releases since then.).165 F .86
+(The \214rst \231demo)6.36 F -.11(wa)-.275 G .86(re\232 sys-).11 F .253
+(tem became operational in 1987 and w)108 632.9 R .253(as sho)-.11 F
+.253(wn at the 1988 A)-.275 F .253(CM-SIGMOD Conference.)-.44 F 2.052
+-.88(We r)108 646.1 T .292(eleased V).88 F .291
+(ersion 1, described in [ST)-1.221 F .291(ON90a], to a fe)-.198 F 3.041
+(we)-.275 G .291(xternal users in June 1989.)-3.206 F(In)5.791 E .659
+(response to a critique of the \214rst rule system [ST)108 659.3 R .659
+(ON89], the rule system w)-.198 F .66(as redesigned)-.11 F([ST)108 672.5
+Q .023(ON90b] and V)-.198 F .023(ersion 2 w)-1.221 F .023
+(as released in June 1990 with the ne)-.11 F 2.772(wr)-.275 G .022
+(ule system.)-2.772 F -1.221(Ve)5.522 G .022(rsion 3)1.221 F 1.18(appea\
+red in 1991 and added support for multiple storage managers, an impro)
+108 685.7 R -.165(ve)-.165 G 3.93(dq).165 G(uery)-3.93 E -.165(exe)108
+698.9 S(cutor).165 E 3.24(,a)-.44 G .49(nd a re)-3.24 F .49(written re)
+-.275 F .49(write rule system.)-.275 F -.165(Fo)5.99 G 3.239(rt).165 G
+.489(he most part, releases since then ha)-3.239 F -.165(ve)-.22 G
+(focused on portability and reliability)108 712.1 Q(.)-.715 E F4(2)
+285.25 756 Q EP
+%%Page: 3 3
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Times-Roman@0 SF(POSTGRES)108 97.2 Q/F1 11/Times-Roman@0 SF .639
+(has been used to implement man)3.389 F 3.39(yd)-.165 G(if)-3.39 E .64
+(ferent research and production applica-)-.275 F 3.207(tions. These)108
+110.4 R .456(include: a \214nancial data analysis system, a jet engine \
+performance monitor)3.207 F(-)-.22 E 1.105(ing package, an asteroid tra\
+cking database, a medical information database, and se)108 123.6 R -.165
+(ve)-.275 G(ral).165 E .268(geographic information systems.)108 136.8 R
+F0(POSTGRES)5.768 E F1 .267
+(has also been used as an educational tool at)3.018 F(se)108 150 Q -.165
+(ve)-.275 G 1.628(ral uni).165 F -.165(ve)-.275 G 4.378
+(rsities. Finally).165 F 4.378(,I)-.715 G 1.628(llustra Information T)
+-4.378 F 1.628(echnologies pick)-.77 F 1.628(ed up the code and)-.11 F
+(commercialized it.)108 163.2 Q F0(POSTGRES)108 180.3 Q F1 .654(became \
+the primary data manager for the Sequoia 2000 scienti\214c computing)
+3.404 F .017(project in late 1992.)108 193.5 R .018
+(Furthermore, the size of the e)5.518 F .018
+(xternal user community nearly doubled)-.165 F .376(during 1993.)108
+206.7 R .376(It became increasingly ob)5.876 F .376
+(vious that maintenance of the prototype code and)-.165 F .961
+(support w)108 219.9 R .961(as taking up lar)-.11 F .962
+(ge amounts of time that should ha)-.198 F 1.292 -.165(ve b)-.22 H .962
+(een de).165 F -.22(vo)-.275 G .962(ted to database).22 F 3.025
+(research. In)108 233.1 R .275(an ef)3.025 F .274
+(fort to reduce this support b)-.275 F .274(urden, the project of)-.22 F
+.274(\214cially ended with V)-.275 F(er)-1.221 E(-)-.22 E(sion 4.2.)108
+246.3 Q/F2 12/Times-Bold@0 SF 3(1.3. What)72 272.5 R(is)3 E/F3 11
+/Times-Bold@0 SF(POSTGRES)3 E F2(95?)A F0(POSTGRES)108 289.6 Q F1 .953
+(95 is a deri)B -.275(va)-.275 G(ti).275 E 1.283 -.165(ve o)-.275 H
+3.703(ft).165 G .953(he last of)-3.703 F .953(\214cial release of)-.275
+F F0(POSTGRES)3.703 E F1(\(v)3.703 E .953(ersion 4.2\). The)-.165 F .165
+(code is no)108 302.8 R 2.915(wc)-.275 G .165(ompletely ANSI C and the \
+code size has been trimmed by 25%. There are a)-2.915 F .395
+(lot of internal changes that impro)108 316 R .726 -.165(ve p)-.165 H
+.396(erformance and code maintainability).165 F(.)-.715 E F0(POSTGRES)
+3.146 E F1(95)A 1.58(runs about 30-50% f)108 329.2 R 1.58
+(aster on the W)-.11 F 1.579
+(isconsin Benchmark compared to v4.2. Apart from)-.44 F -.22(bu)108
+342.4 S 2.75<678c>.22 G -.165(xe)-2.75 G
+(s, these are the major enhancements:).165 E 5.5<8354>113.5 359.5 S
+1.527(he query language POSTQ)-5.5 F 1.527
+(UEL has been replaced with SQL \(implemented in the)-.11 F(serv)122.85
+372.7 Q .73(er\). W)-.165 F 3.48(ed)-.88 G 3.48(on)-3.48 G .729
+(ot support subqueries \(which can be imitated with user de\214ned SQL)
+-3.48 F .487(functions\) at the moment. Aggre)122.85 385.9 R -.055(ga)
+-.165 G .487(tes ha).055 F .817 -.165(ve b)-.22 H .487
+(een re-implemented. W).165 F 3.237(ea)-.88 G .487(lso added sup-)-3.237
+F(port for GR)122.85 399.1 Q(OUP BY)-.44 E 2.75(.T)-1.419 G
+(he libpq interf)-2.75 E(ace is still a)-.11 E -.275(va)-.22 G
+(ilable for C programs.).275 E 5.5<8349>113.5 412.3 S 3.291(na)-5.5 G
+.541(ddition to the monitor program, we pro)-3.291 F .541(vide a ne)
+-.165 F 3.29(wp)-.275 G .54(rogram \(psql\) which supports)-3.29 F
+(GNU readline.)122.85 425.5 Q 5.5<8357>113.5 438.7 S 3.201(ea)-6.38 G
+.452(dded a ne)-3.201 F 3.202(wf)-.275 G .452(ront-end library)-3.202 F
+3.202(,l)-.715 G .452(ibpgtcl, that supports Tcl-based clients.)-3.202 F
+3.202(As)5.952 G(ample)-3.202 E 1.056(shell, pgtclsh, pro)122.85 451.9 R
+1.056(vides ne)-.165 F 3.805(wT)-.275 G 1.055(cl commands to interf)
+-3.805 F 1.055(ace tcl programs with the)-.11 F F0(POST)3.805 E(-)-.92 E
+(GRES)122.85 465.1 Q F1(95 back)A(end.)-.11 E 5.5<8354>113.5 478.3 S
+.369(he lar)-5.5 F .369(ge object interf)-.198 F .37(ace has been o)-.11
+F -.165(ve)-.165 G .37(rhauled. W).165 F 3.12(ek)-.88 G .37(ept In)-3.23
+F -.165(ve)-.44 G .37(rsion lar).165 F .37(ge objects as the)-.198 F
+.828(only mechanism for storing lar)122.85 491.5 R .827
+(ge objects. \(This is not to be confused with the In)-.198 F -.165(ve)
+-.44 G -.22(r-).165 G(sion \214le system which has been remo)122.85
+504.7 Q -.165(ve)-.165 G(d.\)).165 E 5.5<8354>113.5 517.9 S 1.011
+(he instance-le)-5.5 F -.165(ve)-.275 G 3.761(lr).165 G 1.011
+(ule system has been remo)-3.761 F -.165(ve)-.165 G 1.011
+(d. Rules are still a).165 F -.275(va)-.22 G 1.011(ilable as re).275 F
+(write)-.275 E(rules.)122.85 531.1 Q 5.5<8341>113.5 544.3 S .062
+(short tutorial introducing re)-2.688 F .061
+(gular SQL features as well as those of ours is distrib)-.165 F(uted)
+-.22 E(with the source code.)122.85 557.5 Q 5.5<8347>113.5 570.7 S .945
+(NU mak)-5.5 F 3.695(e\()-.11 G .945(instead of BSD mak)-3.695 F .946
+(e\) is used for the b)-.11 F .946(uild. Also,)-.22 F F0(POSTGRES)3.696
+E F1 .946(95 can be)B(compiled with an unpatched gcc \(data alignment o\
+f doubles has been \214x)122.85 583.9 Q(ed\).)-.165 E F2 3(1.4. About)72
+610.1 R(This Release)3 E F0(POSTGRES)108 627.2 Q F1 1.871(95 is a)B
+-.275(va)-.22 G 1.871(ilable free of char).275 F 1.871
+(ge. This manual describes v)-.198 F 1.87(ersion 1.0 of)-.165 F F0(POST)
+4.62 E(-)-.92 E(GRES)108 640.4 Q F1 4.86(95. The)B 2.11(authors ha)4.86
+F 2.44 -.165(ve c)-.22 H 2.11(ompiled and tested).165 F F0(POSTGRES)4.86
+E F1 2.11(95 on the follo)B 2.11(wing plat-)-.275 F(forms:)108 653.6 Q
+F3(3)285.25 756 Q EP
+%%Page: 4 4
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 481.389 88.75 130.61 88.75 DL/F0 11/Times-Roman@0 SF 42.488
+(architecture processor)160.106 99.2 R(operating system)61.429 E 481.389
+103.95 130.61 103.95 DL 481.389 105.95 130.61 105.95 DL(DECstation 3000)
+136.11 116.4 Q(Alpha AXP)40.326 E(OSF/1 2.1, 3.0, 3.2)16.5 E
+(DECstation 5000)136.11 129.6 Q 39.71(MIPS UL)40.326 F(TRIX 4.4)-1.012 E
+91.047(Sun4 SP)136.11 142.8 R 31.548(ARC SunOS)-1.012 F
+(4.1.3, 4.1.3_U1; Solaris 2.4)2.75 E(H-P 9000/700 and 800)136.11 156 Q
+-1.012(PA)16.5 G 24.222(-RISC HP-UX)1.012 F(9.00, 9.01, 9.03)2.75 E 93.5
+(Intel X86)136.11 169.2 R(Linux 1.2.8, ELF)49.192 E 481.389 173.95
+130.61 173.95 DL 312.407 88.75 312.407 173.95 DL 244.273 88.75 244.273
+173.95 DL 481.389 88.75 481.389 173.95 DL 130.61 88.75 130.61 173.95 DL
+/F1 12/Times-Bold@0 SF 3(1.5. Outline)72 208.4 R(of This Manual)3 E F0
+.296(From no)108 225.5 R 3.046(wo)-.275 G .296(n, W)-3.046 F 3.046(ew)
+-.88 G .296(ill use)-3.046 F/F2 10/Times-Roman@0 SF(POSTGRES)3.046 E F0
+.296(to mean)3.046 F F2(POSTGRES)3.046 E F0 3.046(95. The)B .295
+(\214rst part of this man-)3.046 F .108(ual goes o)108 238.7 R -.165(ve)
+-.165 G 2.859(rs).165 G .109
+(ome basic system concepts and procedures for starting the)-2.859 F F2
+(POSTGRES)2.859 E F0(sys-)2.859 E 3.817(tem. W)108 251.9 R 3.817(et)-.88
+G 1.067(hen turn to a tutorial o)-3.817 F -.165(ve)-.165 G(rvie).165 E
+3.817(wo)-.275 G 3.817(ft)-3.817 G(he)-3.817 E F2(POSTGRES)3.817 E F0
+1.066(data model and SQL query)3.817 F 1.26(language, introducing a fe)
+108 265.1 R 4.01(wo)-.275 G 4.01(fi)-4.01 G 1.26(ts adv)-4.01 F 1.26
+(anced features.)-.275 F(Ne)6.76 E 1.26(xt, we e)-.165 F 1.26
+(xplain the)-.165 F F2(POSTGRES)4.011 E F0 .745(approach to e)108 278.3
+R .745(xtensibility and describe ho)-.165 F 3.495(wu)-.275 G .745
+(sers can e)-3.495 F(xtend)-.165 E F2(POSTGRES)3.495 E F0 .745
+(by adding user)3.495 F(-)-.22 E .122(de\214ned types, operators, aggre)
+108 291.5 R -.055(ga)-.165 G .122
+(tes, and both query language and programming language).055 F 3.516
+(functions. After)108 304.7 R .766(an e)3.516 F .766(xtremely brief o)
+-.165 F -.165(ve)-.165 G(rvie).165 E 3.516(wo)-.275 G 3.516(ft)-3.516 G
+(he)-3.516 E F2(POSTGRES)3.516 E F0 .766(rule system, the manual)3.516 F
+.468
+(concludes with a detailed appendix that discusses some of the more in)
+108 317.9 R -.22(vo)-.44 G(lv).22 E .468(ed and operat-)-.165 F
+(ing system-speci\214c procedures in)108 331.1 Q -.22(vo)-.44 G(lv).22 E
+(ed in e)-.165 E(xtending the system.)-.165 E 1.76 -.88(We a)108 357.5 T
+(ssume pro\214cienc).88 E 2.75(yw)-.165 G(ith UNIX and C programming.)
+-2.75 E .32 LW 76 659.4 72 659.4 DL 80 659.4 76 659.4 DL 84 659.4 80
+659.4 DL 88 659.4 84 659.4 DL 92 659.4 88 659.4 DL 96 659.4 92 659.4 DL
+100 659.4 96 659.4 DL 104 659.4 100 659.4 DL 108 659.4 104 659.4 DL 112
+659.4 108 659.4 DL 116 659.4 112 659.4 DL 120 659.4 116 659.4 DL 124
+659.4 120 659.4 DL 128 659.4 124 659.4 DL 132 659.4 128 659.4 DL 136
+659.4 132 659.4 DL 140 659.4 136 659.4 DL 144 659.4 140 659.4 DL 148
+659.4 144 659.4 DL 152 659.4 148 659.4 DL 156 659.4 152 659.4 DL 160
+659.4 156 659.4 DL 164 659.4 160 659.4 DL 168 659.4 164 659.4 DL 172
+659.4 168 659.4 DL 176 659.4 172 659.4 DL 180 659.4 176 659.4 DL 184
+659.4 180 659.4 DL 188 659.4 184 659.4 DL 192 659.4 188 659.4 DL 196
+659.4 192 659.4 DL 200 659.4 196 659.4 DL 204 659.4 200 659.4 DL 208
+659.4 204 659.4 DL 212 659.4 208 659.4 DL 216 659.4 212 659.4 DL/F3 7
+/Times-Roman@0 SF(UNIX)93.6 671.4 Q/F4 8/Times-Roman@0 SF .042
+(is a trademark of X/Open, Ltd.)2.042 F .042(Sun4, SP)4.042 F .041
+(ARC, SunOS and Solaris are trademarks of Sun Microsystems, Inc.)-.736 F
+.041(DEC, DEC-)4.041 F 1.409(station, Alpha AXP and UL)72 681 R 1.409
+(TRIX are trademarks of Digital Equipment Corp.)-.736 F -.736(PA)5.41 G
+1.41(-RISC and HP-UX are trademarks of He).736 F(wlett-)-.2 E -.12(Pa)72
+690.6 S(ckard Co.).12 E(OSF/1 is a trademark of the Open Softw)4 E
+(are F)-.08 E(oundation.)-.12 E/F5 11/Times-Bold@0 SF(4)285.25 756 Q EP
+%%Page: 5 5
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(2. POSTGRES)72 165.4 R
+(ARCHITECTURE CONCEPTS)4.75 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6
+DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL
+102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6
+DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6 124.5
+178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6
+141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6
+157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5
+178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196
+178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL
+212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6
+DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5
+178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6
+251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6
+267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5
+178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306
+178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL
+322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6
+DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5
+178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6
+361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6
+377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5
+178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416
+178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL
+432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6
+DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5
+178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6
+471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6
+487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11
+/Times-Roman@0 SF 1.972
+(Before we continue, you should understand the basic)108 208.9 R/F2 10
+/Times-Roman@0 SF(POSTGRES)4.722 E F1 1.971(system architecture.)4.722 F
+.235(Understanding ho)108 222.1 R 2.985(wt)-.275 G .235(he parts of)
+-2.985 F F2(POSTGRES)2.985 E F1 .235(interact will mak)2.985 F 2.985(et)
+-.11 G .236(he ne)-2.985 F .236(xt chapter some)-.165 F(what)-.275 E
+77.5 247.3 72 247.3 DL 80.5 247.3 75 247.3 DL 86 247.3 80.5 247.3 DL
+91.5 247.3 86 247.3 DL 97 247.3 91.5 247.3 DL 102.5 247.3 97 247.3 DL
+108 247.3 102.5 247.3 DL 113.5 247.3 108 247.3 DL 119 247.3 113.5 247.3
+DL 124.5 247.3 119 247.3 DL 130 247.3 124.5 247.3 DL 135.5 247.3 130
+247.3 DL 141 247.3 135.5 247.3 DL 146.5 247.3 141 247.3 DL 152 247.3
+146.5 247.3 DL 157.5 247.3 152 247.3 DL 163 247.3 157.5 247.3 DL 168.5
+247.3 163 247.3 DL 174 247.3 168.5 247.3 DL 179.5 247.3 174 247.3 DL 185
+247.3 179.5 247.3 DL 190.5 247.3 185 247.3 DL 196 247.3 190.5 247.3 DL
+201.5 247.3 196 247.3 DL 207 247.3 201.5 247.3 DL 212.5 247.3 207 247.3
+DL 218 247.3 212.5 247.3 DL 223.5 247.3 218 247.3 DL 229 247.3 223.5
+247.3 DL 234.5 247.3 229 247.3 DL 240 247.3 234.5 247.3 DL 245.5 247.3
+240 247.3 DL 251 247.3 245.5 247.3 DL 256.5 247.3 251 247.3 DL 262 247.3
+256.5 247.3 DL 267.5 247.3 262 247.3 DL 273 247.3 267.5 247.3 DL 278.5
+247.3 273 247.3 DL 284 247.3 278.5 247.3 DL 289.5 247.3 284 247.3 DL 295
+247.3 289.5 247.3 DL 300.5 247.3 295 247.3 DL 306 247.3 300.5 247.3 DL
+311.5 247.3 306 247.3 DL 317 247.3 311.5 247.3 DL 322.5 247.3 317 247.3
+DL 328 247.3 322.5 247.3 DL 333.5 247.3 328 247.3 DL 339 247.3 333.5
+247.3 DL 344.5 247.3 339 247.3 DL 350 247.3 344.5 247.3 DL 355.5 247.3
+350 247.3 DL 361 247.3 355.5 247.3 DL 366.5 247.3 361 247.3 DL 372 247.3
+366.5 247.3 DL 377.5 247.3 372 247.3 DL 383 247.3 377.5 247.3 DL 388.5
+247.3 383 247.3 DL 394 247.3 388.5 247.3 DL 399.5 247.3 394 247.3 DL 405
+247.3 399.5 247.3 DL 410.5 247.3 405 247.3 DL 416 247.3 410.5 247.3 DL
+421.5 247.3 416 247.3 DL 427 247.3 421.5 247.3 DL 432.5 247.3 427 247.3
+DL 438 247.3 432.5 247.3 DL 443.5 247.3 438 247.3 DL 449 247.3 443.5
+247.3 DL 454.5 247.3 449 247.3 DL 460 247.3 454.5 247.3 DL 465.5 247.3
+460 247.3 DL 471 247.3 465.5 247.3 DL 476.5 247.3 471 247.3 DL 482 247.3
+476.5 247.3 DL 487.5 247.3 482 247.3 DL 493 247.3 487.5 247.3 DL 498.5
+247.3 493 247.3 DL 504 247.3 498.5 247.3 DL 0 0 288 470 -360 649 144
+633.7 PBEGIN
+%%BeginDocument: manual-arch.eps
+%%Title: stdin
+%%Creator: fig2dev Version 3.1 Patchlevel 0
+%%CreationDate: Sat Feb 24 21:36:25 1996
+%%For: jolly@arcadia.CS.Berkeley.EDU (Jolly Chen,421 Soda,(510) 6421863,540-5955)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 470 649
+%%Pages: 0
+%%BeginSetup
+%%IncludeFeature: *PageSize Letter
+%%EndSetup
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {} def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-17.0 662.0 translate
+1 -1 scale
+
+/clp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+ /DrawEllipse {
+ /endangle exch def
+ /startangle exch def
+ /yrad exch def
+ /xrad exch def
+ /y exch def
+ /x exch def
+ /savematrix mtrx currentmatrix def
+ x y tr xrad yrad sc 0 0 1 startangle endangle arc
+ closepath
+ savematrix setmatrix
+ } def
+
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+
+$F2psBegin
+10 setmiterlimit
+ 0.06000 0.06000 sc
+/Times-Roman findfont 240.00 scalefont setfont
+5550 1350 m
+gs 1 -1 sc (POSTMASTER) col-1 show gr
+7.500 slw
+% Polyline
+n 405 600 m 300 600 300 1320 105 arcto 4 {pop} repeat 300 1425 3270 1425 105 arcto 4 {pop} repeat 3375 1425 3375 705 105 arcto 4 {pop} repeat 3375 600 405 600 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 2325 600 m 2325 1425 l gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+375 1275 m
+gs 1 -1 sc (APPLICATION) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+2475 1125 m
+gs 1 -1 sc (LIBPQ) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+900 975 m
+gs 1 -1 sc (USER) col-1 show gr
+% Polyline
+n 405 3225 m 300 3225 300 3945 105 arcto 4 {pop} repeat 300 4050 3270 4050 105 arcto 4 {pop} repeat 3375 4050 3375 3330 105 arcto 4 {pop} repeat 3375 3225 405 3225 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 2325 3225 m 2325 4050 l gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+375 3900 m
+gs 1 -1 sc (APPLICATION) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+2475 3750 m
+gs 1 -1 sc (LIBPQ) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+900 3600 m
+gs 1 -1 sc (USER) col-1 show gr
+% Polyline
+n 5280 3075 m 5175 3075 5175 3495 105 arcto 4 {pop} repeat 5175 3600 7245 3600 105 arcto 4 {pop} repeat 7350 3600 7350 3180 105 arcto 4 {pop} repeat 7350 3075 5280 3075 105 arcto 4 {pop} repeat clp gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+5325 3450 m
+gs 1 -1 sc (POSTMASTER) col-1 show gr
+% Polyline
+n 5655 3900 m 5550 3900 5550 4320 105 arcto 4 {pop} repeat 5550 4425 6795 4425 105 arcto 4 {pop} repeat 6900 4425 6900 4005 105 arcto 4 {pop} repeat 6900 3900 5655 3900 105 arcto 4 {pop} repeat clp gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+5700 4275 m
+gs 1 -1 sc (SERVER) col-1 show gr
+/Times-Bold findfont 240.00 scalefont setfont
+300 2100 m
+gs 1 -1 sc (\(a\) frontend sends request to) col-1 show gr
+/Times-Bold findfont 240.00 scalefont setfont
+675 2400 m
+gs 1 -1 sc (postmaster via well-known) col-1 show gr
+/Times-Bold findfont 240.00 scalefont setfont
+675 2700 m
+gs 1 -1 sc (network socket) col-1 show gr
+% Polyline
+n 406 8251 m 301 8251 301 8971 105 arcto 4 {pop} repeat 301 9076 3271 9076 105 arcto 4 {pop} repeat 3376 9076 3376 8356 105 arcto 4 {pop} repeat 3376 8251 406 8251 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 2326 8251 m 2326 9076 l gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+376 8926 m
+gs 1 -1 sc (APPLICATION) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+2476 8776 m
+gs 1 -1 sc (LIBPQ) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+901 8626 m
+gs 1 -1 sc (USER) col-1 show gr
+% Polyline
+n 5431 8476 m 5326 8476 5326 8896 105 arcto 4 {pop} repeat 5326 9001 7396 9001 105 arcto 4 {pop} repeat 7501 9001 7501 8581 105 arcto 4 {pop} repeat 7501 8476 5431 8476 105 arcto 4 {pop} repeat clp gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+5476 8851 m
+gs 1 -1 sc (POSTMASTER) col-1 show gr
+% Polyline
+n 405 5625 m 300 5625 300 6345 105 arcto 4 {pop} repeat 300 6450 3270 6450 105 arcto 4 {pop} repeat 3375 6450 3375 5730 105 arcto 4 {pop} repeat 3375 5625 405 5625 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 2325 5625 m 2325 6450 l gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+375 6300 m
+gs 1 -1 sc (APPLICATION) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+2475 6150 m
+gs 1 -1 sc (LIBPQ) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+900 6000 m
+gs 1 -1 sc (USER) col-1 show gr
+% Polyline
+n 5655 6675 m 5550 6675 5550 7095 105 arcto 4 {pop} repeat 5550 7200 6795 7200 105 arcto 4 {pop} repeat 6900 7200 6900 6780 105 arcto 4 {pop} repeat 6900 6675 5655 6675 105 arcto 4 {pop} repeat clp gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+5700 7050 m
+gs 1 -1 sc (SERVER) col-1 show gr
+% Polyline
+n 5430 5850 m 5325 5850 5325 6270 105 arcto 4 {pop} repeat 5325 6375 7395 6375 105 arcto 4 {pop} repeat 7500 6375 7500 5955 105 arcto 4 {pop} repeat 7500 5850 5430 5850 105 arcto 4 {pop} repeat clp gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+5475 6225 m
+gs 1 -1 sc (POSTMASTER) col-1 show gr
+/Times-Bold findfont 240.00 scalefont setfont
+300 7200 m
+gs 1 -1 sc (\(c\) frontend connected) col-1 show gr
+/Times-Bold findfont 240.00 scalefont setfont
+675 7500 m
+gs 1 -1 sc (to backend server) col-1 show gr
+% Polyline
+n 5505 975 m 5400 975 5400 1395 105 arcto 4 {pop} repeat 5400 1500 7470 1500 105 arcto 4 {pop} repeat 7575 1500 7575 1080 105 arcto 4 {pop} repeat 7575 975 5505 975 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Ellipse
+n 4425 1200 105 105 0 360 DrawEllipse gs col-1 s gr
+
+/Times-Roman findfont 240.00 scalefont setfont
+5701 9676 m
+gs 1 -1 sc (SERVER1) col-1 show gr
+% Ellipse
+n 4425 3825 105 105 0 360 DrawEllipse gs col-1 s gr
+
+% Ellipse
+n 6105 3705 1680 1080 0 360 DrawEllipse gs col-1 s gr
+
+% Ellipse
+n 6105 1305 1680 1080 0 360 DrawEllipse gs col-1 s gr
+
+% Ellipse
+n 4471 8716 105 105 0 360 DrawEllipse gs col-1 s gr
+
+% Ellipse
+n 6105 6405 1680 1080 0 360 DrawEllipse gs col-1 s gr
+
+% Ellipse
+n 4470 6090 105 105 0 360 DrawEllipse gs col-1 s gr
+
+% Ellipse
+n 6225 9375 1875 1650 0 360 DrawEllipse gs col-1 s gr
+
+% Polyline
+ [66.7] 0 setdash
+n 4500 1200 m 5400 1200 l gs col-1 s gr [] 0 setdash
+% Polyline
+n 6225 3600 m 6225 3900 l gs col-1 s gr
+n 6262.50 3765.00 m 6225.00 3900.00 l 6187.50 3765.00 l gs col-1 s gr
+% Polyline
+ [66.7] 0 setdash
+n 4576 8701 m 5326 8701 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [66.7] 0 setdash
+n 4575 6075 m 5325 6075 l gs col-1 s gr [] 0 setdash
+% Polyline
+n 3450 9525 m 3000 9075 l gs col-1 s gr
+% Polyline
+n 5656 9301 m 5551 9301 5551 9721 105 arcto 4 {pop} repeat 5551 9826 6796 9826 105 arcto 4 {pop} repeat 6901 9826 6901 9406 105 arcto 4 {pop} repeat 6901 9301 5656 9301 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 5730 10125 m 5625 10125 5625 10545 105 arcto 4 {pop} repeat 5625 10650 6870 10650 105 arcto 4 {pop} repeat 6975 10650 6975 10230 105 arcto 4 {pop} repeat 6975 10125 5730 10125 105 arcto 4 {pop} repeat clp gs col-1 s gr
+% Interp Spline
+n 3375 1050 m
+ 3503.93 1040.59 3560.18 1040.59 3600 1050 curveto
+ 3679.17 1068.69 3820.83 1181.31 3900 1200 curveto
+ 3966.39 1215.67 4060.14 1215.67 4275 1200 curveto
+ gs col-1 s gr
+
+n 4137.63 1172.42 m 4275.00 1200.00 l 4143.09 1247.22 l gs col-1 s gr
+% Interp Spline
+n 3375 3675 m
+ 3679.71 3639.77 3810.96 3621.02 3900 3600 curveto
+ 4059.28 3562.40 4415.07 3411.27 4575 3375 curveto
+ 4676.94 3351.89 4826.94 3333.14 5175 3300 curveto
+ gs col-1 s gr
+
+n 5037.05 3275.46 m 5175.00 3300.00 l 5044.16 3350.13 l gs col-1 s gr
+% Interp Spline
+n 3376 8701 m
+ 3679.72 8719.96 3810.97 8738.71 3901 8776 curveto
+ 4070.77 8846.32 4347.49 9141.91 4501 9226 curveto
+ 4632.16 9297.85 4958.41 9412.76 5101 9451 curveto
+ 5177.14 9471.42 5289.64 9490.17 5551 9526 curveto
+ gs col-1 s gr
+
+n 5422.34 9470.51 m 5551.00 9526.00 l 5412.16 9544.82 l gs col-1 s gr
+% Interp Spline
+n 3375 6075 m
+ 3678.72 6093.96 3809.97 6112.71 3900 6150 curveto
+ 4069.77 6220.32 4346.49 6515.91 4500 6600 curveto
+ 4631.16 6671.85 4957.41 6786.76 5100 6825 curveto
+ 5176.14 6845.42 5288.64 6864.17 5550 6900 curveto
+ gs col-1 s gr
+
+n 5421.34 6844.51 m 5550.00 6900.00 l 5411.16 6918.82 l gs col-1 s gr
+% Interp Spline
+n 3450 9525 m
+ 3753.72 9543.96 3884.97 9562.71 3975 9600 curveto
+ 4144.77 9670.32 4421.49 9965.91 4575 10050 curveto
+ 4706.16 10121.85 5032.41 10236.76 5175 10275 curveto
+ 5251.14 10295.42 5363.64 10314.17 5625 10350 curveto
+ gs col-1 s gr
+
+n 5496.34 10294.51 m 5625.00 10350.00 l 5486.16 10368.82 l gs col-1 s gr
+/Times-Roman findfont 210.00 scalefont setfont
+5775 2100 m
+gs 1 -1 sc (server host) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+4650 1425 m
+gs 1 -1 sc (listening) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+4125 1050 m
+gs 1 -1 sc (TCP port) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+3450 3375 m
+gs 1 -1 sc (connection) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+3450 3150 m
+gs 1 -1 sc (initial) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+6300 3825 m
+gs 1 -1 sc (forks child ) col-1 show gr
+/Times-Bold findfont 240.00 scalefont setfont
+300 4800 m
+gs 1 -1 sc (\(b\) postmaster creates backend server) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+3601 9226 m
+gs 1 -1 sc (queries/) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+3601 9451 m
+gs 1 -1 sc (data) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+4576 9001 m
+gs 1 -1 sc (listening) col-1 show gr
+/Times-Bold findfont 240.00 scalefont setfont
+301 9826 m
+gs 1 -1 sc (\(d\) frontend connected) col-1 show gr
+/Times-Bold findfont 240.00 scalefont setfont
+676 10126 m
+gs 1 -1 sc (to multiple backend servers) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+3600 6600 m
+gs 1 -1 sc (queries/) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+3600 6825 m
+gs 1 -1 sc (data) col-1 show gr
+/Times-Roman findfont 210.00 scalefont setfont
+4575 6375 m
+gs 1 -1 sc (listening) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+5775 10500 m
+gs 1 -1 sc (SERVER2) col-1 show gr
+$F2psEnd
+restore
+%%EndDocument
+end PEND/F3 11/Times-Bold@0 SF(Figur)192.151 660.1 Q 2.75(e1)-.198 G F1
+5.5(.H)-2.75 G .55 -.275(ow a c)-5.5 H(onnection is established.).275 E
+77.5 673.3 72 673.3 DL 80.5 673.3 75 673.3 DL 86 673.3 80.5 673.3 DL
+91.5 673.3 86 673.3 DL 97 673.3 91.5 673.3 DL 102.5 673.3 97 673.3 DL
+108 673.3 102.5 673.3 DL 113.5 673.3 108 673.3 DL 119 673.3 113.5 673.3
+DL 124.5 673.3 119 673.3 DL 130 673.3 124.5 673.3 DL 135.5 673.3 130
+673.3 DL 141 673.3 135.5 673.3 DL 146.5 673.3 141 673.3 DL 152 673.3
+146.5 673.3 DL 157.5 673.3 152 673.3 DL 163 673.3 157.5 673.3 DL 168.5
+673.3 163 673.3 DL 174 673.3 168.5 673.3 DL 179.5 673.3 174 673.3 DL 185
+673.3 179.5 673.3 DL 190.5 673.3 185 673.3 DL 196 673.3 190.5 673.3 DL
+201.5 673.3 196 673.3 DL 207 673.3 201.5 673.3 DL 212.5 673.3 207 673.3
+DL 218 673.3 212.5 673.3 DL 223.5 673.3 218 673.3 DL 229 673.3 223.5
+673.3 DL 234.5 673.3 229 673.3 DL 240 673.3 234.5 673.3 DL 245.5 673.3
+240 673.3 DL 251 673.3 245.5 673.3 DL 256.5 673.3 251 673.3 DL 262 673.3
+256.5 673.3 DL 267.5 673.3 262 673.3 DL 273 673.3 267.5 673.3 DL 278.5
+673.3 273 673.3 DL 284 673.3 278.5 673.3 DL 289.5 673.3 284 673.3 DL 295
+673.3 289.5 673.3 DL 300.5 673.3 295 673.3 DL 306 673.3 300.5 673.3 DL
+311.5 673.3 306 673.3 DL 317 673.3 311.5 673.3 DL 322.5 673.3 317 673.3
+DL 328 673.3 322.5 673.3 DL 333.5 673.3 328 673.3 DL 339 673.3 333.5
+673.3 DL 344.5 673.3 339 673.3 DL 350 673.3 344.5 673.3 DL 355.5 673.3
+350 673.3 DL 361 673.3 355.5 673.3 DL 366.5 673.3 361 673.3 DL 372 673.3
+366.5 673.3 DL 377.5 673.3 372 673.3 DL 383 673.3 377.5 673.3 DL 388.5
+673.3 383 673.3 DL 394 673.3 388.5 673.3 DL 399.5 673.3 394 673.3 DL 405
+673.3 399.5 673.3 DL 410.5 673.3 405 673.3 DL 416 673.3 410.5 673.3 DL
+421.5 673.3 416 673.3 DL 427 673.3 421.5 673.3 DL 432.5 673.3 427 673.3
+DL 438 673.3 432.5 673.3 DL 443.5 673.3 438 673.3 DL 449 673.3 443.5
+673.3 DL 454.5 673.3 449 673.3 DL 460 673.3 454.5 673.3 DL 465.5 673.3
+460 673.3 DL 471 673.3 465.5 673.3 DL 476.5 673.3 471 673.3 DL 482 673.3
+476.5 673.3 DL 487.5 673.3 482 673.3 DL 493 673.3 487.5 673.3 DL 498.5
+673.3 493 673.3 DL 504 673.3 498.5 673.3 DL F3(5)285.25 756 Q EP
+%%Page: 6 6
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF(clearer)108 97.2 Q(.)-.605 E 1.025
+(In database jar)108 114.3 R(gon,)-.198 E/F1 10/Times-Roman@0 SF
+(POSTGRES)3.775 E F0 1.025(uses a simple \231process-per)3.775 F 1.025
+(-user\232 client/serv)-.22 F 1.024(er model.)-.165 F(A)6.524 E F1
+(POSTGRES)108 127.5 Q F0(session consists of the follo)2.75 E
+(wing cooperating)-.275 E F1(UNIX)2.75 E F0(processes \(programs\):)2.75
+E 5.5<8341>113.5 144.6 S(supervisory daemon process \(the)-2.75 E/F2 11
+/Courier@0 SF(postmaster)2.75 E F0(\),)A 5.5<8374>113.5 157.8 S
+(he user')-5.5 E 2.75(sf)-.605 G(rontend application \(e.g., the)-2.75 E
+F2(psql)2.75 E F0(program\), and)2.75 E 5.5<8374>113.5 171 S
+(he one or more back)-5.5 E(end database serv)-.11 E(ers \(the)-.165 E
+F2(postgres)2.75 E F0(process itself\).)2.75 E 2.783(As)108 188.1 S
+(ingle)-2.783 E F2(postmaster)2.783 E F0 .034(manages a gi)2.783 F -.165
+(ve)-.275 G 2.784(nc).165 G .034(ollection of)-2.784 F/F3 11
+/Times-Italic@0 SF(databases)2.784 E F0 .034(on a single host.)2.784 F
+.034(Such a)5.534 F .214(collection of databases is called an)108 201.3
+R F3(installation)2.963 E F0(or)2.963 E F3(site)2.963 E F0 5.713(.F)C
+.213(rontend applications that wish to)-5.713 F 2.462(access a gi)108
+214.5 R -.165(ve)-.275 G 5.213(nd).165 G 2.463
+(atabase within an installation mak)-5.213 F 5.213(ec)-.11 G 2.463
+(alls to the)-5.213 F F1(LIBPQ)5.213 E F0(library)5.213 E 7.963(.T)-.715
+G(he)-7.963 E .275(library sends user requests o)108 227.7 R -.165(ve)
+-.165 G 3.024(rt).165 G .274(he netw)-3.024 F .274(ork to the)-.11 F F2
+(postmaster)3.024 E F0 .274(\(Figure 1\(a\)\), which in)3.024 F .591
+(turn starts a ne)108 240.9 R 3.341(wb)-.275 G(ack)-3.341 E .591
+(end serv)-.11 F .592
+(er process \(Figure 1\(b\)\) and connects the frontend process)-.165 F
+.165(to the ne)108 254.1 R 2.915(ws)-.275 G(erv)-2.915 E .165
+(er \(Figure 1\(c\)\).)-.165 F .164
+(From that point on, the frontend process and the back)5.664 F(end)-.11
+E(serv)108 267.3 Q .625(er communicate without interv)-.165 F .626
+(ention by the)-.165 F F2(postmaster)3.376 E F0 6.126(.H)C .626
+(ence, the)-6.126 F F2(postmas-)3.376 E(ter)108 280.5 Q F0 1.72(is al)
+4.47 F -.11(wa)-.11 G 1.72(ys running, w).11 F 1.72
+(aiting for requests, whereas frontend and back)-.11 F 1.72
+(end processes)-.11 F .795(come and go.)108 293.7 R(The)6.296 E F1
+(LIBPQ)3.546 E F0 .796(library allo)3.546 F .796
+(ws a single frontend to mak)-.275 F 3.546(em)-.11 G .796
+(ultiple connections)-3.546 F 1.511(to back)108 306.9 R 1.511
+(end processes.)-.11 F(Ho)7.011 E(we)-.275 E -.165(ve)-.275 G 2.391 -.44
+(r, t).165 H 1.511
+(he frontend application is still a single-threaded pro-).44 F 3.294
+(cess. Multithreaded)108 320.1 R(frontend/back)3.294 E .545
+(end connections are not currently supported in)-.11 F F1(LIBPQ)3.295 E
+F0(.)A .054(One implication of this architecture is that the)108 337.2 R
+F2(postmaster)2.803 E F0 .053(and the back)2.803 F .053(end al)-.11 F
+-.11(wa)-.11 G .053(ys run).11 F .831
+(on the same machine \(the database serv)108 350.4 R .832
+(er\), while the frontend application may run an)-.165 F(y-)-.165 E
+3.659(where. Y)108 363.6 R .909(ou should k)-1.21 F .908
+(eep this in mind, because the \214les that can be accessed on a client)
+-.11 F .943
+(machine may not be accessible \(or may only be accessed using a dif)108
+376.8 R .943(ferent \214lename\) on)-.275 F(the database serv)108 390 Q
+(er machine.)-.165 E -1.21(Yo)108 407.1 S 3.967(us)1.21 G 1.217
+(hould also be a)-3.967 F -.11(wa)-.165 G 1.217(re that the).11 F F2
+(postmaster)3.967 E F0(and)3.967 E F2(postgres)3.967 E F0(serv)3.967 E
+1.216(ers run with the)-.165 F(user)108 420.3 Q .493(-id of the)-.22 F
+F1(POSTGRES)3.243 E F0(\231superuser)3.243 E 4.783 -.77(.\232 N)-.605 H
+.493(ote that the).77 F F1(POSTGRES)3.244 E F0 .494
+(superuser does not ha)3.244 F -.165(ve)-.22 G .931
+(to be a special user \(e.g., a user named \231postgres\232\).)108 433.5
+R .931(Furthermore, the)6.431 F F1(POSTGRES)3.681 E F0(supe-)3.681 E
+.171(ruser should de\214nitely not be the)108 446.7 R F1(UNIX)2.921 E F0
+(superuser)2.921 E 2.921<2c99>-.44 G 2.921(root\232! In)-2.921 F(an)
+2.921 E 2.921(yc)-.165 G .171(ase, all \214les relating to)-2.921 F 2.75
+(ad)108 459.9 S(atabase should belong to this)-2.75 E F1(POSTGRES)2.75 E
+F0(superuser)2.75 E(.)-.605 E/F4 11/Times-Bold@0 SF(6)285.25 756 Q EP
+%%Page: 7 7
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(3. GETTING)72 165.4 R(ST)4.75 E(AR)
+-1.71 E(TED WITH POSTGRES)-.76 E 77.5 178.6 72 178.6 DL 80.5 178.6 75
+178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5
+178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6
+108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6
+124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5
+178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163
+178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL
+179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6
+DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5
+178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6
+218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6
+234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5
+178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273
+178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL
+289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6
+DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5
+178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6
+328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6
+344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5
+178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383
+178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL
+399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6
+DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5
+178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6
+438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6
+454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5
+178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493
+178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL
+/F1 11/Times-Roman@0 SF .735(This section discusses ho)108 208.9 R 3.485
+(wt)-.275 G 3.485(os)-3.485 G(tart)-3.485 E/F2 10/Times-Roman@0 SF
+(POSTGRES)3.484 E F1 .734(and set up your o)3.484 F .734(wn en)-.275 F
+.734(vironment so that)-.44 F .707(you can use frontend applications. W)
+108 222.1 R 3.458(ea)-.88 G(ssume)-3.458 E F2(POSTGRES)3.458 E F1 .708
+(has already been successfully)3.458 F
+(installed. \(Refer to the installation notes for ho)108 235.3 Q 2.75
+(wt)-.275 G 2.75(oi)-2.75 G(nstall)-2.75 E F2(POSTGRES)2.75 E F1(.\))A
+.637(Some of the steps listed in this section will apply to all)108
+261.7 R F2(POSTGRES)3.386 E F1 .636(users, and some will)3.386 F 1.135
+(apply primarily to the site database administrator)108 274.9 R 6.635
+(.T)-.605 G(his)-6.635 E/F3 11/Times-Italic@0 SF 1.135(site administr)
+3.885 F(ator)-.165 E F1 1.135(is the person)3.885 F .129
+(who installed the softw)108 288.1 R .129
+(are, created the database directories and started the)-.11 F/F4 11
+/Courier@0 SF(postmaster)2.879 E F1 4.183(process. This)108 301.3 R
+1.433(person does not ha)4.183 F 1.763 -.165(ve t)-.22 H 4.183(ob).165 G
+4.183(et)-4.183 G(he)-4.183 E F2(UNIX)4.183 E F1(superuser)4.183 E 4.184
+<2c99>-.44 G(root,)-4.184 E 4.184<9a6f>-.77 G 4.184(rt)-4.184 G 1.434
+(he computer)-4.184 F(system administrator)108 314.5 Q(.)-.605 E 1.512(\
+In this section, items for end users are labelled \231User\232 and item\
+s intended for the site)108 331.6 R(administrator are labelled \231)108
+344.8 Q(Admin.)-.88 E<9a>-.77 E .677(Throughout this manual, an)108
+361.9 R 3.427(ye)-.165 G .677(xamples that be)-3.592 F .678
+(gin with the character `)-.165 F(`)-.814 E F4(%)A F1 2.306 -.814('' a)D
+.678(re commands).814 F 1.067(that should be typed at the)108 375.1 R F2
+(UNIX)3.817 E F1 1.067(shell prompt.)3.817 F 1.067(Examples that be)
+6.567 F 1.067(gin with the character)-.165 F -.814(``)108 388.3 S F4(*)
+.814 E F1 1.628 -.814('' a)D(re commands in the).814 E F2(POSTGRES)2.75
+E F1(query language,)2.75 E F2(POSTGRES)2.75 E F1(SQL.)2.75 E/F5 12
+/Times-Bold@0 SF 3(3.1. Admin/User:)72 414.5 R(Setting Up Y)3 E(our En)
+-1.332 E(vir)-.48 E(onment)-.216 E 77.5 439.7 72 439.7 DL 80.5 439.7 75
+439.7 DL 86 439.7 80.5 439.7 DL 91.5 439.7 86 439.7 DL 97 439.7 91.5
+439.7 DL 102.5 439.7 97 439.7 DL 108 439.7 102.5 439.7 DL 113.5 439.7
+108 439.7 DL 119 439.7 113.5 439.7 DL 124.5 439.7 119 439.7 DL 130 439.7
+124.5 439.7 DL 135.5 439.7 130 439.7 DL 141 439.7 135.5 439.7 DL 146.5
+439.7 141 439.7 DL 152 439.7 146.5 439.7 DL 157.5 439.7 152 439.7 DL 163
+439.7 157.5 439.7 DL 168.5 439.7 163 439.7 DL 174 439.7 168.5 439.7 DL
+179.5 439.7 174 439.7 DL 185 439.7 179.5 439.7 DL 190.5 439.7 185 439.7
+DL 196 439.7 190.5 439.7 DL 201.5 439.7 196 439.7 DL 207 439.7 201.5
+439.7 DL 212.5 439.7 207 439.7 DL 218 439.7 212.5 439.7 DL 223.5 439.7
+218 439.7 DL 229 439.7 223.5 439.7 DL 234.5 439.7 229 439.7 DL 240 439.7
+234.5 439.7 DL 245.5 439.7 240 439.7 DL 251 439.7 245.5 439.7 DL 256.5
+439.7 251 439.7 DL 262 439.7 256.5 439.7 DL 267.5 439.7 262 439.7 DL 273
+439.7 267.5 439.7 DL 278.5 439.7 273 439.7 DL 284 439.7 278.5 439.7 DL
+289.5 439.7 284 439.7 DL 295 439.7 289.5 439.7 DL 300.5 439.7 295 439.7
+DL 306 439.7 300.5 439.7 DL 311.5 439.7 306 439.7 DL 317 439.7 311.5
+439.7 DL 322.5 439.7 317 439.7 DL 328 439.7 322.5 439.7 DL 333.5 439.7
+328 439.7 DL 339 439.7 333.5 439.7 DL 344.5 439.7 339 439.7 DL 350 439.7
+344.5 439.7 DL 355.5 439.7 350 439.7 DL 361 439.7 355.5 439.7 DL 366.5
+439.7 361 439.7 DL 372 439.7 366.5 439.7 DL 377.5 439.7 372 439.7 DL 383
+439.7 377.5 439.7 DL 388.5 439.7 383 439.7 DL 394 439.7 388.5 439.7 DL
+399.5 439.7 394 439.7 DL 405 439.7 399.5 439.7 DL 410.5 439.7 405 439.7
+DL 416 439.7 410.5 439.7 DL 421.5 439.7 416 439.7 DL 427 439.7 421.5
+439.7 DL 432.5 439.7 427 439.7 DL 438 439.7 432.5 439.7 DL 443.5 439.7
+438 439.7 DL 449 439.7 443.5 439.7 DL 454.5 439.7 449 439.7 DL 460 439.7
+454.5 439.7 DL 465.5 439.7 460 439.7 DL 471 439.7 465.5 439.7 DL 476.5
+439.7 471 439.7 DL 482 439.7 476.5 439.7 DL 487.5 439.7 482 439.7 DL 493
+439.7 487.5 439.7 DL 498.5 439.7 493 439.7 DL 504 439.7 498.5 439.7 DL 0
+0 432 826 -170.061 317 72 636.161 PBEGIN
+%%BeginDocument: manual-files.eps
+%%Title: stdin
+%%Creator: fig2dev Version 3.1 Patchlevel 0
+%%CreationDate: Sat Feb 24 21:36:26 1996
+%%For: jolly@arcadia.CS.Berkeley.EDU (Jolly Chen,421 Soda,(510) 6421863,540-5955)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 826 317
+%%Pages: 0
+%%BeginSetup
+%%IncludeFeature: *PageSize Letter
+%%EndSetup
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {} def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-17.0 331.0 translate
+1 -1 scale
+
+/clp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+
+$F2psBegin
+10 setmiterlimit
+ 0.06000 0.06000 sc
+/Times-Roman findfont 240.00 scalefont setfont
+1650 3990 m
+gs 1 -1 sc (pg_class ....) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+3750 2415 m
+gs 1 -1 sc ([shared classes]) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+3750 2115 m
+gs 1 -1 sc (pg_log) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+3750 4215 m
+gs 1 -1 sc ([private classes]) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+3750 3990 m
+gs 1 -1 sc (pg_class ....) col-1 show gr
+7.500 slw
+% Polyline
+n 2850 1665 m 1575 1890 l gs col-1 s gr
+% Polyline
+n 2850 1665 m 2475 1890 l gs col-1 s gr
+% Polyline
+n 1500 2265 m 1050 2790 l gs col-1 s gr
+% Polyline
+n 2475 2265 m 2475 2790 l gs col-1 s gr
+% Polyline
+n 2850 1680 m 4050 1905 l gs col-1 s gr
+% Polyline
+n 2475 2265 m 4500 2790 l gs col-1 s gr
+% Polyline
+n 4575 3165 m 4575 3690 l gs col-1 s gr
+% Polyline
+n 2475 3165 m 2475 3690 l gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+1350 2190 m
+gs 1 -1 sc (files) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+2250 2190 m
+gs 1 -1 sc (base) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+1950 3090 m
+gs 1 -1 sc (template1) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+2625 1590 m
+gs 1 -1 sc (data) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+450 3090 m
+gs 1 -1 sc ([.bki files]) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+3225 3090 m
+gs 1 -1 sc ( ) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+4500 2190 m
+gs 1 -1 sc (....) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+4275 3090 m
+gs 1 -1 sc (mydb ....) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+6600 4875 m
+gs 1 -1 sc (EXECUTABLE) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+6600 5175 m
+gs 1 -1 sc (PROGRAMS) col-1 show gr
+% Polyline
+n 7800 465 m 10125 1290 l gs col-1 s gr
+% Polyline
+n 10125 1665 m 10125 1890 l gs col-1 s gr
+% Polyline
+n 7800 465 m 11475 1290 l gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+1650 4215 m
+gs 1 -1 sc ([private classes]) col-1 show gr
+% Polyline
+n 11475 1665 m 11475 1890 l gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+11100 2190 m
+gs 1 -1 sc (libpq-fe.h ....) col-1 show gr
+% Polyline
+n 7800 465 m 12675 1290 l gs col-1 s gr
+% Polyline
+n 7800 465 m 13650 1290 l gs col-1 s gr
+% Polyline
+n 7800 450 m 2850 1275 l gs col-1 s gr
+% Polyline
+n 7800 450 m 7350 1275 l gs col-1 s gr
+% Polyline
+n 300 4500 m 5550 4500 l gs col-1 s gr
+% Polyline
+n 300 4575 m 5550 4575 l gs col-1 s gr
+% Polyline
+n 5775 4500 m 9600 4500 l gs col-1 s gr
+% Polyline
+n 5775 4575 m 9600 4575 l gs col-1 s gr
+% Polyline
+n 9825 4500 m 14025 4500 l gs col-1 s gr
+% Polyline
+n 9825 4575 m 14025 4575 l gs col-1 s gr
+% Polyline
+n 7350 1665 m 6225 1890 l gs col-1 s gr
+% Polyline
+n 7350 1665 m 7275 1890 l gs col-1 s gr
+% Polyline
+n 7350 1665 m 8475 1890 l gs col-1 s gr
+/Times-Roman findfont 240.00 scalefont setfont
+9825 2190 m
+gs 1 -1 sc (libpq.a) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+9975 1590 m
+gs 1 -1 sc (lib) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+11100 1590 m
+gs 1 -1 sc (include) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+12600 1590 m
+gs 1 -1 sc (src) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+13500 1590 m
+gs 1 -1 sc (doc) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+7350 390 m
+gs 1 -1 sc (postgres) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+2400 4950 m
+gs 1 -1 sc (DATA) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+10950 5175 m
+gs 1 -1 sc (DEVELOPMENT) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+10950 4875 m
+gs 1 -1 sc (APPLICATION ) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+10950 5475 m
+gs 1 -1 sc (ENVIRONMENT) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+7200 1590 m
+gs 1 -1 sc (bin) col-1 show gr
+/Times-Roman findfont 240.00 scalefont setfont
+5775 2190 m
+gs 1 -1 sc ( psql postgres postmaster....) col-1 show gr
+$F2psEnd
+restore
+%%EndDocument
+end PEND/F6 11/Times-Bold@0 SF(Figur)214.358 662.561 Q 2.75(e2)-.198 G
+F1(.)-2.75 E F2(POSTGRES)5.5 E F1(\214le layout.)2.75 E 77.5 675.761 72
+675.761 DL 80.5 675.761 75 675.761 DL 86 675.761 80.5 675.761 DL 91.5
+675.761 86 675.761 DL 97 675.761 91.5 675.761 DL 102.5 675.761 97
+675.761 DL 108 675.761 102.5 675.761 DL 113.5 675.761 108 675.761 DL 119
+675.761 113.5 675.761 DL 124.5 675.761 119 675.761 DL 130 675.761 124.5
+675.761 DL 135.5 675.761 130 675.761 DL 141 675.761 135.5 675.761 DL
+146.5 675.761 141 675.761 DL 152 675.761 146.5 675.761 DL 157.5 675.761
+152 675.761 DL 163 675.761 157.5 675.761 DL 168.5 675.761 163 675.761 DL
+174 675.761 168.5 675.761 DL 179.5 675.761 174 675.761 DL 185 675.761
+179.5 675.761 DL 190.5 675.761 185 675.761 DL 196 675.761 190.5 675.761
+DL 201.5 675.761 196 675.761 DL 207 675.761 201.5 675.761 DL 212.5
+675.761 207 675.761 DL 218 675.761 212.5 675.761 DL 223.5 675.761 218
+675.761 DL 229 675.761 223.5 675.761 DL 234.5 675.761 229 675.761 DL 240
+675.761 234.5 675.761 DL 245.5 675.761 240 675.761 DL 251 675.761 245.5
+675.761 DL 256.5 675.761 251 675.761 DL 262 675.761 256.5 675.761 DL
+267.5 675.761 262 675.761 DL 273 675.761 267.5 675.761 DL 278.5 675.761
+273 675.761 DL 284 675.761 278.5 675.761 DL 289.5 675.761 284 675.761 DL
+295 675.761 289.5 675.761 DL 300.5 675.761 295 675.761 DL 306 675.761
+300.5 675.761 DL 311.5 675.761 306 675.761 DL 317 675.761 311.5 675.761
+DL 322.5 675.761 317 675.761 DL 328 675.761 322.5 675.761 DL 333.5
+675.761 328 675.761 DL 339 675.761 333.5 675.761 DL 344.5 675.761 339
+675.761 DL 350 675.761 344.5 675.761 DL 355.5 675.761 350 675.761 DL 361
+675.761 355.5 675.761 DL 366.5 675.761 361 675.761 DL 372 675.761 366.5
+675.761 DL 377.5 675.761 372 675.761 DL 383 675.761 377.5 675.761 DL
+388.5 675.761 383 675.761 DL 394 675.761 388.5 675.761 DL 399.5 675.761
+394 675.761 DL 405 675.761 399.5 675.761 DL 410.5 675.761 405 675.761 DL
+416 675.761 410.5 675.761 DL 421.5 675.761 416 675.761 DL 427 675.761
+421.5 675.761 DL 432.5 675.761 427 675.761 DL 438 675.761 432.5 675.761
+DL 443.5 675.761 438 675.761 DL 449 675.761 443.5 675.761 DL 454.5
+675.761 449 675.761 DL 460 675.761 454.5 675.761 DL 465.5 675.761 460
+675.761 DL 471 675.761 465.5 675.761 DL 476.5 675.761 471 675.761 DL 482
+675.761 476.5 675.761 DL 487.5 675.761 482 675.761 DL 493 675.761 487.5
+675.761 DL 498.5 675.761 493 675.761 DL 504 675.761 498.5 675.761 DL F6
+(7)285.25 756 Q EP
+%%Page: 8 8
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF .856(Figure 2 sho)108 97.2 R .856(ws ho)-.275 F
+3.606(wt)-.275 G(he)-3.606 E/F1 10/Times-Roman@0 SF(POSTGRES)3.606 E F0
+(distrib)3.606 E .856(ution is laid out when installed in the def)-.22 F
+(ault)-.11 E -.11(wa)108 110.4 S 2.629 -.715(y. F).11 H 1.199
+(or simplicity).55 F 3.949(,w)-.715 G 3.949(ew)-3.949 G 1.199
+(ill assume that)-3.949 F F1(POSTGRES)3.949 E F0 1.198
+(has been installed in the directory)3.949 F/F2 11/Courier@0 SF
+(/usr/local/postgres95)108 123.6 Q F0 16.351(.T)C 10.851
+(herefore, where)-16.351 F -.165(ve)-.275 G 13.601(ry).165 G 10.852
+(ou see the directory)-13.601 F F2(/usr/local/postgres95)108 136.8 Q F0
+2.02(you should substitute the name of the directory where)4.771 F F1
+(POSTGRES)108 150 Q F0(is actually installed.)2.75 E(All)108 167.1 Q F1
+(POSTGRES)24.549 E F0 21.8(commands are installed in the directory)24.55
+F F2(/usr/local/postgres95/bin)108 180.3 Q F0 6.918(.T)C 1.418
+(herefore, you should add this directory to your)-6.918 F(shell)108
+193.5 Q/F3 11/Times-Italic@0 SF .391(command path)3.141 F F0 5.891(.I)C
+3.141(fy)-5.891 G .391(ou use a v)-3.141 F .391(ariant of the Berk)-.275
+F(ele)-.11 E 3.142(yCs)-.165 G .392(hell, such as)-3.142 F F2(csh)3.142
+E F0(or)3.142 E F2(tcsh)3.142 E F0(,)A(you w)108 206.7 Q(ould add)-.11 E
+/F4 10/Courier@0 SF 6(%s)148 231.9 S
+(et path = \( /usr/local/postgres95/bin $path \))-6 E F0 .213(in the)108
+258.1 R F2(.login)2.963 E F0 .212(\214le in your home directory)2.963 F
+5.712(.I)-.715 G 2.962(fy)-5.712 G .212(ou use a v)-2.962 F .212
+(ariant of the Bourne shell, such)-.275 F(as)108 271.3 Q F2(sh)2.75 E F0
+(,)A F2(ksh)2.75 E F0 2.75(,o)C(r)-2.75 E F2(bash)2.75 E F0 2.75(,t)C
+(hen you w)-2.75 E(ould add)-.11 E F4 6(%P)148 296.5 S
+(ATH=/usr/local/postgres95/bin:$PATH)-6 E 6(%e)148 308.7 S(xport PATH)-6
+E F0(to the)108 334.9 Q F2(.profile)2.75 E F0
+(\214le in your home directory)2.75 E(.)-.715 E .322(From no)108 352 R
+3.072(wo)-.275 G .322(n, we will assume that you ha)-3.072 F .652 -.165
+(ve a)-.22 H .323(dded the).165 F F1(POSTGRES)3.073 E F2(bin)3.073 E F0
+.323(directory to your)3.073 F 2.893(path. In)108 365.2 R .143
+(addition, we will mak)2.893 F 2.893(ef)-.11 G .143
+(requent reference to \231setting a shell v)-2.893 F .143
+(ariable\232 or \231setting)-.275 F .826(an en)108 378.4 R .826
+(vironment v)-.44 F .827(ariable\232 throughout this document.)-.275 F
+.827(If you did not fully understand the)6.327 F .056
+(last paragraph on modifying your search path, you should consult the)
+108 391.6 R F1(UNIX)2.806 E F0 .056(manual pages)2.806 F
+(that describe your shell before going an)108 404.8 Q 2.75(yf)-.165 G
+(urther)-2.75 E(.)-.605 E/F5 12/Times-Bold@0 SF 3(3.2. Admin:)72 431 R
+(Starting the P)3 E(ostmaster)-.24 E F0 1.227(It should be clear from t\
+he preceding discussion that nothing can happen to a database)108 448.1
+R .602(unless the)108 461.3 R F2(postmaster)3.352 E F0 .602
+(process is running.)3.352 F .602(As the site administrator)6.102 F
+3.351(,t)-.44 G .601(here are a num-)-3.351 F 1.686
+(ber of things you should remember before starting the)108 474.5 R F2
+(postmaster)4.436 E F0 7.186(.T)C 1.686(hese are dis-)-7.186 F 2.24
+(cussed in the section of this manual titled, \231)108 487.7 R
+(Administering)-.88 E F1(POSTGRES)4.989 E F0 6.529 -.77(.\232 H)D -.275
+(ow).77 G -2.365 -.275(ev e).275 H 3.119 -.44(r, i).275 H(f).44 E F1
+(POSTGRES)108 500.9 Q F0 .106(has been installed by follo)2.856 F .107
+(wing the installation instructions e)-.275 F .107(xactly as written,)
+-.165 F(the follo)108 514.1 Q
+(wing simple command is all you should need to start the)-.275 E F2
+(postmaster)2.75 E F0(:)A F4 6(%p)148 539.3 S(ostmaster &)-6 E F0(The)
+108 569.4 Q F2(postmaster)3.005 E F0 .255
+(occasionally prints out messages which are often helpful during trou-)
+3.005 F 3.201(bleshooting. If)108 582.6 R .451(you wish to vie)3.201 F
+3.201(wd)-.275 G(eb)-3.201 E .451(ugging messages from the postmaster)
+-.22 F 3.201(,y)-.44 G .451(ou can start)-3.201 F
+(it with the -d option and redirect the output to the log \214le:)108
+595.8 Q F4 6(%p)148 621 S(ostmaster -d >& pm.log &)-6 E F0
+(If you do not wish to see these messages, you can type)108 647.2 Q F4 6
+(%p)148 672.4 S(ostmaster -S)-6 E F0 .921(and the)108 698.6 R F2
+(postmaster)3.671 E F0 .921(will be \231S\232ilent.)3.671 F .921
+(Notice that there is no ampersand \(\231&\232\) at the)6.421 F
+(end of the last e)108 711.8 Q(xample.)-.165 E/F6 11/Times-Bold@0 SF(8)
+285.25 756 Q EP
+%%Page: 9 9
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(3.3. Admin:)72 97.2 R
+(Adding and Deleting Users)3 E/F1 11/Times-Roman@0 SF(The)108 114.3 Q/F2
+11/Courier@0 SF(createuser)7.893 E F1 5.144
+(command enables speci\214c users to access)7.894 F/F3 10/Times-Roman@0
+SF(POSTGRES)7.894 E F1 10.644(.T)C(he)-10.644 E F2(destroyuser)108 127.5
+Q F1 .524(command remo)3.274 F -.165(ve)-.165 G 3.274(su).165 G .524
+(sers and pre)-3.274 F -.165(ve)-.275 G .524(nts them from accessing)
+.165 F F3(POSTGRES)3.273 E F1(.)A 1.744
+(Note that these commands only af)108 140.7 R 1.744
+(fect users with respect to)-.275 F F3(POSTGRES)4.495 E F1 4.495(;t)C
+(he)-4.495 E 4.495(yh)-.165 G -2.475 -.22(av e)-4.495 H(no)4.715 E(ef)
+108 153.9 Q
+(fect administration of users that the operating system manages.)-.275 E
+F0 3(3.4. User:)72 180.1 R(Starting A)3 E(pplications)-.3 E F1 .087
+(Assuming that your site administrator has properly started the)108
+197.2 R F2(postmaster)2.837 E F1 .087(process and)2.837 F .186
+(authorized you to use the database, you \(as a user\) may be)108 210.4
+R .187(gin to start up applications.)-.165 F(As)5.687 E(pre)108 223.6 Q
+.303(viously mentioned, you should add)-.275 F F2
+(/usr/local/postgres95/bin)3.052 E F1 .302(to your shell)3.052 F
+(search path.)108 239 Q(In most cases, this is all you should ha)5.5 E
+.33 -.165(ve t)-.22 H 2.75(od).165 G 2.75(oi)-2.75 G 2.75(nt)-2.75 G
+(erms of preparation.)-2.75 E/F4 8/Times-Roman@0 SF(1)-4.4 I F1 1.245
+(If you get the follo)108 256.1 R 1.245(wing error message from a)-.275
+F F3(POSTGRES)3.995 E F1 1.245(command \(such as)3.995 F F2(psql)3.995 E
+F1(or)3.996 E F2(createdb)108 269.3 Q F1(\):)A/F5 10/Courier@0 SF(conne\
+ctDB\(\) failed: Is the postmaster running at 'localhost' on port '4322\
+'?)148 294.5 Q F1 1.103(it is usually because \(1\) the)108 320.7 R F2
+(postmaster)3.852 E F1 1.102
+(is not running, or \(2\) you are attempting to)3.852 F
+(connect to the wrong serv)108 333.9 Q(er host.)-.165 E
+(If you get the follo)108 351 Q(wing error message:)-.275 E F5
+(FATAL 1:Feb 17 23:19:55:process userid \(2360\) !=)148 376.2 Q
+(database owner \(268\))160 388.4 Q F1 .188
+(it means that the site administrator started the)108 414.6 R F2
+(postmaster)2.938 E F1 .188(as the wrong user)2.938 F 5.688(.T)-.605 G
+.188(ell him)-6.458 F(to restart it as the)108 427.8 Q F3(POSTGRES)2.75
+E F1(superuser)2.75 E(.)-.605 E F0 3(3.5. User:)72 454 R
+(Managing a Database)3 E F1(No)108 471.1 Q 2.859(wt)-.275 G(hat)-2.859 E
+F3(POSTGRES)2.859 E F1 .109
+(is up and running we can create some databases to e)2.859 F .108
+(xperiment with.)-.165 F
+(Here, we describe the basic commands for managing a database.)108 484.3
+Q F0 3(3.5.1. Cr)72 510.5 R(eating a Database)-.216 E F1(Let')108 527.6
+Q 2.96(ss)-.605 G .21(ay you w)-2.96 F .21
+(ant to create a database named)-.11 F F2(mydb)2.96 E F1 5.71(.Y)C .211
+(ou can do this with the follo)-6.92 F(wing)-.275 E(command:)108 540.8 Q
+F5 6(%c)148 566 S(reatedb mydb)-6 E F3(POSTGRES)108 592.2 Q F1(allo)2.8
+E .05(ws you to create an)-.275 F 2.8(yn)-.165 G .05
+(umber of databases at a gi)-2.8 F -.165(ve)-.275 G 2.799(ns).165 G .049
+(ite and you automat-)-2.799 F 2.104(ically become the)108 605.4 R/F6 11
+/Times-Italic@0 SF 2.104(database administr)4.854 F(ator)-.165 E F1
+2.104(of the database you just created.)4.854 F(Database)7.604 E
+(names must ha)108 618.6 Q .33 -.165(ve a)-.22 H 2.75(na).165 G(lphabet\
+ic \214rst character and are limited to 16 characters in length.)-2.75 E
+.32 LW 76 638.6 72 638.6 DL 80 638.6 76 638.6 DL 84 638.6 80 638.6 DL 88
+638.6 84 638.6 DL 92 638.6 88 638.6 DL 96 638.6 92 638.6 DL 100 638.6 96
+638.6 DL 104 638.6 100 638.6 DL 108 638.6 104 638.6 DL 112 638.6 108
+638.6 DL 116 638.6 112 638.6 DL 120 638.6 116 638.6 DL 124 638.6 120
+638.6 DL 128 638.6 124 638.6 DL 132 638.6 128 638.6 DL 136 638.6 132
+638.6 DL 140 638.6 136 638.6 DL 144 638.6 140 638.6 DL 148 638.6 144
+638.6 DL 152 638.6 148 638.6 DL 156 638.6 152 638.6 DL 160 638.6 156
+638.6 DL 164 638.6 160 638.6 DL 168 638.6 164 638.6 DL 172 638.6 168
+638.6 DL 176 638.6 172 638.6 DL 180 638.6 176 638.6 DL 184 638.6 180
+638.6 DL 188 638.6 184 638.6 DL 192 638.6 188 638.6 DL 196 638.6 192
+638.6 DL 200 638.6 196 638.6 DL 204 638.6 200 638.6 DL 208 638.6 204
+638.6 DL 212 638.6 208 638.6 DL 216 638.6 212 638.6 DL/F7 5
+/Times-Roman@0 SF(1)93.6 649 Q F4 .431
+(If your site administrator has not set things up in the def)2.431 3.2 N
+.431(ault w)-.08 F(ay)-.08 E 2.431(,y)-.52 G .431(ou may ha)-2.431 F
+.671 -.12(ve s)-.16 H .431(ome more w).12 F .431(ork to do.)-.08 F -.12
+(Fo)4.432 G 2.432(re).12 G .432(xample, if the)-2.552 F .068
+(database serv)72 661.8 R .068
+(er machine is a remote machine, you will need to set the)-.12 F/F8 8
+/Courier@0 SF(PGHOST)2.068 E F4(en)2.068 E .067(vironment v)-.32 F .067
+(ariable to the name of the database serv-)-.2 F .131(er machine.)72
+671.4 R .131(The en)4.131 F .131(vironment v)-.32 F(ariable)-.2 E F8
+(PGPORT)2.131 E F4 .131(may also ha)2.131 F .372 -.12(ve t)-.16 H 2.132
+(ob).12 G 2.132(es)-2.132 G 2.132(et. The)-2.132 F .132
+(bottom line is this: if you try to start an application pro-)2.132 F
+.614(gram and it complains that it cannot connect to the)72 681 R F8
+(postmaster)2.613 E F4 2.613(,y)C .613
+(ou should immediately consult your site administrator to mak)-2.613 F
+(e)-.08 E(sure that your en)72 690.6 Q(vironment is properly set up.)
+-.32 E/F9 11/Times-Bold@0 SF(9)285.25 756 Q EP
+%%Page: 10 10
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF 2.528(Not e)108 97.2 R -.165(ve)-.275 G 2.528
+(ry user has authorization to become a database administrator).165 F
+8.027(.I)-.605 G(f)-8.027 E/F1 10/Times-Roman@0 SF(POSTGRES)5.277 E F0
+.333(refuses to create databases for you, then the site administrator n\
+eeds to grant you permis-)108 110.4 R(sion to create databases.)108
+123.6 Q(Consult your site administrator if this occurs.)5.5 E/F2 12
+/Times-Bold@0 SF 3(3.5.2. Accessing)72 149.8 R 3(aD)3 G(atabase)-3 E F0
+(Once you ha)108 166.9 Q .33 -.165(ve c)-.22 H
+(onstructed a database, you can access it by:).165 E 5.5<8372>113.5 184
+S 2.696(unning the)-5.5 F F1(POSTGRES)5.446 E F0 2.696
+(terminal monitor programs \()5.446 F/F3 11/Courier@0 SF(monitor)5.446 E
+F0(or)5.445 E F3(psql)5.445 E F0 5.445(\)w)C(hich)-5.445 E(allo)122.85
+197.2 Q(ws you to interacti)-.275 E -.165(ve)-.275 G(ly enter).165 E
+2.75(,e)-.44 G(dit, and e)-2.75 E -.165(xe)-.165 G(cute SQL commands.)
+.165 E 5.5<8377>113.5 210.4 S 1.107(riting a C program using the)-5.5 F
+F1(LIBPQ)3.857 E F0 1.107(subroutine library)3.857 F 6.607(.T)-.715 G
+1.108(his allo)-6.607 F 1.108(ws you to submit)-.275 F .883(SQL command\
+s from C and get answers and status messages back to your program.)
+122.85 223.6 R(This interf)122.85 236.8 Q
+(ace is discussed further in section ??.)-.11 E -1.21(Yo)108 253.9 S
+3.472(um)1.21 G .722(ight w)-3.472 F .722(ant to start up)-.11 F F3
+(psql)3.472 E F0 3.472(,t)C 3.472(ot)-3.472 G .722(ry out the e)-3.472 F
+.723(xamples in this manual. It can be acti-)-.165 F -.275(va)108 267.1
+S(ted for the).275 E F3(mydb)2.75 E F0(database by typing the command:)
+2.75 E/F4 10/Courier@0 SF 6(%p)148 292.3 S(sql mydb)-6 E F0 -1.21(Yo)108
+318.5 S 2.75(uw)1.21 G(ill be greeted with the follo)-2.75 E
+(wing message:)-.275 E F4
+(Welcome to the POSTGRES95 interactive sql monitor:)148 343.7 Q
+(type \\? for help on slash commands)166 368.1 Q(type \\q to quit)166
+380.3 Q(type \\g or terminate with semicolon to execute query)166 392.5
+Q(You are currently connected to the database: mydb)154 404.7 Q(mydb=>)
+148 429.1 Q F0 .632(This prompt indicates that the terminal monitor is \
+listening to you and that you can type)108 455.3 R(SQL queries into a w)
+108 468.5 Q(orkspace maintained by the terminal monitor)-.11 E(.)-.605 E
+(The)108 485.6 Q F3(psql)2.959 E F0 .209
+(program responds to escape codes that be)2.959 F .209
+(gin with the backslash character)-.165 F 2.959<2c99>-.44 G<5c9a2e>
+-2.959 E -.165(Fo)108 498.8 S 3.786(re).165 G 1.035
+(xample, you can get help on the syntax of v)-3.951 F(arious)-.275 E F1
+(POSTGRES)3.785 E F0 1.035(SQL commands by)3.785 F(typing:)108 512 Q F4
+(mydb=> \\h)148 537.2 Q F0 .761(Once you ha)108 563.4 R 1.091 -.165
+(ve \214)-.22 H .761(nished entering your queries into the w).165 F .762
+(orkspace, you can pass the con-)-.11 F(tents of the w)108 576.6 Q
+(orkspace to the)-.11 E F1(POSTGRES)2.75 E F0(serv)2.75 E(er by typing:)
+-.165 E F4(mydb=> \\g)148 601.8 Q F0 .593(This tells the serv)108 628 R
+.593(er to process the query)-.165 F 6.093(.I)-.715 G 3.342(fy)-6.093 G
+.592(ou terminate your query with a semicolon,)-3.342 F
+(the \\g is not necessary)108 641.2 Q 5.5(.P)-.715 G
+(sql will automatically process semicolon-terminated queries.)-5.5 E
+1.76 -.88(To r)108 658.3 T(ead queries from a \214le, say).88 E F3
+(myFile,)2.75 E F0(instead of entering them interacti)2.75 E -.165(ve)
+-.275 G(ly).165 E 2.75(,t)-.715 G(ype:)-2.75 E F4(mydb=> \\i fileName)
+148 683.5 Q F0 1.76 -.88(To g)108 709.7 T(et out of psql and return to)
+.88 E F1(UNIX)2.75 E F0 2.75(,t)C(ype)-2.75 E/F5 11/Times-Bold@0 SF(10)
+282.5 756 Q EP
+%%Page: 11 11
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(mydb=> \\q)148 96.2 Q/F1 11/Times-Roman@0 SF(and)108
+122.4 Q/F2 11/Courier@0 SF(psql)3.184 E F1 .434
+(will quit and return you to your command shell. \(F)3.184 F .434
+(or more escape codes, type)-.165 F F2(\\h)108 135.6 Q F1(at the)2.75 E
+F2(monitor)2.75 E F1(prompt.\))2.75 E .855
+(White space \(i.e., spaces, tabs and ne)108 152.7 R .855
+(wlines\) may be used freely in SQL queries.)-.275 F(Com-)6.354 E .099
+(ments are denoted by)108 165.9 R F2(--)2.849 E F1 5.599(.E)C -.165(ve)
+-5.599 G .1
+(rything after the dashes up to the end of the line is ignored.).165 F
+/F3 12/Times-Bold@0 SF 3(3.5.3. Destr)72 183 R(oying a Database)-.216 E
+F1 .453(If you are the database administrator for the database)108 200.1
+R F2(mydb)3.202 E F1 3.202(,y)C .452(ou can destro)-3.202 F 3.202(yi)
+-.11 G 3.202(tu)-3.202 G .452(sing the)-3.202 F(follo)108 213.3 Q(wing)
+-.275 E/F4 10/Times-Roman@0 SF(UNIX)2.75 E F1(command:)2.75 E F0 6(%d)
+148 238.5 S(estroydb mydb)-6 E F1 .08(This action ph)108 264.7 R .08
+(ysically remo)-.055 F -.165(ve)-.165 G 2.83(sa).165 G .08(ll of the)
+-2.83 F F4(UNIX)2.83 E F1 .081
+(\214les associated with the database and can-)2.83 F(not be undone, so\
+ this should only be done with a great deal of forethought.)108 277.9 Q
+/F5 11/Times-Bold@0 SF(11)282.5 756 Q EP
+%%Page: 12 12
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(4. THE)72 165.4 R -.19(QU)4.75 G(ER)
+.19 E 4.75(YL)-.665 G(ANGU)-4.75 E -1.045(AG)-1.14 G(E)1.045 E 77.5
+178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5
+178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108
+178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL
+124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6
+DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5
+178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6
+163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6
+179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5
+178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218
+178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL
+234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6
+DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5
+178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6
+273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6
+289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5
+178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328
+178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL
+344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6
+DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5
+178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6
+383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6
+399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5
+178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438
+178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL
+454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6
+DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5
+178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6
+493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF(The)108
+208.9 Q/F2 10/Times-Roman@0 SF(POSTGRES)3.209 E F1 .459
+(query language is a v)3.209 F .459(ariant of SQL-3. It has man)-.275 F
+3.209(ye)-.165 G .458(xtensions such as an)-3.374 F -.165(ex)108 222.1 S
+1.643(tensible type system, inheritance, functions and production rules\
+. Those are features).165 F .139(carried o)108 235.3 R -.165(ve)-.165 G
+2.889(rf).165 G .139(rom the original)-2.889 F F2(POSTGRES)2.889 E F1
+.139(query language, POSTQ)2.889 F .138(UEL. This section pro-)-.11 F
+(vides an o)108 248.5 Q -.165(ve)-.165 G(rvie).165 E 2.75(wo)-.275 G
+2.75(fh)-2.75 G .55 -.275(ow t)-2.75 H 2.75(ou).275 G(se)-2.75 E F2
+(POSTGRES)2.75 E F1(SQL to perform simple operations.)2.75 E .357
+(This manual is only intended to gi)108 265.6 R .687 -.165(ve y)-.275 H
+.357(ou an idea of our \215a).165 F -.22(vo)-.22 G 3.107(ro).22 G 3.107
+(fS)-3.107 G .357(QL and is in no w)-3.107 F .357(ay a)-.11 F .093
+(complete tutorial on SQL. Numerous books ha)108 278.8 R .423 -.165
+(ve b)-.22 H .093(een written on SQL. F).165 F .093(or instance, con-)
+-.165 F .283(sult [MEL)108 292 R .283(T93] or [D)-1.012 F -1.221(AT)-.44
+G .283(E93]. Y)1.221 F .283(ou should also be a)-1.21 F -.11(wa)-.165 G
+.283(re that some features are not part of).11 F(the ANSI standard.)108
+305.2 Q 2.094(In the e)108 322.3 R 2.093(xamples that follo)-.165 F
+3.523 -.715(w, w)-.275 H 4.843(ea).715 G 2.093(ssume that you ha)-4.843
+F 2.423 -.165(ve c)-.22 H 2.093(reated the).165 F/F3 11/Courier@0 SF
+(mydb)4.843 E F1 2.093(database as)4.843 F(described in the pre)108
+335.5 Q(vious subsection and ha)-.275 E .33 -.165(ve s)-.22 H
+(tarted psql.).165 E 24.523
+(Examples in this manual can also be found in)108 352.6 R F3
+(/usr/local/postgres95/src/tutorial)108 365.8 Q F1 7.623(.R)C 2.123
+(efer to the README \214le in that)-7.623 F(directory for ho)108 379 Q
+2.75(wt)-.275 G 2.75(ou)-2.75 G(se them.)-2.75 E 1.76 -.88(To s)5.5 H
+(tart the tutorial, do the follo).88 E(wing:)-.275 E/F4 10/Courier@0 SF
+6(%c)148 404.2 S 6(d/)-6 G(usr/local/postgres95/src/tutorial)-6 E 6(%p)
+148 416.4 S(sql -s mydb)-6 E
+(Welcome to the POSTGRES95 interactive sql monitor:)148 428.6 Q
+(type \\? for help on slash commands)166 453 Q(type \\q to quit)166
+465.2 Q(type \\g or terminate with semicolon to execute query)166 477.4
+Q(You are currently connected to the database: jolly)154 489.6 Q
+(mydb=> \\i basics.sql)148 526.2 Q F1(The)108 556.3 Q F3(\\i)3.107 E F1
+.357(command read in queries from the speci\214ed \214les. The)3.107 F
+F3(-s)3.108 E F1 .358(option puts you in sin-)3.108 F .868
+(gle step mode which pauses before sending a query to the back)108 569.5
+R .868(end. Queries in this sec-)-.11 F(tion are in the \214le)108 582.7
+Q F3(basics.sql)2.75 E F1(.)A/F5 12/Times-Bold@0 SF 3(4.1. Concepts)72
+608.9 R F1 .824(The fundamental notion in)108 626 R F2(POSTGRES)3.574 E
+F1 .824(is that of a)3.574 F/F6 11/Times-Italic@0 SF(class,)3.574 E F1
+.824(which is a named collection of)3.574 F(object)108 639.2 Q F6
+(instances)4.277 E F1 7.027(.E)C 1.526
+(ach instance has the same collection of named)-7.027 F F6(attrib)4.276
+E(utes)-.22 E F1 4.276(,a)C 1.526(nd each)-4.276 F(attrib)108 652.4 Q
+.728(ute is of a speci\214c)-.22 F F6(type)3.478 E F1 6.228(.F)C .729
+(urthermore, each instance has a permanent)-6.228 F F6 .729
+(object identi-)3.479 F(\214er)108 665.6 Q F1 .004
+(\(OID\) that is unique throughout the installation.)2.754 F .003
+(Because SQL syntax refers to)5.503 F F6(tables,)2.753 E F1 .191
+(we will use the terms)108 678.8 R F6(table)2.941 E F1(and)2.941 E F6
+(class)2.941 E F1(interchangeably)2.941 E 5.691(.L)-.715 G(ik)-5.691 E
+-.275(ew)-.11 G .192(ise, a).275 F F6 -.495(ro)2.942 G(w).495 E F1 .192
+(is an)2.942 F F6(instance)2.942 E F1(and)2.942 E F6(columns)108 692 Q
+F1(are)2.75 E F6(attrib)2.75 E(utes.)-.22 E F1 .183(As pre)108 709.1 R
+.182(viously discussed, classes are grouped into databases, and a colle\
+ction of databases)-.275 F(managed by a single)108 722.3 Q F3
+(postmaster)2.75 E F1(process constitutes an installation or site.)2.75
+E/F7 11/Times-Bold@0 SF(12)282.5 756 Q EP
+%%Page: 13 13
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(4.2. Cr)72 97.2 R(eating a New Class)-.216 E/F1
+11/Times-Roman@0 SF -1.21(Yo)108 114.3 S 3.643(uc)1.21 G .893
+(an create a ne)-3.643 F 3.643(wc)-.275 G .893
+(lass by specifying the class name, along with all attrib)-3.643 F .894
+(ute names)-.22 F(and their types:)108 127.5 Q/F2 10/Courier@0 SF
+(CREATE TABLE weather \()148 152.7 Q 66(city varchar\(80\),)196 164.9 R
+48(temp_lo int,)196 177.1 R(-- low temperature)66 E 48(temp_hi int,)196
+189.3 R(-- high temperature)66 E 66(prcp real,)196 201.5 R
+(-- precipitation)54 E 66(date date)196 213.7 R(\);)160 225.9 Q F1 2.323
+(Note that k)108 256 R -.165(ey)-.11 G -.11(wo).165 G 2.323
+(rds are case-insensiti).11 F 2.653 -.165(ve b)-.275 H 2.323
+(ut identi\214ers are case-sensiti)-.055 F -.165(ve)-.275 G(.).165 E/F3
+10/Times-Roman@0 SF(POSTGRES)7.823 E F1 .214(SQL supports the usual SQL\
+ types int, \215oat, real, smallint, char\(N\), v)108 269.2 R .214
+(archar\(N\), date, and)-.275 F 4.038(time. As)108 282.4 R 1.288
+(we will see later)4.038 F(,)-.44 E F3(POSTGRES)4.038 E F1 1.287
+(can be customized with an arbitrary number of)4.038 F(user)108 295.6 Q
+(-de\214ned data types.)-.22 E(Consequently)5.5 E 2.75(,t)-.715 G
+(ype names are not k)-2.75 E -.165(ey)-.11 G -.11(wo).165 G(rds.).11 E
+.544(So f)108 312.7 R(ar)-.11 E 3.294(,t)-.44 G(he)-3.294 E F3(POSTGRES)
+3.294 E/F4 11/Times-Bold@0 SF(cr)3.294 E(eate)-.198 E F1 .544
+(command looks e)3.294 F .544(xactly lik)-.165 F 3.294(et)-.11 G .545
+(he command used to create a)-3.294 F .688
+(table in a traditional relational system.)108 325.9 R(Ho)6.188 E(we)
+-.275 E -.165(ve)-.275 G 1.568 -.44(r, w).165 H 3.438(ew).44 G .688
+(ill presently see that classes ha)-3.438 F -.165(ve)-.22 G
+(properties that are e)108 339.1 Q(xtensions of the relational model.)
+-.165 E F0 3(4.3. P)72 365.3 R(opulating a Class with Instances)-.24 E
+F1(The)108 382.4 Q F4(insert)2.75 E F1
+(statement is used to populate a class with instances:)2.75 E F2
+(INSERT INTO weather)148 407.6 Q
+(VALUES \('San Francisco', 46, 50, 0.25, '11/27/1994'\))166 419.8 Q F1
+-1.21(Yo)108 449.9 S 4.457(uc)1.21 G 1.707(an also use the)-4.457 F F4
+(copy)4.457 E F1 1.707(command to perform load lar)4.457 F 1.708
+(ge amounts of data from \215at)-.198 F(\(ASCII\) \214les.)108 463.1 Q
+F0 3(4.4. Querying)72 489.3 R 3(aC)3 G(lass)-3 E F1(The)108 506.4 Q/F5
+11/Courier@0 SF(weather)5.528 E F1 2.778
+(class can be queried with normal relational selection and projection)
+5.528 F 3.033(queries. A)108 519.6 R F3(SQL)3.033 E F4(select)3.033 E F1
+.284(statement is used to do this.)3.033 F .284(The statement is di)
+5.784 F .284(vided into a)-.275 F/F6 11/Times-Italic@0 SF(tar)3.034 E
+-.11(ge)-.407 G(t).11 E(list)108 532.8 Q F1 .208
+(\(the part that lists the attrib)2.958 F .208
+(utes to be returned\) and a)-.22 F F6(quali\214cation)2.957 E F1 .207
+(\(the part that speci-)2.957 F(\214es an)108 546 Q 2.75(yr)-.165 G 2.75
+(estrictions\). F)-2.75 F(or e)-.165 E(xample, to retrie)-.165 E .33
+-.165(ve a)-.275 H(ll the ro).165 E(ws of)-.275 E F5(weather)2.75 E F1
+2.75(,t)C(ype:)-2.75 E F2(SELECT * FROM WEATHER;)148 571.2 Q F1
+(and the output should be:)108 596.4 Q .4 LW 464 613.9 148 613.9 DL F2
+63(city temp_lo)153 623.6 R 9(temp_hi prcp date)15 F 464 628.1 148 628.1
+DL(San Francisco)153 637.8 Q 39(46 50 0.25)15 F(11-27-1994)15 E 464
+642.3 148 642.3 DL(San Francisco)153 652 Q 39(43 57 0)15 F(11-29-1994)33
+E 464 656.5 148 656.5 DL 45(Hayward 37)153 666.2 R 78(54 11-29-1994)45 F
+464 670.7 148 670.7 DL 464 613.9 464 670.7 DL 148 613.9 148 670.7 DL
+391.5 613.9 391.5 670.7 DL 352.5 613.9 352.5 670.7 DL 295.5 613.9 295.5
+670.7 DL 238.5 613.9 238.5 670.7 DL F1 -1.21(Yo)108 696.3 S 2.75(um)1.21
+G(ay specify an)-2.75 E 2.75(ya)-.165 G(ribitrary e)-2.75 E
+(xpressions in the tar)-.165 E(get list. F)-.198 E(or e)-.165 E
+(xample, you can do:)-.165 E F4(13)282.5 756 Q EP
+%%Page: 14 14
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF 6(*S)148 96.2 S
+(ELECT city, \(temp_hi+temp_lo\)/2 AS temp_avg, date FROM weather;)-6 E
+/F1 11/Times-Roman@0 SF 1.411(Arbitrary Boolean operators \()108 126.3 R
+/F2 11/Times-Bold@0 SF(and)4.161 E F1(,)A F2(or)4.161 E F1(and)4.161 E
+F2(not)4.161 E F1 4.161(\)a)C 1.411(re allo)-4.161 F 1.411
+(wed in the quali\214cation of an)-.275 F(y)-.165 E(query)108 139.5 Q
+5.5(.F)-.715 G(or e)-5.665 E(xample,)-.165 E F0(SELECT *)148 164.7 Q
+(FROM weather)160 176.9 Q(WHERE city = 'San Francisco')160 189.1 Q
+(and prcp > 0.0;)178 201.3 Q .4 LW 464 231.8 148 231.8 DL 63
+(city temp_lo)153 241.5 R 9(temp_hi prcp date)15 F 464 246 148 246 DL
+(San Francisco)153 255.7 Q 39(46 50 0.25)15 F(11-27-1994)15 E 464 260.2
+148 260.2 DL 464 231.8 464 260.2 DL 148 231.8 148 260.2 DL 391.5 231.8
+391.5 260.2 DL 352.5 231.8 352.5 260.2 DL 295.5 231.8 295.5 260.2 DL
+238.5 231.8 238.5 260.2 DL F1 1.312
+(As a \214nal note, you can specify that the results of a)108 285.8 R F2
+(select)4.062 E F1 1.312(can be returned in a sorted)4.062 F
+(order or with duplicate instances remo)108 299 Q -.165(ve)-.165 G(d.)
+.165 E F0(SELECT DISTINCT city)148 324.2 Q(FROM weather)160 336.4 Q
+(ORDER BY city;)160 348.6 Q/F3 12/Times-Bold@0 SF 3(4.5. Redir)72 387.8
+R(ecting SELECT Queries)-.216 E F1(An)108 404.9 Q(y)-.165 E F2(select)
+2.75 E F1(query can be redirected to a ne)2.75 E 2.75(wc)-.275 G(lass)
+-2.75 E F0(SELECT * INTO temp from weather;)148 430.1 Q F1 1.177
+(This creates an implicit)108 460.2 R F2(cr)3.928 E(eate)-.198 E F1
+1.178(command, creating a ne)3.928 F 3.928(wc)-.275 G(lass)-3.928 E/F4
+11/Courier@0 SF(temp)3.928 E F1 1.178(with the attrib)3.928 F(ute)-.22 E
+1.316(names and types speci\214ed in the tar)108 473.4 R 1.315
+(get list of the)-.198 F F2 1.315(SELECT INT)4.065 F(O)-.198 E F1 4.065
+(command. W)4.065 F 4.065(ec)-.88 G(an)-4.065 E 1.632
+(then, of course, perform an)108 486.6 R 4.383(yo)-.165 G 1.633
+(perations on the resulting class that we can perform on)-4.383 F
+(other classes.)108 499.8 Q F3 3(4.6. J)72 526 R(oins Between Classes)
+-.18 E F1 .273(Thus f)108 543.1 R(ar)-.11 E 3.023(,o)-.44 G .273
+(ur queries ha)-3.023 F .603 -.165(ve o)-.22 H .273
+(nly accessed one class at a time.).165 F .272
+(Queries can access multiple)5.773 F .191
+(classes at once, or access the same class in such a w)108 556.3 R .191
+(ay that multiple instances of the class)-.11 F 1.49
+(are being processed at the same time.)108 569.5 R 4.24(Aq)6.99 G 1.489
+(uery that accesses multiple instances of the)-4.24 F(same or dif)108
+582.7 Q(ferent classes at one time is called a)-.275 E/F5 11
+/Times-Italic@0 SF(join query)2.75 E F1(.)A 1.057(As an e)108 599.8 R
+1.057(xample, say we wish to \214nd all the records that are in the tem\
+perature range of)-.165 F 1.094(other records. In ef)108 613 R 1.093
+(fect, we need to compare the)-.275 F F4(temp_lo)3.843 E F1(and)3.843 E
+F4(temp_hi)3.843 E F1(attrib)3.843 E 1.093(utes of)-.22 F(each)108 628.4
+Q F4(EMP)3.027 E F1 .277(instance to the)3.027 F F4(temp_lo)3.027 E F1
+(and)3.027 E F4(temp_hi)3.027 E F1(attrib)3.027 E .277
+(utes of all other)-.22 F F4(EMP)3.027 E F1(instances.)3.027 E/F6 8
+/Times-Roman@0 SF(2)-4.4 I F1 1.76 -.88(We c)108 641.6 T
+(an do this with the follo).88 E(wing query:)-.275 E F0
+(SELECT W1.city, W1.temp_lo, W1.temp_hi,)148 666.8 Q
+(W2.city, W2.temp_lo, W2.temp_hi)202 679 Q .32 LW 76 688.6 72 688.6 DL
+80 688.6 76 688.6 DL 84 688.6 80 688.6 DL 88 688.6 84 688.6 DL 92 688.6
+88 688.6 DL 96 688.6 92 688.6 DL 100 688.6 96 688.6 DL 104 688.6 100
+688.6 DL 108 688.6 104 688.6 DL 112 688.6 108 688.6 DL 116 688.6 112
+688.6 DL 120 688.6 116 688.6 DL 124 688.6 120 688.6 DL 128 688.6 124
+688.6 DL 132 688.6 128 688.6 DL 136 688.6 132 688.6 DL 140 688.6 136
+688.6 DL 144 688.6 140 688.6 DL 148 688.6 144 688.6 DL 152 688.6 148
+688.6 DL 156 688.6 152 688.6 DL 160 688.6 156 688.6 DL 164 688.6 160
+688.6 DL 168 688.6 164 688.6 DL 172 688.6 168 688.6 DL 176 688.6 172
+688.6 DL 180 688.6 176 688.6 DL 184 688.6 180 688.6 DL 188 688.6 184
+688.6 DL 192 688.6 188 688.6 DL 196 688.6 192 688.6 DL 200 688.6 196
+688.6 DL 204 688.6 200 688.6 DL 208 688.6 204 688.6 DL 212 688.6 208
+688.6 DL 216 688.6 212 688.6 DL/F7 5/Times-Roman@0 SF(2)93.6 699 Q F6
+.094(This is only a conceptual model.)2.094 3.2 N .095
+(The actual join may be performed in a more ef)4.095 F .095
+(\214cient manner)-.2 F 2.095(,b)-.32 G .095(ut this is in)-2.255 F .095
+(visible to the user)-.32 F(.)-.44 E F2(14)282.5 756 Q EP
+%%Page: 15 15
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(FROM weather W1, weather W2)148 96.2 Q
+(WHERE W1.temp_lo < W2.temp_lo)148 108.4 Q(and W1.temp_hi > W2.temp_hi;)
+178 120.6 Q .4 LW 557 151.1 148 151.1 DL 63(city temp_lo)153 160.8 R 9
+(temp_hi city)15 F 9(temp_lo temp_hi)69 F 557 165.3 148 165.3 DL
+(San Francisco)153 175 Q 39(43 57 San)15 F 9(Francisco 46)6 F(50)45 E
+557 179.5 148 179.5 DL(San Francisco)153 189.2 Q 39(37 54 San)15 F 9
+(Francisco 46)6 F(50)45 E 557 193.7 148 193.7 DL 557 151.1 557 193.7 DL
+148 151.1 148 193.7 DL 502.5 151.1 502.5 193.7 DL 445.5 151.1 445.5
+193.7 DL 352.5 151.1 352.5 193.7 DL 295.5 151.1 295.5 193.7 DL 238.5
+151.1 238.5 193.7 DL/F1 11/Times-Roman@0 SF .966(In this case, both)108
+215.4 R/F2 11/Courier@0 SF(W1)3.716 E F1(and)3.716 E F2(W2)3.716 E F1
+(are)3.716 E/F3 11/Times-Italic@0 SF(surr)3.716 E -.11(og)-.495 G(ates)
+.11 E F1 .966(for an instance of the class)3.716 F F2(weather)3.716 E F1
+3.716(,a)C(nd)-3.716 E .53(both range o)108 228.6 R -.165(ve)-.165 G
+3.28(ra).165 G .53(ll instances of the class.)-3.28 F .529
+(\(In the terminology of most database systems,)6.03 F F2(W1)108 241.8 Q
+F1(and)3.184 E F2(W2)3.184 E F1 .434(are kno)3.184 F .434
+(wn as \231range v)-.275 F(ariables.)-.275 E 3.184(\232\) A)-.77 F .434
+(query can contain an arbitrary number of)3.184 F
+(class names and surrog)108 257.2 Q(ates.)-.055 E/F4 8/Times-Roman@0 SF
+(3)-4.4 I/F5 12/Times-Bold@0 SF 3(4.7. Updates)72 283.4 R F1 -1.21(Yo)
+108 300.5 S 3.226(uc)1.21 G .476(an update e)-3.226 F .476
+(xisting instances using the)-.165 F/F6 11/Times-Bold@0 SF(update)3.226
+E F1 .475(command. Suppose you disco)3.226 F -.165(ve)-.165 G 3.225(rt)
+.165 G(he)-3.225 E .94(temperature readings are all of)108 313.7 R 3.69
+(fb)-.275 G 3.69(y2d)-3.69 G -.165(eg)-3.69 G .94(rees as of No).165 F
+3.69(v2)-.165 G .94(8, you may update the data as)-3.69 F(follo)108
+326.9 Q(w:)-.275 E F0 6(*U)148 352.1 S(PDATE weather)-6 E
+(SET temp_hi = temp_hi - 2,)160 364.3 Q(temp_lo = temp_lo - 2)12 E
+(WHERE date > '11/28/1994;)160 376.5 Q F5 3(4.8. Deletions)72 415.7 R F1
+(Deletions are performed using the)108 432.8 Q F6(delete)2.75 E F1
+(command:)2.75 E F0 6(*D)148 458 S
+(ELETE FROM weather WHERE city = 'Hayward';)-6 E F1
+(All weather recording belongs to Hayw)108 484.2 Q(ard is remo)-.11 E
+-.165(ve)-.165 G(d.).165 E(One should be w)108 501.3 Q
+(ary of queries of the form)-.11 E F0(DELETE FROM)148 526.5 Q/F7 10
+/Times-Italic@0 SF(classname;)6 E F1 -.44(Wi)108 552.7 S .494
+(thout a quali\214cation, the).44 F F6(delete)3.244 E F1 .493
+(command will simply delete all instances of the gi)3.243 F -.165(ve)
+-.275 G(n).165 E(class, lea)108 565.9 Q(ving it empty)-.22 E 5.5(.T)
+-.715 G(he system)-5.5 E F6(will not r)2.75 E(equest con\214rmation)
+-.198 E F1(before doing this.)2.75 E F5 3(4.9. Using)72 592.1 R(Aggr)3 E
+(egate Functions)-.216 E F1(Lik)108 609.2 Q 2.854(em)-.11 G .104
+(ost other query languages,)-2.854 F/F8 10/Times-Roman@0 SF(POSTGRES)
+2.854 E F1 .104(supports aggre)2.854 F -.055(ga)-.165 G .104
+(te functions.).055 F(Ho)5.604 E(we)-.275 E -.165(ve)-.275 G .985 -.44
+(r, t).165 H(he).44 E 1.225(current implementation of)108 622.4 R F8
+(POSTGRES)3.974 E F1(aggre)3.974 E -.055(ga)-.165 G 1.224
+(te functions is v).055 F 1.224(ery limited.)-.165 F(Speci\214cally)
+6.724 E(,)-.715 E 3.444(while there are aggre)108 635.6 R -.055(ga)-.165
+G 3.444(tes to compute such functions as the count, sum, a).055 F -.165
+(ve)-.22 G(rage,).165 E .32 LW 76 645.2 72 645.2 DL 80 645.2 76 645.2 DL
+84 645.2 80 645.2 DL 88 645.2 84 645.2 DL 92 645.2 88 645.2 DL 96 645.2
+92 645.2 DL 100 645.2 96 645.2 DL 104 645.2 100 645.2 DL 108 645.2 104
+645.2 DL 112 645.2 108 645.2 DL 116 645.2 112 645.2 DL 120 645.2 116
+645.2 DL 124 645.2 120 645.2 DL 128 645.2 124 645.2 DL 132 645.2 128
+645.2 DL 136 645.2 132 645.2 DL 140 645.2 136 645.2 DL 144 645.2 140
+645.2 DL 148 645.2 144 645.2 DL 152 645.2 148 645.2 DL 156 645.2 152
+645.2 DL 160 645.2 156 645.2 DL 164 645.2 160 645.2 DL 168 645.2 164
+645.2 DL 172 645.2 168 645.2 DL 176 645.2 172 645.2 DL 180 645.2 176
+645.2 DL 184 645.2 180 645.2 DL 188 645.2 184 645.2 DL 192 645.2 188
+645.2 DL 196 645.2 192 645.2 DL 200 645.2 196 645.2 DL 204 645.2 200
+645.2 DL 208 645.2 204 645.2 DL 212 645.2 208 645.2 DL 216 645.2 212
+645.2 DL/F9 5/Times-Roman@0 SF(3)93.6 655.6 Q F4 .265
+(The semantics of such a join are that the quali\214cation is a truth e)
+2.265 3.2 N .264
+(xpression de\214ned for the Cartesian product of the classes in-)-.12 F
+.273(dicated in the query)72 668.4 R 4.273(.F)-.52 G .273(or those inst\
+ances in the Cartesian product for which the quali\214cation is true,)
+-4.393 F/F10 7/Times-Roman@0 SF(POSTGRES)2.274 E F4 .274
+(computes and returns)2.274 F .98(the v)72 678 R .98
+(alues speci\214ed in the tar)-.2 F .979(get list.)-.144 F F10(POSTGRES)
+4.979 E F4 .979(SQL does not assign an)2.979 F 2.979(ym)-.12 G .979
+(eaning to duplicate v)-2.979 F .979(alues in such e)-.2 F 2.979
+(xpressions. This)-.12 F .344(means that)72 687.6 R F10(POSTGRES)2.344 E
+F4 .344(sometimes recomputes the same tar)2.344 F .344(get list se)-.144
+F -.12(ve)-.2 G .344
+(ral times \212 this frequently happens when Boolean e).12 F(xpressions)
+-.12 E(are connected with an)72 697.2 Q/F11 8/Times-Bold@0 SF(or)2 E F4
+4(.T)C 2(or)-4.64 G(emo)-2 E .24 -.12(ve s)-.12 H
+(uch duplicates, you must use the).12 E F11(select distinct)2 E F4
+(statement.)2 E F6(15)282.5 756 Q EP
+%%Page: 16 16
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF .561(maximum and minimum o)108 97.2 R -.165(ve)
+-.165 G 3.31(ras).165 G .56(et of instances, aggre)-3.31 F -.055(ga)
+-.165 G .56(tes can only appear in the tar).055 F(get)-.198 E
+(list of a query and not in the quali\214cation \()108 110.4 Q/F1 11
+/Courier@0 SF(where)2.75 E F0(clause\) As an e)2.75 E(xample,)-.165 E/F2
+10/Courier@0 SF(SELECT max\(temp_lo\))148 135.6 Q(FROM weather;)148
+147.8 Q F0(Aggre)108 174 Q -.055(ga)-.165 G(tes may also ha).055 E .33
+-.165(ve G)-.22 H -.44(RO).165 G(UP BY clauses:).44 E F2
+(SELECT city, max\(temp_lo\))148 199.2 Q(FROM weather)148 211.4 Q
+(GROUP BY city;)148 223.6 Q/F3 11/Times-Bold@0 SF(16)282.5 756 Q EP
+%%Page: 17 17
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(5. AD)72 165.4 R -2.565(VA)-.76 G
+(NCED POSTGRES SQL FEA)2.565 E(TURES)-1.805 E 77.5 178.6 72 178.6 DL
+80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97
+178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL
+113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6
+DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5
+178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6
+152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6
+168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5
+178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207
+178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL
+223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6
+DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5
+178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6
+262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6
+278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5
+178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317
+178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL
+333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6
+DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5
+178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6
+372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6
+388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5
+178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427
+178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL
+443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6
+DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5
+178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6
+482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6
+498.5 178.6 DL/F1 11/Times-Roman@0 SF(Ha)108 208.9 Q .065(ving co)-.22 F
+-.165(ve)-.165 G .065(red the basics of using).165 F/F2 10/Times-Roman@0
+SF(POSTGRES)2.816 E F1 .066(SQL to access your data, we will no)2.816 F
+2.816(wd)-.275 G(is-)-2.816 E 1.624(cuss those features of)108 222.1 R
+F2(POSTGRES)4.374 E F1 1.624(that distinguish it from con)4.374 F -.165
+(ve)-.44 G 1.623(ntional data managers.).165 F 1.681
+(These features include inheritance, time tra)108 235.3 R -.165(ve)-.22
+G 4.431(la).165 G 1.681(nd non-atomic data v)-4.431 F 1.681
+(alues \(array- and)-.275 F(set-v)108 248.5 Q(alued attrib)-.275 E
+(utes\).)-.22 E 1.195(Examples in this section can also be found in)108
+265.6 R/F3 11/Courier@0 SF(advance.sql)3.945 E F1 1.194
+(in the tutorial directory)3.945 F(.)-.715 E
+(\(Refer to the introduction of the pre)108 278.8 Q
+(vious chapter for ho)-.275 E 2.75(wt)-.275 G 2.75(ou)-2.75 G(se it.\))
+-2.75 E/F4 12/Times-Bold@0 SF 3(5.1. Inheritance)72 305 R F1(Let')108
+322.1 Q 4.858(sc)-.605 G 2.108(reate tw)-4.858 F 4.858(oc)-.11 G 2.108
+(lasses. The)-4.858 F F3(capitals)4.858 E F1 2.109
+(class contains state capitals which are also)4.858 F(cities. Naturally)
+108 335.3 Q 2.75(,t)-.715 G(he)-2.75 E F3(capitals)2.75 E F1
+(class should)2.75 E/F5 11/Times-Italic@0 SF(inherit)2.75 E F1(from)2.75
+E F3(cities)2.75 E F1(.)A/F6 10/Courier@0 SF(CREATE TABLE cities \()148
+360.5 Q 66(name text,)196 372.7 R 30(population float,)196 384.9 R 42
+(altitude int)196 397.1 R(-- \(in ft\))72 E(\);)148 409.3 Q
+(CREATE TABLE capitals \()148 433.7 Q 60(state char2)196 445.9 R 6(\)I)
+148 458.1 S(NHERITS \(cities\);)-6 E F1 .424
+(In this case, an instance of)108 488.2 R F3(capitals)3.174 E F5
+(inherits)3.173 E F1 .423(all attrib)3.173 F .423(utes \()-.22 F F3
+(name)A F1(,)A F3(population)3.173 E F1 3.173(,a)C(nd)-3.173 E F3
+(altitude)108 501.4 Q F1 3.006(\)f)C .256(rom its parent,)-3.006 F F3
+(cities)3.006 E F1 5.756(.T)C .256(he type of the attrib)-5.756 F(ute)
+-.22 E F3(name)3.006 E F1(is)3.006 E F3(text,)3.006 E F1 3.007(ab)3.007
+G(uilt-)-3.227 E(in)108 514.6 Q F2(POSTGRES)2.935 E F1 .185(type for v)
+2.935 F .185(ariable length ASCII strings.)-.275 F .185
+(The type of the attrib)5.685 F(ute)-.22 E F3(popula-)2.935 E(tion)108
+527.8 Q F1(is)3.958 E F3(float4,)3.958 E F1 3.959(ab)3.958 G(uilt-in)
+-4.179 E F2(POSTGRES)3.959 E F1 1.209
+(type for double precision \215oating point num-)3.959 F 2.89
+(bres. State)108 541 R .14(capitals ha)2.89 F .47 -.165(ve a)-.22 H
+2.889(ne).165 G .139(xtra attrib)-3.054 F(ute,)-.22 E F3(state)2.889 E
+F1 2.889(,t)C .139(hat sho)-2.889 F .139(ws their state.)-.275 F(In)
+5.639 E F2(POSTGRES)2.889 E F1(,)A 3.482(ac)108 556.4 S .732
+(lass can inherit from zero or more other classes,)-3.482 F/F7 8
+/Times-Roman@0 SF(4)-4.4 I F1 .733(and a query can reference either all)
+3.483 4.4 N .095(instances of a class or all instances of a class plus \
+all of its descendants.)108 569.6 R -.165(Fo)5.595 G 2.845(re).165 G
+.095(xample, the)-3.01 F(follo)108 582.8 Q(wing query \214nds all the c\
+ities that are situated at an attitude of 500 'ft or higher:)-.275 E F6
+(SELECT name, altitude)148 608 Q(FROM cities)148 620.2 Q
+(WHERE altitude > 500;)148 632.4 Q .32 LW 76 668.001 72 668.001 DL 80
+668.001 76 668.001 DL 84 668.001 80 668.001 DL 88 668.001 84 668.001 DL
+92 668.001 88 668.001 DL 96 668.001 92 668.001 DL 100 668.001 96 668.001
+DL 104 668.001 100 668.001 DL 108 668.001 104 668.001 DL 112 668.001 108
+668.001 DL 116 668.001 112 668.001 DL 120 668.001 116 668.001 DL 124
+668.001 120 668.001 DL 128 668.001 124 668.001 DL 132 668.001 128
+668.001 DL 136 668.001 132 668.001 DL 140 668.001 136 668.001 DL 144
+668.001 140 668.001 DL 148 668.001 144 668.001 DL 152 668.001 148
+668.001 DL 156 668.001 152 668.001 DL 160 668.001 156 668.001 DL 164
+668.001 160 668.001 DL 168 668.001 164 668.001 DL 172 668.001 168
+668.001 DL 176 668.001 172 668.001 DL 180 668.001 176 668.001 DL 184
+668.001 180 668.001 DL 188 668.001 184 668.001 DL 192 668.001 188
+668.001 DL 196 668.001 192 668.001 DL 200 668.001 196 668.001 DL 204
+668.001 200 668.001 DL 208 668.001 204 668.001 DL 212 668.001 208
+668.001 DL 216 668.001 212 668.001 DL/F8 5/Times-Roman@0 SF(4)93.6
+678.401 Q F7(I.e., the inheritance hierarch)2 3.2 M 2(yi)-.04 G 2(sad)-2
+G(irected ac)-2 E(yclic graph.)-.12 E/F9 11/Times-Bold@0 SF(17)282.5 756
+Q EP
+%%Page: 18 18
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.4 LW 275 88.5 148 88.5 DL/F0 10/Courier@0 SF 39(name altitude)153 98.2
+R 275 102.7 148 102.7 DL(Las Vegas)153 112.4 Q(2174)15 E 275 116.9 148
+116.9 DL 15(Mariposa 1953)153 126.6 R 275 131.1 148 131.1 DL 275 88.5
+275 131.1 DL 148 88.5 148 131.1 DL 214.5 88.5 214.5 131.1 DL/F1 11
+/Times-Roman@0 SF .328(On the other hand, to \214nd the names of all ci\
+ties, including state capitals, that are located)108 152.8 R
+(at an altitude o)108 166 Q -.165(ve)-.165 G 2.75(r5).165 G
+(00 'ft, the query is:)-2.75 E F0(SELECT c.name, c.altitude)148 191.2 Q
+(FROM cities* c)148 203.4 Q(WHERE c.altitude > 500;)148 215.6 Q F1
+(which returns:)108 240.8 Q 275 258.3 148 258.3 DL F0 39(name altitude)
+153 268 R 275 272.5 148 272.5 DL(Las Vegas)153 282.2 Q(2174)15 E 275
+286.7 148 286.7 DL 15(Mariposa 1953)153 296.4 R 275 300.9 148 300.9 DL
+21(Madison 845)153 310.6 R 275 315.1 148 315.1 DL 275 258.3 275 315.1 DL
+148 258.3 148 315.1 DL 214.5 258.3 214.5 315.1 DL F1 1.294(Here the)108
+336.8 R/F2 11/Courier@0 SF(*)4.044 E F1(after)4.044 E F2(cities)4.044 E
+F1 1.294(indicates that the query should be run o)4.044 F -.165(ve)-.165
+G(r).165 E F2(cities)4.043 E F1 1.293(and all)4.043 F .067(classes belo)
+108 350 R(w)-.275 E F2(cities)2.817 E F1 .068
+(in the inheritance hierarch)2.817 F 4.248 -.715(y. M)-.055 H(an).715 E
+2.818(yo)-.165 G 2.818(ft)-2.818 G .068(he commands that we ha)-2.818 F
+-.165(ve)-.22 G .907(already discussed \212)108 363.2 R/F3 11
+/Times-Bold@0 SF(select)3.657 E F1(,)A F3(update)3.657 E F1(and)3.657 E
+F3(delete)3.657 E F1 3.657<8a73>3.657 G .907(upport this)-3.657 F F2(*)
+3.657 E F1 .906(notation, as do others,)3.656 F(lik)108 376.4 Q(e)-.11 E
+F3(alter)2.75 E F1(command.)2.75 E/F4 12/Times-Bold@0 SF 3(5.2. T)72
+402.6 R(ime T)-.216 E(ra)-.888 E -.12(ve)-.3 G(l).12 E/F5 10
+/Times-Roman@0 SF(POSTGRES)108 419.7 Q F1 .259(supports the notion of)
+3.009 F/F6 11/Times-Italic@0 SF .26(time tr)3.01 F(avel)-.165 E F1 5.76
+(.T)C .26(his feature allo)-5.76 F .26(ws a user to run historical)-.275
+F 2.75(queries. F)108 432.9 R(or e)-.165 E
+(xample, to \214nd the current population of Mariposa city)-.165 E 2.75
+(,o)-.715 G(ne w)-2.75 E(ould query:)-.11 E F0
+(SELECT * FROM cities WHERE name = 'Mariposa';)148 458.1 Q 344 488.6 148
+488.6 DL 33(name population)153 498.3 R(altitude)15 E 344 502.8 148
+502.8 DL 9(Mariposa 1320)153 512.5 R(1953)51 E 344 517 148 517 DL 344
+488.6 344 517 DL 148 488.6 148 517 DL 283.5 488.6 283.5 517 DL 208.5
+488.6 208.5 517 DL F5(POSTGRES)108 538.7 Q F1 1.068
+(will automatically \214nd the v)3.818 F 1.068(ersion of Mariposa')-.165
+F 3.817(sr)-.605 G 1.067(ecord v)-3.817 F 1.067(alid at the current)
+-.275 F(time.)108 551.9 Q .794(One can also gi)108 569 R 1.124 -.165
+(ve a t)-.275 H(ime).165 E F6 -.165(ra)3.545 G(ng).165 E(e)-.11 E F1
+6.295(.F)C .795(or e)-6.46 F .795
+(xample to see the past and present populations of)-.165 F
+(Mariposa, one w)108 582.2 Q(ould query:)-.11 E F0
+(SELECT name, population)148 607.4 Q(FROM cities['epoch', 'now'])148
+619.6 Q(WHERE name = 'Mariposa';)148 631.8 Q F1 .81
+(where \231epoch\232 indicates the be)108 660.2 R .81
+(ginning of the system clock.)-.165 F/F7 8/Times-Roman@0 SF(5)-4.4 I F1
+.809(If you ha)3.559 4.4 N 1.139 -.165(ve exe)-.22 H .809(cuted all of)
+.165 F(the e)108 672.4 Q(xamples so f)-.165 E(ar)-.11 E 2.75(,t)-.44 G
+(hen the abo)-2.75 E .33 -.165(ve q)-.165 H(uery returns:).165 E .32 LW
+76 682 72 682 DL 80 682 76 682 DL 84 682 80 682 DL 88 682 84 682 DL 92
+682 88 682 DL 96 682 92 682 DL 100 682 96 682 DL 104 682 100 682 DL 108
+682 104 682 DL 112 682 108 682 DL 116 682 112 682 DL 120 682 116 682 DL
+124 682 120 682 DL 128 682 124 682 DL 132 682 128 682 DL 136 682 132 682
+DL 140 682 136 682 DL 144 682 140 682 DL 148 682 144 682 DL 152 682 148
+682 DL 156 682 152 682 DL 160 682 156 682 DL 164 682 160 682 DL 168 682
+164 682 DL 172 682 168 682 DL 176 682 172 682 DL 180 682 176 682 DL 184
+682 180 682 DL 188 682 184 682 DL 192 682 188 682 DL 196 682 192 682 DL
+200 682 196 682 DL 204 682 200 682 DL 208 682 204 682 DL 212 682 208 682
+DL 216 682 212 682 DL/F8 5/Times-Roman@0 SF(5)93.6 692.4 Q F7(On)2 3.2 M
+/F9 7/Times-Roman@0 SF(UNIX)2 E F7(systems, this is al)2 E -.08(wa)-.08
+G(ys midnight, January 1, 1970 GMT).08 E(.)-.592 E F3(18)282.5 756 Q EP
+%%Page: 19 19
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.4 LW 281 88.5 148 88.5 DL/F0 10/Courier@0 SF 33(name population)153
+98.2 R 281 102.7 148 102.7 DL 9(Mariposa 1200)153 112.4 R 281 116.9 148
+116.9 DL 9(Mariposa 1320)153 126.6 R 281 131.1 148 131.1 DL 281 88.5 281
+131.1 DL 148 88.5 148 131.1 DL 208.5 88.5 208.5 131.1 DL/F1 11
+/Times-Roman@0 SF .247(The def)108 156.7 R .247(ault be)-.11 F .247(gin\
+ning of a time range is the earliest time representable by the system a\
+nd)-.165 F 2.009(the def)108 169.9 R 2.009
+(ault end is the current time; thus, the abo)-.11 F 2.338 -.165(ve t)
+-.165 H 2.008(ime range can be abbre).165 F 2.008(viated as)-.275 F
+-.814(``)108 183.1 S/F2 11/Courier@0 SF([,]).814 E F1 -.77(.')C(')-.044
+E/F3 12/Times-Bold@0 SF 3(5.3. Non-Atomic)72 209.3 R -1.104(Va)3 G(lues)
+1.104 E F1 1.373
+(One of the tenets of the relational model is that the attrib)108 226.4
+R 1.374(utes of a relation are)-.22 F/F4 11/Times-Italic@0 SF(atomic)
+4.124 E F1(.)A/F5 10/Times-Roman@0 SF(POSTGRES)108 239.6 Q F1 1.647
+(does not ha)4.397 F 1.976 -.165(ve t)-.22 H 1.646
+(his restriction; attrib).165 F 1.646(utes can themselv)-.22 F 1.646
+(es contain sub-v)-.165 F(alues)-.275 E .112
+(that can be accessed from the query language.)108 252.8 R -.165(Fo)
+5.612 G 2.862(re).165 G .113(xample, you can create attrib)-3.027 F .113
+(utes that)-.22 F(are)108 266 Q F4(arr)2.75 E(ays)-.165 E F1
+(of base types.)2.75 E F3 3(5.3.1. Arrays)72 292.2 R F5(POSTGRES)108
+309.3 Q F1(allo)4.98 E 2.23(ws attrib)-.275 F 2.23
+(utes of an instance to be de\214ned as \214x)-.22 F 2.23
+(ed-length or v)-.165 F(ariable-)-.275 E .319
+(length multi-dimensional arrays. Arrays of an)108 322.5 R 3.069(yb)
+-.165 G .319(ase type or user)-3.069 F .319(-de\214ned type can be cre-)
+-.22 F(ated. T)108 335.7 Q 2.75(oi)-.88 G(llustrate their use, we \214r\
+st create a class with arrays of base types.)-2.75 E F0 6(*C)148 360.9 S
+(REATE TABLE SAL_EMP \()-6 E 66(name text,)196 373.1 R 6
+(pay_by_quarter int4[],)196 385.3 R 42(schedule char16[][])196 397.5 R
+(\);)148 409.7 Q F1 .313(The abo)108 435.9 R .643 -.165(ve q)-.165 H
+.313(uery will create a class named).165 F F2(SAL_EMP)3.062 E F1 .312
+(with a)3.062 F F2(text)3.062 E F1 .312(string \()3.062 F F2(name)A F1
+.312(\), a one-)B 3.084(dimensional array of)108 449.1 R F2(int4)5.834 E
+F1(\()5.834 E F2(pay_by_quarter)A F1 3.084
+(\), which represents the emplo)B(yee')-.11 E(s)-.605 E 1.396
+(salary by quarter and a tw)108 462.3 R 1.396(o-dimensional array of)
+-.11 F F2(char16)4.146 E F1(\()4.146 E F2(schedule)A F1 1.396
+(\), which repre-)B 1.737(sents the emplo)108 475.5 R(yee')-.11 E 4.487
+(sw)-.605 G 1.737(eekly schedule.)-4.487 F(No)7.237 E 4.487(ww)-.275 G
+4.487(ed)-4.487 G 4.487(os)-4.487 G(ome)-4.487 E F2(INSERTS)4.487 E F1
+1.737(s; note that when)B .034(appending to an array)108 488.7 R 2.784
+(,w)-.715 G 2.784(ee)-2.784 G .034(nclose the v)-2.784 F .034
+(alues within braces and separate them by commas.)-.275 F(If you kno)108
+501.9 Q 2.75(wC)-.275 G 2.75(,t)-2.75 G(his is not unlik)-2.75 E 2.75
+(et)-.11 G(he syntax for initializing structures.)-2.75 E F0
+(INSERT INTO SAL_EMP)148 527.1 Q(VALUES \('Bill',)178 539.3 Q
+('{10000, 10000, 10000, 10000}',)226 551.5 Q
+('{{"meeting", "lunch"}, {}}'\);)226 563.7 Q(INSERT INTO SAL_EMP)148
+588.1 Q(VALUES \('Carol',)178 600.3 Q('{20000, 25000, 25000, 25000}',)
+226 612.5 Q('{{"talk", "consult"}, {"meeting"}}'\);)226 624.7 Q F1 .582
+(By def)108 650.9 R(ault,)-.11 E F5(POSTGRES)3.332 E F1 .583
+(uses the \231one-based\232 numbering con)3.332 F -.165(ve)-.44 G .583
+(ntion for arrays \212 that is,).165 F(an array of)108 664.1 Q F4(n)
+3.146 E F1(elements starts with array[1] and ends with array[)3.014 E F4
+(n).396 E F1(].).264 E(No)108 681.2 Q 1.852 -.715(w, w)-.275 H 3.172(ec)
+.715 G .422(an run some queries on)-3.172 F F2(SAL_EMP)3.172 E F1 5.921
+(.F)C .421(irst, we sho)-5.921 F 3.171(wh)-.275 G .971 -.275(ow t)-3.171
+H 3.171(oa).275 G .421(ccess a single ele-)-3.171 F .803
+(ment of an array at a time.)108 694.4 R .804(This query retrie)6.304 F
+-.165(ve)-.275 G 3.554(st).165 G .804(he names of the emplo)-3.554 F
+.804(yees whose pay)-.11 F(changed in the second quarter:)108 707.6 Q/F6
+11/Times-Bold@0 SF(19)282.5 756 Q EP
+%%Page: 20 20
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF 6(*S)148 96.2 S(ELECT name)-6 E(FROM SAL_EMP)160
+108.4 Q(WHERE SAL_EMP.pay_by_quarter[1] <>)160 120.6 Q
+(SAL_EMP.pay_by_quarter[2];)208 132.8 Q .4 LW 188 163.3 148 163.3 DL
+(name)153 173 Q 188 177.5 148 177.5 DL(Carol)153 187.2 Q 188 191.7 148
+191.7 DL 188 163.3 188 191.7 DL 148 163.3 148 191.7 DL/F1 11
+/Times-Roman@0 SF(This query retrie)108 213.4 Q -.165(ve)-.275 G 2.75
+(st).165 G(he third quarter pay of all emplo)-2.75 E(yees:)-.11 E F0 6
+(*S)148 238.6 S(ELECT SAL_EMP.pay_by_quarter[3] FROM SAL_EMP;)-6 E 242
+269.1 148 269.1 DL(pay_by_quarter)153 278.8 Q 242 283.3 148 283.3 DL
+(10000)153 293 Q 242 297.5 148 297.5 DL(25000)153 307.2 Q 242 311.7 148
+311.7 DL 242 269.1 242 311.7 DL 148 269.1 148 311.7 DL F1 1.873 -.88
+(We c)108 333.4 T .113(an also access arbitrary).88 F/F2 11
+/Times-Italic@0 SF(slices)2.863 E F1 .113(of an array)2.863 F 2.863(,o)
+-.715 G(r)-2.863 E F2(subarr)2.863 E(ays)-.165 E F1 5.613(.T)C .113
+(his query retrie)-5.613 F -.165(ve)-.275 G 2.863(st).165 G .112
+(he \214rst)-2.863 F(item on Bill')108 346.6 Q 2.75(ss)-.605 G
+(chedule for the \214rst tw)-2.75 E 2.75(od)-.11 G(ays of the week.)
+-2.75 E F0 6(*S)148 371.8 S(ELECT SAL_EMP.schedule[1:2][1:1])-6 E
+(FROM SAL_EMP)160 384 Q(WHERE SAL_EMP.name = 'Bill';)160 396.2 Q 266
+426.7 148 426.7 DL(schedule)153 436.4 Q 266 440.9 148 440.9 DL
+({{"meeting"},{""}})153 450.6 Q 266 455.1 148 455.1 DL 266 426.7 266
+455.1 DL 148 426.7 148 455.1 DL/F3 11/Times-Bold@0 SF(20)282.5 756 Q EP
+%%Page: 21 21
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(6. EXTENDING)72 165.4 R(SQL: AN O)
+4.75 E(VER)-.95 E(VIEW)-1.045 E 77.5 178.6 72 178.6 DL 80.5 178.6 75
+178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5
+178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6
+108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6
+124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5
+178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163
+178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL
+179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6
+DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5
+178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6
+218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6
+234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5
+178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273
+178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL
+289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6
+DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5
+178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6
+328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6
+344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5
+178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383
+178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL
+399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6
+DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5
+178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6
+438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6
+454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5
+178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493
+178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL
+/F1 11/Times-Roman@0 SF 1.923(In the sections that follo)108 208.9 R
+3.353 -.715(w, w)-.275 H 4.673(ew).715 G 1.923(ill discuss ho)-4.673 F
+4.673(wy)-.275 G 1.923(ou can e)-4.673 F 1.923(xtend the)-.165 F/F2 10
+/Times-Roman@0 SF(POSTGRES)4.674 E F1(SQL)4.674 E
+(query language by adding:)108 222.1 Q 5.5<8366>113.5 239.2 S(unctions)
+-5.5 E 5.5<8374>113.5 252.4 S(ypes)-5.5 E 5.5<836f>113.5 265.6 S
+(perators)-5.5 E 5.5<8361>113.5 278.8 S(ggre)-5.5 E -.055(ga)-.165 G
+(tes).055 E/F3 12/Times-Bold@0 SF 3(6.1. Ho)72 305 R 3(wE)-.12 G
+(xtensibility W)-3 E(orks)-.9 E F2(POSTGRES)108 322.1 Q F1 .453(is e)
+3.203 F .453(xtensible because its operation is)-.165 F/F4 11
+/Times-Italic@0 SF(catalo)3.202 E(g-driven)-.11 E F1 5.952(.I)C 3.202
+(fy)-5.952 G .452(ou are f)-3.202 F .452(amiliar with)-.11 F .211
+(standard relational systems, you kno)108 335.3 R 2.961(wt)-.275 G .211
+(hat the)-2.961 F 2.961(ys)-.165 G .211
+(tore information about databases, tables,)-2.961 F .408
+(columns, etc., in what are commonly kno)108 348.5 R .408(wn as)-.275 F
+F4 .408(system catalo)3.158 F(gs)-.11 E F1 5.908(.\()C .407
+(Some systems call this)-5.908 F(the)108 361.7 Q F4 1.187
+(data dictionary)3.937 F F1 3.937(\). The)B 1.187
+(catalogs appear to the user as classes, lik)3.937 F 3.938(ea)-.11 G
+1.518 -.165(ny o)-3.938 H(ther).165 E 3.938(,b)-.44 G 1.188(ut the)
+-4.158 F .658(DBMS stores its internal bookk)108 374.9 R .658
+(eeping in them.)-.11 F .657(One k)6.158 F .987 -.165(ey d)-.11 H(if)
+.165 E .657(ference between)-.275 F F2(POSTGRES)3.407 E F1 1.334
+(and standard relational systems is that)108 388.1 R F2(POSTGRES)4.084 E
+F1 1.335(stores much more information in its)4.084 F .253
+(catalogs \212 not only information about tables and columns, b)108
+401.3 R .253(ut also information about its)-.22 F .778
+(types, functions, access methods, and so on.)108 414.5 R .778
+(These classes can be modi\214ed by the user)6.278 F(,)-.44 E .625
+(and since)108 427.7 R F2(POSTGRES)3.375 E F1 .624
+(bases its internal operation on these classes, this means that)3.375 F
+F2(POST)3.374 E(-)-.92 E(GRES)108 440.9 Q F1 .205(can be e)2.955 F .205
+(xtended by users.)-.165 F .206(By comparison, con)5.706 F -.165(ve)-.44
+G .206(ntional database systems can only).165 F .07(be e)108 454.1 R .07
+(xtended by changing hard-coded procedures within the DBMS or by loadin\
+g modules)-.165 F(specially-written by the DBMS v)108 467.3 Q(endor)
+-.165 E(.)-.605 E F2(POSTGRES)108 484.4 Q F1 1.749(is also unlik)4.499 F
+4.499(em)-.11 G 1.75(ost other data managers in that the serv)-4.499 F
+1.75(er can incorporate)-.165 F(user)108 497.6 Q 1.338
+(-written code into itself through)-.22 F F4 1.338(dynamic loading)4.088
+F F1 6.838(.T)C 1.338(hat is, the user can specify an)-6.838 F .323
+(object code \214le \(e.g., a compiled)108 510.8 R/F5 11/Courier@0 SF
+(.o)3.073 E F1 .323(\214le or shared library\) that implements a ne)
+3.073 F 3.074(wt)-.275 G .324(ype or)-3.074 F 1.527(function and)108 524
+R F2(POSTGRES)4.277 E F1 1.527(will load it as required.)4.277 F 1.526
+(Code written in SQL are e)7.026 F -.165(ve)-.275 G 4.276(nm).165 G(ore)
+-4.276 E(tri)108 537.2 Q(vial to add to the serv)-.275 E(er)-.165 E(.)
+-.605 E 1.451
+(This ability to modify its operation \231on the \215y\232 mak)108 554.3
+R(es)-.11 E F2(POSTGRES)4.201 E F1 1.451(uniquely suited for)4.201 F
+(rapid prototyping of ne)108 567.5 Q 2.75(wa)-.275 G
+(pplications and storage structures.)-2.75 E F3 3(6.2. The)72 593.7 R/F6
+11/Times-Bold@0 SF(POSTGRES)3 E F3 -.888(Ty)3 G(pe System).888 E F1(The)
+108 610.8 Q F2(POSTGRES)2.75 E F1(type system can be brok)2.75 E(en do)
+-.11 E(wn in se)-.275 E -.165(ve)-.275 G(ral w).165 E(ays.)-.11 E -.88
+(Ty)108 627.9 S .435(pes are di).88 F .435(vided into)-.275 F F4(base)
+3.185 E F1 .435(types and)3.185 F F4(composite)3.185 E F1 3.184
+(types. Base)3.184 F .434(types are those, lik)3.184 F(e)-.11 E F5(int4)
+3.184 E F1(,)A 1.371(that are implemented in a language such as C.)108
+641.1 R(The)6.871 E 4.121(yg)-.165 G 1.371
+(enerally correspond to what are)-4.121 F .34(often kno)108 654.3 R .34
+(wn as \231abstract data types\232;)-.275 F F2(POSTGRES)3.09 E F1 .34
+(can only operate on such types through)3.09 F 1.733(methods pro)108
+667.5 R 1.733(vided by the user and only understands the beha)-.165 F
+1.734(vior of such types to the)-.22 F -.165(ex)108 680.7 S .736
+(tent that the user describes them.).165 F .736
+(Composite types are created whene)6.236 F -.165(ve)-.275 G 3.486(rt)
+.165 G .736(he user cre-)-3.486 F 1.165(ates a class.)108 693.9 R F5
+(EMP)6.665 E F1 1.166(is an e)3.915 F 1.166(xample of a composite type.)
+-.165 F F2(POSTGRES)6.666 E F1 1.166(stores these types in)3.916 F .58
+(only one w)108 707.1 R .58
+(ay \(within the \214le that stores all instances of the class\) b)-.11
+F .579(ut the user can \231look)-.22 F 2.912(inside\232 at the attrib)
+108 720.3 R 2.913
+(utes of these types from the query language and optimize their)-.22 F
+F6(21)282.5 756 Q EP
+%%Page: 22 22
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF(retrie)108 97.2 Q -.275(va)-.275 G 2.75(lb).275
+G 2.75(y\()-2.75 G(for e)-2.75 E
+(xample\) de\214ning indices on the attrib)-.165 E(utes.)-.22 E/F1 10
+/Times-Roman@0 SF(POSTGRES)108 114.3 Q F0 2.579
+(base types are further di)5.329 F 2.579(vided into)-.275 F/F2 11
+/Times-Italic@0 SF -.22(bu)5.329 G(ilt-in).22 E F0 2.578(types and)5.328
+F F2(user)5.328 E(-de\214ned)-.22 E F0(types.)5.328 E 2.057
+(Built-in types \(lik)108 127.5 R(e)-.11 E/F3 11/Courier@0 SF(int4)4.808
+E F0 4.808(\)a)C 2.058(re those that are compiled into the system.)
+-4.808 F(User)7.558 E(-de\214ned)-.22 E
+(types are those created by the user in the manner to be described belo)
+108 140.7 Q -.715(w.)-.275 G/F4 12/Times-Bold@0 SF 3(6.3. About)72 166.9
+R(the)3 E/F5 11/Times-Bold@0 SF(POSTGRES)3 E F4(System Catalogs)3 E F0
+(Ha)108 184 Q 1.236(ving introduced the basic e)-.22 F 1.236
+(xtensibility concepts, we can no)-.165 F 3.986(wt)-.275 G(ak)-3.986 E
+3.986(eal)-.11 G 1.236(ook at ho)-3.986 F 3.985(wt)-.275 G(he)-3.985 E
+.694(catalogs are actually laid out.)108 197.2 R -1.21(Yo)6.194 G 3.444
+(uc)1.21 G .695(an skip this section for no)-3.444 F 2.125 -.715(w, b)
+-.275 H .695(ut some later sections).495 F .649
+(will be incomprehensible without the information gi)108 210.4 R -.165
+(ve)-.275 G 3.399(nh).165 G .649(ere, so mark this page for later)-3.399
+F(reference.)108 223.6 Q 2.139(All system catalogs ha)108 240.7 R 2.469
+-.165(ve n)-.22 H 2.139(ames that be).165 F 2.14(gin with)-.165 F F3
+(pg_)4.89 E F0 7.64(.T)C 2.14(he follo)-7.64 F 2.14
+(wing classes contain)-.275 F .912
+(information that may be useful to the end user)108 253.9 R 6.411(.\()
+-.605 G .911(There are man)-6.411 F 3.661(yo)-.165 G .911
+(ther system catalogs,)-3.661 F -.22(bu)108 267.1 S 2.75(tt).22 G
+(here should rarely be a reason to query them directly)-2.75 E(.\))-.715
+E .44 LW 436.564 284.85 175.435 284.85 DL(catalog name)191.363 295.3 Q
+(description)79.7 E 436.564 300.05 175.435 300.05 DL 436.564 302.05
+175.435 302.05 DL F3(pg_database)180.935 312.5 Q F0(databases)23.1 E F3
+(pg_class)180.935 325.7 Q F0(classes)42.9 E F3(pg_attribute)180.935
+338.9 Q F0(class attrib)16.5 E(utes)-.22 E F3(pg_index)180.935 352.1 Q
+F0(secondary indices)42.9 E F3(pg_proc)180.935 378.5 Q F0
+(procedures \(both C and SQL\))49.5 E F3(pg_type)180.935 391.7 Q F0
+(types \(both base and comple)49.5 E(x\))-.165 E F3(pg_operator)180.935
+404.9 Q F0(operators)23.1 E F3(pg_aggregate)180.935 418.1 Q F0(aggre)
+16.5 E -.055(ga)-.165 G(tes and aggre).055 E -.055(ga)-.165 G
+(te functions).055 E F3(pg_am)180.935 444.5 Q F0(access methods)62.7 E
+F3(pg_amop)180.935 457.7 Q F0(access method operators)49.5 E F3
+(pg_amproc)180.935 470.9 Q F0(access method support functions)36.3 E F3
+(pg_opclass)180.935 484.1 Q F0(access method operator classes)29.7 E
+436.564 488.85 175.435 488.85 DL 268.385 284.85 268.385 488.85 DL
+436.564 284.85 436.564 488.85 DL 175.435 284.85 175.435 488.85 DL 2.299
+(The Reference Manual gi)108 510.3 R -.165(ve)-.275 G 5.049(sam).165 G
+2.299(ore detailed e)-5.049 F 2.299
+(xplanation of these catalogs and their)-.165 F(attrib)108 523.5 Q 3.35
+(utes. Ho)-.22 F(we)-.275 E -.165(ve)-.275 G 1.48 -.44(r, F).165 H .6
+(igure 3 sho).44 F .6
+(ws the major entities and their relationships in the sys-)-.275 F .557
+(tem catalogs.)108 536.7 R(\(Attrib)6.057 E .557
+(utes that do not refer to other entities are not sho)-.22 F .558
+(wn unless the)-.275 F 3.308(ya)-.165 G(re)-3.308 E(part of a primary k)
+108 549.9 Q -.165(ey)-.11 G(.\))-.55 E .221(This diagram is more or les\
+s incomprehensible until you actually start looking at the con-)108 567
+R .887(tents of the catalogs and see ho)108 580.2 R 3.638(wt)-.275 G(he)
+-3.638 E 3.638(yr)-.165 G .888(elate to each other)-3.638 F 6.388(.F)
+-.605 G .888(or no)-6.553 F 2.318 -.715(w, t)-.275 H .888
+(he main things to).715 F(tak)108 593.4 Q 2.75(ea)-.11 G -.11(wa)-2.915
+G 2.75(yf).11 G(rom this diagram are as follo)-2.75 E(ws:)-.275 E 13.75
+(\(1\) In)113.5 610.5 R(se)3.509 E -.165(ve)-.275 G .759
+(ral of the sections that follo).165 F 2.189 -.715(w, w)-.275 H 3.509
+(ew).715 G .759(ill present v)-3.509 F .759(arious join queries on the)
+-.275 F .546(system catalogs that display information we need to e)
+142.826 623.7 R .546(xtend the system.)-.165 F(Looking)6.046 E .319
+(at this diagram should mak)142.826 636.9 R 3.069(es)-.11 G .319
+(ome of these join queries \(which are often three- or)-3.069 F(four)
+142.826 650.1 Q(-w)-.22 E 1.791(ay joins\) more understandable, because\
+ you will be able to see that the)-.11 F(attrib)142.826 663.3 Q
+(utes used in the queries form foreign k)-.22 E -.165(ey)-.11 G 2.75(si)
+.165 G 2.75(no)-2.75 G(ther classes.)-2.75 E 13.75(\(2\) Man)113.5 680.4
+R 2.868(yd)-.165 G(if)-2.868 E .118(ferent features \(classes, attrib)
+-.275 F .117(utes, functions, types, access methods, etc.\))-.22 F 2.01
+(are tightly inte)142.826 693.6 R 2.01(grated in this schema.)-.165 F
+4.76(As)7.51 G(imple)-4.76 E F5(cr)4.76 E(eate)-.198 E F0 2.01
+(command may modify)4.76 F(man)142.826 706.8 Q 2.75(yo)-.165 G 2.75(ft)
+-2.75 G(hese catalogs.)-2.75 E F5(22)282.5 756 Q EP
+%%Page: 23 23
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 109.2 72 109.2 DL 80.5 109.2 75 109.2 DL 86 109.2 80.5 109.2
+DL 91.5 109.2 86 109.2 DL 97 109.2 91.5 109.2 DL 102.5 109.2 97 109.2 DL
+108 109.2 102.5 109.2 DL 113.5 109.2 108 109.2 DL 119 109.2 113.5 109.2
+DL 124.5 109.2 119 109.2 DL 130 109.2 124.5 109.2 DL 135.5 109.2 130
+109.2 DL 141 109.2 135.5 109.2 DL 146.5 109.2 141 109.2 DL 152 109.2
+146.5 109.2 DL 157.5 109.2 152 109.2 DL 163 109.2 157.5 109.2 DL 168.5
+109.2 163 109.2 DL 174 109.2 168.5 109.2 DL 179.5 109.2 174 109.2 DL 185
+109.2 179.5 109.2 DL 190.5 109.2 185 109.2 DL 196 109.2 190.5 109.2 DL
+201.5 109.2 196 109.2 DL 207 109.2 201.5 109.2 DL 212.5 109.2 207 109.2
+DL 218 109.2 212.5 109.2 DL 223.5 109.2 218 109.2 DL 229 109.2 223.5
+109.2 DL 234.5 109.2 229 109.2 DL 240 109.2 234.5 109.2 DL 245.5 109.2
+240 109.2 DL 251 109.2 245.5 109.2 DL 256.5 109.2 251 109.2 DL 262 109.2
+256.5 109.2 DL 267.5 109.2 262 109.2 DL 273 109.2 267.5 109.2 DL 278.5
+109.2 273 109.2 DL 284 109.2 278.5 109.2 DL 289.5 109.2 284 109.2 DL 295
+109.2 289.5 109.2 DL 300.5 109.2 295 109.2 DL 306 109.2 300.5 109.2 DL
+311.5 109.2 306 109.2 DL 317 109.2 311.5 109.2 DL 322.5 109.2 317 109.2
+DL 328 109.2 322.5 109.2 DL 333.5 109.2 328 109.2 DL 339 109.2 333.5
+109.2 DL 344.5 109.2 339 109.2 DL 350 109.2 344.5 109.2 DL 355.5 109.2
+350 109.2 DL 361 109.2 355.5 109.2 DL 366.5 109.2 361 109.2 DL 372 109.2
+366.5 109.2 DL 377.5 109.2 372 109.2 DL 383 109.2 377.5 109.2 DL 388.5
+109.2 383 109.2 DL 394 109.2 388.5 109.2 DL 399.5 109.2 394 109.2 DL 405
+109.2 399.5 109.2 DL 410.5 109.2 405 109.2 DL 416 109.2 410.5 109.2 DL
+421.5 109.2 416 109.2 DL 427 109.2 421.5 109.2 DL 432.5 109.2 427 109.2
+DL 438 109.2 432.5 109.2 DL 443.5 109.2 438 109.2 DL 449 109.2 443.5
+109.2 DL 454.5 109.2 449 109.2 DL 460 109.2 454.5 109.2 DL 465.5 109.2
+460 109.2 DL 471 109.2 465.5 109.2 DL 476.5 109.2 471 109.2 DL 482 109.2
+476.5 109.2 DL 487.5 109.2 482 109.2 DL 493 109.2 487.5 109.2 DL 498.5
+109.2 493 109.2 DL 504 109.2 498.5 109.2 DL 0 0 432 754 -433.278 761 72
+568.878 PBEGIN
+%%BeginDocument: manual-er.eps
+%%Title: stdin
+%%Creator: fig2dev Version 3.1 Patchlevel 0
+%%CreationDate: Sat Feb 24 21:36:26 1996
+%%For: jolly@arcadia.CS.Berkeley.EDU (Jolly Chen,421 Soda,(510) 6421863,540-5955)
+%%Orientation: Portrait
+%%BoundingBox: 0 0 754 761
+%%Pages: 0
+%%BeginSetup
+%%IncludeFeature: *PageSize Letter
+%%EndSetup
+%%EndComments
+/$F2psDict 200 dict def
+$F2psDict begin
+$F2psDict /mtrx matrix put
+/col-1 {} def
+/col0 {0.000 0.000 0.000 srgb} bind def
+/col1 {0.000 0.000 1.000 srgb} bind def
+/col2 {0.000 1.000 0.000 srgb} bind def
+/col3 {0.000 1.000 1.000 srgb} bind def
+/col4 {1.000 0.000 0.000 srgb} bind def
+/col5 {1.000 0.000 1.000 srgb} bind def
+/col6 {1.000 1.000 0.000 srgb} bind def
+/col7 {1.000 1.000 1.000 srgb} bind def
+/col8 {0.000 0.000 0.560 srgb} bind def
+/col9 {0.000 0.000 0.690 srgb} bind def
+/col10 {0.000 0.000 0.820 srgb} bind def
+/col11 {0.530 0.810 1.000 srgb} bind def
+/col12 {0.000 0.560 0.000 srgb} bind def
+/col13 {0.000 0.690 0.000 srgb} bind def
+/col14 {0.000 0.820 0.000 srgb} bind def
+/col15 {0.000 0.560 0.560 srgb} bind def
+/col16 {0.000 0.690 0.690 srgb} bind def
+/col17 {0.000 0.820 0.820 srgb} bind def
+/col18 {0.560 0.000 0.000 srgb} bind def
+/col19 {0.690 0.000 0.000 srgb} bind def
+/col20 {0.820 0.000 0.000 srgb} bind def
+/col21 {0.560 0.000 0.560 srgb} bind def
+/col22 {0.690 0.000 0.690 srgb} bind def
+/col23 {0.820 0.000 0.820 srgb} bind def
+/col24 {0.500 0.190 0.000 srgb} bind def
+/col25 {0.630 0.250 0.000 srgb} bind def
+/col26 {0.750 0.380 0.000 srgb} bind def
+/col27 {1.000 0.500 0.500 srgb} bind def
+/col28 {1.000 0.630 0.630 srgb} bind def
+/col29 {1.000 0.750 0.750 srgb} bind def
+/col30 {1.000 0.880 0.880 srgb} bind def
+/col31 {1.000 0.840 0.000 srgb} bind def
+
+end
+save
+-30.0 776.0 translate
+1 -1 scale
+
+/clp {closepath} bind def
+/ef {eofill} bind def
+/gr {grestore} bind def
+/gs {gsave} bind def
+/l {lineto} bind def
+/m {moveto} bind def
+/n {newpath} bind def
+/s {stroke} bind def
+/slc {setlinecap} bind def
+/slj {setlinejoin} bind def
+/slw {setlinewidth} bind def
+/srgb {setrgbcolor} bind def
+/rot {rotate} bind def
+/sc {scale} bind def
+/tr {translate} bind def
+/tnt {dup dup currentrgbcolor
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add
+ 4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}
+ bind def
+/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul
+ 4 -2 roll mul srgb} bind def
+/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def
+/$F2psEnd {$F2psEnteredState restore end} def
+
+$F2psBegin
+10 setmiterlimit
+ 0.90000 0.90000 sc
+0.500 slw
+% Polyline
+n 194 414 m 259 414 l 259 454 l 274 454 l gs col-1 s gr
+% Polyline
+n 194 234 m 274 234 l gs col-1 s gr
+% Polyline
+n 259 134 m 239 134 l 239 394 l 199 394 l gs col-1 s gr
+% Polyline
+n 259 54 m 219 54 l 219 389 l gs col-1 s gr
+% Polyline
+n 199 389 m 219 389 l gs col-1 s gr
+% Polyline
+n 279 254 m 259 254 l 259 399 l 199 399 l gs col-1 s gr
+% Polyline
+n 179 234 m 199 234 l gs col-1 s gr
+% Polyline
+n 259 74 m 199 74 l 199 214 l 179 214 l gs col-1 s gr
+% Polyline
+n 379 294 m 399 294 l gs col-1 s gr
+% Polyline
+n 384 239 m 459 239 l 459 514 l 499 514 l gs col-1 s gr
+% Polyline
+n 459 494 m 499 494 l gs col-1 s gr
+% Polyline
+n 379 274 m 514 274 l gs col-1 s gr
+% Polyline
+n 379 474 m 439 474 l gs col-1 s gr
+% Polyline
+n 379 494 m 439 494 l gs col-1 s gr
+% Polyline
+n 379 514 m 439 514 l gs col-1 s gr
+% Polyline
+n 379 534 m 439 534 l gs col-1 s gr
+% Polyline
+n 379 554 m 439 554 l gs col-1 s gr
+% Polyline
+n 379 574 m 439 574 l gs col-1 s gr
+% Polyline
+n 379 594 m 439 594 l gs col-1 s gr
+% Polyline
+n 379 614 m 439 614 l gs col-1 s gr
+% Polyline
+n 379 634 m 439 634 l gs col-1 s gr
+% Polyline
+n 379 654 m 439 654 l gs col-1 s gr
+% Polyline
+n 439 279 m 514 279 l gs col-1 s gr
+% Polyline
+n 434 439 m 444 449 l gs col-1 s gr
+% Polyline
+n 404 269 m 414 279 l gs col-1 s gr
+% Polyline
+n 454 439 m 464 449 l gs col-1 s gr
+% Polyline
+n 619 634 m 659 634 l gs col-1 s gr
+% Polyline
+n 634 519 m 644 529 l gs col-1 s gr
+% Polyline
+n 654 579 m 664 589 l gs col-1 s gr
+% Polyline
+n 499 494 m 519 494 l gs col-1 s gr
+% Polyline
+n 499 514 m 519 514 l gs col-1 s gr
+% Polyline
+n 599 104 m 599 79 l 514 79 l 514 104 l clp gs col-1 s gr
+% Polyline
+n 624 124 m 624 104 l 514 104 l 514 124 l clp gs col-1 s gr
+% Polyline
+n 459 534 m 499 534 l gs col-1 s gr
+% Polyline
+n 499 534 m 519 534 l gs col-1 s gr
+% Polyline
+n 459 534 m 459 514 l gs col-1 s gr
+% Polyline
+n 384 229 m 499 229 l 499 314 l 519 314 l gs col-1 s gr
+% Polyline
+n 624 114 m 639 114 l 639 354 l 619 354 l gs col-1 s gr
+% Polyline
+n 384 454 m 419 454 l 419 414 l 739 414 l gs col-1 s gr
+% Polyline
+n 384 449 m 399 449 l 399 399 l 699 399 l 699 54 l 739 54 l gs col-1 s gr
+% Polyline
+n 624 449 m 719 449 l 719 94 l 739 94 l gs col-1 s gr
+% Polyline
+n 679 134 m 744 134 l gs col-1 s gr
+% Polyline
+n 674 159 m 684 169 l gs col-1 s gr
+% Polyline
+n 839 74 m 859 74 l 859 249 l 844 249 l gs col-1 s gr
+% Polyline
+n 844 254 m 859 254 l 859 434 l 839 434 l gs col-1 s gr
+% Polyline
+n 624 269 m 679 269 l 679 114 l 739 114 l gs col-1 s gr
+% Polyline
+n 624 274 m 679 274 l 679 474 l 739 474 l gs col-1 s gr
+% Polyline
+n 521 284 m 514 284 514 357 7 arcto 4 {pop} repeat 514 364 617 364 7 arcto 4 {pop} repeat 624 364 624 291 7 arcto 4 {pop} repeat 624 284 521 284 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 179 604 m 179 579 l 74 579 l 74 604 l clp gs col-1 s gr
+% Polyline
+n 184 704 m 184 679 l 74 679 l 74 704 l clp gs col-1 s gr
+% Polyline
+n 81 604 m 74 604 74 617 7 arcto 4 {pop} repeat 74 624 177 624 7 arcto 4 {pop} repeat 184 624 184 611 7 arcto 4 {pop} repeat 184 604 81 604 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 184 724 m 184 704 l 74 704 l 74 724 l clp gs col-1 s gr
+% Polyline
+n 179 614 m 199 614 l 199 714 l 184 714 l gs col-1 s gr
+% Polyline
+n 184 764 m 184 724 l 74 724 l 74 764 l clp gs col-1 s gr
+% Polyline
+n 184 784 m 184 764 l 74 764 l 74 784 l clp gs col-1 s gr
+% Polyline
+n 81 724 m 74 724 74 777 7 arcto 4 {pop} repeat 74 784 177 784 7 arcto 4 {pop} repeat 184 784 184 731 7 arcto 4 {pop} repeat 184 724 81 724 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 166 804 m 159 804 159 812 7 arcto 4 {pop} repeat 159 819 172 819 7 arcto 4 {pop} repeat 179 819 179 811 7 arcto 4 {pop} repeat 179 804 166 804 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 439 654 m 439 279 l gs col-1 s gr
+% Polyline
+ [4.4] 0 setdash
+n 359 94 m 419 94 l 419 269 l 514 269 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 384 234 m 479 234 l 479 334 l 519 334 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 239 739 m 279 739 l gs col-1 s gr [] 0 setdash
+% Polyline
+n 239 759 m 279 759 l gs col-1 s gr
+% Polyline
+ [4.4] 0 setdash
+n 379 314 m 399 314 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 379 334 m 399 334 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 399 294 m 399 334 l gs col-1 s gr [] 0 setdash
+% Polyline
+n 399 274 m 399 294 l gs col-1 s gr
+% Polyline
+ [4.4] 0 setdash
+n 619 614 m 639 614 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 619 594 m 639 594 l gs col-1 s gr [] 0 setdash
+% Polyline
+n 521 464 m 514 464 514 677 7 arcto 4 {pop} repeat 514 684 617 684 7 arcto 4 {pop} repeat 624 684 624 471 7 arcto 4 {pop} repeat 624 464 521 464 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+ [4.4] 0 setdash
+n 639 594 m 639 614 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 619 574 m 639 574 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 619 554 m 639 554 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 624 454 m 639 454 l 639 594 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 619 654 m 659 654 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 619 674 m 659 674 l gs col-1 s gr [] 0 setdash
+% Polyline
+ [4.4] 0 setdash
+n 659 674 m 659 654 l gs col-1 s gr [] 0 setdash
+% Polyline
+n 624 279 m 659 279 l 659 634 l gs col-1 s gr
+% Polyline
+ [4.4] 0 setdash
+n 659 634 m 659 654 l gs col-1 s gr [] 0 setdash
+% Polyline
+n 154 184 m 154 159 l 69 159 l 69 184 l clp gs col-1 s gr
+% Polyline
+n 76 184 m 69 184 69 237 7 arcto 4 {pop} repeat 69 244 172 244 7 arcto 4 {pop} repeat 179 244 179 191 7 arcto 4 {pop} repeat 179 184 76 184 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 69 224 m 179 224 l gs col-1 s gr
+% Polyline
+n 174 414 m 194 414 l gs col-1 s gr
+% Polyline
+n 179 399 m 199 399 l gs col-1 s gr
+% Polyline
+n 179 394 m 199 394 l gs col-1 s gr
+% Polyline
+n 179 389 m 199 389 l gs col-1 s gr
+% Polyline
+n 179 404 m 179 384 l 69 384 l 69 404 l clp gs col-1 s gr
+% Polyline
+n 154 384 m 154 359 l 69 359 l 69 384 l clp gs col-1 s gr
+% Polyline
+n 179 424 m 179 404 l 69 404 l 69 424 l clp gs col-1 s gr
+% Polyline
+n 359 224 m 359 199 l 274 199 l 274 224 l clp gs col-1 s gr
+% Polyline
+n 384 244 m 384 224 l 274 224 l 274 244 l clp gs col-1 s gr
+% Polyline
+n 384 344 m 384 244 l 274 244 l 274 344 l clp gs col-1 s gr
+% Polyline
+n 339 44 m 339 19 l 254 19 l 254 44 l clp gs col-1 s gr
+% Polyline
+n 261 44 m 254 44 254 137 7 arcto 4 {pop} repeat 254 144 357 144 7 arcto 4 {pop} repeat 364 144 364 51 7 arcto 4 {pop} repeat 364 44 261 44 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 254 124 m 364 124 l gs col-1 s gr
+% Polyline
+n 819 44 m 819 19 l 734 19 l 734 44 l clp gs col-1 s gr
+% Polyline
+n 741 44 m 734 44 734 137 7 arcto 4 {pop} repeat 734 144 837 144 7 arcto 4 {pop} repeat 844 144 844 51 7 arcto 4 {pop} repeat 844 44 741 44 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 734 104 m 844 104 l gs col-1 s gr
+% Polyline
+n 819 244 m 819 219 l 734 219 l 734 244 l clp gs col-1 s gr
+% Polyline
+n 844 264 m 844 244 l 734 244 l 734 264 l clp gs col-1 s gr
+% Polyline
+n 599 264 m 599 239 l 514 239 l 514 264 l clp gs col-1 s gr
+% Polyline
+n 624 284 m 624 264 l 514 264 l 514 284 l clp gs col-1 s gr
+% Polyline
+n 624 364 m 624 284 l 514 284 l 514 364 l clp gs col-1 s gr
+% Polyline
+n 514 344 m 624 344 l gs col-1 s gr
+% Polyline
+n 819 404 m 819 379 l 734 379 l 734 404 l clp gs col-1 s gr
+% Polyline
+n 741 404 m 734 404 734 477 7 arcto 4 {pop} repeat 734 484 837 484 7 arcto 4 {pop} repeat 844 484 844 411 7 arcto 4 {pop} repeat 844 404 741 404 7 arcto 4 {pop} repeat clp gs col-1 s gr
+% Polyline
+n 734 464 m 844 464 l gs col-1 s gr
+% Polyline
+n 599 444 m 599 419 l 514 419 l 514 444 l clp gs col-1 s gr
+% Polyline
+n 624 464 m 624 444 l 514 444 l 514 464 l clp gs col-1 s gr
+% Polyline
+n 624 544 m 624 464 l 514 464 l 514 544 l clp gs col-1 s gr
+% Polyline
+n 624 684 m 624 544 l 514 544 l 514 684 l clp gs col-1 s gr
+% Polyline
+n 384 464 m 384 444 l 274 444 l 274 464 l clp gs col-1 s gr
+% Polyline
+n 359 444 m 359 419 l 274 419 l 274 444 l clp gs col-1 s gr
+% Polyline
+n 384 664 m 384 464 l 274 464 l 274 664 l clp gs col-1 s gr
+% Interp Spline
+n 219 799 m
+ 219.84 787.54 219.84 782.54 219 779 curveto
+ 217.75 773.72 212.79 763.10 209 759 curveto
+ 205.29 754.99 199.04 751.24 184 744 curveto
+ gs col-1 s gr
+
+n 190.34 749.27 m 184.00 744.00 l 192.08 745.67 l gs col-1 s gr
+/Times-Roman findfont 14.00 scalefont setfont
+589 339 m
+gs 1 -1 sc ([8]) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+299 79 m
+gs 1 -1 sc ([8]) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+119 659 m
+gs 1 -1 sc (REFERS-TO) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+79 779 m
+gs 1 -1 sc (non-key) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+249 459 m
+gs 1 -1 sc (1) col-1 show gr
+% Polyline
+n 74 194 m 59 194 l 59 394 l 69 394 l gs col-1 s gr
+/Times-Roman findfont 14.00 scalefont setfont
+184 429 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+189 859 m
+gs 1 -1 sc (identified by the non-oid primary key in other contexts\).) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+49 399 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+34 189 m
+gs 1 -1 sc (13:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+264 229 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+184 229 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+184 209 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+229 89 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+209 379 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+229 379 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+249 379 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+229 129 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+229 49 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+389 439 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+409 439 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+389 349 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+504 264 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+489 349 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+489 329 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+389 224 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+629 369 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+629 109 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+429 669 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+504 294 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+369 89 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+469 254 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+389 254 m
+gs 1 -1 sc (0:1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+284 739 m
+gs 1 -1 sc (optional) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+284 759 m
+gs 1 -1 sc (mandatory) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+424 194 m
+gs 1 -1 sc (0:1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+709 49 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+709 89 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+629 444 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+629 469 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+629 629 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+664 639 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+649 294 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+629 264 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+669 299 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+709 489 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+689 429 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+849 449 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+849 69 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+849 244 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+849 269 m
+gs 1 -1 sc (1) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+654 134 m
+gs 1 -1 sc (0:N) col-1 show gr
+/Times-Roman findfont 18.00 scalefont setfont
+39 569 m
+gs 1 -1 sc (KEY:) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+74 239 m
+gs 1 -1 sc (atttypid) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 259 m
+gs 1 -1 sc (typrelid) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 279 m
+gs 1 -1 sc (typinput) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 299 m
+gs 1 -1 sc (typoutput) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 319 m
+gs 1 -1 sc (typreceive) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 339 m
+gs 1 -1 sc (typsend) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+259 139 m
+gs 1 -1 sc (indexrelid) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+739 119 m
+gs 1 -1 sc (amopselect) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+739 139 m
+gs 1 -1 sc (amopnpages) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+519 359 m
+gs 1 -1 sc (prolang) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+739 479 m
+gs 1 -1 sc (amproc) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+519 559 m
+gs 1 -1 sc (oprcom) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+519 579 m
+gs 1 -1 sc (oprnegate) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+519 599 m
+gs 1 -1 sc (oprlsortop) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+519 619 m
+gs 1 -1 sc (oprrsortop) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+519 639 m
+gs 1 -1 sc (oprcode) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+519 659 m
+gs 1 -1 sc (oprrest) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+519 679 m
+gs 1 -1 sc (oprjoin) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 479 m
+gs 1 -1 sc (amgettuple) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 499 m
+gs 1 -1 sc (aminsert) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 519 m
+gs 1 -1 sc (amdelete) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 539 m
+gs 1 -1 sc (amgetattr) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 559 m
+gs 1 -1 sc (ambeginscan) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 579 m
+gs 1 -1 sc (amrescan) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 599 m
+gs 1 -1 sc (amendscan) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 619 m
+gs 1 -1 sc (ammarkpos) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 639 m
+gs 1 -1 sc (amrestrpos) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+279 659 m
+gs 1 -1 sc (ambuild) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+79 599 m
+gs 1 -1 sc (DEPENDENT) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+79 699 m
+gs 1 -1 sc (INDEPENDENT) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+74 179 m
+gs 1 -1 sc (pg_attribute) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+74 379 m
+gs 1 -1 sc (pg_class) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+259 39 m
+gs 1 -1 sc (pg_index) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+279 219 m
+gs 1 -1 sc (pg_type) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+279 439 m
+gs 1 -1 sc (pg_am) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+519 259 m
+gs 1 -1 sc (pg_proc) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+519 99 m
+gs 1 -1 sc (pg_language) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+739 39 m
+gs 1 -1 sc (pg_amop) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+739 239 m
+gs 1 -1 sc (pg_opclass) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+739 399 m
+gs 1 -1 sc (pg_amproc) col-1 show gr
+/Times-Bold findfont 14.00 scalefont setfont
+519 439 m
+gs 1 -1 sc (pg_operator) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+74 199 m
+gs 1 -1 sc (attrelid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+74 219 m
+gs 1 -1 sc (attnum) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+74 419 m
+gs 1 -1 sc (relam) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+74 399 m
+gs 1 -1 sc (oid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+259 59 m
+gs 1 -1 sc (indrelid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+259 79 m
+gs 1 -1 sc (indkey) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+259 99 m
+gs 1 -1 sc (indproc) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+259 119 m
+gs 1 -1 sc (indpred) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+279 239 m
+gs 1 -1 sc (oid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+279 459 m
+gs 1 -1 sc (oid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+519 279 m
+gs 1 -1 sc (oid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+519 119 m
+gs 1 -1 sc (oid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+739 59 m
+gs 1 -1 sc (amopid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+739 79 m
+gs 1 -1 sc (amopclaid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+739 99 m
+gs 1 -1 sc (amopopr) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+739 259 m
+gs 1 -1 sc (oid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+739 419 m
+gs 1 -1 sc (amid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+739 439 m
+gs 1 -1 sc (amopclaid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+739 459 m
+gs 1 -1 sc (amprocnum) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+519 459 m
+gs 1 -1 sc (oid) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+79 719 m
+gs 1 -1 sc (primary key) col-1 show gr
+/Times-BoldItalic findfont 14.00 scalefont setfont
+79 619 m
+gs 1 -1 sc (foreign key) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+79 739 m
+gs 1 -1 sc (non-oid primary) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+84 759 m
+gs 1 -1 sc (key \(if any\)) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+519 479 m
+gs 1 -1 sc (oprname) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+519 499 m
+gs 1 -1 sc (oprleft) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+519 519 m
+gs 1 -1 sc (oprright) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+519 539 m
+gs 1 -1 sc (oprresult) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+519 299 m
+gs 1 -1 sc (proname) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+519 319 m
+gs 1 -1 sc (prorettype) col-1 show gr
+/Times-Italic findfont 14.00 scalefont setfont
+519 339 m
+gs 1 -1 sc (proargtypes) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+189 819 m
+gs 1 -1 sc (indicates these key values are alternate primary keys) col-1 show gr
+/Times-Roman findfont 14.00 scalefont setfont
+189 839 m
+gs 1 -1 sc (\(i.e., this class is generally identified by oid but may be) col-1 show gr
+$F2psEnd
+restore
+%%EndDocument
+end PEND/F0 11/Times-Bold@0 SF(Figur)177.701 595.278 Q 2.75(e3)-.198 G
+/F1 11/Times-Roman@0 SF 5.5(.T)-2.75 G(he major)-5.5 E/F2 10
+/Times-Roman@0 SF(POSTGRES)2.75 E F1(system catalogs.)2.75 E 77.5
+608.478 72 608.478 DL 80.5 608.478 75 608.478 DL 86 608.478 80.5 608.478
+DL 91.5 608.478 86 608.478 DL 97 608.478 91.5 608.478 DL 102.5 608.478
+97 608.478 DL 108 608.478 102.5 608.478 DL 113.5 608.478 108 608.478 DL
+119 608.478 113.5 608.478 DL 124.5 608.478 119 608.478 DL 130 608.478
+124.5 608.478 DL 135.5 608.478 130 608.478 DL 141 608.478 135.5 608.478
+DL 146.5 608.478 141 608.478 DL 152 608.478 146.5 608.478 DL 157.5
+608.478 152 608.478 DL 163 608.478 157.5 608.478 DL 168.5 608.478 163
+608.478 DL 174 608.478 168.5 608.478 DL 179.5 608.478 174 608.478 DL 185
+608.478 179.5 608.478 DL 190.5 608.478 185 608.478 DL 196 608.478 190.5
+608.478 DL 201.5 608.478 196 608.478 DL 207 608.478 201.5 608.478 DL
+212.5 608.478 207 608.478 DL 218 608.478 212.5 608.478 DL 223.5 608.478
+218 608.478 DL 229 608.478 223.5 608.478 DL 234.5 608.478 229 608.478 DL
+240 608.478 234.5 608.478 DL 245.5 608.478 240 608.478 DL 251 608.478
+245.5 608.478 DL 256.5 608.478 251 608.478 DL 262 608.478 256.5 608.478
+DL 267.5 608.478 262 608.478 DL 273 608.478 267.5 608.478 DL 278.5
+608.478 273 608.478 DL 284 608.478 278.5 608.478 DL 289.5 608.478 284
+608.478 DL 295 608.478 289.5 608.478 DL 300.5 608.478 295 608.478 DL 306
+608.478 300.5 608.478 DL 311.5 608.478 306 608.478 DL 317 608.478 311.5
+608.478 DL 322.5 608.478 317 608.478 DL 328 608.478 322.5 608.478 DL
+333.5 608.478 328 608.478 DL 339 608.478 333.5 608.478 DL 344.5 608.478
+339 608.478 DL 350 608.478 344.5 608.478 DL 355.5 608.478 350 608.478 DL
+361 608.478 355.5 608.478 DL 366.5 608.478 361 608.478 DL 372 608.478
+366.5 608.478 DL 377.5 608.478 372 608.478 DL 383 608.478 377.5 608.478
+DL 388.5 608.478 383 608.478 DL 394 608.478 388.5 608.478 DL 399.5
+608.478 394 608.478 DL 405 608.478 399.5 608.478 DL 410.5 608.478 405
+608.478 DL 416 608.478 410.5 608.478 DL 421.5 608.478 416 608.478 DL 427
+608.478 421.5 608.478 DL 432.5 608.478 427 608.478 DL 438 608.478 432.5
+608.478 DL 443.5 608.478 438 608.478 DL 449 608.478 443.5 608.478 DL
+454.5 608.478 449 608.478 DL 460 608.478 454.5 608.478 DL 465.5 608.478
+460 608.478 DL 471 608.478 465.5 608.478 DL 476.5 608.478 471 608.478 DL
+482 608.478 476.5 608.478 DL 487.5 608.478 482 608.478 DL 493 608.478
+487.5 608.478 DL 498.5 608.478 493 608.478 DL 504 608.478 498.5 608.478
+DL 13.75(\(3\) T)113.5 649.078 R .962(ypes and procedures)-.88 F/F3 8
+/Times-Roman@0 SF(6)-4.4 I F1 .961(are central to the schema.)3.712 4.4
+N .961(Nearly e)6.461 F -.165(ve)-.275 G .961(ry catalog contains).165 F
+.739(some reference to instances in one or both of these classes.)
+142.826 662.278 R -.165(Fo)6.239 G 3.489(re).165 G(xample,)-3.654 E F2
+(POST)3.489 E(-)-.92 E(GRES)142.826 675.478 Q F1 .182(frequently uses t\
+ype signatures \(e.g., of functions and operators\) to identify)2.933 F
+.32 LW 76 685.078 72 685.078 DL 80 685.078 76 685.078 DL 84 685.078 80
+685.078 DL 88 685.078 84 685.078 DL 92 685.078 88 685.078 DL 96 685.078
+92 685.078 DL 100 685.078 96 685.078 DL 104 685.078 100 685.078 DL 108
+685.078 104 685.078 DL 112 685.078 108 685.078 DL 116 685.078 112
+685.078 DL 120 685.078 116 685.078 DL 124 685.078 120 685.078 DL 128
+685.078 124 685.078 DL 132 685.078 128 685.078 DL 136 685.078 132
+685.078 DL 140 685.078 136 685.078 DL 144 685.078 140 685.078 DL 148
+685.078 144 685.078 DL 152 685.078 148 685.078 DL 156 685.078 152
+685.078 DL 160 685.078 156 685.078 DL 164 685.078 160 685.078 DL 168
+685.078 164 685.078 DL 172 685.078 168 685.078 DL 176 685.078 172
+685.078 DL 180 685.078 176 685.078 DL 184 685.078 180 685.078 DL 188
+685.078 184 685.078 DL 192 685.078 188 685.078 DL 196 685.078 192
+685.078 DL 200 685.078 196 685.078 DL 204 685.078 200 685.078 DL 208
+685.078 204 685.078 DL 212 685.078 208 685.078 DL 216 685.078 212
+685.078 DL/F4 5/Times-Roman@0 SF(6)93.6 695.478 Q F3 1.28 -.64(We u)2
+3.2 P(se the w).64 E(ords)-.08 E/F5 8/Times-Italic@0 SF(pr)2 E(ocedur)
+-.36 E(e)-.296 E F3(and)2 E F5(function)2 E F3(more or less interchang)2
+E(ably)-.04 E(.)-.52 E F0(23)282.5 756 Q EP
+%%Page: 24 24
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF(unique instances of other catalogs.)142.826 97.2
+Q 13.75(\(4\) There)113.5 114.3 R .222(are man)2.972 F 2.972(ya)-.165 G
+(ttrib)-2.972 E .222(utes and relationships that ha)-.22 F .552 -.165
+(ve o)-.22 H -.165(bv).165 G .222(ious meanings, b).165 F .222(ut there)
+-.22 F 1.599(are man)142.826 127.5 R 4.349(y\()-.165 G 1.599
+(particularly those that ha)-4.349 F 1.928 -.165(ve t)-.22 H 4.348(od)
+.165 G 4.348(ow)-4.348 G 1.598(ith access methods\) that do not.)-4.348
+F 1.899(The relationships between)142.826 140.7 R/F1 11/Courier@0 SF
+(pg_am)4.649 E F0(,)A F1(pg_amop)4.649 E F0(,)A F1 -1.95
+(pg_amproc, pg_operator)4.65 F F0(and)142.826 153.9 Q F1(pg_opclass)
+4.062 E F0 1.312
+(are particularly hard to understand and will be described in)4.062 F
+.679(depth \(in the section on interf)142.826 167.1 R .68
+(acing types and operators to indices\) after we ha)-.11 F -.165(ve)-.22
+G(discussed basic e)142.826 180.3 Q(xtensions.)-.165 E/F2 11
+/Times-Bold@0 SF(24)282.5 756 Q EP
+%%Page: 25 25
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(7. EXTENDING)72 165.4 R
+(SQL: FUNCTIONS)4.75 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86
+178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5
+178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119
+178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL
+135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6
+DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5
+178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6
+174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6
+190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5
+178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229
+178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL
+245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6
+DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5
+178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6
+284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6
+300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5
+178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339
+178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL
+355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6
+DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5
+178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6
+394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6
+410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5
+178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449
+178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL
+465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6
+DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5
+178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11
+/Times-Roman@0 SF .665(As it turns out, part of de\214ning a ne)108
+208.9 R 3.415(wt)-.275 G .664
+(ype is the de\214nition of functions that describe its)-3.415 F(beha)
+108 222.1 Q(vior)-.22 E 6.346(.C)-.605 G(onsequently)-6.346 E 3.596(,w)
+-.715 G .846(hile it is possible to de\214ne a ne)-3.596 F 3.596(wf)
+-.275 G .847(unction without de\214ning a)-3.596 F(ne)108 235.3 Q 4.407
+(wt)-.275 G 1.657(ype, the re)-4.407 F -.165(ve)-.275 G 1.657
+(rse is not true.).165 F 3.417 -.88(We t)7.157 H 1.657
+(herefore describe ho).88 F 4.406(wt)-.275 G 4.406(oa)-4.406 G 1.656
+(dd ne)-4.406 F 4.406(wf)-.275 G 1.656(unctions to)-4.406 F/F2 10
+/Times-Roman@0 SF(POSTGRES)108 248.5 Q F1(before describing ho)2.75 E
+2.75(wt)-.275 G 2.75(oa)-2.75 G(dd ne)-2.75 E 2.75(wt)-.275 G(ypes.)
+-2.75 E F2(POSTGRES)108 265.6 Q F1 1.65(SQL pro)4.4 F 1.65(vides tw)
+-.165 F 4.401(ot)-.11 G 1.651(ypes of functions:)-4.401 F/F3 11
+/Times-Italic@0 SF 1.651(query langua)4.401 F 1.871 -.11(ge f)-.11 H
+(unctions).11 E F1(\(functions)4.401 E 1.675(written in SQL and)108
+278.8 R F3(pr)4.425 E -.11(og)-.495 G -.165(ra).11 G 1.675(mming langua)
+.165 F 1.895 -.11(ge f)-.11 H(unctions).11 E F1 1.675
+(\(functions written in a compiled)4.425 F .664
+(programming language such as C.\))108 292 R .664
+(Either kind of function can tak)6.164 F 3.415(eab)-.11 G .665
+(ase type, a com-)-3.415 F 1.166(posite type or some combination as ar)
+108 305.2 R 1.166(guments \(parameters\).)-.198 F 1.166
+(In addition, both kinds of)6.666 F .371
+(functions can return a base type or a composite type.)108 318.4 R(It')
+5.871 E 3.121(se)-.605 G .371(asier to de\214ne SQL functions,)-3.121 F
+(so we')108 331.6 Q(ll start with those.)-.11 E
+(Examples in this section can also be found in)108 348.7 Q/F4 11
+/Courier@0 SF(funcs.sql)2.75 E F1(and)2.75 E F4(C-code/funcs.c)2.75 E F1
+(.)A/F5 12/Times-Bold@0 SF 3(7.1. Query)72 374.9 R
+(Language \(SQL\) Functions)3 E 77.5 388.1 72 388.1 DL 80.5 388.1 75
+388.1 DL 86 388.1 80.5 388.1 DL 91.5 388.1 86 388.1 DL 97 388.1 91.5
+388.1 DL 102.5 388.1 97 388.1 DL 108 388.1 102.5 388.1 DL 113.5 388.1
+108 388.1 DL 119 388.1 113.5 388.1 DL 124.5 388.1 119 388.1 DL 130 388.1
+124.5 388.1 DL 135.5 388.1 130 388.1 DL 141 388.1 135.5 388.1 DL 146.5
+388.1 141 388.1 DL 152 388.1 146.5 388.1 DL 157.5 388.1 152 388.1 DL 163
+388.1 157.5 388.1 DL 168.5 388.1 163 388.1 DL 174 388.1 168.5 388.1 DL
+179.5 388.1 174 388.1 DL 185 388.1 179.5 388.1 DL 190.5 388.1 185 388.1
+DL 196 388.1 190.5 388.1 DL 201.5 388.1 196 388.1 DL 207 388.1 201.5
+388.1 DL 212.5 388.1 207 388.1 DL 218 388.1 212.5 388.1 DL 223.5 388.1
+218 388.1 DL 229 388.1 223.5 388.1 DL 234.5 388.1 229 388.1 DL 240 388.1
+234.5 388.1 DL 245.5 388.1 240 388.1 DL 251 388.1 245.5 388.1 DL 256.5
+388.1 251 388.1 DL 262 388.1 256.5 388.1 DL 267.5 388.1 262 388.1 DL 273
+388.1 267.5 388.1 DL 278.5 388.1 273 388.1 DL 284 388.1 278.5 388.1 DL
+289.5 388.1 284 388.1 DL 295 388.1 289.5 388.1 DL 300.5 388.1 295 388.1
+DL 306 388.1 300.5 388.1 DL 311.5 388.1 306 388.1 DL 317 388.1 311.5
+388.1 DL 322.5 388.1 317 388.1 DL 328 388.1 322.5 388.1 DL 333.5 388.1
+328 388.1 DL 339 388.1 333.5 388.1 DL 344.5 388.1 339 388.1 DL 350 388.1
+344.5 388.1 DL 355.5 388.1 350 388.1 DL 361 388.1 355.5 388.1 DL 366.5
+388.1 361 388.1 DL 372 388.1 366.5 388.1 DL 377.5 388.1 372 388.1 DL 383
+388.1 377.5 388.1 DL 388.5 388.1 383 388.1 DL 394 388.1 388.5 388.1 DL
+399.5 388.1 394 388.1 DL 405 388.1 399.5 388.1 DL 410.5 388.1 405 388.1
+DL 416 388.1 410.5 388.1 DL 421.5 388.1 416 388.1 DL 427 388.1 421.5
+388.1 DL 432.5 388.1 427 388.1 DL 438 388.1 432.5 388.1 DL 443.5 388.1
+438 388.1 DL 449 388.1 443.5 388.1 DL 454.5 388.1 449 388.1 DL 460 388.1
+454.5 388.1 DL 465.5 388.1 460 388.1 DL 471 388.1 465.5 388.1 DL 476.5
+388.1 471 388.1 DL 482 388.1 476.5 388.1 DL 487.5 388.1 482 388.1 DL 493
+388.1 487.5 388.1 DL 498.5 388.1 493 388.1 DL 504 388.1 498.5 388.1 DL 3
+(7.1.1. SQL)72 418.4 R(Functions on Base T)3 E(ypes)-.888 E F1 1.475
+(The simplest possible SQL function has no ar)108 435.5 R 1.475
+(guments and simply returns a base type,)-.198 F(such as)108 448.7 Q F4
+(int4)2.75 E F1(:)A/F6 10/Courier@0 SF
+(CREATE FUNCTION one\(\) RETURNS int4)148 473.9 Q
+(AS 'SELECT 1 as RESULT' LANGUAGE 'sql';)178 486.1 Q
+(SELECT one\(\) AS answer;)148 524.3 Q .4 LW 194 554.8 148 554.8 DL
+(answer)153 564.5 Q 194 569 148 569 DL(1)153 578.7 Q 194 583.2 148 583.2
+DL 194 554.8 194 583.2 DL 148 554.8 148 583.2 DL F1 .376
+(Notice that we de\214ned a tar)108 604.9 R .376
+(get list for the function \(with the name)-.198 F F4(RESULT)3.126 E F1
+.376(\), b)B .376(ut the tar)-.22 F(-)-.22 E .773
+(get list of the query that in)108 618.1 R -.22(vo)-.44 G -.11(ke).22 G
+3.523(dt).11 G .773(he function o)-3.523 F -.165(ve)-.165 G .773
+(rrode the function').165 F 3.523(st)-.605 G(ar)-3.523 E .774(get list.)
+-.198 F(Hence,)6.274 E(the result is labelled)108 631.3 Q F4(answer)2.75
+E F1(instead of)2.75 E F4(one)2.75 E F1(.)A(It')108 648.4 Q 4.424(sa)
+-.605 G 1.674(lmost as easy to de\214ne SQL functions that tak)-4.424 F
+4.423(eb)-.11 G 1.673(ase types as ar)-4.423 F 4.423(guments. In)-.198 F
+(the)4.423 E -.165(ex)108 661.6 S(ample belo).165 E 1.43 -.715(w, n)
+-.275 H(otice ho).715 E 2.75(ww)-.275 G 2.75(er)-2.75 G(efer to the ar)
+-2.75 E(guments within the function as)-.198 E F4($1)2.75 E F1(and)2.75
+E F4($2)2.75 E F1(.)A F6
+(CREATE FUNCTION add_em\(int4, int4\) RETURNS int4)148 686.8 Q
+(AS 'SELECT $1 + $2;' LANGUAGE 'sql';)178 699 Q/F7 11/Times-Bold@0 SF
+(25)282.5 756 Q EP
+%%Page: 26 26
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(SELECT add_em\(1, 2\) AS answer;)148 96.2 Q .4 LW
+194 126.7 148 126.7 DL(answer)153 136.4 Q 194 140.9 148 140.9 DL(3)153
+150.6 Q 194 155.1 148 155.1 DL 194 126.7 194 155.1 DL 148 126.7 148
+155.1 DL/F1 12/Times-Bold@0 SF 3(7.1.2. SQL)72 189.8 R
+(Functions on Composite T)3 E(ypes)-.888 E/F2 11/Times-Roman@0 SF 1.145
+(When specifying functions with ar)108 206.9 R 1.146
+(guments of composite types \(such as)-.198 F/F3 11/Courier@0 SF(EMP)
+3.896 E F2 1.146(\), we must)B .317(not only specify which ar)108 220.1
+R .317(gument we w)-.198 F .316(ant \(as we did abo)-.11 F .646 -.165
+(ve w)-.165 H(ith).165 E F3($1)3.066 E F2(and)3.066 E F3($2)3.066 E F2
+3.066(\)b)C .316(ut also the)-3.286 F(attrib)108 233.3 Q .393
+(utes of that ar)-.22 F 3.143(gument. F)-.198 F .393(or e)-.165 F .393
+(xample, tak)-.165 F 3.143(et)-.11 G .393(he function)-3.143 F F3
+(double_salary)3.143 E F2 .393(that com-)3.143 F
+(putes what your salary w)108 246.5 Q(ould be if it were doubled.)-.11 E
+F0(CREATE FUNCTION double_salary\(EMP\) RETURNS int4)148 271.7 Q
+(AS 'SELECT $1.salary * 2 AS salary;' LANGUAGE 'sql';)178 283.9 Q
+(SELECT name, double_salary\(EMP\) AS dream)148 308.3 Q(FROM EMP)160
+320.5 Q(WHERE EMP.dept = 'toy';)160 332.7 Q 227 363.2 148 363.2 DL 9
+(name dream)153 372.9 R 227 377.4 148 377.4 DL 15(Sam 2400)153 387.1 R
+227 391.6 148 391.6 DL 227 363.2 227 391.6 DL 148 363.2 148 391.6 DL
+184.5 363.2 184.5 391.6 DL F2(Notice the use of the syntax)108 413.3 Q
+F3($1.salary)2.75 E F2(.)A .755(Before launching into the subject of fu\
+nctions that return composite types, we must \214rst)108 430.4 R .063
+(introduce the)108 443.6 R/F4 11/Times-Italic@0 SF(function)2.813 E F2
+.063(notation for projecting attrib)2.813 F 2.813(utes. The)-.22 F .064
+(simple w)2.814 F .064(ay to e)-.11 F .064(xplain this is)-.165 F 1.137
+(that we can usually use the notation)108 456.8 R F3(attribute\(class\))
+3.886 E F2(and)3.886 E F3(class.attribute)3.886 E F2(interchang)108 470
+Q(ably)-.055 E(.)-.715 E F0(--)148 495.2 Q(-- this is the same as:)148
+507.4 Q 11(-- SELECT)148 519.6 R
+(EMP.name AS youngster FROM EMP WHERE EMP.age < 30)6 E(--)148 531.8 Q
+(SELECT name\(EMP\) AS youngster)148 544 Q(FROM EMP)148 556.2 Q
+(WHERE age\(EMP\) < 30;)148 568.4 Q 212 598.9 148 598.9 DL(youngster)153
+608.6 Q 212 613.1 148 613.1 DL(Sam)153 622.8 Q 212 627.3 148 627.3 DL
+212 598.9 212 627.3 DL 148 598.9 148 627.3 DL F2(As we shall see, ho)108
+649 Q(we)-.275 E -.165(ve)-.275 G .88 -.44(r, t).165 H(his is not al).44
+E -.11(wa)-.11 G(ys the case.).11 E .763
+(This function notation is important when we w)108 666.1 R .764
+(ant to use a function that returns a single)-.11 F 3.825(instance. W)
+108 679.3 R 3.825(ed)-.88 G 3.825(ot)-3.825 G 1.075
+(his by assembling the entire instance within the function, attrib)
+-3.825 F 1.074(ute by)-.22 F(attrib)108 692.5 Q 2.75(ute. This)-.22 F
+(is an e)2.75 E(xample of a function that returns a single)-.165 E F3
+(EMP)2.75 E F2(instance:)2.75 E/F5 11/Times-Bold@0 SF(26)282.5 756 Q EP
+%%Page: 27 27
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(CREATE FUNCTION new_emp\(\) RETURNS EMP)148 96.2 Q
+(AS 'SELECT \\'None\\'::text AS name,)166 108.4 Q(1000 AS salary,)232
+120.6 Q(25 AS age,)232 132.8 Q(\\'none\\'::char16 AS dept;')232 145 Q
+(LANGUAGE 'sql';)166 157.2 Q/F1 11/Times-Roman@0 SF .103
+(In this case we ha)108 183.4 R .433 -.165(ve s)-.22 H .103
+(peci\214ed each of the attrib).165 F .103(utes with a constant v)-.22 F
+.103(alue, b)-.275 F .104(ut an)-.22 F 2.854(yc)-.165 G(ompu-)-2.854 E
+(tation or e)108 196.6 Q(xpression could ha)-.165 E .33 -.165(ve b)-.22
+H(een substituted for these constants.).165 E .014
+(De\214ning a function lik)108 213.7 R 2.764(et)-.11 G .014
+(his can be trick)-2.764 F 4.194 -.715(y. S)-.165 H .014
+(ome of the more important ca).715 F -.165(ve)-.22 G .013
+(ats are as fol-).165 F(lo)108 226.9 Q(ws:)-.275 E 5.5<8354>113.5 244 S
+.286(he tar)-5.5 F .286(get list order must be)-.198 F/F2 11
+/Times-Bold@0 SF(exactly)3.036 E F1 .286
+(the same as that in which the attrib)3.036 F .286(utes appear in)-.22 F
+(the)122.85 257.2 Q F2(CREA)2.75 E(TE T)-1.045 E(ABLE)-.99 E F1
+(statement \(or when you e)2.75 E -.165(xe)-.165 G(cute a).165 E/F3 11
+/Courier@0 SF(.*)2.75 E F1(query\).)5.5 E 5.5<8359>113.5 270.4 S .556
+(ou must be careful to typecast the e)-6.71 F .555(xpressions \(using)
+-.165 F F3(::)3.305 E F1 3.305(\)v)C .555(ery carefully or you will)
+-3.47 F(see the follo)122.85 283.6 Q(wing error:)-.275 E F0
+(WARN::function declared to return type EMP does not retrieve \(EMP.*\))
+162.85 308.8 Q F1 5.5<8357>113.5 338.9 S 3.364
+(hen calling a function that returns an instance, we cannot retrie)-5.5
+F 3.695 -.165(ve t)-.275 H 3.365(he entire).165 F 4.436(instance. W)
+122.85 352.1 R 4.436(em)-.88 G 1.686(ust either project an attrib)-4.436
+F 1.685(ute out of the instance or pass the entire)-.22 F
+(instance into another function.)122.85 365.3 Q F0
+(SELECT name\(new_emp\(\)\) AS nobody;)162.85 390.5 Q .4 LW 208.85 421
+162.85 421 DL(nobody)167.85 430.7 Q 208.85 435.2 162.85 435.2 DL(None)
+167.85 444.9 Q 208.85 449.4 162.85 449.4 DL 208.85 421 208.85 449.4 DL
+162.85 421 162.85 449.4 DL F1 5.5<8354>113.5 471.1 S .701(he reason wh)
+-5.5 F 2.131 -.715(y, i)-.055 H 3.451(ng).715 G .702
+(eneral, we must use the function syntax for projecting attrib)-3.451 F
+(utes)-.22 E .418(of function return v)122.85 484.3 R .418
+(alues is that the parser just doesn')-.275 F 3.168(tu)-.198 G .418
+(nderstand the other \(dot\) syn-)-3.168 F
+(tax for projection when combined with function calls.)122.85 497.5 Q F0
+(SELECT new_emp\(\).name AS nobody;)162.85 522.7 Q
+(WARN:parser: syntax error at or near ".")162.85 534.9 Q F1(An)108 565 Q
+3.873(yc)-.165 G 1.124(ollection of commands in the SQL query language \
+can be packaged together and)-3.873 F 2.551(de\214ned as a function.)108
+578.2 R 2.551(The commands can include updates \(i.e.,)8.051 F F2
+(insert)5.301 E F1(,)A F2(update)5.301 E F1(and)5.301 E F2(delete)108
+591.4 Q F1 4.825(\)a)C 4.825(sw)-4.825 G 2.075(ell as)-4.825 F F2
+(select)4.825 E F1 4.825(queries. Ho)4.825 F(we)-.275 E -.165(ve)-.275 G
+2.955 -.44(r, t).165 H 2.075(he \214nal command must be a).44 F F2
+(select)4.825 E F1(that)4.826 E(returns whate)108 604.6 Q -.165(ve)-.275
+G 2.75(ri).165 G 2.75(ss)-2.75 G(peci\214ed as the function')-2.75 E(s)
+-.605 E F3(returntype)2.75 E F1(.)A F0
+(CREATE FUNCTION clean_EMP \(\) RETURNS int4)148 629.8 Q
+(AS 'DELETE FROM EMP WHERE EMP.salary <= 0;)166 642 Q
+(SELECT 1 AS ignore_this')190 654.2 Q(LANGUAGE 'sql';)166 666.4 Q
+(SELECT clean_EMP\(\);)148 690.8 Q F2(27)282.5 756 Q EP
+%%Page: 28 28
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.4 LW 164 88.5 148 88.5 DL/F0 10/Courier@0 SF(x)153 98.2 Q 164 102.7 148
+102.7 DL(1)153 112.4 Q 164 116.9 148 116.9 DL 164 88.5 164 116.9 DL 148
+88.5 148 116.9 DL/F1 12/Times-Bold@0 SF 3(7.2. Pr)72 151.6 R
+(ogramming Language Functions)-.216 E .44 LW 77.5 164.8 72 164.8 DL 80.5
+164.8 75 164.8 DL 86 164.8 80.5 164.8 DL 91.5 164.8 86 164.8 DL 97 164.8
+91.5 164.8 DL 102.5 164.8 97 164.8 DL 108 164.8 102.5 164.8 DL 113.5
+164.8 108 164.8 DL 119 164.8 113.5 164.8 DL 124.5 164.8 119 164.8 DL 130
+164.8 124.5 164.8 DL 135.5 164.8 130 164.8 DL 141 164.8 135.5 164.8 DL
+146.5 164.8 141 164.8 DL 152 164.8 146.5 164.8 DL 157.5 164.8 152 164.8
+DL 163 164.8 157.5 164.8 DL 168.5 164.8 163 164.8 DL 174 164.8 168.5
+164.8 DL 179.5 164.8 174 164.8 DL 185 164.8 179.5 164.8 DL 190.5 164.8
+185 164.8 DL 196 164.8 190.5 164.8 DL 201.5 164.8 196 164.8 DL 207 164.8
+201.5 164.8 DL 212.5 164.8 207 164.8 DL 218 164.8 212.5 164.8 DL 223.5
+164.8 218 164.8 DL 229 164.8 223.5 164.8 DL 234.5 164.8 229 164.8 DL 240
+164.8 234.5 164.8 DL 245.5 164.8 240 164.8 DL 251 164.8 245.5 164.8 DL
+256.5 164.8 251 164.8 DL 262 164.8 256.5 164.8 DL 267.5 164.8 262 164.8
+DL 273 164.8 267.5 164.8 DL 278.5 164.8 273 164.8 DL 284 164.8 278.5
+164.8 DL 289.5 164.8 284 164.8 DL 295 164.8 289.5 164.8 DL 300.5 164.8
+295 164.8 DL 306 164.8 300.5 164.8 DL 311.5 164.8 306 164.8 DL 317 164.8
+311.5 164.8 DL 322.5 164.8 317 164.8 DL 328 164.8 322.5 164.8 DL 333.5
+164.8 328 164.8 DL 339 164.8 333.5 164.8 DL 344.5 164.8 339 164.8 DL 350
+164.8 344.5 164.8 DL 355.5 164.8 350 164.8 DL 361 164.8 355.5 164.8 DL
+366.5 164.8 361 164.8 DL 372 164.8 366.5 164.8 DL 377.5 164.8 372 164.8
+DL 383 164.8 377.5 164.8 DL 388.5 164.8 383 164.8 DL 394 164.8 388.5
+164.8 DL 399.5 164.8 394 164.8 DL 405 164.8 399.5 164.8 DL 410.5 164.8
+405 164.8 DL 416 164.8 410.5 164.8 DL 421.5 164.8 416 164.8 DL 427 164.8
+421.5 164.8 DL 432.5 164.8 427 164.8 DL 438 164.8 432.5 164.8 DL 443.5
+164.8 438 164.8 DL 449 164.8 443.5 164.8 DL 454.5 164.8 449 164.8 DL 460
+164.8 454.5 164.8 DL 465.5 164.8 460 164.8 DL 471 164.8 465.5 164.8 DL
+476.5 164.8 471 164.8 DL 482 164.8 476.5 164.8 DL 487.5 164.8 482 164.8
+DL 493 164.8 487.5 164.8 DL 498.5 164.8 493 164.8 DL 504 164.8 498.5
+164.8 DL 3(7.2.1. Pr)72 204.2 R(ogramming Language Functions on Base T)
+-.216 E(ypes)-.888 E/F2 11/Times-Roman@0 SF(Internally)108 221.3 Q(,)
+-.715 E/F3 10/Times-Roman@0 SF(POSTGRES)2.921 E F2(re)2.921 E -.055(ga)
+-.165 G .171(rds a base type as a \231blob of memory).055 F 4.462 -.77
+(.\232 T)-.715 H .172(he user).77 F .172(-de\214ned func-)-.22 F .359
+(tions that you de\214ne o)108 234.5 R -.165(ve)-.165 G 3.108(rat).165 G
+.358(ype in turn de\214ne the w)-3.108 F .358(ay that)-.11 F F3
+(POSTGRES)3.108 E F2 .358(can operate on it.)3.108 F 1.561(That is,)108
+247.7 R F3(POSTGRES)4.311 E F2 1.562(will only store and retrie)4.311 F
+1.892 -.165(ve t)-.275 H 1.562(he data from disk and use your user).165
+F(-)-.22 E(de\214ned functions to input, process, and output the data.)
+108 260.9 Q(Base types can ha)108 278 Q .33 -.165(ve o)-.22 H
+(ne of three internal formats:).165 E 5.5<8370>113.5 295.1 S(ass by v)
+-5.5 E(alue, \214x)-.275 E(ed-length)-.165 E 5.5<8370>113.5 308.3 S
+(ass by reference, \214x)-5.5 E(ed-length)-.165 E 5.5<8370>113.5 321.5 S
+(ass by reference, v)-5.5 E(ariable-length)-.275 E(By-v)108 338.6 Q .513
+(alue types can only be 1, 2 or 4 bytes in length \(e)-.275 F -.165(ve)
+-.275 G 3.262(ni).165 G 3.262(fy)-3.262 G .512
+(our computer supports by-)-3.262 F -.275(va)108 351.8 S 1.546
+(lue types of other sizes\).).275 F F3(POSTGRES)7.046 E F2 1.547
+(itself only passes inte)4.296 F 1.547(ger types by v)-.165 F 4.297
+(alue. Y)-.275 F(ou)-1.21 E .012
+(should be careful to de\214ne your types such that the)108 365 R 2.762
+(yw)-.165 G .012(ill be the same size \(in bytes\) on all)-2.762 F 4.056
+(architectures. F)108 378.2 R 1.306(or e)-.165 F 1.306(xample, the)-.165
+F/F4 11/Courier@0 SF(long)4.056 E F2 1.307
+(type is dangerous because it is 4 bytes on some)4.056 F 1.213
+(machines and 8 bytes on others, whereas)108 391.4 R F4(int)3.963 E F2
+1.213(type is 4 bytes on most)3.963 F F3(UNIX)3.963 E F2(machines)3.963
+E 1.798(\(though not on most personal computers\).)108 404.6 R 4.548(Ar)
+7.298 G 1.798(easonable implementation of the)-4.548 F F4(int4)4.548 E
+F2(type on)108 417.8 Q F3(UNIX)2.75 E F2(machines might be:)2.75 E F0
+(/* 4-byte integer, passed by value */)148 443 Q(typedef int int4;)148
+455.2 Q F2 .251(On the other hand, \214x)108 481.4 R .251
+(ed-length types of an)-.165 F 3.001(ys)-.165 G .25
+(ize may be passed by-reference.)-3.001 F -.165(Fo)5.75 G 3(re).165 G
+(xam-)-3.165 E(ple, here is a sample implementation of the)108 494.6 Q
+F3(POSTGRES)2.75 E F4(char16)2.75 E F2(type:)2.75 E F0
+(/* 16-byte structure, passed by reference */)148 519.8 Q
+(typedef struct {)148 532 Q(char data[16];)172 544.2 Q 6(}c)148 556.4 S
+(har16;)-6 E F2 1.537(Only pointers to such types can be used when pass\
+ing them in and out of)108 582.6 R F3(POSTGRES)4.287 E F2(functions.)108
+595.8 Q(Finally)108 612.9 Q 4.149(,a)-.715 G 1.399(ll v)-4.149 F 1.399
+(ariable-length types must also be passed by reference.)-.275 F 1.399
+(All v)6.899 F(ariable-length)-.275 E 1.027(types must be)108 626.1 R
+1.027(gin with a length \214eld of e)-.165 F 1.028
+(xactly 4 bytes, and all data to be stored within)-.165 F 1.456
+(that type must be located in the memory immediately follo)108 639.3 R
+1.456(wing that length \214eld.)-.275 F(The)6.956 E .613(length \214eld\
+ is the total length of the structure \(i.e., it includes the size of t\
+he length \214eld)108 652.5 R 2.75(itself\). W)108 665.7 R 2.75(ec)-.88
+G(an de\214ne the)-2.75 E F4(text)2.75 E F2(type as follo)2.75 E(ws:)
+-.275 E F0(typedef struct {)148 690.9 Q(int4 length;)172 703.1 Q/F5 11
+/Times-Bold@0 SF(28)282.5 756 Q EP
+%%Page: 29 29
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(char data[1];)172 96.2 Q 6(}t)148 108.4 S(ext;)-6 E
+/F1 11/Times-Roman@0 SF(Ob)108 134.6 Q(viously)-.165 E 3.247(,t)-.715 G
+(he)-3.247 E/F2 11/Courier@0 SF(data)3.247 E F1 .496
+(\214eld is not long enough to hold all possible strings \212 it')3.247
+F 3.246(si)-.605 G(mpossi-)-3.246 E .825
+(ble to declare such a structure in C.)108 147.8 R .825
+(When manipulating v)6.325 F .825(ariable-length types, we must)-.275 F
+1.108(be careful to allocate the correct amount of memory and initializ\
+e the length \214eld.)108 161 R -.165(Fo)6.607 G(r).165 E -.165(ex)108
+174.2 S .75(ample, if we w).165 F .75(anted to store 40 bytes in a)-.11
+F F2(text)3.501 E F1 .751(structure, we might use a code frag-)3.501 F
+(ment lik)108 187.4 Q 2.75(et)-.11 G(his:)-2.75 E F0
+(#include "postgres.h")148 212.6 Q(#include "utils/palloc.h")148 224.8 Q
+(...)148 249.2 Q(char buffer[40]; /* our source data */)148 273.6 Q(...)
+148 298 Q(text *destination = \(text *\) palloc\(VARHDRSZ + 40\);)148
+322.4 Q(destination->length = VARHDRSZ + 40;)148 334.6 Q
+(memmove\(destination->data, buffer, 40\);)148 346.8 Q(...)148 371.2 Q
+F1(No)108 401.3 Q 2.913(wt)-.275 G .163(hat we')-2.913 F .493 -.165
+(ve g)-.55 H .163(one o).165 F -.165(ve)-.165 G 2.912(ra).165 G .162
+(ll of the possible structures for base types, we can sho)-2.912 F 2.912
+(ws)-.275 G(ome)-2.912 E -.165(ex)108 414.5 S
+(amples of real functions. Suppose).165 E F2(funcs.c)2.75 E F1(look lik)
+2.75 E(e:)-.11 E F0(#include <string.h>)148 439.7 Q
+(#include "postgres.h")148 451.9 Q(/* for char16, etc. */)12 E
+(#include "utils/palloc.h" /* for palloc */)148 464.1 Q(int)148 488.5 Q
+(add_one\(int arg\))148 500.7 Q({)148 512.9 Q(return\(arg + 1\);)172
+525.1 Q(})148 537.3 Q(char16 *)148 561.7 Q
+(concat16\(char16 *arg1, char16 *arg2\))148 573.9 Q({)148 586.1 Q
+(char16 *new_c16 = \(char16 *\) palloc\(sizeof\(char16\)\);)172 598.3 Q
+(memset\(\(void *\) new_c16, 0, sizeof\(char16\)\);)172 622.7 Q
+(\(void\) strncpy\(new_c16, arg1, 16\);)172 634.9 Q
+(return \(char16 *\)\(strncat\(new_c16, arg2, 16\)\);)172 647.1 Q(})148
+659.3 Q(text *)148 683.7 Q(copytext\(text *t\))148 695.9 Q({)148 708.1 Q
+(/*)172 720.3 Q/F3 11/Times-Bold@0 SF(29)282.5 756 Q EP
+%%Page: 30 30
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF 6(*V)178 96.2 S
+(ARSIZE is the total size of the struct in bytes.)-6 E(*/)178 108.4 Q
+(text *new_t = \(text *\) palloc\(VARSIZE\(t\)\);)172 120.6 Q
+(memset\(new_t, 0, VARSIZE\(t\)\);)172 145 Q
+(VARSIZE\(new_t\) = VARSIZE\(t\);)172 169.4 Q(/*)172 181.6 Q 6(*V)178
+193.8 S(ARDATA is a pointer to the data region of the struct.)-6 E(*/)
+178 206 Q(memcpy\(\(void *\) VARDATA\(new_t\), /* destination */)172
+218.2 Q(\(void *\) VARDATA\(t\),)214 230.4 Q(/* source */)30 E 78
+(VARSIZE\(t\)-VARHDRSZ\); /*)214 242.6 R(how many bytes */)6 E
+(return\(new_t\);)172 267 Q(})148 279.2 Q/F1 11/Times-Roman@0 SF(On)108
+305.4 Q/F2 10/Times-Roman@0 SF(OSF/1)2.75 E F1(we w)2.75 E(ould type:)
+-.11 E F0(CREATE FUNCTION add_one\(int4\) RETURNS int4)148 330.6 Q
+(AS '/usr/local/postgres95/tutorial/obj/funcs.so' LANGUAGE 'c';)178
+342.8 Q(CREATE FUNCTION concat16\(char16, char16\) RETURNS char16)148
+367.2 Q(AS '/usr/local/postgres95/tutorial/obj/funcs.so' LANGUAGE 'c';)
+178 379.4 Q(CREATE FUNCTION copytext\(text\) RETURNS text)148 403.8 Q
+(AS '/usr/local/postgres95/tutorial/obj/funcs.so' LANGUAGE 'c';)178 416
+Q F1 .412(On other systems, we might ha)108 442.2 R .742 -.165(ve t)-.22
+H 3.162(om).165 G(ak)-3.162 E 3.162(et)-.11 G .412(he \214lename end in)
+-3.162 F/F3 11/Courier@0 SF(.sl)3.162 E F1 .413(\(to indicate that it')
+3.162 F 3.163(sa)-.605 G(shared library\).)108 455.4 Q/F4 12
+/Times-Bold@0 SF 3(7.2.2. Pr)72 481.6 R
+(ogramming Language Functions on Composite T)-.216 E(ypes)-.888 E F1
+1.054(Composite types do not ha)108 498.7 R 1.384 -.165(ve a \214)-.22 H
+-.165(xe).165 G 3.804(dl).165 G 1.054(ayout lik)-3.804 F 3.804(eC)-.11 G
+3.803(structures. Instances)-.001 F 1.053(of a composite)3.803 F .636
+(type may contain null \214elds.)108 511.9 R .637
+(In addition, composite types that are part of an inheritance)6.136 F
+(hierarch)108 525.1 Q 2.858(ym)-.055 G .108(ay ha)-2.858 F .438 -.165
+(ve d)-.22 H(if).165 E .107
+(ferent \214elds than other members of the same inheritance hierarch)
+-.275 F -.715(y.)-.055 G(Therefore,)108 538.3 Q F2(POSTGRES)3.867 E F1
+(pro)3.867 E 1.117(vides a procedural interf)-.165 F 1.117
+(ace for accessing \214elds of composite)-.11 F(types from C.)108 551.5
+Q(As)108 568.6 Q F2(POSTGRES)3.483 E F1 .733(processes a set of instanc\
+es, each instance will be passed into your func-)3.483 F
+(tion as an opaque structure of type TUPLE.)108 581.8 Q(Suppose we w)108
+598.9 Q(ant to write a function to answer the query)-.11 E F0 6(*S)148
+624.1 S(ELECT name, c_overpaid\(EMP, 1500\) AS overpaid)-6 E(FROM EMP)
+160 636.3 Q(WHERE name = 'Bill' or name = 'Sam';)160 648.5 Q F1
+(In the query abo)108 674.7 Q -.165(ve)-.165 G 2.75(,w).165 G 2.75(ec)
+-2.75 G(an de\214ne)-2.75 E F3(c_overpaid)2.75 E F1(as:)2.75 E F0
+(#include "postgres.h")148 699.9 Q(/* for char16, etc. */)12 E
+(#include "libpq-fe.h" /* for TUPLE */)148 712.1 Q/F5 11/Times-Bold@0 SF
+(30)282.5 756 Q EP
+%%Page: 31 31
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(bool)148 96.2 Q
+(c_overpaid\(TUPLE t,/* the current instance of EMP */)148 108.4 Q
+(int4 limit\))214 120.6 Q({)148 132.8 Q(bool isnull = false;)172 145 Q
+(int4 salary;)172 157.2 Q
+(salary = \(int4\) GetAttributeByName\(t, "salary", &isnull\);)172 181.6
+Q(if \(isnull\))172 206 Q(return \(false\);)196 218.2 Q
+(return\(salary > limit\);)172 230.4 Q(})148 242.6 Q/F1 11/Courier@0 SF
+(GetAttributeByName)108 268.8 Q/F2 11/Times-Roman@0 SF .07(is the)2.82 F
+/F3 10/Times-Roman@0 SF(POSTGRES)2.82 E F2 .07
+(system function that returns attrib)2.82 F .07(utes out of)-.22 F .165
+(the current instance.)108 282 R .164(It has three ar)5.665 F .164
+(guments: the ar)-.198 F .164(gument of type TUPLE passed into the)-.198
+F .471(function, the name of the desired attrib)108 295.2 R .472
+(ute, and a return parameter that describes whether)-.22 F .917
+(the attrib)108 308.4 R .917(ute is null.)-.22 F F1(GetAttributeByName)
+6.417 E F2 .916(will align data properly so you can cast)3.667 F .472
+(its return v)108 321.6 R .472(alue to the desired type.)-.275 F -.165
+(Fo)5.972 G 3.222(re).165 G .472(xample, if you ha)-3.387 F .803 -.165
+(ve a)-.22 H 3.223(na).165 G(ttrib)-3.223 E(ute)-.22 E F1(name)3.223 E
+F2 .473(which is)3.223 F(of the type)108 334.8 Q F1(char16)2.75 E F2
+2.75(,t)C(he)-2.75 E F1(GetAttributeByName)2.75 E F2(call w)2.75 E
+(ould look lik)-.11 E(e:)-.11 E F0(char *str;)148 360 Q(...)148 372.2 Q
+(str = \(char *\) GetAttributeByName\(t, "name", &isnull\))148 384.4 Q
+F2(The follo)108 414.5 Q(wing query lets)-.275 E F3(POSTGRES)2.75 E F2
+(kno)2.75 E 2.75(wa)-.275 G(bout the)-2.75 E F1(c_overpaid)2.75 E F2
+(function:)2.75 E F0 6(*C)148 439.7 S
+(REATE FUNCTION c_overpaid\(EMP, int4\) RETURNS bool)-6 E
+(AS '/usr/local/postgres95/tutorial/obj/funcs.so' LANGUAGE 'c';)178
+451.9 Q F2 .212(While there are w)108 482 R .212(ays to construct ne)
+-.11 F 2.962(wi)-.275 G .211(nstances or modify e)-2.962 F .211
+(xisting instances from within)-.165 F 2.75(aCf)108 495.2 S
+(unction, these are f)-2.75 E(ar too comple)-.11 E 2.75(xt)-.165 G 2.75
+(od)-2.75 G(iscuss in this manual.)-2.75 E/F4 12/Times-Bold@0 SF 3
+(7.2.3. Ca)72 521.4 R -.12(ve)-.3 G(ats).12 E F2 2.789 -.88(We n)108
+538.5 T 1.579 -.275(ow t).88 H 1.03(urn to the more dif).275 F 1.03
+(\214cult task of writing programming language functions.)-.275 F(Be)
+6.53 E -.11(wa)108 551.7 S 1.163
+(rned: this section of the manual will not mak).11 F 3.913(ey)-.11 G
+1.163(ou a programmer)-3.913 F 6.663(.Y)-.605 G 1.163(ou must ha)-7.873
+F 1.493 -.165(ve a)-.22 H 1.023
+(good understanding of C \(including the use of pointers and the)108
+564.9 R F1(malloc)3.773 E F2 1.023(memory man-)3.773 F
+(ager\) before trying to write C functions for use with)108 578.1 Q F3
+(POSTGRES)2.75 E F2(.)A .757(While it may be possible to load functions\
+ written in languages other than C into)108 595.2 R F3(POST)3.506 E(-)
+-.92 E(GRES)108 608.4 Q F2 3.613(,t)C .863(his is often dif)-3.613 F
+.864(\214cult \(when it is possible at all\) because other languages, s\
+uch as)-.275 F F3(FOR)108 621.6 Q(TRAN)-.6 E F2 1.087(and P)3.837 F
+1.087(ascal often do not follo)-.165 F 3.837(wt)-.275 G 1.086
+(he same \231calling con)-3.837 F -.165(ve)-.44 G 1.086(ntion\232 as C.)
+.165 F 1.086(That is,)6.586 F 1.24(other languages do not pass ar)108
+634.8 R 1.24(gument and return v)-.198 F 1.241
+(alues between functions in the same)-.275 F -.11(wa)108 648 S 4.214
+-.715(y. F).11 H .034(or this reason, we will assume that your programm\
+ing language functions are writ-).55 F(ten in C.)108 661.2 Q
+(The basic rules for b)108 678.3 Q(uilding C functions are as follo)-.22
+E(ws:)-.275 E 13.75(\(1\) Most)113.5 695.4 R 1.235
+(of the header \(include\) \214les for)3.985 F F3(POSTGRES)3.985 E F2
+1.236(should already be installed in)3.985 F F1
+(/usr/local/postgres95/include)142.826 708.6 Q F2 2.464
+(\(see Figure 2\).)5.214 F -1.21(Yo)7.964 G 5.214(us)1.21 G 2.464
+(hould al)-5.214 F -.11(wa)-.11 G(ys).11 E(include)142.826 721.8 Q/F5 11
+/Times-Bold@0 SF(31)282.5 756 Q EP
+%%Page: 32 32
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(-I/usr/local/postgres95/include)182.826 96.2 Q/F1 11
+/Times-Roman@0 SF 1.373(on your)142.826 122.4 R/F2 11/Courier@0 SF(cc)
+4.123 E F1 1.373(command lines.)4.123 F 1.373
+(Sometimes, you may \214nd that you require header)6.873 F .198
+(\214les that are in the serv)142.826 135.6 R .197
+(er source itself \(i.e., you need a \214le we ne)-.165 F .197
+(glected to install)-.165 F(in)142.826 148.8 Q F2(include)2.75 E F1 2.75
+(\). In)B(those cases you may need to add one or more of)2.75 E F0
+(-I/usr/local/postgres95/src/backend)182.826 174 Q
+(-I/usr/local/postgres95/src/backend/include)182.826 186.2 Q
+(-I/usr/local/postgres95/src/backend/port/<PORTNAME>)182.826 198.4 Q
+(-I/usr/local/postgres95/src/backend/obj)182.826 210.6 Q F1(\(where)
+142.826 236.8 Q F2(<PORTNAME>)2.75 E F1(is the name of the port, e.g.,)
+2.75 E F2(alpha)2.75 E F1(or)2.75 E F2(sparc\).)2.75 E F1 13.75
+(\(2\) When)113.5 253.9 R 2.892(allocating memory)5.642 F 5.642(,u)-.715
+G 2.892(se the)-5.642 F/F3 10/Times-Roman@0 SF(POSTGRES)5.643 E F1
+(routines)5.643 E F2(palloc)5.643 E F1(and)5.643 E F2(pfree)5.643 E F1
+.088(instead of the corresponding C library routines)142.826 267.1 R F2
+(malloc)2.838 E F1(and)2.838 E F2(free)2.838 E F1 5.588(.T)C .088
+(he memory)-5.588 F .857(allocated by)142.826 280.3 R F2(palloc)3.607 E
+F1 .857(will be freed automatically at the end of each transaction,)
+3.607 F(pre)142.826 293.5 Q -.165(ve)-.275 G(nting memory leaks.).165 E
+13.75(\(3\) Al)113.5 310.6 R -.11(wa)-.11 G .427
+(ys zero the bytes of your structures using).11 F F2(memset)3.177 E F1
+(or)3.177 E F2(bzero)3.177 E F1 5.927(.S)C -2.365 -.275(ev e)-5.927 H
+.427(ral rou-).275 F .521(tines \(such as the hash access method, hash \
+join and the sort algorithm\) compute)142.826 323.8 R 1.463
+(functions of the ra)142.826 337 R 4.213(wb)-.165 G 1.463
+(its contained in your structure.)-4.213 F(Ev)6.963 E 1.463
+(en if you initialize all)-.165 F .133
+(\214elds of your structure, there may be se)142.826 350.2 R -.165(ve)
+-.275 G .133(ral bytes of alignment padding \(holes in).165 F
+(the structure\) that may contain g)142.826 363.4 Q(arbage v)-.055 E
+(alues.)-.275 E 13.75(\(4\) Most)113.5 380.5 R .496(of the internal)
+3.246 F F3(POSTGRES)3.246 E F1 .496(types are declared in)3.246 F F2
+(postgres.h)3.245 E F1 3.245(,s)C 3.245(oi)-3.245 G(t')-3.245 E 3.245
+(su)-.605 G(su-)-3.245 E
+(ally a good idea to include that \214le as well.)142.826 393.7 Q 13.75
+(\(5\) Compiling)113.5 410.8 R .214
+(and loading your object code so that it can be dynamically loaded into)
+2.964 F F3(POSTGRES)142.826 424 Q F1(al)2.83 E -.11(wa)-.11 G .08
+(ys requires special \215ags.).11 F .079
+(See Appendix A for a detailed e)5.58 F(xplana-)-.165 E(tion of ho)
+142.826 437.2 Q 2.75(wt)-.275 G 2.75(od)-2.75 G 2.75(oi)-2.75 G 2.75(tf)
+-2.75 G(or your particular operating system.)-2.75 E/F4 11/Times-Bold@0
+SF(32)282.5 756 Q EP
+%%Page: 33 33
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(8. EXTENDING)72 165.4 R(SQL: TYPES)
+4.75 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6
+DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL
+108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6
+DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130
+178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6
+146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5
+178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185
+178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL
+201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6
+DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5
+178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6
+240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6
+256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5
+178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295
+178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL
+311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6
+DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5
+178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6
+350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6
+366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5
+178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405
+178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL
+421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6
+DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5
+178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6
+460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6
+476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5
+178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF .275
+(As pre)108 208.9 R .275(viously mentioned, there are tw)-.275 F 3.025
+(ok)-.11 G .276(inds of types in)-3.025 F/F2 10/Times-Roman@0 SF
+(POSTGRES)3.026 E F1(:)A/F3 11/Times-Italic@0 SF(base)3.026 E F1 .276
+(types \(de\214ned)3.026 F(in a programming language\) and)108 222.1 Q
+F3(composite)2.75 E F1(types \(instances\).)2.75 E 1.449
+(Examples in this section up to interf)108 239.2 R 1.448
+(acing indices can be found in)-.11 F/F4 11/Courier@0 SF(complex.sql)
+4.198 E F1(and)A F4(complex.c)108 252.4 Q F1 5.5(.C)C(omposite e)-5.5 E
+(xamples are in)-.165 E F4(funcs.sql)2.75 E F1(.)A/F5 12/Times-Bold@0 SF
+3(8.1. User)72 278.6 R(-De\214ned T)-.444 E(ypes)-.888 E 77.5 291.8 72
+291.8 DL 80.5 291.8 75 291.8 DL 86 291.8 80.5 291.8 DL 91.5 291.8 86
+291.8 DL 97 291.8 91.5 291.8 DL 102.5 291.8 97 291.8 DL 108 291.8 102.5
+291.8 DL 113.5 291.8 108 291.8 DL 119 291.8 113.5 291.8 DL 124.5 291.8
+119 291.8 DL 130 291.8 124.5 291.8 DL 135.5 291.8 130 291.8 DL 141 291.8
+135.5 291.8 DL 146.5 291.8 141 291.8 DL 152 291.8 146.5 291.8 DL 157.5
+291.8 152 291.8 DL 163 291.8 157.5 291.8 DL 168.5 291.8 163 291.8 DL 174
+291.8 168.5 291.8 DL 179.5 291.8 174 291.8 DL 185 291.8 179.5 291.8 DL
+190.5 291.8 185 291.8 DL 196 291.8 190.5 291.8 DL 201.5 291.8 196 291.8
+DL 207 291.8 201.5 291.8 DL 212.5 291.8 207 291.8 DL 218 291.8 212.5
+291.8 DL 223.5 291.8 218 291.8 DL 229 291.8 223.5 291.8 DL 234.5 291.8
+229 291.8 DL 240 291.8 234.5 291.8 DL 245.5 291.8 240 291.8 DL 251 291.8
+245.5 291.8 DL 256.5 291.8 251 291.8 DL 262 291.8 256.5 291.8 DL 267.5
+291.8 262 291.8 DL 273 291.8 267.5 291.8 DL 278.5 291.8 273 291.8 DL 284
+291.8 278.5 291.8 DL 289.5 291.8 284 291.8 DL 295 291.8 289.5 291.8 DL
+300.5 291.8 295 291.8 DL 306 291.8 300.5 291.8 DL 311.5 291.8 306 291.8
+DL 317 291.8 311.5 291.8 DL 322.5 291.8 317 291.8 DL 328 291.8 322.5
+291.8 DL 333.5 291.8 328 291.8 DL 339 291.8 333.5 291.8 DL 344.5 291.8
+339 291.8 DL 350 291.8 344.5 291.8 DL 355.5 291.8 350 291.8 DL 361 291.8
+355.5 291.8 DL 366.5 291.8 361 291.8 DL 372 291.8 366.5 291.8 DL 377.5
+291.8 372 291.8 DL 383 291.8 377.5 291.8 DL 388.5 291.8 383 291.8 DL 394
+291.8 388.5 291.8 DL 399.5 291.8 394 291.8 DL 405 291.8 399.5 291.8 DL
+410.5 291.8 405 291.8 DL 416 291.8 410.5 291.8 DL 421.5 291.8 416 291.8
+DL 427 291.8 421.5 291.8 DL 432.5 291.8 427 291.8 DL 438 291.8 432.5
+291.8 DL 443.5 291.8 438 291.8 DL 449 291.8 443.5 291.8 DL 454.5 291.8
+449 291.8 DL 460 291.8 454.5 291.8 DL 465.5 291.8 460 291.8 DL 471 291.8
+465.5 291.8 DL 476.5 291.8 471 291.8 DL 482 291.8 476.5 291.8 DL 487.5
+291.8 482 291.8 DL 493 291.8 487.5 291.8 DL 498.5 291.8 493 291.8 DL 504
+291.8 498.5 291.8 DL 3(8.1.1. Functions)72 322.1 R(Needed f)3 E
+(or a User)-.3 E(-De\214ned T)-.444 E(ype)-.888 E F1 3.097(Au)108 339.2
+S(ser)-3.097 E .347(-de\214ned type must al)-.22 F -.11(wa)-.11 G .347
+(ys ha).11 F -.165(ve)-.22 G F3(input)3.262 E F1(and)3.096 E F3(output)
+3.096 E F1 3.096(functions. These)3.096 F .346(functions deter)3.096 F
+(-)-.22 E 1.115(mine ho)108 352.4 R 3.865(wt)-.275 G 1.116(he type appe\
+ars in strings \(for input by the user and output to the user\) and)
+-3.865 F(ho)108 365.6 Q 2.93(wt)-.275 G .18(he type is or)-2.93 F -.055
+(ga)-.198 G .18(nized in memory).055 F 5.679(.T)-.715 G .179
+(he input function tak)-5.679 F .179(es a null-delimited character)-.11
+F 1.27(string as its input and returns the internal \(in memory\) repre\
+sentation of the type.)108 378.8 R(The)6.77 E .931(output function tak)
+108 392 R .93(es the internal representation of the type and returns a \
+null-delimited)-.11 F(character string.)108 405.2 Q .939(Suppose we w)
+108 422.3 R .939(ant to de\214ne a)-.11 F F4(complex)3.69 E F1 .94
+(type which represents comple)3.69 F 3.69(xn)-.165 G .94(umbers. Natu-)
+-3.69 F(rally)108 435.5 Q 2.75(,w)-.715 G 2.75(ec)-2.75 G
+(hoose to represent a comple)-2.75 E 2.75(xi)-.165 G 2.75(nm)-2.75 G
+(emory as the follo)-2.75 E(wing C structure:)-.275 E/F6 10/Courier@0 SF
+(typedef struct Complex {)148 460.7 Q 30(double x;)172 472.9 R 30
+(double y;)172 485.1 R 6(}C)148 497.3 S(omplex;)-6 E F1
+(and a string of the form)108 523.5 Q F4(\(x,y\))2.75 E F1(as the e)2.75
+E(xternal string representation.)-.165 E 1.12(These functions are usual\
+ly not hard to write, especially the output function.)108 540.6 R(Ho)
+6.62 E(we)-.275 E -.165(ve)-.275 G -.44(r,).165 G
+(there are a number of points to remember)108 553.8 Q(.)-.605 E 13.75
+(\(1\) When)113.5 570.9 R 2.47(de\214ning your e)5.22 F 2.47
+(xternal \(string\) representation, remember that you must)-.165 F
+-2.365 -.275(ev e)142.826 584.1 T .113(ntually write a complete and rob)
+.275 F .113(ust parser for that representation as your input)-.22 F
+(function!)142.826 597.3 Q F6(Complex *)182.826 622.5 Q
+(complex_in\(char *str\))182.826 634.7 Q({)182.826 646.9 Q(double x, y;)
+206.826 659.1 Q(Complex *result;)206.826 671.3 Q
+(if \(sscanf\(str, " \( %lf , %lf \)", &x, &y\) != 2\) {)206.826 695.7 Q
+(elog\(WARN, "complex_in: error in parsing)230.826 707.9 Q(return NULL;)
+230.826 720.1 Q/F7 11/Times-Bold@0 SF(33)282.5 756 Q EP
+%%Page: 34 34
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(})206.826 96.2 Q
+(result = \(Complex *\)palloc\(sizeof\(Complex\)\);)206.826 108.4 Q
+(result->x = x;)206.826 120.6 Q(result->y = y;)206.826 132.8 Q
+(return \(result\);)206.826 145 Q(})182.826 157.2 Q/F1 11/Times-Roman@0
+SF(The output function can simply be:)142.826 183.4 Q F0(char *)182.826
+208.6 Q(complex_out\(Complex *complex\))182.826 220.8 Q({)182.826 233 Q
+(char *result;)206.826 245.2 Q(if \(complex == NULL\))206.826 269.6 Q
+(return\(NULL\);)230.826 281.8 Q(result = \(char *\) palloc\(60\);)
+206.826 306.2 Q(sprintf\(result, "\(%g,%g\)", complex->x, complex->y\);)
+206.826 318.4 Q(return\(result\);)206.826 330.6 Q(})182.826 342.8 Q F1
+13.75(\(2\) Y)113.5 372.9 R .752(ou should try to mak)-1.21 F 3.502(et)
+-.11 G .752(he input and output functions in)-3.502 F -.165(ve)-.44 G
+.752(rses of each other).165 F 6.252(.I)-.605 G(f)-6.252 E .181
+(you do not, you will ha)142.826 386.1 R .511 -.165(ve s)-.22 H -2.365
+-.275(ev e).165 H .18(re problems when you need to dump your data into)
+.275 F 3.169<618c>142.826 399.3 S .419
+(le and then read it back in \(say)-3.169 F 3.17(,i)-.715 G .42
+(nto someone else')-3.17 F 3.17(sd)-.605 G .42(atabase on another com-)
+-3.17 F 3.672(puter\). This)142.826 412.5 R .922
+(is a particularly common problem when \215oating-point numbers are)
+3.672 F(in)142.826 425.7 Q -.22(vo)-.44 G(lv).22 E(ed.)-.165 E 3.371
+-.88(To d)108 442.8 T 1.612(e\214ne the).88 F/F2 11/Courier@0 SF
+(complex)4.362 E F1 1.612(type, we need to create the tw)4.362 F 4.362
+(ou)-.11 G(ser)-4.362 E 1.612(-de\214ned functions)-.22 F F2(com-)4.362
+E(plex_in)108 456 Q F1(and)2.75 E F2(complex_out)2.75 E F1
+(before creating the type:)2.75 E F0
+(CREATE FUNCTION complex_in\(opaque\))148 481.2 Q(RETURNS complex)166
+493.4 Q(AS '/usr/local/postgres95/tutorial/obj/complex.so')166 505.6 Q
+(LANGUAGE 'c';)166 517.8 Q(CREATE FUNCTION complex_out\(opaque\))148
+542.2 Q(RETURNS opaque)166 554.4 Q
+(AS '/usr/local/postgres95/tutorial/obj/complex.so')166 566.6 Q
+(LANGUAGE 'c';)166 578.8 Q(CREATE TYPE complex \()148 603.2 Q
+(internallength = 16,)166 615.4 Q(input = complex_in,)166 627.6 Q
+(output = complex_out)166 639.8 Q(\);)148 652 Q F1 .371
+(As discussed earlier)108 682.1 R(,)-.44 E/F3 10/Times-Roman@0 SF
+(POSTGRES)3.121 E F1 .371(fully supports arrays of base types.)3.121 F
+(Additionally)5.87 E(,)-.715 E F3(POST)3.12 E(-)-.92 E(GRES)108 695.3 Q
+F1 .32(supports arrays of user)3.069 F .32(-de\214ned types as well.)
+-.22 F .32(When you de\214ne a type,)5.82 F F3(POSTGRES)3.07 E F1 1.231
+(automatically pro)108 708.5 R 1.23
+(vides support for arrays of that type.)-.165 F -.165(Fo)6.73 G 3.98(rh)
+.165 G 1.23(istorical reasons, the array)-3.98 F 3.301
+(type has the same name as the user)108 721.7 R 3.301
+(-de\214ned type with the underscore character)-.22 F F2(_)6.051 E/F4 11
+/Times-Bold@0 SF(34)282.5 756 Q EP
+%%Page: 35 35
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF(prepended.)108 97.2 Q 1.849
+(Composite types do not need an)108 114.3 R 4.599(yf)-.165 G 1.849
+(unction de\214ned on them, since the system already)-4.599 F
+(understands what the)108 127.5 Q 2.75(yl)-.165 G(ook lik)-2.75 E 2.75
+(ei)-.11 G(nside.)-2.75 E/F1 12/Times-Bold@0 SF 3(8.1.2. Lar)72 153.7 R
+(ge Objects)-.12 E F0 .758(The types discussed to this point are all \
+\231small\232 objects \212 that is, the)108 170.8 R 3.508(ya)-.165 G
+.758(re smaller than)-3.508 F(8KB)108 186.2 Q/F2 8/Times-Roman@0 SF(7)
+-4.4 I F0 .304(in size.)3.054 4.4 N .304(If you require a lar)5.804 F
+.305(ger type for something lik)-.198 F 3.055(ead)-.11 G .305
+(ocument retrie)-3.055 F -.275(va)-.275 G 3.055(ls).275 G(ystem)-3.055 E
+(or for storing bitmaps, you will need to use the)108 199.4 Q/F3 10
+/Times-Roman@0 SF(POSTGRES)2.75 E/F4 11/Times-Italic@0 SF(lar)2.75 E .22
+-.11(ge o)-.407 H(bject).11 E F0(interf)2.75 E(ace.)-.11 E .32 LW 76
+667.4 72 667.4 DL 80 667.4 76 667.4 DL 84 667.4 80 667.4 DL 88 667.4 84
+667.4 DL 92 667.4 88 667.4 DL 96 667.4 92 667.4 DL 100 667.4 96 667.4 DL
+104 667.4 100 667.4 DL 108 667.4 104 667.4 DL 112 667.4 108 667.4 DL 116
+667.4 112 667.4 DL 120 667.4 116 667.4 DL 124 667.4 120 667.4 DL 128
+667.4 124 667.4 DL 132 667.4 128 667.4 DL 136 667.4 132 667.4 DL 140
+667.4 136 667.4 DL 144 667.4 140 667.4 DL 148 667.4 144 667.4 DL 152
+667.4 148 667.4 DL 156 667.4 152 667.4 DL 160 667.4 156 667.4 DL 164
+667.4 160 667.4 DL 168 667.4 164 667.4 DL 172 667.4 168 667.4 DL 176
+667.4 172 667.4 DL 180 667.4 176 667.4 DL 184 667.4 180 667.4 DL 188
+667.4 184 667.4 DL 192 667.4 188 667.4 DL 196 667.4 192 667.4 DL 200
+667.4 196 667.4 DL 204 667.4 200 667.4 DL 208 667.4 204 667.4 DL 212
+667.4 208 667.4 DL 216 667.4 212 667.4 DL/F5 5/Times-Roman@0 SF(7)93.6
+677.8 Q F2 2.338(8*1)2.338 3.2 O .338(024 == 8192 bytes.)-2.338 F .338
+(In f)4.338 F .338
+(act, the type must be considerably smaller than 8192 bytes, since the)
+-.08 F/F6 7/Times-Roman@0 SF(POSTGRES)2.338 E F2 .338(tuple and page)
+2.338 F -.12(ove)72 690.6 S
+(rhead must also \214t into this 8KB limitation.).12 E(The actual v)4 E
+(alue that \214ts depends on the machine architecture.)-.2 E/F7 11
+/Times-Bold@0 SF(35)282.5 756 Q EP
+%%Page: 36 36
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(9. EXTENDING)72 165.4 R(SQL: OPERA)
+4.75 E -.342(TO)-1.805 G(RS).342 E 77.5 178.6 72 178.6 DL 80.5 178.6 75
+178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5
+178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6
+108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6
+124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5
+178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163
+178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL
+179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6
+DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5
+178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6
+218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6
+234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5
+178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273
+178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL
+289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6
+DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5
+178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6
+328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6
+344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5
+178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383
+178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL
+399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6
+DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5
+178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6
+438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6
+454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5
+178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493
+178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL
+/F1 10/Times-Roman@0 SF(POSTGRES)108 208.9 Q/F2 11/Times-Roman@0 SF .485
+(supports left unary)3.235 F 3.235(,r)-.715 G .485
+(ight unary and binary operators.)-3.235 F .484(Operators can be)5.984 F
+/F3 11/Times-Italic@0 SF -.11(ov)3.234 G(er).11 E(-)-.22 E(loaded)108
+222.1 Q F2 3.116(,o)C 3.117(rr)-3.116 G .367(e-used with dif)-3.117 F
+.367(ferent numbers and types of ar)-.275 F 3.117(guments. If)-.198 F
+.367(there is an ambigu-)3.117 F .126(ous situation and the system cann\
+ot determine the correct operator to use, it will return an)108 235.3 R
+1.232(error and you may ha)108 248.5 R 1.562 -.165(ve t)-.22 H 3.982(ot)
+.165 G 1.232
+(ypecast the left and/or right operands to help it understand)-3.982 F
+(which operator you meant to use.)108 261.7 Q 2.289 -.88(To c)108 278.8
+T .529(reate an operator for adding tw).88 F 3.279(oc)-.11 G(omple)
+-3.279 E 3.279(xn)-.165 G .529(umbers can be done as follo)-3.279 F
+3.278(ws. First)-.275 F(we)3.278 E .436
+(need to create a function to add the ne)108 292 R 3.186(wt)-.275 G .436
+(ypes. Then, we can create the operator with the)-3.186 F(function.)108
+305.2 Q/F4 10/Courier@0 SF
+(CREATE FUNCTION complex_add\(complex, complex\))148 330.4 Q
+(RETURNS complex)166 342.6 Q(AS '$PWD/obj/complex.so')166 354.8 Q
+(LANGUAGE 'c';)166 367 Q(CREATE OPERATOR + \()148 403.6 Q
+(leftarg = complex,)166 415.8 Q(rightarg = complex,)166 428 Q
+(procedure = complex_add,)166 440.2 Q(commutator = +)166 452.4 Q(\);)148
+464.6 Q F2 -.88(We)108 506.9 S -1.815 -.55('v e).88 H(sho)4.31 E 1.01
+(wn ho)-.275 F 3.76(wt)-.275 G 3.76(oc)-3.76 G 1.01
+(reate a binary operator here. T)-3.76 F 3.759(oc)-.88 G 1.009
+(reate unary operators, just omit)-3.759 F(one of)108 520.1 Q/F5 11
+/Courier@0 SF(leftarg)2.75 E F2(\(for left unary\) or)2.75 E F5
+(rightarg)2.75 E F2(\(for right unary\).)2.75 E 1.823(If we gi)108 537.2
+R 2.153 -.165(ve t)-.275 H 1.824(he system enough type information, it \
+can automatically \214gure out which).165 F(operators to use.)108 550.4
+Q F4(SELECT \(a + b\) AS c FROM test_complex;)148 575.6 Q .4 LW 248
+606.1 148 606.1 DL(c)153 615.8 Q 248 620.3 148 620.3 DL(\(5.2,6.05\))153
+630 Q 248 634.5 148 634.5 DL(\(133.42,144.95\))153 644.2 Q 248 648.7 148
+648.7 DL 248 606.1 248 648.7 DL 148 606.1 148 648.7 DL/F6 11
+/Times-Bold@0 SF(36)282.5 756 Q EP
+%%Page: 37 37
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(10. EXTENDING)72 165.4 R(SQL: A)4.75
+E(GGREGA)-1.045 E(TES)-1.805 E 77.5 178.6 72 178.6 DL 80.5 178.6 75
+178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5
+178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6
+108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6
+124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5
+178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163
+178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL
+179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6
+DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5
+178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6
+218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6
+234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5
+178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273
+178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL
+289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6
+DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5
+178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6
+328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6
+344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5
+178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383
+178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL
+399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6
+DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5
+178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6
+438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6
+454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5
+178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493
+178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL
+/F1 11/Times-Roman@0 SF(Aggre)108 208.9 Q -.055(ga)-.165 G .241(tes in)
+.055 F/F2 10/Times-Roman@0 SF(POSTGRES)2.991 E F1 .241(are e)2.991 F
+.241(xpressed in terms of)-.165 F/F3 11/Times-Italic@0 SF .241(state tr)
+2.991 F .241(ansition functions)-.165 F F1 5.741(.T)C .24(hat is, an)
+-5.741 F(aggre)108 222.1 Q -.055(ga)-.165 G .924
+(te can be de\214ned in terms of).055 F F3(state)3.675 E F1 .925
+(that is modi\214ed whene)3.675 F -.165(ve)-.275 G 3.675(ra).165 G 3.675
+(ni)-3.675 G .925(nstance is pro-)-3.675 F 3.74(cessed. Some)108 235.3 R
+.989(state functions look at a particular v)3.74 F .989
+(alue in the instance when computing)-.275 F 1.59(the ne)108 248.5 R
+4.34(ws)-.275 G 1.59(tate \()-4.34 F F3(sfunc1)A F1 1.59(in the)4.34 F
+/F4 11/Times-Bold@0 SF(cr)4.34 E 1.59(eate aggr)-.198 F(egate)-.198 E F1
+1.59(syntax\) while others only k)4.34 F 1.591(eep track of)-.11 F
+(their o)108 261.7 Q(wn internal state \()-.275 E F3(sfunc2)A F1(\).)A
+.085(If we de\214ne an aggre)108 278.8 R -.055(ga)-.165 G .084
+(te that uses only).055 F/F5 11/Courier@0 SF(sfunc1)2.834 E F1 2.834(,w)
+C 2.834(ed)-2.834 G .084(e\214ne an aggre)-2.834 F -.055(ga)-.165 G .084
+(te that computes a).055 F .488(running function of the attrib)108 292 R
+.488(ute v)-.22 F .488(alues from each instance.)-.275 F .488
+(\231Sum\232 is an e)5.988 F .488(xample of this)-.165 F .074
+(kind of aggre)108 305.2 R -.055(ga)-.165 G 2.824(te. \231Sum\232).055 F
+.073(starts at zero and al)2.824 F -.11(wa)-.11 G .073
+(ys adds the current instance').11 F 2.823(sv)-.605 G .073(alue to its)
+-3.098 F .19(running total.)108 318.4 R 1.95 -.88(We w)5.69 H .19
+(ill use the).88 F F5(int4pl)2.94 E F1 .19(that is b)2.94 F .191
+(uilt into)-.22 F F2(POSTGRES)2.941 E F1 .191(to perform this addi-)
+2.941 F(tion.)108 331.6 Q/F6 10/Courier@0 SF
+(CREATE AGGREGATE complex_sum \()148 356.8 Q(sfunc1 = complex_add,)178
+369 Q(basetype = complex,)178 381.2 Q(stype1 = complex,)178 393.4 Q
+(initcond1 = '\(0,0\)')178 405.6 Q(\);)160 417.8 Q
+(SELECT complex_sum\(a\) FROM test_complex;)148 454.4 Q .4 LW 224 484.9
+148 484.9 DL(complex_sum)153 494.6 Q 224 499.1 148 499.1 DL(\(34,53.9\))
+153 508.8 Q 224 513.3 148 513.3 DL 224 484.9 224 513.3 DL 148 484.9 148
+513.3 DL F1 .184(If we de\214ne only)108 535 R F5(sfunc2)2.934 E F1
+2.934(,w)C 2.934(ea)-2.934 G .184(re specifying an aggre)-2.934 F -.055
+(ga)-.165 G .184(te that computes a running func-).055 F .998
+(tion that is independent of the attrib)108 548.2 R .999(ute v)-.22 F
+.999(alues from each instance.)-.275 F .999(\231Count\232 is the most)
+6.499 F 1.313(common e)108 561.4 R 1.313(xample of this kind of aggre)
+-.165 F -.055(ga)-.165 G 4.063(te. \231Count\232).055 F 1.312
+(starts at zero and adds one to its)4.063 F 1.665
+(running total for each instance, ignoring the instance v)108 574.6 R
+4.415(alue. Here,)-.275 F 1.666(we use the b)4.415 F(uilt-in)-.22 E F5
+(int4inc)108 587.8 Q F1 .631(routine to do the w)3.381 F .631
+(ork for us.)-.11 F .63(This routine increments \(adds one to\) its ar)
+6.131 F(gu-)-.198 E(ment.)108 601 Q F6
+(CREATE AGGREGATE my_count \(sfunc2 = int4inc, -- add one)148 626.2 Q
+(basetype = int4, stype2 = int4,)322 638.4 Q(initcond2 = '0'\))322 650.6
+Q(SELECT my_count\(*\) as emp_count from EMP;)148 675 Q F4(37)282.5 756
+Q EP
+%%Page: 38 38
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.4 LW 212 88.5 148 88.5 DL/F0 10/Courier@0 SF(emp_count)153 98.2 Q 212
+102.7 148 102.7 DL(5)153 112.4 Q 212 116.9 148 116.9 DL 212 88.5 212
+116.9 DL 148 88.5 148 116.9 DL/F1 11/Times-Roman@0 SF -1.804 -.88
+(\231A v)108 138.6 T .095(erage\232 is an e).715 F .095
+(xample of an aggre)-.165 F -.055(ga)-.165 G .096
+(te that requires both a function to compute the run-).055 F .987
+(ning sum and a function to compute the running count.)108 151.8 R .986
+(When all of the instances ha)6.486 F -.165(ve)-.22 G .405
+(been processed, the \214nal answer for the aggre)108 165 R -.055(ga)
+-.165 G .405(te is the running sum di).055 F .405(vided by the run-)
+-.275 F .923(ning count.)108 178.2 R 2.683 -.88(We u)6.423 H .923
+(se the).88 F/F2 11/Courier@0 SF(int4pl)3.673 E F1(and)3.673 E F2
+(int4inc)3.673 E F1 .922(routines we used before as well as the)3.673 F
+/F3 10/Times-Roman@0 SF(POSTGRES)108 191.4 Q F1(inte)2.855 E .105
+(ger di)-.165 F .105(vision routine,)-.275 F F2(int4div)2.855 E F1 2.855
+(,t)C 2.855(oc)-2.855 G .105(ompute the di)-2.855 F .106
+(vision of the sum by the)-.275 F(count.)108 204.6 Q F0
+(CREATE AGGREGATE my_average \(sfunc1 = int4pl, --)148 229.8 Q(sum)12 E
+(basetype = int4,)334 242 Q(stype1 = int4,)334 254.2 Q
+(sfunc2 = int4inc, -- count)334 266.4 Q(stype2 = int4,)334 278.6 Q
+(finalfunc = int4div, -- division)334 290.8 Q(initcond1 = '0',)334 303 Q
+(initcond2 = '0'\))334 315.2 Q
+(SELECT my_average\(salary\) as emp_average FROM EMP;)148 339.6 Q 224
+370.1 148 370.1 DL(emp_average)153 379.8 Q 224 384.3 148 384.3 DL(1640)
+153 394 Q 224 398.5 148 398.5 DL 224 370.1 224 398.5 DL 148 370.1 148
+398.5 DL/F4 11/Times-Bold@0 SF(38)282.5 756 Q EP
+%%Page: 39 39
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(11. INTERF)72 165.4 R -1.045(AC)-1.71
+G(ING EXTENSIONS T)1.045 E 4.75(OI)-.342 G(NDICES)-4.75 E 77.5 178.6 72
+178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86
+178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5
+178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6
+119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6
+135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5
+178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174
+178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL
+190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6
+DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5
+178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6
+229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6
+245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5
+178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284
+178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL
+300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6
+DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5
+178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6
+339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6
+355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5
+178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394
+178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL
+410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6
+DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5
+178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6
+449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6
+465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5
+178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504
+178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF .125
+(The procedures described thus f)108 208.9 R .125
+(ar let you de\214ne a ne)-.11 F 2.875(wt)-.275 G .124(ype, ne)-2.875 F
+2.874(wf)-.275 G .124(unctions and ne)-2.874 F 2.874(wo)-.275 G(per)
+-2.874 E(-)-.22 E 3.069(ators. Ho)108 222.1 R(we)-.275 E -.165(ve)-.275
+G 1.199 -.44(r, w).165 H 3.069(ec).44 G .32
+(annot yet de\214ne a secondary inde)-3.069 F 3.07(x\()-.165 G .32
+(such as a B-tree, R-tree or hash)-3.07 F(access method\) o)108 235.3 Q
+-.165(ve)-.165 G 2.75(ran).165 G .55 -.275(ew t)-2.75 H
+(ype or its operators.).275 E .181(Look back at Figure 3.)108 252.4 R
+.181(The right half sho)5.681 F .18
+(ws the catalogs that we must modify in order to)-.275 F(tell)108 265.6
+Q/F2 10/Times-Roman@0 SF(POSTGRES)4.911 E F1(ho)4.911 E 4.911(wt)-.275 G
+4.911(ou)-4.911 G 2.161(se a user)-4.911 F 2.161
+(-de\214ned type and/or user)-.22 F 2.162(-de\214ned operators with an)
+-.22 F(inde)108 278.8 Q 3.874(x\()-.165 G(i.e.,)-3.874 E/F3 11/Courier@0
+SF(pg_am)3.874 E F1(,)A F3(pg_amop)3.874 E F1(,)A F3(pg_amproc)3.873 E
+F1(and)3.873 E F3(pg_opclass)3.873 E F1 3.873(\). Unfortunately)B 3.873
+(,t)-.715 G(here)-3.873 E 1.611(is no simple command to do this.)108 292
+R 3.372 -.88(We w)7.111 H 1.612(ill demonstrate ho).88 F 4.362(wt)-.275
+G 4.362(om)-4.362 G 1.612(odify these catalogs)-4.362 F .78
+(through a running e)108 305.2 R .78(xample: a ne)-.165 F 3.53(wo)-.275
+G .779(perator class for the B-tree access method that sorts)-3.53 F
+(inte)108 318.4 Q(gers in ascending absolute v)-.165 E(alue order)-.275
+E(.)-.605 E(The)108 335.5 Q F3(pg_am)3.956 E F1 1.206
+(class contains one instance for e)3.956 F -.165(ve)-.275 G 1.206
+(ry user).165 F 1.206(-de\214ned access method.)-.22 F(Support)6.706 E
+1.667(for the heap access method is b)108 348.7 R 1.667(uilt into)-.22 F
+F2(POSTGRES)4.417 E F1 4.417(,b)C 1.667(ut e)-4.637 F -.165(ve)-.275 G
+1.667(ry other access method is).165 F(described here.)108 361.9 Q
+(The schema is)5.5 E 496.228 379.65 115.771 379.65 DL F3(amname)121.271
+390.1 Q F1(name of the access method)56.1 E 496.228 394.85 115.771
+394.85 DL F3(amowner)121.271 405.3 Q F1(object id of the o)49.5 E(wner')
+-.275 E 2.75(si)-.605 G(nstance in pg_user)-2.75 E 496.228 410.05
+115.771 410.05 DL F3(amkind)121.271 420.5 Q F1(not used at present, b)
+56.1 E(ut set to 'o' as a place holder)-.22 E 496.228 425.25 115.771
+425.25 DL F3(amstrategies)121.271 435.7 Q F1(number of strate)16.5 E
+(gies for this access method \(see belo)-.165 E(w\))-.275 E 496.228
+440.45 115.771 440.45 DL F3(amsupport)121.271 450.9 Q F1
+(number of support routines for this access method \(see belo)36.3 E
+(w\))-.275 E 496.228 455.65 115.771 455.65 DL F3(amgettuple)121.271
+466.1 Q(aminsert)121.271 479.3 Q(...)121.271 492.5 Q F1 4.257
+(procedure identi\214ers for interf)216.971 466.1 R 4.257
+(ace routines to the access)-.11 F 5.101(method. F)216.971 479.3 R 2.351
+(or e)-.165 F(xample,)-.165 E F3(regproc)5.101 E F1 2.351
+(ids for opening, closing,)5.101 F
+(and getting instances from the access method appear here.)216.971 492.5
+Q 496.228 497.25 115.771 497.25 DL 208.721 379.65 208.721 497.25 DL
+496.228 379.65 496.228 497.25 DL 115.771 379.65 115.771 497.25 DL .68
+(The object ID of the instance in)108 518.7 R F3(pg_am)3.431 E F1 .681
+(is used as a foreign k)3.431 F 1.011 -.165(ey i)-.11 H 3.431(nl).165 G
+.681(ots of other classes.)-3.431 F -1.21(Yo)108 531.9 S 2.912(ud)1.21 G
+(on')-2.912 E 2.912(tn)-.198 G .162(eed to add a ne)-2.912 F 2.911(wi)
+-.275 G .161(nstance to this class; all you')-2.911 F .161
+(re interested in is the object ID)-.55 F
+(of the access method instance you w)108 545.1 Q(ant to e)-.11 E(xtend:)
+-.165 E/F4 10/Courier@0 SF(SELECT oid FROM pg_am WHERE amname = 'btree')
+148 570.3 Q .4 LW 176 587.8 148 587.8 DL(oid)153 597.5 Q 176 602 148 602
+DL(403)153 611.7 Q 176 616.2 148 616.2 DL 176 587.8 176 616.2 DL 148
+587.8 148 616.2 DL F1(The)108 650.9 Q F3(amstrategies)3.445 E F1(attrib)
+3.445 E .695(ute e)-.22 F .695
+(xists to standardize comparisons across data types.)-.165 F -.165(Fo)
+6.196 G(r).165 E -.165(ex)108 664.1 S 1.527
+(ample, B-trees impose a strict ordering on k).165 F -.165(ey)-.11 G
+1.527(s, lesser to greater).165 F 7.026(.S)-.605 G(ince)-7.026 E F2
+(POSTGRES)4.276 E F1(allo)108 677.3 Q 1.144
+(ws the user to de\214ne operators,)-.275 F F2(POSTGRES)3.894 E F1 1.145
+(cannot look at the)3.894 F/F5 11/Times-Bold@0 SF(name)3.895 E F1 1.145
+(of an operator)3.895 F(\(e)108 690.5 Q(g,)-.165 E F3(>)3.713 E F1(or)
+3.713 E F3(<)3.713 E F1 3.712(\)a)C .962
+(nd tell what kind of comparison it is.)-3.712 F .962(In f)6.462 F .962
+(act, some access methods don')-.11 F(t)-.198 E 3.648(impose an)108
+703.7 R 6.398(yo)-.165 G 3.648(rdering at all.)-6.398 F -.165(Fo)9.149 G
+6.399(re).165 G 3.649(xample, R-trees e)-6.564 F 3.649
+(xpress a rectangle-containment)-.165 F F5(39)282.5 756 Q EP
+%%Page: 40 40
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF 1.021
+(relationship, whereas a hashed data structure e)108 97.2 R 1.021
+(xpresses only bitwise similarity based on)-.165 F .039(the v)108 110.4
+R .039(alue of a hash function.)-.275 F/F1 10/Times-Roman@0 SF(POSTGRES)
+5.539 E F0 .039(needs some consistent w)2.789 F .039
+(ay of taking a quali\214ca-)-.11 F .049(tion in your query)108 123.6 R
+2.799(,l)-.715 G .049
+(ooking at the operator and then deciding if a usable inde)-2.799 F
+2.798(xe)-.165 G 2.798(xists. This)-2.963 F .162(implies that)108 136.8
+R F1(POSTGRES)2.912 E F0 .162(needs to kno)2.912 F 1.592 -.715(w, f)
+-.275 H .162(or e).715 F .162(xample, that the)-.165 F/F2 11/Courier@0
+SF(<=)2.913 E F0(and)2.913 E F2(>)2.913 E F0 .163(operators partition)
+2.913 F 3.102(aB)108 150 S(-tree.)-3.102 E F1(POSTGRES)5.852 E F0 .352
+(uses strate)3.102 F .352(gies to e)-.165 F .351
+(xpress these relationships between operators and)-.165 F(the w)108
+163.2 Q(ay the)-.11 E 2.75(yc)-.165 G(an be used to scan indices.)-2.75
+E .687(De\214ning a ne)108 180.3 R 3.437(ws)-.275 G .687(et of strate)
+-3.437 F .687(gies is be)-.165 F .687
+(yond the scope of this discussion, b)-.165 F .688(ut we')-.22 F .688
+(ll e)-.11 F(xplain)-.165 E(ho)108 193.5 Q 3.122(wB)-.275 G .372
+(-tree strate)-3.122 F .372(gies w)-.165 F .372(ork because you')-.11 F
+.372(ll need to kno)-.11 F 3.122(wt)-.275 G .372(hat to add a ne)-3.122
+F 3.121(wo)-.275 G .371(perator class.)-3.121 F .099(In the)108 206.7 R
+F2(pg_am)2.849 E F0 .099(class, the)2.849 F F2(amstrategies)2.849 E F0
+(attrib)2.849 E .099(ute is the number of strate)-.22 F .099
+(gies de\214ned for)-.165 F(this access method.)108 219.9 Q -.165(Fo)5.5
+G 2.75(rB).165 G(-trees, this number is 5.)-2.75 E(These strate)5.5 E
+(gies correspond to)-.165 E .44 LW 367.858 237.65 244.141 237.65 DL
+(less than)249.641 248.1 Q(1)69.025 E 367.858 252.85 244.141 252.85 DL
+(less than or equal)249.641 263.3 Q(2)30.536 E 367.858 268.05 244.141
+268.05 DL 80.641(equal 3)249.641 278.5 R 367.858 283.25 244.141 283.25
+DL(greater than or equal)249.641 293.7 Q(4)16.5 E 367.858 298.45 244.141
+298.45 DL(greater than)249.641 308.9 Q(5)54.989 E 367.858 313.65 244.141
+313.65 DL 367.858 237.65 367.858 313.65 DL 244.141 237.65 244.141 313.65
+DL 348.608 237.65 348.608 313.65 DL .255(The idea is that you')108 335.1
+R .254(ll need to add procedures corresponding to the comparisons abo)
+-.11 F .584 -.165(ve t)-.165 H(o).165 E(the)108 348.3 Q F2(pg_amop)3.068
+E F0 .318(relation \(see belo)3.068 F 3.068(w\). The)-.275 F .318
+(access method code can use these strate)3.068 F .319(gy num-)-.165 F
+.11(bers, re)108 361.5 R -.055(ga)-.165 G .11
+(rdless of data type, to \214gure out ho).055 F 2.86(wt)-.275 G 2.86(op)
+-2.86 G .11(artition the B-tree, compute selecti)-2.86 F(vity)-.275 E(,)
+-.715 E .898(and so on.)108 374.7 R(Don')6.399 E 3.649(tw)-.198 G .899
+(orry about the details of adding procedures yet; just understand that)
+-3.759 F .48(there must be a set of these procedures for)108 387.9 R F2
+(int2)3.23 E F0(,)A F2(int4)3.23 E F0(,)A F2(oid)3.23 E F0 3.23(,a)C .48
+(nd e)-3.23 F -.165(ve)-.275 G .479(ry other data type).165 F
+(on which a B-tree can operate.)108 401.1 Q .803(Sometimes, strate)108
+418.2 R .803(gies aren')-.165 F 3.554(te)-.198 G .804
+(nough information for the system to \214gure out ho)-3.554 F 3.554(wt)
+-.275 G 3.554(ou)-3.554 G(se)-3.554 E 1.848(an inde)108 431.4 R 4.598
+(x. Some)-.165 F 1.848
+(access methods require other support routines in order to w)4.598 F
+4.598(ork. F)-.11 F(or)-.165 E -.165(ex)108 444.6 S 1.976
+(ample, the B-tree access method must be able to compare tw).165 F 4.726
+(ok)-.11 G -.165(ey)-4.836 G 4.726(sa).165 G 1.976(nd determine)-4.726 F
+.745(whether one is greater than, equal to, or less than the other)108
+457.8 R 6.245(.S)-.605 G(imilarly)-6.245 E 3.495(,t)-.715 G .745
+(he R-tree access)-3.495 F 1.685(method must be able to compute interse\
+ctions, unions, and sizes of rectangles.)108 471 R(These)7.185 E .884(o\
+perations do not correspond to user quali\214cations in SQL queries; th\
+e)108 484.2 R 3.633(ya)-.165 G .883(re administra-)-3.633 F(ti)108 497.4
+Q .33 -.165(ve r)-.275 H(outines used by the access methods, internally)
+.165 E(.)-.715 E 1.971(In order to manage di)108 514.5 R -.165(ve)-.275
+G 1.972(rse support routines consistently across all).165 F F1(POSTGRES)
+4.722 E F0(access)4.722 E(methods,)108 527.7 Q F2(pg_am)4.65 E F0 1.9
+(includes an attrib)4.65 F 1.9(ute called)-.22 F F2(amsupport)4.65 E F0
+7.4(.T)C 1.899(his attrib)-7.4 F 1.899(ute records the)-.22 F .136
+(number of support routines used by an access method.)108 540.9 R -.165
+(Fo)5.636 G 2.887(rB).165 G .137(-trees, this number is one \212)-2.887
+F .173(the routine to tak)108 554.1 R 2.923(et)-.11 G .393 -.11(wo ke)
+-2.923 H .173(ys and return)-.055 F/F3 11/Symbol SF(-)2.923 E F0 .173
+(1, 0, or).916 F F3(+)2.923 E F0 .172
+(1, depending on whether the \214rst k).916 F .502 -.165(ey i)-.11 H(s)
+.165 E(less than, equal to, or greater than the second.)108 569.5 Q/F4 8
+/Times-Roman@0 SF(8)-4.4 I F0(The)108 586.6 Q F2(amstrategies)4.312 E F0
+1.562(entry in)4.312 F F2(pg_am)4.312 E F0 1.562(is just the)4.312 F/F5
+11/Times-Italic@0 SF(number)4.312 E F0 1.562(of strate)4.312 F 1.562
+(gies de\214ned for the)-.165 F 1.852(access method in question.)108
+599.8 R 1.852(The procedures for less than, less equal, and so on don')
+7.352 F(t)-.198 E 3.555(appear in)108 613 R F2(pg_am)6.305 E F0 9.055
+(.S)C(imilarly)-9.055 E(,)-.715 E F2(amsupport)6.305 E F0 3.555
+(is just the number of support routines)6.305 F
+(required by the access method.)108 626.2 Q
+(The actual routines are listed else)5.5 E(where.)-.275 E .974(The ne)
+108 643.3 R .974(xt class of interest is)-.165 F F2(pg_opclass.)3.724 E
+F0 .973(This class e)6.474 F .973(xists only to associate a name)-.165 F
+1.914(with an)108 656.5 R F2(oid)4.664 E F0 7.414(.I)C(n)-7.414 E F2
+(pg_amop)4.665 E F0 4.665(,e)C -.165(ve)-4.94 G 1.915
+(ry B-tree operator class has a set of procedures, one).165 F 4.98
+(through \214v)108 669.7 R 4.98(e, abo)-.165 F -.165(ve)-.165 G 10.48
+(.S).165 G 4.979(ome e)-10.48 F 4.979(xisting opclasses are)-.165 F F2
+(int2_ops)7.729 E F0(,)A F2(int4_ops)7.729 E F0 7.729(,a)C(nd)-7.729 E
+.32 LW 76 679.3 72 679.3 DL 80 679.3 76 679.3 DL 84 679.3 80 679.3 DL 88
+679.3 84 679.3 DL 92 679.3 88 679.3 DL 96 679.3 92 679.3 DL 100 679.3 96
+679.3 DL 104 679.3 100 679.3 DL 108 679.3 104 679.3 DL 112 679.3 108
+679.3 DL 116 679.3 112 679.3 DL 120 679.3 116 679.3 DL 124 679.3 120
+679.3 DL 128 679.3 124 679.3 DL 132 679.3 128 679.3 DL 136 679.3 132
+679.3 DL 140 679.3 136 679.3 DL 144 679.3 140 679.3 DL 148 679.3 144
+679.3 DL 152 679.3 148 679.3 DL 156 679.3 152 679.3 DL 160 679.3 156
+679.3 DL 164 679.3 160 679.3 DL 168 679.3 164 679.3 DL 172 679.3 168
+679.3 DL 176 679.3 172 679.3 DL 180 679.3 176 679.3 DL 184 679.3 180
+679.3 DL 188 679.3 184 679.3 DL 192 679.3 188 679.3 DL 196 679.3 192
+679.3 DL 200 679.3 196 679.3 DL 204 679.3 200 679.3 DL 208 679.3 204
+679.3 DL 212 679.3 208 679.3 DL 216 679.3 212 679.3 DL/F6 5
+/Times-Roman@0 SF(8)93.6 689.7 Q F4
+(Strictly speaking, this routine can return a ne)2 3.2 M -.04(ga)-.12 G
+(ti).04 E .24 -.12(ve n)-.2 H(umber \(< 0\), 0, or a non-zero positi).12
+E .24 -.12(ve n)-.2 H(umber \(> 0\).).12 E/F7 11/Times-Bold@0 SF(40)
+282.5 756 Q EP
+%%Page: 41 41
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Courier@0 SF(oid_ops)108 97.2 Q/F1 11/Times-Roman@0 SF 7.077(.Y)C
+1.577(ou need to add an instance with your opclass name \(for e)-8.287 F
+(xample,)-.165 E F0(com-)4.328 E(plex_abs_ops)108 110.4 Q F1 3.409(\)t)C
+(o)-3.409 E F0(pg_opclass)3.409 E F1 6.159(.T)C(he)-6.159 E F0(oid)3.409
+E F1 .658(of this instance is a foreign k)3.408 F .988 -.165(ey i)-.11 H
+3.408(no).165 G(ther)-3.408 E(classes.)108 123.6 Q/F2 10/Courier@0 SF
+(INSERT INTO pg_opclass \(opcname\) VALUES \('complex_abs_ops'\);)148
+148.8 Q(SELECT oid, opcname)148 173.2 Q(FROM pg_opclass)160 185.4 Q
+(WHERE opcname = 'complex_abs_ops';)160 197.6 Q .4 LW 275 215.1 148
+215.1 DL 21(oid opcname)153 224.8 R 275 229.3 148 229.3 DL 9
+(17314 int4_abs_ops)153 239 R 275 243.5 148 243.5 DL 275 215.1 275 243.5
+DL 148 215.1 148 243.5 DL 190.5 215.1 190.5 243.5 DL F1 .186
+(Note that the)108 278.2 R F0(oid)2.936 E F1 .186(for your)2.936 F F0
+(pg_opclass)2.936 E F1(instance)2.936 E/F3 11/Times-Bold@0 SF .186
+(will be differ)2.936 F(ent)-.198 E F1 5.686(!Y)C .187
+(ou should substi-)-6.896 F(tute your v)108 291.4 Q
+(alue for 17314 where)-.275 E -.165(ve)-.275 G 2.75(ri).165 G 2.75(ta)
+-2.75 G(ppears in this discussion.)-2.75 E .151(So no)108 308.5 R 2.901
+(ww)-.275 G 2.9(eh)-2.901 G -2.475 -.22(av e)-2.9 H .15
+(an access method and an operator class.)3.12 F 1.91 -.88(We s)5.65 H
+.15(till need a set of operators;).88 F .651
+(the procedure for de\214ning operators w)108 321.7 R .652
+(as discussed earlier in this manual.)-.11 F -.165(Fo)6.152 G 3.402(rt)
+.165 G(he)-3.402 E F0(com-)3.402 E(plex_abs_ops)108 334.9 Q F1
+(operator class on B-trees, the operators we require are:)2.75 E
+(absolute v)148 361.1 Q(alue less-than)-.275 E(absolute v)148 374.3 Q
+(alue less-than-or)-.275 E(-equal)-.22 E(absolute v)148 387.5 Q
+(alue equal)-.275 E(absolute v)148 400.7 Q(alue greater)-.275 E
+(-than-or)-.22 E(-equal)-.22 E(absolute v)148 413.9 Q(alue greater)-.275
+E(-than)-.22 E(Suppose the code that implements the functions de\214ned\
+ is stored in the \214le)108 440.1 Q F2
+(/usr/local/postgres95/src/tutorial/complex.c)148 465.3 Q F1 -.165(Pa)
+108 491.5 S .592(rt of the code look lik).165 F 3.342(et)-.11 G .592
+(his: \(note that we will only sho)-3.342 F 3.342(wt)-.275 G .592
+(he equality operator for the)-3.342 F .631(rest of the e)108 504.7 R
+.632(xamples. The other four operators are v)-.165 F .632(ery similar)
+-.165 F 3.382(.R)-.605 G .632(efer to)-3.382 F F0(complex.c)3.382 E F1
+(or)3.382 E F0(complex.sql)108 517.9 Q F1(for the details.\))2.75 E F2
+(#define Mag\(c\))148 543.1 Q(\(\(c\)->x*\(c\)->x + \(c\)->y*\(c\)->y\))
+24 E(bool)148 567.5 Q(complex_abs_eq\(Complex *a, Complex *b\))148 579.7
+Q({)148 591.9 Q(double amag = Mag\(a\), bmag = Mag\(b\);)172 604.1 Q
+(return \(amag==bmag\);)172 616.3 Q(})148 628.5 Q F1
+(There are a couple of important things that are happening belo)108
+654.7 Q -.715(w.)-.275 G 1.966
+(First, note that operators for less-than, less-than-or)108 671.8 R
+1.966(-equal, equal, greater)-.22 F(-than-or)-.22 E(-equal,)-.22 E .885
+(and greater)108 685 R .886(-than for)-.22 F F0(int4)3.636 E F1 .886
+(are being de\214ned.)3.636 F .886
+(All of these operators are already de\214ned)6.386 F(for)108 698.2 Q F0
+(int4)2.962 E F1 .212(under the names)2.962 F F0(<)2.962 E F1(,)A F0(<=)
+2.962 E F1(,)A F0(=)2.962 E F1(,)A F0(>=)2.962 E F1 2.962(,a)C(nd)-2.962
+E F0(>)2.962 E F1 5.712(.T)C .212(he ne)-5.712 F 2.961(wo)-.275 G .211
+(perators beha)-2.961 F .541 -.165(ve d)-.22 H(if).165 E(ferently)-.275
+E 2.961(,o)-.715 G(f)-2.961 E 2.783(course. In)108 711.4 R .033
+(order to guarantee that)2.783 F/F4 10/Times-Roman@0 SF(POSTGRES)2.783 E
+F1 .034(uses these ne)2.783 F 2.784(wo)-.275 G .034
+(perators rather than the old)-2.784 F F3(41)282.5 756 Q EP
+%%Page: 42 42
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF .765(ones, the)108 97.2 R 3.515(yn)-.165 G .764
+(eed to be named dif)-3.515 F .764(ferently from the old ones.)-.275 F
+.764(This is a k)6.264 F 1.094 -.165(ey p)-.11 H .764(oint: you can).165
+F -.165(ove)108 110.4 S 1.48(rload operators in).165 F/F1 10
+/Times-Roman@0 SF(POSTGRES)4.23 E F0 4.23(,b)C 1.48
+(ut only if the operator isn')-4.45 F 4.231(ta)-.198 G 1.481
+(lready de\214ned for the)-4.231 F(ar)108 123.6 Q 1.474(gument types.)
+-.198 F 1.474(That is, if you ha)6.974 F -.165(ve)-.22 G/F2 11/Courier@0
+SF(<)4.388 E F0 1.473(de\214ned for \()4.223 F F2(int4)A F0(,)A F2(int4)
+4.223 E F0 1.473(\), you can')B 4.223(td)-.198 G 1.473(e\214ne it)-4.223
+F(ag)108 136.8 Q(ain.)-.055 E F1(POSTGRES)5.893 E/F3 11/Times-Bold@0 SF
+.393(does not check)3.143 F F0 .393
+(this when you de\214ne your operator)3.143 F 3.144(,s)-.44 G 3.144(ob)
+-3.144 G 3.144(ec)-3.144 G 3.144(areful. T)-3.144 F(o)-.88 E -.22(avo)
+108 150 S .642
+(id this problem, odd names will be used for the operators.).22 F .641
+(If you get this wrong, the)6.141 F(access methods are lik)108 163.2 Q
+(ely to crash when you try to do scans.)-.11 E 1.223
+(The other important point is that all the operator functions return)108
+180.3 R/F4 11/Times-Italic@0 SF(Boolean)3.974 E F0 -.275(va)3.974 G
+3.974(lues. The).275 F .733(access methods rely on this f)108 193.5 R
+3.483(act. \(On)-.11 F .733
+(the other hand, the support function returns what-)3.483 F -2.365 -.275
+(ev e)108 206.7 T 2.75(rt).275 G(he particular access method e)-2.75 E
+(xpects \212 in this case, a signed inte)-.165 E(ger)-.165 E(.\))-.605 E
+1.443(The \214nal routine in the \214le is the \231support routine\232 \
+mentioned when we discussed the)108 223.8 R F2(amsupport)108 237 Q F0
+(attrib)2.75 E(ute of the)-.22 E F2(pg_am)2.75 E F0 2.75(class. W)2.75 F
+2.75(ew)-.88 G(ill use this later on.)-2.75 E -.165(Fo)5.5 G 2.75(rn)
+.165 G -.275(ow)-2.75 G 2.75(,i)-.44 G(gnore it.)-2.75 E/F5 10/Courier@0
+SF(CREATE FUNCTION complex_abs_eq\(complex, complex\))148 262.2 Q
+(RETURNS bool)178 274.4 Q
+(AS '/usr/local/postgres95/tutorial/obj/complex.so')178 286.6 Q
+(LANGUAGE 'c';)178 298.8 Q F0(No)108 337.2 Q 3.975(wd)-.275 G 1.224
+(e\214ne the operators that use them.)-3.975 F 1.224
+(As noted, the operator names must be unique)6.724 F .684
+(among all operators that tak)108 350.4 R 3.434(et)-.11 G -.11(wo)-3.434
+G F2(int4)3.544 E F0 3.434(operands. In)3.434 F .684
+(order to see if the operator names)3.434 F(listed belo)108 363.6 Q 2.75
+(wa)-.275 G(re tak)-2.75 E(en, we can do a query on)-.11 E F2
+(pg_operator)2.75 E F0(:)A F5(/*)148 388.8 Q 6(*t)154 401 S
+(his query uses the regular expression operator \(~\))-6 E 6(*t)154
+413.2 S 6(of)-6 G(ind three-character operator names that end in)-6 E 6
+(*t)154 425.4 S(he character &)-6 E(*/)154 437.6 Q(SELECT *)148 449.8 Q
+(FROM pg_operator)148 462 Q(WHERE oprname ~ '^..&$'::text;)148 474.2 Q
+F0 1.15(to see if your name is tak)108 500.4 R 1.149
+(en for the types you w)-.11 F 3.899(ant. The)-.11 F 1.149
+(important things here are the)3.899 F .359
+(procedure \(which are the C functions de\214ned abo)108 513.6 R -.165
+(ve)-.165 G 3.109(\)a).165 G .359(nd the restriction and join selecti)
+-3.109 F(v-)-.275 E .13(ity functions.)108 526.8 R -1.21(Yo)5.63 G 2.88
+(us)1.21 G .13(hould just use the ones used belo)-2.88 F .129
+(w\212note that there are dif)-.275 F .129(ferent such)-.275 F .54
+(functions for the less-than, equal, and greater)108 540 R .541
+(-than cases.)-.22 F(These)6.041 E F4(must)3.291 E F0 .541
+(be supplied, or the)3.291 F .048
+(access method will crash when it tries to use the operator)108 553.2 R
+5.548(.Y)-.605 G .048(ou should cop)-6.758 F 2.798(yt)-.11 G .048
+(he names for)-2.798 F F2(restrict)108 566.4 Q F0(and)2.75 E F2(join)
+2.75 E F0 2.75(,b)C
+(ut use the procedure names you de\214ned in the last step.)-2.97 E F5
+(CREATE OPERATOR = \()148 591.6 Q
+(leftarg = complex, rightarg = complex, procedure = complex_abs_eq,)166
+603.8 Q(restrict = eqsel, join = eqjoinsel)166 616 Q(\))148 628.2 Q F0
+1.687(Notice that \214v)108 654.4 R 4.437(eo)-.165 G 1.688
+(perators corresponding to less, less equal, equal, greater)-4.437 F
+4.438(,a)-.44 G 1.688(nd greater)-4.438 F(equal are de\214ned.)108 667.6
+Q -.88(We)108 684.7 S -.55('r).88 G 2.896(ej).55 G .145
+(ust about \214nished. the last thing we need to do is to update the)
+-2.896 F F2(pg_amop)2.895 E F0(relation.)2.895 E 1.76 -.88(To d)108
+697.9 T 2.75(ot).88 G(his, we need the follo)-2.75 E(wing attrib)-.275 E
+(utes:)-.22 E F3(42)282.5 756 Q EP
+%%Page: 43 43
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 428.05 88.75 183.95 88.75 DL/F0 11/Courier@0 SF(amopid)189.45
+99.2 Q/F1 11/Times-Roman@0 SF(the)278.55 99.2 Q F0(oid)3.821 E F1 1.071
+(of the)3.821 F F0(pg_am)3.821 E F1(instance)3.822 E
+(for B-tree \(== 403, see abo)278.55 112.4 Q -.165(ve)-.165 G(\)).165 E
+428.05 117.15 183.95 117.15 DL F0(amopclaid)189.45 127.6 Q F1(the)278.55
+127.6 Q F0(oid)5.539 E F1 2.788(of the)5.538 F F0(pg_opclass)5.538 E F1
+5.213(instance for)278.55 140.8 R F0(int4_abs_ops)7.964 E F1 .684
+(\(== whate)278.55 154 R -.165(ve)-.275 G 3.434(ry).165 G .684
+(ou got instead of)-3.434 F(17314, see abo)278.55 167.2 Q -.165(ve)-.165
+G(\)).165 E 428.05 171.95 183.95 171.95 DL F0(amopopr)189.45 182.4 Q F1
+(the)278.55 182.4 Q F0(oid)2.779 E F1 2.779(so)C 2.779(ft)-2.779 G .029
+(he operators for the)-2.779 F 1.386(opclass \(which we')278.55 195.6 R
+1.386(ll get in just)-.11 F 2.75(am)278.55 208.8 S(inute\))-2.75 E
+428.05 213.55 183.95 213.55 DL(cost functions.)278.55 224 Q F0
+(amopselect,)189.45 224 Q(amopnpages)189.45 237.2 Q 428.05 241.95 183.95
+241.95 DL 428.05 88.75 428.05 241.95 DL 183.95 88.75 183.95 241.95 DL
+270.3 88.75 270.3 241.95 DL F1 .012(The cost functions are used by the \
+query optimizer to decide whether or not to use a gi)108 263.4 R -.165
+(ve)-.275 G(n).165 E(inde)108 276.6 Q 5.733(xi)-.165 G 5.733(nas)-5.733
+G 5.733(can. F)-5.733 F(ortunately)-.165 E 5.733(,t)-.715 G 2.983
+(hese already e)-5.733 F 5.733(xist. The)-.165 F(tw)5.733 E 5.732(of)
+-.11 G 2.982(unctions we')-5.732 F 2.982(ll use are)-.11 F F0(btreesel,)
+108 289.8 Q F1 1.467(which estimates the selecti)4.217 F 1.467
+(vity of the B-tree, and)-.275 F F0(btreenpage,)4.218 E F1(which)4.218 E
+(estimates the number of pages a search will touch in the tree.)108 303
+Q .215(So we need the)108 320.1 R F0(oid)2.965 E F1 2.965(so)C 2.965(ft)
+-2.965 G .215(he operators we just de\214ned.)-2.965 F -.88(We)5.714 G
+-.11('l).88 G 2.964(ll).11 G .214(ook up the names of all the)-2.964 F
+(operators that tak)108 333.3 Q 2.75(et)-.11 G -.11(wo)-2.75 G F0(int4)
+2.86 E F1(s, and pick ours out:)A/F2 10/Courier@0 SF
+(SELECT o.oid AS opoid, o.oprname)148 358.5 Q
+(INTO TABLE complex_ops_tmp)148 370.7 Q(FROM pg_operator o, pg_type t)
+148 382.9 Q(WHERE o.oprleft = t.oid and o.oprright = t.oid)148 395.1 Q
+(and t.typname = 'complex';)178 407.3 Q F1(which returns:)108 432.5 Q .4
+LW 245 450 148 450 DL F2 21(oid oprname)153 459.7 R 245 464.2 148 464.2
+DL 9(17321 <)153 473.9 R 245 478.4 148 478.4 DL 9(17322 <=)153 488.1 R
+245 492.6 148 492.6 DL 15(17323 =)153 502.3 R 245 506.8 148 506.8 DL 9
+(17324 >=)153 516.5 R 245 521 148 521 DL 9(17325 >)153 530.7 R 245 535.2
+148 535.2 DL 245 450 245 535.2 DL 148 450 148 535.2 DL 190.5 450 190.5
+535.2 DL F1(\(Ag)108 556.9 Q .294(ain, some of your)-.055 F F0(oid)3.044
+E F1 .295(numbers will almost certainly be dif)3.044 F 3.045
+(ferent.\) The)-.275 F .295(operators we)3.045 F 1.839
+(are interested in are those with)108 570.1 R F0(oid)4.589 E F1 4.589
+(s1)C 1.839(7321 through 17325.)-4.589 F 1.838(The v)7.338 F 1.838
+(alues you get will)-.275 F .504(probably be dif)108 583.3 R .504
+(ferent, and you should substitute them for the v)-.275 F .505
+(alues belo)-.275 F 4.685 -.715(w. W)-.275 H 3.255(ec)-.165 G .505
+(an look)-3.255 F
+(at the operator names and pick out the ones we just added.)108 596.5 Q
+(No)108 613.6 Q 3.447(ww)-.275 G(e')-3.447 E .697(re ready to update)
+-.55 F F0(pg_amop)3.447 E F1 .696(with our ne)3.446 F 3.446(wo)-.275 G
+.696(perator class.)-3.446 F .696(The most important)6.196 F 1.116(thin\
+g in this entire discussion is that the operators are ordered, from les\
+s equal through)108 626.8 R(greater equal, in)108 640 Q F0(pg_amop)2.75
+E F1 5.5(.W)C 2.75(ea)-6.38 G(dd the instances we need:)-2.75 E F2
+(INSERT INTO pg_amop \(amopid, amopclaid, amopopr, amopstrategy,)154
+665.2 Q(amopselect, amopnpages\))274 677.4 Q
+(SELECT am.oid, opcl.oid, c.opoid, 3,)178 689.6 Q
+('btreesel'::regproc, 'btreenpage'::regproc)195 701.8 Q/F3 11
+/Times-Bold@0 SF(43)282.5 756 Q EP
+%%Page: 44 44
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(FROM pg_am am, pg_opclass opcl, complex_ops_tmp c)
+178 96.2 Q(WHERE amname = 'btree' and opcname = 'complex_abs_ops')178
+108.4 Q(and c.oprname = '=';)196 120.6 Q/F1 11/Times-Roman@0 SF 1.007(N\
+ote the order: \231less than\232 is 1, \231less than or equal\232 is 2,\
+ \231equal\232 is 3, \231greater than or)108 159 R
+(equal\232 is 4, and \231greater than\232 is 5.)108 172.2 Q .437
+(The last step \(\214nally!\) is re)108 189.3 R .438
+(gistration of the \231support routine\232 pre)-.165 F .438
+(viously described in our)-.275 F 1.924(discussion of)108 202.5 R/F2 11
+/Courier@0 SF(pg_am)4.674 E F1 7.424(.T)C(he)-7.424 E F2(oid)4.674 E F1
+1.923(of this support routine is stored in the)4.673 F F2(pg_amproc)
+4.673 E F1 .078(class, k)108 215.7 R -.165(ey)-.11 G .078
+(ed by the access method).165 F F2(oid)2.828 E F1 .078
+(and the operator class)2.828 F F2(oid)2.829 E F1 5.579(.F)C .079
+(irst, we need to re)-5.579 F(g-)-.165 E .804(ister the function in)108
+228.9 R/F3 10/Times-Roman@0 SF(POSTGRES)3.554 E F1 .803
+(\(recall that we put the C code that implements this rou-)3.554 F(tine\
+ in the bottom of the \214le in which we implemented the operator routi\
+nes\):)108 242.1 Q F0(CREATE FUNCTION int4_abs_cmp\(int4, int4\))148
+267.3 Q(RETURNS int4)184 279.5 Q
+(AS '/usr/local/postgres95/tutorial/obj/complex.so')184 291.7 Q
+(LANGUAGE 'c';)184 303.9 Q
+(SELECT oid, proname FROM pg_proc WHERE prname = 'int4_abs_cmp';)148
+340.5 Q .4 LW 275 358 148 358 DL 21(oid proname)153 367.7 R 275 372.2
+148 372.2 DL 9(17328 int4_abs_cmp)153 381.9 R 275 386.4 148 386.4 DL 275
+358 275 386.4 DL 148 358 148 386.4 DL 190.5 358 190.5 386.4 DL F1(\(Ag)
+108 421.1 Q .642(ain, your)-.055 F F2(oid)3.392 E F1 .642
+(number will probably be dif)3.392 F .642
+(ferent and you should substitute the v)-.275 F(alue)-.275 E .526
+(you see for the v)108 434.3 R .526(alue belo)-.275 F -.715(w.)-.275 G
+6.026(\)R).715 G .526(ecalling that the B-tree instance')-6.026 F(s)
+-.605 E F2(oid)3.276 E F1 .526(is 403 and that of)3.276 F F2
+(int4_abs_ops)108 447.5 Q F1(is 17314, we can add the ne)2.75 E 2.75(wi)
+-.275 G(nstance as follo)-2.75 E(ws:)-.275 E F0
+(INSERT INTO pg_amproc \(amid, amopclaid, amproc, amprocnum\))148 472.7
+Q(VALUES \('403'::oid,)178 484.9 Q(-- btree oid)48 E 30
+('17314'::oid, --)226 497.1 R(pg_opclass tuple)12 E 30('17328'::oid, --)
+226 509.3 R(new pg_proc oid)6 E('1'::int2\);)226 521.5 Q/F4 11
+/Times-Bold@0 SF(44)282.5 756 Q EP
+%%Page: 45 45
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(12. LIBPQ)72 165.4 R 77.5 178.6 72
+178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86
+178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5
+178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6
+119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6
+135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5
+178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174
+178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL
+190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6
+DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5
+178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6
+229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6
+245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5
+178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284
+178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL
+300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6
+DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5
+178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6
+339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6
+355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5
+178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394
+178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL
+410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6
+DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5
+178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6
+449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6
+465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5
+178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504
+178.6 498.5 178.6 DL/F1 10/Times-Roman@0 SF(LIBPQ)108 208.9 Q/F2 11
+/Times-Roman@0 SF .581(is the application programming interf)3.331 F
+.581(ace to)-.11 F F1(POSTGRES)3.331 E F2(.)A F1(LIBPQ)6.081 E F2 .582
+(is a set of library)3.331 F .976(routines which allo)108 222.1 R .976
+(ws client programs to pass queries to the)-.275 F F1(POSTGRES)3.726 E
+F2(back)3.726 E .975(end serv)-.11 F(er)-.165 E(and to recei)108 235.3 Q
+.33 -.165(ve t)-.275 H(he results of these queries.).165 E 1.922(This v)
+108 252.4 R 1.922(ersion of the documentation describes the C interf)
+-.165 F 1.922(ace library)-.11 F 7.423(.T)-.715 G 1.923(hree short pro-)
+-7.423 F 1.642(grams are included at the end of this section to sho)108
+265.6 R 4.392(wh)-.275 G 2.192 -.275(ow t)-4.392 H 4.391(ow).275 G 1.641
+(rite programs that use)-4.391 F F1(LIBPQ)108 278.8 Q F2(.)A
+(There are se)108 295.9 Q -.165(ve)-.275 G(ral e).165 E(xamples of)-.165
+E F1(LIBPQ)2.75 E F2(applications in the follo)2.75 E(wing directories:)
+-.275 E/F3 10/Courier@0 SF(../src/test/regress)148 321.1 Q
+(../src/test/examples)148 333.3 Q(../src/bin/psql)148 345.5 Q F2 1.96
+(Frontend programs which use)108 375.6 R F1(LIBPQ)4.71 E F2 1.961
+(must include the header \214le)4.711 F/F4 11/Courier@0 SF(libpq-fe.h)
+4.711 E F2(and)4.711 E(must link with the)108 388.8 Q F4(libpq)2.75 E F2
+(library)2.75 E(.)-.715 E/F5 12/Times-Bold@0 SF 3(12.1. Contr)72 428.2 R
+(ol and Initialization)-.216 E F2 .497(The follo)108 445.3 R .497
+(wing en)-.275 F .497(vironment v)-.44 F .497
+(ariables can be used to set up def)-.275 F .496(ault en)-.11 F .496
+(vironment v)-.44 F .496(alues to)-.275 F -.22(avo)108 458.5 S
+(id hard-coding database names into an application program:).22 E<83>
+113.5 475.6 Q/F6 11/Times-Bold@0 SF(PGHOST)5.5 E F2(sets the def)2.75 E
+(ault serv)-.11 E(er name.)-.165 E<83>113.5 488.8 Q F6(PGOPTIONS)5.5 E
+F2(sets additional runtime options for the)2.75 E F1(POSTGRES)2.75 E F2
+(back)2.75 E(end.)-.11 E<83>113.5 502 Q F6(PGPOR)5.5 E(T)-.44 E F2
+(sets the def)2.75 E(ault port for communicating with the)-.11 E F1
+(POSTGRES)2.75 E F2(back)2.75 E(end.)-.11 E<83>113.5 515.2 Q F6(PGTTY)
+5.5 E F2 .201(sets the \214le or tty on which deb)2.951 F .201
+(ugging messages from the back)-.22 F .202(end serv)-.11 F .202(er are)
+-.165 F(displayed.)122.85 528.4 Q<83>113.5 541.6 Q F6(PGD)5.5 E -1.65
+-1.045(AT A)-.385 H -.33(BA)1.045 G(SE).33 E F2(sets the def)2.75 E
+(ault)-.11 E F1(POSTGRES)2.75 E F2(database name.)2.75 E<83>113.5 554.8
+Q F6(PGREALM)5.5 E F2 .232(sets the)2.982 F/F7 11/Times-Italic@0 SF
+-.385(Ke)2.982 G(rber).385 E(os)-.495 E F2 .232(realm to use with)2.982
+F F1(POSTGRES)2.981 E F2 2.981(,i)C 2.981(fi)-2.981 G 2.981(ti)-2.981 G
+2.981(sd)-2.981 G(if)-2.981 E .231(ferent from the)-.275 F 1.027
+(local realm.)122.85 568 R(If)6.527 E F4(PGREALM)3.777 E F2 1.027
+(is set,)3.777 F F1(POSTGRES)3.777 E F2 1.027
+(applications will attempt authentication)3.777 F 1.308(with serv)122.85
+581.2 R 1.308(ers for this realm and use separate tick)-.165 F 1.307
+(et \214les to a)-.11 F -.22(vo)-.22 G 1.307(id con\215icts with local)
+.22 F(tick)122.85 594.4 Q 2.668(et \214les.)-.11 F 2.668(This en)8.168 F
+2.668(vironment v)-.44 F 2.668(ariable is only used if)-.275 F F7 -.385
+(Ke)5.418 G(rber).385 E(os)-.495 E F2 2.668(authentication is)5.418 F
+(enabled.)122.85 607.6 Q F5 3(12.2. Database)72 633.8 R
+(Connection Functions)3 E F2(The follo)108 650.9 Q
+(wing routines deal with making a connection to a back)-.275 E
+(end from a C program.)-.11 E F6(PQsetdb)108 668 Q F2(Mak)133 685.1 Q
+(es a ne)-.11 E 2.75(wc)-.275 G(onnection to a back)-2.75 E(end.)-.11 E
+F3(PGconn *PQsetdb\(char *pghost,)173 710.3 Q(char *pgport,)269 722.5 Q
+F6(45)282.5 756 Q EP
+%%Page: 46 46
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(char *pgoptions,)269 96.2 Q(char *pgtty,)269 108.4 Q
+(char *dbName\);)269 120.6 Q/F1 11/Times-Roman@0 SF .482(If an)133 146.8
+R 3.232(ya)-.165 G -.198(rg)-3.232 G .481
+(ument is NULL, then the corresponding en).198 F .481(vironment v)-.44 F
+.481(ariable is check)-.275 F(ed.)-.11 E(If the en)133 160 Q
+(vironment v)-.44 E(ariable is also not set, then hardwired def)-.275 E
+(aults are used.)-.11 E/F2 11/Times-Italic@0 SF(PQsetdb)133 177.1 Q F1
+(al)4.191 E -.11(wa)-.11 G 1.441(ys returns a v).11 F 1.441
+(alid PGconn pointer)-.275 F 6.941(.T)-.605 G(he)-6.941 E F2(PQstatus)
+4.191 E F1 1.442(\(see belo)4.192 F 1.442(w\) com-)-.275 F 2.872
+(mand should be called to ensure that a connection w)133 190.3 R 2.872
+(as properly made before)-.11 F .2(queries are sent via the connection.)
+133 203.5 R/F3 10/Times-Roman@0 SF(LIBPQ)5.701 E F1 .201
+(programmers should be careful to main-)2.951 F .054
+(tain the PGconn abstraction.)133 216.7 R .054
+(Use the accessor functions belo)5.554 F 2.803(wt)-.275 G 2.803(og)
+-2.803 G .053(et at the contents)-2.803 F 1.332(of PGconn.)133 229.9 R
+-1.342 -.814(Av o)6.832 H 1.332
+(id directly referencing the \214elds of the PGconn structure as the)
+.814 F(y)-.165 E(are subject to change in the future.)133 243.1 Q/F4 11
+/Times-Bold@0 SF(PQdb)133 260.2 Q F1
+(returns the database name of the connection.)2.75 E F0
+(char *PQdb\(PGconn *conn\))173 285.4 Q F4(PQhost)133 311.6 Q F1
+(returns the host name of the connection.)2.75 E F0
+(char *PQhost\(PGconn *conn\))173 336.8 Q F4(PQoptions)133 363 Q F1
+(returns the pgoptions used in the connection.)2.75 E F0
+(char *PQoptions\(PGconn *conn\))173 388.2 Q F4(PQport)133 414.4 Q F1
+(returns the pgport of the connection.)2.75 E F0
+(char *PQport\(PGconn *conn\))173 439.6 Q F4(PQtty)133 465.8 Q F1
+(returns the pgtty of the connection.)2.75 E F0
+(char *PQtty\(PGconn *conn\))173 491 Q F4(PQstatus)133 517.2 Q F1 3.175
+(Returns the status of the connection. The status can be CONNEC-)5.926 F
+(TION_OK or CONNECTION_B)133 530.4 Q(AD.)-.385 E F0
+(ConnStatusType *PQstatus\(PGconn *conn\))173 555.6 Q F4(PQerr)133 581.8
+Q(orMessage)-.198 E F1
+(returns the error message associated with the connection)2.75 E F0
+(char *PQerrorMessage\(PGconn* conn\);)173 607 Q F4(PQ\214nish)108 637.1
+Q F1 .041(Close the connection to the back)133 654.2 R 2.791(end. Also)
+-.11 F .041(frees memory used by the PGconn struc-)2.791 F 2.75
+(ture. The)133 667.4 R
+(PGconn pointer should not be used after PQ\214nish has been called.)
+2.75 E F0(void PQfinish\(PGconn *conn\))173 692.6 Q F4(46)282.5 756 Q EP
+%%Page: 47 47
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Bold@0 SF(PQr)108 97.2 Q(eset)-.198 E/F1 11/Times-Roman@0
+SF 1.035(Reset the communication port with the back)133 114.3 R 3.784
+(end. This)-.11 F 1.034(function will close the IPC)3.784 F(sock)133
+127.5 Q .211(et connection to the back)-.11 F .212
+(end and attempt to reestablish a ne)-.11 F 2.962(wc)-.275 G .212
+(onnection to the)-2.962 F(same back)133 140.7 Q(end.)-.11 E/F2 10
+/Courier@0 SF(void PQreset\(PGconn *conn\))173 165.9 Q F0(PQtrace)108
+196 Q F1 1.773
+(Enables tracing of messages passed between the frontend and the back)
+133 213.1 R 4.523(end. The)-.11 F(messages are echoed to the deb)133
+226.3 Q(ug_port \214le stream.)-.22 E F2(void PQtrace\(PGconn *conn,)173
+251.5 Q(FILE* debug_port\);)251 263.7 Q F0(PQuntrace)108 293.8 Q F1
+(Disables tracing of messages passed between the frontend and the back)
+133 310.9 Q(end.)-.11 E F2(void PQuntrace\(PGconn *conn\);)173 336.1 Q
+/F3 12/Times-Bold@0 SF 3(12.3. Query)72 366.2 R(Execution Functions)3 E
+F0(PQexec)108 383.3 Q F1 .141(Submit a query to)133 400.4 R/F4 10
+/Times-Roman@0 SF(POSTGRES)2.891 E F1 5.641(.R)C .141
+(eturns a PGresult pointer if the query w)-5.641 F .142(as success-)-.11
+F .738(ful or a NULL otherwise.)133 413.6 R .738(If a NULL is returned,)
+6.238 F/F5 11/Times-Italic@0 SF(PQerr)3.488 E(orMessa)-.495 E -.11(ge)
+-.11 G F1 .738(can be used to)3.598 F
+(get more information about the error)133 426.8 Q(.)-.605 E F2
+(PGresult *PQexec\(PGconn *conn,)173 452 Q(char *query\);)275 464.2 Q F1
+3.049(The PGresult structure encapsulates the query result returned by \
+the back)133 490.4 R(end.)-.11 E F4(LIBPQ)133 503.6 Q F1 .217(programme\
+rs should be careful to maintain the PGresult abstraction. Use the)2.967
+F 2.819(accessor functions described belo)133 516.8 R 5.569(wt)-.275 G
+5.569(or)-5.569 G(etrie)-5.569 E 3.149 -.165(ve t)-.275 H 2.819
+(he results of the query).165 F 8.32(.A)-.715 G -.22(vo)-9.134 G(id).22
+E .188
+(directly referencing the \214elds of the PGresult structure as the)133
+530 R 2.938(ya)-.165 G .188(re subject to change)-2.938 F
+(in the future.)133 543.2 Q F0(PQr)108 560.3 Q(esultStatus)-.198 E F1
+.562(Returns the result status of the query)133 577.4 R(.)-.715 E F5
+(PQr)6.062 E(esultStatus)-.407 E F1 .562(can return one of the follo)
+3.312 F(w-)-.275 E(ing v)133 590.6 Q(alues:)-.275 E F2
+(PGRES_EMPTY_QUERY,)173 615.8 Q 6(PGRES_COMMAND_OK, /*)173 628 R
+(the query was a command */)6 E 6(PGRES_TUPLES_OK, /*)173 640.2 R
+(the query successfully returned tuples */)6 E(PGRES_COPY_OUT,)173 652.4
+Q(PGRES_COPY_IN,)173 664.6 Q
+(PGRES_BAD_RESPONSE, /* an unexpected response was received */)173 676.8
+Q(PGRES_NONFATAL_ERROR,)173 689 Q(PGRES_FATAL_ERROR)173 701.2 Q F0(47)
+282.5 756 Q EP
+%%Page: 48 48
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF .004
+(If the result status is PGRES_TUPLES_OK, then the follo)133 97.2 R .004
+(wing routines can be used)-.275 F(to retrie)133 110.4 Q .33 -.165(ve t)
+-.275 H(he tuples returned by the query).165 E(.)-.715 E/F1 11
+/Times-Bold@0 SF(PQntuples)133 127.5 Q F0
+(returns the number of tuples \(instances\) in the query result.)2.75 E
+/F2 10/Courier@0 SF(int PQntuples\(PGresult *res\);)173 152.7 Q F1
+(PQn\214elds)133 178.9 Q F0(returns the number of \214elds \(attrib)2.75
+E(utes\) in the query result.)-.22 E F2(int PQnfields\(PGresult *res\);)
+173 204.1 Q F1(PQfname)133 230.3 Q F0 1.473
+(returns the \214eld \(attrib)4.223 F 1.473
+(ute\) name associated with the gi)-.22 F -.165(ve)-.275 G 4.224<6e8c>
+.165 G 1.474(eld inde)-4.224 F(x.)-.165 E(Field indices start at 0.)133
+243.5 Q F2(char *PQfname\(PGresult *res,)173 268.7 Q(int field_index\);)
+251 280.9 Q F1(PQfnumber)133 307.1 Q F0 .418
+(returns the \214eld \(attrib)3.168 F .417(ute\) inde)-.22 F 3.167(xa)
+-.165 G .417(ssociated with the gi)-3.167 F -.165(ve)-.275 G 3.167<6e8c>
+.165 G .417(eld name.)-3.167 F F2(int PQfnumber\(PGresult *res,)173
+332.3 Q(char* field_name\);)251 344.5 Q F1(PQftype)133 370.7 Q F0 1.677
+(returns the \214eld type associated with the gi)4.426 F -.165(ve)-.275
+G 4.427<6e8c>.165 G 1.677(eld inde)-4.427 F 1.677(x. The inte)-.165 F
+(ger)-.165 E(returned is an internal coding of the type.)133 383.9 Q
+(Field indices start at 0.)5.5 E F2(Oid PQftype\(PGresult *res,)173
+409.1 Q(int field_num\);)245 421.3 Q F1(PQfsize)133 447.5 Q F0 .17
+(returns the size in bytes of the \214eld associated with the gi)2.92 F
+-.165(ve)-.275 G 2.919<6e8c>.165 G .169(eld inde)-2.919 F .169(x. If)
+-.165 F(the size returned is -1, the \214eld is a v)133 460.7 Q
+(ariable length \214eld.)-.275 E(Field indices start at 0.)5.5 E F2
+(int2 PQfsize\(PGresult *res,)173 485.9 Q(int field_index\);)251 498.1 Q
+F1(PQgetv)133 524.3 Q(alue)-.11 E F0 .494(returns the \214eld \(attrib)
+3.244 F .494(ute\) v)-.22 F 3.244(alue. F)-.275 F .494
+(or most queries, the v)-.165 F .495(alue returned)-.275 F(by)133 537.5
+Q/F3 11/Times-Italic@0 SF(PQg)5.299 E(etvalue)-.11 E F0 2.549
+(is a null-terminated ASCII string representation of the attrib)5.299 F
+(ute)-.22 E -.275(va)133 550.7 S 3.973(lue. If).275 F 1.223(the query w)
+3.973 F 1.223(as a result of a)-.11 F F1(BIN)3.973 E(AR)-.22 E(Y)-.385 E
+F0(cursor)3.974 E 3.974(,t)-.44 G 1.224(hen the v)-3.974 F 1.224
+(alue returned by)-.275 F F3(PQg)133 563.9 Q(etvalue)-.11 E F0 1.781
+(is the binary representation of the type in the internal format of the)
+4.531 F(back)133 577.1 Q .287(end serv)-.11 F(er)-.165 E 5.788(.I)-.605
+G 3.038(ti)-5.788 G 3.038(st)-3.038 G .288(he programmer')-3.038 F 3.038
+(sr)-.605 G .288(esponsibility to cast and con)-3.038 F -.165(ve)-.44 G
+.288(rt the data to).165 F .604(the correct C type.)133 590.3 R .604
+(The v)6.104 F .604(alue returned by)-.275 F F3(PQg)3.354 E(etvalue)-.11
+E F0 .603(points to storage that is part)3.354 F .264
+(of the PGresult structure.)133 603.5 R .264(One must e)5.764 F .264
+(xplicitly cop)-.165 F 3.014(yt)-.11 G .264(he v)-3.014 F .265
+(alue into other storage if it)-.275 F
+(is to be used past the lifetime of the PGresult structure itself.)133
+616.7 Q F2(char* PQgetvalue\(PGresult *res,)173 641.9 Q(int tup_num,)275
+654.1 Q(int field_num\);)275 666.3 Q F1(PQgetlength)133 692.5 Q F0 .49
+(returns the length of a \214eld \(attrib)3.24 F .489(ute\) in bytes.)
+-.22 F .489(If the \214eld is a)5.989 F F3(struct)3.239 E(varlena)133
+705.7 Q F0 3.324(,t)C .574(he length returned here does)-3.324 F F1(not)
+3.324 E F0 .575(include the size \214eld of the v)3.325 F .575
+(arlena, i.e.,)-.275 F(it is 4 bytes less.)133 718.9 Q F1(48)282.5 756 Q
+EP
+%%Page: 49 49
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(int PQgetlength\(PGresult *res,)173 96.2 Q
+(int tup_num,)269 108.4 Q(int field_num\);)269 120.6 Q/F1 11
+/Times-Bold@0 SF(PQcmdStatus)108 150.7 Q/F2 11/Times-Roman@0 SF
+(Returns the command status associated with the last query command.)133
+167.8 Q F0(char *PQcmdStatus\(PGresult *res\);)173 193 Q F1(PQoidStatus)
+108 223.1 Q F2 2.297(Returns a string with the object id of the tuple i\
+nserted if the last query is an)133 240.2 R(INSER)133 253.4 Q 2.75(Tc)
+-.66 G 2.75(ommand. Otherwise,)-2.75 F(returns an empty string.)2.75 E
+F0(char* PQoidStatus\(PGresult *res\);)173 278.6 Q F1(PQdisplayT)108
+308.7 Q(uples)-1.012 E F2 .946
+(Prints out all the tuples and, optionally)133 325.8 R 3.696(,t)-.715 G
+.946(he attrib)-3.696 F .947(ute names to the speci\214ed output)-.22 F
+2.75(stream. The)133 339 R(programs)2.75 E F1(psql)2.75 E F2(and)2.75 E
+F1(monitor)2.75 E F2(both use)2.75 E/F3 11/Times-Italic@0 SF(PQdisplayT)
+2.75 E(uples)-.605 E F2(for output.)2.75 E F0(void PQdisplayTuples\()173
+364.2 Q(PGresult* res,)215 376.4 Q(FILE* fout,)215 388.6 Q
+(/* output stream */)36 E(int fillAlign,)215 400.8 Q
+(/* pad the fields with spaces? */)18 E(char *fieldSep,)215 413 Q
+(/* string to use as the field separator */)12 E
+(int printHeader, /* display attribute headers */)215 425.2 Q
+(int quiet,)215 437.4 Q(/* print the number of rows returned ? */)42 E
+(\);)215 449.6 Q F1(PQclear)108 479.7 Q F2 .635
+(Frees the storage associated with the PGresult.)133 496.8 R(Ev)6.135 E
+.634(ery query result should be prop-)-.165 F .588
+(erly freed when it is no longer used.)133 510 R -.165(Fa)6.089 G .589
+(ilure to do this will result in memory leaks).165 F
+(in the frontend application.)133 523.2 Q F0
+(void PQclear\(PQresult *res\);)173 548.4 Q/F4 12/Times-Bold@0 SF 3
+(12.4. F)72 578.5 R(ast P)-.3 E(ath)-.12 E/F5 10/Times-Roman@0 SF
+(POSTGRES)108 595.6 Q F2(pro)3.011 E .26(vides a)-.165 F F1 .26
+(fast path)3.01 F F2(interf)3.01 E .26
+(ace to send function calls to the back)-.11 F 3.01(end. This)-.11 F .26
+(is a)3.01 F 1.006
+(trapdoor into system internals and can be a potential security hole.)
+108 608.8 R 1.007(Most users will not)6.507 F(need this feature.)108 622
+Q F0(PGresult* PQfn\(PGconn* conn,)148 647.2 Q(int fnid,)226 659.4 Q
+(int *result_buf,)226 671.6 Q(int *result_len,)226 683.8 Q
+(int result_is_int,)226 696 Q(PQArgBlock *args,)226 708.2 Q
+(int nargs\);)226 720.4 Q F1(49)282.5 756 Q EP
+%%Page: 50 50
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF(The)108 97.2 Q/F1 11/Times-Italic@0 SF(fnid)
+3.054 E F0(ar)3.054 E .304
+(gument is the object identi\214er of the function to be e)-.198 F -.165
+(xe)-.165 G(cuted.).165 E F1 -.407(re)5.803 G(sult_b).407 E(uf)-.22 E F0
+.303(is the)3.053 F -.22(bu)108 110.4 S -.275(ff).22 G .807
+(er in which to load the return v).275 F 3.557(alue. The)-.275 F .807
+(caller must ha)3.557 F 1.137 -.165(ve a)-.22 H .807(llocated suf).165 F
+.807(\214cient space)-.275 F .861(to store the return v)108 123.6 R
+3.611(alue. The)-.275 F .861
+(result length will be returned in the storage pointed to by)3.611 F F1
+-.407(re)108 136.8 S(sult_len.).407 E F0 .075
+(If the result is to be an inte)5.575 F .075(ger v)-.165 F .075
+(alue, than)-.275 F F1 -.407(re)2.825 G(sult_is_int).407 E F0 .075
+(should be set to 1; oth-)2.825 F(erwise it should be set to 0.)108 150
+Q F1(ar)5.5 E(gs)-.407 E F0(and)2.75 E F1(nar)2.75 E(gs)-.407 E F0
+(specify the ar)2.75 E(guments to the function.)-.198 E/F2 10/Courier@0
+SF(typedef struct {)148 175.2 Q(int len;)172 187.4 Q(int isint;)172
+199.6 Q(union {)172 211.8 Q(int *ptr;)196 224 Q(int integer;)184 236.2 Q
+6(}u)172 248.4 S(;)-6 E 6(}P)148 260.6 S(QArgBlock;)-6 E F1(PQfn)108
+290.7 Q F0(al)4.181 E -.11(wa)-.11 G 1.431(ys returns a v).11 F 1.431
+(alid PGresult*.)-.275 F 1.431(The resultStatus should be check)6.931 F
+1.431(ed before the)-.11 F .37(result is used.)108 303.9 R .37
+(The caller is responsible for freeing the PGresult with)8.62 F F1
+(PQclear)3.121 E F0 .371(when it is)3.121 F(not longer needed.)108 317.1
+Q/F3 12/Times-Bold@0 SF 3(12.5. Asynchr)72 334.2 R(onous Noti\214cation)
+-.216 E/F4 10/Times-Roman@0 SF(POSTGRES)108 351.3 Q F0 .808
+(supports asynchronous noti\214cation via the)3.558 F F1(LISTEN)3.557 E
+F0(and)3.557 E F1(NO)3.557 E(TIFY)-.44 E F0(commands.)3.557 E 3.739(Ab)
+108 364.5 S(ack)-3.739 E .989(end re)-.11 F .989
+(gisters its interest in a particular relation with the LISTEN command.)
+-.165 F(All)6.49 E(back)108 377.7 Q 3.32(ends listening on a particular\
+ relation will be noti\214ed asynchronously when a)-.11 F(NO)108 390.9 Q
+.996(TIFY of that relation name is e)-.44 F -.165(xe)-.165 G .997
+(cuted by another back).165 F 3.747(end. No)-.11 F .997
+(additional informa-)3.747 F .53
+(tion is passed from the noti\214er to the listener)108 404.1 R 6.029
+(.T)-.605 G .529(hus, typically)-6.029 F 3.279(,a)-.715 G .859 -.165
+(ny a)-3.279 H .529(ctual data that needs).165 F
+(to be communicated is transferred through the relation.)108 417.3 Q F4
+(LIBPQ)108 434.4 Q F0 2.056(applications are noti\214ed whene)4.806 F
+-.165(ve)-.275 G 4.807(rac).165 G 2.057(onnected back)-4.807 F 2.057
+(end has recei)-.11 F -.165(ve)-.275 G 4.807(da).165 G 4.807(na)-4.807 G
+(syn-)-4.807 E .731(chronous noti\214cation.)108 447.6 R(Ho)6.231 E(we)
+-.275 E -.165(ve)-.275 G 1.611 -.44(r, t).165 H .731
+(he communication from the back).44 F .731(end to the frontend is)-.11 F
+2.002(not asynchronous.)108 460.8 R 2.002
+(Noti\214cation comes piggy-back)7.502 F 2.002
+(ed on other query results.)-.11 F 2.002(Thus, an)7.502 F .81
+(application must submit queries, e)108 474 R -.165(ve)-.275 G 3.56(ne)
+.165 G .81(mpty ones, in order to recei)-3.56 F 1.139 -.165(ve n)-.275 H
+.809(otice of back).165 F(end)-.11 E 3.308(noti\214cation. In)108 487.2
+R(ef)3.308 E .558(fect, the)-.275 F F4(LIBPQ)3.308 E F0 .558
+(application must poll the back)3.308 F .559(end to see if there is an)
+-.11 F(y)-.165 E 1.901(pending noti\214cation information.)108 500.4 R
+1.9(After the e)7.401 F -.165(xe)-.165 G 1.9(cution of a query).165 F
+4.65(,af)-.715 G 1.9(rontend may call)-4.65 F F1(PQNoti\214es)108 513.6
+Q F0(to see if an)2.75 E 2.75(yn)-.165 G(oti\214cation data is a)-2.75 E
+-.275(va)-.22 G(ilable from the back).275 E(end.)-.11 E/F5 11
+/Times-Bold@0 SF(PQNoti\214es)108 530.7 Q F0 2.129(returns the noti\214\
+cation from a list of unhandled noti\214cations from the back)133 547.8
+R(end.)-.11 E .825
+(Returns NULL if there are no pending noti\214cations from the back)133
+561 R(end.)-.11 E F1(PQNoti\214es)6.325 E F0(beha)133 574.2 Q -.165(ve)
+-.22 G 3.76(sl).165 G(ik)-3.76 E 3.76(et)-.11 G 1.01
+(he popping of a stack.)-3.76 F 1.011
+(Once a noti\214cation is returned from)6.511 F F1(PQnoti-)3.761 E
+(\214es,)133 587.4 Q F0(it is considered handled and will be remo)2.75 E
+-.165(ve)-.165 G 2.75(df).165 G(rom the list of noti\214cations.)-2.75 E
+F2(PGnotify* PQNotifies\(PGconn *conn\);)173 612.6 Q F0
+(The second sample program gi)108 642.7 Q -.165(ve)-.275 G 2.75(sa).165
+G 2.75(ne)-2.75 G(xample of the use of asynchronous noti\214cation.)
+-2.915 E F3 3(12.6. Functions)72 659.8 R
+(Associated with the COPY Command)3 E F0(The)108 676.9 Q F1(copy)3.4 E
+F0 .65(command in)3.4 F F4(POSTGRES)3.4 E F0 .649
+(has options to read from or write to the netw)3.4 F .649(ork con-)-.11
+F 1.149(nection used by)108 690.1 R F4(LIBPQ)3.899 E F0 6.649(.T)C 1.149
+(herefore, functions are necessary to access this netw)-6.649 F 1.15
+(ork con-)-.11 F(nection directly so applications may tak)108 703.3 Q
+2.75(ef)-.11 G(ull adv)-2.75 E(antage of this capability)-.275 E(.)-.715
+E F5(50)282.5 756 Q EP
+%%Page: 51 51
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Bold@0 SF(PQgetline)108 97.2 Q/F1 11/Times-Roman@0 SF 1.171
+(Reads a ne)133 114.3 R 1.171
+(wline-terminated line of characters \(transmitted by the back)-.275 F
+1.17(end serv)-.11 F(er\))-.165 E .821(into a b)133 127.5 R(uf)-.22 E
+(fer)-.275 E/F2 11/Times-Italic@0 SF(string)3.571 E F1 .821(of size)
+3.571 F F2(length)3.571 E F1 6.321(.L)C(ik)-6.321 E(e)-.11 E F2(fg)3.571
+E(ets)-.11 E F1 .822(\(3\), this routine copies up to)B F2(length)3.572
+E F1(-1)A .56(characters into)133 140.7 R F2(string)3.31 E F1 6.06(.I)C
+3.31(ti)-6.06 G 3.31(sl)-3.31 G(ik)-3.31 E(e)-.11 E F2 -.11(ge)3.31 G
+(ts).11 E F1 .56(\(3\), ho)B(we)-.275 E -.165(ve)-.275 G 1.439 -.44
+(r, i).165 H 3.309(nt).44 G .559(hat it con)-3.309 F -.165(ve)-.44 G
+.559(rts the terminating).165 F(ne)133 153.9 Q
+(wline into a null character)-.275 E(.)-.605 E F2(PQg)133 171 Q(etline)
+-.11 E F1 .329(returns EOF at EOF)3.078 F 3.079(,0i)-.88 G 3.079(ft)
+-3.079 G .329(he entire line has been read, and 1 if the b)-3.079 F(uf)
+-.22 E(fer)-.275 E(is full b)133 184.2 Q(ut the terminating ne)-.22 E
+(wline has not yet been read.)-.275 E 1.471
+(Notice that the application must check to see if a ne)133 201.3 R 4.221
+(wl)-.275 G 1.471(ine consists of the single)-4.221 F 2.691
+(character \231.)133 214.5 R 2.691(\232, which indicates that the back)
+-.77 F 2.691(end serv)-.11 F 2.692(er has \214nished sending the)-.165 F
+.89(results of the)133 227.7 R F2(copy)3.64 E F1 3.64
+(command. Therefore,)3.64 F .889(if the application e)3.639 F -.165(ve)
+-.275 G 3.639(re).165 G .889(xpects to recei)-3.804 F -.165(ve)-.275 G
+1.419(lines that are more than)133 240.9 R F2(length)4.169 E F1 1.419
+(-1 characters long, the application must be sure to)B
+(check the return v)133 254.1 Q(alue of)-.275 E F2(PQg)2.75 E(etline)
+-.11 E F1 -.165(ve)2.75 G(ry carefully).165 E(.)-.715 E(The code in)133
+271.2 Q/F3 10/Courier@0 SF(../src/bin/psql/psql.c)173 296.4 Q F1
+(contains routines that correctly handle the cop)133 322.6 Q 2.75(yp)
+-.11 G(rotocol.)-2.75 E F3(int PQgetline\(PGconn *conn,)173 347.8 Q
+(char *string,)257 360 Q(int length\))257 372.2 Q F0(PQputline)108 402.3
+Q F1(Sends a null-terminated)133 419.4 Q F2(string)2.75 E F1
+(to the back)2.75 E(end serv)-.11 E(er)-.165 E(.)-.605 E .152
+(The application must e)133 436.5 R .152
+(xplicitly send the single character \231.)-.165 F 5.652<9a74>-.77 G
+2.901(oi)-5.652 G .151(ndicate to the back-)-2.901 F
+(end that it has \214nished sending its data.)133 449.7 Q F3
+(void PQputline\(PGconn *conn,)173 474.9 Q(char *string\);)263 487.1 Q
+F0(PQendcopy)108 517.2 Q F1 2.02(Syncs with the back)133 534.3 R 4.77
+(end. This)-.11 F 2.021(function w)4.77 F 2.021(aits until the back)-.11
+F 2.021(end has \214nished the)-.11 F(cop)133 547.5 Q 5.207 -.715(y. I)
+-.11 H 3.777(ts).715 G 1.027
+(hould either be issued when the last string has been sent to the back)
+-3.777 F(end)-.11 E(using)133 560.7 Q F2(PQputline)3.67 E F1 .921
+(or when the last string has been recei)3.67 F -.165(ve)-.275 G 3.671
+(df).165 G .921(rom the back)-3.671 F .921(end using)-.11 F F2(PGg)133
+573.9 Q(etline)-.11 E F1 6.439(.I)C 3.689(tm)-6.439 G .939
+(ust be issued or the back)-3.689 F .939
+(end may get \231out of sync\232 with the fron-)-.11 F 5.023(tend. Upon)
+133 587.1 R 2.274(return from this function, the back)5.023 F 2.274
+(end is ready to recei)-.11 F 2.604 -.165(ve t)-.275 H 2.274(he ne).165
+F(xt)-.165 E(query)133 600.3 Q(.)-.715 E(The return v)133 617.4 Q
+(alue is 0 on successful completion, nonzero otherwise.)-.275 E F3
+(int PQendcopy\(PGconn *conn\);)173 642.6 Q F1(As an e)133 668.8 Q
+(xample:)-.165 E F3
+(PQexec\(conn, "create table foo \(a int4, b char16, d float8\)"\);)173
+694 Q(PQexec\(conn, "copy foo from stdin"\);)173 706.2 Q
+(PQputline\(conn, "3<TAB>hello world<TAB>4.5\\n"\);)173 718.4 Q F0(51)
+282.5 756 Q EP
+%%Page: 52 52
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF
+(PQputline\(conn,"4<TAB>goodbye world<TAB>7.11\\n"\);)173 96.2 Q(...)173
+108.4 Q(PQputline\(conn,".\\n"\);)173 120.6 Q(PQendcopy\(conn\);)173
+132.8 Q/F1 12/Times-Bold@0 SF 3(12.7. LIBPQ)72 162.9 R -.888(Tr)3 G
+(acing Functions).888 E/F2 11/Times-Bold@0 SF(PQtrace)108 180 Q/F3 11
+/Times-Roman@0 SF(Enable tracing of the frontend/back)133 197.1 Q
+(end communication to a deb)-.11 E(ugging \214le stream.)-.22 E F0
+(void PQtrace\(PGconn *conn)173 222.3 Q(FILE *debug_port\))251 234.5 Q
+F2(PQuntrace)108 264.6 Q F3(Disable tracing started by)133 281.7 Q/F4 11
+/Times-Italic@0 SF(PQtr)2.75 E(ace)-.165 E F0
+(void PQuntrace\(PGconn *conn\))173 306.9 Q F1 3(12.8. User)72 337 R -.6
+(Au)3 G(thentication Functions).6 E F3 1.119(If the user has generated \
+the appropriate authentication credentials \(e.g., obtaining)108 354.1 R
+F4 -.385(Ke)3.869 G -.22(r-).385 G(ber)108 367.3 Q(os)-.495 E F3(tick)
+3.064 E .314(ets\), the frontend/back)-.11 F .315
+(end authentication process is handled by)-.11 F F4(PQe)3.065 E(xec)-.22
+E F3(without)3.065 E(an)108 380.5 Q 2.812(yf)-.165 G .062(urther interv)
+-2.812 F 2.812(ention. The)-.165 F(follo)2.812 E .061
+(wing routines may be called by)-.275 F/F5 10/Times-Roman@0 SF(LIBPQ)
+2.811 E F3 .061(programs to tai-)2.811 F(lor the beha)108 393.7 Q
+(vior of the authentication process.)-.22 E F2(fe_getauthname)108 410.8
+Q F3 1.32(Returns a pointer to static space containing whate)133 427.9 R
+-.165(ve)-.275 G 4.07(rn).165 G 1.321(ame the user has authenti-)-4.07 F
+3.549(cated. Use)133 441.1 R .799(of this routine in place of calls to)
+3.549 F F4 -.11(ge)3.548 G(ten).11 E(v)-.44 E F3 .798(\(3\) or)B F4 -.11
+(ge)3.548 G(tpwuid).11 E F3 .798(\(3\) by applica-)B 1.407(tions is hig\
+hly recommended, as it is entirely possible that the authenticated user)
+133 454.3 R .29(name is)133 467.5 R F2(not)3.04 E F3 .29(the same as v)
+3.04 F .29(alue of the)-.275 F/F6 11/Courier@0 SF(USER)3.04 E F3(en)3.04
+E .29(vironment v)-.44 F .29(ariable or the user')-.275 F 3.039(se)-.605
+G(ntry)-3.039 E(in)133 480.7 Q F4(/etc/passwd)2.75 E F3(.)A F0
+(char *fe_getauthname\(char* errorMessage\))173 505.9 Q F2
+(fe_setauthsvc)108 536 Q F3 1.521(Speci\214es that)133 553.1 R F5(LIBPQ)
+4.272 E F3 1.522(should use authentication service)4.272 F F4(name)4.272
+E F3 1.522(rather than its com-)4.272 F(piled-in def)133 566.3 Q 2.75
+(ault. This)-.11 F -.275(va)2.75 G(lue is typically tak).275 E
+(en from a command-line switch.)-.11 E F0
+(void fe_setauthsvc\(char *name,)173 591.5 Q(char* errorMessage\))287
+603.7 Q F3(An)133 629.9 Q 3.529(ye)-.165 G .778(rror messages from the \
+authentication attempts are returned in the errorMes-)-3.529 F(sage ar)
+133 643.1 Q(gument.)-.198 E F1 3(12.9. B)72 660.2 R(UGS)-.12 E F3 1.28
+(The query b)108 677.3 R(uf)-.22 E 1.28
+(fer is 8192 bytes long, and queries o)-.275 F -.165(ve)-.165 G 4.031
+(rt).165 G 1.281(hat length will be silently trun-)-4.031 F(cated.)108
+690.5 Q F2(52)282.5 756 Q EP
+%%Page: 53 53
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(12.10. Sample)72 97.2 R(Pr)3 E(ograms)-.216 E
+/F1 11/Times-Bold@0 SF(53)282.5 756 Q EP
+%%Page: 54 54
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(12.10.1. Sample)72 97.2 R(Pr)3 E(ogram 1)-.216
+E/F1 10/Courier@0 SF(/*)148 113.3 Q 6(*t)154 125.5 S(estlibpq.c)-6 E 24
+(*T)154 137.7 S(est the C version of)-24 E/F2 9/Courier@0 SF(LIBPQ)6 E
+F1 6(,t)C(he)-6 E F2(POSTGRES)6 E F1(frontend library.)6 E(*)154 149.9 Q
+(*)154 162.1 Q(*/)154 174.3 Q(#include <stdio.h>)148 186.5 Q
+(#include "libpq-fe.h")148 198.7 Q(void)148 223.1 Q
+(exit_nicely\(PGconn* conn\))148 235.3 Q({)148 247.5 Q
+(PQfinish\(conn\);)160 259.7 Q(exit\(1\);)160 271.9 Q(})148 284.1 Q
+(main\(\))148 308.5 Q({)148 320.7 Q
+(char *pghost, *pgport, *pgoptions, *pgtty;)160 332.9 Q(char* dbName;)
+160 345.1 Q(int nFields;)160 357.3 Q(int i,j;)160 369.5 Q 6(/* FILE)148
+393.9 R(*debug; */)6 E(PGconn* conn;)160 418.3 Q(PGresult* res;)160
+430.5 Q(/* begin, by setting the parameters for a backend connection)160
+454.9 Q(if the parameters are null, then the system will try to use)178
+467.1 Q(reasonable defaults by looking up environment variables)178
+479.3 Q(or, failing that, using hardwired constants */)178 491.5 Q
+(pghost = NULL;)160 503.7 Q(/* host name of the backend server */)12 E
+(pgport = NULL;)160 515.9 Q(/* port of the backend server */)12 E
+(pgoptions = NULL; /* special options to start up the backend server */)
+160 528.1 Q(pgtty = NULL;)160 540.3 Q
+(/* debugging tty for the backend server */)30 E(dbName = "template1";)
+160 552.5 Q(/* make a connection to the database */)160 576.9 Q
+(conn = PQsetdb\(pghost, pgport, pgoptions, pgtty, dbName\);)160 589.1 Q
+(/* check to see that the backend connection was successfully made */)
+160 613.5 Q(if \(PQstatus\(conn\) == CONNECTION_BAD\) {)160 625.7 Q
+(fprintf\(stderr,"Connection to database '%s' failed.0, dbName\);)172
+637.9 Q(fprintf\(stderr,"%s",PQerrorMessage\(conn\)\);)172 650.1 Q
+(exit_nicely\(conn\);)172 662.3 Q(})160 674.5 Q 6(/* debug)148 698.9 R 6
+(=f)6 G 6(open\("/tmp/trace.out","w"\); */)-6 F 12(/* PQtrace\(conn,)148
+711.1 R 6(debug\); */)6 F/F3 11/Times-Bold@0 SF(54)282.5 756 Q EP
+%%Page: 55 55
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(/* start a transaction block */)160 96.2 Q
+(res = PQexec\(conn,"BEGIN"\);)160 108.4 Q
+(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 120.6 Q
+(fprintf\(stderr,"BEGIN command failed0\);)172 132.8 Q(PQclear\(res\);)
+172 145 Q(exit_nicely\(conn\);)172 157.2 Q(})160 169.4 Q
+(/* should PQclear PGresult whenever it is no longer needed to avoid)160
+181.6 Q(memory leaks */)178 193.8 Q(PQclear\(res\);)160 206 Q(/* fetch \
+instances from the pg_database, the system catalog of databases*/)160
+230.4 Q(res = PQexec\(conn,"DECLARE myportal CURSOR FOR select * from p\
+g_database"\);)160 242.6 Q
+(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 254.8 Q
+(fprintf\(stderr,"DECLARE CURSOR command failed0\);)172 267 Q
+(PQclear\(res\);)172 279.2 Q(exit_nicely\(conn\);)172 291.4 Q(})160
+303.6 Q(PQclear\(res\);)160 315.8 Q
+(res = PQexec\(conn,"FETCH ALL in myportal"\);)160 340.2 Q
+(if \(PQresultStatus\(res\) != PGRES_TUPLES_OK\) {)160 352.4 Q
+(fprintf\(stderr,"FETCH ALL command didn't return tuples properly0\);)
+172 364.6 Q(PQclear\(res\);)172 376.8 Q(exit_nicely\(conn\);)172 389 Q
+(})160 401.2 Q(/* first, print out the attribute names */)160 425.6 Q
+(nFields = PQnfields\(res\);)160 437.8 Q
+(for \(i=0; i < nFields; i++\) {)160 450 Q
+(printf\("%-15s",PQfname\(res,i\)\);)172 462.2 Q(})160 474.4 Q
+(printf\("0\);)160 486.6 Q(/* next, print out the instances */)160 511 Q
+(for \(i=0; i < PQntuples\(res\); i++\) {)160 523.2 Q(for \(j=0)172
+535.4 Q 6(;j<n)12 G(Fields; j++\) {)-6 E
+(printf\("%-15s", PQgetvalue\(res,i,j\)\);)184 547.6 Q(})172 559.8 Q
+(printf\("0\);)172 572 Q(})160 584.2 Q(PQclear\(res\);)160 608.6 Q
+(/* close the portal */)160 633 Q
+(res = PQexec\(conn, "CLOSE myportal"\);)160 645.2 Q(PQclear\(res\);)160
+657.4 Q(/* end the transaction */)160 681.8 Q
+(res = PQexec\(conn, "END"\);)160 694 Q(PQclear\(res\);)160 706.2 Q/F1
+11/Times-Bold@0 SF(55)282.5 756 Q EP
+%%Page: 56 56
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF
+(/* close the connection to the database and cleanup */)160 96.2 Q
+(PQfinish\(conn\);)160 108.4 Q 12(/* fclose\(debug\);)148 132.8 R(*/)6 E
+(})148 145 Q/F1 11/Times-Bold@0 SF(56)282.5 756 Q EP
+%%Page: 57 57
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(12.10.2. Sample)72 97.2 R(Pr)3 E(ogram 2)-.216
+E/F1 10/Courier@0 SF(/*)148 113.3 Q 6(*t)154 125.5 S(estlibpq2.c)-6 E 24
+(*T)154 137.7 S(est of the asynchronous notification interface)-24 E(*)
+154 149.9 Q(populate a database with the following:)166 162.1 Q
+(CREATE TABLE TBL1 \(i int4\);)148 186.5 Q
+(CREATE TABLE TBL2 \(i int4\);)148 210.9 Q(CREATE RULE r1 AS ON INSERT \
+TO TBL1 DO [INSERT INTO TBL2 values \(new.i\); NOTIFY TBL2];)148 235.3 Q
+6(*T)154 259.7 S(hen start up this program)-6 E 6(*A)154 271.9 S
+(fter the program has begun, do)-6 E(INSERT INTO TBL1 values \(10\);)148
+296.3 Q(*)154 320.7 Q(*)154 332.9 Q(*/)154 345.1 Q(#include <stdio.h>)
+148 357.3 Q(#include "libpq-fe.h")148 369.5 Q
+(void exit_nicely\(PGconn* conn\))148 393.9 Q({)148 406.1 Q
+(PQfinish\(conn\);)160 418.3 Q(exit\(1\);)160 430.5 Q(})148 442.7 Q
+(main\(\))148 467.1 Q({)148 479.3 Q
+(char *pghost, *pgport, *pgoptions, *pgtty;)160 491.5 Q(char* dbName;)
+160 503.7 Q(int nFields;)160 515.9 Q(int i,j;)160 528.1 Q(PGconn* conn;)
+160 552.5 Q(PGresult* res;)160 564.7 Q(PGnotify* notify;)160 576.9 Q
+(/* begin, by setting the parameters for a backend connection)160 601.3
+Q(if the parameters are null, then the system will try to use)178 613.5
+Q(reasonable defaults by looking up environment variables)178 625.7 Q
+(or, failing that, using hardwired constants */)178 637.9 Q
+(pghost = NULL;)160 650.1 Q(/* host name of the backend server */)12 E
+(pgport = NULL;)160 662.3 Q(/* port of the backend server */)12 E
+(pgoptions = NULL; /* special options to start up the backend server */)
+160 674.5 Q(pgtty = NULL;)160 686.7 Q
+(/* debugging tty for the backend server */)30 E(dbName = getenv\("USER\
+"\); /* change this to the name of your test database*/)160 698.9 Q
+(/* make a connection to the database */)160 723.3 Q/F2 11/Times-Bold@0
+SF(57)282.5 756 Q EP
+%%Page: 58 58
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF
+(conn = PQsetdb\(pghost, pgport, pgoptions, pgtty, dbName\);)160 96.2 Q
+(/* check to see that the backend connection was successfully made */)
+160 120.6 Q(if \(PQstatus\(conn\) == CONNECTION_BAD\) {)160 132.8 Q
+(fprintf\(stderr,"Connection to database '%s' failed.0, dbName\);)172
+145 Q(fprintf\(stderr,"%s",PQerrorMessage\(conn\)\);)172 157.2 Q
+(exit_nicely\(conn\);)172 169.4 Q(})160 181.6 Q
+(res = PQexec\(conn, "LISTEN TBL2"\);)160 206 Q
+(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 218.2 Q
+(fprintf\(stderr,"LISTEN command failed0\);)172 230.4 Q(PQclear\(res\);)
+172 242.6 Q(exit_nicely\(conn\);)172 254.8 Q(})160 267 Q
+(/* should PQclear PGresult whenever it is no longer needed to avoid)160
+279.2 Q(memory leaks */)178 291.4 Q(PQclear\(res\);)160 303.6 Q
+(while \(1\) {)160 328 Q
+(/* async notification only come back as a result of a query*/)184 340.2
+Q(/* we can send empty queries */)184 352.4 Q
+(res = PQexec\(conn, " "\);)184 364.6 Q 30(/* printf\("res->status)148
+376.8 R 6(=%)6 G(s0, pgresStatus[PQresultStatus\(res\)]\); */)-6 E
+(/* check for asynchronous returns */)184 389 Q
+(notify = PQnotifies\(conn\);)184 401.2 Q(if \(notify\) {)184 413.4 Q
+(fprintf\(stderr,)196 425.6 Q
+("ASYNC NOTIFY of '%s' from backend pid '%d' received0,)232 437.8 Q
+(notify->relname, notify->be_pid\);)232 450 Q(free\(notify\);)196 462.2
+Q(break;)196 474.4 Q(})184 486.6 Q(PQclear\(res\);)184 498.8 Q(})160 511
+Q(/* close the connection to the database and cleanup */)160 535.4 Q
+(PQfinish\(conn\);)160 547.6 Q(})148 572 Q/F1 11/Times-Bold@0 SF(58)
+282.5 756 Q EP
+%%Page: 59 59
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(12.10.3. Sample)72 97.2 R(Pr)3 E(ogram 3)-.216
+E/F1 10/Courier@0 SF(/*)148 113.3 Q 6(*t)154 125.5 S(estlibpq3.c)-6 E 24
+(*T)154 137.7 S(est the C version of)-24 E/F2 9/Courier@0 SF(LIBPQ)6 E
+F1 6(,t)C(he)-6 E F2(POSTGRES)6 E F1(frontend library.)6 E 18(*t)154
+149.9 S(ests the binary cursor interface)-18 E(*)154 162.1 Q(*)154 174.3
+Q(*)154 186.5 Q(populate a database by doing the following:)154 198.7 Q
+(CREATE TABLE test1 \(i int4, d float4, p polygon\);)148 223.1 Q(INSERT\
+ INTO test1 values \(1, 3.567, '\(3.0, 4.0, 1.0, 2.0\)'::polygon\);)148
+247.5 Q(INSERT INTO test1 values \(2, 89.05, '\(4.0, 3.0, 2.0, 1.0\)'::\
+polygon\);)148 271.9 Q(the expected output is:)154 296.3 Q(tuple 0: got)
+148 320.7 Q 6(i=\()154 332.9 S 6(4b)-6 G(ytes\) 1,)-6 E 6(d=\()154 345.1
+S 6(4b)-6 G(ytes\) 3.567000,)-6 E 6(p=\()154 357.3 S 6(4b)-6 G
+(ytes\) 2 points)-6 E
+(boundbox = \(hi=3.000000/4.000000, lo = 1.000000,2.000000\))54 E
+(tuple 1: got)148 369.5 Q 6(i=\()154 381.7 S 6(4b)-6 G(ytes\) 2,)-6 E 6
+(d=\()154 393.9 S 6(4b)-6 G(ytes\) 89.050003,)-6 E 6(p=\()154 406.1 S 6
+(4b)-6 G(ytes\) 2 points)-6 E
+(boundbox = \(hi=4.000000/3.000000, lo = 2.000000,1.000000\))54 E(*)154
+430.5 Q(*/)154 442.7 Q(#include <stdio.h>)148 454.9 Q
+(#include "libpq-fe.h")148 467.1 Q
+(#include "utils/geo-decls.h" /* for the POLYGON type */)148 479.3 Q
+(void exit_nicely\(PGconn* conn\))148 503.7 Q({)148 515.9 Q
+(PQfinish\(conn\);)160 528.1 Q(exit\(1\);)160 540.3 Q(})148 552.5 Q
+(main\(\))148 576.9 Q({)148 589.1 Q
+(char *pghost, *pgport, *pgoptions, *pgtty;)160 601.3 Q(char* dbName;)
+160 613.5 Q(int nFields;)160 625.7 Q(int i,j;)160 637.9 Q
+(int i_fnum, d_fnum, p_fnum;)160 650.1 Q(PGconn* conn;)160 674.5 Q
+(PGresult* res;)160 686.7 Q
+(/* begin, by setting the parameters for a backend connection)160 711.1
+Q(if the parameters are null, then the system will try to use)178 723.3
+Q/F3 11/Times-Bold@0 SF(59)282.5 756 Q EP
+%%Page: 60 60
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF
+(reasonable defaults by looking up environment variables)178 96.2 Q
+(or, failing that, using hardwired constants */)178 108.4 Q
+(pghost = NULL;)160 120.6 Q(/* host name of the backend server */)12 E
+(pgport = NULL;)160 132.8 Q(/* port of the backend server */)12 E
+(pgoptions = NULL; /* special options to start up the backend server */)
+160 145 Q(pgtty = NULL;)160 157.2 Q
+(/* debugging tty for the backend server */)30 E
+(dbName = getenv\("USER"\);)160 181.6 Q
+(/* change this to the name of your test database*/)12 E
+(/* make a connection to the database */)160 206 Q
+(conn = PQsetdb\(pghost, pgport, pgoptions, pgtty, dbName\);)160 218.2 Q
+(/* check to see that the backend connection was successfully made */)
+160 242.6 Q(if \(PQstatus\(conn\) == CONNECTION_BAD\) {)160 254.8 Q
+(fprintf\(stderr,"Connection to database '%s' failed.0, dbName\);)172
+267 Q(fprintf\(stderr,"%s",PQerrorMessage\(conn\)\);)172 279.2 Q
+(exit_nicely\(conn\);)172 291.4 Q(})160 303.6 Q
+(/* start a transaction block */)160 328 Q
+(res = PQexec\(conn,"BEGIN"\);)160 340.2 Q
+(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 352.4 Q
+(fprintf\(stderr,"BEGIN command failed0\);)172 364.6 Q(PQclear\(res\);)
+172 376.8 Q(exit_nicely\(conn\);)172 389 Q(})160 401.2 Q
+(/* should PQclear PGresult whenever it is no longer needed to avoid)160
+413.4 Q(memory leaks */)178 425.6 Q(PQclear\(res\);)160 437.8 Q(/* fetc\
+h instances from the pg_database, the system catalog of databases*/)160
+462.2 Q(res = PQexec\(conn,"DECLARE mycursor BINARY CURSOR FOR select *\
+ from test1"\);)160 474.4 Q
+(if \(PQresultStatus\(res\) != PGRES_COMMAND_OK\) {)160 486.6 Q
+(fprintf\(stderr,"DECLARE CURSOR command failed0\);)172 498.8 Q
+(PQclear\(res\);)172 511 Q(exit_nicely\(conn\);)172 523.2 Q(})160 535.4
+Q(PQclear\(res\);)160 547.6 Q
+(res = PQexec\(conn,"FETCH ALL in mycursor"\);)160 572 Q
+(if \(PQresultStatus\(res\) != PGRES_TUPLES_OK\) {)160 584.2 Q
+(fprintf\(stderr,"FETCH ALL command didn't return tuples properly0\);)
+172 596.4 Q(PQclear\(res\);)172 608.6 Q(exit_nicely\(conn\);)172 620.8 Q
+(})160 633 Q(i_fnum = PQfnumber\(res,"i"\);)160 657.4 Q
+(d_fnum = PQfnumber\(res,"d"\);)160 669.6 Q
+(p_fnum = PQfnumber\(res,"p"\);)160 681.8 Q(for \(i=0;i<3;i++\) {)160
+706.2 Q(printf\("type[%d] = %d, size[%d] = %d0,)184 718.4 Q/F1 11
+/Times-Bold@0 SF(60)282.5 756 Q EP
+%%Page: 61 61
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(i, PQftype\(res,i\),)214 96.2 Q
+(i, PQfsize\(res,i\)\);)214 108.4 Q(})160 120.6 Q
+(for \(i=0; i < PQntuples\(res\); i++\) {)160 132.8 Q(int *ival;)172 145
+Q(float *dval;)172 157.2 Q(int plen;)172 169.4 Q(POLYGON* pval;)172
+181.6 Q(/* we hard-wire this to the 3 fields we know about */)172 193.8
+Q(ival =)172 206 Q(\(int*\)PQgetvalue\(res,i,i_fnum\);)12 E(dval =)172
+218.2 Q(\(float*\)PQgetvalue\(res,i,d_fnum\);)12 E
+(plen = PQgetlength\(res,i,p_fnum\);)172 230.4 Q(/* plen doesn't includ\
+e the length field so need to increment by VARHDSZ*/)172 254.8 Q
+(pval = \(POLYGON*\) malloc\(plen + VARHDRSZ\);)172 267 Q
+(pval->size = plen;)172 279.2 Q
+(memmove\(\(char*\)&pval->npts, PQgetvalue\(res,i,p_fnum\), plen\);)172
+291.4 Q(printf\("tuple %d: got0, i\);)172 303.6 Q
+(printf\(" i = \(%d bytes\) %d,0,)172 315.8 Q
+(PQgetlength\(res,i,i_fnum\), *ival\);)202 328 Q
+(printf\(" d = \(%d bytes\) %f,0,)172 340.2 Q
+(PQgetlength\(res,i,d_fnum\), *dval\);)202 352.4 Q(printf\(" p = \(%d b\
+ytes\) %d points boundbox = \(hi=%f/%f, lo = %f,%f\)0,)172 364.6 Q
+(PQgetlength\(res,i,d_fnum\),)202 376.8 Q(pval->npts,)202 389 Q
+(pval->boundbox.xh,)202 401.2 Q(pval->boundbox.yh,)202 413.4 Q
+(pval->boundbox.xl,)202 425.6 Q(pval->boundbox.yl\);)202 437.8 Q(})160
+450 Q(PQclear\(res\);)160 474.4 Q(/* close the portal */)160 498.8 Q
+(res = PQexec\(conn, "CLOSE mycursor"\);)160 511 Q(PQclear\(res\);)160
+523.2 Q(/* end the transaction */)160 547.6 Q
+(res = PQexec\(conn, "END"\);)160 559.8 Q(PQclear\(res\);)160 572 Q
+(/* close the connection to the database and cleanup */)160 596.4 Q
+(PQfinish\(conn\);)160 608.6 Q(})148 633 Q/F1 11/Times-Bold@0 SF(61)
+282.5 756 Q EP
+%%Page: 62 62
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(13. LARGE)72 165.4 R(OBJECTS)4.75 E
+77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL
+91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL
+108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6
+DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130
+178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6
+146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5
+178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185
+178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL
+201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6
+DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5
+178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6
+240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6
+256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5
+178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295
+178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL
+311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6
+DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5
+178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6
+350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6
+366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5
+178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405
+178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL
+421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6
+DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5
+178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6
+460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6
+476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5
+178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF(In)
+108 208.9 Q/F2 10/Times-Roman@0 SF(POSTGRES)4.497 E F1 4.497(,d)C 1.746
+(ata v)-4.497 F 1.746(alues are stored in tuples and indi)-.275 F 1.746
+(vidual tuples cannot span data)-.275 F 1.017(pages. Since the size of \
+a data page is 8192 bytes, the upper limit on the size of a data)108
+222.1 R -.275(va)108 235.3 S 1.306(lue is relati).275 F -.165(ve)-.275 G
+1.306(ly lo).165 F 2.736 -.715(w. T)-.275 H 4.055(os)-.165 G 1.305
+(upport the storage of lar)-4.055 F 1.305(ger atomic v)-.198 F(alues,)
+-.275 E F2(POSTGRES)4.055 E F1(pro-)4.055 E .029(vides a lar)108 248.5 R
+.029(ge object interf)-.198 F 2.779(ace. This)-.11 F(interf)2.78 E .03
+(ace pro)-.11 F .03(vides \214le-oriented access to user data that)-.165
+F(has been declared to be a lar)108 261.7 Q(ge type.)-.198 E 2.267(This\
+ section describes the implementation and the programmatic and query la\
+nguage)108 278.8 R(interf)108 292 Q(aces to)-.11 E F2(POSTGRES)2.75 E F1
+(lar)2.75 E(ge object data.)-.198 E/F3 12/Times-Bold@0 SF 3
+(13.1. Historical)72 309.1 R(Note)3 E F1(Originally)108 326.2 Q(,)-.715
+E F2(POSTGRES)4.077 E F1 1.327
+(4.2 supports three standard implementations of lar)4.077 F 1.328
+(ge objects: as)-.198 F 1.471(\214les e)108 339.4 R 1.471(xternal to)
+-.165 F F2(POSTGRES)4.22 E F1 4.22(,a)C(s)-4.22 E F2(UNIX)4.22 E F1 1.47
+(\214les managed by)4.22 F F2(POSTGRES)4.22 E F1 4.22(,a)C 1.47
+(nd as data stored)-4.22 F 2.431(within the)108 352.6 R F2(POSTGRES)
+5.181 E F1 2.432
+(database. It causes considerable confusion among users. As a)5.181 F
+1.719(result, we only support lar)108 365.8 R 1.719
+(ge objects as data stored within the)-.198 F F2(POSTGRES)4.469 E F1
+1.719(database in)4.469 F F2(POSTGRES)108 379 Q F1 1.127(95. Ev)B 1.127
+(en though is is slo)-.165 F 1.128(wer to access, it pro)-.275 F 1.128
+(vides stricter data inte)-.165 F 1.128(grity and)-.165 F 1.272
+(time tra)108 392.2 R -.165(ve)-.22 G 1.272(l. F).165 F 1.272
+(or historical reasons, the)-.165 F 4.022(ya)-.165 G 1.272(re called In)
+-4.022 F -.165(ve)-.44 G 1.272(rsion lar).165 F 1.272(ge objects. \(W)
+-.198 F 4.021(ew)-.88 G 1.271(ill use)-4.021 F(In)108 405.4 Q -.165(ve)
+-.44 G(rsion and lar).165 E
+(ge objects interchangeably to mean the same thing in this section.\))
+-.198 E F3 3(13.2. In)72 431.6 R -.12(ve)-.48 G(rsion Lar).12 E
+(ge Objects)-.12 E F1 2.125(The In)108 448.7 R -.165(ve)-.44 G 2.125
+(rsion lar).165 F 2.125(ge object implementation breaks lar)-.198 F
+2.125(ge objects up into \231chunks\232 and)-.198 F 1.03
+(stores the chunks in tuples in the database.)108 461.9 R 3.78(AB)6.53 G
+1.03(-tree inde)-3.78 F 3.78(xg)-.165 G 1.03(uarantees f)-3.78 F 1.03
+(ast searches for)-.11 F
+(the correct chunk number when doing random access reads and writes.)108
+475.1 Q F3 3(13.3. Lar)72 501.3 R(ge Object Interfaces)-.12 E F1 .643
+(The f)108 518.4 R(acilities)-.11 E F2(POSTGRES)3.393 E F1(pro)3.393 E
+.643(vides to access lar)-.165 F .643(ge objects, both in the back)-.198
+F .644(end as part of)-.11 F(user)108 531.6 Q .947(-de\214ned functions\
+ or the front end as part of an application using the)-.22 F(interf)
+6.446 E .946(ace, are)-.11 F .561(described belo)108 544.8 R 1.991 -.715
+(w. \()-.275 H -.165(Fo).715 G 3.311(ru).165 G .561(sers f)-3.311 F .561
+(amiliar with)-.11 F F2(POSTGRES)3.311 E F1(4.2,)3.311 E F2(POSTGRES)
+3.311 E F1 .561(95 has a ne)B 3.312(ws)-.275 G .562(et of)-3.312 F .27
+(functions pro)108 558 R .27(viding a more coherent interf)-.165 F .27
+(ace. The interf)-.11 F .269(ace is the same for dynamically-)-.11 F
+(loaded C functions as well as for .)108 571.2 Q(The)108 588.3 Q F2
+(POSTGRES)4.358 E F1(lar)4.358 E 1.608(ge object interf)-.198 F 1.609
+(ace is modeled after the)-.11 F F2(UNIX)4.359 E F1 1.609
+(\214le system interf)4.359 F(ace,)-.11 E .45(with analogues of)108
+601.5 R/F4 11/Times-Italic@0 SF(open)3.199 E F1(\(2\),)A F4 -.407(re)
+3.199 G(ad).407 E F1(\(2\),)A F4(write)3.199 E F1(\(2\),)A F4(lseek)
+3.199 E F1 .449(\(2\), etc.)B .449(User functions call these rou-)5.949
+F 1.739(tines to retrie)108 614.7 R 2.069 -.165(ve o)-.275 H 1.739
+(nly the data of interest from a lar).165 F 1.74(ge object.)-.198 F
+-.165(Fo)7.24 G 4.49(re).165 G 1.74(xample, if a lar)-4.655 F(ge)-.198 E
+.074(object type called)108 627.9 R F4(mugshot)2.824 E F1 -.165(ex)2.824
+G .074(isted that stored photographs of f).165 F .073
+(aces, then a function called)-.11 F F4(bear)108 641.1 Q(d)-.407 E F1
+.148(could be declared on)2.898 F F4(mugshot)2.898 E F1(data.)2.898 E F4
+(Bear)5.648 E(d)-.407 E F1 .149(could look at the lo)2.898 F .149
+(wer third of a photo-)-.275 F .793
+(graph, and determine the color of the beard that appeared there, if an)
+108 654.3 R 4.972 -.715(y. T)-.165 H .792(he entire lar).715 F(ge)-.198
+E(object v)108 667.5 Q(alue need not be b)-.275 E(uf)-.22 E(fered, or e)
+-.275 E -.165(ve)-.275 G 2.75(ne).165 G(xamined, by the)-2.915 E F4
+(bear)2.75 E(d)-.407 E F1(function.)2.75 E(Lar)108 684.6 Q 1.165(ge obj\
+ects may be accessed from dynamically-loaded C functions or database cl\
+ient)-.198 F .831(programs that link the)108 697.8 R(library)6.331 E(.)
+-.715 E F2(POSTGRES)6.331 E F1(pro)3.581 E .83
+(vides a set of routines that support open-)-.165 F
+(ing, reading, writing, closing, and seeking on lar)108 711 Q
+(ge objects.)-.198 E/F5 11/Times-Bold@0 SF(62)282.5 756 Q EP
+%%Page: 63 63
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(13.3.1. Cr)72 97.2 R(eating a Lar)-.216 E
+(ge Object)-.12 E/F1 11/Times-Roman@0 SF(The routine)108 114.3 Q/F2 10
+/Courier@0 SF(Oid lo_creat\(PGconn *conn, int mode\))148 139.5 Q F1 .042
+(creates a ne)108 165.7 R 2.792(wl)-.275 G(ar)-2.792 E .042
+(ge object. The)-.198 F/F3 11/Times-Italic@0 SF(mode)2.792 E F1 .043
+(is a bitmask describing se)2.792 F -.165(ve)-.275 G .043(ral dif).165 F
+.043(ferent attrib)-.275 F .043(utes of)-.22 F(the ne)108 178.9 Q 2.75
+(wo)-.275 G 2.75(bject. The)-2.75 F
+(symbolic constants listed here are de\214ned in)2.75 E F2
+(/usr/local/postgres95/src/backend/libpq/libpq-fs.h)148 204.1 Q F1 .084
+(The access type \(read, write, or both\) is controlled by)108 230.3 R
+/F4 10/Times-Roman@0 SF(OR)2.834 E F1 .084(ing together the bits)2.834 F
+F4(INV_READ)2.834 E F1(and)108 243.5 Q F4(INV_WRITE)2.845 E F1 5.595(.I)
+C 2.845(ft)-5.595 G .095(he lar)-2.845 F .095(ge object should be archi)
+-.198 F -.165(ve)-.275 G 2.845(d\212t).165 G .095
+(hat is, if historical v)-2.845 F .096(ersions of)-.165 F .934
+(it should be mo)108 256.7 R -.165(ve)-.165 G 3.684(dp).165 G .933
+(eriodically to a special archi)-3.684 F 1.263 -.165(ve r)-.275 H .933
+(elation \212 then the).165 F F4(INV_ARCHIVE)3.683 E F1 .369
+(bit should be set.)108 269.9 R .369(The lo)5.869 F .37
+(w-order sixteen bits of)-.275 F F3(mask)3.12 E F1 .37
+(are the storage manager number on)3.12 F 1.894(which the lar)108 283.1
+R 1.894(ge object should reside.)-.198 F -.165(Fo)7.394 G 4.644(rs).165
+G 1.894(ites other than Berk)-4.644 F(ele)-.11 E 3.323 -.715(y, t)-.165
+H 1.893(hese bits should).715 F(al)108 296.3 Q -.11(wa)-.11 G
+(ys be zero.).11 E(The commands belo)108 313.4 Q 2.75(wc)-.275 G
+(reate an \(In)-2.75 E -.165(ve)-.44 G(rsion\) lar).165 E(ge object:)
+-.198 E F2(inv_oid = lo_creat\(INV_READ|INV_WRITE|INV_ARCHIVE\);)148
+338.6 Q F0 3(13.3.2. Importing)72 377.8 R 3(aL)3 G(ar)-3 E(ge Object)
+-.12 E F1 1.76 -.88(To i)9 H(mport a UNIX \214le as a lar).88 E
+(ge object, call)-.198 E F2(Oid)148 403 Q
+(lo_import\(PGconn *conn, text *filename\))148 415.2 Q F1(The)108 441.4
+Q F3(\214lename)3.168 E F1(ar)3.168 E .419(gument speci\214es the UNIX \
+pathname of the \214le to be imported as a lar)-.198 F(ge)-.198 E
+(object.)108 454.6 Q F0 3(13.3.3. Exporting)72 480.8 R 3(aL)3 G(ar)-3 E
+(ge Object)-.12 E F1 1.76 -.88(To e)9 H(xport a lar).715 E
+(ge object into UNIX \214le, call)-.198 E F2(int)148 506 Q
+(lo_export\(PGconn *conn, Oid lobjId, text *filename\))148 518.2 Q F1
+(The)108 544.4 Q F3(lobjId)3.071 E F1(ar)3.071 E .321
+(gument speci\214es the Oid of the lar)-.198 F .32(ge object to e)-.198
+F .32(xport and the)-.165 F F3(\214lename)3.07 E F1(ar)3.07 E(gu-)-.198
+E(ment speci\214es the UNIX pathname of the \214le.)108 557.6 Q F0 3
+(13.3.4. Opening)72 583.8 R(an Existing Lar)3 E(ge Object)-.12 E F1 1.76
+-.88(To o)108 600.9 T(pen an e).88 E(xisting lar)-.165 E
+(ge object, call)-.198 E F2(int)148 626.1 Q
+(lo_open\(PGconn *conn, Oid lobjId, int mode, ...\))148 638.3 Q F1(The)
+108 664.5 Q F3(lobjId)3.207 E F1(ar)3.207 E .457
+(gument speci\214es the Oid of the lar)-.198 F .458(ge object to open.)
+-.198 F .458(The mode bits control)5.958 F
+(whether the object is opened for reading)108 677.7 Q F4(INV_READ)2.75 E
+F1(\), writing or both.)A 4.2(Al)108 694.8 S(ar)-4.2 E 1.45
+(ge object cannot be opened before it is created.)-.198 F/F5 11
+/Courier@0 SF(lo_open)6.949 E F1 1.449(returns a lar)4.199 F 1.449
+(ge object)-.198 F 5.198(descriptor for later use in)108 708 R F5
+(lo_read)7.948 E F1(,)A F5(lo_write)7.948 E F1(,)A F5(lo_lseek)7.948 E
+F1(,)A F5(lo_tell)7.948 E F1 7.949(,a)C(nd)-7.949 E F5(lo_close)108
+721.2 Q F1(.)A/F6 11/Times-Bold@0 SF(63)282.5 756 Q EP
+%%Page: 64 64
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(13.3.5. Writing)72 97.2 R(Data to a Lar)3 E
+(ge Object)-.12 E/F1 11/Times-Roman@0 SF(The routine)108 114.3 Q/F2 10
+/Courier@0 SF(int)148 139.5 Q
+(lo_write\(PGconn *conn, int fd, char *buf, int len\))148 151.7 Q F1
+(writes)108 177.9 Q/F3 11/Times-Italic@0 SF(len)3.046 E F1 .296
+(bytes from)3.046 F F3 -.22(bu)3.046 G(f).22 E F1 .296(to lar)3.046 F
+.296(ge object)-.198 F F3(fd)3.046 E F1 5.796(.T)C(he)-5.796 E F3(fd)
+3.046 E F1(ar)3.045 E .295(gument must ha)-.198 F .625 -.165(ve b)-.22 H
+.295(een returned by).165 F 2.75(ap)108 191.1 S(re)-2.75 E(vious)-.275 E
+F3(lo_open)2.75 E F1(.)A .059
+(The number of bytes actually written is returned.)108 208.2 R .059
+(In the e)5.559 F -.165(ve)-.275 G .059(nt of an error).165 F 2.809(,t)
+-.44 G .06(he return v)-2.809 F(alue)-.275 E(is ne)108 221.4 Q -.055(ga)
+-.165 G(ti).055 E -.165(ve)-.275 G(.).165 E F0 3(13.3.6. Seeking)72
+247.6 R(on a Lar)3 E(ge Object)-.12 E F1 1.76 -.88(To c)108 264.7 T
+(hange the current read or write location on a lar).88 E
+(ge object, call)-.198 E F2(int)148 289.9 Q
+(lo_lseek\(PGconn *conn, int fd, int offset, int whence\))148 302.1 Q F1
+.386(This routine mo)108 328.3 R -.165(ve)-.165 G 3.136(st).165 G .386
+(he current location pointer for the lar)-3.136 F .386
+(ge object described by)-.198 F F3(fd)3.135 E F1 .385(to the)3.135 F(ne)
+108 341.5 Q 6.512(wl)-.275 G 3.762(ocation speci\214ed by)-6.512 F F3
+(of)6.512 E(fset)-.198 E F1 9.262(.T)C 3.762(he v)-9.262 F 3.762(alid v)
+-.275 F 3.762(alues for .i whence are)-.275 F/F4 11/Courier@0 SF
+(SEEK_SET)6.512 E(SEEK_CUR)108 354.7 Q F1(and)2.75 E F4(SEEK_END.)2.75 E
+F0 3(13.3.7. Closing)72 380.9 R 3(aL)3 G(ar)-3 E(ge Object Descriptor)
+-.12 E F1 2.75(Al)108 398 S(ar)-2.75 E
+(ge object may be closed by calling)-.198 E F2(int)148 423.2 Q
+(lo_close\(PGconn *conn, int fd\))148 435.4 Q F1(where)108 461.6 Q F3
+(fd)3.9 E F1 1.15(is a lar)3.9 F 1.15(ge object descriptor returned by)
+-.198 F F3(lo_open)3.9 E F1 6.65(.O)C 3.9(ns)-6.65 G(uccess,)-3.9 E F3
+(lo_close)3.9 E F1(returns)3.899 E 2.75(zero. On)108 474.8 R(error)2.75
+E 2.75(,t)-.44 G(he return v)-2.75 E(alue is ne)-.275 E -.055(ga)-.165 G
+(ti).055 E -.165(ve)-.275 G(.).165 E F0 3(13.4. Built)72 491.9 R(in r)3
+E(egister)-.216 E(ed functions)-.216 E F1 .182(There are tw)108 509 R
+2.932(ob)-.11 G .182(uilt-in re)-3.152 F .182(gistered functions,)-.165
+F F3(lo_import)2.932 E F1(and)2.932 E F3(lo_e)2.932 E(xport)-.22 E F1
+.182(which are con)2.932 F -.165(ve)-.44 G(nient).165 E
+(for use in SQL queries.)108 522.2 Q(Here is an e)108 539.3 Q
+(xample of there use)-.165 E F2(CREATE TABLE image \()148 564.5 Q 66
+(name text,)196 576.7 R 54(raster oid)196 588.9 R(\);)148 601.1 Q
+(INSERT INTO image \(name, raster\))148 625.5 Q
+(VALUES \('beautiful image', lo_import\('/etc/motd'\)\);)166 637.7 Q
+(SELECT lo_export\(image.raster, "/tmp/motd"\) from image)148 662.1 Q
+(WHERE name = 'beautiful image';)166 674.3 Q/F5 11/Times-Bold@0 SF(64)
+282.5 756 Q EP
+%%Page: 65 65
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 4.583(13.5. Accessing)72 97.2 R(Lar)4.583 E 1.583
+(ge Objects fr)-.12 F 1.583(om LIBPQ)-.216 F/F1 11/Times-Roman@0 SF
+(Belo)10.582 E 4.332(wi)-.275 G 4.332(sas)-4.332 G 1.582
+(ample program which sho)-4.332 F(ws)-.275 E(ho)108 110.4 Q 2.774(wt)
+-.275 G .024(he lar)-2.774 F .024(ge object interf)-.198 F .024(ace in)
+-.11 F/F2 10/Times-Roman@0 SF(LIBPQ)2.775 E F1 .025(can be used.)2.775 F
+-.165(Pa)5.525 G .025(rts of the program are commented).165 F(out b)108
+123.6 Q(ut are left in the source for the readers bene\214t.)-.22 E
+(This program can be found in)5.5 E/F3 10/Courier@0 SF
+(../src/test/examples)148 148.8 Q F1 1.29
+(Frontend applications which use the lar)108 178.9 R 1.289
+(ge object interf)-.198 F 1.289(ace in)-.11 F F2(LIBPQ)4.039 E F1 1.289
+(should include the)4.039 F(header \214le)108 192.1 Q/F4 11/Courier@0 SF
+(libpq/libpq-fs.h)2.75 E F1(and link with the)2.75 E F4(libpq)2.75 E F1
+(library)2.75 E(.)-.715 E/F5 11/Times-Bold@0 SF(65)282.5 756 Q EP
+%%Page: 66 66
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(13.6. Sample)72 97.2 R(Pr)3 E(ogram)-.216 E/F1
+10/Courier@0 SF(/*-----------------------------------------------------\
+--------------------)148 122.4 Q(*)154 134.6 Q 6(*t)154 146.8 S
+(estlo.c--)-6 E 24(*t)154 159 S(est using large objects with libpq)-24 E
+(*)154 171.2 Q 6(*C)154 183.4 S
+(opyright \(c\) 1994, Regents of the University of California)-6 E(*)154
+195.6 Q(*)154 207.8 Q 6(*I)154 220 S(DENTIFICATION)-6 E 24(*$)154 232.2
+S(Header: /usr/local/devel/pglite/cvs/src/doc/manual.me,v 1.17 1996/02/\
+24 01:19:32 jolly Exp $)-24 E(*)154 244.4 Q(*--------------------------\
+-----------------------------------------------)154 256.6 Q(*/)154 268.8
+Q(#include <stdio.h>)148 281 Q(#include "libpq-fe.h")148 293.2 Q
+(#include "libpq/libpq-fs.h")148 305.4 Q(#define BUFSIZE)148 329.8 Q
+(1024)54 E(/*)148 354.2 Q 6(*i)154 366.4 S(mportFile -)-6 E 24(*i)154
+378.6 S
+(mport file "in_filename" into database as large object "lobjOid")-24 E
+(*)154 390.8 Q(*/)154 403 Q
+(Oid importFile\(PGconn *conn, char *filename\))148 415.2 Q({)148 427.4
+Q(Oid lobjId;)172 439.6 Q(int lobj_fd;)172 451.8 Q(char buf[BUFSIZE];)
+172 464 Q(int nbytes, tmp;)172 476.2 Q(int fd;)172 488.4 Q(/*)172 512.8
+Q 6(*o)178 525 S(pen the file to be read in)-6 E(*/)178 537.2 Q
+(fd = open\(filename, O_RDONLY, 0666\);)172 549.4 Q(if \(fd < 0\))172
+561.6 Q 18({/)12 G 6(*e)-18 G(rror */)-6 E
+(fprintf\(stderr, "can't open unix file)184 573.8 Q(})172 586 Q(/*)172
+610.4 Q 6(*c)178 622.6 S(reate the large object)-6 E(*/)178 634.8 Q
+(lobjId = lo_creat\(conn, INV_READ|INV_WRITE\);)172 647 Q
+(if \(lobjId == 0\) {)172 659.2 Q
+(fprintf\(stderr, "can't create large object"\);)184 671.4 Q(})172 683.6
+Q(lobj_fd = lo_open\(conn, lobjId, INV_WRITE\);)172 708 Q(/*)172 720.2 Q
+/F2 11/Times-Bold@0 SF(66)282.5 756 Q EP
+%%Page: 67 67
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF 6(*r)178 96.2 S
+(ead in from the Unix file and write to the inversion file)-6 E(*/)178
+108.4 Q(while \(\(nbytes = read\(fd, buf, BUFSIZE\)\) > 0\) {)172 120.6
+Q(tmp = lo_write\(conn, lobj_fd, buf, nbytes\);)184 132.8 Q
+(if \(tmp < nbytes\) {)184 145 Q(fprintf\(stderr, "error while reading)
+208 157.2 Q(})184 169.4 Q(})172 181.6 Q(\(void\) close\(fd\);)172 206 Q
+(\(void\) lo_close\(conn, lobj_fd\);)172 218.2 Q(return lobjId;)172
+242.6 Q(})148 254.8 Q
+(void pickout\(PGconn *conn, Oid lobjId, int start, int len\))148 279.2
+Q({)148 291.4 Q(int lobj_fd;)172 303.6 Q(char* buf;)172 315.8 Q
+(int nbytes;)172 328 Q(int nread;)172 340.2 Q
+(lobj_fd = lo_open\(conn, lobjId, INV_READ\);)172 364.6 Q
+(if \(lobj_fd < 0\) {)172 376.8 Q
+(fprintf\(stderr,"can't open large object %d",)184 389 Q(lobjId\);)220
+401.2 Q(})172 413.4 Q(lo_lseek\(conn, lobj_fd, start, SEEK_SET\);)172
+437.8 Q(buf = malloc\(len+1\);)172 450 Q(nread = 0;)172 474.4 Q
+(while \(len - nread > 0\) {)172 486.6 Q
+(nbytes = lo_read\(conn, lobj_fd, buf, len - nread\);)184 498.8 Q
+(buf[nbytes] = ' ';)184 511 Q(fprintf\(stderr,">>> %s", buf\);)184 523.2
+Q(nread += nbytes;)184 535.4 Q(})172 547.6 Q(fprintf\(stderr,"0\);)172
+559.8 Q(lo_close\(conn, lobj_fd\);)172 572 Q(})148 584.2 Q
+(void overwrite\(PGconn *conn, Oid lobjId, int start, int len\))148
+608.6 Q({)148 620.8 Q(int lobj_fd;)172 633 Q(char* buf;)172 645.2 Q
+(int nbytes;)172 657.4 Q(int nwritten;)172 669.6 Q(int i;)172 681.8 Q
+(lobj_fd = lo_open\(conn, lobjId, INV_READ\);)172 706.2 Q
+(if \(lobj_fd < 0\) {)172 718.4 Q/F1 11/Times-Bold@0 SF(67)282.5 756 Q
+EP
+%%Page: 68 68
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(fprintf\(stderr,"can't open large object %d",)184
+96.2 Q(lobjId\);)220 108.4 Q(})172 120.6 Q
+(lo_lseek\(conn, lobj_fd, start, SEEK_SET\);)172 145 Q
+(buf = malloc\(len+1\);)172 157.2 Q(for \(i=0;i<len;i++\))172 181.6 Q
+(buf[i] = 'X';)184 193.8 Q(buf[i] = ' ';)172 206 Q(nwritten = 0;)172
+230.4 Q(while \(len - nwritten > 0\) {)172 242.6 Q
+(nbytes = lo_write\(conn, lobj_fd, buf + nwritten, len - nwritten\);)184
+254.8 Q(nwritten += nbytes;)184 267 Q(})172 279.2 Q
+(fprintf\(stderr,"0\);)172 291.4 Q(lo_close\(conn, lobj_fd\);)172 303.6
+Q(})148 315.8 Q(/*)148 352.4 Q 6(*e)154 364.6 S(xportFile -)-6 E 24(*e)
+154 376.8 S(xport large object "lobjOid" to file "out_filename")-24 E(*)
+154 389 Q(*/)154 401.2 Q
+(void exportFile\(PGconn *conn, Oid lobjId, char *filename\))148 413.4 Q
+({)148 425.6 Q(int lobj_fd;)172 437.8 Q(char buf[BUFSIZE];)172 450 Q
+(int nbytes, tmp;)172 462.2 Q(int fd;)172 474.4 Q(/*)172 498.8 Q 6(*c)
+178 511 S(reate an inversion "object")-6 E(*/)178 523.2 Q
+(lobj_fd = lo_open\(conn, lobjId, INV_READ\);)172 535.4 Q
+(if \(lobj_fd < 0\) {)172 547.6 Q
+(fprintf\(stderr,"can't open large object %d",)184 559.8 Q(lobjId\);)220
+572 Q(})172 584.2 Q(/*)172 608.6 Q 6(*o)178 620.8 S
+(pen the file to be written to)-6 E(*/)178 633 Q
+(fd = open\(filename, O_CREAT|O_WRONLY, 0666\);)172 645.2 Q
+(if \(fd < 0\))172 657.4 Q 18({/)12 G 6(*e)-18 G(rror */)-6 E
+(fprintf\(stderr, "can't open unix file)184 669.6 Q(filename\);)220
+681.8 Q(})172 694 Q(/*)172 718.4 Q/F1 11/Times-Bold@0 SF(68)282.5 756 Q
+EP
+%%Page: 69 69
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF 6(*r)178 96.2 S
+(ead in from the Unix file and write to the inversion file)-6 E(*/)178
+108.4 Q
+(while \(\(nbytes = lo_read\(conn, lobj_fd, buf, BUFSIZE\)\) > 0\) {)172
+120.6 Q(tmp = write\(fd, buf, nbytes\);)184 132.8 Q
+(if \(tmp < nbytes\) {)196 145 Q(fprintf\(stderr,"error while writing)
+208 157.2 Q(filename\);)244 169.4 Q(})184 181.6 Q(})172 193.8 Q
+(\(void\) lo_close\(conn, lobj_fd\);)172 218.2 Q(\(void\) close\(fd\);)
+172 230.4 Q(return;)172 254.8 Q(})148 267 Q(void)148 291.4 Q
+(exit_nicely\(PGconn* conn\))148 303.6 Q({)148 315.8 Q
+(PQfinish\(conn\);)160 328 Q(exit\(1\);)160 340.2 Q(})148 352.4 Q(int)
+148 376.8 Q(main\(int argc, char **argv\))148 389 Q({)148 401.2 Q
+(char *in_filename, *out_filename;)172 413.4 Q(char *database;)172 425.6
+Q(Oid lobjOid;)172 437.8 Q(PGconn *conn;)172 450 Q(PGresult *res;)172
+462.2 Q(if \(argc != 4\) {)172 486.6 Q
+(fprintf\(stderr, "Usage: %s database_name in_filename out_filename0,)
+184 498.8 Q(argv[0]\);)220 511 Q(exit\(1\);)184 523.2 Q(})172 535.4 Q
+(database = argv[1];)172 559.8 Q(in_filename = argv[2];)172 572 Q
+(out_filename = argv[3];)172 584.2 Q(/*)172 608.6 Q 6(*s)178 620.8 S
+(et up the connection)-6 E(*/)178 633 Q
+(conn = PQsetdb\(NULL, NULL, NULL, NULL, database\);)172 645.2 Q
+(/* check to see that the backend connection was successfully made */)
+172 669.6 Q(if \(PQstatus\(conn\) == CONNECTION_BAD\) {)172 681.8 Q
+(fprintf\(stderr,"Connection to database '%s' failed.0, database\);)184
+694 Q(fprintf\(stderr,"%s",PQerrorMessage\(conn\)\);)184 706.2 Q
+(exit_nicely\(conn\);)184 718.4 Q/F1 11/Times-Bold@0 SF(69)282.5 756 Q
+EP
+%%Page: 70 70
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(})172 96.2 Q(res = PQexec\(conn, "begin"\);)172
+120.6 Q(PQclear\(res\);)172 132.8 Q(printf\("importing file)172 145 Q 6
+(/* lobjOid)148 157.2 R 6(=i)6 G(mportFile\(conn, in_filename\); */)-6 E
+(lobjOid = lo_import\(conn, in_filename\);)172 169.4 Q(/*)148 181.6 Q
+(printf\("as large object %d.0, lobjOid\);)172 193.8 Q
+(printf\("picking out bytes 1000-2000 of the large object0\);)172 218.2
+Q(pickout\(conn, lobjOid, 1000, 1000\);)172 230.4 Q
+(printf\("overwriting bytes 1000-2000 of the large object with X's0\);)
+172 254.8 Q(overwrite\(conn, lobjOid, 1000, 1000\);)172 267 Q(*/)148
+279.2 Q(printf\("exporting large object to file)172 303.6 Q 18
+(/* exportFile\(conn,)148 315.8 R(lobjOid, out_filename\); */)6 E
+(lo_export\(conn, lobjOid,out_filename\);)172 328 Q
+(res = PQexec\(conn, "end"\);)172 352.4 Q(PQclear\(res\);)172 364.6 Q
+(PQfinish\(conn\);)172 376.8 Q(exit\(0\);)172 389 Q(})148 401.2 Q/F1 11
+/Times-Bold@0 SF(70)282.5 756 Q EP
+%%Page: 71 71
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(14. THE)72 165.4 R(POSTGRES R)4.75 E
+(ULE SYSTEM)-.57 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86
+178.6 80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5
+178.6 97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119
+178.6 113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL
+135.5 178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6
+DL 152 178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5
+178.6 DL 168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6
+174 178.6 DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6
+190.5 178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5
+178.6 207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229
+178.6 223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL
+245.5 178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6
+DL 262 178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5
+178.6 DL 278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6
+284 178.6 DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6
+300.5 178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5
+178.6 317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339
+178.6 333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL
+355.5 178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6
+DL 372 178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5
+178.6 DL 388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6
+394 178.6 DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6
+410.5 178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5
+178.6 427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449
+178.6 443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL
+465.5 178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6
+DL 482 178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5
+178.6 DL 498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11
+/Times-Roman@0 SF 3.372
+(Production rule systems are conceptually simple, b)108 208.9 R 3.372
+(ut there are man)-.22 F 6.122(ys)-.165 G 3.372(ubtle points)-6.122 F
+(in)108 222.1 Q -.22(vo)-.44 G(lv).22 E .603(ed in actually using them.)
+-.165 F(Consequently)6.103 E 3.353(,w)-.715 G 3.352(ew)-3.353 G .602
+(ill not attempt to e)-3.352 F .602(xplain the actual)-.165 F 2.737
+(syntax and operation of the)108 235.3 R/F2 10/Times-Roman@0 SF
+(POSTGRES)5.488 E F1 2.738(rule system here.)5.488 F 2.738
+(Instead, you should read)8.238 F([ST)108 248.5 Q 1.803(ON90b] to under\
+stand some of these points and the theoretical foundations of the)-.198
+F F2(POSTGRES)108 261.7 Q F1 2.477
+(rule system before trying to use rules.)5.227 F 2.478
+(The discussion in this section is)7.977 F .205(intended to pro)108
+274.9 R .205(vide an o)-.165 F -.165(ve)-.165 G(rvie).165 E 2.955(wo)
+-.275 G 2.954(ft)-2.955 G(he)-2.954 E F2(POSTGRES)2.954 E F1 .204
+(rule system and point the user at help-)2.954 F(ful references and e)
+108 288.1 Q(xamples.)-.165 E 1.641(The \231query re)108 305.2 R 1.642
+(write\232 rule system modi\214es queries to tak)-.275 F 4.392(er)-.11 G
+1.642(ules into consideration, and)-4.392 F .518
+(then passes the modi\214ed query to the query optimizer for e)108 318.4
+R -.165(xe)-.165 G 3.268(cution. It).165 F .517(is v)3.267 F .517
+(ery po)-.165 F(werful,)-.275 E .246(and can be used for man)108 331.6 R
+2.996(yt)-.165 G .246(hings such as query language procedures, vie)
+-2.996 F .246(ws, and v)-.275 F(ersions.)-.165 E(The po)108 344.8 Q
+(wer of this rule system is discussed in [ONG90] as well as [ST)-.275 E
+(ON90b].)-.198 E/F3 11/Times-Bold@0 SF(71)282.5 756 Q EP
+%%Page: 72 72
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(15. ADMINISTERING)72 165.4 R
+(POSTGRES)4.75 E 77.5 178.6 72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6
+80.5 178.6 DL 91.5 178.6 86 178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6
+97 178.6 DL 108 178.6 102.5 178.6 DL 113.5 178.6 108 178.6 DL 119 178.6
+113.5 178.6 DL 124.5 178.6 119 178.6 DL 130 178.6 124.5 178.6 DL 135.5
+178.6 130 178.6 DL 141 178.6 135.5 178.6 DL 146.5 178.6 141 178.6 DL 152
+178.6 146.5 178.6 DL 157.5 178.6 152 178.6 DL 163 178.6 157.5 178.6 DL
+168.5 178.6 163 178.6 DL 174 178.6 168.5 178.6 DL 179.5 178.6 174 178.6
+DL 185 178.6 179.5 178.6 DL 190.5 178.6 185 178.6 DL 196 178.6 190.5
+178.6 DL 201.5 178.6 196 178.6 DL 207 178.6 201.5 178.6 DL 212.5 178.6
+207 178.6 DL 218 178.6 212.5 178.6 DL 223.5 178.6 218 178.6 DL 229 178.6
+223.5 178.6 DL 234.5 178.6 229 178.6 DL 240 178.6 234.5 178.6 DL 245.5
+178.6 240 178.6 DL 251 178.6 245.5 178.6 DL 256.5 178.6 251 178.6 DL 262
+178.6 256.5 178.6 DL 267.5 178.6 262 178.6 DL 273 178.6 267.5 178.6 DL
+278.5 178.6 273 178.6 DL 284 178.6 278.5 178.6 DL 289.5 178.6 284 178.6
+DL 295 178.6 289.5 178.6 DL 300.5 178.6 295 178.6 DL 306 178.6 300.5
+178.6 DL 311.5 178.6 306 178.6 DL 317 178.6 311.5 178.6 DL 322.5 178.6
+317 178.6 DL 328 178.6 322.5 178.6 DL 333.5 178.6 328 178.6 DL 339 178.6
+333.5 178.6 DL 344.5 178.6 339 178.6 DL 350 178.6 344.5 178.6 DL 355.5
+178.6 350 178.6 DL 361 178.6 355.5 178.6 DL 366.5 178.6 361 178.6 DL 372
+178.6 366.5 178.6 DL 377.5 178.6 372 178.6 DL 383 178.6 377.5 178.6 DL
+388.5 178.6 383 178.6 DL 394 178.6 388.5 178.6 DL 399.5 178.6 394 178.6
+DL 405 178.6 399.5 178.6 DL 410.5 178.6 405 178.6 DL 416 178.6 410.5
+178.6 DL 421.5 178.6 416 178.6 DL 427 178.6 421.5 178.6 DL 432.5 178.6
+427 178.6 DL 438 178.6 432.5 178.6 DL 443.5 178.6 438 178.6 DL 449 178.6
+443.5 178.6 DL 454.5 178.6 449 178.6 DL 460 178.6 454.5 178.6 DL 465.5
+178.6 460 178.6 DL 471 178.6 465.5 178.6 DL 476.5 178.6 471 178.6 DL 482
+178.6 476.5 178.6 DL 487.5 178.6 482 178.6 DL 493 178.6 487.5 178.6 DL
+498.5 178.6 493 178.6 DL 504 178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF
+1.395(In this section, we will discuss aspects of)108 208.9 R/F2 10
+/Times-Roman@0 SF(POSTGRES)4.145 E F1 1.394
+(that are of interest to those who)4.144 F(mak)108 222.1 Q 3.096(ee)-.11
+G(xtensi)-3.261 E .676 -.165(ve u)-.275 H .346(se of).165 F F2(POSTGRES)
+3.096 E F1 3.096(,o)C 3.096(rw)-3.096 G .346
+(ho are the site administrator for a group of)-3.096 F F2(POST)3.096 E
+(-)-.92 E(GRES)108 235.3 Q F1(users.)2.75 E/F3 12/Times-Bold@0 SF 3
+(15.1. Fr)72 261.5 R(equent T)-.216 E(asks)-1.104 E 77.5 274.7 72 274.7
+DL 80.5 274.7 75 274.7 DL 86 274.7 80.5 274.7 DL 91.5 274.7 86 274.7 DL
+97 274.7 91.5 274.7 DL 102.5 274.7 97 274.7 DL 108 274.7 102.5 274.7 DL
+113.5 274.7 108 274.7 DL 119 274.7 113.5 274.7 DL 124.5 274.7 119 274.7
+DL 130 274.7 124.5 274.7 DL 135.5 274.7 130 274.7 DL 141 274.7 135.5
+274.7 DL 146.5 274.7 141 274.7 DL 152 274.7 146.5 274.7 DL 157.5 274.7
+152 274.7 DL 163 274.7 157.5 274.7 DL 168.5 274.7 163 274.7 DL 174 274.7
+168.5 274.7 DL 179.5 274.7 174 274.7 DL 185 274.7 179.5 274.7 DL 190.5
+274.7 185 274.7 DL 196 274.7 190.5 274.7 DL 201.5 274.7 196 274.7 DL 207
+274.7 201.5 274.7 DL 212.5 274.7 207 274.7 DL 218 274.7 212.5 274.7 DL
+223.5 274.7 218 274.7 DL 229 274.7 223.5 274.7 DL 234.5 274.7 229 274.7
+DL 240 274.7 234.5 274.7 DL 245.5 274.7 240 274.7 DL 251 274.7 245.5
+274.7 DL 256.5 274.7 251 274.7 DL 262 274.7 256.5 274.7 DL 267.5 274.7
+262 274.7 DL 273 274.7 267.5 274.7 DL 278.5 274.7 273 274.7 DL 284 274.7
+278.5 274.7 DL 289.5 274.7 284 274.7 DL 295 274.7 289.5 274.7 DL 300.5
+274.7 295 274.7 DL 306 274.7 300.5 274.7 DL 311.5 274.7 306 274.7 DL 317
+274.7 311.5 274.7 DL 322.5 274.7 317 274.7 DL 328 274.7 322.5 274.7 DL
+333.5 274.7 328 274.7 DL 339 274.7 333.5 274.7 DL 344.5 274.7 339 274.7
+DL 350 274.7 344.5 274.7 DL 355.5 274.7 350 274.7 DL 361 274.7 355.5
+274.7 DL 366.5 274.7 361 274.7 DL 372 274.7 366.5 274.7 DL 377.5 274.7
+372 274.7 DL 383 274.7 377.5 274.7 DL 388.5 274.7 383 274.7 DL 394 274.7
+388.5 274.7 DL 399.5 274.7 394 274.7 DL 405 274.7 399.5 274.7 DL 410.5
+274.7 405 274.7 DL 416 274.7 410.5 274.7 DL 421.5 274.7 416 274.7 DL 427
+274.7 421.5 274.7 DL 432.5 274.7 427 274.7 DL 438 274.7 432.5 274.7 DL
+443.5 274.7 438 274.7 DL 449 274.7 443.5 274.7 DL 454.5 274.7 449 274.7
+DL 460 274.7 454.5 274.7 DL 465.5 274.7 460 274.7 DL 471 274.7 465.5
+274.7 DL 476.5 274.7 471 274.7 DL 482 274.7 476.5 274.7 DL 487.5 274.7
+482 274.7 DL 493 274.7 487.5 274.7 DL 498.5 274.7 493 274.7 DL 504 274.7
+498.5 274.7 DL F1 .405
+(Here we will brie\215y discuss some procedures that you should be f)108
+305 R .405(amiliar with in manag-)-.11 F(ing an)108 318.2 Q(y)-.165 E F2
+(POSTGRES)2.75 E F1(installation.)2.75 E F3 3(15.1.1. Starting)72 344.4
+R(the P)3 E(ostmaster)-.24 E F1 .539(If you did not install)108 361.5 R
+F2(POSTGRES)3.289 E F1 -.165(ex)3.289 G .538
+(actly as described in the installation instructions, you).165 F(may ha)
+108 374.7 Q .33 -.165(ve t)-.22 H 2.75(op).165 G
+(erform some additional steps before starting the)-2.75 E/F4 11
+/Courier@0 SF(postmaster)2.75 E F1(process.)2.75 E 5.5<8345>113.5 391.8
+S -.165(ve)-5.5 G 3.135(ni).165 G 3.135(fy)-3.135 G .385
+(ou were not the person who installed)-3.135 F F2(POSTGRES)3.136 E F1
+3.136(,y)C .386(ou should understand the)-3.136 F 1.448
+(installation instructions.)122.85 405 R 1.448
+(The installation instructions e)6.948 F 1.448
+(xplain some important issues)-.165 F .008(with respect to where)122.85
+418.2 R F2(POSTGRES)2.759 E F1 .009
+(places some important \214les, proper settings for en)2.759 F(vi-)-.44
+E(ronment v)122.85 431.4 Q(ariables, etc. that may v)-.275 E
+(ary from one v)-.275 E(ersion of)-.165 E F2(POSTGRES)2.75 E F1
+(to another)2.75 E(.)-.605 E 5.5<8359>113.5 444.6 S(ou)-6.71 E/F5 11
+/Times-Italic@0 SF(must)4.815 E F1 2.065(start the)4.815 F F4
+(postmaster)4.815 E F1 2.064(process with the user)4.814 F 2.064
+(-id that o)-.22 F 2.064(wns the installed)-.275 F 1.264
+(database \214les.)122.85 457.8 R 1.264(In most cases, if you ha)6.764 F
+1.594 -.165(ve f)-.22 H(ollo).165 E 1.264
+(wed the installation instructions, this)-.275 F .393
+(will be the user \231postgres\232.)122.85 471 R .392
+(If you do not start the)5.893 F F4(postmaster)3.142 E F1 .392
+(with the right user)3.142 F(-)-.22 E .703(id, the back)122.85 484.2 R
+.703(end serv)-.11 F .703(ers that are started by the)-.165 F F4
+(postmaster)3.453 E F1 .704(will not be able to read)3.453 F(the data.)
+122.85 497.4 Q 5.5<834d>113.5 510.6 S(ak)-5.5 E 3.831(es)-.11 G 1.081
+(ure that)-3.831 F F4(/usr/local/postgres95/bin)3.831 E F1 1.08
+(is in your shell command path,)3.831 F(because the)122.85 523.8 Q F4
+(postmaster)2.75 E F1(will use your)2.75 E F4(PATH)2.75 E F1(to locate)
+2.75 E F2(POSTGRES)2.75 E F1(commands.)2.75 E 5.5<8352>113.5 537 S .571
+(emember to set the en)-5.5 F .571(vironment v)-.44 F(ariable)-.275 E F4
+(PGDATA)3.321 E F1 .571(to the directory where the)3.321 F F2(POST)3.322
+E(-)-.92 E(GRES)122.85 550.2 Q F1 .043(databases are installed.)2.794 F
+.043(\(This v)5.543 F .043(ariable is more fully e)-.275 F .043
+(xplained in the)-.165 F F2(POSTGRES)2.793 E F1
+(installation instructions.\))122.85 563.4 Q 5.5<8349>113.5 576.6 S
+3.041(fy)-5.5 G .292(ou do start the)-3.041 F F4(postmaster)3.042 E F1
+.292(using non-standard options, such as a dif)3.042 F .292(ferent TCP)
+-.275 F .052(port number)122.85 589.8 R 2.802(,r)-.44 G .052
+(emember to tell all users so that the)-2.802 F 2.802(yc)-.165 G .052
+(an set their)-2.802 F F4(PGPORT)2.801 E F1(en)2.801 E(vironment)-.44 E
+-.275(va)122.85 603 S(riable correctly).275 E(.)-.715 E F3 3
+(15.1.2. Shutting)72 629.2 R(Do)3 E(wn the P)-.12 E(ostmaster)-.24 E F1
+.174(If you need to halt the)108 646.3 R F4(postmaster)2.924 E F1 .175
+(process, you can use the)2.925 F F2(UNIX)2.925 E F4(kill)2.925 E F1
+.175(\(1\) command.)B .445(Some people habitually use the)108 659.5 R F4
+(-9)3.195 E F1(or)3.195 E F4(-KILL)3.195 E F1 .445
+(option; this should ne)3.195 F -.165(ve)-.275 G 3.194(rb).165 G 3.194
+(en)-3.194 G .444(ecessary and)-3.194 F 1.129
+(we do not recommend that you do this, as the)108 672.7 R F4(postmaster)
+3.879 E F1 1.129(will be unable to free its)3.879 F -.275(va)108 685.9 S
+(rious shared resources, its child processes will be unable to e).275 E
+(xit gracefully)-.165 E 2.75(,e)-.715 G(tc.)-2.75 E/F6 11/Times-Bold@0
+SF(72)282.5 756 Q EP
+%%Page: 73 73
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(15.1.3. Adding)72 97.2 R(and Remo)3 E
+(ving Users)-.12 E/F1 11/Times-Roman@0 SF(The)108 114.3 Q/F2 11
+/Courier@0 SF(createuser)3.748 E F1(and)3.748 E F2(destroyuser)3.748 E
+F1 .998(commands enable and disable access to)3.748 F/F3 10
+/Times-Roman@0 SF(POST)3.747 E(-)-.92 E(GRES)108 127.5 Q F1
+(by speci\214c users on the host system.)2.75 E F0 3(15.1.4. P)72 153.7
+R(eriodic Upk)-.24 E(eep)-.12 E F1(The)108 170.8 Q F2(vacuum)2.825 E F1
+.075(command should be run on each database periodically)2.825 F 5.575
+(.T)-.715 G .076(his command pro-)-5.575 F .532
+(cesses deleted instances)108 186.2 R/F4 8/Times-Roman@0 SF(9)-4.4 I F1
+.532(and, more importantly)3.282 4.4 N 3.282(,u)-.715 G .532
+(pdates the system)-3.282 F/F5 11/Times-Italic@0 SF(statistics)3.281 E
+F1(concerning)3.281 E .531(the size of each class.)108 199.4 R .531
+(If these statistics are permitted to become out-of-date and inaccu-)
+6.031 F .521(rate, the)108 212.6 R F3(POSTGRES)3.271 E F1 .52
+(query optimizer may mak)3.271 F 3.27(ee)-.11 G .52
+(xtremely poor decisions with respect to)-3.435 F 1.083(query e)108
+225.8 R -.275(va)-.275 G 1.083(luation strate).275 F 3.833
+(gies. Therefore,)-.165 F 1.083(we recommend running)3.833 F F2(vacuum)
+3.834 E F1 -2.365 -.275(ev e)3.834 H 1.084(ry night or).275 F
+(so \(perhaps in a script that is e)108 239 Q -.165(xe)-.165 G
+(cuted by the).165 E F3(UNIX)2.75 E F2(cron)2.75 E F1(\(1\) or)A F2(at)
+2.75 E F1(\(1\) commands\).)A/F6 11/Times-Bold@0 SF .066(Do fr)108 256.1
+R .066(equent backups)-.198 F F1 5.565(.T)C .065
+(hat is, you should either back up your database directories using)
+-5.565 F(the)108 269.3 Q F3(POSTGRES)4.428 E F6(copy)4.428 E F1 1.679
+(command and/or the)4.429 F F3(UNIX)4.429 E F2(dump)4.429 E F1 1.679
+(\(1\) or)B F2(tar)4.429 E F1 1.679(\(1\) commands.)B -1.21(Yo)7.179 G
+(u)1.21 E .45(may think, \231Wh)108 282.5 R 3.2(ya)-.055 G 3.2(mIb)-3.2
+G .449(acking up my database?)-3.2 F .449(What about crash reco)5.949 F
+-.165(ve)-.165 G 3.199(ry?\232 One).165 F(side)3.199 E(ef)108 295.7 Q
+.483(fect of the)-.275 F F3(POSTGRES)3.233 E F1 .483(\231no o)3.233 F
+-.165(ve)-.165 G .483
+(rwrite\232 storage manager is that it is also a \231no log\232 stor)
+.165 F(-)-.22 E 1.793(age manager)108 308.9 R 7.293(.T)-.605 G 1.792(ha\
+t is, the database log stores only abort/commit data, and this is not)
+-7.293 F .713(enough information to reco)108 322.1 R -.165(ve)-.165 G
+3.463(rt).165 G .713
+(he database if the storage medium \(disk\) or the database)-3.463 F
+1.262(\214les are corrupted!)108 335.3 R 1.261(In other w)6.761 F 1.261
+(ords, if a disk block goes bad or)-.11 F F3(POSTGRES)4.011 E F1 1.261
+(happens to)4.011 F .486(corrupt a database \214le,)108 348.5 R F6 -.275
+(yo)3.236 G 3.236(uc).275 G .486(annot r)-3.236 F(eco)-.198 E -.11(ve)
+-.11 G 3.236(rt).11 G .486(hat \214le)-3.236 F F1 5.986(.T)C .486
+(his can be disastrous if the \214le is)-5.986 F
+(one of the shared catalogs, such as)108 361.7 Q F2(pg_database)2.75 E
+F1(.)A F0 3(15.1.5. T)72 387.9 R(uning)-1.104 E F1 .265(Once your users\
+ start to load a signi\214cant amount of data, you will typically run i\
+nto per)108 405 R(-)-.22 E 1.034(formance problems.)108 418.2 R F3
+(POSTGRES)6.534 E F1 1.034(is not the f)3.784 F 1.035
+(astest DBMS in the w)-.11 F 1.035(orld, b)-.11 F 1.035(ut man)-.22 F
+3.785(yo)-.165 G 3.785(ft)-3.785 G(he)-3.785 E -.11(wo)108 431.4 S .19
+(rst problems encountered by users are due to their lack of e).11 F .19
+(xperience with an)-.165 F 2.94(yD)-.165 G(BMS.)-2.94 E
+(Some general tips include:)108 444.6 Q 13.75(\(1\) De\214ne)113.5 461.7
+R 2.337(indices o)5.087 F -.165(ve)-.165 G 5.087(ra).165 G(ttrib)-5.087
+E 2.338(utes that are commonly used for quali\214cations.)-.22 F -.165
+(Fo)7.838 G(r).165 E -.165(ex)142.826 474.9 S(ample, if you often e).165
+E -.165(xe)-.165 G(cute queries of the form).165 E/F7 10/Courier@0 SF
+(SELECT * from EMP where salary < 5000)182.826 500.1 Q F1 1.478
+(then a B-tree inde)142.826 526.3 R 4.228(xo)-.165 G 4.228(nt)-4.228 G
+(he)-4.228 E F2(salary)4.227 E F1(attrib)4.227 E 1.477
+(ute will probably be useful.)-.22 F 1.477(If scans)6.977 F(in)142.826
+539.5 Q -.22(vo)-.44 G(lving equality are more common, as in).22 E F7
+(SELECT * from EMP where salary = 5000)182.826 564.7 Q F1 2.063
+(then you should consider de\214ning a hash inde)142.826 590.9 R 4.814
+(xo)-.165 G(n)-4.814 E F2(salary)4.814 E F1 7.564(.Y)C 2.064
+(ou can de\214ne)-8.774 F .202
+(both, though it will use more disk space and may slo)142.826 604.1 R
+2.951(wd)-.275 G -.275(ow)-2.951 G 2.951(nu).275 G .201(pdates a bit.)
+-2.951 F(Scans)5.701 E(using indices are)142.826 617.3 Q F6(much)2.75 E
+F1 -.11(fa)2.75 G(ster than sequential scans of the entire class.).11 E
+13.75(\(2\) Run)113.5 634.4 R(the)3.882 E F2(vacuum)3.882 E F1 1.132
+(command a lot.)3.882 F 1.132
+(This command updates the statistics that the)6.632 F .404
+(query optimizer uses to mak)142.826 647.6 R 3.154(ei)-.11 G .404
+(ntelligent decisions; if the statistics are inaccurate,)-3.154 F .088
+(the system will mak)142.826 660.8 R 2.839(ei)-.11 G .089
+(nordinately stupid decisions with respect to the w)-2.839 F .089
+(ay it joins)-.11 F .32 LW 76 670.4 72 670.4 DL 80 670.4 76 670.4 DL 84
+670.4 80 670.4 DL 88 670.4 84 670.4 DL 92 670.4 88 670.4 DL 96 670.4 92
+670.4 DL 100 670.4 96 670.4 DL 104 670.4 100 670.4 DL 108 670.4 104
+670.4 DL 112 670.4 108 670.4 DL 116 670.4 112 670.4 DL 120 670.4 116
+670.4 DL 124 670.4 120 670.4 DL 128 670.4 124 670.4 DL 132 670.4 128
+670.4 DL 136 670.4 132 670.4 DL 140 670.4 136 670.4 DL 144 670.4 140
+670.4 DL 148 670.4 144 670.4 DL 152 670.4 148 670.4 DL 156 670.4 152
+670.4 DL 160 670.4 156 670.4 DL 164 670.4 160 670.4 DL 168 670.4 164
+670.4 DL 172 670.4 168 670.4 DL 176 670.4 172 670.4 DL 180 670.4 176
+670.4 DL 184 670.4 180 670.4 DL 188 670.4 184 670.4 DL 192 670.4 188
+670.4 DL 196 670.4 192 670.4 DL 200 670.4 196 670.4 DL 204 670.4 200
+670.4 DL 208 670.4 204 670.4 DL 212 670.4 208 670.4 DL 216 670.4 212
+670.4 DL/F8 5/Times-Roman@0 SF(9)93.6 680.8 Q F4 .195(This may mean dif)
+2.195 3.2 N .195(ferent things depending on the)-.2 F/F9 8
+/Times-Italic@0 SF(ar)2.195 E -.12(ch)-.296 G .195(ive mode).12 F F4
+.195(with which each class has been created.)2.195 F(Ho)4.195 E(we)-.2 E
+-.12(ve)-.2 G .835 -.32(r, t).12 H .195(he current).32 F .759
+(implementation of the)72 693.6 R/F10 8/Courier@0 SF(vacuum)2.759 E F4
+.759(command does)2.759 F F9(not)2.759 E F4 .759(perform an)2.759 F
+2.759(yc)-.12 G .759(ompaction or clustering of data.)-2.759 F .76
+(Therefore, the)4.76 F/F11 7/Times-Roman@0 SF(UNIX)2.76 E F4 .76
+(\214les which)2.76 F(store each)72 703.2 Q F11(POSTGRES)2 E F4
+(class ne)2 E -.12(ve)-.2 G 2(rs).12 G
+(hrink and the space \231reclaimed\232 by)-2 E F10(vacuum)2 E F4(is ne)2
+E -.12(ve)-.2 G 2(ra).12 G(ctually reused.)-2 E F6(73)282.5 756 Q EP
+%%Page: 74 74
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF(and scans classes.)142.826 97.2 Q 13.75
+(\(3\) When)113.5 114.3 R 1.381
+(specifying query qual\214cations \(i.e., the)4.131 F/F1 11/Courier@0 SF
+(where)4.131 E F0 1.38(part of the query\), try to)4.13 F 2.234
+(ensure that a clause in)142.826 127.5 R -.22(vo)-.44 G 2.235
+(lving a constant can be turned into one of the form).22 F/F2 11
+/Times-Italic@0 SF -.165(ra)142.826 140.7 S(ng).165 E(e_variable oper)
+-.11 E(ator constant)-.165 E F0 2.75(,e)C(.g.,)-2.75 E/F3 10/Courier@0
+SF(EMP.salary = 5000)182.826 165.9 Q F0(The)142.826 192.1 Q/F4 10
+/Times-Roman@0 SF(POSTGRES)3.184 E F0 .433
+(query optimizer will only use an inde)3.184 F 3.183(xw)-.165 G .433
+(ith a constant quali\214ca-)-3.183 F(tion of this form.)142.826 205.3 Q
+(It doesn')5.5 E 2.75(th)-.198 G(urt to write the clause as)-2.75 E F3
+(5000 = EMP.salary)182.826 230.5 Q F0 .779
+(if the operator \(in this case,)142.826 256.7 R F1(=)3.529 E F0 3.53
+(\)h)C .78(as a)-3.53 F F2(commutator)3.53 E F0 .78
+(operator de\214ned so that)3.53 F F4(POST)3.53 E(-)-.92 E(GRES)142.826
+269.9 Q F0 .784(can re)3.534 F .784
+(write the query into the desired form.)-.275 F(Ho)6.284 E(we)-.275 E
+-.165(ve)-.275 G 1.664 -.44(r, i).165 H 3.534(fs).44 G .783
+(uch an operator)-3.534 F(does not e)142.826 283.1 Q(xist,)-.165 E F4
+(POSTGRES)2.75 E F0(will ne)2.75 E -.165(ve)-.275 G 2.75(rc).165 G
+(onsider the use of an inde)-2.75 E(x.)-.165 E 13.75(\(4\) When)113.5
+300.2 R .152(joining se)2.902 F -.165(ve)-.275 G .152
+(ral classes together in one query).165 F 2.902(,t)-.715 G .153
+(ry to write the join clauses in)-2.902 F 2.75<6199>142.826 313.4 S
+(chained\232 form, e.g.,)-2.75 E F3
+(where A.a = B.b and B.b = C.c and ...)182.826 338.6 Q F0 .795
+(Notice that relati)142.826 364.8 R -.165(ve)-.275 G .795(ly fe).165 F
+3.545(wc)-.275 G .795(lauses refer to a gi)-3.545 F -.165(ve)-.275 G
+3.544(nc).165 G .794(lass and attrib)-3.544 F .794(ute; the clauses)-.22
+F 1.628(form a linear sequence connecting the attrib)142.826 378 R 1.628
+(utes, lik)-.22 F 4.378(el)-.11 G 1.628(inks in a chain.)-4.378 F 1.628
+(This is)7.128 F
+(preferable to a query written in a \231star\232 form, such as)142.826
+391.2 Q F3(where A.a = B.b and A.a = C.c and ...)182.826 416.4 Q F0
+2.321(Here, man)142.826 442.6 R 5.071(yc)-.165 G 2.321
+(lauses refer to the same class and attrib)-5.071 F 2.321
+(ute \(in this case,)-.22 F F1(A.a)5.071 E F0(\).)A 1.108
+(When presented with a query of this form, the)142.826 455.8 R F4
+(POSTGRES)3.858 E F0 1.108(query optimizer will)3.858 F
+(tend to consider f)142.826 469 Q
+(ar more choices than it should and may run out of memory)-.11 E(.)-.715
+E 13.75(\(5\) If)113.5 486.1 R 1.684
+(you are really desperate to see what query plans look lik)4.434 F 1.683
+(e, you can run the)-.11 F F1(postmaster)142.826 499.3 Q F0 1.258
+(with the)4.008 F F1(-d)4.008 E F0 1.259(option and then run)4.008 F F1
+(monitor)4.009 E F0 1.259(with the)4.009 F F1(-t)4.009 E F0(option.)
+4.009 E .246
+(The format in which query plans will be printed is hard to read b)
+142.826 512.5 R .246(ut you should be)-.22 F(able to tell whether an)
+142.826 525.7 Q 2.75(yi)-.165 G(nde)-2.75 E 2.75(xs)-.165 G
+(cans are being performed.)-2.75 E/F5 12/Times-Bold@0 SF 3(15.2. Infr)72
+551.9 R(equent T)-.216 E(asks)-1.104 E .44 LW 77.5 565.1 72 565.1 DL
+80.5 565.1 75 565.1 DL 86 565.1 80.5 565.1 DL 91.5 565.1 86 565.1 DL 97
+565.1 91.5 565.1 DL 102.5 565.1 97 565.1 DL 108 565.1 102.5 565.1 DL
+113.5 565.1 108 565.1 DL 119 565.1 113.5 565.1 DL 124.5 565.1 119 565.1
+DL 130 565.1 124.5 565.1 DL 135.5 565.1 130 565.1 DL 141 565.1 135.5
+565.1 DL 146.5 565.1 141 565.1 DL 152 565.1 146.5 565.1 DL 157.5 565.1
+152 565.1 DL 163 565.1 157.5 565.1 DL 168.5 565.1 163 565.1 DL 174 565.1
+168.5 565.1 DL 179.5 565.1 174 565.1 DL 185 565.1 179.5 565.1 DL 190.5
+565.1 185 565.1 DL 196 565.1 190.5 565.1 DL 201.5 565.1 196 565.1 DL 207
+565.1 201.5 565.1 DL 212.5 565.1 207 565.1 DL 218 565.1 212.5 565.1 DL
+223.5 565.1 218 565.1 DL 229 565.1 223.5 565.1 DL 234.5 565.1 229 565.1
+DL 240 565.1 234.5 565.1 DL 245.5 565.1 240 565.1 DL 251 565.1 245.5
+565.1 DL 256.5 565.1 251 565.1 DL 262 565.1 256.5 565.1 DL 267.5 565.1
+262 565.1 DL 273 565.1 267.5 565.1 DL 278.5 565.1 273 565.1 DL 284 565.1
+278.5 565.1 DL 289.5 565.1 284 565.1 DL 295 565.1 289.5 565.1 DL 300.5
+565.1 295 565.1 DL 306 565.1 300.5 565.1 DL 311.5 565.1 306 565.1 DL 317
+565.1 311.5 565.1 DL 322.5 565.1 317 565.1 DL 328 565.1 322.5 565.1 DL
+333.5 565.1 328 565.1 DL 339 565.1 333.5 565.1 DL 344.5 565.1 339 565.1
+DL 350 565.1 344.5 565.1 DL 355.5 565.1 350 565.1 DL 361 565.1 355.5
+565.1 DL 366.5 565.1 361 565.1 DL 372 565.1 366.5 565.1 DL 377.5 565.1
+372 565.1 DL 383 565.1 377.5 565.1 DL 388.5 565.1 383 565.1 DL 394 565.1
+388.5 565.1 DL 399.5 565.1 394 565.1 DL 405 565.1 399.5 565.1 DL 410.5
+565.1 405 565.1 DL 416 565.1 410.5 565.1 DL 421.5 565.1 416 565.1 DL 427
+565.1 421.5 565.1 DL 432.5 565.1 427 565.1 DL 438 565.1 432.5 565.1 DL
+443.5 565.1 438 565.1 DL 449 565.1 443.5 565.1 DL 454.5 565.1 449 565.1
+DL 460 565.1 454.5 565.1 DL 465.5 565.1 460 565.1 DL 471 565.1 465.5
+565.1 DL 476.5 565.1 471 565.1 DL 482 565.1 476.5 565.1 DL 487.5 565.1
+482 565.1 DL 493 565.1 487.5 565.1 DL 498.5 565.1 493 565.1 DL 504 565.1
+498.5 565.1 DL F0 .029(At some time or another)108 595.4 R 2.779(,e)-.44
+G -.165(ve)-3.054 G(ry).165 E F4(POSTGRES)2.778 E F0 .028
+(site administrator has to perform all of the fol-)2.778 F(lo)108 608.6
+Q(wing actions.)-.275 E F5 3(15.2.1. Cleaning)72 634.8 R
+(Up After Crashes)3 E F0(The)108 651.9 Q F1(postgres)3.101 E F0(serv)
+3.101 E .351(er and the)-.165 F F1(postmaster)3.101 E F0 .351(run as tw)
+3.101 F 3.101(od)-.11 G(if)-3.101 E .351(ferent processes.)-.275 F(The)
+5.851 E 3.102(ym)-.165 G(ay)-3.102 E 1.494(crash separately or together)
+108 665.1 R 6.993(.T)-.605 G 1.493(he housek)-6.993 F 1.493
+(eeping procedures required to \214x one kind of)-.11 F(crash are dif)
+108 678.3 Q(ferent from those required to \214x the other)-.275 E(.)
+-.605 E(The message you will usually see when the back)108 695.4 Q
+(end serv)-.11 E(er crashes is:)-.165 E F3
+(FATAL: no response from backend: detected in ...)148 720.6 Q/F6 11
+/Times-Bold@0 SF(74)282.5 756 Q EP
+%%Page: 75 75
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF .584(This generally means one of tw)108 97.2 R
+3.334(ot)-.11 G .584(hings: there is a b)-3.334 F .584(ug in the)-.22 F
+/F1 10/Times-Roman@0 SF(POSTGRES)3.334 E F0(serv)3.334 E(er)-.165 E
+3.335(,o)-.44 G 3.335(rt)-3.335 G(here)-3.335 E .003(is a b)108 110.4 R
+.003(ug in some user code that has been dynamically loaded into)-.22 F
+F1(POSTGRES)2.752 E F0 5.502(.Y)C .002(ou should)-6.712 F .823
+(be able to restart your application and resume processing, b)108 123.6
+R .824(ut there are some considera-)-.22 F(tions:)108 136.8 Q(\(1\))
+113.5 153.9 Q F1(POSTGRES)16.5 E F0 1.694
+(usually dumps a core \214le \(a snapshot of process memory used for)
+4.444 F(deb)142.826 167.1 Q(ugging\) in the database directory)-.22 E/F2
+10/Courier@0 SF(/usr/local/postgres95/data/base/<database>/core)182.826
+192.3 Q F0 .478(on the serv)142.826 218.5 R .479(er machine.)-.165 F
+.479(If you don')5.979 F 3.229(tw)-.198 G .479(ant to try to deb)-3.339
+F .479(ug the problem or produce)-.22 F 3.399(as)142.826 231.7 S .649
+(tack trace to report the b)-3.399 F .648
+(ug to someone else, you can delete this \214le \(which is)-.22 F
+(probably around 10MB\).)142.826 244.9 Q 13.75(\(2\) When)113.5 262 R
+.576(one back)3.326 F .576(end crashes in an uncontrolled w)-.11 F .577
+(ay \(i.e., without calling its b)-.11 F(uilt-)-.22 E .64
+(in cleanup routines\), the)142.826 275.2 R/F3 11/Courier@0 SF
+(postmaster)3.39 E F0 .64(will detect this situation, kill all running)
+3.39 F(serv)142.826 288.4 Q 2.589
+(ers and reinitialize the state shared among all back)-.165 F 2.589
+(ends \(e.g., the shared)-.11 F -.22(bu)142.826 301.6 S -.275(ff).22 G
+1.61(er pool and locks\).).275 F 1.61(If your serv)7.11 F 1.609
+(er crashed, you will get the \231no response\232)-.165 F 1.132
+(message sho)142.826 314.8 R 1.132(wn abo)-.275 F -.165(ve)-.165 G 6.632
+(.I).165 G 3.882(fy)-6.632 G 1.132(our serv)-3.882 F 1.132(er w)-.165 F
+1.132(as killed because someone else')-.11 F 3.882(ss)-.605 G(erv)-3.882
+E(er)-.165 E(crashed, you will see the follo)142.826 328 Q
+(wing message:)-.275 E F2 6(Ih)182.826 353.2 S
+(ave been signalled by the postmaster.)-6 E
+(Some backend process has died unexpectedly and possibly)182.826 365.4 Q
+(corrupted shared memory.)182.826 377.6 Q(The current transaction was)12
+E(aborted, and I am going to exit.)182.826 389.8 Q(Please resend the)12
+E(last query. -- The postgres backend)182.826 402 Q F0 13.75
+(\(3\) Sometimes)113.5 432.1 R .371
+(shared state is not completely cleaned up.)3.121 F .37
+(Frontend applications may)5.87 F(see errors of the form:)142.826 445.3
+Q F2(WARN: cannot write block 34 of myclass [mydb] blind)182.826 470.5 Q
+F0(In this case, you should kill the)142.826 496.7 Q F3(postmaster)2.75
+E F0(and restart it.)2.75 E 13.75(\(4\) When)113.5 513.8 R .541(the sys\
+tem crashes while updating the system catalogs \(e.g., when you are)3.29
+F .581(creating a class, de\214ning an inde)142.826 527 R .581
+(x, retrie)-.165 F .58(ving into a class, etc.\) the B-tree indices)
+-.275 F .986(de\214ned on the catalogs are sometimes corrupted.)142.826
+540.2 R .987(The general \(and non-unique\))6.487 F .363
+(symptom is that)142.826 553.4 R/F4 11/Times-Bold@0 SF(all)3.113 E F0
+.363(queries stop w)3.113 F 3.113(orking. If)-.11 F .363(you ha)3.113 F
+.693 -.165(ve t)-.22 H .363(ried all of the abo).165 F .693 -.165(ve s)
+-.165 H(teps).165 E .231(and nothing else seems to w)142.826 566.6 R
+.231(ork, try using the)-.11 F F3(reindexdb)2.981 E F0 2.981
+(command. If)2.981 F F3(rein-)2.981 E(dexdb)142.826 579.8 Q F0 .293
+(succeeds b)3.043 F .293(ut things still don')-.22 F 3.043(tw)-.198 G
+.293(ork, you ha)-3.153 F .623 -.165(ve a)-.22 H .292
+(nother problem; if it f).165 F(ails,)-.11 E .084
+(the system catalogs themselv)142.826 593 R .084
+(es were almost certainly corrupted and you will ha)-.165 F -.165(ve)
+-.22 G(to go back to your backups.)142.826 606.2 Q(The)108 623.3 Q F3
+(postmaster)3.443 E F0 .693(does not usually crash \(it doesn')3.443 F
+3.443(td)-.198 G 3.443(ov)-3.443 G .693(ery much e)-3.608 F .693
+(xcept start serv)-.165 F(ers\))-.165 E -.22(bu)108 636.5 S 4.052(ti).22
+G 4.052(td)-4.052 G 1.302(oes happen on occasion.)-4.052 F 1.302
+(In addition, there are a fe)6.802 F 4.053(wc)-.275 G 1.303
+(ases where it encounters)-4.053 F .574
+(problems during the reinitialization of shared resources.)108 649.7 R
+(Speci\214cally)6.074 E 3.324(,t)-.715 G .574(here are race con-)-3.324
+F .482(ditions where the operating system lets the)108 662.9 R F3
+(postmaster)3.232 E F0 .482(free shared resources b)3.232 F .483
+(ut then)-.22 F .788(will not permit it to reallocate the same amount o\
+f shared resources \(e)108 676.1 R -.165(ve)-.275 G 3.538(nw).165 G .788
+(hen there is)-3.538 F(no contention\).)108 689.3 Q -1.21(Yo)108 706.4 S
+5.278(uw)1.21 G 2.528(ill typically ha)-5.278 F 2.858 -.165(ve t)-.22 H
+5.278(or).165 G 2.528(un the)-5.278 F F3(ipcclean)5.278 E F0 2.529
+(command if system errors cause the)5.278 F F3(postmaster)108 719.6 Q F0
+3.334(to crash.)6.084 F 3.333
+(If this happens, you may \214nd \(using the)8.833 F F1(UNIX)6.083 E F3
+(ipcs)6.083 E F0(\(1\))A F4(75)282.5 756 Q EP
+%%Page: 76 76
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF .354(command\) that the \231postgres\232 user h\
+as shared memory and/or semaphores allocated e)108 97.2 R -.165(ve)-.275
+G(n).165 E .265(though no)108 110.4 R/F1 11/Courier@0 SF(postmaster)
+3.015 E F0 .265(process is running.)3.015 F .265
+(In this case, you should run)5.765 F F1(ipcclean)3.014 E F0(as)3.014 E
+2.671(the \231postgres\232 user in order to deallocate these resources.)
+108 123.6 R 2.672(Be w)8.171 F 2.672(arned that)-.11 F/F2 11
+/Times-Italic@0 SF(all)5.422 E F0(such)5.422 E .269(resources o)108
+136.8 R .268(wned by the \231postgres\232 user will be deallocated.)
+-.275 F .268(If you ha)5.768 F .598 -.165(ve m)-.22 H(ultiple).165 E F1
+(post-)3.018 E(master)108 150 Q F0 .383(processes running on the same m\
+achine, you should kill all of them before run-)3.133 F(ning)108 163.2 Q
+F1(ipcclean)2.913 E F0 .163(\(otherwise, the)2.913 F 2.913(yw)-.165 G
+.163(ill crash on their o)-2.913 F .162
+(wn when their shared resources are)-.275 F(suddenly deallocated\).)108
+176.4 Q/F3 12/Times-Bold@0 SF 3(15.2.2. Mo)72 202.6 R(ving Database Dir)
+-.12 E(ectories)-.216 E F0 4.764(By def)108 219.7 R 4.764(ault, all)-.11
+F/F4 10/Times-Roman@0 SF(POSTGRES)7.515 E F0 4.765
+(databases are stored in separate subdirectories under)7.515 F F1
+(/usr/local/postgres95/data/base)108 235.1 Q F0(.)A/F5 8/Times-Roman@0
+SF(10)-4.4 I F0 1.688(At some point, you may \214nd that you)4.438 4.4 N
+.8(wish to mo)108 248.3 R 1.13 -.165(ve o)-.165 H .799(ne or more datab\
+ases to another location \(e.g., to a \214lesystem with more).165 F
+(free space\).)108 261.5 Q(If you wish to mo)108 278.6 Q -.165(ve)-.165
+G F2(all)2.915 E F0(of your databases to the ne)2.75 E 2.75(wl)-.275 G
+(ocation, you can simply:)-2.75 E 5.5<834b>113.5 295.7 S(ill the)-5.5 E
+F1(postmaster)2.75 E F0(.)A 5.5<8343>113.5 308.9 S(op)-5.5 E 2.838(yt)
+-.11 G .088(he entire)-2.838 F F1(data)2.838 E F0 .089
+(directory to the ne)2.838 F 2.839(wl)-.275 G .089
+(ocation \(making sure that the ne)-2.839 F 2.839<778c>-.275 G .089
+(les are)-2.839 F -.275(ow)122.85 322.1 S
+(ned by user \231postgres\232\).).275 E/F6 10/Courier@0 SF 6(%c)162.85
+347.3 S 6(p-)-6 G(rp /usr/local/postgres95/data /new/place/data)-6 E F0
+5.5<8352>113.5 373.5 S .773(eset your)-5.5 F F1(PGDATA)3.523 E F0(en)
+3.523 E .773(vironment v)-.44 F .773
+(ariable \(as described earlier in this manual and in)-.275 F
+(the installation instructions\).)122.85 386.7 Q F6 6(#u)162.85 411.9 S
+(sing csh or tcsh...)-6 E 6(%s)162.85 424.1 S
+(etenv PGDATA /new/place/data)-6 E 6(#u)162.85 448.5 S
+(sing sh, ksh or bash...)-6 E 6(%P)162.85 460.7 S
+(GDATA=/new/place/data; export PGDATA)-6 E F0 5.5<8352>113.5 486.9 S
+(estart the)-5.5 E F1(postmaster)2.75 E F0(.)A F6 6(%p)162.85 512.1 S
+(ostmaster &)-6 E F0 5.5<8341>113.5 538.3 S 1.129
+(fter you run some queries and are sure that the ne)-5.5 F(wly-mo)-.275
+E -.165(ve)-.165 G 3.879(dd).165 G 1.129(atabase w)-3.879 F 1.129
+(orks, you)-.11 F(can remo)122.85 551.5 Q .33 -.165(ve t)-.165 H(he old)
+.165 E F1(data)2.75 E F0(directory)2.75 E(.)-.715 E F6 6(%r)162.85 576.7
+S 6(m-)-6 G(rf /usr/local/postgres95/data)-6 E F0 2.673 -.88(To i)108
+606.8 T .913(nstall a).88 F F2(single)3.663 E F0 .913
+(database in an alternate directory while lea)3.663 F .913
+(ving all other databases in)-.22 F(place, do the follo)108 620 Q(wing:)
+-.275 E 5.5<8343>113.5 637.1 S .81(reate the database \(if it doesn')
+-5.5 F 3.561(ta)-.198 G .811(lready e)-3.561 F .811(xist\) using the)
+-.165 F/F7 11/Times-Bold@0 SF(cr)3.561 E(eatedb)-.198 E F0 3.561
+(command. In)3.561 F(the)3.561 E(follo)122.85 650.3 Q
+(wing steps we will assume the database is named)-.275 E F1(foo)2.75 E
+F0(.)A .32 LW 76 667.4 72 667.4 DL 80 667.4 76 667.4 DL 84 667.4 80
+667.4 DL 88 667.4 84 667.4 DL 92 667.4 88 667.4 DL 96 667.4 92 667.4 DL
+100 667.4 96 667.4 DL 104 667.4 100 667.4 DL 108 667.4 104 667.4 DL 112
+667.4 108 667.4 DL 116 667.4 112 667.4 DL 120 667.4 116 667.4 DL 124
+667.4 120 667.4 DL 128 667.4 124 667.4 DL 132 667.4 128 667.4 DL 136
+667.4 132 667.4 DL 140 667.4 136 667.4 DL 144 667.4 140 667.4 DL 148
+667.4 144 667.4 DL 152 667.4 148 667.4 DL 156 667.4 152 667.4 DL 160
+667.4 156 667.4 DL 164 667.4 160 667.4 DL 168 667.4 164 667.4 DL 172
+667.4 168 667.4 DL 176 667.4 172 667.4 DL 180 667.4 176 667.4 DL 184
+667.4 180 667.4 DL 188 667.4 184 667.4 DL 192 667.4 188 667.4 DL 196
+667.4 192 667.4 DL 200 667.4 196 667.4 DL 204 667.4 200 667.4 DL 208
+667.4 204 667.4 DL 212 667.4 208 667.4 DL 216 667.4 212 667.4 DL/F8 5
+/Times-Roman@0 SF(10)93.6 677.8 Q F5 .324
+(Data for certain classes may stored else)2.324 3.2 N .324
+(where if a non-standard storage manager w)-.2 F .324
+(as speci\214ed when the)-.08 F 2.323(yw)-.12 G .323(ere created.)-2.323
+F(Use)4.323 E(of non-standard storage managers is an e)72 690.6 Q
+(xperimental feature that is not supported outside of Berk)-.12 E(ele)
+-.08 E -.52(y.)-.12 G F7(76)282.5 756 Q EP
+%%Page: 77 77
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF 5.5<834b>113.5 97.2 S(ill the)-5.5 E/F1 11
+/Courier@0 SF(postmaster)2.75 E F0(.)A 5.5<8343>113.5 110.4 S(op)-5.5 E
+4.575(yt)-.11 G 1.824(he directory)-4.575 F F1
+(/usr/local/postgres95/data/base/foo)4.574 E F0 1.824(and its con-)4.574
+F(tents to its ultimate destination.)122.85 123.6 Q
+(It should still be o)5.5 E(wned by the \231postgres\232 user)-.275 E(.)
+-.605 E/F2 10/Courier@0 SF 6(%c)162.85 148.8 S 6(p-)-6 G
+(rp /usr/local/postgres95/data/base/foo /new/place/foo)-6 E F0 5.5<8352>
+113.5 175 S(emo)-5.5 E .33 -.165(ve t)-.165 H(he directory).165 E F1
+(/usr/local/postgres95/data/base/foo)2.75 E F0(:)A F2 6(%r)162.85 200.2
+S 6(m-)-6 G(rf /usr/local/postgres95/data/base/foo)-6 E F0 5.5<834d>
+113.5 226.4 S(ak)-5.5 E 3.48(eas)-.11 G .73(ymbolic link from)-3.48 F F1
+(/usr/local/postgres95/data/base)3.48 E F0 .73(to the ne)3.48 F(w)-.275
+E(directory:)122.85 239.6 Q F2 6(%l)162.85 264.8 S 6(n-)-6 G 6(s/)-6 G
+(new/place/foo /usr/local/postgres95/data/base/foo)-6 E F0 5.5<8352>
+113.5 291 S(estart the)-5.5 E F1(postmaster)2.75 E F0(.)A/F3 12
+/Times-Bold@0 SF 3(15.2.3. Updating)72 317.2 R(Databases)3 E/F4 10
+/Times-Roman@0 SF(POSTGRES)108 334.3 Q F0 .679(is a research system.)
+3.429 F .679(In general,)6.179 F F4(POSTGRES)3.429 E F0 .679
+(may not retain the same binary)3.429 F .715
+(format for the storage of databases from release to release.)108 347.5
+R .715(Therefore, when you update)6.215 F(your)108 360.7 Q F4(POSTGRES)
+2.8 E F0(softw)2.8 E .05(are, you will probably ha)-.11 F .38 -.165
+(ve t)-.22 H 2.8(om).165 G .049(odify your databases as well.)-2.8 F
+(This)5.549 E .248(is a common occurrence with commercial database syst\
+ems as well; unfortunately)108 373.9 R 2.998(,u)-.715 G(nlik)-2.998 E(e)
+-.11 E .598(commercial systems,)108 387.1 R F4(POSTGRES)3.348 E F0 .598
+(does not come with user)3.348 F .597(-friendly utilities to mak)-.22 F
+3.347(ey)-.11 G(our)-3.347 E(life easier when these updates occur)108
+400.3 Q(.)-.605 E .171(In general, you must do the follo)108 417.4 R
+.172(wing to update your databases to a ne)-.275 F 2.922(ws)-.275 G
+(oftw)-2.922 E .172(are release:)-.11 F<83>113.5 434.5 Q/F5 11
+/Times-Italic@0 SF(Extensions)5.5 E F0 1.073(\(such as user)3.823 F
+1.073(-de\214ned types, functions, aggre)-.22 F -.055(ga)-.165 G 1.072
+(tes, etc.\) must be reloaded).055 F(by re-e)122.85 447.7 Q -.165(xe)
+-.165 G(cuting the SQL).165 E/F6 11/Times-Bold@0 SF(CREA)2.75 E(TE)
+-1.045 E F0 2.75(commands. See)2.75 F(Appendix A for more details.)2.75
+E<83>113.5 460.9 Q F5(Data)5.5 E F0 1.08
+(must be dumped from the old classes into ASCII \214les \(using the)
+3.829 F F6(COPY)3.83 E F0(com-)3.83 E .235(mand\), the ne)122.85 474.1 R
+2.985(wc)-.275 G .235(lasses created in the ne)-2.985 F 2.985(wd)-.275 G
+.234(atabase \(using the)-2.985 F F6(CREA)2.984 E(TE)-1.045 E F0 -1.023
+(TA)C .234(BLE com-)1.023 F
+(mand\), and the data reloaded from the ASCII \214les.)122.85 487.3 Q
+<83>113.5 500.5 Q F5(Rules)5.5 E F0(and)4.214 E F5(vie)4.214 E(ws)-.165
+E F0 1.465(must also be reloaded by re-e)4.215 F -.165(xe)-.165 G 1.465
+(cuting the v).165 F(arious)-.275 E F6(CREA)4.215 E(TE)-1.045 E F0(com-)
+4.215 E(mands.)122.85 513.7 Q -1.21(Yo)108 530.8 S 4.717(us)1.21 G 1.966
+(hould gi)-4.717 F 2.296 -.165(ve a)-.275 H 2.296 -.165(ny n).165 H
+2.516 -.275(ew r).165 H 1.966
+(elease a \231trial period\232; in particular).275 F 4.716(,d)-.44 G
+4.716(on)-4.716 G 1.966(ot delete the old)-4.716 F 1.741(database until\
+ you are satis\214ed that there are no compatibility problems with the \
+ne)108 544 R(w)-.275 E(softw)108 557.2 Q 3.529(are. F)-.11 F .779(or e)
+-.165 F .779(xample, you do not w)-.165 F .779(ant to disco)-.11 F -.165
+(ve)-.165 G 3.529(rt).165 G .779(hat a b)-3.529 F .779(ug in a type')
+-.22 F 3.529<7399>-.605 G .778(input\232 \(con-)-3.529 F -.165(ve)108
+570.4 S 2.143(rsion from ASCII\) and \231output\232 \(con).165 F -.165
+(ve)-.44 G 2.143(rsion to ASCII\) routines pre).165 F -.165(ve)-.275 G
+2.143(nts you from).165 F 1.032(reloading your data after you ha)108
+583.6 R 1.362 -.165(ve d)-.22 H(estro).165 E 1.031
+(yed your old databases!)-.11 F 1.031(\(This should be stan-)6.531 F
+.838(dard procedure when updating an)108 596.8 R 3.589(ys)-.165 G(oftw)
+-3.589 E .839(are package, b)-.11 F .839
+(ut some people try to economize)-.22 F
+(on disk space without applying enough foresight.\))108 610 Q F3 3
+(15.3. Database)72 636.2 R(Security)3 E .44 LW 77.5 649.4 72 649.4 DL
+80.5 649.4 75 649.4 DL 86 649.4 80.5 649.4 DL 91.5 649.4 86 649.4 DL 97
+649.4 91.5 649.4 DL 102.5 649.4 97 649.4 DL 108 649.4 102.5 649.4 DL
+113.5 649.4 108 649.4 DL 119 649.4 113.5 649.4 DL 124.5 649.4 119 649.4
+DL 130 649.4 124.5 649.4 DL 135.5 649.4 130 649.4 DL 141 649.4 135.5
+649.4 DL 146.5 649.4 141 649.4 DL 152 649.4 146.5 649.4 DL 157.5 649.4
+152 649.4 DL 163 649.4 157.5 649.4 DL 168.5 649.4 163 649.4 DL 174 649.4
+168.5 649.4 DL 179.5 649.4 174 649.4 DL 185 649.4 179.5 649.4 DL 190.5
+649.4 185 649.4 DL 196 649.4 190.5 649.4 DL 201.5 649.4 196 649.4 DL 207
+649.4 201.5 649.4 DL 212.5 649.4 207 649.4 DL 218 649.4 212.5 649.4 DL
+223.5 649.4 218 649.4 DL 229 649.4 223.5 649.4 DL 234.5 649.4 229 649.4
+DL 240 649.4 234.5 649.4 DL 245.5 649.4 240 649.4 DL 251 649.4 245.5
+649.4 DL 256.5 649.4 251 649.4 DL 262 649.4 256.5 649.4 DL 267.5 649.4
+262 649.4 DL 273 649.4 267.5 649.4 DL 278.5 649.4 273 649.4 DL 284 649.4
+278.5 649.4 DL 289.5 649.4 284 649.4 DL 295 649.4 289.5 649.4 DL 300.5
+649.4 295 649.4 DL 306 649.4 300.5 649.4 DL 311.5 649.4 306 649.4 DL 317
+649.4 311.5 649.4 DL 322.5 649.4 317 649.4 DL 328 649.4 322.5 649.4 DL
+333.5 649.4 328 649.4 DL 339 649.4 333.5 649.4 DL 344.5 649.4 339 649.4
+DL 350 649.4 344.5 649.4 DL 355.5 649.4 350 649.4 DL 361 649.4 355.5
+649.4 DL 366.5 649.4 361 649.4 DL 372 649.4 366.5 649.4 DL 377.5 649.4
+372 649.4 DL 383 649.4 377.5 649.4 DL 388.5 649.4 383 649.4 DL 394 649.4
+388.5 649.4 DL 399.5 649.4 394 649.4 DL 405 649.4 399.5 649.4 DL 410.5
+649.4 405 649.4 DL 416 649.4 410.5 649.4 DL 421.5 649.4 416 649.4 DL 427
+649.4 421.5 649.4 DL 432.5 649.4 427 649.4 DL 438 649.4 432.5 649.4 DL
+443.5 649.4 438 649.4 DL 449 649.4 443.5 649.4 DL 454.5 649.4 449 649.4
+DL 460 649.4 454.5 649.4 DL 465.5 649.4 460 649.4 DL 471 649.4 465.5
+649.4 DL 476.5 649.4 471 649.4 DL 482 649.4 476.5 649.4 DL 487.5 649.4
+482 649.4 DL 493 649.4 487.5 649.4 DL 498.5 649.4 493 649.4 DL 504 649.4
+498.5 649.4 DL F0 1.632(Most sites that use)108 679.7 R F4(POSTGRES)
+4.383 E F0 1.633
+(are educational or research institutions and do not pay)4.383 F 1.615
+(much attention to security in their)108 692.9 R F4(POSTGRES)4.365 E F0
+4.365(installations. If)4.365 F 1.614(desired, one can install)4.365 F
+F4(POSTGRES)108 706.1 Q F0 1.524(with additional security features.)
+4.274 F(Naturally)7.024 E 4.274(,s)-.715 G 1.524
+(uch features come with addi-)-4.274 F(tional administrati)108 719.3 Q
+.33 -.165(ve ove)-.275 H(rhead that must be dealt with.).165 E F6(77)
+282.5 756 Q EP
+%%Page: 78 78
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 12/Times-Bold@0 SF 3(15.3.1. K)72 97.2 R(erber)-.3 E(os)-.216 E/F1
+10/Times-Roman@0 SF(POSTGRES)108 114.3 Q/F2 11/Times-Roman@0 SF 1.328
+(can be con\214gured to use the MIT K)4.078 F 1.327(erberos netw)-.275 F
+1.327(ork authentication system.)-.11 F .791(This pre)108 127.5 R -.165
+(ve)-.275 G .791(nts outside users from connecting to your databases o)
+.165 F -.165(ve)-.165 G 3.541(rt).165 G .791(he netw)-3.541 F .792
+(ork without)-.11 F(the correct authentication information.)108 140.7 Q
+F0 3(15.4. Querying)72 166.9 R(the System Catalogs)3 E .44 LW 77.5 180.1
+72 180.1 DL 80.5 180.1 75 180.1 DL 86 180.1 80.5 180.1 DL 91.5 180.1 86
+180.1 DL 97 180.1 91.5 180.1 DL 102.5 180.1 97 180.1 DL 108 180.1 102.5
+180.1 DL 113.5 180.1 108 180.1 DL 119 180.1 113.5 180.1 DL 124.5 180.1
+119 180.1 DL 130 180.1 124.5 180.1 DL 135.5 180.1 130 180.1 DL 141 180.1
+135.5 180.1 DL 146.5 180.1 141 180.1 DL 152 180.1 146.5 180.1 DL 157.5
+180.1 152 180.1 DL 163 180.1 157.5 180.1 DL 168.5 180.1 163 180.1 DL 174
+180.1 168.5 180.1 DL 179.5 180.1 174 180.1 DL 185 180.1 179.5 180.1 DL
+190.5 180.1 185 180.1 DL 196 180.1 190.5 180.1 DL 201.5 180.1 196 180.1
+DL 207 180.1 201.5 180.1 DL 212.5 180.1 207 180.1 DL 218 180.1 212.5
+180.1 DL 223.5 180.1 218 180.1 DL 229 180.1 223.5 180.1 DL 234.5 180.1
+229 180.1 DL 240 180.1 234.5 180.1 DL 245.5 180.1 240 180.1 DL 251 180.1
+245.5 180.1 DL 256.5 180.1 251 180.1 DL 262 180.1 256.5 180.1 DL 267.5
+180.1 262 180.1 DL 273 180.1 267.5 180.1 DL 278.5 180.1 273 180.1 DL 284
+180.1 278.5 180.1 DL 289.5 180.1 284 180.1 DL 295 180.1 289.5 180.1 DL
+300.5 180.1 295 180.1 DL 306 180.1 300.5 180.1 DL 311.5 180.1 306 180.1
+DL 317 180.1 311.5 180.1 DL 322.5 180.1 317 180.1 DL 328 180.1 322.5
+180.1 DL 333.5 180.1 328 180.1 DL 339 180.1 333.5 180.1 DL 344.5 180.1
+339 180.1 DL 350 180.1 344.5 180.1 DL 355.5 180.1 350 180.1 DL 361 180.1
+355.5 180.1 DL 366.5 180.1 361 180.1 DL 372 180.1 366.5 180.1 DL 377.5
+180.1 372 180.1 DL 383 180.1 377.5 180.1 DL 388.5 180.1 383 180.1 DL 394
+180.1 388.5 180.1 DL 399.5 180.1 394 180.1 DL 405 180.1 399.5 180.1 DL
+410.5 180.1 405 180.1 DL 416 180.1 410.5 180.1 DL 421.5 180.1 416 180.1
+DL 427 180.1 421.5 180.1 DL 432.5 180.1 427 180.1 DL 438 180.1 432.5
+180.1 DL 443.5 180.1 438 180.1 DL 449 180.1 443.5 180.1 DL 454.5 180.1
+449 180.1 DL 460 180.1 454.5 180.1 DL 465.5 180.1 460 180.1 DL 471 180.1
+465.5 180.1 DL 476.5 180.1 471 180.1 DL 482 180.1 476.5 180.1 DL 487.5
+180.1 482 180.1 DL 493 180.1 487.5 180.1 DL 498.5 180.1 493 180.1 DL 504
+180.1 498.5 180.1 DL F2 .509
+(As an administrator \(or sometimes as a plain user\), you w)108 210.4 R
+.51(ant to \214nd out what e)-.11 F(xtensions)-.165 E(ha)108 223.6 Q
+.854 -.165(ve b)-.22 H .524(een added to a gi).165 F -.165(ve)-.275 G
+3.273(nd).165 G 3.273(atabase. The)-3.273 F .523(queries listed belo)
+3.273 F 3.273(wa)-.275 G .523(re \231canned\232 queries that)-3.273 F
+.599(you can run on an)108 236.8 R 3.35(yd)-.165 G .6
+(atabase to get simple answers.)-3.35 F .6(Before e)6.1 F -.165(xe)-.165
+G .6(cuting an).165 F 3.35(yo)-.165 G 3.35(ft)-3.35 G .6(he queries)
+-3.35 F(belo)108 250 Q 1.46 -.715(w, b)-.275 H 2.78(es).715 G .03
+(ure to e)-2.78 F -.165(xe)-.165 G .029(cute the).165 F F1(POSTGRES)
+2.779 E/F3 11/Courier@0 SF(vacuum)2.779 E F2 2.779(command. \(The)2.779
+F .029(queries will run much)2.779 F(more quickly that w)108 263.2 Q(ay)
+-.11 E 2.75(.\) Also,)-.715 F
+(note that these queries are also listed in)2.75 E/F4 10/Courier@0 SF
+(/usr/local/postgres95/tutorial/syscat.sql)148 288.4 Q F2
+(so use cut-and-paste \(or the)108 314.6 Q F3(\\i)2.75 E F2
+(command\) instead of doing a lot of typing.)2.75 E 3.742(This query pr\
+ints the names of all database adminstrators and the name of their)108
+331.7 R(database\(s\).)108 344.9 Q F4(SELECT usename, datname)148 370.1
+Q(FROM pg_user, pg_database)172 382.3 Q
+(WHERE usesysid = int2in\(int4out\(datdba\)\))172 394.5 Q
+(ORDER BY usename, datname;)172 406.7 Q F2(This query lists all user)108
+432.9 Q(-de\214ned classes in the database.)-.22 E F4(SELECT relname)148
+458.1 Q(FROM pg_class)172 470.3 Q(WHERE relkind = 'r')172 482.5 Q
+(-- not indices)66 E(and relname !~ '^pg_')184 494.7 Q(-- not catalogs)
+42 E(and relname !~ '^Inv')184 506.9 Q(-- not large objects)42 E
+(ORDER BY relname;)172 519.1 Q F2 .671(This query lists all simple indi\
+ces \(i.e., those that are not de\214ned o)108 545.3 R -.165(ve)-.165 G
+3.421(raf).165 G .671(unction of se)-3.421 F(v-)-.275 E(eral attrib)108
+558.5 Q(utes\).)-.22 E F4(SELECT bc.relname AS class_name,)148 583.7 Q
+(ic.relname AS index_name,)202 595.9 Q(a.attname)202 608.1 Q
+(FROM pg_class bc,)172 620.3 Q(-- base class)78 E(pg_class ic,)202 632.5
+Q(-- index class)78 E(pg_index i,)202 644.7 Q(pg_attribute a)202 656.9 Q
+(-- att in base)66 E(WHERE i.indrelid = bc.oid)172 669.1 Q
+(and i.indexrelid = ic.oid)190 681.3 Q(and i.indkey[0] = a.attnum)190
+693.5 Q(and a.attrelid = bc.oid)190 705.7 Q(and i.indproc = '0'::oid)190
+717.9 Q(-- no functional indices)18 E/F5 11/Times-Bold@0 SF(78)282.5 756
+Q EP
+%%Page: 79 79
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(ORDER BY class_name, index_name, attname;)172 96.2 Q
+/F1 11/Times-Roman@0 SF .14(This query prints a report of the user)108
+122.4 R .14(-de\214ned attrib)-.22 F .14
+(utes and their types for all user)-.22 F(-de\214ned)-.22 E
+(classes in the database.)108 135.6 Q F0
+(SELECT c.relname, a.attname, t.typname)148 160.8 Q
+(FROM pg_class c, pg_attribute a, pg_type t)172 173 Q
+(WHERE c.relkind = 'r')172 185.2 Q(-- no indices)30 E
+(and c.relname !~ '^pg_' -- no catalogs)184 197.4 Q
+(and c.relname !~ '^Inv' -- no large objects)184 209.6 Q
+(and a.attnum > 0)184 221.8 Q(-- no system att's)48 E
+(and a.attrelid = c.oid)184 234 Q(and a.atttypid = t.oid)184 246.2 Q
+(ORDER BY relname, attname;)172 258.4 Q F1(This query lists all user)108
+284.6 Q(-de\214ned base types \(not including array types\).)-.22 E F0
+(SELECT u.usename, t.typname)148 309.8 Q(FROM pg_type t, pg_user u)172
+322 Q(WHERE u.usesysid = int2in\(int4out\(t.typowner\)\))172 334.2 Q
+(and t.typrelid = '0'::oid)184 346.4 Q(-- no complex types)18 E
+(and t.typelem = '0'::oid)184 358.6 Q(-- no arrays)24 E
+(and u.usename <> 'postgres')184 370.8 Q(ORDER BY usename, typname;)172
+383 Q F1(This query lists all left-unary \(post-\214x\) operators.)108
+409.2 Q F0(SELECT o.oprname AS left_unary,)148 434.4 Q
+(right.typname AS operand,)202 446.6 Q(result.typname AS return_type)202
+458.8 Q(FROM pg_operator o, pg_type right, pg_type result)172 471 Q
+(WHERE o.oprkind = 'l')172 483.2 Q(-- left unary)66 E
+(and o.oprright = right.oid)184 495.4 Q(and o.oprresult = result.oid)184
+507.6 Q(ORDER BY operand;)172 519.8 Q F1
+(This query lists all right-unary \(pre-\214x\) operators.)108 546 Q F0
+(SELECT o.oprname AS right_unary,)148 571.2 Q(left.typname AS operand,)
+202 583.4 Q(result.typname AS return_type)202 595.6 Q
+(FROM pg_operator o, pg_type left, pg_type result)172 607.8 Q
+(WHERE o.oprkind = 'r')172 620 Q(-- right unary)60 E
+(and o.oprleft = left.oid)184 632.2 Q(and o.oprresult = result.oid)184
+644.4 Q(ORDER BY operand;)172 656.6 Q F1
+(This query lists all binary operators.)108 682.8 Q F0
+(SELECT o.oprname AS binary_op,)148 708 Q(left.typname AS left_opr,)202
+720.2 Q/F2 11/Times-Bold@0 SF(79)282.5 756 Q EP
+%%Page: 80 80
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 10/Courier@0 SF(right.typname AS right_opr,)202 96.2 Q
+(result.typname AS return_type)202 108.4 Q
+(FROM pg_operator o, pg_type left, pg_type right, pg_type result)172
+120.6 Q(WHERE o.oprkind = 'b')172 132.8 Q(-- binary)54 E
+(and o.oprleft = left.oid)184 145 Q(and o.oprright = right.oid)184 157.2
+Q(and o.oprresult = result.oid)184 169.4 Q
+(ORDER BY left_opr, right_opr;)172 181.6 Q/F1 11/Times-Roman@0 SF 1.527
+(This query returns the name, number of ar)108 207.8 R 1.526
+(guments \(parameters\) and return type of all)-.198 F(user)108 221 Q
+.826(-de\214ned C functions.)-.22 F .826
+(The same query can be used to \214nd all b)6.326 F .827
+(uilt-in C functions if)-.22 F 3.101(you change the \231C\232 to \231in\
+ternal\232, or all SQL functions if you change the \231C\232 to)108
+234.2 R(\231postquel\232.)108 247.4 Q F0
+(SELECT p.proname, p.pronargs, t.typname)148 272.6 Q
+(FROM pg_proc p, pg_language l, pg_type t)172 284.8 Q
+(WHERE p.prolang = l.oid)172 297 Q(and p.prorettype = t.oid)184 309.2 Q
+(and l.lanname = 'c')184 321.4 Q(ORDER BY proname;)172 333.6 Q F1 1.286
+(This query lists all of the aggre)108 359.8 R -.055(ga)-.165 G 1.286
+(te functions that ha).055 F 1.616 -.165(ve b)-.22 H 1.287
+(een installed and the types to).165 F 1.369(which the)108 373 R 4.119
+(yc)-.165 G 1.368(an be applied.)-4.119 F/F2 11/Courier@0 SF(count)6.868
+E F1 1.368(is not included because it can tak)4.118 F 4.118(ea)-.11 G
+1.698 -.165(ny t)-4.118 H 1.368(ype as its).165 F(ar)108 386.2 Q
+(gument.)-.198 E F0(SELECT a.aggname, t.typname)148 411.4 Q
+(FROM pg_aggregate a, pg_type t)172 423.6 Q(WHERE a.aggbasetype = t.oid)
+172 435.8 Q(ORDER BY aggname, typname;)172 448 Q F1 1.036(This query li\
+sts all of the operator classes that can be used with each access metho\
+d as)108 474.2 R
+(well as the operators that can be used with the respecti)108 487.4 Q
+.33 -.165(ve o)-.275 H(perator classes.).165 E F0
+(SELECT am.amname, opc.opcname, opr.oprname)148 512.6 Q
+(FROM pg_am am, pg_amop amop, pg_opclass opc, pg_operator opr)172 524.8
+Q(WHERE amop.amopid = am.oid)172 537 Q(and amop.amopclaid = opc.oid)184
+549.2 Q(and amop.amopopr = opr.oid)184 561.4 Q
+(ORDER BY amname, opcname, oprname;)172 573.6 Q/F3 11/Times-Bold@0 SF
+(80)282.5 756 Q EP
+%%Page: 81 81
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 19/Times-Bold@0 SF 4.75(16. REFERENCES)72 165.4 R 77.5 178.6
+72 178.6 DL 80.5 178.6 75 178.6 DL 86 178.6 80.5 178.6 DL 91.5 178.6 86
+178.6 DL 97 178.6 91.5 178.6 DL 102.5 178.6 97 178.6 DL 108 178.6 102.5
+178.6 DL 113.5 178.6 108 178.6 DL 119 178.6 113.5 178.6 DL 124.5 178.6
+119 178.6 DL 130 178.6 124.5 178.6 DL 135.5 178.6 130 178.6 DL 141 178.6
+135.5 178.6 DL 146.5 178.6 141 178.6 DL 152 178.6 146.5 178.6 DL 157.5
+178.6 152 178.6 DL 163 178.6 157.5 178.6 DL 168.5 178.6 163 178.6 DL 174
+178.6 168.5 178.6 DL 179.5 178.6 174 178.6 DL 185 178.6 179.5 178.6 DL
+190.5 178.6 185 178.6 DL 196 178.6 190.5 178.6 DL 201.5 178.6 196 178.6
+DL 207 178.6 201.5 178.6 DL 212.5 178.6 207 178.6 DL 218 178.6 212.5
+178.6 DL 223.5 178.6 218 178.6 DL 229 178.6 223.5 178.6 DL 234.5 178.6
+229 178.6 DL 240 178.6 234.5 178.6 DL 245.5 178.6 240 178.6 DL 251 178.6
+245.5 178.6 DL 256.5 178.6 251 178.6 DL 262 178.6 256.5 178.6 DL 267.5
+178.6 262 178.6 DL 273 178.6 267.5 178.6 DL 278.5 178.6 273 178.6 DL 284
+178.6 278.5 178.6 DL 289.5 178.6 284 178.6 DL 295 178.6 289.5 178.6 DL
+300.5 178.6 295 178.6 DL 306 178.6 300.5 178.6 DL 311.5 178.6 306 178.6
+DL 317 178.6 311.5 178.6 DL 322.5 178.6 317 178.6 DL 328 178.6 322.5
+178.6 DL 333.5 178.6 328 178.6 DL 339 178.6 333.5 178.6 DL 344.5 178.6
+339 178.6 DL 350 178.6 344.5 178.6 DL 355.5 178.6 350 178.6 DL 361 178.6
+355.5 178.6 DL 366.5 178.6 361 178.6 DL 372 178.6 366.5 178.6 DL 377.5
+178.6 372 178.6 DL 383 178.6 377.5 178.6 DL 388.5 178.6 383 178.6 DL 394
+178.6 388.5 178.6 DL 399.5 178.6 394 178.6 DL 405 178.6 399.5 178.6 DL
+410.5 178.6 405 178.6 DL 416 178.6 410.5 178.6 DL 421.5 178.6 416 178.6
+DL 427 178.6 421.5 178.6 DL 432.5 178.6 427 178.6 DL 438 178.6 432.5
+178.6 DL 443.5 178.6 438 178.6 DL 449 178.6 443.5 178.6 DL 454.5 178.6
+449 178.6 DL 460 178.6 454.5 178.6 DL 465.5 178.6 460 178.6 DL 471 178.6
+465.5 178.6 DL 476.5 178.6 471 178.6 DL 482 178.6 476.5 178.6 DL 487.5
+178.6 482 178.6 DL 493 178.6 487.5 178.6 DL 498.5 178.6 493 178.6 DL 504
+178.6 498.5 178.6 DL/F1 11/Times-Roman@0 SF([D)108 208.9 Q -1.221(AT)
+-.44 G 16.445(E93] Date,)1.221 F .066
+(C. J. and Darwen, Hugh, A Guide to The SQL Standard, 3rd Edition,)2.816
+F(Reading, MA, June 1993.)173.186 222.1 Q([MEL)108 239.2 Q 15.18
+(T93] Melton,)-1.012 F 2.75(J. Understanding)2.75 F(the Ne)2.75 E 2.75
+(wS)-.275 G(QL, 1994.)-2.75 E 20.284([ONG90] Ong,)108 256.3 R .878
+(L. and Goh, J., `)3.628 F 2.638 -.88(`A U)-.814 H .878(ni\214ed Frame)
+.88 F -.11(wo)-.275 G .878(rk for V).11 F .878(ersion Modeling Using)
+-1.221 F .172(Production Rules in a Database System," Electronics Resea\
+rch Laboratory)173.186 269.5 R(,)-.715 E(Uni)173.186 282.7 Q -.165(ve)
+-.275 G .611(rsity of California, ERL T).165 F .612
+(echnical Memorandum M90/33, Berk)-.77 F(ele)-.11 E -.715(y,)-.165 G
+(CA, April 1990.)173.186 295.9 Q([R)108 313 Q -.385(OW)-.44 G 12.551
+(E87] Ro).385 F 2.491(we, L. and Stonebrak)-.275 F(er)-.11 E 5.241(,M)
+-.44 G 2.491(., `)-5.241 F 2.491(`The POSTGRES Data Model,)-.814 F 4.118
+-.814('' P)-.77 H(roc.).814 E
+(1987 VLDB Conference, Brighton, England, Sept. 1987.)173.186 326.2 Q
+([ST)108 343.3 Q 15.587(ON86] Stonebrak)-.198 F(er)-.11 E 3.433(,M)-.44
+G 3.433(.a)-3.433 G .683(nd Ro)-3.433 F .683(we, L., `)-.275 F .683
+(`The Design of POSTGRES,)-.814 F 2.311 -.814('' P)-.77 H .684
+(roc. 1986).814 F -.44(AC)173.186 356.5 S 2.147
+(M-SIGMOD Conference on Management of Data, W).44 F 2.146
+(ashington, DC,)-.88 F(May 1986.)173.186 369.7 Q([ST)108 386.8 Q 10.703
+(ON87a] Stonebrak)-.198 F(er)-.11 E 3.378(,M)-.44 G .628
+(., Hanson, E. and Hong, C.-H., `)-3.378 F .628(`The Design of the POST)
+-.814 F(-)-1.012 E .476(GRES Rules System,)173.186 400 R 2.104 -.814
+('' P)-.77 H .475(roc. 1987 IEEE Conference on Data Engineering,).814 F
+(Los Angeles, CA, Feb)173.186 413.2 Q 2.75(.1)-.44 G(987.)-2.75 E([ST)
+108 430.3 Q 10.087(ON87b] Stonebrak)-.198 F(er)-.11 E 4.026(,M)-.44 G
+1.276(., `)-4.026 F 1.276(`The POSTGRES Storage System,)-.814 F 2.904
+-.814('' P)-.77 H 1.276(roc. 1987 VLDB).814 F
+(Conference, Brighton, England, Sept. 1987.)173.186 443.5 Q([ST)108
+460.6 Q 15.587(ON89] Stonebrak)-.198 F(er)-.11 E 3.64(,M)-.44 G .89
+(., Hearst, M., and Potamianos, S., `)-3.64 F 2.65 -.88(`A C)-.814 H .89
+(ommentary on the).88 F(POSTGRES Rules System,)173.186 473.8 Q 1.628
+-.814('' S)-.77 H(IGMOD Record).814 E/F2 11/Times-Italic@0 SF(18)2.75 E
+F1(\(3\), Sept. 1989.)A([ST)108 490.9 Q 10.703(ON90a] Stonebrak)-.198 F
+(er)-.11 E 2.878(,M)-.44 G .128(., Ro)-2.878 F .129
+(we, L. A., and Hirohama, M., `)-.275 F .129(`The Implementation of)
+-.814 F(POSTGRES,)173.186 504.1 Q 3.993 -.814('' I)-.77 H 2.365(EEE T)
+.814 F 2.365(ransactions on Kno)-.385 F 2.365
+(wledge and Data Engineering)-.275 F F2(2)173.186 517.3 Q F1
+(\(1\), March 1990.)A([ST)108 534.4 Q 10.087(ON90b] Stonebrak)-.198 F
+(er)-.11 E 5.388(,M)-.44 G 5.389(.e)-5.388 G 5.389(ta)-5.389 G 2.639
+(l., `)-5.389 F 2.639(`On Rules, Procedures, Caching and V)-.814 F(ie)
+-.66 E 2.639(ws in)-.275 F 1.245(Database Systems,)173.186 547.6 R 2.873
+-.814('' P)-.77 H 1.245(roc. 1990 A).814 F 1.244
+(CM-SIGMOD Conference on Manage-)-.44 F(ment of Data, Atlantic City)
+173.186 560.8 Q 2.75(,N)-.715 G(.J., June 1990.)-2.75 E/F3 11
+/Times-Bold@0 SF(81)282.5 756 Q EP
+%%Page: 82 82
+%%BeginPageSetup
+BP
+%%EndPageSetup
+.44 LW 77.5 97.2 72 97.2 DL 80.5 97.2 75 97.2 DL 86 97.2 80.5 97.2 DL
+91.5 97.2 86 97.2 DL 97 97.2 91.5 97.2 DL 102.5 97.2 97 97.2 DL 108 97.2
+102.5 97.2 DL 113.5 97.2 108 97.2 DL 119 97.2 113.5 97.2 DL 124.5 97.2
+119 97.2 DL 130 97.2 124.5 97.2 DL 135.5 97.2 130 97.2 DL 141 97.2 135.5
+97.2 DL 146.5 97.2 141 97.2 DL 152 97.2 146.5 97.2 DL 157.5 97.2 152
+97.2 DL 163 97.2 157.5 97.2 DL 168.5 97.2 163 97.2 DL 174 97.2 168.5
+97.2 DL 179.5 97.2 174 97.2 DL 185 97.2 179.5 97.2 DL 190.5 97.2 185
+97.2 DL 196 97.2 190.5 97.2 DL 201.5 97.2 196 97.2 DL 207 97.2 201.5
+97.2 DL 212.5 97.2 207 97.2 DL 218 97.2 212.5 97.2 DL 223.5 97.2 218
+97.2 DL 229 97.2 223.5 97.2 DL 234.5 97.2 229 97.2 DL 240 97.2 234.5
+97.2 DL 245.5 97.2 240 97.2 DL 251 97.2 245.5 97.2 DL 256.5 97.2 251
+97.2 DL 262 97.2 256.5 97.2 DL 267.5 97.2 262 97.2 DL 273 97.2 267.5
+97.2 DL 278.5 97.2 273 97.2 DL 284 97.2 278.5 97.2 DL 289.5 97.2 284
+97.2 DL 295 97.2 289.5 97.2 DL 300.5 97.2 295 97.2 DL 306 97.2 300.5
+97.2 DL 311.5 97.2 306 97.2 DL 317 97.2 311.5 97.2 DL 322.5 97.2 317
+97.2 DL 328 97.2 322.5 97.2 DL 333.5 97.2 328 97.2 DL 339 97.2 333.5
+97.2 DL 344.5 97.2 339 97.2 DL 350 97.2 344.5 97.2 DL 355.5 97.2 350
+97.2 DL 361 97.2 355.5 97.2 DL 366.5 97.2 361 97.2 DL 372 97.2 366.5
+97.2 DL 377.5 97.2 372 97.2 DL 383 97.2 377.5 97.2 DL 388.5 97.2 383
+97.2 DL 394 97.2 388.5 97.2 DL 399.5 97.2 394 97.2 DL 405 97.2 399.5
+97.2 DL 410.5 97.2 405 97.2 DL 416 97.2 410.5 97.2 DL 421.5 97.2 416
+97.2 DL 427 97.2 421.5 97.2 DL 432.5 97.2 427 97.2 DL 438 97.2 432.5
+97.2 DL 443.5 97.2 438 97.2 DL 449 97.2 443.5 97.2 DL 454.5 97.2 449
+97.2 DL 460 97.2 454.5 97.2 DL 465.5 97.2 460 97.2 DL 471 97.2 465.5
+97.2 DL 476.5 97.2 471 97.2 DL 482 97.2 476.5 97.2 DL 487.5 97.2 482
+97.2 DL 493 97.2 487.5 97.2 DL 498.5 97.2 493 97.2 DL 504 97.2 498.5
+97.2 DL/F0 12/Times-Bold@0 SF -.3(Ap)72 136.6 S
+(pendix A: Linking Dynamically-Loaded Functions).3 E 77.5 149.8 72 149.8
+DL 80.5 149.8 75 149.8 DL 86 149.8 80.5 149.8 DL 91.5 149.8 86 149.8 DL
+97 149.8 91.5 149.8 DL 102.5 149.8 97 149.8 DL 108 149.8 102.5 149.8 DL
+113.5 149.8 108 149.8 DL 119 149.8 113.5 149.8 DL 124.5 149.8 119 149.8
+DL 130 149.8 124.5 149.8 DL 135.5 149.8 130 149.8 DL 141 149.8 135.5
+149.8 DL 146.5 149.8 141 149.8 DL 152 149.8 146.5 149.8 DL 157.5 149.8
+152 149.8 DL 163 149.8 157.5 149.8 DL 168.5 149.8 163 149.8 DL 174 149.8
+168.5 149.8 DL 179.5 149.8 174 149.8 DL 185 149.8 179.5 149.8 DL 190.5
+149.8 185 149.8 DL 196 149.8 190.5 149.8 DL 201.5 149.8 196 149.8 DL 207
+149.8 201.5 149.8 DL 212.5 149.8 207 149.8 DL 218 149.8 212.5 149.8 DL
+223.5 149.8 218 149.8 DL 229 149.8 223.5 149.8 DL 234.5 149.8 229 149.8
+DL 240 149.8 234.5 149.8 DL 245.5 149.8 240 149.8 DL 251 149.8 245.5
+149.8 DL 256.5 149.8 251 149.8 DL 262 149.8 256.5 149.8 DL 267.5 149.8
+262 149.8 DL 273 149.8 267.5 149.8 DL 278.5 149.8 273 149.8 DL 284 149.8
+278.5 149.8 DL 289.5 149.8 284 149.8 DL 295 149.8 289.5 149.8 DL 300.5
+149.8 295 149.8 DL 306 149.8 300.5 149.8 DL 311.5 149.8 306 149.8 DL 317
+149.8 311.5 149.8 DL 322.5 149.8 317 149.8 DL 328 149.8 322.5 149.8 DL
+333.5 149.8 328 149.8 DL 339 149.8 333.5 149.8 DL 344.5 149.8 339 149.8
+DL 350 149.8 344.5 149.8 DL 355.5 149.8 350 149.8 DL 361 149.8 355.5
+149.8 DL 366.5 149.8 361 149.8 DL 372 149.8 366.5 149.8 DL 377.5 149.8
+372 149.8 DL 383 149.8 377.5 149.8 DL 388.5 149.8 383 149.8 DL 394 149.8
+388.5 149.8 DL 399.5 149.8 394 149.8 DL 405 149.8 399.5 149.8 DL 410.5
+149.8 405 149.8 DL 416 149.8 410.5 149.8 DL 421.5 149.8 416 149.8 DL 427
+149.8 421.5 149.8 DL 432.5 149.8 427 149.8 DL 438 149.8 432.5 149.8 DL
+443.5 149.8 438 149.8 DL 449 149.8 443.5 149.8 DL 454.5 149.8 449 149.8
+DL 460 149.8 454.5 149.8 DL 465.5 149.8 460 149.8 DL 471 149.8 465.5
+149.8 DL 476.5 149.8 471 149.8 DL 482 149.8 476.5 149.8 DL 487.5 149.8
+482 149.8 DL 493 149.8 487.5 149.8 DL 498.5 149.8 493 149.8 DL 504 149.8
+498.5 149.8 DL/F1 11/Times-Roman@0 SF 1.43(After you ha)108 180.1 R
+1.761 -.165(ve c)-.22 H 1.431(reated and re).165 F 1.431
+(gistered a user)-.165 F 1.431(-de\214ned function, your w)-.22 F 1.431
+(ork is essentially)-.11 F(done.)108 193.3 Q/F2 10/Times-Roman@0 SF
+(POSTGRES)5.585 E F1 2.835(,h)C -.275(ow)-2.835 G -2.365 -.275(ev e).275
+H .965 -.44(r, m).275 H .085(ust load the).44 F/F3 11/Times-Italic@0 SF
+.085(object code)2.835 F F1 .085(\(e.g., a)2.835 F/F4 11/Courier@0 SF
+(.o)2.835 E F1 .084(\214le, or a shared library\))2.835 F .536
+(that implements your function.)108 206.5 R .537(As pre)6.036 F .537
+(viously mentioned,)-.275 F F2(POSTGRES)3.287 E F1 .537
+(loads your code at)3.287 F 1.335(run-time, as required.)108 219.7 R
+1.334(In order to allo)6.834 F 4.084(wy)-.275 G 1.334
+(our code to be dynamically loaded, you may)-4.084 F(ha)108 232.9 Q 1.43
+-.165(ve t)-.22 H 3.85(oc).165 G 1.1
+(ompile and link-edit it in a special w)-3.85 F(ay)-.11 E 6.6(.T)-.715 G
+1.1(his section brie\215y describes ho)-6.6 F 3.85(wt)-.275 G(o)-3.85 E
+.666(perform the compilation and link-editing required before you can l\
+oad your user)108 246.1 R(-de\214ned)-.22 E .222
+(functions into a running)108 259.3 R F2(POSTGRES)2.973 E F1(serv)2.973
+E(er)-.165 E 5.723(.N)-.605 G .223(ote that)-5.723 F F3 .223(this pr)
+2.973 F .223(ocess has c)-.495 F(hang)-.165 E .223(ed as of V)-.11 F(er)
+-1.221 E(-)-.22 E .177(sion 4.2.)108 274.7 R/F5 8/Times-Roman@0 SF(11)
+-4.4 I F1 -1.21(Yo)2.927 4.4 O 2.927(us)1.21 G .177(hould e)-2.927 F
+.177
+(xpect to read \(and reread, and re-reread\) the manual pages for the)
+-.165 F 3.075(Cc)108 287.9 S(ompiler)-3.075 E(,)-.44 E F4(cc)3.075 E F1
+.325(\(1\), and the link editor)B(,)-.44 E F4(ld)3.075 E F1 .324
+(\(1\), if you ha)B .654 -.165(ve s)-.22 H .324(peci\214c questions.)
+.165 F .324(In addition,)5.824 F 36.494(the re)108 301.1 R 36.494
+(gression test suites in the directory)-.165 F F4
+(/usr/local/postgres95/src/regress)108 314.3 Q F1 2.851(contain se)5.602
+F -.165(ve)-.275 G 2.851(ral w).165 F 2.851(orking e)-.11 F 2.851
+(xamples of)-.165 F(this process.)108 327.5 Q(If you cop)5.5 E 2.75(yw)
+-.11 G(hat these tests do, you should not ha)-2.75 E .33 -.165(ve a)-.22
+H .33 -.165(ny p).165 H(roblems.).165 E(The follo)108 344.6 Q
+(wing terminology will be used belo)-.275 E(w:)-.275 E(Dynamic loading)
+108 361.7 Q .398(is what)133 374.9 R F2(POSTGRES)3.148 E F1 .399
+(does to an object \214le.)3.149 F .399
+(The object \214le is copied into the running)5.899 F F2(POSTGRES)133
+388.1 Q F1(serv)3.051 E .301(er and the functions and v)-.165 F .3
+(ariables within the \214le are made a)-.275 F -.275(va)-.22 G(ilable)
+.275 E 2.218(to the functions within the)133 401.3 R F2(POSTGRES)4.968 E
+F1(process.)4.969 E F2(POSTGRES)7.719 E F1 2.219(does this using the)
+4.969 F(dynamic loading mechanism pro)133 414.5 Q
+(vided by the operating system.)-.165 E(Loading and link editing)108
+431.6 Q .438(is what you do to an object \214le in order to produce ano\
+ther kind of object \214le \(e.g.,)133 444.8 R .433(an e)133 458 R -.165
+(xe)-.165 G .433(cutable program or a shared library\).).165 F -1.21(Yo)
+5.933 G 3.184(up)1.21 G .434(erform this using the link editing)-3.184 F
+(program,)133 471.2 Q F4(ld)2.75 E F1(\(1\).)A(The follo)108 488.3 Q
+(wing general restrictions and notes also apply to the discussion belo)
+-.275 E -.715(w.)-.275 G 5.5<8350>113.5 505.4 S 1.132(aths gi)-5.665 F
+-.165(ve)-.275 G 3.882(nt).165 G 3.882(ot)-3.882 G(he)-3.882 E/F6 11
+/Times-Bold@0 SF(cr)3.882 E 1.131(eate function)-.198 F F1 1.131
+(command must be absolute paths \(i.e., start with)3.881 F .535(\231/\
+\232\) that refer to directories visible on the machine on which the)
+122.85 518.6 R F2(POSTGRES)3.285 E F1(serv)3.285 E .535(er is)-.165 F
+(running.)122.85 534 Q F5(12)-4.4 I F1 5.5<8354>113.5 547.2 S(he)-5.5 E
+F2(POSTGRES)4.044 E F1 1.294(user must be able to tra)4.044 F -.165(ve)
+-.22 G 1.294(rse the path gi).165 F -.165(ve)-.275 G 4.044(nt).165 G
+4.043(ot)-4.044 G(he)-4.043 E F6(cr)4.043 E 1.293(eate function)-.198 F
+F1 1.102(command and be able to read the object \214le.)122.85 560.4 R
+1.102(This is because the)6.602 F F2(POSTGRES)3.852 E F1(serv)3.853 E
+(er)-.165 E 2.562(runs as the)122.85 573.6 R F2(POSTGRES)5.311 E F1
+(user)5.311 E 5.311(,n)-.44 G 2.561
+(ot as the user who starts up the frontend process.)-5.311 F .32 LW 76
+583.2 72 583.2 DL 80 583.2 76 583.2 DL 84 583.2 80 583.2 DL 88 583.2 84
+583.2 DL 92 583.2 88 583.2 DL 96 583.2 92 583.2 DL 100 583.2 96 583.2 DL
+104 583.2 100 583.2 DL 108 583.2 104 583.2 DL 112 583.2 108 583.2 DL 116
+583.2 112 583.2 DL 120 583.2 116 583.2 DL 124 583.2 120 583.2 DL 128
+583.2 124 583.2 DL 132 583.2 128 583.2 DL 136 583.2 132 583.2 DL 140
+583.2 136 583.2 DL 144 583.2 140 583.2 DL 148 583.2 144 583.2 DL 152
+583.2 148 583.2 DL 156 583.2 152 583.2 DL 160 583.2 156 583.2 DL 164
+583.2 160 583.2 DL 168 583.2 164 583.2 DL 172 583.2 168 583.2 DL 176
+583.2 172 583.2 DL 180 583.2 176 583.2 DL 184 583.2 180 583.2 DL 188
+583.2 184 583.2 DL 192 583.2 188 583.2 DL 196 583.2 192 583.2 DL 200
+583.2 196 583.2 DL 204 583.2 200 583.2 DL 208 583.2 204 583.2 DL 212
+583.2 208 583.2 DL 216 583.2 212 583.2 DL/F7 5/Times-Roman@0 SF(11)93.6
+593.6 Q F5 .445(The old)2.446 3.2 N/F8 7/Times-Roman@0 SF(POSTGRES)2.445
+E F5 .445(dynamic loading mechanism required in-depth kno)2.445 F .445
+(wledge in terms of e)-.2 F -.12(xe)-.12 G .445
+(cutable format, placement and).12 F .174(alignment of e)72 606.4 R -.12
+(xe)-.12 G .174(cutable instructions within memory).12 F 2.174(,e)-.52 G
+.174(tc. on the part of the person writing the dynamic loader)-2.174 F
+4.174(.S)-.44 G .174(uch loaders tended to)-4.174 F .862(be slo)72 616 R
+2.862(wa)-.2 G .862(nd b)-2.862 F(uggy)-.16 E 4.862(.A)-.52 G 2.862(so)
+-4.862 G 2.862(fV)-2.862 G .862(ersion 4.2, the)-3.75 F F8(POSTGRES)
+2.862 E F5 .862(dynamic loading mechanism has been re)2.862 F .861
+(written to use the dynamic loading)-.2 F .698(mechanism pro)72 625.6 R
+.698(vided by the operating system.)-.12 F .699
+(This approach is generally f)4.698 F(aster)-.08 E 2.699(,m)-.32 G .699
+(ore reliable and more portable than our pre)-2.699 F(vious)-.2 E .181
+(dynamic loading mechanism.)72 635.2 R .18
+(The reason for this is that nearly all modern v)4.181 F .18(ersions of)
+-.12 F F8(UNIX)2.18 E F5 .18(use a dynamic loading mechanism to im-)2.18
+F .648(plement shared libraries and must therefore pro)72 644.8 R .648
+(vide a f)-.12 F .648(ast and reliable mechanism.)-.08 F .648
+(On the other hand, the object \214le must be post-)4.648 F .433
+(processed a bit before it can be loaded into)72 654.4 R F8(POSTGRES)
+2.433 E F5 4.433(.W)C 2.433(eh)-5.073 G .433(ope that the lar)-2.433 F
+.432(ge increase in speed and reliability will mak)-.144 F 2.432(eu)-.08
+G 2.432(pf)-2.432 G .432(or the)-2.432 F(slight decrease in con)72 664 Q
+-.12(ve)-.32 G(nience.).12 E F7(12)93.6 674.4 Q F5(Relati)2.257 3.2 M
+.497 -.12(ve p)-.2 H .257(aths do in f).12 F .257(act w)-.08 F .257
+(ork, b)-.08 F .257(ut are relati)-.16 F .497 -.12(ve t)-.2 H 2.257(ot)
+.12 G .257
+(he directory where the database resides \(which is generally in)-2.257
+F .256(visible to the)-.32 F .044(frontend application\).)72 687.2 R(Ob)
+4.044 E(viously)-.12 E 2.044(,i)-.52 G 2.044(tm)-2.044 G(ak)-2.044 E
+.044(es no sense to mak)-.08 F 2.044(et)-.08 G .044(he path relati)
+-2.044 F .284 -.12(ve t)-.2 H 2.044(ot).12 G .044
+(he directory in which the user started the frontend ap-)-2.044 F
+(plication, since the serv)72 696.8 Q
+(er could be running on a completely dif)-.12 E(ferent machine!)-.2 E F6
+(82)282.5 756 Q EP
+%%Page: 83 83
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF 1.887(\(Making the \214le or a higher)122.85
+97.2 R(-le)-.22 E -.165(ve)-.275 G 4.637(ld).165 G 1.887
+(irectory unreadable and/or une)-4.637 F -.165(xe)-.165 G 1.887
+(cutable by the).165 F(\231postgres\232 user is an)122.85 110.4 Q/F1 11
+/Times-Italic@0 SF -.22(ex)2.75 G(tr).22 E(emely)-.407 E F0
+(common mistak)2.75 E(e.\))-.11 E 5.5<8353>113.5 123.6 S 1.373(ymbol na\
+mes de\214ned within object \214les must not con\215ict with each other\
+ or with)-5.5 F(symbols de\214ned in)122.85 136.8 Q/F2 10/Times-Roman@0
+SF(POSTGRES)2.75 E F0(.)A 5.5<8354>113.5 150 S .308
+(he GNU C compiler usually does not pro)-5.5 F .308
+(vide the special options that are required to)-.165 F 1.35
+(use the operating system')122.85 163.2 R 4.1(sd)-.605 G 1.349
+(ynamic loader interf)-4.1 F 4.099(ace. In)-.11 F 1.349
+(such cases, the C compiler)4.099 F
+(that comes with the operating system must be used.)122.85 176.4 Q/F3 12
+/Times-Bold@0 SF(UL)72 202.6 Q(TRIX)-1.104 E F0 .024(It is v)108 219.7 R
+.024(ery easy to b)-.165 F .025
+(uild dynamically-loaded object \214les under UL)-.22 F 2.775(TRIX. UL)
+-1.012 F .025(TRIX does not)-1.012 F(ha)108 232.9 Q 2.587 -.165(ve a)
+-.22 H 2.587 -.165(ny s).165 H 2.257
+(hared-library mechanism and hence does not place an).165 F 5.007(yr)
+-.165 G 2.256(estrictions on the)-5.007 F .204(dynamic loader interf)108
+246.1 R 2.954(ace. On)-.11 F .205
+(the other hand, we had to \(re\)write a non-portable dynamic)2.955 F
+(loader ourselv)108 259.3 Q(es and could not use true shared libraries.)
+-.165 E 1.364(Under UL)108 276.4 R 1.363(TRIX, the only restriction is \
+that you must produce each object \214le with the)-1.012 F(option)108
+289.6 Q/F4 11/Courier@0 SF(-G 0)2.75 E F0 5.5(.\()C(Notice that that')
+-5.5 E 2.75(st)-.605 G(he numeral `)-2.75 E(`)-.814 E F4(0)A F0 1.628
+-.814('' a)D(nd not the letter `).814 E(`)-.814 E F4(O)A F0 -.814('')C
+2.75(\). F).814 F(or e)-.165 E(xample,)-.165 E/F5 10/Courier@0 SF 6(#s)
+184 314.8 S(imple ULTRIX example)-6 E 6(%c)184 327 S 6(c-)-6 G 6(G0-)-6
+G 6(cf)-6 G(oo.c)-6 E F0 1.628(produces an object \214le called)108
+353.2 R F4(foo.o)4.378 E F0 1.628
+(that can then be dynamically loaded into)4.378 F F2(POST)4.379 E(-)-.92
+E(GRES)108 366.4 Q F0 5.5(.N)C 2.75(oa)-5.5 G
+(dditional loading or link-editing must be performed.)-2.75 E F3
+(DEC OSF/1)72 392.6 Q F0 .797(Under DEC OSF/1, you can tak)108 409.7 R
+3.547(ea)-.11 G 1.126 -.165(ny s)-3.547 H .796
+(imple object \214le and produce a shared object \214le).165 F .834
+(by running the)108 422.9 R F4(ld)3.584 E F0 .834(command o)3.584 F
+-.165(ve)-.165 G 3.584(ri).165 G 3.584(tw)-3.584 G .835
+(ith the correct options.)-3.584 F .835(The commands to do this)6.335 F
+(look lik)108 436.1 Q(e:)-.11 E F5 6(#s)184 461.3 S
+(imple DEC OSF/1 example)-6 E 6(%c)184 473.5 S 6(c-)-6 G 6(cf)-6 G(oo.c)
+-6 E 6(%l)184 485.7 S 6(d-)-6 G
+(shared -expect_unresolved '*' -o foo.so foo.o)-6 E F0 .224
+(The resulting shared object \214le can then be loaded into)108 511.9 R
+F2(POSTGRES)2.974 E F0 5.724(.W)C .224(hen specifying the)-5.724 F .062
+(object \214le name to the)108 525.1 R/F6 11/Times-Bold@0 SF(cr)2.812 E
+.062(eate function)-.198 F F0 .063(command, one must gi)2.812 F .393
+-.165(ve i)-.275 H 2.813(tt).165 G .063(he name of the shared)-2.813 F
+.996(object \214le \(ending in)108 540.5 R F4(.so)3.746 E F0 3.746(\)r)C
+.996(ather than the simple object \214le.)-3.746 F/F7 8/Times-Roman@0 SF
+(13)-4.4 I F0 .996(If the \214le you specify is)3.746 4.4 N
+(not a shared object, the back)108 553.7 Q(end will hang!)-.11 E F3
+(SunOS 4.x, Solaris 2.x and HP-UX)72 579.9 Q F0 .348(Under both SunOS 4\
+.x, Solaris 2.x and HP-UX, the simple object \214le must be created by)
+108 597 R 1.225
+(compiling the source \214le with special compiler \215ags)108 610.2 R
+F1(and)3.976 E F0 3.976(as)3.976 G 1.226(hared library must be pro-)
+-3.976 F(duced.)108 623.4 Q .32 LW 76 633 72 633 DL 80 633 76 633 DL 84
+633 80 633 DL 88 633 84 633 DL 92 633 88 633 DL 96 633 92 633 DL 100 633
+96 633 DL 104 633 100 633 DL 108 633 104 633 DL 112 633 108 633 DL 116
+633 112 633 DL 120 633 116 633 DL 124 633 120 633 DL 128 633 124 633 DL
+132 633 128 633 DL 136 633 132 633 DL 140 633 136 633 DL 144 633 140 633
+DL 148 633 144 633 DL 152 633 148 633 DL 156 633 152 633 DL 160 633 156
+633 DL 164 633 160 633 DL 168 633 164 633 DL 172 633 168 633 DL 176 633
+172 633 DL 180 633 176 633 DL 184 633 180 633 DL 188 633 184 633 DL 192
+633 188 633 DL 196 633 192 633 DL 200 633 196 633 DL 204 633 200 633 DL
+208 633 204 633 DL 212 633 208 633 DL 216 633 212 633 DL/F8 5
+/Times-Roman@0 SF(13)93.6 643.4 Q F7(Actually)2.723 3.2 M(,)-.52 E/F9 7
+/Times-Roman@0 SF(POSTGRES)2.723 E F7 .723(does not care what you name \
+the \214le as long as it is a shared object \214le.)2.723 F .724
+(If you prefer to name your)4.724 F .041
+(shared object \214les with the e)72 656.2 R(xtension)-.12 E/F10 8
+/Courier@0 SF(.o)2.041 E F7 2.041(,t)C .041(his is \214ne with)-2.041 F
+F9(POSTGRES)2.041 E F7 .041(so long as you mak)2.041 F 2.041(es)-.08 G
+.04(ure that the correct \214le name is gi)-2.041 F -.12(ve)-.2 G 2.04
+(nt).12 G 2.04(ot)-2.04 G(he)-2.04 E/F11 8/Times-Bold@0 SF(cr)72 665.8 Q
+.331(eate function)-.144 F F7 2.331(command. In)2.331 F .331(other w)
+2.331 F .331(ords, you must simply be consistent.)-.08 F(Ho)4.331 E(we)
+-.2 E -.12(ve)-.2 G .971 -.32(r, f).12 H .332
+(rom a pragmatic point of vie).32 F 1.372 -.52(w, w)-.2 H 2.332(ed).52 G
+(iscourage)-2.332 E .626
+(this practice because you will undoubtedly confuse yourself with re)72
+675.4 R -.04(ga)-.12 G .626(rds to which \214les ha).04 F .865 -.12
+(ve b)-.16 H .625(een made into shared object \214les and).12 F .557
+(which ha)72 685 R .797 -.12(ve n)-.16 H 2.557(ot. F).12 F .557(or e)
+-.12 F .558(xample, it')-.12 F 2.558(sv)-.44 G .558(ery hard to write)
+-2.678 F F10(Makefile)2.558 E F7 2.558(st)C 2.558(od)-2.558 G 2.558(ot)
+-2.558 G .558
+(he link-editing automatically if both the object \214le and the)-2.558
+F(shared object \214le end in)72 694.6 Q F10(.o)2 E F7(!)A F6(83)282.5
+756 Q EP
+%%Page: 84 84
+%%BeginPageSetup
+BP
+%%EndPageSetup
+/F0 11/Times-Roman@0 SF .671
+(The necessary steps with HP-UX are as follo)108 97.2 R 3.42(ws. The)
+-.275 F/F1 11/Courier@0 SF(+z)3.42 E F0 .67
+(\215ag to the HP-UX C compiler)3.42 F 1.752
+(produces so-called \231Position Independent Code\232 \(PIC\) and the)
+108 110.4 R F1(+u)4.502 E F0 1.752(\215ag remo)4.502 F -.165(ve)-.165 G
+4.502(ss).165 G(ome)-4.502 E 1.207(alignment restrictions that the P)108
+123.6 R 1.207(A-RISC architecture normally enforces.)-1.012 F 1.206
+(The object \214le)6.706 F 1.607(must be turned into a shared library u\
+sing the HP-UX link editor with the)108 136.8 R F1(-b)4.357 E F0
+(option.)4.357 E .109(This sounds complicated b)108 150 R .109
+(ut is actually v)-.22 F .108
+(ery simple, since the commands to do it are just:)-.165 F/F2 10
+/Courier@0 SF 6(#s)184 175.2 S(imple HP-UX example)-6 E 6(%c)184 187.4 S
+6(c+)-6 G 6(z+)-6 G 6(u-)-6 G 6(cf)-6 G(oo.c)-6 E 6(%l)184 199.6 S 6(d-)
+-6 G 6(b-)-6 G 6(of)-6 G(oo.sl foo.o)-6 E F0 1.502(As with the)108 225.8
+R F1(.so)4.252 E F0 1.503(\214les mentioned in the last subsection, the)
+4.253 F/F3 11/Times-Bold@0 SF(cr)4.253 E 1.503(eate function)-.198 F F0
+(command)4.253 E .378(must be told which \214le is the correct \214le t\
+o load \(i.e., you must gi)108 239 R .708 -.165(ve i)-.275 H 3.128(tt)
+.165 G .378(he location of the)-3.128 F(shared library)108 252.2 Q 2.75
+(,o)-.715 G(r)-2.75 E F1(.sl)2.75 E F0(\214le\).)2.75 E
+(Under SunOS 4.x, the commands look lik)108 269.3 Q(e:)-.11 E F2 6(#s)
+184 294.5 S(imple SunOS 4.x example)-6 E 6(%c)184 306.7 S 6(c-)-6 G
+(PIC -c foo.c)-6 E 6(%l)184 318.9 S 6(d-)-6 G
+(dc -dp -Bdynamic -o foo.so foo.o)-6 E F0(and the equi)108 345.1 Q -.275
+(va)-.275 G(lent lines under Solaris 2.x are:).275 E F2 6(#s)184 370.3 S
+(imple Solaris 2.x example)-6 E 6(%c)184 382.5 S 6(c-)-6 G 6(KP)-6 G
+(IC -c foo.c)-6 E(or)220 394.7 Q 6(%g)184 406.9 S(cc -fPIC -c foo.c)-6 E
+6(%l)184 419.1 S 6(d-)-6 G 6(G-)-6 G(Bdynamic -o foo.so foo.o)-6 E F0
+.827(When linking shared libraries, you may ha)108 445.3 R 1.157 -.165
+(ve t)-.22 H 3.577(os).165 G .827
+(pecify some additional shared libraries)-3.577 F(\(typically system li\
+braries, such as the C and math libraries\) on your)108 458.5 Q F1(ld)
+2.75 E F0(command line.)2.75 E F3(84)282.5 756 Q EP
+%%Trailer
+end
+%%EOF