-
+
-
label="DG2" id="docguide">
Documentation
- User's Guide: documents the query language environment
+ User's Guide: documents the SQL implementation
- Reference Manual: documents the query language
+ Reference Manual: reference pages for programs and SQL commands
This is the base package of
SGML processing.
-
nwalsh.com/docbook/dsssl/index.html">Norm Walsh's Modular DocBook Stylesheets
+
docbook.sourceforge.net/projects/dsssl/index.html">DocBook DSSSL Stylesheets
These contain the processing instructions for converting the
- JadeTeX
If you want to, you can also install
TeX as a formatting backend for
-
Jade. This will generate printed
- output that is inferior to what you get from the
-
RTF backend. Tables are a particular
- problem area. Also, there is no opportunity to manually polish
- the results. Still, it works all right, especially for simpler
- documents that don't use tables, and as both
-
JadeTeX and the style sheets are
- under continuous improvement, it will certainly get better over
- time.
+
JadeTeX can create Postscript or
+
PDF files (the latter with bookmarks).
+
+
+ However, the output from
JadeTeX is
+ inferior to what you get from the
RTF
+ backend. Particular problem areas are tables and various
+ artifacts of vertical and horizontal spacing. Also, there is
+ no opportunity to manually polish the results.
(or jade). Possibly
sgml-tools will be needed as well. If your
distributor does not provide these then you should be able to make
- use of the packages from some large, reasonably compatible vendor.
+ use of the packages from some other, reasonably compatible vendor.
-
Installing Jade
+
Installing OpenJade
- The installation of OpenJade offers a GNU-style
- ./configure; make; make install build process.
- Details can be found in the OpenJade source distribution. In a
- nutshell:
+
+ The installation of OpenJade offers a GNU-style
+ ./configure; make; make install build
+ process. Details can be found in the OpenJade source
+ distribution. In a nutshell:
./configure --enable-default-catalog=/usr/local/share/sgml/catalog
make
make install
- Be sure to remember where you put the default
- catalog; you will need it below. You can also leave it
- off, but then you will have to set the environment variable
- SGML_CATALOG_FILES to point to the file whenever
-
+ Be sure to remember where you put the default
+ catalog; you will need it below. You can also leave
+ it off, but then you will have to set the environment variable
+ SGML_CATALOG_FILES to point to the file
+ whenever you use
jade later on.
+ (This method is also an option if OpenJade is already
+ installed and you want to install the rest of the toolchain
+ locally.)
+
+
- Additionally, you should install the files
- dsssl.dtd, fot.dtd,
- style-sheet.dtd, and
- catalog from the dsssl
- directory somewhere, perhaps into
- /usr/local/share/sgml/dsssl. (Or just copy
- the entire directory.)
-
+
+ Additionally, you should install the files
+ dsssl.dtd, fot.dtd,
+ style-sheet.dtd, and
+ catalog from the
+ dsssl directory somewhere, perhaps into
+ /usr/local/share/sgml/dsssl. It's
+ probably easiest to copy the entire directory:
+
+cp -R dsssl /usr/local/share/sgml
+
+
+
+
+
+ Finally, create the file
+ /usr/local/share/sgml/catalog and add
+ this line to it:
+CATALOG "dsssl/catalog"
+
+ (This is a relative path reference to the file installed in
+ . Be sure to adjust it
+ if you chose your installation layout differently.)
+
+
+
- Unpack the archive.
+ Create the directory
+ /usr/local/share/sgml/docbook31 and change
+ to it. (The exact location is irrelevant, but this one is
+ reasonable within the layout we are following here.)
+
$ mkdir /usr/local/share/sgml/docbook31
+
$ cd /usr/local/share/sgml/docbook31
- Place the files into the directory
- /usr/local/share/sgml/docbook31. (The
- exact location is irrelevant, but this one is fairly standard.)
+ Unpack the archive.
+
+
$ unzip -a ...../docbk31.zip
+
+ (The archive will unpack its files into the current directory.)
- Create a file
+ Edit the file
/usr/local/share/sgml/catalog (or whatever
you told jade during installation) and put a line like this
into it:
CATALOG "docbook31/docbook.cat"
+
+
Optionally, you can edit the file
docbook.cat and comment out or remove the
url="http://www.oasis-open.org/cover/ISOEnts.zip">ISO 8879
character entities archive, unpack it, and put the
files in the same directory you put the DocBook files in.
+
+
$ cd /usr/local/share/sgml/docbook31
+
$ unzip ...../ISOEnts.zip
+
+
+
+
+
+ Run the following command in the directory with the DocBook and ISO files:
+perl -pi -e 's/iso-(.*).gml/ISO\1/g' docbook.cat
+
+ (This fixes a mixup between the names used in the DocBook
+ catalog file and the actual names of the ISO character entity
+ files.)
-
Installing Norman Walsh's DSSSL Style Sheets
+
Installing the DocBook DSSSL Style Sheets
+
+ To install the style sheets, unzip and untar the distribution and
+ move it to a suitable place, for example
+ /usr/local/share/sgml. (The archive will
+ automatically create a subdirectory.)
+
+
$ gunzip docbook-dsssl-1.xx>.tar.gz
+
$ tar -C /usr/local/share/sgml -xf docbook-dsssl-1.xx>.tar
+
+
- To install the style sheets, simply unzip the distribution kit in
- a suitable place, for example
- /usr/local/share/sgml/stylesheets. (The
- archive will automatically create a docbook
- subdirectory.)
+ The usual catalog entry in
+ /usr/local/share/sgml/catalog can also be
+ made:
+CATALOG "docbook-dsssl--1.xx>/catalog
+
+ Because stylesheets change rather often, and it's sometimes
+ beneficial to try out alternative versions,
+
PostgreSQL doesn't use this catalog
+ entry. See for information about how
+ to select the stylesheets instead.
-
JadeTeX itself. All of these can be
- found on your friendly neighborhood
+
ot2enc. All of these can be found on
+ your friendly neighborhood
url="http://www.ctan.org">
CTAN site.
+ The installation of the
TeX base
+ system is far beyond the scope of this introduction. Binary
+ packages should be available for any system that can run
-
JadeTeX does not at the time of
- writing come with much of an installation guide, but there is a
- makefile that shows what is needed. It
- also includes a directory cooked, wherein
- you'll find some of the macro packages it needs, but not all, and
- not complete -- at least last we looked.
+ Before you can use
JadeTeX with the
+
PostgreSQL documentation sources, you
+ will need to increase the size of
+
TeX's internal data structures.
+ Details on this can be found in the
JadeTeX
+ installation insructions.
- Before building the jadetex.fmt format file,
- you'll probably want to edit the jadetex.ltx
- file, to change the configuration of
-
Babel to suit your locality. The line
- to change looks something like
-\RequirePackage[german,french,english]{babel}[1997/01/23]
-
- and you should obviously list only the languages you actually need,
- and have configured
Babel for.
-
-
- It is quite likely that when you use
-
PostgreSQL documentation sources, that
-
TeX will stop during the second run,
- and tell you that its capacity has been exceeded. This is, as
- far as we can tell, because of the way
-
JadeTeX generates cross referencing
- information.
TeX can, of course, be
- compiled with larger data structure sizes. The details of this
- will vary according to your installation.
+ Once that is finished you can install
JadeTeX:
+
+
$ gunzip jadetex-xxx.tar.gz
+
$ tar xf jadetex-xxx.tar
+
+ The last two need to be done as root.
most common toolset is the
editor with appropriate editing mode. On some systems
- (e.g., RedHat Linux) these tools are provided in a typical full
- installation.
+ these tools are provided in a typical full installation.
-
+
Functions and Operators
-
Multi-type Formatting Functions
+
Data Type Formatting Functions
Date/Time Operators
- 4">
+ 3">
|
Name
Date/Time Functions
- 4">
+ 5">
|
Name
3
-
=> SELECT a, CASE WHEN a=1 THEN 'one' WHEN a=2 THEN 'two' ELSE 'other' END FROM test;
+ CASE WHEN a=1 THEN 'one'
+ WHEN a=2 THEN 'two'
+ ELSE 'other'
+ END
+ FROM test;
a | case
---+-------
The example above can be written using the simple
CASE syntax:
-
=> SELECT a, CASE a WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'other' END FROM test;
+ CASE a WHEN 1 THEN 'one'
+ WHEN 2 THEN 'two'
+ ELSE 'other'
+ END
+ FROM test;
a | case
---+-------
Among all relational operators the most difficult one to process and
optimize is the join. The number of alternative plans to answer a query
- grows exponentially with the number of joins included in it. Further
+ grows exponentially with the number of joins included in it. Further
optimization effort is caused by the support of a variety of
join methods
(e.g., nested loop, hash join, merge join in
Postgres) to
- process individual joins and a diversity of
+ process individual joins and a diversity of
indexes (e.g., R-tree,
B-tree, hash in
Postgres) as access paths for relations.
Technology, in Freiberg, Germany, encountered the described problems as its
folks wanted to take the
Postgres DBMS as the backend for a decision
support knowledge based system for the maintenance of an electrical
- power grid. The DBMS needed to handle large join queries for the
+ power grid. The DBMS needed to handle large join queries for the
inference machine of the knowledge based system.
-
Genetic Algorithms (GA)
+
Genetic Algorithms
- The
GA is a heuristic optimization method which
+ The
genetic algorithm (GA) is a heuristic optimization method which
operates through
determined, randomized search. The set of possible solutions for the
optimization problem is considered as a
strongly that a
GA is not a pure random search for a solution to a
problem. A
GA uses stochastic processes, but the result is distinctly
non-random (better than random).
+
-Structured Diagram of a
GA:
----------------------------
-
-P(t) generation of ancestors at a time t
-P''(t) generation of descendants at a time t
-
+
+
Structured Diagram of a Genetic Algorithm
+
+
+
+
+ |
+ P(t)
+ generation of ancestors at a time t
+
+
+ |
+ P''(t)
+ generation of descendants at a time t
+
+
+
+
+
+
+=========================================+
|>>>>>>>>>>> Algorithm GA <<<<<<<<<<<<<<|
+=========================================+
| +-------------------------------------+
| | t := t + 1 |
+===+=====================================+
- >
- para>
+>
+ figure>
The
GEQO module is intended for the solution of the query
optimization problem similar to a traveling salesman problem (
TSP).
Possible query plans are encoded as integer strings. Each string
- represents the join order from one relation of the query to the next.
+ represents the join order from one relation of the query to the next.
E. g., the query tree
+>
/\
/\ 2
/\ 3
4 1
- >
+>
is encoded by the integer string '4-1-3-2',
which means, first join relation '4' and '1', then '3', and
then '2', where 1, 2, 3, 4 are relids within the
the
Postgres query optimizer to
- support large join queries effectively through
+ support large join queries effectively through
non-exhaustive search.
+
-
+
PostgreSQL>]]>
The following prerequisites exist for building
PostgreSQL>:
-
-
-
+
+
+
GNU> make> is required; other
make> programs will not> work.
GNU> make> is often installed under
-
-
-
+
+
+
The
GNU> Readline> library for comfortable
line editing and command history retrieval will automatically be used
if found. You might wish to install it before proceeding, but it is not
-
-
-
-
-
-
-
+
+
+
+
+
+
+
not> required when building from a released source
package because the output files are pre-generated. You will
-
- on Windows
-
+
+ on Windows
+
+
To build on
Windows NT> or Windows
2000> you need the
Cygwin> and
cygipc> packages. See the file
-
-
-
+
+
+
To dump your database installation, type:
pg_dumpall > outputfile>
concepts in such a way that users can easily
extend the system:
-
+ spacing="compact">
inheritance>
Other features provide additional power and flexibility:
-
+ spacing="compact">
constraints
*
* Copyright (c) 1994, Regents of the University of California
*
- *
- * IDENTIFICATION
- * /usr/local/devel/pglite/cvs/src/doc/manual.me,v 1.16 1995/09/01 23:55:00 jolly Exp
- *
*--------------------------------------------------------------
*/
#include <stdio.h>
risk. To allow it, you must compile
Postgres> with
the C preprocessor macro ALLOW_ABSOLUTE_DBPATHS>
defined. One way to do this is to run the compilation step like
- this: gmake CPPFLAGS=-DALLOW_ABSOLUTE_DBPATHS all>.
+ this:
+gmake CPPFLAGS=-DALLOW_ABSOLUTE_DBPATHS all
+
- The four isolation levels and the corresponding behaviors are described below.
+ The four transaction isolation levels and the corresponding
+ behaviors are described in .
-
-
ANSI/ISO SQL Isolation Levels
+
id="mvcc-isolevel-table">
+
SQL Transaction Isolation Levels
Isolation Levels
- /usr/local/pgsql/ is generally used as the root
+ We use /usr/local/pgsql/ as the root
directory of the installation and /usr/local/pgsql/data
as the directory with the database files. These directories may vary
on your site, details can be derived in the Administrator's Guide.
-
The following table shows how pages in both normal
Postgres tables
+
shows how pages in both normal
Postgres tables
(e.g., a B-tree index) are structured.
+
-
+
id="page-table">
Sample Page Layout
Page Layout
-1">
+2">
|
Item
-
-Description
-
+Description
|
-
-itemPointerData
-
+itemPointerData
|
-
-filler
-
+filler
|
-
-itemData...
-
+itemData...
|
-
-Unallocated Space
-
+Unallocated Space
|
-
-ItemContinuationData
-
+ItemContinuationData
|
-
-Special Space
-
+Special Space
|
-
-``ItemData 2''
-
+ItemData 2
|
-
-``ItemData 1''
-
+ItemData 1
|
-
-ItemIdData
-
+ItemIdData
|
-
-PageHeaderData
-
+PageHeaderData
-
along with the same estimated costs that a plain EXPLAIN shows.
For example, we might get a result like this:
-regression=# explain analyze select * from tenk1 t1, tenk2 t2 where t1.unique1 < 50
-regression-# and t1.unique2 = t2.unique2;
+
+regression=# explain analyze
+regression-# select * from tenk1 t1, tenk2 t2
+regression-# where t1.unique1 < 50 and t1.unique2 = t2.unique2;
NOTICE: QUERY PLAN:
Nested Loop (cost=0.00..330.41 rows=49 width=296) (actual time=1.31..28.90 rows=50 loops=1)
-> Index Scan using tenk2_unique2 on tenk2 t2
(cost=0.00..3.01 rows=1 width=148) (actual time=0.28..0.31 rows=1 loops=50)
Total runtime: 30.67 msec
- >
+>
Note that the actual time
values are in milliseconds of
real time, whereas the cost
estimates are expressed in
In some query plans, it is possible for a subplan node to be executed more
- than once. For example, the inner indexscan is executed once per outer
+ than once. For example, the inner index scan is executed once per outer
tuple in the above nested-loop plan. In such cases, the
loops
value reports the
total number of executions of the node, and the actual time and rows
-
+
Queries
-SELECT select_list FROM ... WHERE ... GROUP BY grouping_column_reference , grouping_column_reference...
+SELECT select_list
+ FROM ...
+ WHERE ...
+ GROUP BY grouping_column_reference , grouping_column_reference...
The ORDER BY clause specifies the sort order:
-SELECT select_list FROM table_expression ORDER BY column1 ASC | DESC , column2 ASC | DESC ...
+SELECT select_list
+ FROM table_expression
+ ORDER BY column1 ASC | DESC , column2 ASC | DESC ...
column1, etc., refer to select list
columns. These can be either the output name of a column (see
-SELECT select_list FROM table_expression ORDER BY sort_spec LIMIT { number | ALL } OFFSET number
+SELECT select_list
+ FROM table_expression
+ ORDER BY sort_spec
+ LIMIT { number | ALL } OFFSET number
style to fully qualify column names in join queries:
-SELECT weather.city, weather.temp_lo, weather.temp_hi, weather.prcp, weather.date, cities.location
+SELECT weather.city, weather.temp_lo, weather.temp_hi,
+ weather.prcp, weather.date, cities.location
FROM weather, cities
WHERE cities.name = weather.city;
select command will cause
Postgres to
report an error because the query cycled too many times:
-
-
Example of a circular rewrite rule combination:
CREATE RULE "_RETemp" AS
ON SELECT TO emp
DO INSTEAD
SELECT * FROM toyemp;
-
CREATE RULE "_RETtoyemp" AS
ON SELECT TO toyemp
DO INSTEAD
SELECT * FROM emp;
-
+
+
This attempt to select from EMP will cause
Postgres to issue an error
because the queries cycled too many times:
+
SELECT * FROM emp;
-
-
+
-->
table constraint definition:
-
-[ CONSTRAINT constraint_name ] CHECK ( VALUE condition )
+
+[ CONSTRAINT constraint_name ]
+ CHECK ( VALUE condition )
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
[ [ NOT ] DEFERRABLE ]
-
+
column constraint definition:
-
-[ CONSTRAINT constraint_name ] CHECK ( VALUE condition )
+
+[ CONSTRAINT constraint_name ]
+ CHECK ( VALUE condition )
[ {INITIALLY DEFERRED | INITIALLY IMMEDIATE} ]
[ [ NOT ] DEFERRABLE ]
-
+
+
2000-11-24
SET TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
-SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE }
+SET SESSION CHARACTERISTICS AS TRANSACTION ISOLATION LEVEL
+ { READ COMMITTED | SERIALIZABLE }
The session default transaction isolation level can also be set
- with the command SET default_transaction_isolation =
- 'value' and in the
+ with the command
+SET default_transaction_isolation = 'value'
+
+ and in the
configuration file. Consult the Administrator's
Guide for more information.
- One way to set these options is to create a file
- postgresql.conf in the data directory (e.g.,
- /usr/local/pgsql/data). An example of what
+ One way to set these options is to edit the file
+ postgresql.conf in the data directory.
+ (A default file is installed there.) An example of what
this file could look like is:
# This is a comment
to your ~/.emacs
initialization file:
;; check for files with a path containing "postgres" or "pgsql"
-(setq auto-mode-alist (cons '("\\(postgres\\|pgsql\\).*\\.[ch]\\'" . pgsql-c-mode) auto-mode-alist))
-(setq auto-mode-alist (cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode) auto-mode-alist))
+(setq auto-mode-alist
+ (cons '("\\(postgres\\|pgsql\\).*\\.[ch]\\'" . pgsql-c-mode)
+ auto-mode-alist))
+(setq auto-mode-alist
+ (cons '("\\(postgres\\|pgsql\\).*\\.cc\\'" . pgsql-c-mode)
+ auto-mode-alist))
(defun pgsql-c-mode ()
;; sets up formatting for Postgres C code
(c-set-style "bsd") ; set c-basic-offset to 4, plus other stuff
(c-set-offset 'case-label '+) ; tweak case indent to match PG custom
(setq indent-tabs-mode t)) ; make sure we keep tabs when indenting
-
+
~/.vimrc or equivalent file should contain
the following:
set tabstop=4
-
+
or equivalently from within vi, try
:set ts=4
-
+
The text browsing tools
more and
more -x4
less -x4
-
+
Algorithm
SPI_connect performs the following:
-
-
-
-•
-
-
Initializes the SPI internal
structures for query execution and memory management.
-
-
-
-
+
(element lineannotation ($italic-seq$))
(element structfield ($mono-seq$))
(element structname ($mono-seq$))
+(element symbol ($mono-seq$))
(element type ($mono-seq$))
+
+;; The rules in the default stylesheet for productname format it as
+;; a paragraph. This may be suitable for productname directly
+;; within *info, but it's nonsense when productname is used
+;; inline, as we do.
+(mode set-titlepage-recto-mode
+ (element (para productname) ($charseq$)))
+(mode set-titlepage-verso-mode
+ (element (para productname) ($charseq$)))
+(mode book-titlepage-recto-mode
+ (element (para productname) ($charseq$)))
+(mode book-titlepage-verso-mode
+ (element (para productname) ($charseq$)))
+;; Add more here if needed...
+
+
;; customize the html stylesheet
(define bop-footnotes #t)
(define %hyphenation%
(if tex-backend #t #f))
+(define %refentry-new-page% #t)
+(define %refentry-keep% #f)
(define %graphic-default-extension%
(cond (tex-backend "eps")
(rtf-backend "ai"))) ;; ApplixWare?
-;; The rules in the default stylesheet for productname format it as
-;; a paragraph. This may be suitable for productname directly
-;; within *info, but it's nonsense when productname is used
-;; inline, as we do.
-(mode set-titlepage-recto-mode
- (element (para productname) ($charseq$)))
-(mode set-titlepage-verso-mode
- (element (para productname) ($charseq$)))
-(mode book-titlepage-recto-mode
- (element (para productname) ($charseq$)))
-(mode book-titlepage-verso-mode
- (element (para productname) ($charseq$)))
-;; Add more here if needed...
+(define %footnote-ulinks%
+ (and tex-backend
+ (>= (string->number "1.73") 1.73)))
;; Format legalnotice justified and with space between paragraphs.
(mode book-titlepage-verso-mode
space-after: (* 0.8 %para-sep%)
(process-children))))
+
+;; Fix spacing bug in variablelists
+(define (process-listitem-content)
+ (if (absolute-first-sibling?)
+ (make sequence
+ (process-children-trim))
+ (next-match)))
+
+
+;; Default stylesheets format simplelists are tables. This just
+;; spells trouble for Jade.
+
+(define %simplelist-indent% 1em)
+
+(define (my-simplelist-vert members)
+ (make display-group
+ space-before: %para-sep%
+ space-after: %para-sep%
+ start-indent: (+ %simplelist-indent% (inherited-start-indent))
+ (process-children)))
+
+(element simplelist
+ (let ((type (attribute-string (normalize "type")))
+ (cols (if (attribute-string (normalize "columns"))
+ (if (> (string->number (attribute-string (normalize "columns"))) 0)
+ (string->number (attribute-string (normalize "columns")))
+ 1)
+ 1))
+ (members (select-elements (children (current-node)) (normalize "member"))))
+ (cond
+ ((equal? type (normalize "inline"))
+ (if (equal? (gi (parent (current-node)))
+ (normalize "para"))
+ (process-children)
+ (make paragraph
+ space-before: %para-sep%
+ space-after: %para-sep%
+ start-indent: (inherited-start-indent))))
+ ((equal? type (normalize "vert"))
+ (my-simplelist-vert members))
+ ((equal? type (normalize "horiz"))
+ (simplelist-table 'row cols members)))))
+
+(element member
+ (let ((type (inherited-attribute-string (normalize "type"))))
+ (cond
+ ((equal? type (normalize "inline"))
+ (make sequence
+ (process-children)
+ (if (not (last-sibling?))
+ (literal ", ")
+ (literal ""))))
+ ((equal? type (normalize "vert"))
+ (make paragraph
+ space-before: 0pt
+ space-after: 0pt))
+ ((equal? type (normalize "horiz"))
+ (make paragraph
+ quadding: 'start
+ (process-children))))))
+
]]>
- A description of the general syntax of SQL.
+ This chapter describes the syntax of SQL.
each other.
-
Postgres' folding of unquoted names to lower
- case is incompatible with the SQL standard, which says that unquoted
+ The folding of unquoted names to lower case in
PostgreSQL>
+ is incompatible with the SQL standard, which says that unquoted
names should be folded to upper case. Thus, foo
should be equivalent to "FOO" not
"foo" according to the standard. If you want to
( expression )
Parentheses are used to group subexpressions and override precedence.
Operator Precedence (decreasing)
- 2">
+ 3">