-
+
PostgresIP Types Examples
+
- Input
- Output
+ CIDR Input
+ CIDR Displayed
|
- select '192.168.1'::cidr
+ 192.168.1
192.168.1/24
|
- select '192.168'::cidr
+ 192.168
192.168.0/24
|
- select '128.1'::cidr
+ 128.1
128.1/16
|
- select '128':::cidr
+ 128
128.0/16
|
- select '128.1.2'::cidr
+ 128.1.2
128.1.2/24
|
- select '10.1.2'::cidr
+ 10.1.2
10.1.2/24
|
- select '10.1'::cidr
+ 10.1
10.1/16
|
- select '10'::cidr
+ 10
10/8
-
Introduction
+
The Documentation Project
Packaged documentation is available in both
for several reasons, including the inability to make minor format
fixes before committing to hardcopy and generally inadequate table
-stylesheets.
+stylesheets.
-1>
+2>
Styles and Conventions
-->
-
-
-
-
Document Writing
-
-
-
Document Structure
-
-There are currently five separate documents written in DocBook. Each document
-has a container source document which defines the DocBook environment and other
-document source files. These primary source files are located in
-doc/src/sgml/, along with many of the other source files
-used for the documentation. The primary source files are:
-
-
-
-postgres.sgml
-
-This is the integrated document, including all other documents.
-
-
-
-
-
-tutorial.sgml
-
-The introductory tutorial, with examples. Does not include programming topics,
-and is intended to help get someone unfamiliar with
SQL started.
-
-
-
-
-
-user.sgml
-
-The User's Guide. Includes information on data types and user-level interfaces.
-This is the place to put information on "why".
-
-
-
-
-
-reference.sgml
-
-The Reference Manual. Includes
Postgres SQL syntax.
-
-
-
-
-
-programming.sgml
-
-The Programmer's Guide. Includes information on
Postgres
-extensibility and on the programming interfaces.
-
-
-
-
-
-admin.sgml
-
-The Administrator's Guide. Include installation and release notes.
-
-
-
-
-
Authoring Tools
-
Hardcopy Generation for v6.3
+
Hardcopy Generation for v6.4
The hardcopy Postscript documentation is generated by converting the
SGML source code to
RTF, then
-importing into Applixware. After a little cleanup (see the following
-section) the output is "printed" to a postscript file.
+importing into
ApplixWare-4.4.1.
+After a little cleanup (see the following
+section) the output is "printed" to a postscript file.
Some figures were redrawn to avoid having bitmap
following commands:
-% convert -v -geometry 400x400'>' figure03.gif con.gif
-% convert -v -crop 400x380 con.gif connections.gif
-
+% convert -monochrome -v -geometry 500x500'>' catalogs.ps catalogs.gif
+% convert -v -crop 400x500 catalogs.gif catalogs-cropped.gif
+
+
+
We understand that there are some other packaged distributions for
these tools.
FreeBSD seems to have them
available. Please report package status to the docs mailing list and
-we will include that information here.
+we will include that information here.
Manual installation of tools
-
This is a brief run-through of the process of obtaining and
+This is a brief run-through of the process of obtaining and
installing the software you'll need to edit DocBook source with Emacs
and process it with Norman Walsh's DSSSL style sheets to create
HTML
+
+These instructions do not cover new
jade/DocBook
+support in the
sgml-tools package. The authors have
+not tried this package since it adopted DocBook, but it is almost certainly
+a good candidate for use.
Prerequisites
Norman Walsh's
Modular Stylesheets
-version 1.07
+version 1.19
Robin Cover's database of
SGML software
-
-
-Installing Jade
+
+
Installing Jade
-
First, read the installation instructions at the above listed
-URL.
+
Installing Jade
+
+
+Read the installation instructions at the above listed
+URL.
-
Unzip the distribution kit in a suitable place. The command to do
+
+Unzip the distribution kit in a suitable place. The command to do
this will be something like
unzip -aU jade1_1.zip
+
GNU Autoconf, so you'll need to edit a
Makefile yourself. Since James Clark has been
Makefile.
-
Now type make to build Jade and the various
+
+
Type make to build Jade and the various
+
Once the software is built, make install will
do the obvious.
-
+
+
+
+
Installing the DocBook DTD Kit
+
Installing the DocBook DTD Kit
+
You'll want to place the files that make up the
directory you built
Jade to expect them in,
CATALOG /usr/local/share/sgml/CATALOG
+
+
The CATALOG file should then contain three types
of lines. The first is the (optional)
SGML
declaration, thus:
PUBLIC "-//Davenport//ELEMENTS DocBook Document Hierarchy V3.0//EN" dbhier.mod
PUBLIC "-//Davenport//ENTITIES DocBook Additional General Entities V3.0//EN" dbgenent.mod
+
+
Of course, a file containing these comes with the
DocBook kit. Note that the last item on
each of these lines is a file name, given here without a path. You
accompany the entity kit you fetch.
-sect3>
+procedure>
-
Installing Norman Walsh's DSSSL
-style sheets
+
+
Installing Norman Walsh's DSSSL Style Sheets
+
+
Installing Norman Walsh's DSSSL Style Sheets
-
First, read the installation instructions at the above listed
+
+
Read the installation instructions at the above listed
URL.
+
To install Norman's style sheets, simply unzip the distribution
kit in a suitable place. A good place to dot this would be
/usr/local/share, which places the kit in a
+
One way to test the installation is to build the
HTML and
RTF forms of the
-
PostgreSQL manual. Go to the
SGML source
+
+
+
+
+To build the
HTML files,
directory, doc/src/sgml, and say
jade -t sgml -d /usr/local/share/docbook/html/docbook.dsl -D ../graphics postgres.sgml
-to build the
HTML files ("book1.htm" is the top level node), and
+
+book1.htm is the top level node of the output..
+
+
+To generate the
RTF output, ready for importing
+into your favorite word processing system and printing, type:
jade -t rtf -d /usr/local/share/docbook/print/docbook.dsl -D ../graphics postgres.sgml
-to generate the
RTF output, ready for importing
-into your favorite word processing system and printing.
-
+
+
+
+
+
-
First, read the installation instructions at the above listed
+
+
Read the installation instructions at the above listed
URL.
+
Unpack the distribution file, run configure, make and make
install to put the byte-compiled files and info library in place.
+
+
Then add the following lines to your
/usr/local/share/emacs/site-lisp/site-start.el
file to make
Emacs properly load
(cons "/usr/local/share/emacs/site-lisp/psgml" load-path))
(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
+
+
If you want to use
PSGML when editing
+
+
There is one important thing to note with
PSGML: its author assumed that your main
SGML DTD directory would be
/usr/local/lib/sgml. If, as in the examples in
this chapter, you use /usr/local/share/sgml, you
-have to compensate for this. You can set the
-SGML_CATALOG_FILES environment variable, you can
+have to compensate for this.
+
+
+
+You can set the
+SGML_CATALOG_FILES environment variable.
+
+
+You can
customize your
PSGML installation (its
-manual tells you how), or you can even edit the source file
+manual tells you how).
+
+
+You can even edit the source file
psgml.el before compiling and installing
PSGML, changing the hard-coded paths to
match your own default.
-
+
+
+
-
Optional: installing JadeTeX
If you want to, you can also install
Alternate Toolsets
+and
DocBook. It may be the preferred toolset
+for working with
SGML but we have not had a chance to
+evaluate the new package.
+
+
+
Information for
Postgres developers. This is intended
for those who are contributing to the
Postgres
-project; application development information should appear in the Programmer's Guide.
+project; application development information should appear in the
+Programmer's Guide.
+Currently included in the Programmer's Guide.
Detailed reference information on command syntax.
-At the moment, this manual is very sparse, but eventually should contain
-information similar to that in the man pages.
+Currently included in the User's Guide.
the build process (see the --prefix option below). Type
$ cd /usr/src/pgsql/src
-$ ./configure [ options as described below ]
+$ ./configure [ options ]
+
+
+
Among other chores, the configure script selects a system-specific
"template" file from the files provided in the template subdirectory.
If it cannot guess which one to use for your system, it will say so and
exit. In that case you'll need to figure out which one to use and run
- configure again, this time giving the option to
+ configure again, this time giving the
+ option to
make the right file be chosen.
+
+Choose configuration options. Check
+for details. However, for a plain-vanilla first installation with no extra
+options like multi-byte character support or locale collation support it may
+be adequate to have chosen the installation areas and to run configure without
+extra options specified.
+
The configure script accepts many additional options that you can use
if you don't like the default configuration. To see them all, type
--prefix=BASEDIR Selects a different base directory for the
installation of the
Postgres configuration.
The default is /usr/local/pgsql.
-
--with-template=TEMPLATE
Use template file TEMPLATE - the template
files are assumed to be in the directory
src/template, so look there for proper values.
-
- --with-pgport=PORT Sets the port that the postmaster process
- listens for incoming connections on. The
- default is port 5432.
-
--with-tcl Build interface libraries and programs requiring
Tcl/Tk, including libpgtcl, pgtclsh, and pgtksh.
-
--with-perl Build the Perl interface library.
-
--with-odbc Build the ODBC driver package.
-
--enable-hba Enables Host Based Authentication (DEFAULT)
-
--disable-hba Disables Host Based Authentication
-
--enable-locale Enables USE_LOCALE
-
--enable-cassert Enables ASSERT_CHECKING
-
--with-CC=compiler
Use a specific C compiler that the configure
script cannot find.
-
--with-CXX=compiler
--without-CXX
Use a specific C++ compiler that the configure
+
-As an example, here is the configure script used on a Sparc Solaris 2.5 system
- with /opt/postgres being the installation base directory:
+Here is the configure script used on a Sparc Solaris 2.5 system
+ with /opt/postgres specified as
+ the installation base directory:
$ ./configure --prefix=/opt/postgres \
--enable-hba --disable-locale
+
Of course, you may type these three lines all
on the same line.
+
+
+
+
Install the
HTML documentation. Type
Any account that will use
Postgres must
be similarly prepared.
-
-There are several ways to influence the runtime environment of the
Postgres
-server. Refer to the chapter on Administrator's Guide for more information.
+There are several ways to influence the runtime environment of the
+server. Refer to the Administrator's Guide
+ for more information.
+
+
The following instructions are for a
bash/sh shell. Adapt accordingly for other shells.
+
+
+
- Add the following lines to your login shell, ~/.bash_profile:
+ Add the following lines to your login environment:
+
+ shell, ~/.bash_profile:
PATH=$PATH:/usr/local/pgsql/bin
MANPATH=$MANPATH:/usr/local/pgsql/man
+
+Several regression tests could failed if the user's locale collation
+scheme is different from that of standard C locale.
+
+If you configure and compile
Postgres
+ with the option then
+ set locale environment to C (or unset all LC_* variables)
+by putting these additional lines to your login environment
+ before starting postmaster:
+LC_COLLATE=C
+LC_CTYPE=C
+LC_COLLATE=C
+export LC_COLLATE LC_CTYPE LC_COLLATE
+
+
+
+
+
+
+
Make sure that you have defined these variables before continuing
with the remaining steps. The easiest way to do this is to type:
+
+
- Create the database. Do not do the following as root!
- This would be a major security hole. Type
+ Create the database installation from your
Postgres
+superuser account (typically account postgres).
+
+Do not do the following as root!
+This would be a major security hole. Type
$ initdb
- Run postmaster from your
Postgres superuser account (typically
- account postgres).
-
Do not run postmaster from the root account!
+Briefly test that the backend will start and run by running it from
+the command line.
+
+
+
+
Start the postmaster daemon running in the background by typing
+$ cd
+$ postmaster -i
+
+
+
+
+
+Create a database by typing
+$ createdb
+
+
+
+Connect to the new database:
+$ psql
+
+
+
+And run a sample query:
+postgres=> SELECT datetime 'now';
+
+
+
+postgres=> \q
+
+
+
+Remove the test database (unless you will want to use it later for other tests):
+$ destroydb
+
+
+
+
+
+ Run postmaster in the background from your
Postgres
+superuser account (typically account postgres).
+from the root account!
+
+Usually, you will want to modify
+ your computer so that it will automatically start postmaster whenever
+ it boots. It is not required; the
Postgres
+server can
+be run successfully from non-privileged accounts without root intervention.
+
+ Here are some suggestions on how to do this, contributed by various
+ users.
+
+ Whatever you do, postmaster must be run by
+the
Postgres superuser (
postgres?)
+and not by root.
+This is why all of the examples below start by switching user
+ (su) to postgres. These commands also take into account the fact
+ that environment variables like PATH and PGDATA may not be set properly.
+
+ The examples are as follows. Use them with extreme caution.
+
+
+
+If you are installing from a non-privileged account and have no root access, then
+start the
postmaster and send it to the background:
+
$ cd
$ nohup postmaster > regress.log 2>&1 &
+
+
+Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris
+ 2.5.1 to contain the following single line:
+su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
+
+
+
+In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
+ contain the following lines and make it chmod 755 and chown
+ root:bin.
+
+#!/bin/sh
+[ -x /usr/local/pgsql/bin/postmaster ] && {
+ su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
+ -D/usr/local/pgsql/data
+ -S -o -F > /usr/local/pgsql/errlog' &
+ echo -n ' pgsql'
+}
+
+
+ You may put the line breaks as shown above. The shell is smart
+ enough to keep parsing beyond end-of-line if there is an
+ expression unfinished. The exec saves one layer of shell under
+ the postmaster process so the parent is init.
+
+
+In RedHat Linux add a file /etc/rc.d/init.d/postgres.init
+which is based on the example in contrib/linux/.
+Then make a softlink to this file from
+ /etc/rc.d/rc5.d/S98postgres.init.
+
+
+In RedHat Linux edit file /etc/inittab to add the
+ following as a single line:
+
+pg:2345:respawn:/bin/su - postgres -c
+ "/usr/local/pgsql/bin/postmaster -D/usr/local/pgsql/data
+ >> /usr/local/pgsql/server.log 2>&1 </dev/null"
+
+
+ (The author of this example says this example will revive the
+ postmaster if it dies, but he doesn't know if there are other side
+ effects.)
+
+
+
-
- If you haven't already done so, this would be a good time to modify
- your computer so that it will automatically start postmaster whenever
- you boot your computer.
-
- Here are some suggestions on how to do this, contributed by various
- users.
-
- Whatever you do, postmaster must be run by
-the
Postgres superuser (
postgres?)
-and not by root.
-This is why all of the examples below start by switching user
- (su) to postgres. These commands also take into account the fact
- that environment variables like PATH and PGDATA may not be set properly.
-
- The examples are as follows. Use them with extreme caution.
-
-
-
-Edit file rc.local on NetBSD or file rc2.d on SPARC Solaris
- 2.5.1 to contain the following single line:
-su postgres -c "/usr/local/pgsql/bin/postmaster -S -D /usr/local/pgsql/data"
-
-
-
-In FreeBSD 2.2-RELEASE edit /usr/local/etc/rc.d/pgsql.sh to
- contain the following lines and make it chmod 755 and chown
- root:bin.
-
-#!/bin/sh
-[ -x /usr/local/pgsql/bin/postmaster ] && {
- su -l pgsql -c 'exec /usr/local/pgsql/bin/postmaster
- -D/usr/local/pgsql/data
- -S -o -F > /usr/local/pgsql/errlog' &
- echo -n ' pgsql'
-}
-
-
- You may put the line breaks as shown above. The shell is smart
- enough to keep parsing beyond end-of-line if there is an
- expression unfinished. The exec saves one layer of shell under
- the postmaster process so the parent is init.
-
-
-In RedHat Linux add a file /etc/rc.d/init.d/postgres.init
-which is based on the example in contrib/linux/.
-Then make a softlink to this file from
- /etc/rc.d/rc5.d/S98postgres.init.
-
-
-In RedHat Linux edit file /etc/inittab to add the
- following as a single line:
-
-pg:2345:respawn:/bin/su - postgres -c
- "/usr/local/pgsql/bin/postmaster -D/usr/local/pgsql/data
- >> /usr/local/pgsql/server.log 2>&1 </dev/null"
-
-
- (The author of this example says this example will revive the
- postmaster if it dies, but he doesn't know if there are other side
- effects.)
-
-
-
-
-
-
If you haven't already done so, this would be a good time to modify
-
PostgreSQL Administrator's Guide
+
PostgreSQL Installation Guide
- Covering v6.3 for general release
+ Covering v6.4 for general release
The PostgreSQL Development Team
&ports;
+&config;
&install;
&release;
loading techniques for performance reasons,
The Makefile will generate the jar archive.
-<para>
+</note>
Installing the Driver
-
Preparing the database for JDBC
+
Preparing the Database for JDBC
Because Java can only use TCP/IP connections, the
Postgres postmaster
host all 127.0.0.1 255.255.255.255 password
-Here access to all databases are possible from the local machine with
JDBC.
+Here access to all databases are possible from the local machine
-The
JDBC Driver supports trust, ident, password and crypt authentication methods.
+The
JDBC Driver supports trust, ident,
+password and crypt authentication methods.
-jdbc:postgresql:database
+jdbc:postgresql:">database
-jdbc:postgresql://>host/>database
+jdbc:postgresql://">host/>database
-jdbc:postgresql://>host:port/>database
+jdbc:postgresql://">host:port/>database
where:
-host
+">host
-port
+">port
-database
+">database
-
Issuing a query and processing the result
+
Issuing a Query and Processing the Result
Any time you want to issue SQL statements to the database, you require a
the entire result.
-1>
-
Some notes about using the Statement interface:
+2>
+
Using the Statement Interface
-
+The following must be considered when using the Statement interface:
+
+
You can use a Statement instance as many times as you want. You could
-1>
-
Some notes about using the ResultSet interface:
+2>
+
Using the ResultSet Interface
-
+The following must be considered when using the ResultSet interface:
+
+
-Before reading any values, you must call next(). This returns true if
+Before reading any values, you must call next(). This returns true if
there is a result, but more importantly, it prepares the row for processing.
Under the
JDBC spec, you should access a field only once. It's safest
to stick to this rule, although at the current time, the
Postgres driver
will allow you to access a field as many times as you want.
+
-You must close() a ResultSet once you have finished with it.
+You must close a ResultSet by calling close() once you have finished with it.
+
Once you request another query with the Statement used to create a
-ResultSet, the currently open instance is closed().
+ResultSet, the currently open instance is closed.
+An example is as follows:
+
Statement st = db.createStatement();
ResultSet rs = st.executeQuery(select * from mytable);
while(rs.next()) {
-
-
-System.out.print(Column 1 returned );
-
-System.out.println(rs.getString(1));
+ System.out.print(Column 1 returned );
+ System.out.println(rs.getString(1));
}
rs.close();
st.close();
-itemizedlist>
+programlisting>
-
Performing updates
+
Performing Updates
To perform an update (or any other SQL statement that does not return a
result), you simply use the executeUpdate() method:
- st.executeUpdate(create table basic (a int2, b int2));
+st.executeUpdate(create table basic (a int2, b int2));
+
+
-
Closing the connection
+
Closing the Connection
To close the database connection, simply call the close() method to the Connection:
db.close();
-<para>
+</programlisting>
Using Large Objects
-In
Postgres, large objects (also known as BLOBS) are used to hold data in
+large objects (also known as blobs) are used to hold data in
the database that cannot be stored in a normal SQL table. They are stored as a
Table/Index pair, and are refered to from your own tables, by an OID value.
method in ResultSet, and setBinaryStream() method in PreparedStatement. These
methods make the large object appear as a Java stream, allowing you to use the
java.io package, and others, to manipulate the object.
+
-Example:
-You have a table containing the file name of an image, and a large object
+For example, suppose
+you have a table containing the file name of an image, and a large object
containing that image:
- create table images (imgname name,imgoid oid);
+
+create table images (imgname name,imgoid oid);
+
+
To insert an image, you would use:
-
-
+
File file = new File(myimage.gif);
-
FileInputStream fis = new FileInputStream(file);
-
-PreparedStatement ps = conn.prepareStatement(insert into images
-values (?,?));
-
+PreparedStatement ps = conn.prepareStatement(insert into images values (?,?));
ps.setString(1,file.getName());
-
ps.setBinaryStream(2,fis,file.length());
-
ps.executeUpdate();
-
ps.close();
-
fis.close();
-itemizedlist>
+programlisting>
Now in this example, setBinaryStream transfers a set number of bytes from a
stream into a large object, and stores the OID into the field holding a
reference to it.
+
Retrieving an image is even easier (I'm using PreparedStatement here, but
Statement can equally be used):
-
-
-PreparedStatement ps = con.prepareStatement(select oid from
-images where name=?);
-
+
+PreparedStatement ps = con.prepareStatement(select oid from images where name=?);
ps.setString(1,myimage.gif);
-
ResultSet rs = ps.executeQuery();
-
if(rs!=null) {
-
while(rs.next()) {
-
- InputStream is = rs.getBinaryInputStream(1);
-
- // use the stream in some way here
-
- is.close();
-
+ InputStream is = rs.getBinaryInputStream(1);
+ // use the stream in some way here
+ is.close();
}
-
rs.close();
-
}
-
ps.close();
-itemizedlist>
+programlisting>
Now here you can see where the Large Object is retrieved as an InputStream.
You'll also notice that we close the stream before processing the next row in
the result. This is part of the
JDBC Specification, which states that any
InputStream returned is closed when ResultSet.next() or ResultSet.close() is called.
Postgres Extensions to the JDBC API
-
Postgres is an extensible database system. You can add your own functions
+
Postgres is an extensible database system.
+You can add your own functions
to the backend, which can then be called from queries, or even add your own
data types.
Now, as these are facilities unique to us, we support them from Java, with
-a set of extension
API's. Some features within the core of the standard driver
+a set of extension
API's. Some features within
+the core of the standard driver
actually use these extensions to implement Large Objects, etc.
+************************************************************
+Nothing marked up from here on. It looks like it will be tricky:
+what do we want to do with the class inheritance diagrams?
+- thomas 1998-10-23
+************************************************************
+-->
+
Accessing the extensions
Documentation (supplied with Sun's
JDK),
and the
JDBC Specification.
Both are available on
contains updated information not included in this
document, and also includes precompiled drivers for v6.4, and earlier.
pgtcl
-pgtcl is a tcl package for front-end programs to interface with
Postgres
-backends. It makes most of the functionality of libpq available to
+pgtcl is a tcl package for front-end programs
+to interface with
Postgres
+backends. It makes most of the functionality of libpq available to
tcl scripts.
-
PGTCL Commands
+
pgtcl Commands
|
Enabling ApplixWare Database Access
-Note that
-these instructions are for the 4.4.1 release of
+These instructions are for the 4.4.1 release of
Refer to the Linux Sys Admin on-line book
for more detailed information.
Ports
-
-
Currently Supported Platforms
-
This manual describes version 6.4 of
Postgres.
The
Postgres developer community has
-compiled and tested
Postgres on the following
-platforms:
+compiled and tested
Postgres on a
+number of platforms. Check
+for the latest information.
+
+
+
Currently Supported Platforms
+
+At the time of publication, the following platforms have been tested:
Supported Platforms
|
- AIX 4.1.x-4.2
+ AIX 4.2.1
RS6000
- v6.3
- 1998-03-01
-
4.1.4.0,4.2 (Darren King),
- 4.1.5 (
Andreas Zeugswetter);
- 3.2.5 confirmed on v6.2.1 (
Frank Dana)
+ v6.4
+ 1998-10-27
|
BSDI
|
FreeBSD 2.2.x-3.x
x86
- v6.3
- 1998-03-01
+ v6.4
+ 1998-10-26
- |
- NetBSD 1.3.2
- x86
- v6.4
- 1998-10-25
-
- |
- NetBSD 1.3
- NS32532
- v6.3
- 1998-07-20
-
- |
- NetBSD 1.3
- Sparc
- v6.3
- 1998-03-01
-
- |
- NetBSD 1.3
- VAX
- v6.3
- 1998-03-01
-
|
DGUX 5.4R4.11
m88k
v6.3
1998-03-01
+
v6.4 probably OK. Needs new maintainer. (Brian E Gallew)
+
+ |
+ Digital Unix 4.0
+ Alpha
+ v6.4
+ 1998-10-29
+ Minor patchable problems
|
HPUX
5.x is different
- |
- Digital 4.0
- Alpha
- v6.3.2
- 1998-04-16
- reported working for DUnix/v3.2g
-
|
linux 2.0.x
Alpha
v6.3.2
1998-04-16
- mostly successful
+ Mostly successful. Needs work for v6.4.
|
linux 2.0.x
x86
v6.4
- 1998-10-09
+ 1998-10-27
|
linux 2.0.x/glibc2
|
- mklinux
+ linuxPPC 2.1.24
+ PPC603e
+ v6.4
+ 1998-10-26
+
Powerbook 2400c(Tatsuo Ishii)
+
+ |
+ mklinux DR3
PPC750
v6.4
1998-09-16
+
PowerMac 7600 (Tatsuo Ishii)
|
- SCO
+ NetBSD/i386 1.3.2
x86
+ v6.4
+ 1998-10-25
+
+ |
+ NetBSD-current
+ NS32532
+ v6.4
+ 1998-10-27
+
(small problems in date/time math (Jon Buller)
+
+ |
+ NetBSD/sparc 1.3H
+ Sparc
+ v6.4
+ 1998-10-27
+
+ |
+ NetBSD 1.3
+ VAX
v6.3
1998-03-01
- partial success
|
- Solaris
+ SCO UnixWare 2.x
x86
v6.3
1998-03-01
+ aka UNIVEL
+
+ |
+ SCO UnixWare 7
+ x86
+ v6.4
+ 1998-10-04
+
+ |
+ Solaris
+ x86
+ v6.4
+ 1998-10-28
|
- Solaris 2.5.1-2.6
+ Solaris 2.6-2.7
Sparc
v6.4
- 1998-10-25
+ 1998-10-28
|
SunOS 4.1.4
SVR4
MIPS
v6.4
- 1998-10-08
+ 1998-10-28
no 64-bit int support
confirmed with patching
- |
- Unixware
- x86
- v6.4
- 1998-10-04
- aka UNIVEL
-
|
Windows NT
x86
-
PostgreSQL is copyright (C) 1998 by the Postgres Global Development Group.
+
PostgreSQL is copyright (C) 1998
+by the Postgres Global Development Group.
PostgreSQL Programmer's Guide
- Covering v6.3 for general release
+ Covering v6.4 for general release
The PostgreSQL Development Team
-->
- (last updated 1998-02-24)
+ (last updated 1998-10-27)
-->
Summary
&xaggr;
&rules;
&xindex;
-&xplang;
&gist;
+&xplang;
&dfunc;
+
+
&trigger;
&spi;
&lobj;
The arch-dev chapter is current almost identical
to the arch-pg chapter appearing earlier in the
Programmer's Guide. If the Developer's Guide is
-split into a separate document the start using this
+split into a separate document then start using this
again.
- thomas 1998-10-23
&arch-dev;
&biblio;
+
+$Log: reference.sgml,v $
+Revision 1.4 1998/10/30 19:37:12 thomas
+Minor editing and markup changes as a result of preparing the Postscript
+ documentation for v6.4.
+Bigger updates to the installation instructions (install and config).
+
+
+-->
-
PostgreSQL is copyright (C) 1998 by the Postgres Global Development Group.
+
PostgreSQL is copyright (C) 1998
+by the Postgres Global Development Group.
&commands;
+
+
&biblio;
+
Server Programming Interface
- The
Server Programming Interface (
SPI) is an attempt to give users the
-ability to run
SQL queries inside user-defined
C functions.
-Given the lack
-of a proper
Procedural Language (
PL) in the current version of
-
SPI is the only way to write server-stored procedures and triggers. In the future
-
SPI will be used as the "workhorse" for a
PL.
+The Server Programming Interface
+ability to run
SQL queries inside user-defined
+The available Procedural Languages (
PL) give an alternate
+means to access these capabilities.
- In fact,
SPI is just a set of native interface functions to simplify
-access to the Parser, Planner, Optimizer and Executor.
SPI also does some
-memory management.
+In fact,
SPI is just a set of native interface functions
+to simplify access to the Parser, Planner, Optimizer and Executor.
+
SPI also does some memory management.
- To avoid misunderstanding we'll use
function to mean
SPI interface
-functions and
procedure for user-defined C-functions using
SPI.
+To avoid misunderstanding we'll use function
+to mean
SPI interface functions and
+procedure for user-defined C-functions
-
SPI procedures are always called by some (upper) Executor and the
SPI
+
SPI procedures are always called by some (upper)
manager uses the Executor to run your queries. Other procedures may be
called by the Executor running queries from your procedure.
- Note, that if during execution of a query from a procedure the transaction
+Note, that if during execution of a query from a procedure the transaction
is aborted then control will not be returned to your procedure. Rather, all work
will be rolled back and the server will wait for the next command from the
client. This will be changed in future versions.
- Other restrictions are the inability to execute BEGIN, END and ABORT
+Other restrictions are the inability to execute BEGIN, END and ABORT
(transaction control statements) and cursor operations. This will also be
changed in the future.
-
If successful,
SPI functions return a non-negative result (either via
+If successful,
SPI functions return a non-negative result (either via
a returned integer value or in SPI_result global variable, as described below).
On error, a negative or NULL result will be returned.
SPI_execp
- Executes a plan prepared or returned by SPI_saveplan
+Executes a plan from SPI_saveplan
Triggers
- While the current version of
Postgres has various client interfaces
-such as Perl, Tcl, Python and C, it lacks an actual Procedural Language
-(PL). We hope to have a proper PL one day. In the meantime it is possible
+
Postgres has various client interfaces
+such as Perl, Tcl, Python and C, as well as two
+Procedural Languages
+(PL). It is also possible
to call C functions as trigger actions. Note that STATEMENT-level trigger
events are not supported in the current version. You can currently specify
BEFORE or AFTER on INSERT, DELETE or UPDATE of a tuple as a trigger event.
+
-
PostgreSQL is copyright (C) 1998 by the Postgres Global Development Group.
+
PostgreSQL is copyright (C) 1998
+by the Postgres Global Development Group.
+
&biblio;
+
Extending SQL: Aggregates
- Aggregates in
Postgres are expressed in terms of state
+are expressed in terms of state
transition functions. That is, an aggregate can be
defined in terms of state that is modified whenever an
instance is processed. Some state functions look at a
particular value in the instance when computing the new
- state (
sfunc1 in the create aggregate syntax) while
+create aggregate syntax) while
others only keep track of their own internal state
- If we define an aggregate that uses only
sfunc1, we
+ If we define an aggregate that uses only
define an aggregate that computes a running function of
the attribute values from each instance. "Sum" is an
example of this kind of aggregate. "Sum" starts at
zero and always adds the current instance's value to
- its running total. We will use the
int4pl that is
- built into
Postgres to perform this addition.
+ its running total. We will use the
+to perform this addition.
- CREATE AGGREGATE complex_sum (
- sfunc1 = complex_add,
- basetype = complex,
- stype1 = complex,
- initcond1 = '(0,0)'
- );
+CREATE AGGREGATE complex_sum (
+ sfunc1 = complex_add,
+ basetype = complex,
+ stype1 = complex,
+ initcond1 = '(0,0)'
+);
- SELECT complex_sum(a) FROM test_complex;
+SELECT complex_sum(a) FROM test_complex;
+------------+
|complex_sum |
- If we define only
sfunc2, we are specifying an aggregate
+ If we define only
sfunc2, we are
+specifying an aggregate
that computes a running function that is independent of
the attribute values from each instance.
"Count" is the most common example of this kind of
aggregate. "Count" starts at zero and adds one to its
running total for each instance, ignoring the instance
- value. Here, we use the built-in
int4inc routine to do
+ value. Here, we use the built-in
the work for us. This routine increments (adds one to)
its argument.
- CREATE AGGREGATE my_count (sfunc2 = int4inc, -- add one
- basetype = int4, stype2 = int4,
- initcond2 = '0')
+CREATE AGGREGATE my_count (
+ sfunc2 = int4inc, -- add one
+ basetype = int4,
+ stype2 = int4,
+ initcond2 = '0'
+);
- SELECT my_count(*) as emp_count from EMP;
+SELECT my_count(*) as emp_count from EMP;
+----------+
|emp_count |
the count.
- CREATE AGGREGATE my_average (sfunc1 = int4pl, -- sum
- basetype = int4,
- stype1 = int4,
- sfunc2 = int4inc, -- count
- stype2 = int4,
- finalfunc = int4div, -- division
- initcond1 = '0',
- initcond2 = '0')
+CREATE AGGREGATE my_average (
+ sfunc1 = int4pl, -- sum
+ basetype = int4,
+ stype1 = int4,
+ sfunc2 = int4inc, -- count
+ stype2 = int4,
+ finalfunc = int4div, -- division
+ initcond1 = '0',
+ initcond2 = '0'
+);
- SELECT my_average(salary) as emp_average FROM EMP;
+SELECT my_average(salary) as emp_average FROM EMP;
+------------+
|emp_average |
-
Extending SQL: Procedural languages
+
Procedural Languages