linkend="plpgsql-porting-appendix"> for the code.
- Oracle procedures give a little more flexibility to the developer
- because nothing needs to be explicitly returned, but it can be
- through the use of INOUT> or OUT> parameters.
+
Oracle procedures give a little more
+ flexibility to the developer because nothing needs to be
+ explicitly returned, but it can be through the use of
+ INOUT> or OUT> parameters.
- Packages are a way Oracle gives you to encapsulate PL/SQL
- statements and functions into one entity, like Java classes, where
- you define methods and objects. You can access these
- objects/methods with a .
- (dot). Here is an example of an Oracle package from ACS 4 (the
+ Packages are a way
Oracle gives you to
+ encapsulate PL/SQL statements and functions into one entity, like
+ Java classes, where you define methods and objects. You can access
+ these objects/methods with a .
+ (dot). Here is an example of an
Oracle
+ package from ACS 4 (the
+ url="http://www.arsdigita.com/doc/">ArsDigita Community
System):
- We port this to
PostgreSQL> by creating the different objects of
- the Oracle package as functions with a standard naming
- convention. We have to pay attention to some other details, like
- the lack of default parameters in
PostgreSQL> functions. The above
+ We port this to
PostgreSQL> by creating the
+ different objects of the
Oracle package
+ as functions with a standard naming convention. We have to pay
+ attention to some other details, like the lack of default
+ parameters in
PostgreSQL> functions. The above
package would become something like this:
See and the
- Administrator's Guide for more
- information about allowed variable names and values.
+ &cite-admin; for more information about allowed variable names
+ and values.
Refer to CREATE TABLE for a further description
- of valid arguments.
- The PostgreSQL User's Guide has further
- information on inheritance.
+ of valid arguments. The &cite-user; has further information on
+ inheritance.
See and the
- Administrator's Guide for more
- information about allowed variable names and values.
+ &cite-admin; for more information about allowed variable names
+ and values.
ANALYZE deems them uninteresting (for example, in
a unique-key column, there are no common values) or if the column
data type does not support the appropriate operators. There is more
- information about the statistics in the User's
- Guide.
+ information about the statistics in the &cite-user;.
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
just after BEGIN if you need more rigorous transaction
isolation. (Alternatively, you can change the default transaction
- isolation level; see the PostgreSQL Administrator's
- Guide for details.)
+ isolation level; see the &cite-admin; for details.)
In SERIALIZABLE mode queries will see only changes committed before
the entire
transaction began (actually, before execution of the first
DML> statement
- If you turn <literal>autocommit> mode off, then BEGIN>
+ If you turn <varname>autocommit> mode off, then BEGIN>
is not required: any SQL command automatically starts a transaction.
-
+
A checkpoint is a point in the transaction log sequence at which
all data files have been updated to reflect the information in the
log. All data files will be flushed to disk. Refer to the
- PostgreSQL Administrator's Guide for more
- information about the WAL system.
+ &cite-admin; for more information about the WAL system.
See Also
- PostgreSQL Administrator's Guide
+ &cite-admin;
+
+
Usage
- Refer to the chapter on aggregate functions
- in the PostgreSQL Programmer's Guide for
- complete examples of usage.
+ Refer to the chapter on aggregate functions in the
+ &cite-programmer; for complete examples of usage.
-
+
,
,
,
- PostgreSQL Programmer's Guide
+ &cite-programmer;
-
+
,
,
- PostgreSQL Programmer's Guide
+ &cite-programmer;
by specifying its name as the template, this is not (yet) intended as
a general-purpose COPY DATABASE facility.
We recommend that databases used as templates be treated as read-only.
- See the Administrator's Guide> for more information.
+ See the &cite-admin; for more information.
The underlying data type of the domain. This may include array
specifiers.
- Refer to the User's Guide for further
+ Refer to the &cite-user; for further
information about data types and arrays.
- PostgreSQL Programmer's Guide
+ &cite-programmer;
Notes
- Refer to the chapter in the
- PostgreSQL Programmer's Guide
+ Refer to the chapter in the &cite-programmer;
on the topic of extending
for further information on writing external functions.
,
,
,
- PostgreSQL Programmer's Guide
+ &cite-programmer;
Description
- CREATE GROUP will create a new group in the database installation.
- Refer to the Administrator's Guide for information about using groups
- for authentication.
- You must be a database superuser to use this command.
+ CREATE GROUP will create a new group in the
+ database installation. Refer to the &cite-admin; for information
+ about using groups for authentication. You must be a database
+ superuser to use this command.
Use
CREATE LANGUAGE effectively associates the
language name with a call handler that is responsible for executing
- functions written in the language. Refer to the
- Programmer's Guide for more information
- about language call handlers.
+ functions written in the language. Refer to the &cite-programmer;
+ for more information about language call handlers.
- PostgreSQL Programmer's Guide
+ &cite-programmer;
Refer to the chapter on interfacing extensions to indexes in the
- PostgreSQL Programmer's Guide
- for further information.
+ &cite-programmer; for further information.
Notes
- Refer to the chapter on operators in the
- PostgreSQL User's Guide
+ Refer to the chapter on operators in the &cite-user;
for further information.
Refer to DROP OPERATOR to delete
user-defined operators from a database.
currval and
setval
to operate on the sequence. These functions are documented in
- the User's Guide.
+ the &cite-user;.
The data type of the column. This may include array specifiers.
- Refer to the User's Guide for further
- information about data types and arrays.
+ Refer to the &cite-user; for further information about data
+ types and arrays.
- Refer to the chapters on SPI and Triggers in the
- PostgreSQL Programmer's Guide for more
- information.
+ Refer to the chapters on SPI and Triggers in the &cite-programmer;
+ for more information.
- PostgreSQL Programmer's Guide
+ &cite-programmer;
- PostgreSQL Programmer's Guide
+ &cite-programmer;
CREATE USER will add a new user to an instance
- of
PostgreSQL. Refer to the
- Administrator's Guide for information about
- managing users and authentication. You must be a database
- superuser to use this command.
+ of
PostgreSQL. Refer to the &cite-admin;
+ for information about managing users and authentication. You must
+ be a database superuser to use this command.
- See the chapter on client authentication in the
- Administrator's Guide for details on
- how to set up authentication mechanisms. Note that older
- clients may lack support for the MD5 authentication mechanism
- that is needed to work with passwords that are stored
- encrypted.
+ See the chapter on client authentication in the &cite-admin;
+ for details on how to set up authentication mechanisms. Note
+ that older clients may lack support for the MD5 authentication
+ mechanism that is needed to work with passwords that are
+ stored encrypted.
The input data type of the aggregate function,
or * if the function accepts any input type.
- (Refer to the PostgreSQL User's Guide for
- further information about data types.)
- This should become a cross-reference rather than a
- hard-coded chapter number
+ (Refer to the &cite-user; for further information about data types.)
This reference page does not describe the embedded SQL language.
- See the &cite-programmer; for that.
+ See the &cite-programmer; for more information on that topic.
See Also
- PostgreSQL Programmer's Guide for a more
- detailed description of the embedded SQL interface
+ &cite-programmer; for a more detailed description of the embedded
+ SQL interface
2002-08-12
- EXECUTE plan_name [ (parameter [, ...] ) ]
+ EXECUTE plan_name [ (parameter [, ...] ) ] [ INTO [ TEMPORARY | TEMP ] table ]
+
parameter
- The actual value of a parameter to the prepared query.
- This must be an expression yielding a value of a type
- compatible with
- the data-type specified for this parameter position in the
- PREPARE statement that created the prepared
- query.
+ The actual value of a parameter to the prepared query. This
+ must be an expression yielding a value of a type compatible
+ with the data-type specified for this parameter position in
+ the PREPARE statement that created the
+ prepared query.
+
+
+
+
+
+ table
+
+ The name of the table in which to store the results of
+ executing the query (if it is a SELECT). If
+ no table is specified, the results are returned to the client
+ (as normal).
name of a prepared query must be unique within a database session.
+ Like SELECT INTO, EXECUTE can
+ be used to store the results of executing the query in a table by
+ specifying an INTO clause. For more information on this behabior,
+ consult the reference for .
+
+
For more information on the creation and usage of prepared queries,
see .
- Prior to
PostgreSQL 7.3, the query plan
- was emitted in the form of a NOTICE message. Now it appears as a
- query result (formatted like a table with a single text column).
+ Prior to
PostgreSQL 7.3, the query
+ plan was emitted in the form of a NOTICE
+ message. Now it appears as a query result (formatted like a
+ table with a single text column).
costs to estimate which plan is really the cheapest.
+
+ In order to allow the
PostgreSQL query
+ planner to make reasonably informed decisions when optimizing
+ queries, the ANALYZE statement should be used
+ to record statistics about the distribution of data within the
+ table. If you have not done this (or the statistical distribution
+ of the data in the table has changed significantly since the last
+ time ANALYZE was run), the estimated costs and
+ the resulting query plan displayed by EXPLAIN
+ are unlikely to conform to the real properties of the query.
+
+
+
The ANALYZE option causes the query to be actually executed, not only
planned. The total elapsed time expended within each plan node (in
milliseconds) and total number of rows it actually returned are added to
the display. This is useful for seeing whether the planner's estimates
- are close to reality.
+ are close to the actual performance of the query.
There is only sparse documentation on the optimizer's use of cost
information in
PostgreSQL.
- Refer to the User's Guide and
- Programmer's Guide for more information.
+ Refer to the &cite-user; and &cite-programmer; for more information.
Note that the specific numbers shown, and even the selected query
strategy, may vary between
PostgreSQL
- releases due to planner improvements.
+ releases due to planner improvements. In addition, the algorithm
+ used by ANALYZE to generate statistics is not
+ completely deterministic; therefore, it is possible (although not
+ likely) for cost estimations to change between runs of
+ ANALYZE, even if the actual distribution of data
+ in the table has not changed.
- PostgreSQL Administrator's Guide
+ &cite-admin;
See Also
- PostgreSQL Administrator's Guide
+ &cite-admin;
- Insert into arrays (refer to the
- PostgreSQL User's Guide for further
+ Insert into arrays (refer to the &cite-user; for further
information about arrays):
The file name is specified in the same way as for shared library
names in ; in particular, one
may rely on a search path and automatic addition of the system's standard
- shared library file name extension. See the
- Programmer's Guide for more detail.
+ shared library file name extension. See the &cite-programmer; for
+ more information on this topic.
,
- PostgreSQL Programmer's Guide
+ &cite-programmer;
-
+
See Also
- PostgreSQL Programmer's Guide
+ &cite-programmer;
+
+
See Also
- , PostgreSQL Administrator's Guide
+ , &cite-admin;
- PostgreSQL Administrator's Guide
+ &cite-admin;
-
+
- PostgreSQL Administrator's Guide
+ &cite-admin;
- PostgreSQL Programmer's Guide (description of libpgtcl)
+ &cite-programmer; (description of libpgtcl)
tclsh 1
- PostgreSQL Programmer's Guide (description of libpgtcl)
+ &cite-programmer; (description of libpgtcl)
tclsh 1
You can avoid having to type these options by setting up a
- configuration file. See the Administrator's
- Guide for details. Some (safe) options can also be
- set from the connecting client in an application-dependent way.
- For example, if the environment variable PGOPTIONS
-
is set, then libpq>-based clients will pass that string to the
+ configuration file. See the &cite-admin; for details. Some
+ (safe) options can also be set from the connecting client in an
+ application-dependent way. For example, if the environment
+ variable PGOPTIONS is set, then
+
libpq>-based clients will pass that string to the
server, which will interpret it as
postgres command-line options.
means that the day before month
(rather than
month before day) rule is used to interpret ambiguous date
input, and that the day is printed before the month in certain
- date output formats. See the PostgreSQL User's
- Guide for more information.
+ date output formats. See the &cite-user; for more information.
postmaster accepts the following
command line arguments. For a detailed discussion of the options
- consult the Administrator's Guide. You can
- also save typing most of these options by setting up a
- configuration file.
+ consult the &cite-admin;. You can also save typing most of these
+ options by setting up a configuration file.
-c name=value
- Sets a named run-time parameter. Consult the
- Administrator's Guide for a list and
- descriptions. Most of the other command line options are in
- fact short forms of such a parameter assignment.
- can appear multiple times to set multiple parameters.
+ Sets a named run-time parameter. Consult the &cite-admin; for
+ a list and descriptions. Most of the other command line
+ options are in fact short forms of such a parameter
+ assignment.
+ multiple parameters.
default, this value is 32, but it can be set as high as your
system will support. (Note that
is required to be at least twice
- . See the Administrator's
- Guide for a discussion of system resource requirements
- for large numbers of client connections.)
+ . See the &cite-admin; for a discussion of
+ system resource requirements for large numbers of client
+ connections.)
Other environment variables may be used to designate alternative
- data storage locations. See the Administrator's
- Guide for more information.
+ data storage locations. See the &cite-admin; for more
+ information.
current session. The actual source of this value might be a
compiled-in default, the postmaster's configuration file or command-line
switches, or per-database or per-user default settings. See the
- Administrator's Guide for details.
+ &cite-admin; for details.
- DISTINCT will eliminate duplicate rows from the
- result.
- ALL (the default) will return all candidate rows,
- including duplicates.
+ DISTINCT will eliminate duplicate rows from the result. ALL (the
+ default) will return all candidate rows, including duplicates.
- DISTINCT ON eliminates rows that match on all the
+ DISTINCT ON eliminates rows that match on all the
specified expressions, keeping only the first row of each set of
duplicates. The DISTINCT ON expressions are interpreted using the
same rules as for ORDER BY items; see below.
Note that the first row
of each set is unpredictable
- unless ORDER BY is used to ensure that the desired
+ unless ORDER BY is used to ensure that the desired
row appears first. For example,
SELECT DISTINCT ON (location) location, time, report
- SELECT queries can be combined using UNION, INTERSECT, and EXCEPT
- operators. Use parentheses if necessary to determine the ordering
- of these operators.
+ SELECT queries can be combined using UNION,
+ INTERSECT, and EXCEPT operators. Use parentheses if necessary to
+ determine the ordering of these operators.
- The FOR UPDATE clause causes the SELECT statement to lock the selected
- rows against concurrent updates.
+ The FOR UPDATE clause causes the SELECT
+ statement to lock the selected rows against concurrent updates.
- The FROM clause specifies one or more source tables for the SELECT.
- If multiple sources are specified, the result is conceptually the
- Cartesian product of all the rows in all the sources --- but usually
- qualification conditions are added to restrict the returned rows to
- a small subset of the Cartesian product.
+ The FROM clause specifies one or more source tables for the
+ SELECT. If multiple sources are specified, the
+ result is conceptually the Cartesian product of all the rows in
+ all the sources --- but usually qualification conditions are added
+ to restrict the returned rows to a small subset of the Cartesian
+ product.
- A FROM item can also be a parenthesized sub-SELECT (note that an
- alias clause is required for a sub-SELECT!). This is an extremely
- handy feature since it's the only way to get multiple levels of
- grouping, aggregation, or sorting in a single query.
+ A FROM item can also be a parenthesized
+ sub-SELECT (note that an alias clause is
+ required for a sub-SELECT!). This is an
+ extremely useful feature since it's the only way to get multiple
+ levels of grouping, aggregation, or sorting in a single query.
- GROUP BY will condense into a single row all selected rows that share the
- same values for the grouped columns. Aggregate functions, if any,
- are computed across all rows making up each group, producing a
- separate value for each group (whereas without GROUP BY, an
- aggregate produces a single value computed across all the selected
- rows). When GROUP BY is present, it is not valid for the SELECT
- output expression(s) to refer to
+ GROUP BY will condense into a single row all selected rows that
+ share the same values for the grouped columns. Aggregate
+ functions, if any, are computed across all rows making up each
+ group, producing a separate value for each group (whereas without
+ GROUP BY, an aggregate produces a single value computed across all
+ the selected rows). When GROUP BY is present, it is not valid for
+ the SELECT output expression(s) to refer to
ungrouped columns except within aggregate functions, since there
- would be more than one possible value to return for an ungrouped column.
+ would be more than one possible value to return for an ungrouped
+ column.
- A GROUP BY item can be an input column name, or the name or ordinal
- number of an output column (SELECT expression), or it can be an arbitrary
- expression formed from input-column values. In case of ambiguity, a GROUP
- BY name will
- be interpreted as an input-column name rather than an output column name.
+ A GROUP BY item can be an input column name, or the name or
+ ordinal number of an output column (SELECT
+ expression), or it can be an arbitrary expression formed from
+ input-column values. In case of ambiguity, a GROUP BY name will
+ be interpreted as an input-column name rather than an output
+ column name.
- An ORDER BY item can be the name or ordinal
- number of an output column (SELECT expression), or it can be an arbitrary
- expression formed from input-column values. In case of ambiguity, an
- ORDER BY name will be interpreted as an output-column name.
+ An ORDER BY item can be the name or ordinal number of an output
+ column (SELECT expression), or it can be an
+ arbitrary expression formed from input-column values. In case of
+ ambiguity, an ORDER BY name will be interpreted as an
+ output-column name.
The ordinal number refers to the ordinal (left-to-right) position
The UNION operator computes the collection (set union) of the rows
- returned by the queries involved.
- The two SELECT statements that represent the direct operands of the UNION must
- produce the same number of columns, and corresponding columns must be
- of compatible data types.
+ returned by the queries involved. The two
+ SELECT statements that represent the direct
+ operands of the UNION must produce the same number of columns, and
+ corresponding columns must be of compatible data types.
- Multiple UNION operators in the same SELECT statement are
- evaluated left to right, unless otherwise indicated by parentheses.
+ Multiple UNION operators in the same SELECT
+ statement are evaluated left to right, unless otherwise indicated
+ by parentheses.
- FOR UPDATE causes the rows retrieved by the query to be locked as though
- for update. This prevents them from being modified or deleted by other
- transactions until the current transaction ends; that is, other
- transactions that attempt UPDATE, DELETE, or SELECT FOR UPDATE of these
- rows will be blocked until the current transaction ends. Also, if an
- UPDATE, DELETE, or SELECT FOR UPDATE from another transaction has already
- locked a selected row or rows, SELECT FOR UPDATE will wait for the other
- transaction to complete, and will then lock and return the updated row
- (or no row, if the row was deleted). For further discussion see the
- concurrency chapter of the User's Guide.
+ FOR UPDATE causes the rows retrieved by the query to be locked as
+ though for update. This prevents them from being modified or
+ deleted by other transactions until the current transaction ends;
+ that is, other transactions that attempt
+ UPDATE, DELETE, or
+ SELECT FOR UPDATE of these rows will be blocked
+ until the current transaction ends. Also, if an
+ UPDATE, DELETE, or
+ SELECT FOR UPDATE from another transaction has
+ already locked a selected row or rows, SELECT FOR
+ UPDATE will wait for the other transaction to complete,
+ and will then lock and return the updated row (or no row, if the
+ row was deleted). For further discussion see the concurrency
+ chapter of the &cite-user;.
- If specific tables are named in FOR UPDATE, then only rows coming from
- those tables are locked; any other tables used in the SELECT are simply
- read as usual.
+ If specific tables are named in FOR UPDATE, then only rows coming
+ from those tables are locked; any other tables used in the
+ SELECT are simply read as usual.
4
-Some other SQL databases cannot do this except by introducing a dummy one-row
-table to do the select from. A less obvious use is to abbreviate a
-normal select from one or more tables:
+Some other
SQL databases cannot do this except by
+introducing a dummy one-row table to do the select from. A less
+obvious use is to abbreviate a normal select from one or more tables:
SELECT distributors.* WHERE distributors.name = 'Westward';
The SET command changes run-time configuration
parameters. Many of the run-time parameters listed in the
- Administrator's Guide can be changed on-the-fly
- with SET. (But some require superuser privileges
- to change, and others cannot be changed after server or session start.)
- Note that SET only affects the value used by the
- current session.
+ &cite-admin; can be changed on-the-fly with SET.
+ (But some require superuser privileges to change, and others cannot
+ be changed after server or session start.) Note that
+ SET only affects the value used by the current
+ session.
- Even with <literal>autocommit> set to off>, SET>
+ Even with <varname>autocommit> set to off>, SET>
does not start a new transaction block. See the
- autocommit> section of the Administrator's
- Guide for details.
+ autocommit> section of the &cite-admin; for details.
The function set_config provides the equivalent
- capability. See Miscellaneous Functions in the
- PostgreSQL User's Guide.
+ capability. See Miscellaneous Functions in
+ the &cite-user;.
-
+
2000-11-24
SET default_transaction_isolation = 'value'
- and in the
- configuration file. Consult the Administrator's
- Guide for more information.
+ and in the configuration file. Consult the &cite-admin; for more
+ information.
not provide the isolation levels
and . Because of multiversion
concurrency control, the level is not
- truly serializable. See the User's Guide for
- details.
+ truly serializable. See the &cite-user; for details.
- Even with <literal>autocommit> set to off>, SHOW>
+ Even with <varname>autocommit> set to off>, SHOW>
does not start a new transaction block. See the
- autocommit> section of the Administrator's
- Guide for details.
+ autocommit> section of the &cite-admin; for details.
Examples
- Show the current <literal>DateStyle> setting:
+ Show the current <varname>DateStyle> setting:
SHOW DateStyle;
- Show the current genetic optimizer (geqo) setting:
+ Show whether the genetic query optimizer is enabled by displaying
+ the geqo setting:
SHOW GEQO;
geqo
The function current_setting produces equivalent
output. See Miscellaneous Functions in the
- PostgreSQL User's Guide.
+ &cite-user;.
intended usage is in connection with preparation of user-defined template
databases, or other databases that are completely read-only and will not
receive routine maintenance VACUUM> operations.
- See the Administrator's Guide> for details.
+ See the &cite-admin; for details.
For further details see the description of the CREATE
- AGGREGATE command in the Reference
- Manual.
+ AGGREGATE command in the &cite-reference;.
it is not immediately clear which function would be called with
some trivial input like test(1, 1.5). The
currently implemented resolution rules are described in the
- User's Guide, but it is unwise to design a
- system that subtly relies on this behavior.
+ &cite-user;, but it is unwise to design a system that subtly
+ relies on this behavior.