Documentation bug: Chapter 35.4, paragraph 4
Documentation bug: Chapter 35.4, paragraph 4
От:
Jonathan Pool <pool@utilika.org>
Дата:
Chapter 35.4, paragraph 4, of the PostgreSQL 9.0.1 Documentation says: Any collection of commands in the SQL language can be packaged together and= defined as a function. Besides SELECT queries, the commands can include da= ta modification queries (INSERT, UPDATE, and DELETE), as well as other SQL = commands. (The only exception is that you cannot put BEGIN, COMMIT, ROLLBAC= K, or SAVEPOINT commands into a SQL function.) This appears to be incorrect, in that attempting to include a VACUUM comman= d in a query-language function elicits the following error message: ERROR: VACUUM cannot be executed from a function or multi-command string Thus, presumably "VACUUM" should be added to the list of exceptions. =CB=89
Re: Documentation bug: Chapter 35.4, paragraph 4
От:
Robert Haas <robertmhaas@gmail.com>
Дата:
On Tue, Nov 23, 2010 at 1:08 PM, Jonathan Pool wrote: > Chapter 35.4, paragraph 4, of the PostgreSQL 9.0.1 Documentation says: > > Any collection of commands in the SQL language can be packaged together a= nd defined as a function. Besides SELECT queries, the commands can include = data modification queries (INSERT, UPDATE, and DELETE), as well as other SQ= L commands. (The only exception is that you cannot put BEGIN, COMMIT, ROLLB= ACK, or SAVEPOINT commands into a SQL function.) > > This appears to be incorrect, in that attempting to include a VACUUM comm= and in a query-language function elicits the following error message: > > ERROR: =A0VACUUM cannot be executed from a function or multi-command stri= ng > > Thus, presumably "VACUUM" should be added to the list of exceptions. I fear it's worse than that. Taking a look at the places where we call PreventTransactionChain(), they appear to include database-wide CLUSTER, DISCARD ALL, VACUUM (as you noted), COMMIT PREPARED, ROLLBACK PREPARED, CREATE TABLESPACE, DROP TABLESPACE, ALTER TYPE ADD VALUE (but the PreventTransactionChain call says ADD rather than ADD VALUE), CREATE INDEX CONCURRENTLY, CREATE DATABASE, DROP DATABASE, and REINDEX DATABASE. I'm not sure if there's some generic way we could refer to all that rather than listing them all individually. --=20 Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
Re: Documentation bug: Chapter 35.4, paragraph 4
От:
Jonathan Pool <pool@utilika.org>
Дата:
> I just made the wording more generic Thanks much. =CB=89
Re: Documentation bug: Chapter 35.4, paragraph 4
От:
Bruce Momjian <bruce@momjian.us>
Дата:
Robert Haas wrote:
> On Tue, Nov 23, 2010 at 1:08 PM, Jonathan Pool wrote:
> > Chapter 35.4, paragraph 4, of the PostgreSQL 9.0.1 Documentation says:
> >
> > Any collection of commands in the SQL language can be packaged together and defined as a function. Besides SELECT queries, the commands can include data modification queries (INSERT, UPDATE, and DELETE), as well as other SQL commands. (The only exception is that you cannot put BEGIN, COMMIT, ROLLBACK, or SAVEPOINT commands into a SQL function.)
> >
> > This appears to be incorrect, in that attempting to include a VACUUM command in a query-language function elicits the following error message:
> >
> > ERROR: ?VACUUM cannot be executed from a function or multi-command string
> >
> > Thus, presumably "VACUUM" should be added to the list of exceptions.
>
> I fear it's worse than that. Taking a look at the places where we
> call PreventTransactionChain(), they appear to include database-wide
> CLUSTER, DISCARD ALL, VACUUM (as you noted), COMMIT PREPARED, ROLLBACK
> PREPARED, CREATE TABLESPACE, DROP TABLESPACE, ALTER TYPE ADD
> VALUE (but the PreventTransactionChain call says ADD rather
> than ADD VALUE), CREATE INDEX CONCURRENTLY, CREATE DATABASE, DROP
> DATABASE, and REINDEX DATABASE.
>
> I'm not sure if there's some generic way we could refer to all that
> rather than listing them all individually.
I just made the wording more generic; we rarely are asked about this,
so generic seemed appropriate. Applied doc patch attached.
--
Bruce Momjian http://momjian.us
EnterpriseDB http://enterprisedb.com
+ It's impossible for everything to be true. +
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
new file mode 100644
index c65f852..1a35014
*** a/doc/src/sgml/xfunc.sgml
--- b/doc/src/sgml/xfunc.sgml
***************
*** 116,124 ****
Besides SELECT queries, the commands can include data
modification queries (INSERT,
UPDATE, and DELETE), as well as
! other SQL commands. (The only exception is that you cannot put
! BEGIN</>, COMMIT</>, ROLLBACK</>, or
! SAVEPOINT</> commands into a SQL function.)
However, the final command
must be a SELECT or have a RETURNING</>
clause that returns whatever is
--- 116,124 ----
Besides SELECT queries, the commands can include data
modification queries (INSERT,
UPDATE, and DELETE), as well as
! other SQL commands. (You cannot use transaction control commands, e.g.
! COMMIT</>, SAVEPOINT</>, and some utility
! commands, e.g. VACUUM</>, in SQL functions.)
However, the final command
must be a SELECT or have a RETURNING</>
clause that returns whatever is