diff --git a/reference/pgsql/constants.xml b/reference/pgsql/constants.xml
index 8503aa73e9..16fafef557 100644
--- a/reference/pgsql/constants.xml
+++ b/reference/pgsql/constants.xml
@@ -1,5 +1,5 @@
-
+
&reftitle.constants;
&extension.constants;
@@ -202,6 +202,195 @@
+
+
+ PGSQL_TRANSACTION_IDLE
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_TRANSACTION_ACTIVE
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_TRANSACTION_INTRANS
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_TRANSACTION_INERROR
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_TRANSACTION_UNKNOWN
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_SEVERITY
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_SQLSTATE
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_MESSAGE_PRIMARY
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_MESSAGE_DETAIL
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_MESSAGE_HINT
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_STATEMENT_POSITION
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_INTERNAL_POSITION
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_INTERNAL_QUERY
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_CONTEXT
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_SOURCE_FILE
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_SOURCE_LINE
+ (integer)
+
+
+
+
+
+
+
+
+
+ PGSQL_DIAG_SOURCE_FUNCTION
+ (integer)
+
+
+
+
+
+
+
+
+
diff --git a/reference/pgsql/functions/pg-execute.xml b/reference/pgsql/functions/pg-execute.xml
new file mode 100644
index 0000000000..f009384fdd
--- /dev/null
+++ b/reference/pgsql/functions/pg-execute.xml
@@ -0,0 +1,121 @@
+
+
+
+
+
+ pg_execute
+ Execute a previously prepared query
+
+
+
+ &reftitle.description;
+
+ resourcepg_execute
+ stringstmtname
+ arrayparams
+
+
+ resourcepg_execute
+ resourceconnection
+ stringstmtname
+ arrayparams
+
+
+ pg_execute returns a query result resource if
+ the named prepared query could be executed with the given parameters.
+ It returns &false; on failure or if
+ connection is not a valid connection. Details about the error can
+ be retrieved using the pg_last_error
+ function if connection is valid.
+ pg_execute executes a previously prepared
+ query on the
+ connection resource with the specified
+ parameters. It is identical to pg_query_params
+ except that it takes the name of a previously prepared query instead
+ of an actual query. The
+ connection must be a valid connection that
+ was returned by pg_connect or
+ pg_pconnect. The return value of this
+ function is an query result resource to be used to access the
+ results from other PostgreSQL functions such as
+ pg_fetch_array.
+
+
+ connection is an optional parameter for
+ pg_execute. If
+ connection is not set, default
+ connection is used. Default connection is the last connection
+ made by pg_connect or
+ pg_pconnect.
+
+
+ Although connection can be omitted, it
+ is not recommended, since it could be a cause of hard to find
+ bug in script.
+
+
+
+
+
+
+ &reftitle.examples;
+
+
+ Using pg_execute
+
+
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ pg_connect
+ pg_pconnect
+ pg_prepare
+ pg_send_execute
+
+
+
+
+
+
+
diff --git a/reference/pgsql/functions/pg-prepare.xml b/reference/pgsql/functions/pg-prepare.xml
new file mode 100644
index 0000000000..cff4de9f33
--- /dev/null
+++ b/reference/pgsql/functions/pg-prepare.xml
@@ -0,0 +1,131 @@
+
+
+
+
+
+ pg_prepare
+ Prepares a query for future execution
+
+
+
+ &reftitle.description;
+
+ resourcepg_prepare
+ stringstmtname
+ stringquery
+
+
+ resourcepg_prepare
+ resourceconnection
+ stringstmtname
+ stringquery
+
+
+ pg_prepare returns a query result resource if
+ query could be prepared. It returns &false; on failure or if
+ connection is not a valid connection. Details about the error can
+ be retrieved using the pg_last_error
+ function if connection is valid.
+ pg_prepare prepares an SQL statement for
+ the PostgreSQL database connection specified by the
+ connection resource. The
+ connection must be a valid connection that
+ was returned by pg_connect or
+ pg_pconnect. The return value of this
+ function is an query result resource. The stmtname
+ is the name of the prepared query, for future use with
+ pg_execute or pg_send_execute.
+
+
+ connection is an optional parameter for
+ pg_prepare. If
+ connection is not set, default
+ connection is used. Default connection is the last connection
+ made by pg_connect or
+ pg_pconnect.
+
+
+ Although connection can be omitted, it
+ is not recommended, since it could be a cause of hard to find
+ bug in script.
+
+
+
+
+ Parameters to pg_prepare are specified
+ using placeholders in the query. It is not necessary to quote
+ parameters as quoting and escaping is done automatically.
+ Placeholders are indicated in the query
+ by $1, $2, $3 and so on.
+
+ Using prepared queries means you can prepare one and
+ then execute many times, with different parameters. PostgreSQL
+ will cache the query plan on the prepare, then re-use it for
+ each execute, resulting in speed improvements. There is no
+ need to use a prepared query if it will only be executed once.
+ In this case, it is simpler to use pg_query_params.
+
+
+
+
+ &reftitle.examples;
+
+
+ Using pg_prepare
+
+
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ pg_connect
+ pg_pconnect
+ pg_execute
+ pg_send_execute
+ pg_query_params
+
+
+
+
+
+
diff --git a/reference/pgsql/functions/pg-query-params.xml b/reference/pgsql/functions/pg-query-params.xml
new file mode 100644
index 0000000000..61e84e3de5
--- /dev/null
+++ b/reference/pgsql/functions/pg-query-params.xml
@@ -0,0 +1,100 @@
+
+
+
+
+
+ pg_query_params
+ Execute a query, specifying query variables as separate parameters
+
+
+
+ &reftitle.description;
+
+ resourcepg_query_params
+ stringquery
+ arrayparams
+
+
+ resourcepg_query_params
+ resourceconnection
+ stringquery
+ arrayparams
+
+
+ pg_query_params works identically to
+ pg_query, except that instead of putting
+ query parameters directly into the query
+ string, placeholders are used and the parameters are
+ passed in separately. Unlike pg_query,
+ only one non-empty SQL statement can be executed at a time.
+
+
+ Parameters passed in this way are automatically quoted and escaped
+ if necessary. This is an effective way of improving the security
+ of your scripts and eliminating the need for manual quoting and
+ escaping of parameters.
+
+ Placeholders are indicated in the query
+ by $1, $2, $3 and so on. The first parameter will be substituted for
+ $1, the second for $2, the third for $3.
+
+
+
+
+ &reftitle.examples;
+
+
+ Using pg_query_params
+
+
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ pg_query
+ pg_connect
+ pg_escape_string
+
+
+
+
+
+
diff --git a/reference/pgsql/functions/pg-result-error-field.xml b/reference/pgsql/functions/pg-result-error-field.xml
new file mode 100644
index 0000000000..10eb5beb93
--- /dev/null
+++ b/reference/pgsql/functions/pg-result-error-field.xml
@@ -0,0 +1,64 @@
+
+
+
+
+
+ pg_result_error_field
+
+ Get error message field associated with result
+
+
+
+
+ &reftitle.description;
+
+ stringpg_result_error_field
+ resourceresult
+ intfieldcode
+
+
+ pg_result_error_field returns one of the detailed error message
+ fields associated with result resource. It is only available
+ against a PostgreSQL 7.4 or above server. The error field is specified by
+ the fieldcode.
+
+
+ Because pg_query and pg_query_params return &false; if the query fails,
+ you must use pg_send_query and
+ pg_get_result to get the result handle.
+
+
+ Possible fieldcode values are:
+
+
+
+
+ &reftitle.seealso;
+
+
+ pg_result_error
+
+
+
+
+
+
diff --git a/reference/pgsql/functions/pg-send-execute.xml b/reference/pgsql/functions/pg-send-execute.xml
new file mode 100644
index 0000000000..1c04d2db27
--- /dev/null
+++ b/reference/pgsql/functions/pg-send-execute.xml
@@ -0,0 +1,109 @@
+
+
+
+
+
+ pg_send_execute
+ Asynchronously execute a previously prepared query
+
+
+
+ &reftitle.description;
+
+ resourcepg_send_execute
+ stringstmtname
+ arrayparams
+
+
+ resourcepg_send_execute
+ resourceconnection
+ stringstmtname
+ arrayparams
+
+
+ pg_send_execute executes a previously prepared
+ named query on the connection, with the
+ specified parameters. Unlike pg_execute, script execution
+ is not blocked while the query is executing.
+
+
+ pg_send_execute returns a query result resource if
+ the named prepared query could be executed with the given parameters.
+ It returns &false; on failure or if connection is not a valid connection.
+ It is identical to pg_send_query_params
+ except that it takes the name of a previously prepared query instead
+ of an actual query.
+
+
+
+
+ &reftitle.examples;
+
+
+ Using pg_send_execute
+
+
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ pg_connect
+ pg_pconnect
+ pg_prepare
+ pg_send_prepare
+ pg_execute
+
+
+
+
+
+
+
diff --git a/reference/pgsql/functions/pg-send-prepare.xml b/reference/pgsql/functions/pg-send-prepare.xml
new file mode 100644
index 0000000000..848a8eba5f
--- /dev/null
+++ b/reference/pgsql/functions/pg-send-prepare.xml
@@ -0,0 +1,114 @@
+
+
+
+
+
+ pg_send_prepare
+ Asynchronously prepares a query for future execution
+
+
+
+ &reftitle.description;
+
+ resourcepg_send_prepare
+ stringstmtname
+ stringquery
+
+
+ resourcepg_send_prepare
+ resourceconnection
+ stringstmtname
+ stringquery
+
+
+ pg_send_prepare asynchronously prepares a query
+ on the connection. Unlike pg_prepare,
+ script execution is not blocked while the query is being prepared. It
+ behaves in the same fashion as pg_send_query.
+
+
+ Parameters to pg_prepare are specified
+ using placeholders in the query. It is not necessary to quote
+ parameters as quoting and escaping is done automatically.
+ Placeholders are indicated in the query
+ by $1, $2, $3 and so on.
+
+ Using prepared queries means you can prepare one and
+ then execute many times, with different parameters. PostgreSQL
+ will cache the query plan on the prepare, then re-use it for
+ each execute, resulting in speed improvements. There is no
+ need to use a prepared query if it will only be executed once.
+ In this case, it is simpler to use pg_query_params.
+
+
+
+
+ &reftitle.examples;
+
+
+ Using pg_send_prepare
+
+
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ pg_connect
+ pg_pconnect
+ pg_execute
+ pg_send_execute
+ pg_send_query_params
+
+
+
+
+
+
diff --git a/reference/pgsql/functions/pg-send-query-params.xml b/reference/pgsql/functions/pg-send-query-params.xml
new file mode 100644
index 0000000000..52178cd7be
--- /dev/null
+++ b/reference/pgsql/functions/pg-send-query-params.xml
@@ -0,0 +1,95 @@
+
+
+
+
+
+ pg_send_query_params
+
+ Sends asynchronous query, specifying query variables as separate parameters
+
+
+
+
+ &reftitle.description;
+
+ boolpg_send_query_params
+ resourceconnection
+ stringquery
+ arrayparams
+
+
+ pg_send_query_params works identically to
+ pg_send_query, except that instead of putting
+ query parameters directly into the query
+ string, placeholders are used and the parameters are
+ passed in separately. Unlike pg_send_query,
+ only one non-empty SQL statement can be executed at a time.
+
+
+ Parameters passed in this way are automatically quoted and escaped
+ if necessary. This is an effective way of improving the security
+ of your scripts and eliminating the need for manual quoting and
+ escaping of parameters.
+
+ Placeholders are indicated in the query
+ by $1, $2, $3 and so on. The first parameter will be substituted for
+ $1, the second for $2, the third for $3.
+
+
+
+
+ &reftitle.examples;
+
+
+ Using pg_send_query_params
+
+
+]]>
+
+
+
+
+
+
+ &reftitle.seealso;
+
+
+ pg_send_query
+ pg_connect
+ pg_escape_string
+
+
+
+
+
+
diff --git a/reference/pgsql/functions/pg-transaction-status.xml b/reference/pgsql/functions/pg-transaction-status.xml
new file mode 100644
index 0000000000..e6f6440fb8
--- /dev/null
+++ b/reference/pgsql/functions/pg-transaction-status.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+ pg_transaction_status
+
+ Get transaction status
+
+
+
+
+ &reftitle.description;
+
+ intpg_transaction_status
+ resourceconnection
+
+
+ pg_transaction_status returns the current in-transaction status
+ of the server.
+ The status can be PGSQL_TRANSACTION_IDLE (currently idle),
+ PGSQL_TRANSACTION_ACTIVE (a command is in progress),
+ PGSQL_TRANSACTION_INTRANS (idle, in a valid transaction block),
+ or PGSQL_TRANSACTION_INERROR (idle, in a failed transaction block).
+ PGSQL_TRANSACTION_UNKNOWN is reported if the connection is bad.
+ PGSQL_TRANSACTION_ACTIVE is reported only when a query
+ has been sent to the server and not yet completed.
+
+
+
+ pg_transaction_status will give incorrect results when using
+ a PostgreSQL 7.3 server that has the parameter autocommit
+ set to off. The server-side autocommit feature has been
+ deprecated and does not exist in later server versions.
+
+
+
+
+
+ &reftitle.examples;
+
+
+ pg_transaction_status example
+
+
+]]>
+
+
+
+
+
+
+
+
diff --git a/reference/pgsql/reference.xml b/reference/pgsql/reference.xml
index 739d3ab137..f5a301a886 100644
--- a/reference/pgsql/reference.xml
+++ b/reference/pgsql/reference.xml
@@ -1,5 +1,5 @@
-
+
PostgreSQL Functions
PostgreSQL
@@ -22,7 +22,7 @@
&reftitle.required;
To use PostgreSQL support, you need PostgreSQL 6.5 or
- later, PostgreSQL 7.0 or later to enable all PostgreSQL module
+ later, PostgreSQL 7.4 or later to enable all PostgreSQL module
features. PostgreSQL supports many character encoding including
multibyte character encoding. The current version and more
information about PostgreSQL is available at