@@ -1152,7 +1154,8 @@ BYTEA bytea variable-length byte array (null-byte safe)
Finally, you could use the OID
returned from the INSERT statement to look up the
- default value, though this is probably the least portable approach.
+ default value, though this is probably the least portable approach,
+ and the oid value will wrap around when it reaches 4 billion.
In Perl, using DBI with Edmund Mergl's DBD::Pg module, the oid
value is made available via $sth->{pg_oid_status} after
$sth->execute().
diff --git a/doc/src/FAQ/FAQ_german.html b/doc/src/FAQ/FAQ_german.html
index 60752bcb5b2..5042cdfdca9 100644
--- a/doc/src/FAQ/FAQ_german.html
+++ b/doc/src/FAQ/FAQ_german.html
@@ -14,7 +14,7 @@ href="mailto:pgman@candle.pha.pa.us">pgman@candle.pha.pa.us).
Letzte Aktualisierung der deutschen Übersetzung: Di., den 22.07.2003, 16:20 CET
+
Letzte Aktualisierung der deutschen Übersetzung: Di., den 02.09.2003, 10:00 CET
Die aktuellste Version dieses Dokuments liegt auf der PostgreSQL Website:
@@ -1060,8 +1060,12 @@ BYTEA bytea Bytearray mit variabler L
new_id = output of execute("SELECT currval('person_id_seq')");
Schließlich besteht noch die Möglichkeit, den von einer INSERT-Anweisung
- zurückgelieferten OID-Wert als einmaligen Wert zu verwenden.
- In Perl mit dem DBD::Pg-Modul von Edmund Mergl wird der OID-Wert nach einem
+ zurückgelieferten OID-Wert als einmaligen Wert zu verwenden.
+ Dieser Ansatz ist allerdings PostgreSQL-spezifisch; außerdem wird nach
+ ca. 4 Milliarden Einträgen der OID-Wert wieder auf eine kleine Zahl
+ gesetzt, ist also nicht garantiert einmalig.
+
+
In Perl mit dem DBD::Pg-Modul wird der OID-Wert nach einem
$sth->excute() über $sth->{pg_oid_status} zurückgeliefert.
4.15.3) Führen currval() und nextval() zu einer Race-Condition mit anderen
@@ -1285,13 +1289,21 @@ BYTEA bytea Bytearray mit variabler L
contrib/pgcrypto enthält diverse Funktionen für die Benützung mit
- SQL-Abfragen;
-
die einzige Möglichkeit, Kommunikationen zwischen Client und Server
- zu verschlüsseln, ist durch die Anwendung von hostssl in pg_hba.conf;
+ SQL-Abfragen.
+
+
Um Verbindungen zwischen dem Server und Client-Anwendungen zu
+ verschlüsseln, muss in der Server-Konfigurationsdatei postgresql.conf
+ die ssl-Option auf true (Voreinstellung: false) gesetzt werden
+ und ein passender host- bzw. hostssl-Eintrag muss in
+ pg_hba.conf vorhanden sein. Zudem muss die sslmode-Einstellung
+ beim Client nicht auf disable gesetzt werden. (Bitte beachten Sie auch,
+ daß neben der eingebauten SSL-Unterstützung verschlüsselte Verbindungen
+ auch über externe Anwendungen wie stunnel oder ssh aufgebaut werden können).
+
Die Passwörter der Datenbanknutzer werden ab Version 7.3 automatisch
verschlüsselt (in früheren Versionen muß der Parameter PASSWORD_ENCRYPTION
- in postgresql.conf explizit eingeschaltet werden);
-
der Server läuft auf einem verschlüsselten Dateisystem.
+ in postgresql.conf explizit eingeschaltet werden).
+
Betrieb des Servers auf einem verschlüsselten Dateisystem.
@@ -1333,9 +1345,15 @@ BYTEA bytea Bytearray mit variabler L
Die englische Vorlage dieser FAQ wird ständig überarbeitet. Daher liegt
die Übersetzung nicht immer auf dem aktuellsten Stand.
+
Die aktuellste Version der deutschen Übersetzung befindet sich immer unter
+ http://sql-info.de/postgresql/FAQ_german.html.
+ Diese "Arbeitsversion" enthält eventuell Änderungen, die noch nicht auf der
+ PostgreSQL-Website eingebunden worden sind.
+
Über Verbesserungshinweise und Korrekturvorschläge sowie Verständnisfragen
zum Inhalt der FAQ freue ich mich. Ich nehme auch allgemeine Fragen zu PostgreSQL gerne
- entgegen, kann aber leider keine zeitige Antwort garantieren.
+ entgegen, verweise jedoch auf die Mailing-Listen als schnelle und zuverlässige
+ Anlaufstellen.
Diese Übersetzung basiert teilweise auf einer früheren Übersetzung von Karsten
Schulz (schulz@linux-systemhaus.de).
diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefile
index 42551d24074..22f8e427df2 100644
--- a/doc/src/sgml/Makefile
+++ b/doc/src/sgml/Makefile
@@ -2,7 +2,7 @@
#
# PostgreSQL documentation makefile
#
-# $Header: /cvsroot/pgsql/doc/src/sgml/Makefile,v 1.57 2003/04/10 01:22:44 petere Exp $
+# $Header: /cvsroot/pgsql/doc/src/sgml/Makefile,v 1.57.2.1 2003/09/07 04:36:40 momjian Exp $
#
#----------------------------------------------------------------------------
@@ -48,7 +48,7 @@ endif
# Enable draft mode during development
ifneq (,$(findstring devel, $(VERSION)))
-JADEFLAGS += -V draft-mode
+override JADEFLAGS += -V draft-mode
endif
@@ -82,7 +82,7 @@ html: postgres.sgml $(ALLSGML) stylesheet.dsl
$(JADE) $(JADEFLAGS) $(SGMLINCLUDE) $(CATALOG) -d stylesheet.dsl -i output-html -t sgml $<
-COLLATEINDEX := $(PERL) $(COLLATEINDEX) -f -g
+COLLATEINDEX := LC_ALL=C $(PERL) $(COLLATEINDEX) -f -g
ifeq (,$(wildcard HTML.index))
bookindex.sgml:
diff --git a/doc/src/sgml/advanced.sgml b/doc/src/sgml/advanced.sgml
index d6d7881ef38..a0b4726a919 100644
--- a/doc/src/sgml/advanced.sgml
+++ b/doc/src/sgml/advanced.sgml
@@ -1,5 +1,5 @@
@@ -142,7 +142,7 @@ ERROR: <unnamed> referential integrity violation - key referenced from we
Transactions
- transactions
+ transaction
diff --git a/doc/src/sgml/array.sgml b/doc/src/sgml/array.sgml
index fabf2e732cd..a06c00cd348 100644
--- a/doc/src/sgml/array.sgml
+++ b/doc/src/sgml/array.sgml
@@ -1,10 +1,10 @@
-
+
Arrays
- arrays
+ array
@@ -162,7 +162,6 @@ ERROR: multidimensional arrays must have array expressions with matching dimens
expression syntax is discussed in more detail in .
-
@@ -326,9 +325,9 @@ UPDATE sal_emp SET pay_by_quarter[1:2] = '{27000,27000}'
||.
SELECT ARRAY[1,2] || ARRAY[3,4];
- ?column?
----------------
- {{1,2},{3,4}}
+ ?column?
+-----------
+ {1,2,3,4}
(1 row)
SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];
@@ -337,27 +336,68 @@ SELECT ARRAY[5,6] || ARRAY[[1,2],[3,4]];
{{5,6},{1,2},{3,4}}
(1 row)
+
+
The concatenation operator allows a single element to be pushed on to the
beginning or end of a one-dimensional array. It also accepts two
N>-dimensional arrays, or an N>-dimensional
- and an N+1>-dimensional array. In the former case, the two
- N>-dimension arrays become outer elements of an
- N+1>-dimensional array. In the latter, the
- N>-dimensional array is added as either the first or last
- outer element of the N+1>-dimensional array.
-
- When extending an array by concatenation, the subscripts of its existing
- elements are preserved. For example, when pushing
- onto the beginning of an array with one-based subscripts, the resulting
- array has zero-based subscripts:
+ and an N+1>-dimensional array.
+
+
+ When a single element is pushed on to the beginning of a one-dimensional
+ array, the result is an array with a lower bound subscript equal to
+ the righthand operand's lower bound subscript, minus one. When a single
+ element is pushed on to the end of a one-dimensional array, the result is
+ an array retaining the lower bound of the lefthand operand. For example:
SELECT array_dims(1 || ARRAY[2,3]);
array_dims
------------
[0:2]
(1 row)
+
+SELECT array_dims(ARRAY[1,2] || 3);
+ array_dims
+------------
+ [1:3]
+(1 row)
+
+
+
+
+ When two arrays with an equal number of dimensions are concatenated, the
+ result retains the lower bound subscript of the lefthand operand's outer
+ dimension. The result is an array comprising every element of the lefthand
+ operand followed by every element of the righthand operand. For example:
+
+SELECT array_dims(ARRAY[1,2] || ARRAY[3,4,5]);
+ array_dims
+------------
+ [1:5]
+(1 row)
+
+SELECT array_dims(ARRAY[[1,2],[3,4]] || ARRAY[[5,6],[7,8],[9,0]]);
+ array_dims
+------------
+ [1:5][1:2]
+(1 row)
+
+
+
+
+ When an N>-dimensional array is pushed on to the beginning
+ or end of an N+1>-dimensional array, the result is
+ analogous to the element-array case above. Each N>-dimensional
+ sub-array is essentially an element of the N+1>-dimensional
+ array's outer dimension. For example:
+
+SELECT array_dims(ARRAY[1,2] || ARRAY[[3,4],[5,6]]);
+ array_dims
+------------
+ [0:2][1:2]
+(1 row)
@@ -386,9 +426,9 @@ SELECT array_append(ARRAY[1,2], 3);
(1 row)
SELECT array_cat(ARRAY[1,2], ARRAY[3,4]);
- array_cat
----------------
- {{1,2},{3,4}}
+ array_cat
+-----------
+ {1,2,3,4}
(1 row)
SELECT array_cat(ARRAY[[1,2],[3,4]], ARRAY[5,6]);
diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml
index 6e7e9cbf0be..204ffa5b838 100644
--- a/doc/src/sgml/backup.sgml
+++ b/doc/src/sgml/backup.sgml
@@ -1,5 +1,5 @@
Backup and Restore
@@ -153,6 +153,12 @@ pg_dump -h host1> dbname> | psql -h h
+
+
+ Restore performance can be improved by increasing SORT_MEM>
+ (see ).
+
+
@@ -279,13 +285,15 @@ pg_dump -Fc dbname >
- For reasons of backward compatibility, pg_dump> does
- not dump large objects by default. To dump large objects you must use
- either the custom or the TAR output format, and use the
@@ -365,7 +373,15 @@ tar -cf backup.tar /usr/local/pgsql/data
Migration between releases
- upgrading>>
+
+
+ upgrading
+
+
+
+ version
+ compatibility
+
As a general rule, the internal data storage format is subject to
diff --git a/doc/src/sgml/charset.sgml b/doc/src/sgml/charset.sgml
index fb9db34019c..ec2ada9b488 100644
--- a/doc/src/sgml/charset.sgml
+++ b/doc/src/sgml/charset.sgml
@@ -1,4 +1,4 @@
-
+
Localization>
@@ -197,7 +197,7 @@ initdb --locale=sv_SE
Sort order in queries using ORDER BY>
- ORDER BY>>
+ ORDER BY>and locales>
diff --git a/doc/src/sgml/client-auth.sgml b/doc/src/sgml/client-auth.sgml
index e6180c762ee..0564779552a 100644
--- a/doc/src/sgml/client-auth.sgml
+++ b/doc/src/sgml/client-auth.sgml
@@ -1,5 +1,5 @@
@@ -199,13 +199,17 @@ hostnossl databaseuser
(actual-IP-address xor IP-address-field) and IP-mask-field
- must be zero for the record to match. (Of course IP addresses
- can be spoofed but this consideration is beyond the scope of
- PostgreSQL.) If you machine supports
- IPv6, the default pg_hba.conf> file will have an
- IPv6 entry for localhost>. You can add your own IPv6
- entries to the file. IPv6 entries are used only for IPv6
- connections.
+ must be zero for the record to match.
+
+
+
+ An IP address given in IPv4 format will match IPv6 connections that
+ have the corresponding address, for example 127.0.0.1>
+ will match the IPv6 address ::ffff:127.0.0.1>. An entry
+ given in IPv6 format will match only IPv6 connections, even if the
+ represented address is in the IPv4-in-IPv6 range. Note that entries
+ in IPv6 format will be rejected if the system's C library does not have
+ support for IPv6 addresses.
@@ -219,9 +223,10 @@ hostnossl databaseuserCIDR-mask
- This is an integer specifying the number of significant bits
- to set in the mask, and is an alternative to using the
- IP-mask notation. The number must
+ This field may be used as an alternative to the
+ IP-mask notation. It is an
+ integer specifying the number of high-order bits
+ to set in the mask. The number must
be between 0 and 32 (in the case of an IPv4 address) or 128
(in the case of an IPv6 address) inclusive. 0 will match any
address, while 32/128 will match only the exact host specified.
@@ -451,6 +456,11 @@ local all all trust
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host all all 127.0.0.1 255.255.255.255 trust
+# The same as the last line but using a CIDR mask
+#
+# TYPE DATABASE USER IP-ADDRESS/CIDR-mask METHOD
+host all all 127.0.0.1/32 trust
+
# Allow any user from any host with IP address 192.168.93.x to connect
# to database "template1" as the same user name that ident reports for
# the connection (typically the Unix user name).
@@ -458,6 +468,11 @@ host all all 127.0.0.1 255.255.255.255 trust
# TYPE DATABASE USER IP-ADDRESS IP-MASK METHOD
host template1 all 192.168.93.0 255.255.255.0 ident sameuser
+# The same as the last line but using a CIDR mask
+#
+# TYPE DATABASE USER IP-ADDRESS/CIDR-mask METHOD
+host template1 all 192.168.93.0/24 ident sameuser
+
# Allow a user from host 192.168.12.10 to connect to database
# "template1" if the user's password is correctly supplied.
#
@@ -566,6 +581,7 @@ local db1,db2,@demodbs all md5
password
+ authentication
@@ -610,16 +626,21 @@ local db1,db2,@demodbs all md5
Kerberos is an industry-standard secure
- authentication system suitable for distributed computing over a
- public network. A description of the
- Kerberos system is far beyond the scope
- of this document; in all generality it can be quite complex (yet
- powerful). The Kerberos system
+ is far beyond the scope of this document; in all generality it can be
+ quite complex (yet powerful). The Kerberos
- FAQ> or MIT Project Athena can be
- a good starting point for exploration. Several sources for
- Kerberos> distributions exist.
+ FAQ> or MIT
+ Project Athena can be a good starting point for exploration.
+ Several sources for Kerberos> distributions exist.
+
+
+
+ While PostgreSQL> supports both Kerberos 4 and
+ Kerberos 5, only Kerberos 5 is recommended. Kerberos 4 is
+ considered insecure and no longer recommended for general
+ use.
@@ -850,6 +871,10 @@ omicron bryanh guest1
PAM Authentication
+
+ PAM
+
+
This authentication method operates similarly to
password except that it uses PAM (Pluggable
diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml
index b8053f94e55..295cbd779a0 100644
--- a/doc/src/sgml/datatype.sgml
+++ b/doc/src/sgml/datatype.sgml
@@ -1,17 +1,17 @@
Data Types
- data types
+ data type
- types
- data types
+ type
+ data type
@@ -279,68 +279,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.122 2003/08/09 22:50:21 t
Numeric Types
- data types
+ data typenumeric
-
- integer
-
-
-
- smallint
-
-
-
- bigint
-
-
-
- int4
- integer
-
-
-
- int2
- smallint
-
-
-
- int8
- bigint
-
-
-
- numeric (data type)
-
-
-
- decimal
- numeric
-
-
-
- real
-
-
-
- double precision
-
-
-
- float4
- real
-
-
-
- float8
- double precision
-
-
-
- floating point
-
-
Numeric types consist of two-, four-, and eight-byte integers,
four- and eight-byte floating-point numbers, and fixed-precision
@@ -434,6 +376,33 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.122 2003/08/09 22:50:21 t
Integer Types
+
+ integer
+
+
+
+ smallint
+
+
+
+ bigint
+
+
+
+ int4
+ integer
+
+
+
+ int2
+ smallint
+
+
+
+ int8
+ bigint
+
+
The types smallint, integer, and
bigint store whole numbers, that is, numbers without
@@ -495,6 +464,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datatype.sgml,v 1.122 2003/08/09 22:50:21 t
Arbitrary Precision Numbers
+
+ numeric (data type)
+
+
+
+ decimal
+ numeric
+
+
The type numeric can store numbers with up to 1000
digits of precision and perform calculations exactly. It is
@@ -562,6 +540,28 @@ NUMERIC
Floating-Point Types
+
+ real
+
+
+
+ double precision
+
+
+
+ float4
+ real
+
+
+
+ float8
+ double precision
+
+
+
+ floating point
+
+
The data types real and double
precision are inexact, variable-precision numeric types.
@@ -675,7 +675,7 @@ NUMERIC
- sequences
+ sequenceand serial type
@@ -807,18 +807,33 @@ CREATE TABLE tablename (
Character Types
- character strings
+ character stringdata types
- strings
- character strings
+ string
+ character string
-
+
+ character
+
+
+
+ character varying
+
+
+ text
- character strings
+
+
+
+ char
+
+
+
+ varchar
@@ -1020,6 +1035,15 @@ SELECT b, char_length(b) FROM test2;
Binary Data Types
+
+
+ binary data
+
+
+
+ bytea
+
+
The bytea data type allows storage of binary strings;
see .
@@ -1210,6 +1234,34 @@ SELECT b, char_length(b) FROM test2;
Date/Time Types
+
+ date
+
+
+ time
+
+
+ time without time zone
+
+
+ time with time zone
+
+
+ timestamp
+
+
+ timestamp with time zone
+
+
+ timestamp without time zone
+
+
+ interval
+
+
+ time span
+
+
PostgreSQL supports the full set of
SQL date and time types, shown in date
- data type
@@ -1461,15 +1512,12 @@ SELECT b, char_length(b) FROM test2;
time
- data typetime without time zone
- timetime with time zone
- data type
@@ -1587,17 +1635,14 @@ SELECT b, char_length(b) FROM test2;
timestamp
- data typetimestamp with time zone
- data typetimestamp without time zone
- data type
@@ -1797,13 +1842,13 @@ January 8 04:05:06 1999 PST
dateoutput format
- Formatting
+ formattingtimeoutput format
- Formatting
+ formatting
@@ -1924,7 +1969,7 @@ January 8 04:05:06 1999 PST
Time Zones
- time zones
+ time zone
@@ -2265,7 +2310,11 @@ SELECT * FROM test1 WHERE a;
Line Segments
- line
+ lseg
+
+
+
+ line segment
@@ -2293,6 +2342,10 @@ SELECT * FROM test1 WHERE a;
box (data type)
+
+ rectangle
+
+
Boxes are represented by pairs of points that are opposite
corners of the box.
@@ -2431,7 +2484,7 @@ SELECT * FROM test1 WHERE a;
network
- addresses
+ data types
@@ -2708,7 +2761,7 @@ SELECT * FROM test1 WHERE a;
Bit String Types
- bit strings
+ bit stringdata type
@@ -3045,11 +3098,6 @@ SELECT * FROM test;
-
- record>
- Identifies a function returning an unspecified row type.
-
-
any>Indicates that a function accepts any input data type whatever.
@@ -3058,23 +3106,24 @@ SELECT * FROM test;
anyarray>Indicates that a function accepts any array data type
- (see ).
+ (see ).
anyelement>Indicates that a function accepts any data type
- (see ).
+ (see ).
- void>
- Indicates that a function returns no value.
+ cstring>
+ Indicates that a function accepts or returns a null-terminated C string.
- trigger>
- A trigger function is declared to return trigger.>
+ internal>
+ Indicates that a function accepts or returns a server-internal
+ data type.
@@ -3083,14 +3132,18 @@ SELECT * FROM test;
- cstring>
- Indicates that a function accepts or returns a null-terminated C string.
+ record>
+ Identifies a function returning an unspecified row type.
- internal>
- Indicates that a function accepts or returns a server-internal
- data type.
+ trigger>
+ A trigger function is declared to return trigger.>
+
+
+
+ void>
+ Indicates that a function returns no value.
diff --git a/doc/src/sgml/datetime.sgml b/doc/src/sgml/datetime.sgml
index c205ee9c314..9c97f633898 100644
--- a/doc/src/sgml/datetime.sgml
+++ b/doc/src/sgml/datetime.sgml
@@ -1,5 +1,5 @@
@@ -364,7 +364,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datetime.sgml,v 2.32 2003/07/29 00:03:17 tg
- time zones
+ time zone
+ abbreviations
@@ -536,18 +537,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datetime.sgml,v 2.32 2003/07/29 00:03:17 tg
+07:00Christmas (Island) Time
-
MMT+06:30
- Myannar Time
+ Myanmar TimeALMT
@@ -759,6 +752,21 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datetime.sgml,v 2.32 2003/07/29 00:03:17 tg
-01:00West Africa Time
+
+ FNST
+ -01:00
+ Fernando de Noronha Summer Time
+
+
+ FNT
+ -02:00
+ Fernando de Noronha Time
+
+
+ BRST
+ -02:00
+ Brasilia Summer Time
+ NDT-02:30
@@ -774,6 +782,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datetime.sgml,v 2.32 2003/07/29 00:03:17 tg
-03:00(unknown)
+
+ BRT
+ -03:00
+ Brasilia Time
+ NFT-03:30
@@ -794,11 +807,6 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datetime.sgml,v 2.32 2003/07/29 00:03:17 tg
-04:00Atlantic/Porto Acre Summer Time
-
- ACT
- -05:00
- Atlantic/Porto Acre Standard Time
- EDT-04:00
@@ -811,6 +819,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/datetime.sgml,v 2.32 2003/07/29 00:03:17 tg
GMT +4 hours
-->
+
+ ACT
+ -05:00
+ Atlantic/Porto Acre Standard Time
+ CDT-05:00
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index fc6cdc331c2..183a8f790d3 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -1,4 +1,4 @@
-
+
Data Definition
@@ -19,6 +19,18 @@
Table Basics
+
+ table
+
+
+
+ row
+
+
+
+ column
+
+
A table in a relational database is much like a table on paper: It
consists of rows and columns. The number and order of the columns
@@ -60,6 +72,11 @@
containing both date and time.
+
+ table
+ creating
+
+
To create a table, you use the aptly named CREATE
TABLE command. In this command you specify at least a
@@ -114,6 +131,11 @@ CREATE TABLE products (
highly unusual and often a questionable design.
+
+ table
+ removing
+
+
If you no longer need a table, you can remove it using the
DROP TABLE command. For example:
@@ -156,8 +178,8 @@ DROP TABLE products;
- columns
- system columns
+ column
+ system column
@@ -167,6 +189,7 @@ DROP TABLE products;
OID
+ column
The object identifier (object ID) of a row. This is a serial
number that is automatically added by
@@ -182,6 +205,10 @@ DROP TABLE products;
tableoid>
+
+ tableoid
+
+
The OID of the table containing this row. This column is
particularly handy for queries that select from inheritance
@@ -197,6 +224,10 @@ DROP TABLE products;
xmin>
+
+ xmin
+
+
The identity (transaction ID) of the inserting transaction for
this tuple. (Note: In this context, a tuple is an individual
@@ -209,6 +240,10 @@ DROP TABLE products;
cmin>
+
+ cmin
+
+
The command identifier (starting at zero) within the inserting
transaction.
@@ -219,6 +254,10 @@ DROP TABLE products;
xmax>
+
+ xmax
+
+
The identity (transaction ID) of the deleting transaction, or
zero for an undeleted tuple. It is possible for this column to
@@ -232,6 +271,10 @@ DROP TABLE products;
cmax>
+
+ cmax
+
+
The command identifier within the deleting transaction, or zero.
@@ -241,6 +284,10 @@ DROP TABLE products;
ctid>
+
+ ctid
+
+
The physical location of the tuple within its table. Note that
although the ctid can be used to
@@ -292,6 +339,10 @@ DROP TABLE products;
Default Values
+
+ default value
+
+
A column can be assigned a default value. When a new row is
created and no values are specified for some of the columns, the
@@ -302,6 +353,7 @@ DROP TABLE products;
+ null valuedefault value
If no default value is declared explicitly, the null value is the
default value. This usually makes sense because a null value can
be thought to represent unknown data.
@@ -329,6 +381,10 @@ CREATE TABLE products (
Constraints
+
+ constraint
+
+
Data types are a way to limit the kind of data that can be stored
in a table. For many applications, however, the constraint they
@@ -351,6 +407,15 @@ CREATE TABLE products (
Check Constraints
+
+ check constraint
+
+
+
+ constraint
+ check
+
+
A check constraint is the most generic constraint type. It allows
you to specify that the value in a certain column must satisfy an
@@ -375,6 +440,11 @@ CREATE TABLE products (
would not make too much sense.
+
+ constraint
+ name
+
+
You can also give the constraint a separate name. This clarifies
error messages and allows you to refer to the constraint when you
@@ -444,6 +514,11 @@ CREATE TABLE products (
It's a matter of taste.
+
+ null value
+ with check constraints
+
+
It should be noted that a check constraint is satisfied if the
check expression evaluates to true or the null value. Since most
@@ -457,6 +532,15 @@ CREATE TABLE products (
Not-Null Constraints
+
+ not-null constraint
+
+
+
+ constraint
+ NOT NULL
+
+
A not-null constraint simply specifies that a column must not
assume the null value. A syntax example:
@@ -526,6 +610,15 @@ CREATE TABLE products (
Unique Constraints
+
+ unique constraint
+
+
+
+ constraint
+ unique
+
+
Unique constraints ensure that the data contained in a column or a
group of columns is unique with respect to all the rows in the
@@ -573,6 +666,11 @@ CREATE TABLE products (
+
+ null value
+ with unique constraints
+
+
In general, a unique constraint is violated when there are (at
least) two rows in the table where the values of each of the
@@ -591,6 +689,15 @@ CREATE TABLE products (
Primary Keys
+
+ primary key
+
+
+
+ constraint
+ primary key
+
+
Technically, a primary key constraint is simply a combination of a
unique constraint and a not-null constraint. So, the following
@@ -649,6 +756,19 @@ CREATE TABLE example (
Foreign Keys
+
+ foreign key
+
+
+
+ constraint
+ foreign key
+
+
+
+ referential integrity
+
+
A foreign key constraint specifies that the values in a column (or
a group of columns) must match the values appearing in some row
@@ -749,6 +869,16 @@ CREATE TABLE order_items (
the last table.
+
+ CASCADE
+ foreign key action
+
+
+
+ RESTRICT
+ foreign key action
+
+
We know that the foreign keys disallow creation of orders that
do not relate to any products. But what if a product is removed
@@ -998,6 +1128,11 @@ SET SQL_Inheritance TO OFF;
Modifying Tables
+
+ table
+ modifying
+
+
When you create a table and you realize that you made a mistake, or
the requirements of the application changed, then you can drop the
@@ -1042,6 +1177,11 @@ SET SQL_Inheritance TO OFF;
Adding a Column
+
+ column
+ adding
+
+
To add a column, use this command:
@@ -1070,6 +1210,11 @@ ALTER TABLE products ADD COLUMN description text CHECK (description <> '')
Removing a Column
+
+ column
+ removing
+
+
To remove a column, use this command:
@@ -1081,6 +1226,11 @@ ALTER TABLE products DROP COLUMN description;
Adding a Constraint
+
+ constraint
+ adding
+
+
To add a constraint, the table constraint syntax is used. For example:
@@ -1104,6 +1254,11 @@ ALTER TABLE products ALTER COLUMN product_no SET NOT NULL;
Removing a Constraint
+
+ constraint
+ removing
+
+
To remove a constraint you need to know its name. If you gave it
a name then that's easy. Otherwise the system assigned a
@@ -1127,6 +1282,11 @@ ALTER TABLE products ALTER COLUMN product_no DROP NOT NULL;
Changing the Default
+
+ default value
+ changing
+
+
To set a new default for a column, use a command like this:
@@ -1146,6 +1306,11 @@ ALTER TABLE products ALTER COLUMN price DROP DEFAULT;
Renaming a Column
+
+ column
+ renaming
+
+
To rename a column:
@@ -1157,6 +1322,11 @@ ALTER TABLE products RENAME COLUMN product_no TO product_number;
Renaming a Table
+
+ table
+ renaming
+
+
To rename a table:
@@ -1169,6 +1339,15 @@ ALTER TABLE products RENAME TO items;
Privileges
+
+ privilege
+
+
+
+ permission
+ privilege
+
+
When you create a database object, you become its owner. By
default, only the owner of an object can do anything with the
@@ -1241,12 +1420,8 @@ REVOKE ALL ON accounts FROM PUBLIC;
Schemas
-
- schemas
-
-
-
- namespaces
+
+ schema
@@ -1313,6 +1488,11 @@ REVOKE ALL ON accounts FROM PUBLIC;
Creating a Schema
+
+ schema
+ creating
+
+
To create a separate schema, use the command CREATE
SCHEMA. Give the schema a name of your choice. For
@@ -1323,11 +1503,11 @@ CREATE SCHEMA myschema;
- qualified names
+ qualified name
- names
+ namequalified
@@ -1359,6 +1539,11 @@ CREATE TABLE myschema.mytable (
the following chapters.
+
+ schema
+ removing
+
+
To drop a schema if it's empty (all objects in it have been
dropped), use
@@ -1394,6 +1579,11 @@ CREATE SCHEMA schemaname AUTHORIZATION u
The Public Schema
+
+ schema
+ public
+
+
In the previous sections we created tables without specifying any
schema names. By default, such tables (and other objects) are
@@ -1417,11 +1607,11 @@ CREATE TABLE public.products ( ... );
- unqualified names
+ unqualified name
- names
+ nameunqualified
@@ -1437,6 +1627,11 @@ CREATE TABLE public.products ( ... );
in other schemas in the database.
+
+ schema
+ current
+
+
The first schema named in the search path is called the current schema.
Aside from being the first schema searched, it is also the schema in
@@ -1444,6 +1639,10 @@ CREATE TABLE public.products ( ... );
command does not specify a schema name.
+
+ search_path
+
+
To show the current search path, use the following command:
@@ -1523,6 +1722,11 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
Schemas and Privileges
+
+ privilege
+ for schemas
+
+
By default, users cannot see the objects in schemas they do not
own. To allow that, the owner of the schema needs to grant the
@@ -1550,9 +1754,14 @@ REVOKE CREATE ON SCHEMA public FROM PUBLIC;
-
+ The System Catalog Schema
+
+ system catalog
+ schema
+
+
In addition to public> and user-created schemas, each
database contains a pg_catalog> schema, which contains
@@ -1701,6 +1910,16 @@ REVOKE CREATE ON SCHEMA public FROM PUBLIC;
Dependency Tracking
+
+ CASCADE
+ with DROP
+
+
+
+ RESTRICT
+ with DROP
+
+
When you create complex database structures involving many tables
with foreign key constraints, views, triggers, functions, etc. you
diff --git a/doc/src/sgml/dfunc.sgml b/doc/src/sgml/dfunc.sgml
index 3898a2bc176..57fb6f208f3 100644
--- a/doc/src/sgml/dfunc.sgml
+++ b/doc/src/sgml/dfunc.sgml
@@ -1,5 +1,5 @@
@@ -8,9 +8,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/dfunc.sgml,v 1.25 2003/04/10 01:22:44 peter
Before you are able to use your
PostgreSQL extension functions written in
- C, they must be compiled and linked in a special way to produce a file
- that can be dynamically loaded by the server. To be
- precise, a shared library needs to be created.
+ C, they must be compiled and linked in a special way to produce a
+ file that can be dynamically loaded by the server. To be precise, a
+ shared library needs to be
+ created.shared library>
+
@@ -26,17 +28,18 @@ $Header: /cvsroot/pgsql/doc/src/sgml/dfunc.sgml,v 1.25 2003/04/10 01:22:44 peter
- PIC>>
- Creating shared libraries is generally analogous to linking
- executables: first the source files are compiled into object files,
- then the object files are linked together. The object files need to
- be created as position-independent code
- (PIC), which conceptually means that they can be
- placed at an arbitrary location in memory when they are loaded by the
- executable. (Object files intended for executables are usually not compiled
- that way.) The command to link a shared library contains special
- flags to distinguish it from linking an executable. --- At least
- this is the theory. On some systems the practice is much uglier.
+ PIC>> Creating shared libraries is generally
+ analogous to linking executables: first the source files are
+ compiled into object files, then the object files are linked
+ together. The object files need to be created as
+ position-independent code
+ (PIC),PIC>> which
+ conceptually means that they can be placed at an arbitrary location
+ in memory when they are loaded by the executable. (Object files
+ intended for executables are usually not compiled that way.) The
+ command to link a shared library contains special flags to
+ distinguish it from linking an executable. --- At least this is the
+ theory. On some systems the practice is much uglier.
@@ -57,7 +60,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/dfunc.sgml,v 1.25 2003/04/10 01:22:44 peter
BSD/OS>
- BSD/OS>>
+ BSD/OS>shared library>>
The compiler flag to create PIC is
@@ -75,7 +78,7 @@ ld -shared -o foo.so foo.o
FreeBSD>
- FreeBSD>>
+ FreeBSD>shared library>>
The compiler flag to create PIC is
@@ -93,7 +96,7 @@ gcc -shared -o foo.so foo.o
HP-UX>
- HP-UX>>
+ HP-UX>shared library>>
The compiler flag of the system compiler to create
@@ -120,7 +123,7 @@ ld -b -o foo.sl foo.o
IRIX>
- IRIX>>
+ IRIX>shared library>>
PIC is the default, no special compiler
@@ -136,7 +139,7 @@ ld -shared -o foo.so foo.o
Linux>
- Linux>>
+ Linux>shared library>>
The compiler flag to create PIC is
@@ -155,7 +158,7 @@ cc -shared -o foo.so foo.o
MacOS X>
- MacOS X>>
+ MacOS X>shared library>>
Here is an example. It assumes the developer tools are installed.
@@ -169,7 +172,7 @@ cc -bundle -flat_namespace -undefined suppress -o foo.so foo.o
NetBSD>
- NetBSD>>
+ NetBSD>shared library>>
The compiler flag to create PIC is
@@ -187,7 +190,7 @@ gcc -shared -o foo.so foo.o
OpenBSD>
- OpenBSD>>
+ OpenBSD>shared library>>
The compiler flag to create PIC is
@@ -203,7 +206,7 @@ ld -Bshareable -o foo.so foo.o
Solaris>
- Solaris>>
+ Solaris>shared library>>
The compiler flag to create PIC is
@@ -227,7 +230,7 @@ gcc -G -o foo.so foo.o
Tru64 UNIX>
- Tru64 UNIX>>
+ Tru64 UNIX>shared library>>
Digital UNIX>Tru64 UNIX>>
@@ -246,7 +249,7 @@ ld -shared -expect_unresolved '*' -o foo.so foo.o
UnixWare>
- UnixWare>>
+ UnixWare>shared library>>
The compiler flag to create PIC is
-K
diff --git a/doc/src/sgml/dml.sgml b/doc/src/sgml/dml.sgml
index 6476fcf14ab..4f9343cce98 100644
--- a/doc/src/sgml/dml.sgml
+++ b/doc/src/sgml/dml.sgml
@@ -1,4 +1,4 @@
-
+
Data Manipulation
@@ -20,6 +20,14 @@
Inserting Data
+
+ inserting
+
+
+
+ INSERT
+
+
When a table is created, it contains no data. The first thing to
do before a database can be of much use is to insert data. Data is
@@ -98,6 +106,14 @@ INSERT INTO products DEFAULT VALUES;
Updating Data
+
+ updating
+
+
+
+ UPDATE
+
+
The modification of data that is already in the database is
referred to as updating. You can update individual rows, all the
@@ -182,6 +198,14 @@ UPDATE mytable SET a = 5, b = 3, c = 1 WHERE a > 0;
Deleting Data
+
+ deleting
+
+
+
+ DELETE
+
+
So far we have explained how to add data to tables and how to
change data. What remains is to discuss how to remove data that is
diff --git a/doc/src/sgml/ecpg.sgml b/doc/src/sgml/ecpg.sgml
index c26b10ab0e3..4c9fb206290 100644
--- a/doc/src/sgml/ecpg.sgml
+++ b/doc/src/sgml/ecpg.sgml
@@ -1,11 +1,13 @@
ECPG - Embedded SQL in Cembedded SQLin C
+ C
+ ECPG
This chapter describes the embedded SQL package
diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml
index 7d0f65f0679..f8e0ec08ac3 100644
--- a/doc/src/sgml/extend.sgml
+++ b/doc/src/sgml/extend.sgml
@@ -1,5 +1,5 @@
@@ -80,16 +80,25 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.23 2003/08/09 22:50:21 tgl
-
+ The PostgreSQL Type System
-
- extending SQL
- types
+
+ base type
+
+
+
+ data type
+ base
+
+
+
+ composite type
-
- data types
+
+ data type
+ composite
@@ -138,15 +147,25 @@ $Header: /cvsroot/pgsql/doc/src/sgml/extend.sgml,v 1.23 2003/08/09 22:50:21 tgl
pseudo-types.
-
+ Polymorphic Types and Functions
-
- polymorphic types
+
+ polymorphic type
+
+
+
+ polymorphic function
+
+
+
+ type
+ polymorphic
-
- polymorphic functions
+
+ function
+ polymorphic
diff --git a/doc/src/sgml/filelist.sgml b/doc/src/sgml/filelist.sgml
index 4ba2bd9e51a..888220d8df1 100644
--- a/doc/src/sgml/filelist.sgml
+++ b/doc/src/sgml/filelist.sgml
@@ -1,4 +1,4 @@
-
+
@@ -68,7 +68,6 @@
-
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 6729dc677e8..59dd23c2efa 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -1,5 +1,5 @@
@@ -7,11 +7,11 @@ PostgreSQL documentation
Functions and Operators
- functions
+ function
- operators
+ operator
@@ -40,7 +40,7 @@ PostgreSQL documentation
Logical Operators
- operators
+ operatorlogical
@@ -54,18 +54,27 @@ PostgreSQL documentation
The usual logical operators are available:
- and
- operator
+ AND (operator)
- or
- operator
+ OR (operator)
- not
- operator
+ NOT (operator)
+
+
+
+ conjunction
+
+
+
+ disjunction
+
+
+
+ negation
@@ -252,7 +261,7 @@ PostgreSQL documentation
between
In addition to the comparison operators, the special
- BETWEEN construct is available.
+ BETWEEN construct is available.BETWEENa BETWEEN x AND y
@@ -284,6 +293,7 @@ PostgreSQL documentation
expression ISNULL
expression NOTNULL
+ null valuecomparing
@@ -847,7 +857,7 @@ PostgreSQL documentation
String concatenation
- character strings
+ character stringconcatenation
@@ -869,12 +879,12 @@ PostgreSQL documentation
Number of characters in string
- character strings
+ character stringlengthlength
- character strings
+ of a character stringcharacter strings, length
@@ -1110,12 +1120,12 @@ PostgreSQL documentation
Number of characters in string
- character strings
+ character stringlengthlength
- character strings
+ of a character stringcharacter strings, length
@@ -1174,7 +1184,7 @@ PostgreSQL documentation
- quote_ident(string text)
+ quote_ident(string text)quote_ident>>text
Return the given string suitably quoted to be used as an identifier
@@ -1188,7 +1198,7 @@ PostgreSQL documentation
- quote_literal(string text)
+ quote_literal(string text)quote_literal>>text
Return the given string suitably quoted to be used as a string literal
@@ -2055,6 +2065,11 @@ PostgreSQL documentation
Binary String Functions and Operators
+
+ binary data
+ functions
+
+
This section describes functions and operators for examining and
manipulating values of type bytea.
@@ -2092,7 +2107,7 @@ PostgreSQL documentation
String concatenation
- binary strings
+ binary stringconcatenation
@@ -2243,12 +2258,12 @@ PostgreSQL documentation
Length of binary string
- binary strings
+ binary stringlengthlength
- binary strings
+ of a binary stringbinary strings, length
@@ -2321,8 +2336,8 @@ PostgreSQL documentation
LIKE
-
- like
+
+ LIKE
@@ -2420,12 +2435,12 @@ PostgreSQL documentation
Regular Expressions
- regular expressions
+ regular expression
- similar to
+ SIMILAR TO
@@ -2547,7 +2562,7 @@ substring('foobar' from '#"o_b#"%' for '#') NULLPOSIX Regular Expressions
- regular expressions
+ regular expressionpattern matching
@@ -3794,6 +3809,10 @@ substring('foobar' from 'o(.)b') oformatting
+
+ to_char
+
+
The PostgreSQL formatting functions
provide a powerful set of tools for converting various data types
@@ -3870,6 +3889,11 @@ substring('foobar' from 'o(.)b') o
+
+ Warning. to_char(interval, text)
+ is deprecated and should not be used in newly-written code. Will be removed in the next version.
+
+
In an output template string (for to_char>), there are certain patterns that are
recognized and replaced with appropriately-formatted data from the value
@@ -5999,7 +6023,7 @@ SELECT TIMESTAMP 'now';
Sequence-Manipulation Functions
- sequences
+ sequencenextval
@@ -6162,11 +6186,11 @@ SELECT setval('foo', 42, false); Next nextval> wi
Conditional Expressions
- case
+ CASE
- conditionals
+ conditional expression
@@ -6287,8 +6311,12 @@ SELECT a,
COALESCE>
+
+ COALESCE
+
+
-COALESCE(value, ...)
+coalesce(value, ...)
@@ -6497,7 +6525,8 @@ SET search_path TO schema> , schema>, ..
configuration
- server
+ of the server
+ functions
@@ -6534,6 +6563,11 @@ SELECT set_config('show_statement_stats', 'off', false);
+
+ privilege
+ querying
+
+
lists functions that
allow the user to query object access privileges programmatically.
@@ -6966,6 +7000,11 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
col_description
+
+ comment
+ about database objects
+
+
The function shown in extract comments
@@ -7027,7 +7066,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
shows the operators
- available for the array types.
+ available for array types.
+
+ See for more details about array operator
+ behavior.
+
+
shows the functions
available for use with array types. See
@@ -7162,7 +7206,7 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
for NULL inputs
array_cat(ARRAY[1,2,3], ARRAY[4,5,6])
- {{1,2,3},{4,5,6}}
+ {1,2,3,4,5,6}
@@ -7262,6 +7306,11 @@ SELECT pg_type_is_visible('myschema.widget'::regtype);
Aggregate Functions
+
+ aggregate function
+ built-in
+
+
Aggregate functions compute a single result
value from a set of input values. average
- functionavg(expression)
@@ -7472,31 +7520,31 @@ SELECT col FROM sometable ORDER BY col ASC LIMIT 1;
Subquery Expressions
- exists
+ EXISTS
- in
+ IN
- not in
+ NOT IN
- any
+ ANY
- all
+ ALL
- some
+ SOME
- subqueries
+ subquery
@@ -7798,6 +7846,11 @@ SELECT col1 FROM tab1
Row-wise Comparison
+
+ comparison
+ of rows
+
+
(expression, expression ...) operator (subquery)
diff --git a/doc/src/sgml/indices.sgml b/doc/src/sgml/indices.sgml
index 4e79084e7ec..45166fcdea0 100644
--- a/doc/src/sgml/indices.sgml
+++ b/doc/src/sgml/indices.sgml
@@ -1,10 +1,10 @@
-
+
Indexes
- indexes
+ index
@@ -109,12 +109,12 @@ CREATE INDEX test1_id_index ON test1 (id);
B-tree, R-tree, GiST, and Hash. Each index type is more appropriate for
a particular query type because of the algorithm it uses.
- indexes
+ indexB-treeB-tree
- indexes
+ index
By
default, the CREATE INDEX command will create a
@@ -147,12 +147,12 @@ CREATE INDEX test1_id_index ON test1 (id);
- indexes
+ indexR-treeR-tree
- indexes
+ index
R-tree indexes are especially suited for spatial data. To create
an R-tree index, use a command of the form
@@ -178,12 +178,12 @@ CREATE INDEX name ON table
- indexes
+ indexhashhash
- indexes
+ index
The query planner will consider using a hash index whenever an
indexed column is involved in a comparison using the
@@ -219,7 +219,7 @@ CREATE INDEX name ON tableMulticolumn Indexes
- indexes
+ indexmulticolumn
@@ -294,7 +294,7 @@ SELECT name FROM test2 WHERE major = constant OR mino
Unique Indexes
- indexes
+ indexunique
@@ -337,8 +337,8 @@ CREATE UNIQUE INDEX name ON tableIndexes on Expressions
- indexes
- on expressions
+ index
+ on expressions
@@ -392,6 +392,10 @@ CREATE INDEX people_names ON people ((first_name || ' ' || last_name));
Operator Classes
+
+ operator class
+
+
An index definition may specify an operator
class for each column of an index.
@@ -492,7 +496,7 @@ SELECT am.amname AS index_method,
Partial Indexes
- indexes
+ indexpartial
@@ -709,6 +713,11 @@ CREATE UNIQUE INDEX tests_success_constraint ON tests (subject, target)
Examining Index Usage
+
+ index
+ examining usage
+
+
Although indexes in PostgreSQL> do not need
maintenance and tuning, it is still important to check
diff --git a/doc/src/sgml/installation.sgml b/doc/src/sgml/installation.sgml
index 6f4f8486023..ac24dc76720 100644
--- a/doc/src/sgml/installation.sgml
+++ b/doc/src/sgml/installation.sgml
@@ -1,4 +1,4 @@
-
+
PostgreSQL>]]>
@@ -169,10 +169,9 @@ su - postgres
- To build the Python interface module or the PL/Python server
- programming language, you need a Python installation, including
- the header files.
- Since PL/Python will be a shared library, the
+ To build the PL/Python server programming language, you need a
+ Python installation, including the header files. Since
+ PL/Python will be a shared library, the
libpythonlibpython library must be a shared library
also on most platforms. This is not the case in a default
@@ -383,6 +382,7 @@ JAVACMD=$JAVA_HOME/bin/java
pg_dumpall
+ use during upgrade
To back up your database installation, type:
@@ -750,10 +750,7 @@ JAVACMD=$JAVA_HOME/bin/java
--with-python
- Build the Python interface module and the PL/Python
- server-side language. You need to have root access to be able
- to install the Python module at its default place
- (/usr/lib/pythonx>.y>>).
+ Build the PL/Python server-side language.
@@ -875,8 +872,8 @@ JAVACMD=$JAVA_HOME/bin/java
--with-pam
- Build with PAM> (Pluggable Authentication Modules)
- support.
+ Build with PAM>PAM>>
+ (Pluggable Authentication Modules) support.
@@ -1078,20 +1075,6 @@ All of PostgreSQL is successfully made. Ready to install.
possibly can, you will have to do manual work.
-
- If you built the Python interfaces and you were not the
- root user when you executed the above command then that part of
- the installation probably failed. In that case you should become
- the root user and then do
-
-gmake -C src/interfaces/python install
-
- If you do not have root access you are on your own:
- you can still take the required files and place them in
- other directories where Python can find them, but how to
- do that is left as an exercise.
-
-
The standard installation provides only the header files needed for client
application development. If you plan to do any server-side program
@@ -1163,7 +1146,7 @@ All of PostgreSQL is successfully made. Ready to install.
Shared Libraries
- shared libraries
+ shared library
@@ -1284,7 +1267,6 @@ set path = ( /usr/local/pgsql/bin $path )
MANPATH
- man pages
To enable your system to find the man>
documentation, you need to add lines like the following to a
diff --git a/doc/src/sgml/jdbc.sgml b/doc/src/sgml/jdbc.sgml
index a577398bbb4..b524f9dec8c 100644
--- a/doc/src/sgml/jdbc.sgml
+++ b/doc/src/sgml/jdbc.sgml
@@ -1,10 +1,18 @@
JDBC Interface
+
+ JDBC
+
+
+
+ Java
+
+
JDBC is a core API of Java 1.1 and later.
It provides a standard set of
@@ -66,6 +74,14 @@ $Header: /cvsroot/pgsql/doc/src/sgml/Attic/jdbc.sgml,v 1.47 2003/08/07 05:06:40
Setting up the Class Path
+
+ class path
+
+
+
+ CLASSPATH
+
+
To use the driver, the JAR archive (named
postgresql.jar if you built from source, otherwise
@@ -316,6 +332,18 @@ db.close();
Issuing a Query and Processing the Result
+
+ Statement
+
+
+
+ PreparedStatement
+
+
+
+ ResultSet
+
+
Any time you want to issue SQL statements to
the database, you require a Statement or
@@ -681,6 +709,16 @@ st.close();
Storing Binary Data
+
+ bytea
+ in JDBC
+
+
+
+ large object
+ in JDBC
+
+
PostgreSQL provides two distinct ways to
store binary data. Binary data can be stored in a table using
@@ -2597,6 +2635,11 @@ public void unlink(int oid) throws SQLException
Using the Driver in a Multithreaded or a Servlet Environment
+
+ threads
+ with JDBC
+
+
A problem with many JDBC drivers is that only
one thread can use a Connection at any one
@@ -2645,6 +2688,15 @@ public void unlink(int oid) throws SQLException
Connection Pools and Data Sources
+
+ connection pool
+ in JDBC
+
+
+
+ DataSource
+
+
JDBC> 2 introduced standard connection pooling features in an
add-on API> known as the JDBC 2.0 Optional
@@ -3029,7 +3081,11 @@ try {
- Data Sources and JNDI
+ Data Sources and JNDI
+
+
+ JNDI
+
All the ConnectionPoolDataSource and
diff --git a/doc/src/sgml/keywords.sgml b/doc/src/sgml/keywords.sgml
index 26764553f87..b6d129354a2 100644
--- a/doc/src/sgml/keywords.sgml
+++ b/doc/src/sgml/keywords.sgml
@@ -1,10 +1,10 @@
-
+
SQL Key Words
- key words
+ key wordlist of
diff --git a/doc/src/sgml/libpgtcl.sgml b/doc/src/sgml/libpgtcl.sgml
index 220a7d42be2..afcc7061ede 100644
--- a/doc/src/sgml/libpgtcl.sgml
+++ b/doc/src/sgml/libpgtcl.sgml
@@ -125,8 +125,8 @@
The pg_lo_* commands are interfaces to the
large object features of
- PostgreSQL.Large
- Object>> The functions are designed to mimic the analogous file
+ PostgreSQL.large
+ object>in pgctl>> The functions are designed to mimic the analogous file
system functions in the standard Unix file system interface. The
pg_lo_* commands should be used within a
BEGIN/COMMIT transaction
@@ -1043,12 +1043,12 @@ pg_listen connnotifyNamePostgreSQL client
application issues a
- NOTIFYNOTIFY>in
- pgtcl>> command referencing that name. The command string is
- executed from the Tcl idle loop. That is the normal idle state of
- an application written with Tk. In non-Tk Tcl shells, you can
- execute update or vwait
- to cause the idle loop to be entered.
+ NOTIFYNOTIFY>in pgtcl>> command referencing that name. The
+ command string is executed from the Tcl idle loop. That is the
+ normal idle state of an application written with Tk. In non-Tk Tcl
+ shells, you can execute update or
+ vwait to cause the idle loop to be entered.
diff --git a/doc/src/sgml/libpq.sgml b/doc/src/sgml/libpq.sgml
index 8284d4b5f8d..935b1c1186d 100644
--- a/doc/src/sgml/libpq.sgml
+++ b/doc/src/sgml/libpq.sgml
@@ -1,5 +1,5 @@
@@ -9,6 +9,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.131 2003/08/13 16:29:03 tgl
libpq
+
+ C
+
+
libpq is the C
application programmer's interface to
@@ -31,9 +35,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.131 2003/08/13 16:29:03 tgl
- Client programs that use libpq must include the
- header file libpq-fe.h and must link with the
- libpq library.
+ Client programs that use libpq must
+ include the header file
+ libpq-fe.hlibpq-fe.h>>
+ and must link with the libpq library.
@@ -45,17 +50,18 @@ $Header: /cvsroot/pgsql/doc/src/sgml/libpq.sgml,v 1.131 2003/08/13 16:29:03 tgl
application program can have several backend connections open at
one time. (One reason to do that is to access more than one
database.) Each connection is represented by a
- PGconn> object which is obtained from the function
- PQconnectdb> or PQsetdbLogin>. Note that
- these functions will always return a non-null object pointer,
- unless perhaps there is too little memory even to allocate the
- PGconn> object. The PQstatus> function
- should be called to check whether a connection was successfully
- made before queries are sent via the connection object.
+ PGconn>PGconn>> object which
+ is obtained from the function PQconnectdb> or
+ PQsetdbLogin>. Note that these functions will always
+ return a non-null object pointer, unless perhaps there is too
+ little memory even to allocate the PGconn> object.
+ The PQstatus> function should be called to check
+ whether a connection was successfully made before queries are sent
+ via the connection object.
- PQconnectdb
+ PQconnectdbPQconnectdb>>
Makes a new connection to the database server.
@@ -93,12 +99,13 @@ PGconn *PQconnectdb(const char *conninfo);
host
- Name of host to connect to.
- If this begins with a slash, it specifies Unix-domain communication
- rather than TCP/IP communication; the value is the name of the
- directory in which the socket file is stored.
- The default is to connect to a Unix-domain socket in
- /tmp.
+ Name of host to connect to.host name>>
+ If this begins with a slash, it specifies Unix-domain
+ communication rather than TCP/IP communication; the value is the
+ name of the directory in which the socket file is stored. The
+ default is to connect to a Unix-domain socket in
+ /tmp.Unix domain
+ socket>>
@@ -144,8 +151,9 @@ PGconn *PQconnectdb(const char *conninfo);
port
- Port number to connect to at the server host,
- or socket file name extension for Unix-domain connections.
+ Port number to connect to at the server host, or socket file
+ name extension for Unix-domain
+ connections.port>>
@@ -209,44 +217,51 @@ PGconn *PQconnectdb(const char *conninfo);
sslmode
-
- This option determines whether or with what priority an SSL>
- connection will be negotiated with the server. There are four
- modes: disable> will attempt only an unencrypted
- SSL> connection; allow> will negotiate,
- trying first a non-SSL> connection, then if that fails,
- trying an SSL> connection; prefer>
- (the default) will negotiate, trying first an SSL> connection,
- then if that fails, trying a regular non-SSL> connection;
- require> will try only an SSL> connection.
-
-
- If PostgreSQL> is compiled without SSL support,
- using option require> will cause an error, and options
- allow> and prefer> will be tolerated but
- libpq> will be unable to negotiate an SSL>
- connection.
-
+
+ This option determines whether or with what priority an
+ SSL> connection will be negotiated with the
+ server. There are four modes: disable> will attempt
+ only an unencrypted SSL> connection;
+ allow> will negotiate, trying first a
+ non-SSL> connection, then if that fails, trying an
+ SSL> connection; prefer> (the default)
+ will negotiate, trying first an SSL> connection,
+ then if that fails, trying a regular non-SSL>
+ connection; require> will try only an
+ SSL> connection.
+
+
+
+ If PostgreSQL> is compiled without SSL support,
+ using option require> will cause an error, and
+ options allow> and prefer> will be
+ tolerated but libpq> will be unable to negotiate
+ an SSL>
+ connection.SSL>with libpq>
+ requiressl
-
- This option is deprecated in favor of the sslmode>
- setting.
-
-
- If set to 1, an SSL connection to the server is required
- (this is equivalent to sslmode> require>).
- libpq> will then refuse to connect if the server does not
- accept an SSL connection.
- If set to 0 (default), libpq> will negotiate the connection
- type with the server (equivalent to sslmode> prefer>).
- This option is only available if
- PostgreSQL> is compiled with SSL support.
-
+
+ This option is deprecated in favor of the sslmode>
+ setting.
+
+
+
+ If set to 1, an SSL connection to the server
+ is required (this is equivalent to sslmode>
+ require>). libpq> will then refuse
+ to connect if the server does not accept an
+ SSL connection. If set to 0 (default),
+ libpq> will negotiate the connection type with
+ the server (equivalent to sslmode>
+ prefer>). This option is only available if
+ PostgreSQL> is compiled with SSL support.
+
@@ -274,7 +289,7 @@ PGconn *PQconnectdb(const char *conninfo);
- PQsetdbLogin
+ PQsetdbLoginPQsetdbLogin>>
Makes a new connection to the database server.
@@ -299,7 +314,7 @@ PGconn *PQsetdbLogin(const char *pghost,
- PQsetdb
+ PQsetdbPQsetdb>>
Makes a new connection to the database server.
@@ -321,8 +336,8 @@ PGconn *PQsetdb(char *pghost,
- PQconnectStart
- PQconnectPoll
+ PQconnectStartPQconnectStart>>
+ PQconnectPollPQconnectPoll>>nonblocking connection
@@ -515,7 +530,7 @@ switch(PQstatus(conn))
- PQconndefaults
+ PQconndefaultsPQconndefaults>>
Returns the default connection options.
@@ -560,7 +575,7 @@ typedef struct
- PQfinish
+ PQfinishPQfinish>>
Closes the connection to the server. Also frees
@@ -581,7 +596,7 @@ void PQfinish(PGconn *conn);
- PQreset
+ PQresetPQreset>>
Resets the communication channel to the server.
@@ -601,8 +616,8 @@ void PQreset(PGconn *conn);
- PQresetStart
- PQresetPoll
+ PQresetStartPQresetStart>>
+ PQresetPollPQresetPoll>>
Reset the communication channel to the server, in a nonblocking manner.
@@ -665,7 +680,7 @@ These values are fixed for the life of the PGconn> object.
-PQdb
+PQdbPQdb>>
Returns the database name of the connection.
@@ -677,7 +692,7 @@ char *PQdb(const PGconn *conn);
-PQuser
+PQuserPQuser>>
Returns the user name of the connection.
@@ -689,7 +704,7 @@ char *PQuser(const PGconn *conn);
-PQpass
+PQpassPQpass>>
Returns the password of the connection.
@@ -701,7 +716,7 @@ char *PQpass(const PGconn *conn);
-PQhost
+PQhostPQhost>>
Returns the server host name of the connection.
@@ -713,7 +728,7 @@ char *PQhost(const PGconn *conn);
-PQport
+PQportPQport>>
Returns the port of the connection.
@@ -725,13 +740,13 @@ char *PQport(const PGconn *conn);
-PQtty
+PQttyPQtty>>
Returns the debug TTY of the connection.
- (This is obsolete, since the server no longer pays attention
- to the TTY setting, but the function remains
- for backwards compatibility.)
+ (This is obsolete, since the server no longer pays attention
+ to the TTY setting, but the function remains
+ for backwards compatibility.)
char *PQtty(const PGconn *conn);
@@ -740,7 +755,7 @@ char *PQtty(const PGconn *conn);
-PQoptions
+PQoptionsPQoptions>>
Returns the command-line options passed in the connection request.
@@ -759,7 +774,7 @@ are executed on the PGconn> object.
-PQstatus
+PQstatusPQstatus>>
Returns the status of the connection.
@@ -795,7 +810,7 @@ ConnStatusType PQstatus(const PGconn *conn);
-PQtransactionStatus
+PQtransactionStatusPQtransactionStatus>>
Returns the current in-transaction status of the server.
@@ -823,7 +838,7 @@ deprecated and does not exist in later server versions.
-PQparameterStatus
+PQparameterStatusPQparameterStatus>>
Looks up a current parameter setting of the server.
@@ -841,27 +856,27 @@ is not known.
Parameters reported as of the current release include
server_version> (cannot change after startup);
-server_encoding> (also not presently changeable after start);
client_encoding>,
-is_superuser>, and
+is_superuser>,
+session_authorization, and
DateStyle>.
-Pre-3.0-protocol servers do not report parameter settings,
-but libpq> includes logic to obtain values for
-server_version>, server_encoding>, and
-client_encoding>. Applications are encouraged to use
-PQparameterStatus> rather than ad-hoc code to determine these
-values. (Beware however that on a pre-3.0 connection, changing
-client_encoding> via SET> after connection startup
-will not be reflected by PQparameterStatus>.)
+Pre-3.0-protocol servers do not report parameter settings, but
+libpq> includes logic to obtain values for
+server_version>, and client_encoding>.
+Applications are encouraged to use PQparameterStatus>
+rather than ad-hoc code to determine these values. (Beware however
+that on a pre-3.0 connection, changing client_encoding> via
+SET> after connection startup will not be reflected by
+PQparameterStatus>.)
-PQprotocolVersion
+PQprotocolVersionPQprotocolVersion>>
Interrogates the frontend/backend protocol being used.
@@ -881,7 +896,7 @@ only protocol 2.0. (Protocol 1.0 is obsolete and not supported by libpq.)
- PQerrorMessage
+ PQerrorMessagePQerrorMessage>>error message>>
@@ -903,7 +918,7 @@ char *PQerrorMessage(const PGconn* conn);
- PQsocket
+ PQsocketPQsocket>>
Obtains the file descriptor number of the connection socket to
@@ -919,11 +934,13 @@ int PQsocket(const PGconn *conn);
- PQbackendPID
+ PQbackendPIDPQbackendPID>>
- Returns the process ID of the backend server process
- handling this connection.
+ Returns the process ID
+ (PID)PID>determining PID of
+ server process>in libpq>> of the backend server
+ process handling this connection.
int PQbackendPID(const PGconn *conn);
@@ -941,10 +958,10 @@ int PQbackendPID(const PGconn *conn);
- PQgetssl
+ PQgetsslPQgetssl>>
- SSL>>
+ SSL>in libpq
Returns the SSL structure used in the connection, or null
if SSL is not in use.
@@ -985,7 +1002,7 @@ SQL queries and commands.
-PQexec
+PQexecPQexec>>
Submits a command to the server
@@ -1001,8 +1018,8 @@ PGresult *PQexec(PGconn *conn, const char *command);
out-of-memory conditions or serious errors such as inability
to send the command to the server.
If a null pointer is returned, it
- should be treated like a PGRES_FATAL_ERROR result. Use
- PQerrorMessage to get more information about the error.
+ should be treated like a PGRES_FATAL_ERROR result. Use
+ PQerrorMessage to get more information about the error.
@@ -1022,12 +1039,12 @@ condition.
-PQexecParams
+PQexecParamsPQexecParams>>
Submits a command to the server and waits for the result,
- with the ability to pass parameters separately from the SQL
- command text.
+ with the ability to pass parameters separately from the SQL
+ command text.
PGresult *PQexecParams(PGconn *conn,
const char *command,
@@ -1093,11 +1110,11 @@ but has some usefulness as an extra defense against SQL-injection attacks.
-PQexecPrepared
+PQexecPreparedPQexecPrepared>>
Sends a request to execute a prepared statement with given
- parameters, and waits for the result.
+ parameters, and waits for the result.
PGresult *PQexecPrepared(PGconn *conn,
const char *stmtName,
@@ -1138,16 +1155,19 @@ future release.
-The PGresult structure encapsulates the result
-returned by the server.
-libpq application programmers should be careful to
-maintain the PGresult abstraction. Use the accessor functions below to get
-at the contents of PGresult. Avoid directly referencing the fields of the
-PGresult structure because they are subject to change in the future.
+The
+PGresultPGresult>>
+structure encapsulates the result returned by the server.
+libpq application programmers should be
+careful to maintain the PGresult abstraction.
+Use the accessor functions below to get at the contents of
+PGresult. Avoid directly referencing the
+fields of the PGresult structure because they
+are subject to change in the future.
-PQresultStatus
+PQresultStatusPQresultStatus>>
Returns the result status of the command.
@@ -1238,11 +1258,11 @@ processor (see ).
-PQresStatus
+PQresStatusPQresStatus>>
- Converts the enumerated type returned by PQresultStatus> into
- a string constant describing the status code.
+ Converts the enumerated type returned by PQresultStatus> into
+ a string constant describing the status code.
char *PQresStatus(ExecStatusType status);
@@ -1251,7 +1271,7 @@ char *PQresStatus(ExecStatusType status);
-PQresultErrorMessage
+PQresultErrorMessagePQresultErrorMessage>>
Returns the error message associated with the command, or an empty string
@@ -1276,27 +1296,145 @@ when you want to know the status from the latest operation on the connection.
-PQresultErrorField
+PQresultErrorFieldPQresultErrorField>>
Returns an individual field of an error report.
char *PQresultErrorField(const PGresult *res, int fieldcode);
-fieldcode> is an error field identifier defined by the
-PostgreSQL> protocol (see ), for example 'C'> for
-the SQLSTATE error code. NULL is returned if the
+fieldcode> is an error field identifier; see the symbols
+listed below. NULL is returned if the
PGresult is not an error or warning result,
or does not include the specified field. Field values will normally
not include a trailing newline.
-Errors generated internally by libpq will have severity and primary message,
-but typically no other fields. Errors returned by a pre-3.0-protocol server
-will include severity and primary message, and sometimes a detail message,
-but no other fields.
+The following field codes are available:
+
+
+
+PG_DIAG_SEVERITY>
+
+
+The severity; the field contents are ERROR>,
+FATAL>, or PANIC> (in an error message), or
+WARNING>, NOTICE>, DEBUG>,
+INFO>, or LOG> (in a notice message), or a
+localized translation of one of these. Always present.
+
+
+
+
+
+PG_DIAG_SQLSTATE>
+
+
+
+The SQLSTATE code for the error (a 5-character string following SQL
+spec conventions). Not localizable. Always present.
+
+
+
+
+
+PG_DIAG_MESSAGE_PRIMARY>
+
+
+The primary human-readable error message (typically one line). Always
+present.
+
+
+
+
+
+PG_DIAG_MESSAGE_DETAIL>
+
+
+Detail: an optional secondary error message carrying more detail about
+the problem. May run to multiple lines.
+
+
+
+
+
+PG_DIAG_MESSAGE_HINT>
+
+
+Hint: an optional suggestion what to do about the problem. This is
+intended to differ from detail in that it offers advice (potentially
+inappropriate) rather than hard facts. May run to multiple lines.
+
+
+
+
+
+PG_DIAG_STATEMENT_POSITION>
+
+
+A string containing a decimal integer indicating an error cursor
+position as an index into the original statement string. The first
+character has index 1, and positions are measured in characters not
+bytes.
+
+
+
+
+
+PG_DIAG_CONTEXT>
+
+
+An indication of the context in which the error occurred. Presently
+this includes a call stack traceback of active PL functions. The
+trace is one entry per line, most recent first.
+
+
+
+
+
+PG_DIAG_SOURCE_FILE>
+
+
+The file name of the source-code location where the error was
+reported.
+
+
+
+
+
+PG_DIAG_SOURCE_LINE>
+
+
+The line number of the source-code location where the error was
+reported.
+
+
+
+
+
+PG_DIAG_SOURCE_FUNCTION>
+
+
+The name of the source-code function reporting the error.
+
+
+
+
+
+
+
+The client is responsible for formatting displayed information to meet
+its needs; in particular it should break long lines as needed.
+Newline characters appearing in the error message fields should be
+treated as paragraph breaks, not line breaks.
+
+
+
+Errors generated internally by libpq will
+have severity and primary message, but typically no other fields.
+Errors returned by a pre-3.0-protocol server will include severity and
+primary message, and sometimes a detail message, but no other fields.
@@ -1309,7 +1447,7 @@ Note that error fields are only available from
-PQclear
+PQclearPQclear>>
Frees the storage associated with a PGresult.
@@ -1331,7 +1469,7 @@ void PQclear(PQresult *res);
-PQmakeEmptyPGresult
+PQmakeEmptyPGresultPQmakeEmptyPGresult>>
Constructs an empty PGresult object with the given status.
@@ -1368,7 +1506,7 @@ values they will act as though the result has zero rows and zero columns.
-PQntuples
+PQntuplesPQntuples>>
Returns the number of rows (tuples)
@@ -1381,7 +1519,7 @@ int PQntuples(const PGresult *res);
-PQnfields
+PQnfieldsPQnfields>>
Returns the number of columns (fields)
@@ -1394,7 +1532,7 @@ int PQnfields(const PGresult *res);
-PQfname
+PQfnamePQfname>>
Returns the column name associated with the given column number.
@@ -1412,7 +1550,7 @@ NULL is returned if the column number is out of range.
-PQfnumber
+PQfnumberPQfnumber>>
Returns the column number
@@ -1430,7 +1568,7 @@ int PQfnumber(const PGresult *res,
-PQftable
+PQftablePQftable>>
Returns the OID of the table from which the given column was fetched.
@@ -1459,7 +1597,7 @@ exactly which table is referenced.
-PQftablecol
+PQftablecolPQftablecol>>
Returns the column number (within its table) of the column making up
@@ -1480,7 +1618,7 @@ or when using pre-3.0 protocol.
-PQfformat
+PQfformatPQfformat>>
Returns the format code indicating the format of the given column.
@@ -1500,7 +1638,7 @@ for future definition.)
-PQftype
+PQftypePQftype>>
Returns the data type associated with the
@@ -1523,7 +1661,7 @@ in the source tree.
-PQfmod
+PQfmodPQfmod>>
Returns the type modifier of the column
@@ -1545,7 +1683,7 @@ in which case the value is always -1.
-PQfsize
+PQfsizePQfsize>>
Returns the size in bytes of the column
@@ -1567,7 +1705,7 @@ A negative value indicates the data type is variable-length.
-PQbinaryTuples
+PQbinaryTuplesPQbinaryTuples>>
Returns 1 if the PGresult> contains binary data
@@ -1589,11 +1727,11 @@ returns 1 only if all columns of the result are binary (format 1).
-PQgetvalue
+PQgetvaluePQgetvalue>>
Returns a single field value of one row
- of a PGresult.
+ of a PGresult.
Row and column numbers start at 0.
char* PQgetvalue(const PGresult *res,
@@ -1629,8 +1767,8 @@ be used past the lifetime of the PGresult structure i
-PQgetisnull
-
+PQgetisnullPQgetisnull>>
+null value>in libpq>
Tests a field for a null value.
Row and column numbers start at 0.
@@ -1650,7 +1788,7 @@ will return an empty string, not a null pointer, for a null field.)
-PQgetlength
+PQgetlengthPQgetlength>>
Returns the actual length of a field value in bytes.
@@ -1673,7 +1811,7 @@ on PQfsize to obtain the actual data length.
-PQprint
+PQprintPQprint>>
Prints out all the rows and, optionally, the
@@ -1719,11 +1857,11 @@ results.
-PQcmdStatus
+PQcmdStatusPQcmdStatus>>
Returns the command status tag from the SQL command that
- generated the PGresult.
+ generated the PGresult.
char * PQcmdStatus(PGresult *res);
@@ -1736,10 +1874,10 @@ data such as the number of rows processed.
-PQcmdTuples
+PQcmdTuplesPQcmdTuples>>
- Returns the number of rows affected by the SQL command.
+ Returns the number of rows affected by the SQL command.
char * PQcmdTuples(PGresult *res);
@@ -1747,23 +1885,25 @@ char * PQcmdTuples(PGresult *res);
If the SQL command that generated the
- PGresult was INSERT>,
- UPDATE>, DELETE, MOVE>,
- or FETCH>, this returns a
- string containing the number of rows affected. If the
+ PGresult was INSERT>,
+ UPDATE>, DELETE, MOVE>,
+ or FETCH>, this returns a
+ string containing the number of rows affected. If the
command was anything else, it returns the empty string.
-PQoidValue
+PQoidValuePQoidValue>>
- Returns the OID of the inserted row, if the
- SQL command was an INSERT
- that inserted exactly one row into a table that has OIDs.
- Otherwise, returns InvalidOid.
+ Returns the OIDOID>in
+ libpq>> of the inserted row, if the
+ SQL command was an
+ INSERT that inserted exactly one row into
+ a table that has OIDs. Otherwise, returns
+ InvalidOid.
Oid PQoidValue(const PGresult *res);
@@ -1772,7 +1912,7 @@ Oid PQoidValue(const PGresult *res);
-PQoidStatus
+PQoidStatusPQoidStatus>>
Returns a string with the OID of the inserted row, if the
@@ -1800,6 +1940,7 @@ It is not thread-safe.
Escaping Strings for Inclusion in SQL Commands
+ PQescapeString>>
escaping strings>>
@@ -1858,13 +1999,15 @@ strings overlap.
Escaping Binary Strings for Inclusion in SQL Commands
+
- escaping binary strings
+ bytea>
+ in libpq>
- PQescapeBytea
+ PQescapeByteaPQescapeBytea>>
Escapes binary data for use within an SQL command with the type
@@ -1916,7 +2059,7 @@ unsigned char *PQescapeBytea(const unsigned char *from,
- PQunescapeBytea
+ PQunescapeByteaPQunescapeBytea>>
Converts an escaped string representation of binary data into binary
@@ -1943,7 +2086,7 @@ unsigned char *PQunescapeBytea(const unsigned char *from, size_t *to_length);
- PQfreemem
+ PQfreememPQfreemem>>
Frees memory allocated by libpq>.
@@ -2016,32 +2159,32 @@ respectively.
-PQsendQuery
+PQsendQueryPQsendQuery>>
Submits a command to the server without
- waiting for the result(s). 1 is returned if the command was
- successfully dispatched and 0 if not (in which case, use
- PQerrorMessage> to get more information about the failure).
+ waiting for the result(s). 1 is returned if the command was
+ successfully dispatched and 0 if not (in which case, use
+ PQerrorMessage> to get more information about the failure).
int PQsendQuery(PGconn *conn, const char *command);
- After successfully calling PQsendQuery, call
+ After successfully calling PQsendQuery, call
PQgetResult one or more
- times to obtain the results. PQsendQuery may not be called
- again (on the same connection) until PQgetResult has returned a null pointer,
- indicating that the command is done.
+ times to obtain the results. PQsendQuery may not be called
+ again (on the same connection) until PQgetResult has returned a null pointer,
+ indicating that the command is done.
-PQsendQueryParams
+PQsendQueryParamsPQsendQueryParams>>
Submits a command and separate parameters to the server without
- waiting for the result(s).
+ waiting for the result(s).
int PQsendQueryParams(PGconn *conn,
const char *command,
@@ -2053,22 +2196,22 @@ int PQsendQueryParams(PGconn *conn,
int resultFormat);
- This is equivalent to PQsendQuery except that
- query parameters can be specified separately from the query string.
- The function's parameters are handled identically to
- PQexecParams. Like
- PQexecParams, it will not work on 2.0-protocol
- connections, and it allows only one command in the query string.
+ This is equivalent to PQsendQuery except that
+ query parameters can be specified separately from the query string.
+ The function's parameters are handled identically to
+ PQexecParams. Like
+ PQexecParams, it will not work on 2.0-protocol
+ connections, and it allows only one command in the query string.
-PQsendQueryPrepared
+PQsendQueryPreparedPQsendQueryPrepared>>
Sends a request to execute a prepared statement with given
- parameters, without waiting for the result(s).
+ parameters, without waiting for the result(s).
int PQsendQueryPrepared(PGconn *conn,
const char *stmtName,
@@ -2079,41 +2222,41 @@ int PQsendQueryPrepared(PGconn *conn,
int resultFormat);
- This is similar to PQsendQueryParams, but the
- command to be executed is specified by naming a previously-prepared
- statement, instead of giving a query string.
- The function's parameters are handled identically to
- PQexecPrepared. Like
- PQexecPrepared, it will not work on 2.0-protocol
- connections.
+ This is similar to PQsendQueryParams, but the
+ command to be executed is specified by naming a previously-prepared
+ statement, instead of giving a query string.
+ The function's parameters are handled identically to
+ PQexecPrepared. Like
+ PQexecPrepared, it will not work on 2.0-protocol
+ connections.
-PQgetResult
+PQgetResultPQgetResult>>
Waits for the next result from a prior
- PQsendQuery,
- PQsendQueryParams, or
- PQsendQueryPrepared call,
- and returns it. A null pointer is returned when the command is complete
- and there will be no more results.
+ PQsendQuery,
+ PQsendQueryParams, or
+ PQsendQueryPrepared call,
+ and returns it. A null pointer is returned when the command is complete
+ and there will be no more results.
PGresult *PQgetResult(PGconn *conn);
- PQgetResult must be called repeatedly until it returns a null pointer,
- indicating that the command is done. (If called when no command is
- active, PQgetResult will just return a null pointer at once.)
- Each non-null result from PQgetResult should be processed using
- the same PGresult> accessor functions previously described.
- Don't forget to free each result object with PQclear when done with it.
- Note that PQgetResult will block only if a command is active and the
- necessary response data has not yet been read by PQconsumeInput.
+ PQgetResult must be called repeatedly until it returns a null pointer,
+ indicating that the command is done. (If called when no command is
+ active, PQgetResult will just return a null pointer at once.)
+ Each non-null result from PQgetResult should be processed using
+ the same PGresult> accessor functions previously described.
+ Don't forget to free each result object with PQclear when done with it.
+ Note that PQgetResult will block only if a command is active and the
+ necessary response data has not yet been read by PQconsumeInput.
@@ -2134,10 +2277,10 @@ more functions:
-PQconsumeInput
+PQconsumeInputPQconsumeInput>>
- If input is available from the server, consume it.
+ If input is available from the server, consume it.
int PQconsumeInput(PGconn *conn);
@@ -2165,7 +2308,7 @@ application can thus use PQconsumeInput to clear the
-PQisBusy
+PQisBusyPQisBusy>>
Returns 1 if a command is busy, that is, PQgetResult would block
@@ -2201,16 +2344,18 @@ if PQisBusy returns false (0). It can also call
-A client that uses PQsendQuery/PQgetResult
-can also attempt to cancel a command that is still being processed by the server.
+A client that uses
+PQsendQuery/PQgetResult can
+also attempt to cancel a command that is still being processed by the
+server.canceling>SQL command>>
-PQrequestCancel
+PQrequestCancelPQrequestCancel>>
- Requests that the server abandon
- processing of the current command.
+ Requests that the server abandon
+ processing of the current command.
int PQrequestCancel(PGconn *conn);
@@ -2259,7 +2404,7 @@ functions may be used.
- PQsetnonblocking
+ PQsetnonblockingPQsetnonblocking>>
Sets the nonblocking status of the connection.
@@ -2289,7 +2434,7 @@ int PQsetnonblocking(PGconn *conn, int arg);
-PQisnonblocking
+PQisnonblockingPQisnonblocking>>
Returns the blocking status of the database connection.
@@ -2306,7 +2451,7 @@ int PQisnonblocking(const PGconn *conn);
-PQflush
+PQflushPQflush>>
Attempts to flush any queued output data to the server.
@@ -2335,6 +2480,8 @@ and then read the response as described above.
The Fast-Path Interface
+fast path>>
+
PostgreSQL provides a fast-path interface to send
simple function calls to the server.
@@ -2350,8 +2497,8 @@ parameters and results substitutes for a fast-path function call.
-The function PQfn requests execution of a server
-function via the fast-path interface:
+The function PQfnPQfn>>
+requests execution of a server function via the fast-path interface:
PGresult* PQfn(PGconn* conn,
int fnid,
@@ -2417,7 +2564,10 @@ set-valued results when using this interface.
Asynchronous Notification
- NOTIFY
+
+ NOTIFY
+ in libpq
+ PostgreSQL offers asynchronous notification via the
@@ -2433,9 +2583,11 @@ not necessary for there to be any associated table.
-libpq applications submit LISTEN and UNLISTEN
-commands as ordinary SQL commands. The arrival of NOTIFY
-messages can subsequently be detected by calling PQnotifies.
+libpq applications submit
+LISTEN and UNLISTEN commands as
+ordinary SQL commands. The arrival of NOTIFY
+messages can subsequently be detected by calling
+PQnotifies.PQnotifies>>
@@ -2443,8 +2595,8 @@ The function PQnotifies
returns the next notification from a list of unhandled
notification messages received from the server. It returns a null pointer if
there are no pending notifications. Once a notification is
- returned from PQnotifies>, it is considered handled and will be
- removed from the list of notifications.
+ returned from PQnotifies>, it is considered handled and will be
+ removed from the list of notifications.
PGnotify* PQnotifies(PGconn *conn);
@@ -2570,7 +2722,7 @@ if any notifications came in during the processing of the command.
-PQnfields
+PQnfieldsPQnfields>with COPY>>
Returns the number of columns (fields) to be copied.
@@ -2579,30 +2731,30 @@ if any notifications came in during the processing of the command.
-PQbinaryTuples
+PQbinaryTuplesPQbinaryTuples>with COPY>>
0 indicates the overall copy format is textual (rows
- separated by newlines, columns separated by separator
- characters, etc).
- 1 indicates the overall copy format is binary.
- See
- for more information.
+ separated by newlines, columns separated by separator
+ characters, etc).
+ 1 indicates the overall copy format is binary.
+ See
+ for more information.
-PQfformat
+PQfformatPQfformat>with COPY>>
Returns the format code (0 for text, 1 for binary) associated
- with each column of the copy operation. The per-column format
- codes will always be zero when the overall copy format is textual,
- but the binary format can support both text and binary columns.
- (However, as of the current implementation of COPY>,
- only binary columns appear in a binary copy; so the per-column
- formats always match the overall format at present.)
+ with each column of the copy operation. The per-column format
+ codes will always be zero when the overall copy format is textual,
+ but the binary format can support both text and binary columns.
+ (However, as of the current implementation of COPY>,
+ only binary columns appear in a binary copy; so the per-column
+ formats always match the overall format at present.)
@@ -2627,7 +2779,7 @@ When using protocol 2.0, all these functions will return 0.
-PQputCopyData
+PQputCopyDataPQputCopyData>>
Sends data to the server during COPY_IN> state.
@@ -2658,7 +2810,7 @@ by the COPY> command; see
-PQputCopyEnd
+PQputCopyEndPQputCopyEnd>>
Sends end-of-data indication to the server during COPY_IN> state.
@@ -2710,7 +2862,7 @@ operation.
-PQgetCopyData
+PQgetCopyDataPQgetCopyData>>
Receives data from the server during COPY_OUT> state.
@@ -2779,7 +2931,7 @@ operation.
-PQgetline
+PQgetlinePQgetline>>
Reads a newline-terminated line of characters
@@ -2815,7 +2967,7 @@ for a terminator line).
-PQgetlineAsync
+PQgetlineAsyncPQgetlineAsync>>
Reads a row of COPY data
@@ -2867,7 +3019,7 @@ than the room actually available.)
-PQputline
+PQputlinePQputline>>
Sends a null-terminated string to the server.
@@ -2901,7 +3053,7 @@ having sent the actual data.
-PQputnbytes
+PQputnbytesPQputnbytes>>
Sends a non-null-terminated string to the server.
@@ -2922,7 +3074,7 @@ specified directly. Use this procedure when sending binary data.
-PQendcopy
+PQendcopyPQendcopy>>
Synchronizes with the server.
@@ -2981,7 +3133,7 @@ These functions control miscellaneous details of
-PQsetErrorVerbosity
+PQsetErrorVerbosityPQsetErrorVerbosity>>
Determines the verbosity of messages returned by
@@ -3007,7 +3159,7 @@ ones.
-PQtrace
+PQtracePQtrace>>
Enables tracing of the client/server communication to a debugging file stream.
@@ -3019,7 +3171,7 @@ void PQtrace(PGconn *conn, FILE *stream);
-PQuntrace
+PQuntracePQuntrace>>
Disables tracing started by PQtrace.
@@ -3036,6 +3188,11 @@ void PQuntrace(PGconn *conn);
Notice Processing
+
+ notice processing
+ in libpq
+
+
Notice and warning messages generated by the server are not returned by the
query execution functions, since they do not imply failure of the query.
@@ -3056,10 +3213,10 @@ work in the notice receiver.
The function PQsetNoticeReceiver
-notice receiver>>
+notice receiver>>PQsetNoticeReceiver>>
sets or examines the current notice receiver for a connection object.
Similarly, PQsetNoticeProcessor
-notice processor>>
+notice processor>>PQsetNoticeProcessor>>
sets or examines the current notice processor.
@@ -3137,7 +3294,7 @@ functions like PQgetvalue.
Environment Variables
- environment variables
+ environment variable
@@ -3426,11 +3583,12 @@ call fe_setauthsvc at all.
-libpq applications that use the crypt
-authentication method rely on the crypt() operating
-system function, which is often not thread-safe. It is better to use the
-md5 method, which is thread-safe on all
-platforms.
+libpq applications that use the
+crypt authentication method rely on the
+crypt() operating system function, which is often
+not thread-safe.crypt>thread
+safety>> It is better to use the md5 method,
+which is thread-safe on all platforms.
@@ -3438,6 +3596,11 @@ platforms.
Building libpq Programs
+
+ compiling
+ libpq applications
+
+
To build (i.e., compile and link) your libpq programs you need to
do all of the following things:
@@ -3482,12 +3645,12 @@ CPPFLAGS += -I/usr/local/pgsql/include
- pg_config>>
If there is any chance that your program might be compiled by
other users then you should not hardcode the directory location
like that. Instead, you can run the utility
- pg_config to find out where the header files
- are on the local system:
+ pg_configpg_config>with libpq>> to find out where the header
+ files are on the local system:
$ pg_config --includedir
/usr/local/include
@@ -3576,7 +3739,7 @@ testlibpq.o(.text+0xa4): undefined reference to `PQerrorMessage'
/*
* testlibpq.c
*
- * Test the C version of LIBPQ, the POSTGRES frontend library.
+ * Test the C version of LIBPQ, the POSTGRES frontend library.
*/
#include <stdio.h>
#include <stdlib.h>
@@ -3585,112 +3748,112 @@ testlibpq.o(.text+0xa4): undefined reference to `PQerrorMessage'
static void
exit_nicely(PGconn *conn)
{
- PQfinish(conn);
- exit(1);
+ PQfinish(conn);
+ exit(1);
}
int
main(int argc, char **argv)
{
- const char *conninfo;
- PGconn *conn;
- PGresult *res;
- int nFields;
- int i,
- j;
-
- /*
- * If the user supplies a parameter on the command line, use it as
- * the conninfo string; otherwise default to setting dbname=template1
- * and using environment variables or defaults for all other connection
- * parameters.
- */
- if (argc > 1)
- conninfo = argv[1];
- else
- conninfo = "dbname = template1";
-
- /* Make a connection to the database */
- conn = PQconnectdb(conninfo);
-
- /* Check to see that the backend connection was successfully made */
- if (PQstatus(conn) != CONNECTION_OK)
- {
- fprintf(stderr, "Connection to database '%s' failed.\n", PQdb(conn));
- fprintf(stderr, "%s", PQerrorMessage(conn));
- exit_nicely(conn);
- }
-
- /*
- * Our test case here involves using a cursor, for which we must be
- * inside a transaction block. We could do the whole thing with a
- * single PQexec() of "select * from pg_database", but that's too
- * trivial to make a good example.
- */
-
- /* Start a transaction block */
- res = PQexec(conn, "BEGIN");
- if (PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- fprintf(stderr, "BEGIN command failed: %s", PQerrorMessage(conn));
- PQclear(res);
- exit_nicely(conn);
- }
-
- /*
- * Should PQclear PGresult whenever it is no longer needed to avoid
- * memory leaks
- */
- PQclear(res);
-
- /*
- * Fetch rows from 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 failed: %s", PQerrorMessage(conn));
- PQclear(res);
- exit_nicely(conn);
- }
- PQclear(res);
-
- res = PQexec(conn, "FETCH ALL in myportal");
- if (PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- fprintf(stderr, "FETCH ALL failed: %s", PQerrorMessage(conn));
- 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 rows */
- 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 ... we don't bother to check for errors ... */
- 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);
-
- return 0;
+ const char *conninfo;
+ PGconn *conn;
+ PGresult *res;
+ int nFields;
+ int i,
+ j;
+
+ /*
+ * If the user supplies a parameter on the command line, use it as
+ * the conninfo string; otherwise default to setting dbname=template1
+ * and using environment variables or defaults for all other connection
+ * parameters.
+ */
+ if (argc > 1)
+ conninfo = argv[1];
+ else
+ conninfo = "dbname = template1";
+
+ /* Make a connection to the database */
+ conn = PQconnectdb(conninfo);
+
+ /* Check to see that the backend connection was successfully made */
+ if (PQstatus(conn) != CONNECTION_OK)
+ {
+ fprintf(stderr, "Connection to database '%s' failed.\n", PQdb(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
+ exit_nicely(conn);
+ }
+
+ /*
+ * Our test case here involves using a cursor, for which we must be
+ * inside a transaction block. We could do the whole thing with a
+ * single PQexec() of "select * from pg_database", but that's too
+ * trivial to make a good example.
+ */
+
+ /* Start a transaction block */
+ res = PQexec(conn, "BEGIN");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ fprintf(stderr, "BEGIN command failed: %s", PQerrorMessage(conn));
+ PQclear(res);
+ exit_nicely(conn);
+ }
+
+ /*
+ * Should PQclear PGresult whenever it is no longer needed to avoid
+ * memory leaks
+ */
+ PQclear(res);
+
+ /*
+ * Fetch rows from 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 failed: %s", PQerrorMessage(conn));
+ PQclear(res);
+ exit_nicely(conn);
+ }
+ PQclear(res);
+
+ res = PQexec(conn, "FETCH ALL in myportal");
+ if (PQresultStatus(res) != PGRES_TUPLES_OK)
+ {
+ fprintf(stderr, "FETCH ALL failed: %s", PQerrorMessage(conn));
+ 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 rows */
+ 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 ... we don't bother to check for errors ... */
+ 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);
+
+ return 0;
}
@@ -3701,7 +3864,7 @@ main(int argc, char **argv)
/*
* testlibpq2.c
- * Test of the asynchronous notification interface
+ * Test of the asynchronous notification interface
*
* Start this program, then from psql in another window do
* NOTIFY TBL2;
@@ -3732,102 +3895,102 @@ main(int argc, char **argv)
static void
exit_nicely(PGconn *conn)
{
- PQfinish(conn);
- exit(1);
+ PQfinish(conn);
+ exit(1);
}
int
main(int argc, char **argv)
{
- const char *conninfo;
- PGconn *conn;
- PGresult *res;
- PGnotify *notify;
- int nnotifies;
-
- /*
- * If the user supplies a parameter on the command line, use it as
- * the conninfo string; otherwise default to setting dbname=template1
- * and using environment variables or defaults for all other connection
- * parameters.
- */
- if (argc > 1)
- conninfo = argv[1];
- else
- conninfo = "dbname = template1";
-
- /* Make a connection to the database */
- conn = PQconnectdb(conninfo);
-
- /* Check to see that the backend connection was successfully made */
- if (PQstatus(conn) != CONNECTION_OK)
- {
- fprintf(stderr, "Connection to database '%s' failed.\n", PQdb(conn));
- fprintf(stderr, "%s", PQerrorMessage(conn));
- exit_nicely(conn);
- }
-
- /*
- * Issue LISTEN command to enable notifications from the rule's NOTIFY.
- */
- res = PQexec(conn, "LISTEN TBL2");
- if (PQresultStatus(res) != PGRES_COMMAND_OK)
- {
- fprintf(stderr, "LISTEN command failed: %s", PQerrorMessage(conn));
- PQclear(res);
- exit_nicely(conn);
- }
-
- /*
- * should PQclear PGresult whenever it is no longer needed to avoid
- * memory leaks
- */
- PQclear(res);
-
- /* Quit after four notifies are received. */
- nnotifies = 0;
- while (nnotifies < 4)
- {
- /*
- * Sleep until something happens on the connection. We use select(2)
- * to wait for input, but you could also use poll() or similar
- * facilities.
- */
- int sock;
- fd_set input_mask;
-
- sock = PQsocket(conn);
-
- if (sock < 0)
- break; /* shouldn't happen */
-
- FD_ZERO(&input_mask);
- FD_SET(sock, &input_mask);
-
- if (select(sock + 1, &input_mask, NULL, NULL, NULL) < 0)
- {
- fprintf(stderr, "select() failed: %s\n", strerror(errno));
- exit_nicely(conn);
- }
-
- /* Now check for input */
- PQconsumeInput(conn);
- while ((notify = PQnotifies(conn)) != NULL)
- {
- fprintf(stderr,
- "ASYNC NOTIFY of '%s' received from backend pid %d\n",
- notify->relname, notify->be_pid);
- PQfreemem(notify);
- nnotifies++;
- }
- }
-
- fprintf(stderr, "Done.\n");
-
- /* close the connection to the database and cleanup */
- PQfinish(conn);
-
- return 0;
+ const char *conninfo;
+ PGconn *conn;
+ PGresult *res;
+ PGnotify *notify;
+ int nnotifies;
+
+ /*
+ * If the user supplies a parameter on the command line, use it as
+ * the conninfo string; otherwise default to setting dbname=template1
+ * and using environment variables or defaults for all other connection
+ * parameters.
+ */
+ if (argc > 1)
+ conninfo = argv[1];
+ else
+ conninfo = "dbname = template1";
+
+ /* Make a connection to the database */
+ conn = PQconnectdb(conninfo);
+
+ /* Check to see that the backend connection was successfully made */
+ if (PQstatus(conn) != CONNECTION_OK)
+ {
+ fprintf(stderr, "Connection to database '%s' failed.\n", PQdb(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
+ exit_nicely(conn);
+ }
+
+ /*
+ * Issue LISTEN command to enable notifications from the rule's NOTIFY.
+ */
+ res = PQexec(conn, "LISTEN TBL2");
+ if (PQresultStatus(res) != PGRES_COMMAND_OK)
+ {
+ fprintf(stderr, "LISTEN command failed: %s", PQerrorMessage(conn));
+ PQclear(res);
+ exit_nicely(conn);
+ }
+
+ /*
+ * should PQclear PGresult whenever it is no longer needed to avoid
+ * memory leaks
+ */
+ PQclear(res);
+
+ /* Quit after four notifies are received. */
+ nnotifies = 0;
+ while (nnotifies < 4)
+ {
+ /*
+ * Sleep until something happens on the connection. We use select(2)
+ * to wait for input, but you could also use poll() or similar
+ * facilities.
+ */
+ int sock;
+ fd_set input_mask;
+
+ sock = PQsocket(conn);
+
+ if (sock < 0)
+ break; /* shouldn't happen */
+
+ FD_ZERO(&input_mask);
+ FD_SET(sock, &input_mask);
+
+ if (select(sock + 1, &input_mask, NULL, NULL, NULL) < 0)
+ {
+ fprintf(stderr, "select() failed: %s\n", strerror(errno));
+ exit_nicely(conn);
+ }
+
+ /* Now check for input */
+ PQconsumeInput(conn);
+ while ((notify = PQnotifies(conn)) != NULL)
+ {
+ fprintf(stderr,
+ "ASYNC NOTIFY of '%s' received from backend pid %d\n",
+ notify->relname, notify->be_pid);
+ PQfreemem(notify);
+ nnotifies++;
+ }
+ }
+
+ fprintf(stderr, "Done.\n");
+
+ /* close the connection to the database and cleanup */
+ PQfinish(conn);
+
+ return 0;
}
@@ -3838,7 +4001,7 @@ main(int argc, char **argv)
/*
* testlibpq3.c
- * Test out-of-line parameters and binary I/O.
+ * Test out-of-line parameters and binary I/O.
*
* Before running this, populate a database with the following commands
* (provided in src/test/examples/testlibpq3.sql):
@@ -3870,125 +4033,125 @@ main(int argc, char **argv)
static void
exit_nicely(PGconn *conn)
{
- PQfinish(conn);
- exit(1);
+ PQfinish(conn);
+ exit(1);
}
int
main(int argc, char **argv)
{
- const char *conninfo;
- PGconn *conn;
- PGresult *res;
- const char *paramValues[1];
- int i,
- j;
- int i_fnum,
- t_fnum,
- b_fnum;
-
- /*
- * If the user supplies a parameter on the command line, use it as
- * the conninfo string; otherwise default to setting dbname=template1
- * and using environment variables or defaults for all other connection
- * parameters.
- */
- if (argc > 1)
- conninfo = argv[1];
- else
- conninfo = "dbname = template1";
-
- /* Make a connection to the database */
- conn = PQconnectdb(conninfo);
-
- /* Check to see that the backend connection was successfully made */
- if (PQstatus(conn) != CONNECTION_OK)
- {
- fprintf(stderr, "Connection to database '%s' failed.\n", PQdb(conn));
- fprintf(stderr, "%s", PQerrorMessage(conn));
- exit_nicely(conn);
- }
-
- /*
- * The point of this program is to illustrate use of PQexecParams()
- * with out-of-line parameters, as well as binary transmission of
- * results. By using out-of-line parameters we can avoid a lot of
- * tedious mucking about with quoting and escaping. Notice how we
- * don't have to do anything special with the quote mark in the
- * parameter value.
- */
-
- /* Here is our out-of-line parameter value */
- paramValues[0] = "joe's place";
-
- res = PQexecParams(conn,
- "SELECT * FROM test1 WHERE t = $1",
- 1, /* one param */
- NULL, /* let the backend deduce param type */
- paramValues,
- NULL, /* don't need param lengths since text */
- NULL, /* default to all text params */
- 1); /* ask for binary results */
-
- if (PQresultStatus(res) != PGRES_TUPLES_OK)
- {
- fprintf(stderr, "SELECT failed: %s", PQerrorMessage(conn));
- PQclear(res);
- exit_nicely(conn);
- }
-
- /* Use PQfnumber to avoid assumptions about field order in result */
- i_fnum = PQfnumber(res, "i");
- t_fnum = PQfnumber(res, "t");
- b_fnum = PQfnumber(res, "b");
-
- for (i = 0; i < PQntuples(res); i++)
- {
- char *iptr;
- char *tptr;
- char *bptr;
- int blen;
- int ival;
-
- /* Get the field values (we ignore possibility they are null!) */
- iptr = PQgetvalue(res, i, i_fnum);
- tptr = PQgetvalue(res, i, t_fnum);
- bptr = PQgetvalue(res, i, b_fnum);
-
- /*
- * The binary representation of INT4 is in network byte order,
- * which we'd better coerce to the local byte order.
- */
- ival = ntohl(*((uint32_t *) iptr));
-
- /*
- * The binary representation of TEXT is, well, text, and since
- * libpq was nice enough to append a zero byte to it, it'll work
- * just fine as a C string.
- *
- * The binary representation of BYTEA is a bunch of bytes, which
- * could include embedded nulls so we have to pay attention to
- * field length.
- */
- blen = PQgetlength(res, i, b_fnum);
-
- printf("tuple %d: got\n", i);
- printf(" i = (%d bytes) %d\n",
- PQgetlength(res, i, i_fnum), ival);
- printf(" t = (%d bytes) '%s'\n",
- PQgetlength(res, i, t_fnum), tptr);
- printf(" b = (%d bytes) ", blen);
- for (j = 0; j < blen; j++)
- printf("\\%03o", bptr[j]);
- printf("\n\n");
- }
-
- PQclear(res);
-
- /* close the connection to the database and cleanup */
- PQfinish(conn);
-
- return 0;
+ const char *conninfo;
+ PGconn *conn;
+ PGresult *res;
+ const char *paramValues[1];
+ int i,
+ j;
+ int i_fnum,
+ t_fnum,
+ b_fnum;
+
+ /*
+ * If the user supplies a parameter on the command line, use it as
+ * the conninfo string; otherwise default to setting dbname=template1
+ * and using environment variables or defaults for all other connection
+ * parameters.
+ */
+ if (argc > 1)
+ conninfo = argv[1];
+ else
+ conninfo = "dbname = template1";
+
+ /* Make a connection to the database */
+ conn = PQconnectdb(conninfo);
+
+ /* Check to see that the backend connection was successfully made */
+ if (PQstatus(conn) != CONNECTION_OK)
+ {
+ fprintf(stderr, "Connection to database '%s' failed.\n", PQdb(conn));
+ fprintf(stderr, "%s", PQerrorMessage(conn));
+ exit_nicely(conn);
+ }
+
+ /*
+ * The point of this program is to illustrate use of PQexecParams()
+ * with out-of-line parameters, as well as binary transmission of
+ * results. By using out-of-line parameters we can avoid a lot of
+ * tedious mucking about with quoting and escaping. Notice how we
+ * don't have to do anything special with the quote mark in the
+ * parameter value.
+ */
+
+ /* Here is our out-of-line parameter value */
+ paramValues[0] = "joe's place";
+
+ res = PQexecParams(conn,
+ "SELECT * FROM test1 WHERE t = $1",
+ 1, /* one param */
+ NULL, /* let the backend deduce param type */
+ paramValues,
+ NULL, /* don't need param lengths since text */
+ NULL, /* default to all text params */
+ 1); /* ask for binary results */
+
+ if (PQresultStatus(res) != PGRES_TUPLES_OK)
+ {
+ fprintf(stderr, "SELECT failed: %s", PQerrorMessage(conn));
+ PQclear(res);
+ exit_nicely(conn);
+ }
+
+ /* Use PQfnumber to avoid assumptions about field order in result */
+ i_fnum = PQfnumber(res, "i");
+ t_fnum = PQfnumber(res, "t");
+ b_fnum = PQfnumber(res, "b");
+
+ for (i = 0; i < PQntuples(res); i++)
+ {
+ char *iptr;
+ char *tptr;
+ char *bptr;
+ int blen;
+ int ival;
+
+ /* Get the field values (we ignore possibility they are null!) */
+ iptr = PQgetvalue(res, i, i_fnum);
+ tptr = PQgetvalue(res, i, t_fnum);
+ bptr = PQgetvalue(res, i, b_fnum);
+
+ /*
+ * The binary representation of INT4 is in network byte order,
+ * which we'd better coerce to the local byte order.
+ */
+ ival = ntohl(*((uint32_t *) iptr));
+
+ /*
+ * The binary representation of TEXT is, well, text, and since
+ * libpq was nice enough to append a zero byte to it, it'll work
+ * just fine as a C string.
+ *
+ * The binary representation of BYTEA is a bunch of bytes, which
+ * could include embedded nulls so we have to pay attention to
+ * field length.
+ */
+ blen = PQgetlength(res, i, b_fnum);
+
+ printf("tuple %d: got\n", i);
+ printf(" i = (%d bytes) %d\n",
+ PQgetlength(res, i, i_fnum), ival);
+ printf(" t = (%d bytes) '%s'\n",
+ PQgetlength(res, i, t_fnum), tptr);
+ printf(" b = (%d bytes) ", blen);
+ for (j = 0; j < blen; j++)
+ printf("\\%03o", bptr[j]);
+ printf("\n\n");
+ }
+
+ PQclear(res);
+
+ /* close the connection to the database and cleanup */
+ PQfinish(conn);
+
+ return 0;
}
diff --git a/doc/src/sgml/lobj.sgml b/doc/src/sgml/lobj.sgml
index 019c715c25f..c41c7571a61 100644
--- a/doc/src/sgml/lobj.sgml
+++ b/doc/src/sgml/lobj.sgml
@@ -1,5 +1,5 @@
@@ -113,6 +113,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/lobj.sgml,v 1.29 2003/06/21 21:51:33 tgl Ex
Oid lo_creat(PGconn *conn, int mode);
+ lo_creat>>
creates a new large object.
mode is a bit mask
describing several different attributes of the new
@@ -143,7 +144,8 @@ inv_oid = lo_creat(INV_READ|INV_WRITE);
Oid lo_import(PGconn *conn, const char *filename);
- filename
+ lo_import>>
+ filename
specifies the operating system name of
the file to be imported as a large object.
The return value is the OID that was assigned to the new large object.
@@ -159,6 +161,7 @@ Oid lo_import(PGconn *conn, const char *filename);
int lo_export(PGconn *conn, Oid lobjId, const char *filename);
+ lo_export>>
The lobjId argument specifies the OID of the large
object to export and the filename argument specifies
the operating system name name of the file.
@@ -173,6 +176,7 @@ int lo_export(PGconn *conn, Oid lobjId, const char *filename);
int lo_open(PGconn *conn, Oid lobjId, int mode);
+ lo_open>>
The lobjId argument specifies the OID of the large
object to open. The mode bits control whether the
object is opened for reading (INV_READ>), writing (INV_WRITE), or
@@ -194,10 +198,13 @@ int lo_open(PGconn *conn, Oid lobjId, int mode);
int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
- writes len bytes from buf to large object fd>. The fd
- argument must have been returned by a previous lo_open.
- The number of bytes actually written is returned. In
- the event of an error, the return value is negative.
+ lo_write>> writes
+ len bytes from buf
+ to large object fd>. The fd
+ argument must have been returned by a previous
+ lo_open. The number of bytes actually
+ written is returned. In the event of an error, the return value
+ is negative.
@@ -209,10 +216,13 @@ int lo_write(PGconn *conn, int fd, const char *buf, size_t len);
int lo_read(PGconn *conn, int fd, char *buf, size_t len);
- reads len bytes from large object fd into buf. The fd
- argument must have been returned by a previous lo_open.
- The number of bytes actually read is returned. In
- the event of an error, the return value is negative.
+ lo_read>> reads
+ len bytes from large object
+ fd into buf. The
+ fd argument must have been returned by a
+ previous lo_open. The number of bytes
+ actually read is returned. In the event of an error, the return
+ value is negative.
@@ -225,10 +235,14 @@ int lo_read(PGconn *conn, int fd, char *buf, size_t len);
int lo_lseek(PGconn *conn, int fd, int offset, int whence);
- This function moves the current location pointer for the
- large object described by fd> to the new location specified
- by offset>. The valid values for whence> are
- SEEK_SET> (seek from object start), SEEK_CUR> (seek from current position), and SEEK_END> (seek from object end). The return value is the new location pointer.
+ lo_lseek>> This function moves the
+ current location pointer for the large object described by
+ fd> to the new location specified by
+ offset>. The valid values for whence>
+ are SEEK_SET> (seek from object start),
+ SEEK_CUR> (seek from current position), and
+ SEEK_END> (seek from object end). The return value is
+ the new location pointer.
@@ -241,7 +255,8 @@ int lo_lseek(PGconn *conn, int fd, int offset, int whence);
int lo_tell(PGconn *conn, int fd);
- If there is an error, the return value is negative.
+ lo_tell>> If there is an error, the
+ return value is negative.
@@ -253,9 +268,10 @@ int lo_tell(PGconn *conn, int fd);
int lo_close(PGconn *conn, int fd);
- where fd> is a large object descriptor returned by
- lo_open. On success, lo_close
- returns zero. On error, the return value is negative.
+ lo_close>> where fd> is a
+ large object descriptor returned by lo_open.
+ On success, lo_close returns zero. On
+ error, the return value is negative.
@@ -272,8 +288,10 @@ int lo_close(PGconn *conn, int fd);
int lo_unlink(PGconn *conn, Oid lobjId);
- The lobjId argument specifies the OID of the large
- object to remove. In the event of an error, the return value is negative.
+ lo_unlink>> The
+ lobjId argument specifies the OID of the
+ large object to remove. In the event of an error, the return
+ value is negative.
@@ -284,11 +302,13 @@ int lo_unlink(PGconn *conn, Oid lobjId);
Server-side Functions
- There are two built-in server-side functions, lo_import
- and lo_export, for large object access, which are available for use
- in SQL
- commands.
- Here is an example of their use:
+ There are two built-in server-side functions,
+ lo_importlo_import>>
+ and
+ lo_export,lo_export>>
+ for large object access, which are available for use in
+ SQL commands. Here is an example of their
+ use:
CREATE TABLE image (
name text,
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index 122137ad2b9..4404c5e929e 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -1,10 +1,14 @@
Routine Database Maintenance Tasks
+
+ maintenance
+
+
There are a few routine maintenance chores that must be performed on
a regular basis to keep a PostgreSQL
@@ -158,6 +162,15 @@ $Header: /cvsroot/pgsql/doc/src/sgml/maintenance.sgml,v 1.23 2003/06/18 12:19:11
Updating planner statistics
+
+ statistics
+ of the planner
+
+
+
+ ANALYZE
+
+
The PostgreSQL query planner relies on
statistical information about the contents of tables in order to
@@ -396,7 +409,8 @@ VACUUM
Log File Maintenance
- log files
+ server log
+ log file maintenance
diff --git a/doc/src/sgml/manage-ag.sgml b/doc/src/sgml/manage-ag.sgml
index dd0b390230c..c55f78f5cb7 100644
--- a/doc/src/sgml/manage-ag.sgml
+++ b/doc/src/sgml/manage-ag.sgml
@@ -1,5 +1,5 @@
@@ -19,6 +19,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/manage-ag.sgml,v 2.27 2003/03/25 16:15:37 p
Overview
+
+ schema
+
+
A database is a named collection of SQL objects
(database objects). Generally, every database
@@ -70,8 +74,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/manage-ag.sgml,v 2.27 2003/03/25 16:15:37 p
- Databases are created with the SQL command
- CREATE DATABASE:
+ Databases are created with the SQL command CREATE
+ DATABASE:CREATE DATABASE>>
CREATE DATABASE name>;
@@ -93,9 +97,10 @@ CREATE DATABASE name>;
question remains how the first> database at any given
site can be created. The first database is always created by the
initdb> command when the data storage area is
- initialized. (See .)
- This database is called template1>. So to create the
- first real> database you can connect to
+ initialized. (See .) This
+ database is called
+ template1>.template1>> So to
+ create the first real> database you can connect to
template1>.
@@ -112,7 +117,7 @@ CREATE DATABASE name>;
As an extra convenience, there is also a program that you can
execute from the shell to create new databases,
- createdb>.
+ createdb>.createdb>>
createdb dbname
@@ -157,31 +162,33 @@ createdb -O username> dbname>
CREATE DATABASE> actually works by copying an existing
database. By default, it copies the standard system database named
- template1>. Thus that database is the template>
- from which new databases are made. If you add objects to
- template1>, these objects
+ template1>.template1>> Thus that
+ database is the template> from which new databases are
+ made. If you add objects to template1>, these objects
will be copied into subsequently created user databases. This
behavior allows site-local modifications to the standard set of
objects in databases. For example, if you install the procedural
language PL/pgSQL> in template1>, it will
- automatically be available in user databases without any extra action
- being taken when those databases are made.
+ automatically be available in user databases without any extra
+ action being taken when those databases are made.
- There is a second standard system database named template0>.
- This database contains the same data as the initial contents of
- template1>, that is, only the standard objects predefined by
- your version of PostgreSQL.
- template0> should never be changed
- after initdb>. By instructing CREATE DATABASE> to
- copy template0> instead of template1>, you can
- create a virgin> user database that contains none of the
- site-local additions in template1>. This is particularly
- handy when restoring a pg_dump> dump: the dump script should
- be restored in a virgin database to ensure that one recreates the
- correct contents of the dumped database, without any conflicts with
- additions that may now be present in template1>.
+ There is a second standard system database named
+ template0>.template0>> This
+ database contains the same data as the initial contents of
+ template1>, that is, only the standard objects
+ predefined by your version of
+ PostgreSQL. template0>
+ should never be changed after initdb>. By instructing
+ CREATE DATABASE> to copy template0> instead
+ of template1>, you can create a virgin> user
+ database that contains none of the site-local additions in
+ template1>. This is particularly handy when restoring a
+ pg_dump> dump: the dump script should be restored in a
+ virgin database to ensure that one recreates the correct contents
+ of the dumped database, without any conflicts with additions that
+ may now be present in template1>.
@@ -214,7 +221,7 @@ createdb -T template0 dbname>
- Two useful flags exist in pg_database for each
+ Two useful flags exist in pg_databasepg_database>> for each
database: the columns datistemplate and
datallowconn. datistemplate
may be set to indicate that a database is intended as a template for
@@ -382,7 +389,8 @@ gmake CPPFLAGS=-DALLOW_ABSOLUTE_DBPATHS all
Destroying a Database
- Databases are destroyed with the command DROP DATABASE:
+ Databases are destroyed with the command DROP
+ DATABASE:DROP DATABASE>>
DROP DATABASE name>;
@@ -403,7 +411,8 @@ DROP DATABASE name>;
- For convenience, there is also a shell program to drop databases:
+ For convenience, there is also a shell program to drop
+ databases:dropdb>>
dropdb dbname
diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml
index 90a77d0a2c8..03ca970c768 100644
--- a/doc/src/sgml/monitoring.sgml
+++ b/doc/src/sgml/monitoring.sgml
@@ -1,10 +1,20 @@
Monitoring Database Activity
+
+ monitoring
+ database activity
+
+
+
+ database activity
+ monitoring
+
+
A database administrator frequently wonders, What is the system
doing right now?
@@ -589,6 +599,11 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS procpid,
Viewing Locks
+
+ lock
+ monitoring
+
+
Another useful tool for monitoring database activity is the
pg_locks system table. It allows the
diff --git a/doc/src/sgml/mvcc.sgml b/doc/src/sgml/mvcc.sgml
index b5cda133ef2..077b0c3219c 100644
--- a/doc/src/sgml/mvcc.sgml
+++ b/doc/src/sgml/mvcc.sgml
@@ -1,5 +1,5 @@
@@ -22,6 +22,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/mvcc.sgml,v 2.35 2003/03/25 16:15:37 petere
Introduction
+
+ MVCC
+
+
Unlike traditional database systems which use locks for concurrency control,
PostgreSQL
@@ -57,6 +61,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/mvcc.sgml,v 2.35 2003/03/25 16:15:37 petere
Transaction Isolation
+
+ transaction isolation
+
+
The SQL standard defines four levels of
transaction isolation in terms of three phenomena that must be
@@ -108,7 +116,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/mvcc.sgml,v 2.35 2003/03/25 16:15:37 petere
- isolation levels
+ transaction isolation level
The four transaction isolation levels and the corresponding
behaviors are described in .
@@ -206,7 +214,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/mvcc.sgml,v 2.35 2003/03/25 16:15:37 petere
Read Committed Isolation Level
- isolation levels
+ transaction isolation levelread committed
@@ -292,7 +300,7 @@ COMMIT;
Serializable Isolation Level
- isolation levels
+ transaction isolation levelserializable
@@ -376,7 +384,7 @@ ERROR: Can't serialize access due to concurrent update
Explicit Locking
- locking
+ lock
@@ -394,6 +402,10 @@ ERROR: Can't serialize access due to concurrent update
Table-Level Locks
+
+ LOCK
+
+
The list below shows the available lock modes and the contexts in
which they are used automatically by
@@ -644,6 +656,10 @@ ERROR: Can't serialize access due to concurrent update
Deadlocks
+
+ deadlock
+
+
The use of explicit locking can increase the likelyhood of
deadlocks>, wherein two (or more) transactions each
@@ -813,6 +829,11 @@ UPDATE accounts SET balance = balance - 100.00 WHERE acctnum = 22222;
Locking and Indexes
+
+ index
+ locks
+
+
Though PostgreSQL
provides nonblocking read/write access to table
diff --git a/doc/src/sgml/perform.sgml b/doc/src/sgml/perform.sgml
index 0de183a01e0..fa887a406e4 100644
--- a/doc/src/sgml/perform.sgml
+++ b/doc/src/sgml/perform.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,14 @@ $Header: /cvsroot/pgsql/doc/src/sgml/perform.sgml,v 1.30 2003/06/25 02:07:33 mom
Using EXPLAIN
+
+ EXPLAIN
+
+
+
+ query plan
+
+
PostgreSQL devises a query
plan for each query it is given. Choosing the right
@@ -336,6 +344,11 @@ EXPLAIN ANALYZE SELECT * FROM tenk1 t1, tenk2 t2 WHERE t1.unique1 < 50 AND t1
Statistics Used by the Planner
+
+ statistics
+ of the planner
+
+
As we saw in the previous section, the query planner needs to estimate
the number of rows retrieved by a query in order to make good choices
@@ -381,6 +394,10 @@ SELECT relname, relkind, reltuples, relpages FROM pg_class WHERE relname LIKE 't
since it does not read every row of the table.
+
+ pg_statistic
+
+
Most queries retrieve only a fraction of the rows in a table, due
to having WHERE> clauses that restrict the rows to be examined.
@@ -393,6 +410,10 @@ SELECT relname, relkind, reltuples, relpages FROM pg_class WHERE relname LIKE 't
and are always approximate even when freshly updated.
+
+ pg_stats
+
+
Rather than look at pg_statistic directly,
it's better to look at its view pg_stats
@@ -538,6 +559,11 @@ SELECT attname, n_distinct, most_common_vals FROM pg_stats WHERE tablename = 'ro
Controlling the Planner with Explicit JOIN> Clauses
+
+ join
+ controlling the order
+
+
It is possible
to control the query planner to some extent by using the explicit JOIN>
@@ -700,6 +726,10 @@ SELECT * FROM x, y, a, b, c WHERE something AND somethingelse;
Disable Autocommit
+
+ autocommit
+
+
Turn off autocommit and just do one commit at
the end. (In plain SQL, this means issuing BEGIN
diff --git a/doc/src/sgml/plperl.sgml b/doc/src/sgml/plperl.sgml
index 02d38bc5340..55eb99a439a 100644
--- a/doc/src/sgml/plperl.sgml
+++ b/doc/src/sgml/plperl.sgml
@@ -1,5 +1,5 @@
@@ -73,11 +73,12 @@ CREATE FUNCTION perl_max (integer, integer) RETURNS integer AS '
- If an SQL null value is passed to a function, the argument value
- will appear as undefined> in Perl. The above function
- definition will not behave very nicely with null inputs (in fact,
- it will act as though they are zeroes). We could add
- STRICT> to the function definition to make
+ If an SQL null valuenull value>in PL/Perl> is passed to a function,
+ the argument value will appear as undefined> in Perl. The
+ above function definition will not behave very nicely with null
+ inputs (in fact, it will act as though they are zeroes). We could
+ add STRICT> to the function definition to make
PostgreSQL do something more reasonable:
if a null value is passed, the function will not be called at all,
but will just return a null result automatically. Alternatively,
@@ -170,7 +171,7 @@ SELECT name, empcomp(employee) FROM employee;
mirror sites). This module makes available a
DBI>-compliant database-handle named
$pg_dbh that can be used to perform queries
- with normal DBI> syntax.
+ with normal DBI> syntax.DBI>
@@ -180,7 +181,7 @@ SELECT name, empcomp(employee) FROM employee;
elog
- PL/Perl
+ in PL/Perlelog> level, msg
@@ -202,6 +203,11 @@ SELECT name, empcomp(employee) FROM employee;
Trusted and Untrusted PL/Perl
+
+ trusted
+ PL/Perl
+
+
Normally, PL/Perl is installed as a trusted> programming
language named plperl>. In this setup, certain Perl
@@ -231,13 +237,14 @@ CREATE FUNCTION badfunc() RETURNS integer AS '
Sometimes it is desirable to write Perl functions that are not
- restricted. For example, one might want a Perl function that
- sends mail. To handle these cases, PL/Perl can also be installed
- as an untrusted> language (usually called
- PL/PerlU). In this case the full Perl language is
- available. If the createlang program is used to
- install the language, the language name plperlu
- will select the untrusted PL/Perl variant.
+ restricted. For example, one might want a Perl function that sends
+ mail. To handle these cases, PL/Perl can also be installed as an
+ untrusted> language (usually called
+ PL/PerlUPL/PerlU>).
+ In this case the full Perl language is available. If the
+ createlang program is used to install the
+ language, the language name plperlu will select
+ the untrusted PL/Perl variant.
@@ -272,7 +279,9 @@ CREATE FUNCTION badfunc() RETURNS integer AS '
- PL/Perl cannot be used to write trigger functions.
+ PL/Perl cannot be used to write trigger
+ functions.trigger>in
+ PL/Perl>
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml
index b313860ea0c..c616cec5cdc 100644
--- a/doc/src/sgml/plpgsql.sgml
+++ b/doc/src/sgml/plpgsql.sgml
@@ -1,5 +1,5 @@
@@ -63,20 +63,22 @@ $Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.20 2003/08/09 22:50:22 tgl
- As each expression and SQL command is first used
- in the function, the PL/pgSQL> interpreter creates
- a prepared execution plan (using the SPI
- manager's SPI_prepare and
- SPI_saveplan functions). Subsequent visits
- to that expression or command reuse the prepared plan. Thus, a
- function with conditional code that contains many statements for
- which execution plans might be required will only prepare and save
- those plans that are really used during the lifetime of the
- database connection. This can substantially reduce the total
- amount of time required to parse, and generate execution plans for the
- statements in a PL/pgSQL> function. A disadvantage is
- that errors in a specific expression or command may not be detected
- until that part of the function is reached in execution.
+ As each expression and SQL command is first
+ used in the function, the PL/pgSQL> interpreter
+ creates a prepared execution plan (using the
+ SPI manager's SPI_prepare
+ and SPI_saveplan
+ functions).preparing a query>in
+ PL/pgSQL>> Subsequent visits to that expression or command
+ reuse the prepared plan. Thus, a function with conditional code
+ that contains many statements for which execution plans might be
+ required will only prepare and save those plans that are really
+ used during the lifetime of the database connection. This can
+ substantially reduce the total amount of time required to parse,
+ and generate execution plans for the statements in a
+ PL/pgSQL> function. A disadvantage is that errors
+ in a specific expression or command may not be detected until that
+ part of the function is reached in execution.
@@ -196,7 +198,7 @@ END;
and return the polymorphic> types
anyelement and anyarray. The actual
datatypes handled by a polymorphic function can vary from call to
- call, as discussed in .
+ call, as discussed in .
An example is shown in .
@@ -563,7 +565,7 @@ END;
or anyarray), a special parameter $0
is created. Its datatype is the actual return type of the function,
as deduced from the actual input types (see ).
+ linkend="extend-types-polymorphic">).
This allows the function to access its actual return type
as shown in .
$0 is initialized to NULL and can be modified by
@@ -903,6 +905,11 @@ tax := subtotal * 0.06;
SELECT INTO
+
+ SELECT INTO
+ in PL/pgSQL
+
+
The result of a SELECT command yielding multiple columns (but
only one row) can be assigned to a record variable, row-type
@@ -1097,14 +1104,16 @@ EXECUTE ''UPDATE tbl SET ''
This example shows use of the functions
quote_ident(text) and
- quote_literal(text).
- Variables containing column and table identifiers should be
- passed to function quote_ident.
- Variables containing values that should be literal strings in the
- constructed command should be passed to
- quote_literal. Both take the
- appropriate steps to return the input text enclosed in double
- or single quotes respectively, with any embedded special characters
+ quote_literal(text).quote_ident>use
+ in
+ PL/pgSQL>quote_literal>use
+ in PL/pgSQL> Variables containing column and table
+ identifiers should be passed to function
+ quote_ident. Variables containing values
+ that should be literal strings in the constructed command should
+ be passed to quote_literal. Both take the
+ appropriate steps to return the input text enclosed in double or
+ single quotes respectively, with any embedded special characters
properly escaped.
@@ -1517,6 +1526,11 @@ END IF;
Simple Loops
+
+ loop
+ in PL/pgSQL
+
+
With the LOOP>, EXIT>, WHILE>,
and FOR> statements, you can arrange for your
@@ -1655,6 +1669,11 @@ FOR i IN REVERSE 10..1 LOOP
END LOOP;
+
+
+ If the lower bound is greater than the upper bound, the loop body is not
+ executed at all, but no error is raised.
+
@@ -1734,6 +1753,11 @@ END LOOP;
Cursors
+
+ cursor
+ in PL/pgSQL
+
+
Rather than executing a whole query at once, it is possible to set
up a cursor> that encapsulates the query, and then read
@@ -2096,6 +2120,11 @@ RAISE EXCEPTION ''Inexistent ID --> %'', user_id;
Trigger Procedures
+
+ trigger
+ in PL/pgSQL
+
+
PL/pgSQL can be used to define trigger
procedures. A trigger procedure is created with the
@@ -2302,10 +2331,12 @@ CREATE TRIGGER emp_stamp BEFORE INSERT OR UPDATE ON emp
Oracle
+ porting from PL/SQL to PL/pgSQL
- PL/SQL
+ PL/SQL (Oracle)
+ porting to PL/pgSQL
@@ -2546,7 +2577,8 @@ END;
with OUT> parameters and string manipulation.
PostgreSQL> does not have an
instr function, but you can work around it
- using a combination of other functions. In instr> In there is a
PL/pgSQL implementation of
instr that you can use to make your porting
diff --git a/doc/src/sgml/plpython.sgml b/doc/src/sgml/plpython.sgml
index 0a101384ee7..8d476a7a43a 100644
--- a/doc/src/sgml/plpython.sgml
+++ b/doc/src/sgml/plpython.sgml
@@ -1,4 +1,4 @@
-
+
PL/Python - Python Procedural Language
@@ -68,9 +68,10 @@ def __plpython_procedure_myfunc_23456():
If you do not provide a return value, Python returns the default
- None. The
- language module translates Python's None into the
- SQL null value.
+ None. The language module translates Python's
+ None into the SQL null
+ value.null value>in PL/Python>
@@ -87,7 +88,9 @@ def __plpython_procedure_myfunc_23456():
The global dictionary SD is available to store
data between function calls. This variable is private static data.
The global dictionary GD is public data,
- available to all Python functions within a session. Use with care.
+ available to all Python functions within a session. Use with
+ care.global data>in
+ PL/Python>
@@ -102,6 +105,11 @@ def __plpython_procedure_myfunc_23456():
Trigger Functions
+
+ trigger
+ in PL/Python
+
+
When a function is used in a trigger, the dictionary
TD contains trigger-related values. The trigger
@@ -146,7 +154,8 @@ def __plpython_procedure_myfunc_23456():
plpy.error("msg"), and
plpy.fatal("msg"). They are mostly equivalent
to calling elog(LEVEL>, "msg")
- from C code. plpy.error and
+ from C code.elog>in
+ PL/Python>plpy.error and
plpy.fatal actually raise a Python exception
which, if uncaught, causes the PL/Python module to call
elog(ERROR, msg) when the function handler
@@ -187,10 +196,11 @@ foo = rv[i]["my_column"]
- The second function, plpy.prepare, prepares the
- execution plan for a query. It is called with a query string and a
- list of parameter types, if you have parameter references in the
- query. For example:
+ preparing a query>in PL/Python>
+ The second function, plpy.prepare, prepares
+ the execution plan for a query. It is called with a query string
+ and a list of parameter types, if you have parameter references in
+ the query. For example:
plan = plpy.prepare("SELECT last_name FROM my_users WHERE first_name = $1", [ "text" ])
@@ -235,7 +245,8 @@ CREATE FUNCTION usesavedplan() RETURNS trigger AS '
-
Restricted Environment
@@ -259,6 +270,6 @@ CREATE FUNCTION usesavedplan() RETURNS trigger AS '
--->
+]]>
diff --git a/doc/src/sgml/pltcl.sgml b/doc/src/sgml/pltcl.sgml
index d93f7f6517f..ebcf8bdfb8f 100644
--- a/doc/src/sgml/pltcl.sgml
+++ b/doc/src/sgml/pltcl.sgml
@@ -1,5 +1,5 @@
@@ -190,6 +190,11 @@ CREATE FUNCTION overpaid(employee) RETURNS boolean AS '
Global Data in PL/Tcl
+
+ global data
+ in PL/Tcl
+
+
Sometimes it
is useful to have some global data that is held between two
@@ -298,8 +303,10 @@ spi_exec -array C "SELECT * FROM pg_class" {
spi_preparequerytypelist
- Prepares and saves a query plan for later execution. The saved plan
- will be retained for the life of the current session.
+ Prepares and saves a query plan for later execution. The
+ saved plan will be retained for the life of the current
+ session.preparing a query>in
+ PL/Tcl>>
The query may use parameters, that is, placeholders for
@@ -437,7 +444,7 @@ SELECT 'doesn''t' AS ret
elog
- PL/Tcl
+ in PL/Tclelog> levelmsg
@@ -466,7 +473,7 @@ SELECT 'doesn''t' AS ret
Trigger Procedures in PL/Tcl
- triggers
+ triggerin PL/Tcl
diff --git a/doc/src/sgml/postgres.sgml b/doc/src/sgml/postgres.sgml
index cca78b63977..2642b356214 100644
--- a/doc/src/sgml/postgres.sgml
+++ b/doc/src/sgml/postgres.sgml
@@ -1,5 +1,5 @@
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 1de14ddeb61..d949a57df56 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1,4 +1,4 @@
-
+
Frontend/Backend Protocol
@@ -1005,9 +1005,9 @@
ParameterStatus will be generated: they are
server_version> (a pseudo-parameter that cannot change after
startup);
- server_encoding> (also not presently changeable after start);
client_encoding>,
- is_superuser>, and
+ is_superuser>,
+ session_authorization, and
DateStyle>.
This set might change in the future, or even become configurable.
Accordingly, a frontend should simply ignore ParameterStatus for
diff --git a/doc/src/sgml/queries.sgml b/doc/src/sgml/queries.sgml
index d3ec786ac27..6ca1e023081 100644
--- a/doc/src/sgml/queries.sgml
+++ b/doc/src/sgml/queries.sgml
@@ -1,8 +1,16 @@
-
+
Queries
+
+ query
+
+
+
+ SELECT
+
+
The previous chapters explained how to create tables, how to fill
them with data, and how to manipulate that data. Now we finally
@@ -73,6 +81,10 @@ SELECT random();
Table Expressions
+
+ table expression
+
+
A table expression computes a table. The
table expression contains a FROM> clause that is
@@ -112,6 +124,10 @@ FROM table_reference, table_r
overall table expression.
+
+ ONLY
+
+
When a table reference names a table that is the supertable of a
table inheritance hierarchy, the table reference produces rows of
@@ -125,7 +141,7 @@ FROM table_reference, table_r
Joined Tables
- joins
+ join
@@ -141,10 +157,14 @@ FROM table_reference, table_r
Cross join
- joins
+ joincross
+
+ cross join
+
+
T1 CROSS JOIN T2
@@ -175,10 +195,14 @@ FROM table_reference, table_r
Qualified joins
- joins
+ joinouter
+
+ outer join
+
+
T1 { INNER | { LEFT | RIGHT | FULL } OUTER } JOIN T2 ON boolean_expression
@@ -227,9 +251,12 @@ FROM table_reference, table_r
- joins
+ joinnatural
+
+ natural join
+
Finally, NATURAL> is a shorthand form of
USING>: it forms a USING> list
consisting of exactly those column names that appear in both
@@ -256,10 +283,14 @@ FROM table_reference, table_r
LEFT OUTER JOIN>
- joins
+ joinleft
+
+ left join
+
+
First, an inner join is performed. Then, for each row in
@@ -274,6 +305,15 @@ FROM table_reference, table_r
RIGHT OUTER JOIN>
+
+ join
+ right
+
+
+
+ right join
+
+
First, an inner join is performed. Then, for each row in
@@ -424,13 +464,13 @@ FROM table_reference, table_r
Table and Column Aliases
- label
- table
+ alias
+ in the FROM clause
- alias
- label
+ label
+ alias
@@ -530,7 +570,7 @@ SELECT a.* FROM (my_table AS a JOIN your_table AS b ON ...) AS c
Subqueries
- subqueries
+ subquery
@@ -556,6 +596,11 @@ FROM (SELECT * FROM table1) AS alias_name
table function>>
+
+ function>
+ in the FROM clause>
+
+
Table functions are functions that produce a set of rows, made up
of either base data types (scalar types) or composite data types
@@ -628,7 +673,7 @@ SELECT *
The WHERE Clause
- where
+ WHERE
@@ -716,7 +761,11 @@ SELECT ... FROM fdt WHERE EXISTS (SELECT c1 FROM t2 WHERE c2 > fdt.c1)
The GROUP BY and HAVING Clauses
- group
+ GROUP BY
+
+
+
+ grouping
@@ -827,6 +876,10 @@ SELECT product_id, p.name, (sum(s.units) * p.price) AS sales
column names is also allowed.
+
+ HAVING
+
+
If a table has been grouped using a GROUP BY
clause, but then only certain groups are of interest, the
@@ -884,7 +937,7 @@ SELECT product_id, p.name, (sum(s.units) * (p.price - p.cost)) AS profit
Select Lists
- select
+ SELECTselect list
@@ -901,6 +954,10 @@ SELECT product_id, p.name, (sum(s.units) * (p.price - p.cost)) AS profit
Select-List Items
+
+ *
+
+
The simplest kind of select list is * which
emits all columns that the table expression produces. Otherwise,
@@ -944,8 +1001,8 @@ SELECT tbl1.a, tbl2.a, tbl1.b FROM ...
Column Labels
- label
- column
+ alias
+ in the select list
@@ -981,7 +1038,11 @@ SELECT a AS value, b + c AS sum FROM ...
DISTINCT
- distinct
+ DISTINCT
+
+
+
+ duplicates
@@ -997,6 +1058,8 @@ SELECT DISTINCT select_list ...
+ null value>in
+ DISTINCT>
Obviously, two rows are considered distinct if they differ in at
least one column value. Null values are considered equal in this
comparison.
@@ -1035,13 +1098,25 @@ SELECT DISTINCT ON (expression, Combining Queries
- union
+ UNION
+
+
+ INTERSECT
+
+
+ EXCEPT
+
+
+ set union
+
+
+ set intersection
- intersection
+ set difference
- except
+ set operation
@@ -1104,7 +1179,10 @@ SELECT DISTINCT ON (expression, sorting
- query results
+
+
+
+ ORDER BY
@@ -1173,12 +1251,11 @@ SELECT a AS b FROM table1 ORDER BY a;
LIMIT and OFFSET
- limit
+ LIMIT
- offset
- with query results
+ OFFSET
diff --git a/doc/src/sgml/query.sgml b/doc/src/sgml/query.sgml
index 5a7a7f4e62e..de464785a4f 100644
--- a/doc/src/sgml/query.sgml
+++ b/doc/src/sgml/query.sgml
@@ -1,5 +1,5 @@
@@ -87,7 +87,8 @@ $Header: /cvsroot/pgsql/doc/src/sgml/query.sgml,v 1.32 2003/06/24 23:27:24 momji
- cluster
+ database cluster
+ clusterof databasesdatabase cluster
Tables are grouped into databases, and a collection of databases
managed by a single PostgreSQL server
@@ -562,7 +563,7 @@ SELECT *
Aggregate Functions
- aggregate
+ aggregate function
diff --git a/doc/src/sgml/ref/abort.sgml b/doc/src/sgml/ref/abort.sgml
index 5d1d4472d01..87b27265f16 100644
--- a/doc/src/sgml/ref/abort.sgml
+++ b/doc/src/sgml/ref/abort.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
abort the current transaction
+
+ ABORT
+
+
ABORT [ WORK | TRANSACTION ]
diff --git a/doc/src/sgml/ref/alter_aggregate.sgml b/doc/src/sgml/ref/alter_aggregate.sgml
index 972accd7565..f1c85849b3f 100644
--- a/doc/src/sgml/ref/alter_aggregate.sgml
+++ b/doc/src/sgml/ref/alter_aggregate.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change the definition of an aggregate function
+
+ ALTER AGGREGATE
+
+
ALTER AGGREGATE name ( type ) RENAME TO newname
diff --git a/doc/src/sgml/ref/alter_conversion.sgml b/doc/src/sgml/ref/alter_conversion.sgml
index b2767405ca8..469b7e5ec5f 100644
--- a/doc/src/sgml/ref/alter_conversion.sgml
+++ b/doc/src/sgml/ref/alter_conversion.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change the definition of a conversion
+
+ ALTER CONVERSION
+
+
ALTER CONVERSION name RENAME TO newname
diff --git a/doc/src/sgml/ref/alter_database.sgml b/doc/src/sgml/ref/alter_database.sgml
index 12447d6b0a7..bb895328c93 100644
--- a/doc/src/sgml/ref/alter_database.sgml
+++ b/doc/src/sgml/ref/alter_database.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change a database
+
+ ALTER DATABASE
+
+
ALTER DATABASE name SET variable { TO | = } { value | DEFAULT }
diff --git a/doc/src/sgml/ref/alter_domain.sgml b/doc/src/sgml/ref/alter_domain.sgml
index fdbf08e6d48..3980a6f4298 100644
--- a/doc/src/sgml/ref/alter_domain.sgml
+++ b/doc/src/sgml/ref/alter_domain.sgml
@@ -1,5 +1,5 @@
@@ -8,6 +8,7 @@ PostgreSQL documentation
ALTER DOMAINSQL - Language Statements
+
ALTER DOMAIN
@@ -16,6 +17,11 @@ PostgreSQL documentation
change the definition of a domain
+
+
+ ALTER DOMAIN
+
+
2002-11-27
diff --git a/doc/src/sgml/ref/alter_function.sgml b/doc/src/sgml/ref/alter_function.sgml
index 621350980b8..c54974788d8 100644
--- a/doc/src/sgml/ref/alter_function.sgml
+++ b/doc/src/sgml/ref/alter_function.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change the definition of a function
+
+ ALTER FUNCTION
+
+
ALTER FUNCTION name ( [ type [, ...] ] ) RENAME TO newname
diff --git a/doc/src/sgml/ref/alter_group.sgml b/doc/src/sgml/ref/alter_group.sgml
index 6d0695b9384..588eeec2232 100644
--- a/doc/src/sgml/ref/alter_group.sgml
+++ b/doc/src/sgml/ref/alter_group.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change a user group
+
+ ALTER GROUP
+
+
ALTER GROUP groupname ADD USER username [, ... ]
diff --git a/doc/src/sgml/ref/alter_language.sgml b/doc/src/sgml/ref/alter_language.sgml
index 2c922d58830..51545e308f4 100644
--- a/doc/src/sgml/ref/alter_language.sgml
+++ b/doc/src/sgml/ref/alter_language.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change the definition of a procedural language
+
+ ALTER LANGUAGE
+
+
ALTER LANGUAGE name RENAME TO newname
diff --git a/doc/src/sgml/ref/alter_opclass.sgml b/doc/src/sgml/ref/alter_opclass.sgml
index 5a9694c73a8..186b42bcc93 100644
--- a/doc/src/sgml/ref/alter_opclass.sgml
+++ b/doc/src/sgml/ref/alter_opclass.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change the definition of an operator class
+
+ ALTER OPERATOR CLASS
+
+
ALTER OPERATOR CLASS name USING index_method RENAME TO newname
diff --git a/doc/src/sgml/ref/alter_schema.sgml b/doc/src/sgml/ref/alter_schema.sgml
index 6e3c78c9c7c..6247993e13c 100644
--- a/doc/src/sgml/ref/alter_schema.sgml
+++ b/doc/src/sgml/ref/alter_schema.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change the definition of a schema
+
+ ALTER SCHEMA
+
+
ALTER SCHEMA name RENAME TO newname
diff --git a/doc/src/sgml/ref/alter_sequence.sgml b/doc/src/sgml/ref/alter_sequence.sgml
index 28a81022aab..b7ad7ea245a 100644
--- a/doc/src/sgml/ref/alter_sequence.sgml
+++ b/doc/src/sgml/ref/alter_sequence.sgml
@@ -1,5 +1,5 @@
@@ -8,6 +8,7 @@ PostgreSQL documentation
ALTER SEQUENCESQL - Language Statements
+
ALTER SEQUENCE
@@ -16,6 +17,11 @@ PostgreSQL documentation
alter the definition of a sequence generator
+
+
+ ALTER SEQUENCE
+
+
1999-07-20
diff --git a/doc/src/sgml/ref/alter_table.sgml b/doc/src/sgml/ref/alter_table.sgml
index 7f5456c2772..7a208787734 100644
--- a/doc/src/sgml/ref/alter_table.sgml
+++ b/doc/src/sgml/ref/alter_table.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change the definition of a table
+
+ ALTER TABLE
+
+
ALTER TABLE [ ONLY ] table [ * ]
diff --git a/doc/src/sgml/ref/alter_trigger.sgml b/doc/src/sgml/ref/alter_trigger.sgml
index b335434eaf8..90ebe0ce063 100644
--- a/doc/src/sgml/ref/alter_trigger.sgml
+++ b/doc/src/sgml/ref/alter_trigger.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change the definition of a trigger
+
+ ALTER TRIGGER
+
+
ALTER TRIGGER trigger ON table
diff --git a/doc/src/sgml/ref/alter_user.sgml b/doc/src/sgml/ref/alter_user.sgml
index 95de7a592d5..a46a6aa029e 100644
--- a/doc/src/sgml/ref/alter_user.sgml
+++ b/doc/src/sgml/ref/alter_user.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change a database user account
+
+ ALTER USER
+
+
ALTER USER username [ [ WITH ] option [ ... ] ]
diff --git a/doc/src/sgml/ref/analyze.sgml b/doc/src/sgml/ref/analyze.sgml
index 4977964f4e7..12fd1e63be2 100644
--- a/doc/src/sgml/ref/analyze.sgml
+++ b/doc/src/sgml/ref/analyze.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
collect statistics about a database
+
+ ANALYZE
+
+
ANALYZE [ VERBOSE ] [ table [ (column [, ...] ) ] ]
diff --git a/doc/src/sgml/ref/begin.sgml b/doc/src/sgml/ref/begin.sgml
index 7bd1309d289..30c78be8bcd 100644
--- a/doc/src/sgml/ref/begin.sgml
+++ b/doc/src/sgml/ref/begin.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
start a transaction block
+
+ BEGIN
+
+
BEGIN [ WORK | TRANSACTION ]
diff --git a/doc/src/sgml/ref/checkpoint.sgml b/doc/src/sgml/ref/checkpoint.sgml
index 71d075d542e..2ceacfad1a0 100644
--- a/doc/src/sgml/ref/checkpoint.sgml
+++ b/doc/src/sgml/ref/checkpoint.sgml
@@ -1,4 +1,4 @@
-
+
@@ -11,6 +11,10 @@
force a transaction log checkpoint
+
+ CHECKPOINT
+
+
CHECKPOINT
diff --git a/doc/src/sgml/ref/close.sgml b/doc/src/sgml/ref/close.sgml
index 9ae487c3f78..5b8df9cfe07 100644
--- a/doc/src/sgml/ref/close.sgml
+++ b/doc/src/sgml/ref/close.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
close a cursor
+
+ CLOSE
+
+
CLOSE cursor
@@ -31,9 +35,13 @@ CLOSE cursor
- Every open cursor is implicitly closed when a transaction is
- terminated by COMMIT or
- ROLLBACK.
+ Every non-holdable open cursor is implicitly closed when a
+ transaction is terminated by COMMIT or
+ ROLLBACK. Holdable cursors are implicitely
+ closed if the transaction that created them aborts via
+ ROLLBACK; if this does not happen, the holdable
+ cursor remains open until an explicit CLOSE is
+ executed, or the client disconnects.
@@ -66,10 +74,10 @@ CLOSE cursor
- WARNING: PerformPortalClose: portal "cursor" not found
+ ERROR: cursor "cursor" does not exist
- This warning is given if cursor is not declared or has
already been closed.
diff --git a/doc/src/sgml/ref/cluster.sgml b/doc/src/sgml/ref/cluster.sgml
index 90c56551a33..c57f361cfdb 100644
--- a/doc/src/sgml/ref/cluster.sgml
+++ b/doc/src/sgml/ref/cluster.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
cluster a table according to an index
+
+ CLUSTER
+
+
CLUSTER indexname ON tablename
diff --git a/doc/src/sgml/ref/clusterdb.sgml b/doc/src/sgml/ref/clusterdb.sgml
index eb814261876..69aed65428c 100644
--- a/doc/src/sgml/ref/clusterdb.sgml
+++ b/doc/src/sgml/ref/clusterdb.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
cluster a PostgreSQL database
+
+ clusterdb
+
+
clusterdb
@@ -129,10 +133,9 @@ PostgreSQL documentation
--host host>
- Specifies the host name of the machine on which the
- server
- is running. If the value begins with a slash, it is used
- as the directory for the Unix domain socket.
+ Specifies the host name of the machine on which the server is
+ running. If the value begins with a slash, it is used as the
+ directory for the Unix domain socket.
@@ -182,7 +185,7 @@ PostgreSQL documentation
CLUSTER
- Everything went well.
+ The database was successfully clustered.
diff --git a/doc/src/sgml/ref/comment.sgml b/doc/src/sgml/ref/comment.sgml
index 2eaf4ada45d..7e37ed29957 100644
--- a/doc/src/sgml/ref/comment.sgml
+++ b/doc/src/sgml/ref/comment.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define or change the comment of an object
+
+ COMMENT
+
+
COMMENT ON
diff --git a/doc/src/sgml/ref/commit.sgml b/doc/src/sgml/ref/commit.sgml
index a84c61a9011..724f6102e0e 100644
--- a/doc/src/sgml/ref/commit.sgml
+++ b/doc/src/sgml/ref/commit.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
commit the current transaction
+
+ COMMIT
+
+
COMMIT [ WORK | TRANSACTION ]
diff --git a/doc/src/sgml/ref/copy.sgml b/doc/src/sgml/ref/copy.sgml
index 0e24f8b3eec..ddd819eecb5 100644
--- a/doc/src/sgml/ref/copy.sgml
+++ b/doc/src/sgml/ref/copy.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
copy data between files and tables
+
+ COPY
+
+
COPY table [ ( column [, ...] ) ]
@@ -380,7 +384,7 @@ COPY table [ (
+ CREATE AGGREGATE
+
+
CREATE AGGREGATE name (
diff --git a/doc/src/sgml/ref/create_cast.sgml b/doc/src/sgml/ref/create_cast.sgml
index b97135c9538..02002e3bdde 100644
--- a/doc/src/sgml/ref/create_cast.sgml
+++ b/doc/src/sgml/ref/create_cast.sgml
@@ -1,4 +1,4 @@
-
+
@@ -11,6 +11,10 @@
define a user-defined cast
+
+ CREATE CAST
+
+
CREATE CAST (sourcetype AS targettype)
diff --git a/doc/src/sgml/ref/create_constraint.sgml b/doc/src/sgml/ref/create_constraint.sgml
index b61cd5d911f..eaa93ba78ee 100644
--- a/doc/src/sgml/ref/create_constraint.sgml
+++ b/doc/src/sgml/ref/create_constraint.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new constraint trigger
+
+ CREATE CONSTRAINT
+
+
CREATE CONSTRAINT TRIGGER name
diff --git a/doc/src/sgml/ref/create_conversion.sgml b/doc/src/sgml/ref/create_conversion.sgml
index 382c5089832..1ced8820b87 100644
--- a/doc/src/sgml/ref/create_conversion.sgml
+++ b/doc/src/sgml/ref/create_conversion.sgml
@@ -1,4 +1,4 @@
-
+
@@ -11,6 +11,10 @@
define a user-defined conversion
+
+ CREATE CONVERSION
+
+
CREATE [DEFAULT] CONVERSION name
diff --git a/doc/src/sgml/ref/create_database.sgml b/doc/src/sgml/ref/create_database.sgml
index ad0008de403..398b70386ee 100644
--- a/doc/src/sgml/ref/create_database.sgml
+++ b/doc/src/sgml/ref/create_database.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
create a new database
+
+ CREATE DATABASE
+
+
CREATE DATABASE name
diff --git a/doc/src/sgml/ref/create_domain.sgml b/doc/src/sgml/ref/create_domain.sgml
index 0d6fe6ef50a..3ff05d603a5 100644
--- a/doc/src/sgml/ref/create_domain.sgml
+++ b/doc/src/sgml/ref/create_domain.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new domain
+
+ CREATE DOMAIN
+
+
CREATE DOMAIN domainname [AS] data_type
diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml
index 4e1978c6eec..a6467d774d6 100644
--- a/doc/src/sgml/ref/create_function.sgml
+++ b/doc/src/sgml/ref/create_function.sgml
@@ -1,5 +1,5 @@
@@ -13,6 +13,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/ref/create_function.sgml,v 1.48 2003/06/27
define a new function
+
+ CREATE FUNCTION
+
+
CREATE [ OR REPLACE ] FUNCTION name ( [ argtype [, ...] ] )
diff --git a/doc/src/sgml/ref/create_group.sgml b/doc/src/sgml/ref/create_group.sgml
index d90dd31086a..7758de6d47e 100644
--- a/doc/src/sgml/ref/create_group.sgml
+++ b/doc/src/sgml/ref/create_group.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new user group
+
+ CREATE GROUP
+
+
CREATE GROUP name [ [ WITH ] option [ ... ] ]
diff --git a/doc/src/sgml/ref/create_index.sgml b/doc/src/sgml/ref/create_index.sgml
index ff60aaa3b01..05293b25d5f 100644
--- a/doc/src/sgml/ref/create_index.sgml
+++ b/doc/src/sgml/ref/create_index.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new index
+
+ CREATE INDEX
+
+
CREATE [ UNIQUE ] INDEX index_name ON table [ USING method ]
diff --git a/doc/src/sgml/ref/create_language.sgml b/doc/src/sgml/ref/create_language.sgml
index d26eb48911d..a6884abee1d 100644
--- a/doc/src/sgml/ref/create_language.sgml
+++ b/doc/src/sgml/ref/create_language.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new procedural language
+
+ CREATE LANGUAGE
+
+
CREATE [ TRUSTED ] [ PROCEDURAL ] LANGUAGE langname
diff --git a/doc/src/sgml/ref/create_opclass.sgml b/doc/src/sgml/ref/create_opclass.sgml
index eddb8e71287..6696a9eb343 100644
--- a/doc/src/sgml/ref/create_opclass.sgml
+++ b/doc/src/sgml/ref/create_opclass.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new operator class for indexes
+
+ CREATE OPERATOR CLASS
+
+
CREATE OPERATOR CLASS name [ DEFAULT ] FOR TYPE data_type USING index_method AS
diff --git a/doc/src/sgml/ref/create_operator.sgml b/doc/src/sgml/ref/create_operator.sgml
index 2ac9d3f2edd..d64bc28f2d9 100644
--- a/doc/src/sgml/ref/create_operator.sgml
+++ b/doc/src/sgml/ref/create_operator.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new operator
+
+ CREATE OPERATOR
+
+
CREATE OPERATOR name (
@@ -43,17 +47,11 @@ CREATE OPERATOR name (
The operator name is a sequence of up to NAMEDATALEN>-1
(63 by default) characters from the following list:
-+ - * / < > = ~ ! @ # % ^ & | ` ? $
++ - * / < > = ~ ! @ # % ^ & | ` ?
There are a few restrictions on your choice of name:
-
-
- $ cannot be defined as a single-character operator,
- although it can be part of a multicharacter operator name.
-
- -- and /* cannot appear anywhere in an operator name,
@@ -66,7 +64,7 @@ CREATE OPERATOR name (
-,
unless the name also contains at least one of these characters:
-~ ! @ # % ^ & | ` ? $
+~ ! @ # % ^ & | ` ?
For example, @- is an allowed operator name,
but *- is not.
diff --git a/doc/src/sgml/ref/create_rule.sgml b/doc/src/sgml/ref/create_rule.sgml
index ff7f2bfb134..566f8bddfb8 100644
--- a/doc/src/sgml/ref/create_rule.sgml
+++ b/doc/src/sgml/ref/create_rule.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new rewrite rule
+
+ CREATE RULE
+
+
CREATE [ OR REPLACE ] RULE name AS ON event
diff --git a/doc/src/sgml/ref/create_schema.sgml b/doc/src/sgml/ref/create_schema.sgml
index e70d29a37b8..4a40160caf3 100644
--- a/doc/src/sgml/ref/create_schema.sgml
+++ b/doc/src/sgml/ref/create_schema.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new schema
+
+ CREATE SCHEMA
+
+
CREATE SCHEMA schemaname [ AUTHORIZATION username ] [ schema_element [ ... ] ]
diff --git a/doc/src/sgml/ref/create_sequence.sgml b/doc/src/sgml/ref/create_sequence.sgml
index 374f34cb0a8..93b6fc7d50c 100644
--- a/doc/src/sgml/ref/create_sequence.sgml
+++ b/doc/src/sgml/ref/create_sequence.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new sequence generator
+
+ CREATE SEQUENCE
+
+
CREATE [ TEMPORARY | TEMP ] SEQUENCE seqname [ INCREMENT [ BY ] increment ]
diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml
index 2d55997e708..ea35353d314 100644
--- a/doc/src/sgml/ref/create_table.sgml
+++ b/doc/src/sgml/ref/create_table.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new table
+
+ CREATE TABLE
+
+
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name (
diff --git a/doc/src/sgml/ref/create_table_as.sgml b/doc/src/sgml/ref/create_table_as.sgml
index 0f648d56b3a..4e9a54a9e42 100644
--- a/doc/src/sgml/ref/create_table_as.sgml
+++ b/doc/src/sgml/ref/create_table_as.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
create a new table from the results of a query
+
+ CREATE TABLE AS
+
+
CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } ] TABLE table_name [ (column_name [, ...] ) ]
diff --git a/doc/src/sgml/ref/create_trigger.sgml b/doc/src/sgml/ref/create_trigger.sgml
index 1856264954c..9ceea50c503 100644
--- a/doc/src/sgml/ref/create_trigger.sgml
+++ b/doc/src/sgml/ref/create_trigger.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new trigger
+
+ CREATE TRIGGER
+
+
CREATE TRIGGER name { BEFORE | AFTER } { event [ OR ... ] }
diff --git a/doc/src/sgml/ref/create_type.sgml b/doc/src/sgml/ref/create_type.sgml
index 2d2b92a85aa..f72d5344ccf 100644
--- a/doc/src/sgml/ref/create_type.sgml
+++ b/doc/src/sgml/ref/create_type.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new data type
+
+ CREATE TYPE
+
+
CREATE TYPE typename AS
diff --git a/doc/src/sgml/ref/create_user.sgml b/doc/src/sgml/ref/create_user.sgml
index 23d64bd2c54..382f1a246ce 100644
--- a/doc/src/sgml/ref/create_user.sgml
+++ b/doc/src/sgml/ref/create_user.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new database user account
+
+ CREATE USER
+
+
CREATE USER username [ [ WITH ] option [ ... ] ]
diff --git a/doc/src/sgml/ref/create_view.sgml b/doc/src/sgml/ref/create_view.sgml
index 8bfb4f16636..42a69f5fcc2 100644
--- a/doc/src/sgml/ref/create_view.sgml
+++ b/doc/src/sgml/ref/create_view.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a new view
+
+ CREATE VIEW
+
+
CREATE [ OR REPLACE ] VIEW name [ (
@@ -15,6 +15,10 @@ PostgreSQL documentation
create a new PostgreSQL database
+
+ createdb
+
+
createdb
diff --git a/doc/src/sgml/ref/createlang.sgml b/doc/src/sgml/ref/createlang.sgml
index be86e7c1c79..e2fcee63e08 100644
--- a/doc/src/sgml/ref/createlang.sgml
+++ b/doc/src/sgml/ref/createlang.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
define a new PostgreSQL procedural language
+
+ createlang
+
+
createlang
diff --git a/doc/src/sgml/ref/createuser.sgml b/doc/src/sgml/ref/createuser.sgml
index ba882776878..0b07662819b 100644
--- a/doc/src/sgml/ref/createuser.sgml
+++ b/doc/src/sgml/ref/createuser.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
define a new PostgreSQL user account
+
+ createuser
+
+
createuser
@@ -276,7 +280,7 @@ PostgreSQL documentation
CREATE USER
- All is well.
+ The user was successfully created.
diff --git a/doc/src/sgml/ref/deallocate.sgml b/doc/src/sgml/ref/deallocate.sgml
index 008a6262e12..91355ce61a6 100644
--- a/doc/src/sgml/ref/deallocate.sgml
+++ b/doc/src/sgml/ref/deallocate.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
deallocate a prepared statement
+
+ DEALLOCATE
+
+
DEALLOCATE [ PREPARE ] plan_name
diff --git a/doc/src/sgml/ref/declare.sgml b/doc/src/sgml/ref/declare.sgml
index 0aaf0dde43d..3585a71f79f 100644
--- a/doc/src/sgml/ref/declare.sgml
+++ b/doc/src/sgml/ref/declare.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define a cursor
+
+ DECLARE
+
+
DECLARE cursorname [ BINARY ] [ INSENSITIVE ] [ [ NO ] SCROLL ]
@@ -202,11 +206,10 @@ DECLARE cursorname [ BINARY ] [ INS
- WARNING: Closing pre-existing portal "cursorname"
+ ERROR: cursor "cursorname" already exists
- This message is reported if a cursor with the same name already
- exists. The previous definition is discarded.
+ This error occurs if a cursor with the same name already exists.
diff --git a/doc/src/sgml/ref/delete.sgml b/doc/src/sgml/ref/delete.sgml
index b04b86c8887..c5c75459860 100644
--- a/doc/src/sgml/ref/delete.sgml
+++ b/doc/src/sgml/ref/delete.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
delete rows of a table
+
+ DELETE
+
+
DELETE FROM [ ONLY ] table [ WHERE condition ]
diff --git a/doc/src/sgml/ref/drop_aggregate.sgml b/doc/src/sgml/ref/drop_aggregate.sgml
index 49915626a5c..4dcb29eee61 100644
--- a/doc/src/sgml/ref/drop_aggregate.sgml
+++ b/doc/src/sgml/ref/drop_aggregate.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a user-defined aggregate function
+
+ DROP AGGREGATE
+
+
DROP AGGREGATE name ( type ) [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_cast.sgml b/doc/src/sgml/ref/drop_cast.sgml
index 427796e56bf..c25e2ab1db5 100644
--- a/doc/src/sgml/ref/drop_cast.sgml
+++ b/doc/src/sgml/ref/drop_cast.sgml
@@ -1,4 +1,4 @@
-
+
@@ -11,6 +11,10 @@
remove a user-defined cast
+
+ DROP CAST
+
+
DROP CAST (sourcetype AS targettype) [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_conversion.sgml b/doc/src/sgml/ref/drop_conversion.sgml
index d9c795c445a..b225e2b1cea 100644
--- a/doc/src/sgml/ref/drop_conversion.sgml
+++ b/doc/src/sgml/ref/drop_conversion.sgml
@@ -1,4 +1,4 @@
-
+
@@ -11,6 +11,10 @@
remove a user-defined conversion
+
+ DROP CONVERSION
+
+
DROP CONVERSION conversion_name [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_database.sgml b/doc/src/sgml/ref/drop_database.sgml
index fb77f53c67c..4c71b3cf680 100644
--- a/doc/src/sgml/ref/drop_database.sgml
+++ b/doc/src/sgml/ref/drop_database.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a database
+
+ DROP DATABASE
+
+
DROP DATABASE name
diff --git a/doc/src/sgml/ref/drop_domain.sgml b/doc/src/sgml/ref/drop_domain.sgml
index 99c8ec7d44e..81271c88bf1 100644
--- a/doc/src/sgml/ref/drop_domain.sgml
+++ b/doc/src/sgml/ref/drop_domain.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a domain
+
+ DROP DOMAIN
+
+
DROP DOMAIN domainname [, ...] [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_function.sgml b/doc/src/sgml/ref/drop_function.sgml
index 1a62a00f482..005c8a1567b 100644
--- a/doc/src/sgml/ref/drop_function.sgml
+++ b/doc/src/sgml/ref/drop_function.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a user-defined function
+
+ DROP FUNCTION
+
+
DROP FUNCTION name ( [ type [, ...] ] ) [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_group.sgml b/doc/src/sgml/ref/drop_group.sgml
index c6c6907e751..bf83d1e0221 100644
--- a/doc/src/sgml/ref/drop_group.sgml
+++ b/doc/src/sgml/ref/drop_group.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a user group
+
+ DROP GROUP
+
+
DROP GROUP name
diff --git a/doc/src/sgml/ref/drop_index.sgml b/doc/src/sgml/ref/drop_index.sgml
index 4185a4158c2..5b33121c468 100644
--- a/doc/src/sgml/ref/drop_index.sgml
+++ b/doc/src/sgml/ref/drop_index.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove an index
+
+ DROP INDEX
+
+
DROP INDEX name [, ...] [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_language.sgml b/doc/src/sgml/ref/drop_language.sgml
index ad67a95d442..f1f50a1772e 100644
--- a/doc/src/sgml/ref/drop_language.sgml
+++ b/doc/src/sgml/ref/drop_language.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a user-defined procedural language
+
+ DROP LANGUAGE
+
+
DROP [ PROCEDURAL ] LANGUAGE name [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_opclass.sgml b/doc/src/sgml/ref/drop_opclass.sgml
index cb0aebd7103..0c5413c8e63 100644
--- a/doc/src/sgml/ref/drop_opclass.sgml
+++ b/doc/src/sgml/ref/drop_opclass.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a user-defined operator class
+
+ DROP OPERATOR CLASS
+
+
DROP OPERATOR CLASS name USING index_method [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_operator.sgml b/doc/src/sgml/ref/drop_operator.sgml
index 8f3b1e069c6..feae97f5f0d 100644
--- a/doc/src/sgml/ref/drop_operator.sgml
+++ b/doc/src/sgml/ref/drop_operator.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a user-defined operator
+
+ DROP OPERATOR
+
+
DROP OPERATOR name ( lefttype | NONE , righttype | NONE ) [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_rule.sgml b/doc/src/sgml/ref/drop_rule.sgml
index 0276621c575..6824cd268b8 100644
--- a/doc/src/sgml/ref/drop_rule.sgml
+++ b/doc/src/sgml/ref/drop_rule.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a rewrite rule
+
+ DROP RULE
+
+
DROP RULE name ON relation [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_schema.sgml b/doc/src/sgml/ref/drop_schema.sgml
index b8f706b0c77..61c8fbc9421 100644
--- a/doc/src/sgml/ref/drop_schema.sgml
+++ b/doc/src/sgml/ref/drop_schema.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a schema
+
+ DROP SCHEMA
+
+
DROP SCHEMA name [, ...] [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_sequence.sgml b/doc/src/sgml/ref/drop_sequence.sgml
index fe77e2a3d69..8aeeb80fd70 100644
--- a/doc/src/sgml/ref/drop_sequence.sgml
+++ b/doc/src/sgml/ref/drop_sequence.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a sequence
+
+ DROP SEQUENCE
+
+
DROP SEQUENCE name [, ...] [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_table.sgml b/doc/src/sgml/ref/drop_table.sgml
index 4ebda8787e6..7671f9dbf03 100644
--- a/doc/src/sgml/ref/drop_table.sgml
+++ b/doc/src/sgml/ref/drop_table.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a table
+
+ DROP TABLE
+
+
DROP TABLE name [, ...] [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_trigger.sgml b/doc/src/sgml/ref/drop_trigger.sgml
index 5a33d033c24..92307dc7459 100644
--- a/doc/src/sgml/ref/drop_trigger.sgml
+++ b/doc/src/sgml/ref/drop_trigger.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a trigger
+
+ DROP TRIGGER
+
+
DROP TRIGGER name ON table [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_type.sgml b/doc/src/sgml/ref/drop_type.sgml
index 4267efcb0bd..ccbdea350de 100644
--- a/doc/src/sgml/ref/drop_type.sgml
+++ b/doc/src/sgml/ref/drop_type.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a user-defined data type
+
+ DROP TYPE
+
+
DROP TYPE typename [, ...] [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/drop_user.sgml b/doc/src/sgml/ref/drop_user.sgml
index 7d094b993d3..41040fe7a35 100644
--- a/doc/src/sgml/ref/drop_user.sgml
+++ b/doc/src/sgml/ref/drop_user.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a database user account
+
+ DROP USER
+
+
DROP USER name
diff --git a/doc/src/sgml/ref/drop_view.sgml b/doc/src/sgml/ref/drop_view.sgml
index fd32f92f8ac..4238a61cc83 100644
--- a/doc/src/sgml/ref/drop_view.sgml
+++ b/doc/src/sgml/ref/drop_view.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove a view
+
+ DROP VIEW
+
+
DROP VIEW name [, ...] [ CASCADE | RESTRICT ]
diff --git a/doc/src/sgml/ref/dropdb.sgml b/doc/src/sgml/ref/dropdb.sgml
index e029b1a6a36..b21ad29a91b 100644
--- a/doc/src/sgml/ref/dropdb.sgml
+++ b/doc/src/sgml/ref/dropdb.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
remove a PostgreSQL database
+
+ dropdb
+
+
dropdb
diff --git a/doc/src/sgml/ref/droplang.sgml b/doc/src/sgml/ref/droplang.sgml
index 6bddf1a5ba5..6d4f181feeb 100644
--- a/doc/src/sgml/ref/droplang.sgml
+++ b/doc/src/sgml/ref/droplang.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
remove a PostgreSQL procedural language
+
+ droplang
+
+
droplang
diff --git a/doc/src/sgml/ref/dropuser.sgml b/doc/src/sgml/ref/dropuser.sgml
index 24e8d8ecf45..d1d8d10289d 100644
--- a/doc/src/sgml/ref/dropuser.sgml
+++ b/doc/src/sgml/ref/dropuser.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
remove a PostgreSQL user account
+
+ dropuser
+
+
dropuser
@@ -180,7 +184,7 @@ PostgreSQL documentation
DROP USER
- All is well.
+ The user was successfully removed.
diff --git a/doc/src/sgml/ref/ecpg-ref.sgml b/doc/src/sgml/ref/ecpg-ref.sgml
index ffb5ed41945..4fb4d72c5ad 100644
--- a/doc/src/sgml/ref/ecpg-ref.sgml
+++ b/doc/src/sgml/ref/ecpg-ref.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
embedded SQL C preprocessor
+
+ ecpg
+
+
ecpg
diff --git a/doc/src/sgml/ref/end.sgml b/doc/src/sgml/ref/end.sgml
index b672319479e..82274be3e5c 100644
--- a/doc/src/sgml/ref/end.sgml
+++ b/doc/src/sgml/ref/end.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
commit the current transaction
+
+ END
+
+
END [ WORK | TRANSACTION ]
diff --git a/doc/src/sgml/ref/execute.sgml b/doc/src/sgml/ref/execute.sgml
index 7704b8ce27b..d5e29a07a1e 100644
--- a/doc/src/sgml/ref/execute.sgml
+++ b/doc/src/sgml/ref/execute.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
execute a prepared statement
+
+ EXECUTE
+
+
EXECUTE plan_name [ (parameter [, ...] ) ]
diff --git a/doc/src/sgml/ref/explain.sgml b/doc/src/sgml/ref/explain.sgml
index 2ac74e8a383..5078d8fcc84 100644
--- a/doc/src/sgml/ref/explain.sgml
+++ b/doc/src/sgml/ref/explain.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
show the execution plan of a statement
+
+ EXPLAIN
+
+
EXPLAIN [ ANALYZE ] [ VERBOSE ] statement
diff --git a/doc/src/sgml/ref/fetch.sgml b/doc/src/sgml/ref/fetch.sgml
index 305e5fc02cc..682a4a68378 100644
--- a/doc/src/sgml/ref/fetch.sgml
+++ b/doc/src/sgml/ref/fetch.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
retrieve rows from a query using a cursor
+
+ FETCH
+
+
FETCH [ direction { FROM | IN } ] cursor
@@ -281,7 +285,7 @@ where direction can be empty or one
- WARNING: PerformPortalFetch: portal "cursor" not found
+ ERROR: cursor "cursor" does not exist
There is no cursor with the specified name.
diff --git a/doc/src/sgml/ref/grant.sgml b/doc/src/sgml/ref/grant.sgml
index 7ba370d6598..10ec3ca1027 100644
--- a/doc/src/sgml/ref/grant.sgml
+++ b/doc/src/sgml/ref/grant.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
define access privileges
+
+ GRANT
+
+
GRANT { { SELECT | INSERT | UPDATE | DELETE | RULE | REFERENCES | TRIGGER }
diff --git a/doc/src/sgml/ref/initdb.sgml b/doc/src/sgml/ref/initdb.sgml
index ccab2e94422..1ab6d7f48d3 100644
--- a/doc/src/sgml/ref/initdb.sgml
+++ b/doc/src/sgml/ref/initdb.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
create a new PostgreSQL database cluster
+
+ initdb
+
+
initdb
diff --git a/doc/src/sgml/ref/initlocation.sgml b/doc/src/sgml/ref/initlocation.sgml
index 8211e635cd2..938994e6953 100644
--- a/doc/src/sgml/ref/initlocation.sgml
+++ b/doc/src/sgml/ref/initlocation.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
create a secondary PostgreSQL database storage area
+
+ initlocation
+
+
initlocation
diff --git a/doc/src/sgml/ref/insert.sgml b/doc/src/sgml/ref/insert.sgml
index cbb0d279bd2..12f6d70384e 100644
--- a/doc/src/sgml/ref/insert.sgml
+++ b/doc/src/sgml/ref/insert.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
create new rows in a table
+
+ INSERT
+
+
INSERT INTO table [ ( column [, ...] ) ]
diff --git a/doc/src/sgml/ref/ipcclean.sgml b/doc/src/sgml/ref/ipcclean.sgml
index 85ca334c178..48efbd67590 100644
--- a/doc/src/sgml/ref/ipcclean.sgml
+++ b/doc/src/sgml/ref/ipcclean.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
remove shared memory and semaphores from an aborted PostgreSQL server
+
+ ipcclean
+
+
ipcclean
diff --git a/doc/src/sgml/ref/listen.sgml b/doc/src/sgml/ref/listen.sgml
index 154224d0d20..733d34bda58 100644
--- a/doc/src/sgml/ref/listen.sgml
+++ b/doc/src/sgml/ref/listen.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
listen for a notification
+
+ LISTEN
+
+
LISTEN name
diff --git a/doc/src/sgml/ref/load.sgml b/doc/src/sgml/ref/load.sgml
index 056322f58ed..ee0bf007d6a 100644
--- a/doc/src/sgml/ref/load.sgml
+++ b/doc/src/sgml/ref/load.sgml
@@ -1,5 +1,5 @@
@@ -13,6 +13,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/ref/load.sgml,v 1.17 2003/04/26 23:56:51 pe
load or reload a shared library file
+
+ LOAD
+
+
LOAD 'filename'
diff --git a/doc/src/sgml/ref/lock.sgml b/doc/src/sgml/ref/lock.sgml
index c39cb154b8e..8dfb661ba80 100644
--- a/doc/src/sgml/ref/lock.sgml
+++ b/doc/src/sgml/ref/lock.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
lock a table
+
+ LOCK
+
+
LOCK [ TABLE ] name [, ...] [ IN lockmode MODE ]
diff --git a/doc/src/sgml/ref/move.sgml b/doc/src/sgml/ref/move.sgml
index d60ec29c3b5..b21f0244a70 100644
--- a/doc/src/sgml/ref/move.sgml
+++ b/doc/src/sgml/ref/move.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
reposition a cursor
+
+ MOVE
+
+
MOVE [ direction { FROM | IN } ] cursor
diff --git a/doc/src/sgml/ref/notify.sgml b/doc/src/sgml/ref/notify.sgml
index 82cd1531790..37e6f8babc2 100644
--- a/doc/src/sgml/ref/notify.sgml
+++ b/doc/src/sgml/ref/notify.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
generate a notification
+
+ NOTIFY
+
+
NOTIFY name
diff --git a/doc/src/sgml/ref/pg_config-ref.sgml b/doc/src/sgml/ref/pg_config-ref.sgml
index 084d78b95d0..cb27d5c902a 100644
--- a/doc/src/sgml/ref/pg_config-ref.sgml
+++ b/doc/src/sgml/ref/pg_config-ref.sgml
@@ -1,4 +1,4 @@
-
+
@@ -12,6 +12,10 @@
retrieve information about the installed version of PostgreSQL>
+
+ pg_config
+
+
pg_config
diff --git a/doc/src/sgml/ref/pg_controldata.sgml b/doc/src/sgml/ref/pg_controldata.sgml
index 314022eb925..42d767846e2 100644
--- a/doc/src/sgml/ref/pg_controldata.sgml
+++ b/doc/src/sgml/ref/pg_controldata.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
display control information of a PostgreSQL database cluster
+
+ pg_controldata
+
+
pg_controldata
diff --git a/doc/src/sgml/ref/pg_ctl-ref.sgml b/doc/src/sgml/ref/pg_ctl-ref.sgml
index 8aabb33934f..812e76e650e 100644
--- a/doc/src/sgml/ref/pg_ctl-ref.sgml
+++ b/doc/src/sgml/ref/pg_ctl-ref.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
start, stop, or restart a PostgreSQL server
+
+ pg_ctl
+
+
pg_ctl
diff --git a/doc/src/sgml/ref/pg_dump.sgml b/doc/src/sgml/ref/pg_dump.sgml
index 5b9e2d4c40e..23ef56858f9 100644
--- a/doc/src/sgml/ref/pg_dump.sgml
+++ b/doc/src/sgml/ref/pg_dump.sgml
@@ -1,5 +1,5 @@
@@ -18,6 +18,10 @@ PostgreSQL documentation
+
+ pg_dump
+
+
pg_dump
diff --git a/doc/src/sgml/ref/pg_dumpall.sgml b/doc/src/sgml/ref/pg_dumpall.sgml
index 500336e9196..e0ac946472a 100644
--- a/doc/src/sgml/ref/pg_dumpall.sgml
+++ b/doc/src/sgml/ref/pg_dumpall.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
extract a PostgreSQL database cluster into a script file
+
+ pg_dumpall
+
+
pg_dumpall
diff --git a/doc/src/sgml/ref/pg_restore.sgml b/doc/src/sgml/ref/pg_restore.sgml
index cf028b93e59..a04427a7cbd 100644
--- a/doc/src/sgml/ref/pg_restore.sgml
+++ b/doc/src/sgml/ref/pg_restore.sgml
@@ -1,4 +1,4 @@
-
+
@@ -15,6 +15,10 @@
+
+ pg_restore
+
+
pg_restore
@@ -42,8 +46,8 @@
pg_restore can operate in two modes: If
a database name is specified, the archive is restored directly into
- the database. Large objects can only be restored by using a direct
- database connection. Otherwise, a script containing the SQL
+ the database. (Large objects can only be restored by using such a direct
+ database connection.) Otherwise, a script containing the SQL
commands necessary to rebuild the database is created (and written
to a file or standard output), similar to the ones created by the
pg_dump plain text format. Some of the
@@ -228,11 +232,13 @@
--orig-order
- Restore items in the original dump order. By default
- pg_dump will dump items in an order
- convenient to pg_dump, then save the
- archive in a modified OID order. This option overrides the OID
- ordering.
+ Restore items in the order they were originally generated within
+ pg_dump. This option has no known
+ practical use, since pg_dump generates
+ the items in an order convenient to it, which is unlikely to be a
+ safe order for restoring them. (This is not> the order
+ in which the items are ultimately listed in the archive's table of
+ contents.) See also
-r>.
@@ -242,11 +248,10 @@
--oid-order
- Restore items in the OID order. By default
- pg_dump will dump items in an order
- convenient to pg_dump, then save the
- archive in a modified OID order. This option enforces strict
- OID ordering.
+ Restore items in order by OID. This option is of limited usefulness,
+ since OID is only an approximate indication of original creation
+ order. This option overrides
-N> if both are specified.
+ See also
-r>.
@@ -281,13 +286,22 @@
--rearrange
- Restore items in modified OID order. By default
- pg_dump will dump items in an order
- convenient to pg_dump, then save the
- archive in a modified OID order. Most objects will be restored
- in OID order, but some things (e.g., rules and indexes) will
- be restored at the end of the process irrespective of their
- OIDs. This option is the default.
+ Rearrange items by object type (this occurs after the sorting
+ specified by
-N
or
-o
, if
+ given). The rearrangement is intended to give the best possible
+ restore performance.
+
+
+
+ When none of
-N
,
-o
, and
+
-r> appear, pg_restore restores
+ items in the order they appear in the dump's table of contents,
+ or in the order they appear in the list-file if
-L> is
+ given. The combination of
-o> and
-r>
+ duplicates the sorting done by pg_dump
+ before creating the dump's table of contents,
+ and so it is normally unnecessary to specify it.
diff --git a/doc/src/sgml/ref/pgtclsh.sgml b/doc/src/sgml/ref/pgtclsh.sgml
index 2a32d6305e0..f7b52a7cc08 100644
--- a/doc/src/sgml/ref/pgtclsh.sgml
+++ b/doc/src/sgml/ref/pgtclsh.sgml
@@ -1,5 +1,5 @@
@@ -17,6 +17,10 @@ PostgreSQL documentation
+
+ pgtclsh
+
+
pgtclsh
diff --git a/doc/src/sgml/ref/pgtksh.sgml b/doc/src/sgml/ref/pgtksh.sgml
index bcc052bfdbf..c04f219c3f8 100644
--- a/doc/src/sgml/ref/pgtksh.sgml
+++ b/doc/src/sgml/ref/pgtksh.sgml
@@ -1,5 +1,5 @@
@@ -17,6 +17,10 @@ PostgreSQL documentation
+
+ pgtksh
+
+
pgtksh
diff --git a/doc/src/sgml/ref/postgres-ref.sgml b/doc/src/sgml/ref/postgres-ref.sgml
index 073b83fd7d9..66e5e02502b 100644
--- a/doc/src/sgml/ref/postgres-ref.sgml
+++ b/doc/src/sgml/ref/postgres-ref.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
run a PostgreSQL server in single-user mode
+
+ postgres (the program)
+
+
diff --git a/doc/src/sgml/ref/postmaster.sgml b/doc/src/sgml/ref/postmaster.sgml
index ed431c6b54b..d68827c6e1e 100644
--- a/doc/src/sgml/ref/postmaster.sgml
+++ b/doc/src/sgml/ref/postmaster.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
PostgreSQL multiuser database server
+
+ postmaster
+
+
postmaster
diff --git a/doc/src/sgml/ref/prepare.sgml b/doc/src/sgml/ref/prepare.sgml
index 9f58b7a5ce8..22f9067dd0d 100644
--- a/doc/src/sgml/ref/prepare.sgml
+++ b/doc/src/sgml/ref/prepare.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
prepare a statement for execution
+
+ PREPARE
+
+
PREPARE plan_name [ (datatype [, ...] ) ] AS statement
@@ -130,7 +134,7 @@ PREPARE plan_name [ (PostgreSQL collects
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 3969a1ad641..251f67fa5cd 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -1,5 +1,5 @@
@@ -17,6 +17,10 @@ PostgreSQL documentation
+
+ psql
+
+
psql
@@ -2210,8 +2214,14 @@ testdb=> \set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
%n
- The user name you are connected as (not your local system
- user name).
+
+
+ The database session user name. (The expansion of this
+ value might change during a database session as the result
+ of the command SET SESSION
+ AUTHORIZATION.)
+
+
@@ -2227,8 +2237,15 @@ testdb=> \set content '\'' `sed -e "s/'/\\\\\\'/g" < my_file.txt` '\'
%#
- If the current user is a database superuser, then a
- #, otherwise a >.
+
+
+ If the session user is a database superuser, then a
+ #, otherwise a >.
+ (The expansion of this value might change during a database
+ session as the result of the command SET SESSION
+ AUTHORIZATION.)
+
+
diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml
index 591542ac1e0..c18950d0d29 100644
--- a/doc/src/sgml/ref/reindex.sgml
+++ b/doc/src/sgml/ref/reindex.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
rebuild indexes
+
+ REINDEX
+
+
REINDEX { DATABASE | TABLE | INDEX } name [ FORCE ]
diff --git a/doc/src/sgml/ref/reset.sgml b/doc/src/sgml/ref/reset.sgml
index 87d9de30974..71a2bf01b68 100644
--- a/doc/src/sgml/ref/reset.sgml
+++ b/doc/src/sgml/ref/reset.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
restore the value of a run-time parameter to the default value
+
+ RESET
+
+
RESET parameter
diff --git a/doc/src/sgml/ref/revoke.sgml b/doc/src/sgml/ref/revoke.sgml
index 22cb395a75d..6f7eb06deb2 100644
--- a/doc/src/sgml/ref/revoke.sgml
+++ b/doc/src/sgml/ref/revoke.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
remove access privileges
+
+ REVOKE
+
+
REVOKE [ GRANT OPTION FOR ]
diff --git a/doc/src/sgml/ref/rollback.sgml b/doc/src/sgml/ref/rollback.sgml
index dc5b063c495..3a6026fee2a 100644
--- a/doc/src/sgml/ref/rollback.sgml
+++ b/doc/src/sgml/ref/rollback.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
abort the current transaction
+
+ ROLLBACK
+
+
ROLLBACK [ WORK | TRANSACTION ]
diff --git a/doc/src/sgml/ref/select.sgml b/doc/src/sgml/ref/select.sgml
index f983b2a8213..2353bb540cd 100644
--- a/doc/src/sgml/ref/select.sgml
+++ b/doc/src/sgml/ref/select.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
retrieve rows from a table or view
+
+ SELECT
+
+
SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
@@ -660,8 +664,11 @@ SELECT name FROM distributors ORDER BY code;
ORDER BY> clause. If not specified, ASC> is
assumed by default. Alternatively, a specific ordering operator
name may be specified in the USING> clause.
- ASC> is equivalent to USING <> and
- DESC> is equivalent to USING >>.
+ ASC> is usually equivalent to USING <> and
+ DESC> is usually equivalent to USING >>.
+ (But the creator of a user-defined datatype can define exactly what the
+ default sort ordering is, and it might correspond to operators with other
+ names.)
@@ -671,7 +678,7 @@ SELECT name FROM distributors ORDER BY code;
- Data of character types is sorted according to the locale-specific
+ Character-string data is sorted according to the locale-specific
collation order that was established when the database cluster
was initialized.
@@ -1003,7 +1010,9 @@ SELECT distributors.* FROM distributors d, distributors distributors;
that he will actually get. To help detect this sort of mistake,
PostgreSQL will warn if the implicit-FROM
feature is used in a SELECT statement that also
- contains an explicit FROM clause.
+ contains an explicit FROM clause. Also, it is
+ possible to disable the implicit-FROM feature
+ by setting the ADD_MISSING_FROM> parameter to false.
@@ -1015,7 +1024,7 @@ SELECT distributors.* FROM distributors d, distributors distributors;
noise and can be omitted without affecting the meaning. The
PostgreSQL parser requires this key
word when renaming output columns because the type extensibility
- features lead to parsing ambiguities in this context.
+ features lead to parsing ambiguities without it.
AS is optional in FROM
items, however.
@@ -1025,7 +1034,7 @@ SELECT distributors.* FROM distributors d, distributors distributors;
Namespace Available to GROUP BY and ORDER BY
- In the SQL standard, an ORDER BY clause may
+ In the SQL92 standard, an ORDER BY clause may
only use result column names or numbers, while a GROUP
BY clause may only use expressions based on input column
names. PostgreSQL extends each of
@@ -1036,6 +1045,13 @@ SELECT distributors.* FROM distributors d, distributors distributors;
expression will always be taken as input-column names, not as
result-column names.
+
+
+ SQL99 uses a slightly different definition which is not upward compatible
+ with SQL92. In most cases, however, PostgreSQL
+ will interpret an ORDER BY or GROUP
+ BY expression the same way SQL99 does.
+
diff --git a/doc/src/sgml/ref/select_into.sgml b/doc/src/sgml/ref/select_into.sgml
index 131bb6e1a2f..b7263025170 100644
--- a/doc/src/sgml/ref/select_into.sgml
+++ b/doc/src/sgml/ref/select_into.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
create a new table from the results of a query
+
+ SELECT INTO
+
+
SELECT [ ALL | DISTINCT [ ON ( expression [, ...] ) ] ]
diff --git a/doc/src/sgml/ref/set.sgml b/doc/src/sgml/ref/set.sgml
index bb1ddd22759..57c491d6df5 100644
--- a/doc/src/sgml/ref/set.sgml
+++ b/doc/src/sgml/ref/set.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
change a run-time parameter
+
+ SET
+
+
SET [ SESSION | LOCAL ] variable { TO | = } { value | 'value' | DEFAULT }
diff --git a/doc/src/sgml/ref/set_constraints.sgml b/doc/src/sgml/ref/set_constraints.sgml
index 3d5b58bee2e..3e89f60769d 100644
--- a/doc/src/sgml/ref/set_constraints.sgml
+++ b/doc/src/sgml/ref/set_constraints.sgml
@@ -1,4 +1,4 @@
-
+
SET CONSTRAINTS
@@ -10,6 +10,10 @@
set the constraint mode of the current transaction
+
+ SET CONSTRAINTS
+
+
SET CONSTRAINTS { ALL | constraint [, ...] } { DEFERRED | IMMEDIATE }
diff --git a/doc/src/sgml/ref/set_session_auth.sgml b/doc/src/sgml/ref/set_session_auth.sgml
index f8c0297adad..ba2c27acbe9 100644
--- a/doc/src/sgml/ref/set_session_auth.sgml
+++ b/doc/src/sgml/ref/set_session_auth.sgml
@@ -1,4 +1,4 @@
-
+
SET SESSION AUTHORIZATION
@@ -10,6 +10,10 @@
set the session user identifier and the current user identifier of the current session
+
+ SET SESSION AUTHORIZATION
+
+
SET [ SESSION | LOCAL ] SESSION AUTHORIZATION username
diff --git a/doc/src/sgml/ref/set_transaction.sgml b/doc/src/sgml/ref/set_transaction.sgml
index 2ff29bc3d5f..d531d8f43af 100644
--- a/doc/src/sgml/ref/set_transaction.sgml
+++ b/doc/src/sgml/ref/set_transaction.sgml
@@ -1,4 +1,4 @@
-
+
SET TRANSACTION
@@ -10,6 +10,10 @@
set the characteristics of the current transaction
+
+ SET TRANSACTION
+
+
SET TRANSACTION
diff --git a/doc/src/sgml/ref/show.sgml b/doc/src/sgml/ref/show.sgml
index 1f0f52735a0..3bb52cce54b 100644
--- a/doc/src/sgml/ref/show.sgml
+++ b/doc/src/sgml/ref/show.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
show the value of a run-time parameter
+
+ SHOW
+
+
SHOW name
diff --git a/doc/src/sgml/ref/start_transaction.sgml b/doc/src/sgml/ref/start_transaction.sgml
index 5b9abefddd8..8b8690c0f29 100644
--- a/doc/src/sgml/ref/start_transaction.sgml
+++ b/doc/src/sgml/ref/start_transaction.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
start a transaction block
+
+ START TRANSACTION
+
+
START TRANSACTION [ ISOLATION LEVEL { READ COMMITTED | SERIALIZABLE } ] [ READ WRITE | READ ONLY ]
diff --git a/doc/src/sgml/ref/truncate.sgml b/doc/src/sgml/ref/truncate.sgml
index b5b9d84ddc8..f10d0a4456c 100644
--- a/doc/src/sgml/ref/truncate.sgml
+++ b/doc/src/sgml/ref/truncate.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
empty a table
+
+ TRUNCATE
+
+
TRUNCATE [ TABLE ] name
diff --git a/doc/src/sgml/ref/unlisten.sgml b/doc/src/sgml/ref/unlisten.sgml
index 4c3799177b2..54e857b3c9b 100644
--- a/doc/src/sgml/ref/unlisten.sgml
+++ b/doc/src/sgml/ref/unlisten.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
stop listening for a notification
+
+ UNLISTEN
+
+
UNLISTEN { name | * }
diff --git a/doc/src/sgml/ref/update.sgml b/doc/src/sgml/ref/update.sgml
index 1fe85b995ed..c7020e85a7a 100644
--- a/doc/src/sgml/ref/update.sgml
+++ b/doc/src/sgml/ref/update.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
update rows of a table
+
+ UPDATE
+
+
UPDATE [ ONLY ] table SET column = { expression | DEFAULT } [, ...]
diff --git a/doc/src/sgml/ref/vacuum.sgml b/doc/src/sgml/ref/vacuum.sgml
index 3f532c02448..3cfba61f445 100644
--- a/doc/src/sgml/ref/vacuum.sgml
+++ b/doc/src/sgml/ref/vacuum.sgml
@@ -1,5 +1,5 @@
@@ -14,6 +14,10 @@ PostgreSQL documentation
garbage-collect and optionally analyze a database
+
+ VACUUM
+
+
VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ table ]
diff --git a/doc/src/sgml/ref/vacuumdb.sgml b/doc/src/sgml/ref/vacuumdb.sgml
index e04cf16c3fe..5bc236ccd8b 100644
--- a/doc/src/sgml/ref/vacuumdb.sgml
+++ b/doc/src/sgml/ref/vacuumdb.sgml
@@ -1,5 +1,5 @@
@@ -15,6 +15,10 @@ PostgreSQL documentation
garbage-collect and analyze a PostgreSQL database
+
+ vacuumdb
+
+
vacuumdb
@@ -59,10 +63,11 @@ PostgreSQL documentation
- vacuumdb might need to connect several
- times to the PostgreSQL server, asking for
- a password each time. It is convenient to have a
- $HOME/.pgpass> file in such cases.
+ vacuumdb might need to connect several
+ times to the PostgreSQL server, asking
+ for a password each time. It is convenient to have a
+ $HOME/.pgpass> file in such cases. See for more information.
@@ -234,7 +239,7 @@ PostgreSQL documentation
VACUUM
- Everything went well.
+ The database was successfully vacuumed.
diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml
index a5dac7a1411..52ea13fae0e 100644
--- a/doc/src/sgml/regress.sgml
+++ b/doc/src/sgml/regress.sgml
@@ -1,8 +1,16 @@
-
+
Regression Tests
+
+ regression tests
+
+
+
+ test
+
+
The regression tests are a comprehensive set of tests for the SQL
implementation in PostgreSQL. They test
diff --git a/doc/src/sgml/release.sgml b/doc/src/sgml/release.sgml
index 1f4538c7c87..9ff2cb05cce 100644
--- a/doc/src/sgml/release.sgml
+++ b/doc/src/sgml/release.sgml
@@ -1,5 +1,5 @@
@@ -456,8 +456,8 @@ Properly escape jdbc setObject() strings to improve security (Barry)
application examines the system catalogs, additional changes will
be required due to the introduction of schemas in 7.3; for more
information, see:
- http://www.ca.postgresql.org/docs/momjian/upgrade_tips_7.3>.
+ url="http://developer.postgresql.org/~momjian/upgrade_tips_7.3">
+ http://developer.postgresql.org/~momjian/upgrade_tips_7.3>.
@@ -4901,7 +4901,7 @@ Contributors (appologies to any missed)
* david bennett
* ernst.molitor@uni-bonn.de
* Julian Assange
- * Bruce Momjian
+ * Bruce Momjian
* Paul "Shag" Walmsley
* "Alistair G. Crooks"
-->
diff --git a/doc/src/sgml/rules.sgml b/doc/src/sgml/rules.sgml
index 66d20cb11b7..2d485b4d595 100644
--- a/doc/src/sgml/rules.sgml
+++ b/doc/src/sgml/rules.sgml
@@ -1,10 +1,10 @@
-
+
The Rule System
- rules
+ rule
@@ -35,6 +35,10 @@
The Query Tree
+
+ query tree
+
+
To understand how the rule system works it is necessary to know
when it is invoked and what its input and results are.
@@ -146,6 +150,7 @@
the target list
+ target list>>
The target list is a list of expressions that define the
@@ -258,7 +263,16 @@
Views and the Rule System
-rules>and views>>
+
+
+ rule
+ and views
+
+
+
+ view>
+ implementation through rules>
+
Views in PostgreSQL are implemented
@@ -286,9 +300,14 @@ CREATE RULE "_RETURN" AS ON SELECT TO myview DO INSTEAD
same thing: relations.
-
+How SELECT Rules Work
+
+ rule
+ for SELECT
+
+
Rules ON SELECT> are applied to all queries as the last step, even
if the command given is an INSERT,
@@ -736,7 +755,7 @@ SELECT t1.a, t2.b FROM t1, t2 WHERE t1.a = t2.a;
To resolve this problem, another entry is added to the target list
in UPDATE (and also in
DELETE) statements: the current tuple ID
- (CTID>). This is a system column containing the
+ (CTID>).CTID>> This is a system column containing the
file block number and position in the block for the row. Knowing
the table, the CTID> can be used to retrieve the
original row of t1> to be updated. After adding the CTID>
@@ -817,6 +836,21 @@ SELECT t1.a, t2.b, t1.ctid FROM t1, t2 WHERE t1.a = t2.a;
Rules on INSERT>, UPDATE>, and DELETE>
+
+ rule
+ for INSERT
+
+
+
+ rule
+ for UPDATE
+
+
+
+ rule
+ for DELETE
+
+
Rules that are defined on INSERT>, UPDATE>,
and DELETE> are significantly different from the view rules
@@ -1243,7 +1277,7 @@ SELECT shoelace_data.sl_name, 0,
Cooperation with Views
-views>updating>>
+view>updating>>
A simple way to protect view relations from the mentioned
@@ -1654,6 +1688,16 @@ SELECT * FROM shoelace;
Rules and Privileges
+
+ privilege
+ with rules
+
+
+
+ privilege
+ with views
+
+
Due to rewriting of queries by the PostgreSQL
rule system, other tables/views than those used in the original
@@ -1796,6 +1840,16 @@ GRANT SELECT ON phone_number TO secretary;
Rules versus Triggers
+
+ rule
+ compared with triggers
+
+
+
+ trigger
+ compared with rules
+
+
Many things that can be done using triggers can also be
implemented using the PostgreSQL
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index 6adfd85df0f..37168a47b0b 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1,5 +1,5 @@
@@ -69,7 +69,7 @@ $Header: /cvsroot/pgsql/doc/src/sgml/runtime.sgml,v 1.199 2003/08/10 01:20:34 tg
default, although locations such as
/usr/local/pgsql/data or
/var/lib/pgsql/data are popular. To initialize a
- database cluster, use the command initdb, which is
+ database cluster, use the command initdb,initdb>> which is
installed with PostgreSQL. The desired
file system location of your database system is indicated by the
-D
option, for example
@@ -120,11 +120,13 @@ postgres$ initdb -D /usr/local/pgsql/data
However, while the directory contents are secure, the default
client authentication setup allows any local user to connect to the
- database and even become the database superuser. If you do not trust
- other local users, we recommend you use initdb's
-
-W
or
--pwprompt
option to assign a
- password to the database superuser. After initdb,
- modify the pg_hba.conf file to use md5> or
+ database and even become the database superuser. If you do not
+ trust other local users, we recommend you use
+ initdb's
-W
or
+
--pwprompt
option to assign a password to the
+ database superuser.password>of the
+ superuser> After initdb, modify
+ the pg_hba.conf file to use md5> or
password> instead of trust> authentication
before> you start the server for the first time. (Other
approaches include using ident authentication or
@@ -207,8 +209,9 @@ pg_ctl start -l logfile
Normally, you will want to start the database server when the
- computer boots. Autostart scripts are operating system-specific.
- There are a few distributed with
+ computer boots.booting>starting
+ the server during>> Autostart scripts are operating
+ system-specific. There are a few distributed with
PostgreSQL in the
contrib/start-scripts> directory. This may require root
privileges.
@@ -240,7 +243,7 @@ su -c 'pg_ctl start -D /usr/local/pgsql/data -l serverlog' postgres
For FreeBSD, look at the file
contrib/start-scripts/freebsd in the
PostgreSQL source distribution.
- FreeBSD>>
+ FreeBSD>start script>
@@ -248,7 +251,7 @@ su -c 'pg_ctl start -D /usr/local/pgsql/data -l serverlog' postgres
On OpenBSD, add the following lines
to the file /etc/rc.local:
- OpenBSD>>
+ OpenBSD>start script>
if [ -x /usr/local/pgsql/bin/pg_ctl -a -x /usr/local/pgsql/bin/postmaster ]; then
su - -c '/usr/local/pgsql/bin/pg_ctl start -l /var/postgresql/log -s' postgres
@@ -261,7 +264,7 @@ fi
On Linux systems either add
- Linux>>
+ Linux>start script>
/usr/local/pgsql/bin/pg_ctl start -l logfile -D /usr/local/pgsql/data
@@ -276,7 +279,7 @@ fi
On NetBSD, either use the
FreeBSD or
Linux start scripts, depending on
- preference. NetBSD>>
+ preference. NetBSD>start script>
@@ -285,7 +288,7 @@ fi
On Solaris, create a file called
/etc/init.d/postgresql that contains
the following line:
- Solaris>>
+ Solaris>start script>
su - postgres -c "/usr/local/pgsql/bin/pg_ctl start -l logfile -D /usr/local/pgsql/data"
@@ -441,7 +444,7 @@ psql: could not connect to server: Connection refused
configuration
- server
+ of the server
@@ -462,7 +465,7 @@ psql: could not connect to server: Connection refused
One way to set these options is to edit the file
- postgresql.conf in the data directory. (A
+ postgresql.confpostgresql.conf>> in the data directory. (A
default file is installed there.) An example of what this file might
look like is:
@@ -626,7 +629,7 @@ SET ENABLE_SEQSCAN TO OFF;
TCPIP_SOCKET (boolean)
- If this is true, then the server will accept TCP/IP connections.
+ If this is true, then the server will accept TCP/IP connections.TCP/IP>>
Otherwise only local Unix domain socket connections are
accepted. It is off by default. This option can only be set at
server start.
@@ -781,7 +784,8 @@ SET ENABLE_SEQSCAN TO OFF;
AUTHENTICATION_TIMEOUT (integer)
- timeout>authentication>
+ timeout>client authentication>
+ client authentication>timeout during>
Maximum time to complete client authentication, in seconds. If a
@@ -1514,8 +1518,17 @@ SET ENABLE_SEQSCAN TO OFF;
Error Reporting and Logging
+
+ server log
+
+
Syslog
+
+
+ syslog
+
+
@@ -2137,7 +2150,7 @@ SET ENABLE_SEQSCAN TO OFF;
AUSTRALIAN_TIMEZONES (boolean)
- Australian time zones>>
+ time zone>Australian>>
If set to true, ACST,
@@ -2154,8 +2167,8 @@ SET ENABLE_SEQSCAN TO OFF;
significant digits
- display
- of float numbers
+ floating-point
+ displayEXTRA_FLOAT_DIGITS (integer)
@@ -2175,7 +2188,7 @@ SET ENABLE_SEQSCAN TO OFF;
CLIENT_ENCODING (string)
- character set encoding>>
+ character set>>
Sets the client-side encoding (character set).
@@ -2338,7 +2351,7 @@ dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
deadlock
- timeout
+ timeout duringtimeout
@@ -2388,14 +2401,22 @@ dynamic_library_path = '/usr/local/lib/postgresql:/home/my_project/lib:$libdir'
Version and Platform Compatibility
- Previous Postgres Versions
+ Previous PostgreSQL VersionsADD_MISSING_FROM (boolean)
- missing from>>
+ FROM>missing>>
+ When true>, tables that are referenced by a query will be
+ automatically added to the FROM> clause if not already
+ present. The default is true> for compatibility with
+ previous releases of PostgreSQL>. However, this
+ behavior is not SQL-standard, and many people dislike it because it
+ can mask mistakes. Set to false> for the SQL-standard
+ behavior of rejecting references to tables that are not listed in
+ FROM>.
@@ -2905,7 +2926,7 @@ $ postmaster -o '-S 1024 -s'BSD/OS>
- BSD/OS>>
+ BSD/OS>IPC configuration>>
Shared Memory>
@@ -2966,9 +2987,9 @@ options "SEMMNS=240"
FreeBSD>NetBSD>OpenBSD>
- FreeBSD>>
- NetBSD>>
- OpenBSD>>
+ FreeBSD>IPC configuration>>
+ NetBSD>IPC configuration>>
+ OpenBSD>IPC configuration>>
The options SYSVSHM> and SYSVSEM> need
@@ -3002,7 +3023,7 @@ options SEMMAP=256
HP-UX>
- HP-UX>>
+ HP-UX>IPC configuration>>
The default settings tend to suffice for normal installations.
@@ -3023,7 +3044,7 @@ options SEMMAP=256
Linux>
- Linux>>
+ Linux>IPC configuration>>
The default shared memory limit (both
@@ -3060,14 +3081,61 @@ kernel.shmmax = 134217728
- Linux has poor default memory overcommit behavior. Rather than
- failing if it can not reserve enough memory, it returns success,
- but later fails when the memory can't be mapped and terminates
- the application with kill -9>. To prevent unpredictable
- process termination, use:
+ Linux kernel version 2.4.* has poor default memory overcommit
+ behavior, which can result in the postmaster being killed by the
+ kernel due to memory demands by another process if the system
+ runs out of memory.
+
+
+
+ The symptom of this occuring is a kernel message looking like
+ this (consult your system documentation and configuration on
+ where to look for such a message):
+
+ Out of Memory: Killed process 12345 (postmaster).
+
+
+
+
+ To avoid this situation, run PostgreSQL
+ on a machine where you
+ can be sure that other processes will not run the machine out
+ of memory. If your kernel supports strict and/or paranoid modes
+ of overcommit handling, you can also relieve this problem by
+ altering the system's default behaviour. This can be determined
+ by examining the function vm_enough_memory>
+ in the file mm/mmap.c> in the kernel source.
+ If this file reveals that strict and/or paranoid modes are
+ supported by your kernel, turn one of these modes on by using
+
+sysctl -w vm.overcommit_memory=2
+
+ for strict mode or
sysctl -w vm.overcommit_memory=3
+ for paranoid mode, or placing an equivalent entry in
+ /etc/sysctl.conf>.
+
+
+
+
+ Warning: using these settings in a kernel which does not support
+ these modes will almost certainly increase the danger of the
+ kernel killing the postmaster, rather than reducing it.
+ If in any doubt, consult a kernel expert or your kernel vendor.
+
+
+
+
+ These modes are expected to be supported in all 2.6 and later
+ kernels. Some vendor 2.4 kernels may also support these modes.
+ However, it is known that some vendor documents suggest that
+ they support them while examination of the kernel source reveals
+ that they do not.
+
+
+
Note, you will need enough swap space to cover all your memory needs.
@@ -3076,7 +3144,7 @@ sysctl -w vm.overcommit_memory=3
MacOS X>
- MacOS X>>
+ MacOS X>IPC configuration>>
Edit the file
@@ -3096,7 +3164,7 @@ sysctl -w kern.sysv.shmall
SCO OpenServer>
- SCO OpenServer>>
+ SCO OpenServer>IPC configuration>>
In the default configuration, only 512 kB of shared memory per
@@ -3124,7 +3192,7 @@ sysctl -w kern.sysv.shmall
Solaris>
- Solaris>>
+ Solaris>IPC configuration>>
At least in version 2.6, the default maximum size of a shared
@@ -3157,7 +3225,7 @@ set semsys:seminfo_semmsl=32
UnixWare>
- UnixWare>>
+ UnixWare>IPC configuration>>
On UnixWare> 7, the maximum size for shared
@@ -3277,13 +3345,17 @@ default:\
Shutting Down the Server
+
+ shutdown>
+
+
There are several ways to shut down the database server. You control
the type of shutdown by sending different signals to the server
process.
- SIGTERM
+ SIGTERMSIGTERM>>
After receiving SIGTERM, the server
@@ -3296,7 +3368,7 @@ default:\
- SIGINT
+ SIGINTSIGINT>>
The server disallows new connections and sends all existing
@@ -3309,7 +3381,7 @@ default:\
- SIGQUIT
+ SIGQUITSIGQUIT>>
This is the Immediate Shutdown, which
diff --git a/doc/src/sgml/spi.sgml b/doc/src/sgml/spi.sgml
index b3c65204c44..795db64a6bf 100644
--- a/doc/src/sgml/spi.sgml
+++ b/doc/src/sgml/spi.sgml
@@ -1,3821 +1,2462 @@
-
-
-
-
-Vadim
-Mikheev
-
-
-Transcribed 1998-01-16
-
-
-Server Programming Interface
-
-
-The Server Programming Interface
-(SPI) gives users the
-ability to run SQL queries inside user-defined
-C functions.
-
-
-
-
-The available Procedural Languages (PL) give an alternate
-means to build functions that can execute queries.
-
-
-
-
-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.
-
-
-
-Procedures which use SPI are called by the
-Executor. The SPI calls recursively invoke the
-Executor in turn to run queries. When the Executor is invoked
-recursively, it may itself call procedures which may make
-SPI calls.
-
-
-
-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 probably be changed in future versions.
-
-
-
-A related restriction is the inability to execute BEGIN, END and ABORT
-(transaction control statements). This will also be
-changed in the future.
-
-
-
-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.
-
-
-
-Interface Functions
-
-
-
-SPI_connect
-SPI - Connection Management
-
-
-SPI_connect
-
-
- Connects your procedure to the SPI manager.
-
-SPIconnecting
-SPI_connect
-
-
-
-1997-12-24
-
-
+
+ Server Programming Interface
+
+
+ SPI
+
+
+
+ The Server Programming Interface
+ (SPI) gives users the ability to run
+ SQL commands inside user-defined
+ C functions. SPI is a set of
+ interface functions to simplify access to the parser, planner,
+ optimizer, and executor. SPI also does some
+ memory management.
+
+
+
+ To avoid misunderstanding we'll use the term function
+ when we speak of SPI interface functions and
+ procedure for user-defined C-functions, which may be
+ using SPI.
+
+
+
+ Note that if during the execution of a procedure the transaction is
+ aborted because of an error in a command, 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. A
+ related restriction is the inability to execute
+ BEGIN, COMMIT, and
+ ROLLBACK (transaction control statements) inside
+ a procedure. Both of these restrictions will probably be changed in
+ the future.
+
+
+
+ SPI functions return a nonnegative result on
+ success (either via a returned integer value or in the global
+ variable SPI_result, as described below). On
+ error, a negative result or NULL will be returned.
+
+
+
+ Source code files that use SPI must include the header file
+ executor/spi.h.
+
+
+
+
+ The available procedural languages provide different means to
+ execute SQL commands from procedures. Some of these are modelled
+ after SPI, so this documentation might be of use for those users as
+ well.
+
+
+
+
+
+ Interface Functions
+
+
+
+ SPI_connect
+
+
+
+ SPI_connect
+ connect a procedure to the SPI manager
+
+
+ SPI_connect
+
+
+
int SPI_connect(void)
-
-
-
-
-1997-12-24
-
-Inputs
-
-None
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-int
-
-
-
-Return status
-
-
-SPI_OK_CONNECT
-
-
-
- if connected
-
-
-
-
-SPI_ERROR_CONNECT
-
-
-
- if not connected
-
-
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_connect opens a connection from a procedure
-invocation to the SPI manager.
- You must call this function if you will need to execute queries. Some
- utility SPI functions may be called from un-connected procedures.
-
-
- If your procedure is already connected,
- SPI_connect will return an
- SPI_ERROR_CONNECT error. Note that this
- may happen if a procedure which has called
- SPI_connect directly calls another procedure
- which itself calls SPI_connect. While
- recursive calls to the SPI manager are permitted
- when an SPI query invokes another function which
- uses SPI, directly nested calls to
- SPI_connect and
- SPI_finish are forbidden.
-
-
-
-Usage
-
-
-
-
-
-
-Algorithm
-
-SPI_connect performs the following:
- Initializes the SPI internal
- structures for query execution and memory management.
-
-
-
-
-
-
-
-
-
-
-
-SPI_finish
-SPI - Connection Management
-
-
-SPI_finish
-
-
- Disconnects your procedure from the SPI manager.
-
-SPIdisconnecting
-SPI_finish
-
-
-
-1997-12-24
-
-
-SPI_finish(void)
-
-
-
-
-1997-12-24
-
-Inputs
-
-None
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-int
-
-
-
-
-
-SPI_OK_FINISH
- if properly disconnected
-
-
-SPI_ERROR_UNCONNECTED
- if called from an un-connected procedure
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_finish closes an existing connection to the
-SPI manager.
- You must call this function after completing the SPI operations needed
- during your procedure's current invocation.
-
-
- You may get the error return SPI_ERROR_UNCONNECTED if SPI_finish is
- called without having a current valid connection.
- There is no fundamental problem
- with this; it means that nothing was done by the SPI manager.
-
-
-
-Usage
-
-
- SPI_finishmust be called as a final step by a connected procedure,
- or you may get
- unpredictable results! However, you do not need to worry about making
-this happen if the transaction is aborted via elog(ERROR). In that case
-SPI will clean itself up.
-
-
-
-
-Algorithm
-
-SPI_finish performs the following:
- Disconnects your procedure from the SPI manager and frees all memory
- allocations made by your procedure via palloc since
- the SPI_connect.
- These allocations can't be used any more! See Memory management.
-
-
-
-
-
-
-
-
-
-
-
-SPI_exec
-SPI - Connection Management
-
-
-SPI_exec
-
-
- Creates an execution plan (parser+planner+optimizer) and executes a query.
-
-SPIexecuting
-SPI_exec
-
-
-
-1997-12-24
-
-
-SPI_exec(query, tcount)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-const char * query
-
-
-
-String containing query plan
-
-
-
-
-
-int tcount
-
-
-
-Maximum number of tuples to return
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-int
-
-
-
-
-
- SPI_ERROR_UNCONNECTED if called from an un-connected procedure
-
-
- SPI_ERROR_ARGUMENT if query is NULL or tcount < 0.
-
-
- SPI_ERROR_UNCONNECTED if procedure is unconnected.
-
-
- SPI_ERROR_COPY if COPY TO/FROM stdin.
-
-
- SPI_ERROR_CURSOR if DECLARE/CLOSE CURSOR, FETCH.
-
-
- SPI_ERROR_TRANSACTION if BEGIN/ABORT/END.
-
-
- SPI_ERROR_OPUNKNOWN if type of query is unknown (this shouldn't occur).
-
-
-
-
- If execution of your query was successful then one of the following
- (non-negative) values will be returned:
-
-
- SPI_OK_UTILITY if some utility (e.g. CREATE TABLE ...) was executed
-
-
- SPI_OK_SELECT if SELECT (but not SELECT ... INTO!) was executed
-
-
- SPI_OK_SELINTO if SELECT ... INTO was executed
-
-
- SPI_OK_INSERT if INSERT (or INSERT ... SELECT) was executed
-
-
- SPI_OK_DELETE if DELETE was executed
-
-
- SPI_OK_UPDATE if UPDATE was executed
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_exec creates an execution plan (parser+planner+optimizer)
- and executes the query for tcount tuples.
-
-
-
-
-Usage
-
-
- This should only be called from a connected procedure.
- If tcount is zero then it executes the query for all tuples returned by the
- query scan. Using tcount > 0 you may restrict the number of tuples for
- which the query will be executed (much like a LIMIT clause). For example,
-
-
-SPI_exec ("INSERT INTO tab SELECT * FROM tab", 5);
-
-
-will allow at most 5 tuples to be inserted into table.
-
- If execution of your query was successful then a non-negative value will be returned.
-
-
-
-You may pass multiple queries in one string or query string may be
- re-written by RULEs. SPI_exec returns the result for the last query
- executed.
-
-
-
-
- The actual number of tuples for which the (last) query was executed is
- returned in the global variable SPI_processed (if not SPI_OK_UTILITY).
-
- If SPI_OK_SELECT is returned then you may use global
- pointer SPITupleTable *SPI_tuptable to access the result tuples.
-
-
-
- SPI_exec may return one of the following (negative) values:
-
-
- SPI_ERROR_ARGUMENT if query is NULL or tcount < 0.
-
-
- SPI_ERROR_UNCONNECTED if procedure is unconnected.
-
-
- SPI_ERROR_COPY if COPY TO/FROM stdin.
-
-
- SPI_ERROR_CURSOR if DECLARE/CLOSE CURSOR, FETCH.
-
-
- SPI_ERROR_TRANSACTION if BEGIN/ABORT/END.
-
-
- SPI_ERROR_OPUNKNOWN if type of query is unknown (this shouldn't occur).
-
-
-
-
-
-
-
-Structures
-
-
- If SPI_OK_SELECT is returned then you may use the global
- pointer SPITupleTable *SPI_tuptable to access the selected tuples.
-
-
-
- Structure SPITupleTable is defined in spi.h:
-
- typedef struct
- {
- MemoryContext tuptabcxt; /* memory context of result table */
- uint32 alloced; /* # of alloced vals */
- uint32 free; /* # of free vals */
- TupleDesc tupdesc; /* tuple descriptor */
- HeapTuple *vals; /* tuples */
- } SPITupleTable;
-
-
-
-
- vals> is an array of pointers to tuples (the number of useful entries
- is given by SPI_processed). tupdesc> is
- a tuple descriptor which you may pass to SPI functions dealing with
- tuples. tuptabcxt>, alloced>, and free> are internal fields not intended
- for use by SPI callers.
-
-
-
-
- Functions SPI_exec, SPI_execp and
- SPI_prepare change both SPI_processed and SPI_tuptable
- (just the pointer, not the contents of the structure).
- Save these two global variables into local procedure variables if you need
- to access the result of one SPI_exec or
- SPI_execp across later calls.
-
-
-
-
- SPI_finish frees all SPITupleTables allocated during
- the current procedure. You can free a particular result table earlier,
- if you are done with it, by calling SPI_freetuptable.
-
-
-
-
-
-
-
-
-
-
-SPI_prepare
-SPI - Plan Preparation
-
-
-SPI_prepare
-
-
- Prepares a plan for a query, without executing it yet
-
-SPIconnecting
-SPI_prepare
-
-
-
-1997-12-24
-
-
-SPI_prepare(query, nargs, argtypes)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-const char * query
-
-
-
-Query string
-
-
-
-
-
-int nargs
-
-
-
-Number of input parameters ($1 ... $nargs - as in SQL-functions)
-
-
-
-
-
-Oid * argtypes
-
-
-
-Pointer to array of type OIDs for input parameter types
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-void *
-
-
-
-Pointer to an execution plan (parser+planner+optimizer)
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_prepare
- creates and returns an execution plan (parser+planner+optimizer) but doesn't
- execute the query. Should only be called from a connected procedure.
-
-
-
-
-Usage
-
-
- When the same or similar query is to be executed repeatedly, it may
- be advantageous to perform query planning only once.
- SPI_prepare converts a query string into an execution
- plan that can be passed repeatedly to SPI_execp.
-
-
- A prepared query can be generalized by writing parameters ($1, $2, etc)
- in place of what would be constants in a normal query. The values of
- the parameters are then specified when SPI_execp
- is called. This allows the prepared query to be used over a wider
- range of situations than would be possible without parameters.
-
-
-
- However, there is a disadvantage: since the planner does not know the
- values that will be supplied for the parameters, it may make worse
- query planning choices than it would make for a simple query with
- all constants visible.
-
-
-
- If the query uses parameters, their number and data types must be
- specified in the call to SPI_prepare.
-
-
-The plan returned by SPI_prepare may be used only in current
- invocation of the procedure since SPI_finish frees memory allocated for a plan.
- But see SPI_saveplan to save a plan for longer.
-
-
- If successful, a non-null pointer will be returned. Otherwise, you'll get
- a NULL plan. In both cases SPI_result will be set like the value returned
- by SPI_exec, except that it is set to
- SPI_ERROR_ARGUMENT if query is NULL or nargs < 0 or nargs > 0 && argtypes
- is NULL.
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-SPI_execp
-SPI - Plan Execution
-
-
-SPI_execp
-
-
-Executes a plan from SPI_prepare
-
-SPIconnecting
-SPI_execp
-
-
-
-1997-12-24
-
-
-SPI_execp(plan,
-values,
-nulls,
-tcount)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-void *plan
-
-
-
-Execution plan
-
-
-
-
-
-Datum *values
-
-
-
-Actual parameter values
-
-
-
-
-
-const char *nulls
-
-
-
-Array describing which parameters are NULLs
-
-n indicates NULL (values[] entry ignored)
-space indicates not NULL (values[] entry is valid)
-
-
-
-
-
-
-int tcount
-
-
-
-Number of tuples for which plan is to be executed
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-int
-
-
-
- Returns the same value as SPI_exec as well as
-
-
- SPI_ERROR_ARGUMENT
- if plan
- is NULL or tcount < 0
-
-
- SPI_ERROR_PARAM
- if values
- is NULL
- and plan
- was prepared with some parameters.
-
-
-
-
-
-
-SPI_tuptable
-
-
-
-initialized as in
- SPI_exec if successful
-
-
-
-
-SPI_processed
-
-
-
-initialized as in
- SPI_exec if successful
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_execp
- executes a plan prepared by SPI_prepare.
- tcount has the same
- interpretation as in SPI_exec.
-
-
-
-Usage
-
-
- If nulls
-is NULL then
- SPI_execp
-assumes that all parameters (if any) are NOT NULL.
-
-
-
- If one of the objects (a relation, function, etc.) referenced by the prepared
- plan is dropped during your session (by your backend or another process) then the
- results of SPI_execp for this plan will be unpredictable.
-
-
-
-
-
-
-
-
+
+ Description
-
-
-
+
+ SPI_connect opens a connection from a
+ procedure invocation to the SPI manager. You must call this
+ function if you want to execute commands through SPI. Some utility
+ SPI functions may be called from unconnected procedures.
+
-
-
-SPI_cursor_open
-SPI - Cursor Support
-
-
-SPI_cursor_open
-
-
-Sets up a cursor using a plan created with SPI_prepare
-
-SPIcursors
-SPI_cursor_open
-
-
-
-2001-11-14
-
-
-SPI_cursor_open(name,
-plan,
-values,
-nulls)
-
-
-
-
-2001-11-14
-
-Inputs
-
-
-
-
-const char *name
-
-
-
-Name for portal, or NULL to let the system select a name
-
-
-
-
-
-void *plan
-
-
-
-Execution plan
-
-
-
-
-
-Datum *values
-
-
-
-Actual parameter values
-
-
-
-
-
-const char *nulls
-
-
-
-Array describing which parameters are NULLs
-
-n indicates NULL (values[] entry ignored)
-space indicates not NULL (values[] entry is valid)
-
-
-
-
-
-
-
-
-
-2001-11-14
-
-Outputs
-
-
-
-Portal
-
-
-
- Pointer to Portal containing cursor, or NULL on error
-
-
-
-
-
-
-
-
-
-2001-11-14
-
-Description
-
-
-SPI_cursor_open
- sets up a cursor (internally, a Portal) that will execute a plan
- prepared by SPI_prepare.
-
-
+
+ If your procedure is already connected,
+ SPI_connect will return the error code
+ SPI_ERROR_CONNECT. This could happen if
+ a procedure that has called SPI_connect
+ directly calls another procedure that calls
+ SPI_connect. While recursive calls to the
+ SPI manager are permitted when an SQL command
+ called through SPI invokes another function that uses
+ SPI, directly nested calls to
+ SPI_connect and
+ SPI_finish are forbidden.
+
+
+
+
+ Return Value
+
+
+
+ SPI_OK_CONNECT
+
+
+ on success
+
+
+
+
+
+ SPI_ERROR_CONNECT
+
+
+ on error
+
+
+
+
+
+
+
+
+
+
+
+ SPI_finish
+
+
+
+ SPI_finish
+ disconnect a procedure from the SPI manager
+
+
+ SPI_finish
+
+
+
+int SPI_finish(void)
+
+
+
+
+ Description
+
+
+ SPI_finish closes an existing connection to
+ the SPI manager. You must call this function after completing the
+ SPI operations needed during your procedure's current invocation.
+ You do not need to worry about making this happen, however, if you
+ abort the transaction via elog(ERROR). In that
+ case SPI will clean itself up automatically.
+
+
+
+ If SPI_finish is called without having a valid
+ connection, it will return SPI_ERROR_UNCONNECTED.
+ There is no fundamental problem with this; it means that the SPI
+ manager has nothing to do.
+
+
+
+
+ Return Value
+
+
+
+ SPI_OK_FINISH
+
+
+ if properly disconnected
+
+
+
+
+
+ SPI_ERROR_UNCONNECTED
+
+
+ if called from an unconnected procedure
+
+
+
+
+
+
+
+
+
+
+
+ SPI_exec
+
+
+
+ SPI_exec
+ execute a command
+
+
+ SPI_exec
+
+
+
+int SPI_exec(const char * command, int count)
+
+
+
+
+ Description
+
+
+ SPI_exec executes the specified SQL command
+ for count rows.
+
+
+
+ This function should only be called from a connected procedure. If
+ count is zero then it executes the command
+ for all rows that it applies to. If count
+ is greater than 0, then the number of rows for which the command
+ will be executed is restricted (much like a
+ LIMIT clause). For example,
+
+SPI_exec("INSERT INTO tab SELECT * FROM tab", 5);
+
+ will allow at most 5 rows to be inserted into the table.
+
+
+
+ You may pass multiple commands in one string, and the command may
+ be rewritten by rules. SPI_exec returns the
+ result for the command executed last.
+
+
+
+ The actual number of rows for which the (last) command was executed
+ is returned in the global variable SPI_processed
+ (unless the return value of the function is
+ SPI_OK_UTILITY). If the return value of the
+ function is SPI_OK_SELECT then you may the use
+ global pointer SPITupleTable *SPI_tuptable to
+ access the result rows.
+
+
+
+ The structure SPITupleTable is defined
+ thus:
+
+typedef struct
+{
+ MemoryContext tuptabcxt; /* memory context of result table */
+ uint32 alloced; /* number of alloced vals */
+ uint32 free; /* number of free vals */
+ TupleDesc tupdesc; /* row descriptor */
+ HeapTuple *vals; /* rows */
+} SPITupleTable;
+
+ vals> is an array of pointers to rows. (The number
+ of valid entries is given by SPI_processed).
+ tupdesc> is a row descriptor which you may pass to
+ SPI functions dealing with rows. tuptabcxt>,
+ alloced>, and free> are internal
+ fields not intended for use by SPI callers.
+
+
+
+ SPI_finish frees all
+ SPITupleTable>s allocated during the current
+ procedure. You can free a particular result table earlier, if you
+ are done with it, by calling SPI_freetuptable.
+
+
+
+
+ Arguments
+
+
+
+ const char * command
+
+
+ string containing command to execute
+
+
+
+
+
+ int count
+
+
+ maximum number of rows to process or return
+
+
+
+
+
+
+
+ Return Value
+
+
+ If the execution of the command was successful then one of the
+ following (nonnegative) values will be returned:
+
+
+
+ SPI_OK_SELECT
+
+
+ if a SELECT (but not SELECT
+ ... INTO>) was executed
+
+
+
+
+
+ SPI_OK_SELINTO
+
+
+ if a SELECT ... INTO was executed
+
+
+
+
+
+ SPI_OK_DELETE
+
+
+ if a DELETE was executed
+
+
+
+
+
+ SPI_OK_INSERT
+
+
+ if an INSERT was executed
+
+
+
+
+
+ SPI_OK_UPDATE
+
+
+ if an UPDATE was executed
+
+
+
+
+
+ SPI_OK_UTILITY
+
+
+ if a utility command (e.g., CREATE TABLE)
+ was executed
+
+
+
+
+
+
+
+ On error, one of the following negative values is returned:
+
+
+
+ SPI_ERROR_ARGUMENT
+
+
+ if command is NULL or
+ count is less than 0
+
+
+
+
+
+ SPI_ERROR_COPY
+
+
+ if COPY TO stdout> or COPY FROM stdin>
+ was attempted
+
+
+
+
+
+ SPI_ERROR_CURSOR
+
+
+ if DECLARE>, CLOSE>, or FETCH>
+ was attempted
+
+
+
+
+
+ SPI_ERROR_TRANSACTION
+
+
+ if BEGIN>, COMMIT>, or
+ ROLLBACK> was attempted
+
+
+
+
+
+ SPI_ERROR_OPUNKNOWN
+
+
+ if the command type is unknown (shouldn't happen)
+
+
+
+
+
+ SPI_ERROR_UNCONNECTED
+
+
+ if called from an unconnected procedure
+
+
+
+
+
+
+
+
+ Notes
+
+
+ The functions SPI_exec,
+ SPI_execp, and
+ SPI_prepare change both
+ SPI_processed and
+ SPI_tuptable (just the pointer, not the contents
+ of the structure). Save these two global variables into local
+ procedure variables if you need to access the result of
+ SPI_exec or SPI_execp
+ across later calls.
+
+
+
+
+
+
+
+
+ SPI_prepare
+
+
+
+ SPI_prepare
+ prepare a plan for a command, without executing it yet
+
+
+ SPI_prepare
+
+
+
+void * SPI_prepare(const char * command, int nargs, Oid * argtypes)
+
+
+
+
+ Description
+
+
+ SPI_prepare creates and returns an execution
+ plan for the specified command but doesn't execute the command.
+ This function should only be called from a connected procedure.
+
+
+
+ When the same or a similar command is to be executed repeatedly, it
+ may be advantageous to perform the planning only once.
+ SPI_prepare converts a command string into an
+ execution plan that can be executed repeatedly using
+ SPI_execp.
+
+
+
+ A prepared command can be generalized by writing parameters
+ ($1>, $2>, etc.) in place of what would be
+ constants in a normal command. The actual values of the parameters
+ are then specified when SPI_execp is called.
+ This allows the prepared command to be used over a wider range of
+ situations than would be possible without parameters.
+
+
+
+ The plan returned by SPI_prepare can be used
+ only in the current invocation of the procedure since
+ SPI_finish frees memory allocated for a plan.
+ But a plan can be saved for longer using the function
+ SPI_saveplan.
+
+
+
+
+ Arguments
+
+
+
+ const char * command
+
+
+ command string
+
+
+
+
+
+ int nargs
+
+
+ number of input parameters ($1>, $2>, etc.)
+
+
+
+
+
+ Oid * argtypes
+
+
+ pointer to an array containing the OIDs of
+ the data types of the parameters
+
+
+
+
+
+
+
+ Return Value
+
+
+ SPI_prepare returns non-null pointer to an
+ execution plan. On error, NULL will be returned.
+ In both cases, SPI_result will be set analogous
+ to the value returned by SPI_exec, except that
+ it is set to SPI_ERROR_ARGUMENT if
+ command is NULL, or if
+ nargs> is less than 0, or if nargs> is
+ greater than 0 and argtypes> is NULL.
+
+
+
+
+ Notes
+
+
+ There is a disadvantage to using parameters: since the planner does
+ not know the values that will be supplied for the parameters, it
+ may make worse planning choices than it would make for a normal
+ command with all constants visible.
+
+
+
+
+
+
+
+
+ SPI_execp
+
+
+
+ SPI_execp
+ executes a plan prepared by SPI_prepare
+
+
+ SPI_execp
+
+
+
+int SPI_execp(void * plan, Datum * values, const char * nulls, int count)
+
+
+
+
+ Description
+
+
+ SPI_execp executes a plan prepared by
+ SPI_prepare. tcount
+ has the same interpretation as in SPI_exec.
+
+
+
+
+ Arguments
+
+
+
+ void * plan
+
+
+ execution plan (returned by SPI_prepare)
+
+
+
+
+
+ Datum *values
+
+
+ actual parameter values
+
+
+
+
+
+ const char * nulls
+
+
+ An array describing which parameters are null.
+ n indicates a null value (entry in
+ values> will be ignored); a space indicates a
+ nonnull value (entry in values> is valid).
+
+
+
+ If nulls is NULL then
+ SPI_execp assumes that no parameters are
+ null.
+
+
+
+
+
+ int count
+
+
+ number of row for which plan is to be executed
+
+
+
+
+
+
+
+ Return Value
+
+
+ The return value is the same as for SPI_exec
+ or one of the following:
+
+
+
+ SPI_ERROR_ARGUMENT
+
+
+ if plan is NULL or
+ count is less than 0
+
+
+
+
+
+ SPI_ERROR_PARAM
+
+
+ if values is NULL and
+ plan was prepared with some parameters
+
+
+
+
+
+
+
+ SPI_processed and
+ SPI_tuptable are set as in
+ SPI_exec if successful.
+
+
+
+
+ Notes
+
+
+ If one of the objects (a table, function, etc.) referenced by the
+ prepared plan is dropped during the session then the result of
+ SPI_execp for this plan will be unpredictable.
+
+
+
+
+
+
+
+
+ SPI_cursor_open
+
+
+
+ SPI_cursor_open
+ set up a cursor using a plan created with SPI_prepare
+
+
+ SPI_cursor_open
+
+
+
+Portal SPI_cursor_open(const char * name, void * plan, Datum * values, const char * nulls)
+
+
+
+
+ Description
+
+
+ SPI_cursor_open sets up a cursor (internally,
+ a portal) that will execute a plan prepared by
+ SPI_prepare.
+
+
+
Using a cursor instead of executing the plan directly has two
benefits. First, the result rows can be retrieved a few at a time,
avoiding memory overrun for queries that return many rows. Second,
- a Portal can outlive the current procedure (it can, in fact, live to
- the end of the current transaction). Returning the portal name to
- the procedure's caller provides a way of returning a rowset result.
-
-
-
-Usage
-
-
- If nulls
-is NULL then
- SPI_cursor_open
-assumes that all parameters (if any) are NOT NULL.
-
-
-
-
-
-
-
-
-
-
-
-SPI_cursor_find
-SPI - Cursor Support
-
-
-SPI_cursor_find
-
-
-Finds an existing cursor (Portal) by name
-
-SPIcursors
-SPI_cursor_find
-
-
-
-2001-11-14
-
-
-SPI_cursor_find(name)
-
-
-
-
-2001-11-14
-
-Inputs
-
-
-
-
-const char *name
-
-
-
-Name of portal
-
-
-
-
-
-
-
-
-2001-11-14
-
-Outputs
-
-
-
-Portal
-
-
-
- Pointer to Portal with given name, or NULL if not found
-
-
-
-
-
-
-
-
-
-2001-11-14
-
-Description
-
-
-SPI_cursor_find
- finds a pre-existing Portal by name. This is primarily useful
- to resolve a cursor name returned as text by some other function.
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_cursor_fetch
-SPI - Cursor Support
-
-
-SPI_cursor_fetch
-
-
-Fetches some rows from a cursor
-
-SPIcursors
-SPI_cursor_fetch
-
-
-
-2001-11-14
-
-
-SPI_cursor_fetch(portal,
-forward,
-count)
-
-
-
-
-2001-11-14
-
-Inputs
-
-
-
-
-Portal portal
-
-
-
-Portal containing cursor
-
-
-
-
-
-bool forward
-
-
-
-True for fetch forward, false for fetch backward
-
-
-
-
-
-int count
-
-
-
-Maximum number of rows to fetch
-
-
-
-
-
-
-
-
-2001-11-14
-
-Outputs
-
-
-
-SPI_tuptable
-
-
-
-initialized as in
- SPI_exec if successful
-
-
-
-
-SPI_processed
-
-
-
-initialized as in
- SPI_exec if successful
-
-
-
-
-
-
-
-
-
-2001-11-14
-
-Description
-
-
-SPI_cursor_fetch
- fetches some (more) rows from a cursor. This is equivalent to the
- SQL command FETCH>.
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_cursor_move
-SPI - Cursor Support
-
-
-SPI_cursor_move
-
-
-Moves a cursor
-
-SPIcursors
-SPI_cursor_move
-
-
-
-2001-11-14
-
-
-SPI_cursor_move(portal,
-forward,
-count)
-
-
-
-
-2001-11-14
-
-Inputs
-
-
-
-
-Portal portal
-
-
-
-Portal containing cursor
-
-
-
-
-
-bool forward
-
-
-
-True for move forward, false for move backward
-
-
-
-
-
-int count
-
-
-
-Maximum number of rows to move
-
-
-
-
-
-
-
-
-2001-11-14
-
-Outputs
-
-
-
-None
-
-
-
-
-
-
-
-
-
-
-
-
-2001-11-14
-
-Description
-
-
-SPI_cursor_move
- skips over some number of rows in a cursor. This is equivalent to the
- SQL command MOVE>.
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_cursor_close
-SPI - Cursor Support
-
-
-SPI_cursor_close
-
-
-Closes a cursor
-
-SPIcursors
-SPI_cursor_close
-
-
-
-2001-11-14
-
-
-SPI_cursor_close(portal)
-
-
-
-
-2001-11-14
-
-Inputs
-
-
-
-
-Portal portal
-
-
-
-Portal containing cursor
-
-
-
-
-
-
-
-
-2001-11-14
-
-Outputs
-
-
-
-None
-
-
-
-
-
-
-
-
-
-
-
-
-2001-11-14
-
-Description
-
-
-SPI_cursor_close
- closes a previously created cursor and releases its Portal storage.
-
-
-
-Usage
-
-
- All open cursors are closed implicitly at transaction end.
- SPI_cursor_close need only be invoked if
- it is desirable to release resources sooner.
-
-
-
-
-
-
-
-
-
-
-
-SPI_saveplan
-SPI - Plan Storage
-
-
-SPI_saveplan
-
-
- Saves a passed plan
-
-SPIconnecting
-SPI_saveplan
-
-
-
-1997-12-24
-
-
-SPI_saveplan(plan)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-void *query
-
-
-
-Passed plan
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-void *
-
-
-
-Execution plan location. NULL if unsuccessful.
-
-
-
-
-SPI_result
-
-
-
-
-
- SPI_ERROR_ARGUMENT if plan is NULL
-
-
- SPI_ERROR_UNCONNECTED if procedure is un-connected
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_saveplan
- stores a plan prepared by SPI_prepare in safe memory
- protected from freeing by SPI_finish or the transaction manager.
-
-
- In the current version of PostgreSQL there is no ability to
- store prepared plans in the system
- catalog and fetch them from there for execution. This will be implemented
- in future versions.
-
- As an alternative, there is the ability to reuse prepared plans in the
- subsequent invocations of your procedure in the current session.
- Use SPI_execp to execute this saved plan.
-
-
-
-Usage
-
-
- SPI_saveplan saves a passed plan (prepared by SPI_prepare) in memory
- protected from freeing by SPI_finish and by the transaction manager and
- returns a pointer to the saved plan. You may save the pointer returned in
- a local variable. Always check if this pointer is NULL or not either when
- preparing a plan or using an already prepared plan in SPI_execp (see below).
-
-
-
- If one of the objects (a relation, function, etc.) referenced by the prepared
- plan is dropped during your session (by your backend or another process) then the
- results of SPI_execp for this plan will be unpredictable.
-
-
-
-
-
-
-
-
-
-
-
-
-Interface Support Functions
-
-
-The functions described here provide convenient interfaces for extracting
-information from tuple sets returned by SPI_exec> and other
-SPI interface functions.
-
-
-
-All functions described in this section may be used by both connected and
-unconnected procedures.
-
-
-
-
-
-
-
-
-SPI_fnumber
-SPI - Tuple Information
-
-
-SPI_fnumber
-
-
-Finds the attribute number for specified attribute name
-
-SPIdecoding tuples
-SPI_fnumber
-
-
-
-1997-12-24
-
-
-SPI_fnumber(tupdesc, fname)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-TupleDesc tupdesc
-
-
-
-Input tuple description
-
-
-
-
-
-const char * fname
-
-
-
-Field name
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-int
-
-
-
-Attribute number
-
-
-Valid one-based index number of attribute
-
-
-SPI_ERROR_NOATTRIBUTE if the named attribute is not found
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_fnumber
- returns the attribute number for the attribute with name in fname.
-
-
-
-Usage
-
-
-Attribute numbers are 1 based.
-
-
-If the given fname refers to a system attribute (eg, oid>)
-then the appropriate negative attribute number will be returned.
-The caller should be careful to test for exact equality to
-SPI_ERROR_NOATTRIBUTE to detect error;
-testing for result <= 0 is not correct unless system attributes
-should be rejected.
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_fname
-SPI - Tuple Information
-
-
-SPI_fname
-
-
-Finds the attribute name for the specified attribute number
-
-SPIdecoding tuples
-SPI_fname
-
-
-
-1997-12-24
-
-
-SPI_fname(tupdesc, fnumber)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-TupleDesc tupdesc
-
-
-
-Input tuple description
-
-
-
-
-
-int fnumber
-
-
-
-Attribute number
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-char *
-
-
-
-Attribute name
-
-
-NULL if fnumber is out of range
-
-
-SPI_result set to
-SPI_ERROR_NOATTRIBUTE on error
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_fname
- returns the attribute name for the specified attribute.
-
-
-
-Usage
-
-
-Attribute numbers are 1 based.
-
-
-
-Algorithm
-
-
-Returns a newly-allocated copy of the attribute name.
-(Use pfree() to release the copy when done with it.)
-
-
-
-
-
-
-
-
-
-
-
-SPI_getvalue
-SPI - Tuple Information
-
-
-SPI_getvalue
-
-
-Returns the string value of the specified attribute
-
-SPIdecoding tuples
-SPI_getvalue
-
-
-
-1997-12-24
-
-
-SPI_getvalue(tuple, tupdesc, fnumber)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-HeapTuple tuple
-
-
-
-Input tuple to be examined
-
-
-
-
-
-TupleDesc tupdesc
-
-
-
-Input tuple description
-
-
-
-
-
-int fnumber
-
-
-
-Attribute number
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-char *
-
-
-
-Attribute value or NULL if
-
-
-attribute is NULL
-
-
-fnumber is out of range
-(SPI_result set to
-SPI_ERROR_NOATTRIBUTE)
-
-
-no output function available
-(SPI_result set to
-SPI_ERROR_NOOUTFUNC)
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_getvalue
- returns an external (string) representation of the value of the specified attribute.
-
-
-
-Usage
-
-
-Attribute numbers are 1 based.
-
-
-
-Algorithm
-
-
-The result is returned as a palloc'd string.
-(Use pfree() to release the string when done with it.)
-
-
-
-
-
-
-
-
-
-
-
-SPI_getbinval
-SPI - Tuple Information
-
-
-SPI_getbinval
-
-
-Returns the binary value of the specified attribute
-
-SPIdecoding tuples
-SPI_getbinval
-
-
-
-1997-12-24
-
-
-SPI_getbinval(tuple, tupdesc, fnumber, isnull)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-HeapTuple tuple
-
-
-
-Input tuple to be examined
-
-
-
-
-
-TupleDesc tupdesc
-
-
-
-Input tuple description
-
-
-
-
-
-int fnumber
-
-
-
-Attribute number
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-Datum
-
-
-
-Attribute binary value
-
-
-
-
-
-bool * isnull
-
-
-
-flag for null value in attribute
-
-
-
-
-
-SPI_result
-
-
-
-
-
-SPI_ERROR_NOATTRIBUTE
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_getbinval
- returns the specified attribute's value in internal form (as a Datum).
-
-
-
-Usage
-
-
-Attribute numbers are 1 based.
-
-
-
-Algorithm
-
-
-Does not allocate new space for the datum. In the case of a pass-by-
-reference data type, the Datum will be a pointer into the given tuple.
-
-
-
-
-
-
-
-
-
-
-
-SPI_gettype
-SPI - Tuple Information
-
-
-SPI_gettype
-
-
-Returns the type name of the specified attribute
-
-SPIdecoding tuples
-SPI_gettype
-
-
-
-1997-12-24
-
-
-SPI_gettype(tupdesc, fnumber)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-TupleDesc tupdesc
-
-
-
-Input tuple description
-
-
-
-
-
-int fnumber
-
-
-
-Attribute number
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-char *
-
-
-
-The type name for the specified attribute number
-
-
-
-
-
-SPI_result
-
-
-
-
-
-SPI_ERROR_NOATTRIBUTE
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_gettype
- returns a copy of the type name for the specified attribute,
- or NULL on error.
-
-
-
-Usage
-
-
-Attribute numbers are 1 based.
-
-
-
-Algorithm
-
-
-Returns a newly-allocated copy of the type name.
-(Use pfree() to release the copy when done with it.)
-
-
-
-
-
-
-
-
-
-
-
-SPI_gettypeid
-SPI - Tuple Information
-
-
-SPI_gettypeid
-
-
-Returns the type OID of the specified attribute
-
-SPIdecoding tuples
-SPI_gettypeid
-
-
-
-1997-12-24
-
-
-SPI_gettypeid(tupdesc, fnumber)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-TupleDesc tupdesc
-
-
-
-Input tuple description
-
-
-
-
-
-int fnumber
-
-
-
-Attribute number
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-OID
-
-
-
-The type OID for the specified attribute number
-
-
-
-
-
-SPI_result
-
-
-
-
-
-SPI_ERROR_NOATTRIBUTE
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_gettypeid
- returns the type OID for the specified attribute.
-
-
-
-Usage
-
-
-Attribute numbers are 1 based.
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_getrelname
-SPI - Tuple Information
-
-
-SPI_getrelname
-
-
-Returns the name of the specified relation
-
-SPIdecoding tuples
-SPI_getrelname
-
-
-
-1997-12-24
-
-
-SPI_getrelname(rel)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-Relation rel
-
-
-
-Input relation
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-char *
-
-
-
-The name of the specified relation
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_getrelname
- returns the name of the specified relation.
-
-
-
-
-Algorithm
-
-
-Returns a newly-allocated copy of the rel name.
-(Use pfree() to release the copy when done with it.)
-
-
-
-
-
-
-
-
-Memory Management
-
-
-PostgreSQL allocates memory within memory
-contexts, which provide a convenient method of
-managing allocations made in many different places that need to live
-for differing amounts of time. Destroying a context releases all the
-memory that was allocated in it. Thus, it is not necessary to keep track
-of individual objects to avoid memory leaks --- only a relatively small number
-of contexts have to be managed. palloc and related
-functions allocate memory from the current> context.
-
-
-SPI_connect creates a new memory context and makes
-it current. SPI_finish restores the previous
-current memory context and destroys the context created by
-SPI_connect. These actions ensure that transient
-memory allocations made inside your procedure are reclaimed at procedure
-exit, avoiding memory leakage.
-
-
-However, if your procedure needs to return an allocated memory object
-(such as a value of a pass-by-reference data type), you can't allocate
-the return object using palloc, at least not while
-you are connected to SPI. If you try, the object will be deallocated
-during SPI_finish, and your procedure will not
-work reliably!
-
-
-To solve this problem, use SPI_palloc to allocate
-your return object. SPI_palloc allocates space
-from upper Executor> memory --- that is, the memory context
-that was current when SPI_connect was called,
-which is precisely the right context for return values of your procedure.
-
-
-If called while not connected to SPI, SPI_palloc
-acts the same as plain palloc.
-
-
- Before a procedure connects to the SPI manager, the current memory context
-is the upper Executor context, so all allocations made by the procedure via
-palloc or by SPI utility functions are
-made in this context.
-
-
- After SPI_connect is called, the current context is
- the procedure's private context made by SPI_connect.
- All allocations made via
-palloc/repalloc or by SPI utility
-functions (except for SPI_copytuple,
-SPI_copytupledesc,
-SPI_copytupleintoslot,
-SPI_modifytuple,
-and SPI_palloc) are
-made in this context.
-
-
-When a procedure disconnects from the SPI manager (via
-SPI_finish) the
-current context is restored to the upper Executor context, and all allocations
-made in the procedure memory context are freed and can't be used any more!
-
-
-
-All functions described in this section may be used by both connected and
-unconnected procedures. In an unconnected procedure, they act the same
-as the underlying ordinary backend functions (palloc> etc).
-
-
-
-
-
-
-
-
-SPI_copytuple
-SPI - Tuple Copy
-
-
-SPI_copytuple
-
-
-Makes copy of tuple in upper Executor context
-
-SPIcopying tuples
-SPI_copytuple
-
-
-
-1997-12-24
-
-
-SPI_copytuple(tuple)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-HeapTuple tuple
-
-
-
-Input tuple to be copied
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-HeapTuple
-
-
-
-Copied tuple
-
-
- non-NULL
- if tuple
- is not NULL and the copy was successful
-
-
- NULL
- only if tuple
- is NULL
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_copytuple
- makes a copy of tuple in upper Executor context.
-
-
-
-Usage
-
-
-TBD
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_copytupledesc
-SPI - Tuple Descriptor Copy
-
-
-SPI_copytupledesc
-
-
-Makes copy of tuple descriptor in upper Executor context
-
-SPIcopying tuple descriptors
-SPI_copytupledesc
-
-
-
-2001-08-02
-
-
-SPI_copytupledesc(tupdesc)
-
-
-
-
-2001-08-02
-
-Inputs
-
-
-
-
-TupleDesc tupdesc
-
-
-
-Input tuple descriptor to be copied
-
-
-
-
-
-
-
-
-2001-08-02
-
-Outputs
-
-
-
-
-TupleDesc
-
-
-
-Copied tuple descriptor
-
-
- non-NULL
- if tupdesc
- is not NULL and the copy was successful
-
-
- NULL
- only if tupdesc
- is NULL
-
-
-
-
-
-
-
-
-
-
-
-2001-08-02
-
-Description
-
-
-SPI_copytupledesc
- makes a copy of tupdesc in upper Executor context.
-
-
-
-Usage
-
-
-TBD
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_copytupleintoslot
-SPI - Tuple and Descriptor Copy
-
-
-SPI_copytupleintoslot
-
-
-Makes copy of tuple and descriptor in upper Executor context
-
-SPIcopying tuples
-SPI_copytupleintoslot
-
-
-
-1997-12-24
-
-
-SPI_copytupleintoslot(tuple, tupdesc)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-HeapTuple tuple
-
-
-
-Input tuple to be copied
-
-
-
-
-
-TupleDesc tupdesc
-
-
-
-Input tuple descriptor to be copied
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-TupleTableSlot *
-
-
-
-Tuple slot containing copied tuple and descriptor
-
-
- non-NULL
- if tuple
- and tupdesc
- are not NULL and the copy was successful
-
-
- NULL
- only if tuple
- or tupdesc
- is NULL
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_copytupleintoslot
- makes a copy of tuple in upper Executor context, returning it in the
- form of a filled-in TupleTableSlot.
-
-
-
-Usage
-
-
-TBD
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_modifytuple
-SPI - Tuple Modify
-
-
-SPI_modifytuple
-
-
-Creates a tuple by replacing selected fields of a given tuple
-
-SPImodifying tuples
-SPI_modifytuple
-
-
-
-1997-12-24
-
-
-SPI_modifytuple(rel, tuple, nattrs, attnum, Values, Nulls)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-Relation rel
-
-
-
-Used only as source of tuple descriptor for tuple. (Passing a relation
-rather than a tuple descriptor is a misfeature.)
-
-
-
-
-
-HeapTuple tuple
-
-
-
-Input tuple to be modified
-
-
-
-
-
-int nattrs
-
-
-
-Number of attribute numbers in attnum array
-
-
-
-
-
-int * attnum
-
-
-
-Array of numbers of the attributes that are to be changed
-
-
-
-
-
-Datum * Values
-
-
-
-New values for the attributes specified
-
-
-
-
-
-const char * Nulls
-
-
-
-Which new values are NULL, if any
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-HeapTuple
-
-
-
-New tuple with modifications
-
-
- non-NULL
- if tuple
- is not NULL and the modify was successful
-
-
- NULL
- only if tuple
- is NULL
-
-
-
-
-
-
-
-SPI_result
-
-
-
-
-
- SPI_ERROR_ARGUMENT if rel is NULL or tuple is NULL or natts <= 0 or
- attnum is NULL or Values is NULL.
-
-
- SPI_ERROR_NOATTRIBUTE if there is an invalid
- attribute number in attnum (attnum <= 0 or > number of
- attributes in tuple)
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_modifytuple
-creates a new tuple by substituting new values for selected attributes,
-copying the original tuple's attributes at other positions. The input
-tuple is not modified.
-
-
-
-Usage
-
-
-If successful, a pointer to the new tuple is returned. The new tuple is
-allocated in upper Executor context.
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_palloc
-SPI - Memory Management
-
-
-SPI_palloc
-
-
-Allocates memory in upper Executor context
-
-SPIallocating space
-SPI_palloc
-
-
-
-1997-12-24
-
-
-SPI_palloc(size)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-Size size
-
-
-
-Octet size of storage to allocate
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-void *
-
-
-
-New storage space of specified size
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_palloc
- allocates memory in upper Executor context.
-
-
-
-Usage
-
-
-TBD
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_repalloc
-SPI - Memory Management
-
-
-SPI_repalloc
-
-
-Re-allocates memory in upper Executor context
-
-SPIallocating space
-SPI_repalloc
-
-
-
-1997-12-24
-
-
-SPI_repalloc(pointer, size)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-void * pointer
-
-
-
-Pointer to existing storage
-
-
-
-
-
-Size size
-
-
-
-Octet size of storage to allocate
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-void *
-
-
-
-New storage space of specified size with contents copied from existing area
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_repalloc
- re-allocates memory in upper Executor context.
-
-
-
-Usage
-
-
-This function is no longer different from plain repalloc.
-It's kept just for backward compatibility of existing code.
-
-
-
-
-
-
-
-
-
-
-
-
-SPI_pfree
-SPI - Memory Management
-
-
-SPI_pfree
-
-
-Frees memory in upper Executor context
-
-SPIallocating space
-SPI_pfree
-
-
-
-1997-12-24
-
-
-SPI_pfree(pointer)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-void * pointer
-
-
-
-Pointer to existing storage
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-None
-
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_pfree
- frees memory in upper Executor context.
-
-
-
-Usage
-
-
-This function is no longer different from plain pfree.
-It's kept just for backward compatibility of existing code.
-
-
-
-
-
-
-
-
-
-
-SPI_freetuple
-SPI - Memory Management
-
-
-SPI_freetuple
-
-
-Frees a tuple allocated in upper Executor context
-
-SPIallocating space
-SPI_freetuple
-
-
-
-1997-12-24
-
-
-SPI_freetuple(pointer)
-
-
-
-
-1997-12-24
-
-Inputs
-
-
-
-
-HeapTuple pointer
-
-
-
-Pointer to allocated tuple
-
-
-
-
-
-
-
-
-1997-12-24
-
-Outputs
-
-
-
-
-None
-
-
-
-
-
-
-
-
-
-
-
-
-1997-12-24
-
-Description
-
-
-SPI_freetuple
- frees a tuple previously allocated in upper Executor context.
-
-
-
-Usage
-
-
-This function is no longer different from plain heap_freetuple.
-It's kept just for backward compatibility of existing code.
-
-
-
-
-
-
-
-
-
-
-SPI_freetuptable
-SPI - Memory Management
-
-
-SPI_freetuptable
-
-
-Frees a tuple set created by SPI_exec> or similar function
-
-SPIallocating space
-SPI_freetuptable
-
-
-
-2001-11-14
-
-
-SPI_freetuptable(tuptable)
-
-
-
-
-2001-11-14
-
-Inputs
-
-
-
-
-SPITupleTable * tuptable
-
-
-
-Pointer to tuple table
-
-
-
-
-
-
-
-
-2001-11-14
-
-Outputs
-
-
-
-
-None
-
-
-
-
-
-
-
-
-
-
-
-
-2001-11-14
-
-Description
-
-
-SPI_freetuptable
- frees a tuple set created by a prior SPI query function, such as
- SPI_exec>.
-
-
-
-Usage
-
-
-This function is useful if a SPI procedure needs to execute multiple
-queries and does not want to keep the results of earlier queries around
-until it ends. Note that any unfreed tuple sets will be freed anyway
-at SPI_finish>.
-
-
-
-
-
-
-
-
-
-
-SPI_freeplan
-SPI - Memory Management
-
-
-SPI_freeplan
-
-
- Releases a previously saved plan
-
-SPIallocating space
-SPI_freeplan
-
-
-
-2001-11-14
-
-
-SPI_freeplan(plan)
-
-
-
-
-2001-11-14
-
-Inputs
-
-
-
-
-void *plan
-
-
-
-Passed plan
-
-
-
-
-
-
-
-
-2001-11-14
-
-Outputs
-
-
-
-int
-
-
-
-
-
- SPI_ERROR_ARGUMENT if plan is NULL
-
-
-
-
-
-
-
-
-
-
-
-2001-11-14
-
-Description
-
-
-SPI_freeplan
- releases a query plan previously returned by
- SPI_prepare or saved by
- SPI_saveplan.
-
-
-
-
-
-
-
-Visibility of Data Changes
-
-
-PostgreSQL data changes visibility rule: during a query execution, data
-changes made by the query itself (via SQL-function, SPI-function, triggers)
-are invisible to the query scan. For example, in query
+ a portal can outlive the current procedure (it can, in fact, live
+ to the end of the current transaction). Returning the portal name
+ to the procedure's caller provides a way of returning a row set as
+ result.
+
+
+
+
+ Arguments
+
+
+
+ const char * name
+
+
+ name for portal, or NULL to let the system
+ select a name
+
+
+
+
+
+ void * plan
+
+
+ execution plan (returned by SPI_prepare)
+
+
+
+
+
+ Datum * values
+
+
+ actual parameter values
+
+
+
+
+
+ const char *nulls
+
+
+ An array describing which parameters are null values.
+ n indicates a null value (entry in
+ values> will be ignored); a space indicates a
+ nonnull value (entry in values> is valid). If
+ nulls is NULL> then
+ SPI_cursor_open assumes that no parameters
+ are null.
+
+
+
+
+
+
+
+ Return Value
+
+
+ pointer to portal containing the cursor, or NULL
+ on error
+
+
+
+
+
+
+
+
+ SPI_cursor_find
+
+
+
+ SPI_cursor_find
+ find an existing cursor by name
+
+
+ SPI_cursor_find
+
+
+
+Portal SPI_cursor_find(const char * name)
+
+
+
+
+ Description
+
+
+ SPI_cursor_find finds an existing portal by
+ name. This is primarily useful to resolve a cursor name returned
+ as text by some other function.
+
+
+
+
+ Arguments
+
+
+
+ const char * name
+
+
+ name of the portal
+
+
+
+
+
+
+
+ Return Value
+
+
+ pointer to the portal with the specified name, or
+ NULL if none was found
+
+
+
+
+
+
+
+
+ SPI_cursor_fetch
+
+
+
+ SPI_cursor_fetch
+ fetch some rows from a cursor
+
+
+ SPI_cursor_fetch
+
+
+
+void SPI_cursor_fetch(Portal portal, bool forward, int count)
+
+
+
+
+ Description
+
+
+ SPI_cursor_fetch fetches some rows from a
+ cursor. This is equivalent to the SQL command FETCH>.
+
+
+
+
+ Arguments
+
+
+
+ Portal portal
+
+
+ portal containing the cursor
+
+
+
+
+
+ bool forward
+
+
+ true for fetch forward, false for fetch backward
+
+
+
+
+
+ int count
+
+
+ maximum number of rows to fetch
+
+
+
+
+
+
+
+ Return Value
+
+
+ SPI_processed and
+ SPI_tuptable are set as in
+ SPI_exec if successful.
+
+
+
+
+
+
+
+
+ SPI_cursor_move
+
+
+
+ SPI_cursor_move
+ move a cursor
+
+
+ SPI_cursor_move
+
+
+
+void SPI_cursor_move(Portal portal, bool forward, int count)
+
+
+
+
+ Description
+
+
+ SPI_cursor_move skips over some number of rows
+ in a cursor. This is equivalent to the SQL command
+ MOVE>.
+
+
+
+
+ Arguments
+
+
+
+ Portal portal
+
+
+ portal containing the cursor
+
+
+
+
+
+ bool forward
+
+
+ true for move forward, false for move backward
+
+
+
+
+
+ int count
+
+
+ maximum number of rows to move
+
+
+
+
+
+
+
+
+
+
+
+ SPI_cursor_close
+
+
+
+ SPI_cursor_close
+ close a cursor
+
+
+ SPI_cursor_close
+
+
+
+void SPI_cursor_close(Portal portal)
+
+
+
+
+ Description
+
+
+ SPI_cursor_close closes a previously created
+ cursor and releases its portal storage.
+
+
+
+ All open cursors are closed automatically at the end of a
+ transaction. SPI_cursor_close need only be
+ invoked if it is desirable to release resources sooner.
+
+
+
+
+ Arguments
+
+
+
+ Portal portal
+
+
+ portal containing the cursor
+
+
+
+
+
+
+
+
+
+
+
+ SPI_saveplan
+
+
+
+ SPI_saveplan
+ save a plan
+
+
+ SPI_saveplan
+
+
+
+void * SPI_saveplan(void * plan)
+
+
+
+
+ Description
+
+
+ SPI_saveplan saves a passed plan (prepared by
+ SPI_prepare) in memory protected from freeing
+ by SPI_finish and by the transaction manager
+ and returns a pointer to the saved plan. This gives you the
+ ability to reuse prepared plans in the subsequent invocations of
+ your procedure in the current session. You may save the pointer
+ returned in a local variable. Always check if this pointer is
+ NULL or not either when preparing a plan or using
+ an already prepared plan in SPI_execp.
+
+
+
+
+ Arguments
+
+
+
+ void * plan
+
+
+ the plan to be saved
+
+
+
+
+
+
+
+ Return Value
+
+
+ Pointer to the saved plan; NULL if unsuccessful.
+ On error, SPI_result is set thus:
+
+
+
+ SPI_ERROR_ARGUMENT
+
+
+ if plan is NULL
+
+
+
+
+
+ SPI_ERROR_UNCONNECTED
+
+
+ if called from an unconnected procedure
+
+
+
+
+
+
+
+
+ Notes
+
+
+ If one of the objects (a table, function, etc.) referenced by the
+ prepared plan is dropped during the session then the results of
+ SPI_execp for this plan will be unpredictable.
+
+
+
+
+
+
+
+ Interface Support Functions
+
+
+ The functions described here provide an interface for extracting
+ information from result sets returned by SPI_exec> and
+ other SPI functions.
+
+
+
+ All functions described in this section may be used by both
+ connected and unconnected procedures.
+
+
+
+
+
+
+ SPI_fname
+
+
+
+ SPI_fname
+ determine the column name for the specified column number
+
+
+ SPI_fname
+
+
+
+char * SPI_fname(TupleDesc rowdesc, int colnumber)
+
+
+
+
+ Description
+
+
+ SPI_fname returns the column name of the
+ specified column. (You can use pfree to
+ release the copy of the name when you don't need it anymore.)
+
+
+
+
+ Arguments
+
+
+
+ TupleDesc rowdesc
+
+
+ input row description
+
+
+
+
+
+ int colnumber
+
+
+ column number (count starts at 1)
+
+
+
+
+
+
+
+ Return Value
+
+
+ The column name; NULL if
+ colnumber is out of range.
+ SPI_result set to
+ SPI_ERROR_NOATTRIBUTE on error.
+
+
+
+
+
+
+
+
+ SPI_fnumber
+
+
+
+ SPI_fnumber
+ determine the column number for the specified column name
+
+
+ SPI_fnumber
+
+
+
+int SPI_fnumber(TupleDesc rowdesc, const char * colname)
+
+
+
+
+ Description
+
+
+ SPI_fnumber returns the column number for the
+ column with the specified name.
+
+
+
+ If colname refers to a system column (e.g.,
+ oid>) then the appropriate negative column number will
+ be returned. The caller should be careful to test the return value
+ for exact equality to SPI_ERROR_NOATTRIBUTE to
+ detect an error; testing the result for less than or equal to 0 is
+ not correct unless system columns should be rejected.
+
+
+
+
+ Arguments
+
+
+
+ TupleDesc rowdesc
+
+
+ input row description
+
+
+
+
+
+ const char * colname
+
+
+ column name
+
+
+
+
+
+
+
+ Return Value
+
+
+ Column number (count starts at 1), or
+ SPI_ERROR_NOATTRIBUTE if the named column was not
+ found.
+
+
+
+
+
+
+
+
+ SPI_getvalue
+
+
+
+ SPI_getvalue
+ return the string value of the specified column
+
+
+ SPI_getvalue
+
+
+
+char * SPI_getvalue(HeapTuple row, TupleDesc rowdesc, int colnumber)
+
+
+
+
+ Description
+
+
+ SPI_getvalue returns the string representation
+ of the value of the specified column.
+
+
+
+ The result is returned in memory allocated using
+ palloc. (You can use
+ pfree to release the memory when you don't
+ need it anymore.)
+
+
+
+
+ Arguments
+
+
+
+ HeapTuple row
+
+
+ input row to be examined
+
+
+
+
+
+ TupleDesc rowdesc
+
+
+ input row description
+
+
+
+
+
+ int colnumber
+
+
+ column number (count starts at 1)
+
+
+
+
+
+
+
+ Return Value
+
+
+ Column value, or NULL if the column is null,
+ colnumber is out of range
+ (SPI_result is set to
+ SPI_ERROR_NOATTRIBUTE), or no no output function
+ available (SPI_result is set to
+ SPI_ERROR_NOOUTFUNC).
+
+
+
+
+
+
+
+
+ SPI_getbinval
+
+
+
+ SPI_getbinval
+ return the binary value of the specified column
+
+
+ SPI_getbinval
+
+
+
+Datum SPI_getbinval(HeapTuple row, TupleDesc rowdesc, int colnumber, bool * isnull)
+
+
+
+
+ Description
+
+
+ SPI_getbinval returns the value of the
+ specified column in the internal form (as type Datum).
+
+
+
+ This function does not allocate new space for the datum. In the
+ case of a pass-by-reference data type, the return value will be a
+ pointer into the passed row.
+
+
+
+
+ Arguments
+
+
+
+ HeapTuple row
+
+
+ input row to be examined
+
+
+
+
+
+ TupleDesc rowdesc
+
+
+ input row description
+
+
+
+
+
+ int rownumber
+
+
+ column number (count starts at 1)
+
+
+
+
+
+ bool * isnull
+
+
+ flag for a null value in the column
+
+
+
+
+
+
+
+ Return Value
+
+
+ The binary value of the column is returned. The variable pointed
+ to by isnull is set to true if the column is
+ null, else to false.
+
+
+
+ SPI_result is set to
+ SPI_ERROR_NOATTRIBUTE on error.
+
+
+
+
+
+
+
+
+ SPI_gettype
+
+
+
+ SPI_gettype
+ return the data type name of the specified column
+
+
+ SPI_gettype
+
+
+
+char * SPI_gettype(TupleDesc rowdesc, int colnumber)
+
+
+
+
+ Description
+
+
+ SPI_gettype returns the data type name of the
+ specified column. (You can use pfree to
+ release the copy of the name when you don't need it anymore.)
+
+
+
+
+ Arguments
+
+
+
+ TupleDesc rowdesc
+
+
+ input row description
+
+
+
+
+
+ int colnumber
+
+
+ column number (count starts at 1)
+
+
+
+
+
+
+
+ Return Value
+
+
+ The data type name of the specified column, or
+ NULL on error. SPI_result is
+ set to SPI_ERROR_NOATTRIBUTE on error.
+
+
+
+
+
+
+
+
+ SPI_gettypeid
+
+
+
+ SPI_gettypeid
+ return the data type OID of the specified column
+
+
+ SPI_gettypeid
+
+
+
+Oid SPI_gettypeid(TupleDesc rowdesc, int colnumber)
+
+
+
+
+ Description
+
+
+ SPI_gettypeid returns the
+ OID of the data type of the specified column.
+
+
+
+
+ Arguments
+
+
+
+ TupleDesc rowdesc
+
+
+ input row description
+
+
+
+
+
+ int colnumber
+
+
+ column number (count starts at 1)
+
+
+
+
+
+
+
+ Return Value
+
+
+ The OID of the data type of the specified column
+ or InvalidOid on error. On error,
+ SPI_result is set to
+ SPI_ERROR_NOATTRIBUTE.
+
+
+
+
+
+
+
+
+ SPI_getrelname
+
+
+
+ SPI_getrelname
+ return the name of the specified relation
+
+
+ SPI_getrelname
+
+
+
+char * SPI_getrelname(Relation rel)
+
+
+
+
+ Description
+
+
+ SPI_getrelname returns the name of the
+ specified relation. (You can use pfree to
+ release the copy of the name when you don't need it anymore.)
+
+
+
+
+ Arguments
+
+
+
+ Relation rel
+
+
+ input relation
+
+
+
+
+
+
+
+ Return Value
+
+
+ The name of the specified relation.
+
+
+
+
+
+
+
+ Memory Management
+
+
+ PostgreSQL allocates memory within
+ memory contextsmemory
+ contextin SPI, which provide a convenient method of
+ managing allocations made in many different places that need to
+ live for differing amounts of time. Destroying a context releases
+ all the memory that was allocated in it. Thus, it is not necessary
+ to keep track of individual objects to avoid memory leaks; instead
+ only a relatively small number of contexts have to be managed.
+ palloc and related functions allocate memory
+ from the current> context.
+
+
+
+ SPI_connect creates a new memory context and
+ makes it current. SPI_finish restores the
+ previous current memory context and destroys the context created by
+ SPI_connect. These actions ensure that
+ transient memory allocations made inside your procedure are
+ reclaimed at procedure exit, avoiding memory leakage.
+
+
+
+ However, if your procedure needs to return an object in allocated
+ memory (such as a value of a pass-by-reference data type), you
+ cannot allocate that memory using palloc, at
+ least not while you are connected to SPI. If you try, the object
+ will be deallocated by SPI_finish, and your
+ procedure will not work reliably. To solve this problem, use
+ SPI_palloc to allocate memory for your return
+ object. SPI_palloc allocates memory in the
+ upper executor context, that is, the memory context
+ that was current when SPI_connect was called,
+ which is precisely the right context for return a value from your
+ procedure.
+
+
+
+ If SPI_palloc is called while the procedure is
+ not connected to SPI, then it acts the same as a normal
+ palloc. Before a procedure connects to the
+ SPI manager, the current memory context is the upper executor
+ context, so all allocations made by the procedure via
+ palloc or by SPI utility functions are made in
+ this context.
+
+
+
+ When SPI_connect is called, the private
+ context of the procedure, which is created by
+ SPI_connect, is made the current context. All
+ allocations made by palloc,
+ repalloc, or SPI utility functions (except for
+ SPI_copytuple,
+ SPI_copytupledesc,
+ SPI_copytupleintoslot,
+ SPI_modifytuple, and
+ SPI_palloc) are made in this context. When a
+ procedure disconnects from the SPI manager (via
+ SPI_finish) the current context is restored to
+ the upper executor context, and all allocations made in the
+ procedure memory context are freed and cannot be used any more.
+
+
+
+ All functions described in this section may be used by both
+ connected and unconnected procedures. In an unconnected procedure,
+ they act the same as the underlying ordinary server functions
+ (palloc>, etc.).
+
+
+
+
+
+
+ SPI_palloc
+
+
+
+ SPI_palloc
+ allocate memory in the upper executor context
+
+
+ SPI_palloc
+
+
+
+void * SPI_palloc(Size size)
+
+
+
+
+ Description
+
+
+ SPI_palloc allocates memory in the upper
+ executor context.
+
+
+
+
+ Arguments
+
+
+
+ Size size
+
+
+ size in bytes of storage to allocate
+
+
+
+
+
+
+
+ Return Value
+
+
+ pointer to new storage space of the specified size
+
+
+
+
+
+
+
+
+ SPI_repalloc
+
+
+
+ SPI_repalloc
+ reallocate memory in the upper executor context
+
+
+ SPI_repalloc
+
+
+
+void * SPI_repalloc(void * pointer, Size size)
+
+
+
+
+ Description
+
+
+ SPI_repalloc changes the size of a memory
+ segment previously allocated using SPI_palloc.
+
+
+
+ This function is no longer different from plain
+ repalloc. It's kept just for backward
+ compatibility of existing code.
+
+
+
+
+ Arguments
+
+
+
+ void * pointer
+
+
+ pointer to existing storage to change
+
+
+
+
+
+ Size size
+
+
+ size in bytes of storage to allocate
+
+
+
+
+
+
+
+ Return Value
+
+
+ pointer to new storage space of specified size with the contents
+ copied from the existing area
+
+
+
+
+
+
+
+
+ SPI_pfree
+
+
+
+ SPI_pfree
+ free memory in the upper executor context
+
+
+ SPI_pfree
+
+
+
+void SPI_pfree(void * pointer)
+
+
+
+
+ Description
+
+
+ SPI_pfree frees memory previously allocated
+ using SPI_palloc or
+ SPI_repalloc.
+
+
+
+ This function is no longer different from plain
+ pfree. It's kept just for backward
+ compatibility of existing code.
+
+
+
+
+ Arguments
+
+
+
+ void * pointer
+
+
+ pointer to existing storage to free
+
+
+
+
+
+
+
+
+
+
+
+ SPI_copytuple
+
+
+
+ SPI_copytuple
+ make a copy of a row in the upper executor context
+
+
+ SPI_copytuple
+
+
+
+HeapTuple SPI_copytuple(HeapTuple row)
+
+
+
+
+ Description
+
+
+ SPI_copytuple makes a copy of a row in the
+ upper executor context.
+
+
+
+
+ Arguments
+
+
+
+ HeapTuple row
+
+
+ row to be copied
+
+
+
+
+
+
+
+ Return Value
+
+
+ the copied row; NULL only if
+ tuple is NULL
+
+
+
+
+
+
+
+
+ SPI_copytupledesc
+
+
+
+ SPI_copytupledesc
+ make a copy of a row descriptor in the upper executor context
+
+
+ SPI_copytupledesc
+
+
+
+TupleDesc SPI_copytupledesc(TupleDesc tupdesc)
+
+
+
+
+ Description
+
+
+ SPI_copytupledesc makes a copy of a row
+ descriptor in the upper executor context.
+
+
+
+
+ Arguments
+
+
+
+ TupleDesc tupdesc
+
+
+ row descriptor to be copied
+
+
+
+
+
+
+
+ Return Value
+
+
+ the copied row descriptor; NULL only if
+ tupdesc is NULL
+
+
+
+
+
+
+
+
+ SPI_copytupleintoslot
+
+
+
+ SPI_copytupleintoslot
+ make a copy of a row and descriptor in the upper executor context
+
+
+ SPI_copytupleintoslot
+
+
+
+TupleTableSlot * SPI_copytupleintoslot(HeapTuple row, TupleDesc rowdesc)
+
+
+
+
+ Description
+
+
+ SPI_copytupleintoslot makes a copy of a row in
+ the upper executor context, returning it in the form of a filled-in
+ TupleTableSlot structure.
+
+
+
+
+ Arguments
+
+
+
+ HeapTuple row
+
+
+ row to be copied
+
+
+
+
+
+ TupleDesc rowdesc
+
+
+ row descriptor to be copied
+
+
+
+
+
+
+
+ Return Value
+
+
+ TupleTableSlot containing the copied row and
+ descriptor; NULL only if
+ row or rowdesc are
+ NULL
+
+
+
+
+
+
+
+
+ SPI_modifytuple
+
+
+
+ SPI_modifytuple
+ create a row by replacing selected fields of a given row
+
+
+ SPI_modifytuple
+
+
+
+HeapTuple SPI_modifytuple(Relation rel, HeapTuple row, ncols, colnum, Datum * values, const char * nulls)
+
+
+
+
+ Description
+
+
+ SPI_modifytuple creates a new row by
+ substituting new values for selected columns, copying the original
+ row's columns at other positions. The input row is not modified.
+
+
+
+
+ Arguments
+
+
+
+ Relation rel
+
+
+ Used only as the source of the row descriptor for the row.
+ (Passing a relation rather than a row descriptor is a
+ misfeature.)
+
+
+
+
+
+ HeapTuple row
+
+
+ row to be modified
+
+
+
+
+
+ int ncols
+
+
+ number of column numbers in the array
+ colnum
+
+
+
+
+
+ int * colnum
+
+
+ array of the numbers of the columns that are to be changed
+ (count starts at 1)
+
+
+
+
+
+ Datum * values
+
+
+ new values for the specified columns
+
+
+
+
+
+ const char * Nulls
+
+
+ which new values are null, if any (see SPI_execp for the format)
+
+
+
+
+
+
+
+ Return Value
+
+
+ new row with modifications, allocated in the upper executor
+ context; NULL only if row
+ is NULL
+
+
+
+ On error, SPI_result is set as follows:
+
+
+ SPI_ERROR_ARGUMENT
+
+
+ if rel> is NULL>, or if
+ row> is NULL>, or if ncols>
+ is less than or equal to 0, or if colnum> is
+ NULL>, or if values> is NULL>.
+
+
+
+
+
+ SPI_ERROR_NOATTRIBUTE
+
+
+ if colnum> contains an invalid column number (less
+ than or equal to 0 or greater than the number of column in
+ row>)
+
+
+
+
+
+
+
+
+
+
+
+
+ SPI_freetuple
+
+
+
+ SPI_freetuple
+ frees a row allocated in the upper executor context
+
+
+ SPI_freetuple
+
+
+
+void SPI_freetuple(HeapTuple row)
+
+
+
+
+ Description
+
+
+ SPI_freetuple frees a row previously allocated
+ in the upper executor context.
+
+
+
+ This function is no longer different from plain
+ heap_freetuple. It's kept just for backward
+ compatibility of existing code.
+
+
+
+
+ Arguments
+
+
+
+ HeapTuple row
+
+
+ row to free
+
+
+
+
+
+
+
+
+
+
+
+ SPI_freetuptable
+
+
+
+ SPI_freetuptable
+ free a row set created by SPI_exec> or a similar function
+
+
+ SPI_freetuptable
+
+
+
+void SPI_freetuptable(SPITupleTable * tuptable)
+
+
+
+
+ Description
+
+
+ SPI_freetuptable frees a row set created by a
+ prior SPI command execution function, such as
+ SPI_exec>. Therefore, this function is usually called
+ with the global variable SPI_tupletable as
+ argument.
+
+
+
+ This function is useful if a SPI procedure needs to execute
+ multiple commands and does not want to keep the results of earlier
+ commands around until it ends. Note that any unfreed row sets will
+ be freed anyway at SPI_finish>.
+
+
+
+
+ Arguments
+
+
+
+ SPITupleTable * tuptable
+
+
+ pointer to row set to free
+
+
+
+
+
+
+
+
+
+
+
+ SPI_freeplan
+
+
+
+ SPI_freeplan
+ free a previously saved plan
+
+
+ SPI_freeplan
+
+
+
+int SPI_freeplan(void *plan)
+
+
+
+
+ Description
+
+
+ SPI_freeplan releases a command execution plan
+ previously returned by SPI_prepare or saved by
+ SPI_saveplan.
+
+
+
+
+ Arguments
+
+
+
+ void * plan
+
+
+ pointer to plan to free
+
+
+
+
+
+
+
+ Return Value
+
+
+ SPI_ERROR_ARGUMENT if plan
+ is NULL.
+
+
+
+
+
+
+
+ Visibility of Data Changes
+
+
+ The following two rules govern the visibility of data changes in
+ functions that use SPI (or any other C function):
+
+
+
+
+ During the execution of an SQL command, any data changes made by
+ the command (or by function called by the command, including
+ trigger functions) are invisible to the command. For
+ example, in command
- INSERT INTO a SELECT * FROM a
+INSERT INTO a SELECT * FROM a;
- tuples inserted are invisible for SELECT's scan. In effect, this
-duplicates the database table within itself (subject to unique index
-rules, of course) without recursing.
-
-
-
- Changes made by query Q are visible to queries that are started after
-query Q, no matter whether they are started inside Q (during the execution
-of Q) or after Q is done.
-
-
-
-
-Examples
-
-
- This example of SPI usage demonstrates the visibility rule.
- There are more complex examples in src/test/regress/regress.c and
-in contrib/spi.
-
-
-
- This is a very simple example of SPI usage. The procedure execq accepts
-an SQL-query in its first argument and tcount in its second, executes the
-query using SPI_exec and returns the number of tuples for which the query
-executed:
-
-
-#include "executor/spi.h" /* this is what you need to work with SPI */
+ the inserted rows are invisible to the SELECT
+ part.
+
+
+
+
+
+ Changes made by a command C are visible to all commands that are
+ started after C, no matter whether they are started inside C
+ (during the execution of C) or after C is done.
+
+
+
+
+
+
+ The next section contains an example that illustrates the
+ application of these rules.
+
+
+
+
+ Examples
+
+
+ This section contains a very simple example of SPI usage. The
+ procedure execq takes an SQL command as its
+ first argument and a row count as its second, executes the command
+ using SPI_exec and returns the number of rows
+ that were processed by the command. You can find more complex
+ examples for SPI in the source tree in
+ src/test/regress/regress.c and in
+ contrib/spi.
+
+
+
+#include "executor/spi.h"
int execq(text *sql, int cnt);
int
execq(text *sql, int cnt)
{
- char *query;
+ char *command;
int ret;
int proc;
- /* Convert given TEXT object to a C string */
- query = DatumGetCString(DirectFunctionCall1(textout,
- PointerGetDatum(sql)));
+ /* Convert given text object to a C string */
+ command = DatumGetCString(DirectFunctionCall1(textout,
+ PointerGetDatum(sql)));
SPI_connect();
- ret = SPI_exec(query, cnt);
+ ret = SPI_exec(command, cnt);
proc = SPI_processed;
/*
- * If this is SELECT and some tuple(s) fetched -
- * returns tuples to the caller via elog (INFO).
+ * If this is a SELECT and some rows were fetched,
+ * then the rows are printed via elog(INFO).
*/
- if ( ret == SPI_OK_SELECT && SPI_processed > 0 )
+ if (ret == SPI_OK_SELECT && SPI_processed > 0)
{
TupleDesc tupdesc = SPI_tuptable->tupdesc;
SPITupleTable *tuptable = SPI_tuptable;
char buf[8192];
- int i,j;
+ int i, j;
for (j = 0; j < proc; j++)
{
HeapTuple tuple = tuptable->vals[j];
for (i = 1, buf[0] = 0; i <= tupdesc->natts; i++)
- snprintf(buf + strlen (buf), sizeof(buf) - strlen(buf)," %s%s",
+ snprintf(buf + strlen (buf), sizeof(buf) - strlen(buf), " %s%s",
SPI_getvalue(tuple, tupdesc, i),
(i == tupdesc->natts) ? " " : " |");
elog (INFO, "EXECQ: %s", buf);
@@ -3823,99 +2464,105 @@ execq(text *sql, int cnt)
}
SPI_finish();
-
- pfree(query);
+ pfree(command);
return (proc);
}
-
-
+
+
+
+ (This function uses call convention version 0, to make the example
+ easier to understand. In real applications you should user the new
+ version 1 interface.)
+
-
- Now, compile and create the function:
+
+ This is how you declare the function after having compiled it into
+ a shared library:
-
-CREATE FUNCTION execq (text, integer) RETURNS integer
- AS '...path_to_so'
+
+CREATE FUNCTION execq(text, integer) RETURNS integer
+ AS 'filename'
LANGUAGE C;
-
+
+
+
+
+ Here is a sample session:
-
-vac=> SELECT execq('CREATE TABLE a (x INTEGER)', 0);
-execq
------
- 0
+
+=> SELECT execq('CREATE TABLE a (x integer)', 0);
+ execq
+-------
+ 0
(1 row)
-vac=> INSERT INTO a VALUES (execq('INSERT INTO a VALUES (0)',0));
+=> INSERT INTO a VALUES (execq('INSERT INTO a VALUES (0)', 0));
INSERT 167631 1
-vac=> SELECT execq('SELECT * FROM a',0);
-INFO: EXECQ: 0 <<< inserted by execq
-
-INFO: EXECQ: 1 <<< value returned by execq and inserted by upper INSERT
+=> SELECT execq('SELECT * FROM a', 0);
+INFO: EXECQ: 0 -- inserted by execq
+INFO: EXECQ: 1 -- returned by execq and inserted by upper INSERT
-execq
------
- 2
+ execq
+-------
+ 2
(1 row)
-vac=> SELECT execq('INSERT INTO a SELECT x + 2 FROM a',1);
-execq
------
- 1
+=> SELECT execq('INSERT INTO a SELECT x + 2 FROM a', 1);
+ execq
+-------
+ 1
(1 row)
-vac=> SELECT execq('SELECT * FROM a', 10);
-INFO: EXECQ: 0
+=> SELECT execq('SELECT * FROM a', 10);
+INFO: EXECQ: 0
+INFO: EXECQ: 1
+INFO: EXECQ: 2 -- 0 + 2, only one row inserted - as specified
-INFO: EXECQ: 1
-
-INFO: EXECQ: 2 <<< 0 + 2, only one tuple inserted - as specified
-
-execq
------
- 3 <<< 10 is max value only, 3 is real # of tuples
+ execq
+-------
+ 3 -- 10 is the max value only, 3 is the real number of rows
(1 row)
-vac=> DELETE FROM a;
+=> DELETE FROM a;
DELETE 3
-vac=> INSERT INTO a VALUES (execq('SELECT * FROM a', 0) + 1);
+=> INSERT INTO a VALUES (execq('SELECT * FROM a', 0) + 1);
INSERT 167712 1
-vac=> SELECT * FROM a;
-x
--
-1 <<< no tuples in a (0) + 1
+=> SELECT * FROM a;
+ x
+---
+ 1 -- no rows in a (0) + 1
(1 row)
-vac=> INSERT INTO a VALUES (execq('SELECT * FROM a', 0) + 1);
-INFO: EXECQ: 0
+=> INSERT INTO a VALUES (execq('SELECT * FROM a', 0) + 1);
+INFO: EXECQ: 0
INSERT 167713 1
-vac=> SELECT * FROM a;
-x
--
-1
-2 <<< there was single tuple in a + 1
+=> SELECT * FROM a;
+ x
+---
+ 1
+ 2 -- there was one row in a + 1
(2 rows)
--- This demonstrates data changes visibility rule:
+-- This demonstrates the data changes visibility rule:
-vac=> INSERT INTO a SELECT execq('SELECT * FROM a', 0) * x FROM a;
-INFO: EXECQ: 1
-INFO: EXECQ: 2
-INFO: EXECQ: 1
-INFO: EXECQ: 2
-INFO: EXECQ: 2
+=> INSERT INTO a SELECT execq('SELECT * FROM a', 0) * x FROM a;
+INFO: EXECQ: 1
+INFO: EXECQ: 2
+INFO: EXECQ: 1
+INFO: EXECQ: 2
+INFO: EXECQ: 2
INSERT 0 2
-vac=> SELECT * FROM a;
-x
--
-1
-2
-2 <<< 2 tuples * 1 (x in first tuple)
-6 <<< 3 tuples (2 + 1 just inserted) * 2 (x in second tuple)
-(4 rows) ^^^^^^^^
- tuples visible to execq() in different invocations
-
-
-
-
+=> SELECT * FROM a;
+ x
+---
+ 1
+ 2
+ 2 -- 2 rows * 1 (x in first row)
+ 6 -- 3 rows (2 + 1 just inserted) * 2 (x in second row)
+(4 rows) ^^^^^^
+ rows visible to execq() in different invocations
+
+
+
+
diff --git a/doc/src/sgml/syntax.sgml b/doc/src/sgml/syntax.sgml
index 8151c63c8c3..774de140223 100644
--- a/doc/src/sgml/syntax.sgml
+++ b/doc/src/sgml/syntax.sgml
@@ -1,5 +1,5 @@
@@ -26,6 +26,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.82 2003/08/14 23:13:27 tgl
Lexical Structure
+
+ token
+
+
SQL input consists of a sequence of
commands. A command is composed of a
@@ -80,12 +84,18 @@ INSERT INTO MY_TABLE VALUES (3, 'hi there');
Identifiers and Key Words
- identifiers
+ identifier
+ syntax of
- key words
- syntax
+ name
+ syntax of
+
+
+
+ key word
+ syntax of
@@ -121,6 +131,7 @@ INSERT INTO MY_TABLE VALUES (3, 'hi there');
+ identifierlength
The system uses no more than NAMEDATALEN-1
characters of an identifier; longer names can be written in
commands, but they will be truncated. By default,
@@ -133,7 +144,7 @@ INSERT INTO MY_TABLE VALUES (3, 'hi there');
case sensitivity
- SQL commands
+ of SQL commands
Identifier and key word names are case insensitive. Therefore
@@ -152,7 +163,7 @@ UPDATE my_table SET a = 5;
- quotes
+ quotation marksand identifiers
There is a second kind of identifier: the delimited
@@ -207,7 +218,7 @@ UPDATE "my_table" SET "a" = 5;
Constants
- constants
+ constant
@@ -224,13 +235,13 @@ UPDATE "my_table" SET "a" = 5;
String Constants
- character strings
- constants
+ character string
+ constant
- quotes
+ quotation marksescaping
A string constant in SQL is an arbitrary sequence of characters
@@ -286,8 +297,8 @@ SELECT 'foo' 'bar';
Bit-String Constants
- bit strings
- constants
+ bit string
+ constant
@@ -316,8 +327,8 @@ SELECT 'foo' 'bar';
Numeric Constants
- numeric
- constants
+ number
+ constant
@@ -351,6 +362,9 @@ SELECT 'foo' 'bar';
+ integer
+ bigint
+ numeric
A numeric constant that contains neither a decimal point nor an
exponent is initially presumed to be type integer> if its
value fits in type integer> (32 bits); otherwise it is
@@ -363,13 +377,13 @@ SELECT 'foo' 'bar';
The initially assigned data type of a numeric constant is just a
- starting point for the type resolution algorithms. In most
- cases the constant will be automatically coerced to the most
- appropriate type depending on context. When necessary, you
- can force a numeric value to be interpreted as a specific
- data type by casting it. For example, you can force a numeric
- value to be treated as type real> (float4>)
- by writing
+ starting point for the type resolution algorithms. In most cases
+ the constant will be automatically coerced to the most
+ appropriate type depending on context. When necessary, you can
+ force a numeric value to be interpreted as a specific data type
+ by casting it.type cast
+ For example, you can force a numeric value to be treated as type
+ real> (float4>) by writing
REAL '1.23' -- string style
@@ -382,8 +396,8 @@ REAL '1.23' -- string style
Constants of Other Types
- data types
- constants
+ data type
+ constant
@@ -431,8 +445,8 @@ CAST ( 'string' AS type )
Array constants
- arrays
- constants
+ array
+ constant
@@ -468,7 +482,7 @@ CAST ( 'string' AS type )
Operators
- operators
+ operatorsyntax
@@ -600,8 +614,8 @@ CAST ( 'string' AS type )
Comments
- comments
- in SQL
+ comment
+ in SQL
@@ -636,7 +650,7 @@ CAST ( 'string' AS type )
Lexical Precedence
- operators
+ operatorprecedence
@@ -828,6 +842,20 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
Value Expressions
+
+ expression
+ syntax
+
+
+
+ value expression
+
+
+
+ scalar
+ expression
+
+
Value expressions are used in a variety of contexts, such
as in the target list of the SELECT command, as
@@ -903,7 +931,9 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
- Another value expression in parentheses, useful to group subexpressions and override precedence.
+ Another value expression in parentheses, useful to group
+ subexpressions and override
+ precedence.parenthesis>>
@@ -927,6 +957,10 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
Column References
+
+ column reference
+
+
A column can be referenced in the form
@@ -962,6 +996,15 @@ SELECT 3 OPERATOR(pg_catalog.+) 4;
Positional Parameters
+
+ parameter
+ syntax
+
+
+
+ $
+
+
A positional parameter reference is used to indicate a value
that is supplied externally to an SQL statement. Parameters are
@@ -993,6 +1036,11 @@ CREATE FUNCTION dept(text) RETURNS dept
Operator Invocations
+
+ operator
+ invocation
+
+
There are three possible syntaxes for an operator invocation:
@@ -1017,6 +1065,11 @@ CREATE FUNCTION dept(text) RETURNS dept
Function Calls
+
+ function
+ invocation
+
+
The syntax for a function call is the name of a function
(possibly qualified with a schema name), followed by its argument list
@@ -1044,7 +1097,8 @@ sqrt(2)
Aggregate Expressions
- aggregate functions
+ aggregate function
+ invocation
@@ -1123,10 +1177,14 @@ sqrt(2)
Type Casts
-
- data types
- type casts
-
+
+ data type
+ type cast
+
+
+
+ type cast
+
A type cast specifies a conversion from one data type to another.
@@ -1193,6 +1251,10 @@ CAST ( expression AS typeScalar Subqueries
+
+ subquery
+
+
A scalar subquery is an ordinary
SELECT query in parentheses that returns exactly one
@@ -1221,10 +1283,10 @@ SELECT name, (SELECT max(pop) FROM cities WHERE cities.state = states.name)
Array Constructors
-
- arrays
- constructors
-
+
+ array
+ constructor
+
An array constructor> is an expression that builds an
@@ -1270,6 +1332,23 @@ SELECT ARRAY[[1,2],[3,4]];
at the same level must produce sub-arrays of identical dimensions.
+
+ Multidimensional array constructor elements can be anything yielding
+ an array of the proper kind, not only a sub-ARRAY> construct.
+ For example:
+
+create table arr(f1 int[], f2 int[]);
+CREATE TABLE
+insert into arr values (ARRAY[[1,2],[3,4]],ARRAY[[5,6],[7,8]]);
+INSERT 2635544 1
+select ARRAY[f1, f2, '{{9,10},{11,12}}'::int[]] from arr;
+ array
+------------------------------------------------
+ {{{1,2},{3,4}},{{5,6},{7,8}},{{9,10},{11,12}}}
+(1 row)
+
+
+
It is also possible to construct an array from the results of a
subquery. In this form, the array constructor is written with the
@@ -1299,6 +1378,11 @@ SELECT ARRAY(SELECT oid FROM pg_proc WHERE proname LIKE 'bytea%');
Expression Evaluation Rules
+
+ expression
+ order of evaluation
+
+
The order of evaluation of subexpressions is not defined. In
particular, the inputs of an operator or function are not necessarily
diff --git a/doc/src/sgml/trigger.sgml b/doc/src/sgml/trigger.sgml
index d9ee33a2963..c3cc7fe020d 100644
--- a/doc/src/sgml/trigger.sgml
+++ b/doc/src/sgml/trigger.sgml
@@ -1,10 +1,14 @@
Triggers
+
+ trigger
+
+
This chapter describes how to write trigger functions. In
particular, it describes the C-language interface for trigger
@@ -98,18 +102,20 @@ $Header: /cvsroot/pgsql/doc/src/sgml/trigger.sgml,v 1.29 2003/08/10 01:20:34 tgl
When a trigger is being defined, arguments can be specified for
- it. The purpose of including arguments in the trigger definition
- is to allow different triggers with similar requirements to call
- the same function. As an example, there could be a generalized
- trigger function that takes as its arguments two column names and
- puts the current user in one and the current time stamp in the
- other. Properly written, this trigger function would be
- independent of the specific table it is triggering on. So the
- same function could be used for INSERT events
- on any table with suitable columns, to automatically track creation
- of records in a transaction table for example. It could also be
- used to track last-update events if defined as an
- UPDATE trigger.
+ it.trigger>arguments for trigger
+ functions> The purpose of including arguments in the
+ trigger definition is to allow different triggers with similar
+ requirements to call the same function. As an example, there
+ could be a generalized trigger function that takes as its
+ arguments two column names and puts the current user in one and
+ the current time stamp in the other. Properly written, this
+ trigger function would be independent of the specific table it is
+ triggering on. So the same function could be used for
+ INSERT events on any table with suitable
+ columns, to automatically track creation of records in a
+ transaction table for example. It could also be used to track
+ last-update events if defined as an UPDATE
+ trigger.
@@ -117,6 +123,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/trigger.sgml,v 1.29 2003/08/10 01:20:34 tgl
Interaction with the Trigger Manager
+
+ trigger
+ in C
+
+
This section describes the low-level details of the interface to a
trigger function. This information is only needed when writing a
diff --git a/doc/src/sgml/typeconv.sgml b/doc/src/sgml/typeconv.sgml
index 18bad527ff7..82c8fa6a6a0 100644
--- a/doc/src/sgml/typeconv.sgml
+++ b/doc/src/sgml/typeconv.sgml
@@ -1,10 +1,15 @@
Type Conversion
+
+ data type
+ conversion
+
+
SQL statements can, intentionally or not, require
mixing of different data types in the same expression.
@@ -139,6 +144,11 @@ between the built-in types has been carefully crafted and is best not
altered.)
+
+ data type
+ category
+
+
An additional heuristic is provided in the parser to allow better guesses
at proper behavior for SQL standard types. There are
@@ -204,6 +214,11 @@ should use this new function and will no longer do the implicit conversion using
Operators
+
+ operator
+ type resolution in an invocation
+
+
The specific operator to be used in an operator invocation is determined
by following
@@ -452,6 +467,11 @@ SELECT CAST('20' AS int8) ! AS "factorial";
Functions
+
+ function
+ type resolution in an invocation
+
+
The specific function to be used in a function invocation is determined
according to the following steps.
@@ -755,8 +775,22 @@ padding spaces.
-UNION, CASE, and
-ARRAY Constructs
+UNION, CASE, and ARRAY Constructs
+
+
+ UNION
+ determination of result type
+
+
+
+ CASE
+ determination of result type
+
+
+
+ ARRAY
+ determination of result type
+
SQL UNION> constructs must match up possibly dissimilar types to
diff --git a/doc/src/sgml/user-manag.sgml b/doc/src/sgml/user-manag.sgml
index 660d1ccd75d..82481084ee2 100644
--- a/doc/src/sgml/user-manag.sgml
+++ b/doc/src/sgml/user-manag.sgml
@@ -1,5 +1,5 @@
@@ -22,6 +22,18 @@ $Header: /cvsroot/pgsql/doc/src/sgml/user-manag.sgml,v 1.21 2003/08/10 01:20:34
Database Users
+
+ user
+
+
+
+ CREATE USER
+
+
+
+ DROP USER
+
+
Database users are conceptually completely separate from
operating system users. In practice it might be convenient to
@@ -41,6 +53,14 @@ DROP USER name;
+
+ createuser
+
+
+
+ dropuser
+
+
For convenience, the programs createuser
and dropuser are provided as wrappers
@@ -99,7 +119,7 @@ dropuser name
- superuser
+ superusersuperuser>>
A database superuser bypasses all permission checks. Also,
@@ -111,7 +131,7 @@ dropuser name
- database creation
+ database creationdatabase>privilege to create>>
A user must be explicitly given permission to create databases
@@ -123,7 +143,7 @@ dropuser name
- password
+ passwordpassword>>
A password is only significant if the client authentication
@@ -140,7 +160,7 @@ dropuser name
A user's attributes can be modified after creation with
- ALTER USER.
+ ALTER USER.ALTER USER>>
See the reference pages for CREATE USER and
ALTER USER for details.
@@ -166,6 +186,10 @@ ALTER USER myname SET enable_indexscan TO off;
Groups
+
+ group
+
+
As in Unix, groups are a way of logically grouping users to ease
management of privileges: privileges can be granted to, or revoked
@@ -184,6 +208,22 @@ ALTER GROUP name DROP USER uname1
Privileges
+
+ privilege
+
+
+
+ owner
+
+
+
+ GRANT
+
+
+
+ REVOKE
+
+
Being moved to the DDL chapter. Will eventually disappear here.
diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml
index 279364a65d8..8a957b546e8 100644
--- a/doc/src/sgml/wal.sgml
+++ b/doc/src/sgml/wal.sgml
@@ -1,8 +1,17 @@
-
+
Write-Ahead Logging (WAL)
+
+ WAL
+
+
+
+ transaction log
+ WAL
+
+
Write-Ahead Logging (WAL)
is a standard approach to transaction logging. Its detailed
@@ -24,6 +33,10 @@
Benefits of WAL
+
+ fsync
+
+
The first obvious benefit of using WAL is a
significantly reduced number of disk writes, since only the log
@@ -86,7 +99,7 @@
With UNDO, it will also be possible to implement
- savepoints to allow partial rollback of
+ savepointssavepoint>> to allow partial rollback of
invalid transaction operations (parser errors caused by mistyping
commands, insertion of duplicate primary/unique keys and so on)
with the ability to continue or commit valid operations made by
@@ -133,7 +146,7 @@
- Checkpoints are points in the sequence of
+ Checkpointscheckpoint>> are points in the sequence of
transactions at which it is guaranteed that the data files have
been updated with all information logged before the checkpoint. At
checkpoint time, all dirty data pages are flushed to disk and a
@@ -301,7 +314,7 @@
The aim of WAL, to ensure that the log is
written before database records are altered, may be subverted by
- disk drives that falsely report a successful write to the kernel,
+ disk drivesdisk drive>> that falsely report a successful write to the kernel,
when, in fact, they have only cached the data and not yet stored it
on the disk. A power failure in such a situation may still lead to
irrecoverable data corruption. Administrators should try to ensure
diff --git a/doc/src/sgml/xaggr.sgml b/doc/src/sgml/xaggr.sgml
index 7b82af322ea..cb6f0b58f15 100644
--- a/doc/src/sgml/xaggr.sgml
+++ b/doc/src/sgml/xaggr.sgml
@@ -1,13 +1,13 @@
User-Defined Aggregates
- aggregate functions
- extending
+ aggregate function
+ user-defined
@@ -115,7 +115,7 @@ CREATE AGGREGATE avg (
Aggregate functions may use polymorphic
state transition functions or final functions, so that the same functions
can be used to implement multiple aggregates.
- See
+ See
for an explanation of polymorphic functions.
Going a step further, the aggregate function itself may be specified
with a polymorphic base type and state type, allowing a single
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index 0193691a08e..00fb6118329 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -1,11 +1,14 @@
User-Defined Functions
- function>>
+
+ function
+ user-defined
+ PostgreSQL provides four kinds of
@@ -70,7 +73,11 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.72 2003/08/10 01:20:34 tgl E
Query Language (SQL) Functions
- function>SQL>>
+
+ function
+ user-defined
+ in SQL
+
SQL functions execute an arbitrary list of SQL statements, returning
@@ -84,12 +91,12 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.72 2003/08/10 01:20:34 tgl E
- SETOF>function>>
- Alternatively, an SQL function may be declared to return a set,
- by specifying the function's return type
- as SETOF sometype>. In this case
- all rows of the last query's result are returned. Further details
- appear below.
+ SETOF>function>> Alternatively,
+ an SQL function may be declared to return a set, by specifying the
+ function's return type as SETOF
+ sometype>.SETOF>>
+ In this case all rows of the last query's result are returned.
+ Further details appear below.
@@ -523,7 +530,7 @@ SELECT name, listchildren(name) FROM nodes;
SQL functions may be declared to accept and
return the polymorphic> types
anyelement and anyarray.
- See for a more detailed explanation
+ See for a more detailed explanation
of polymorphic functions. Here is a polymorphic function
make_array that builds up an array from two
arbitrary data type elements:
@@ -644,6 +651,12 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision
C-Language Functions
+
+ function
+ user-defined
+ in C
+
+
User-defined functions can be written in C (or a language that can
be made compatible with C, such as C++). Such functions are
@@ -670,6 +683,10 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision
Dynamic Loading
+
+ dynamic loading
+
+
The first time a user-defined function in a particular
loadable object file is called in a session,
@@ -787,9 +804,14 @@ CREATE FUNCTION square_root(double precision) RETURNS double precision
-
+ Base Types in C-Language Functions
+
+ data type
+ internal organisation
+
+
To know how to write C-language functions, you need to know how
PostgreSQL internally represents base data types and how they can
@@ -1479,7 +1501,7 @@ concat_text(PG_FUNCTION_ARGS)
Use pg_config
- --includedir-serverpg_config>>
+ --includedir-serverpg_config>with user-defined C functions>>
to find out where the PostgreSQL> server header
files are installed on your system (or the system that your
users will be running on). This option is new with
@@ -1498,7 +1520,7 @@ concat_text(PG_FUNCTION_ARGS)
When allocating memory, use the
PostgreSQL functions
- palloc and pfree
+ pallocpalloc>> and pfreepfree>>
instead of the corresponding C library functions
malloc and free.
The memory allocated by palloc will be
@@ -2075,7 +2097,7 @@ CREATE OR REPLACE FUNCTION testpassbyval(integer, integer) RETURNS SETOF __testp
C-language functions may be declared to accept and
return the polymorphic> types
anyelement and anyarray.
- See for a more detailed explanation
+ See for a more detailed explanation
of polymorphic functions. When function arguments or return types
are defined as polymorphic types, the function author cannot know
in advance what data type it will be called with, or
@@ -2155,7 +2177,10 @@ CREATE FUNCTION make_array(anyelement)
Function Overloading
- overloading>>
+
+ overloading
+ functions
+
More than one function may be defined with the same SQL name, so long
@@ -2216,6 +2241,11 @@ CREATE FUNCTION test(int, int) RETURNS int
Procedural Language Handlers
+
+ procedural language
+ handler for
+
+
All calls to functions that are written in a language other than
the current version 1 interface for compiled
diff --git a/doc/src/sgml/xindex.sgml b/doc/src/sgml/xindex.sgml
index 6416183c95a..b0b870bcb44 100644
--- a/doc/src/sgml/xindex.sgml
+++ b/doc/src/sgml/xindex.sgml
@@ -1,10 +1,15 @@
Interfacing Extensions To Indexes
+
+ index
+ for user-defined data type
+
+
The procedures described thus far let you define new types, new
functions, and new operators. However, we cannot yet define an
@@ -43,15 +48,18 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xindex.sgml,v 1.30 2003/04/13 09:57:35 pete
The routines for an index method do not directly know anything
- about the data types that the index method will operate on. Instead, an
- operator class> identifies the set of operations that the
- index method needs to use to work with a particular data type.
- Operator classes are so called because one thing they specify is the set
- of WHERE>-clause operators that can be used with an index (i.e., can be
- converted into an index-scan qualification). An operator class may also
- specify some support procedures> that are needed by the
- internal operations of the index method, but do not directly
- correspond to any WHERE>-clause operator that can be used with the index.
+ about the data types that the index method will operate on.
+ Instead, an operator
+ class>operator class>
+ identifies the set of operations that the index method needs to use
+ to work with a particular data type. Operator classes are so
+ called because one thing they specify is the set of
+ WHERE>-clause operators that can be used with an index
+ (i.e., can be converted into an index-scan qualification). An
+ operator class may also specify some support
+ procedures> that are needed by the internal operations of the
+ index method, but do not directly correspond to any
+ WHERE>-clause operator that can be used with the index.
@@ -452,7 +460,7 @@ CREATE OPERATOR = (
It is important to specify the restriction and join selectivity
functions, otherwise the optimizer will be unable to make effective
- use of the index. Note that there less-than, equal, and
+ use of the index. Note that the less-than, equal, and
greater-than cases should use different selectivity functions.
@@ -551,13 +559,68 @@ CREATE OPERATOR CLASS complex_abs_ops
+
+ System Dependencies on Operator Classes
+
+
+ ordering operator
+
+
+
+ PostgreSQL uses operator classes to infer the
+ properties of operators in more ways than just whether they can be used
+ with indexes. Therefore, you might want to create operator classes
+ even if you have no intention of indexing any columns of your datatype.
+
+
+
+ In particular, there are SQL features such as ORDER BY> and
+ DISTINCT> that require comparison and sorting of values.
+ To implement these features on a user-defined datatype,
+ PostgreSQL looks for the default B-tree operator
+ class for the datatype. The equals> member of this operator
+ class defines the system's notion of equality of values for
+ GROUP BY> and DISTINCT>, and the sort ordering
+ imposed by the operator class defines the default ORDER BY>
+ ordering.
+
+
+
+ Comparison of arrays of user-defined types also relies on the semantics
+ defined by the default B-tree operator class.
+
+
+
+ If there is no default B-tree operator class for a datatype, the system
+ will look for a default hash operator class. But since that kind of
+ operator class only provides equality, in practice it is only enough
+ to support array equality.
+
+
+
+ When there is no default operator class for a datatype, you will get
+ errors like could not identify an ordering operator> if you
+ try to use these SQL features with the datatype.
+
+
+
+
+ In PostgreSQL versions before 7.4,
+ sorting and grouping operations would implicitly use operators named
+ =>, <>, and >>. The new
+ behavior of relying on default operator classes avoids having to make
+ any assumption about the behavior of operators with particular names.
+
+
+
+
Special Features of Operator Classes
There are two special features of operator classes that we have
- not discussed yet, mainly because they are not very useful
- with the default B-tree index method.
+ not discussed yet, mainly because they are not useful
+ with the most commonly used index methods.
diff --git a/doc/src/sgml/xoper.sgml b/doc/src/sgml/xoper.sgml
index a2705eb6636..bb04e2854d1 100644
--- a/doc/src/sgml/xoper.sgml
+++ b/doc/src/sgml/xoper.sgml
@@ -1,10 +1,15 @@
User-defined Operators
+
+ operator
+ user-defined
+
+
Every operator is syntactic sugar for a call to an
underlying function that does the real work; so you must
@@ -18,9 +23,10 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xoper.sgml,v 1.24 2003/06/22 22:04:54 tgl E
PostgreSQL supports left unary, right
- unary, and binary operators. Operators can be overloaded; that is,
- the same operator name can be used for different operators that
- have different numbers and types of operands. When a query is
+ unary, and binary operators. Operators can be
+ overloaded;overloadingoperators
+ that is, the same operator name can be used for different operators
+ that have different numbers and types of operands. When a query is
executed, the system determines the operator to call from the
number and types of the provided operands.
@@ -471,17 +477,6 @@ table1.column1 OP table2.column2
-
-
- GROUP BY> and DISTINCT> operations require each
- datatype being grouped or compared to have a mergejoinable
- equality operator named =>. The equality operator and its
- associated SORT1> operator are used to implement these
- operations. Also, the associated SORT1> operator is the
- default ordering operator for ORDER BY>.
-
-
-
In PostgreSQL versions before 7.3,
diff --git a/doc/src/sgml/xplang.sgml b/doc/src/sgml/xplang.sgml
index d350ba25ea8..b0b1622fa9a 100644
--- a/doc/src/sgml/xplang.sgml
+++ b/doc/src/sgml/xplang.sgml
@@ -1,10 +1,14 @@
Procedural Languages
+
+ procedural language
+
+
PostgreSQL allows users to add new
programming languages to be available for writing functions and
diff --git a/doc/src/sgml/xtypes.sgml b/doc/src/sgml/xtypes.sgml
index 74ced8cd83e..2816f59baf8 100644
--- a/doc/src/sgml/xtypes.sgml
+++ b/doc/src/sgml/xtypes.sgml
@@ -1,13 +1,13 @@
User-Defined Types
- data types
- extending
+ data type
+ user-defined
@@ -34,13 +34,17 @@ $Header: /cvsroot/pgsql/doc/src/sgml/xtypes.sgml,v 1.19 2003/08/10 01:20:34 tgl
output function
- A user-defined type must always have input and output functions.
+ A user-defined type must always have input and output
+ functions.input functionof
+ a data typeoutput
+ functionof a data type
These functions determine how the type appears in strings (for input
by the user and output to the user) and how the type is organized in
memory. The input function takes a null-terminated character string
- as its argument and returns the internal (in memory) representation of
- the type. The output function takes the internal representation of
- the type as argument and returns a null-terminated character string.
+ as its argument and returns the internal (in memory) representation
+ of the type. The output function takes the internal representation
+ of the type as argument and returns a null-terminated character
+ string.
--
cgit v1.2.3