Documentation bug: Chapter 35.4, paragraph 4

Started by Jonathan Poolover 15 years ago5 messagesbugsdocs
Jump to latest
#1Jonathan Pool
pool@utilika.org
bugsdocs

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.
ˉ

#2Robert Haas
robertmhaas@gmail.com
In reply to: Jonathan Pool (#1)
bugsdocs
Re: Documentation bug: Chapter 35.4, paragraph 4

On Tue, Nov 23, 2010 at 1:08 PM, Jonathan Pool <pool@utilika.org> 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 <enum> ADD
VALUE <label> (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.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#3Robert Haas
robertmhaas@gmail.com
In reply to: Robert Haas (#2)
bugsdocs
Re: [BUGS] Documentation bug: Chapter 35.4, paragraph 4

On Sun, Nov 28, 2010 at 8:05 AM, Robert Haas <robertmhaas@gmail.com> wrote:

On Tue, Nov 23, 2010 at 1:08 PM, Jonathan Pool <pool@utilika.org> 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 <enum> ADD
VALUE <label> (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 feel like it would be valuable to document that the commands
mentioned above can't be executed from within a transaction block.
Looking over TFM, the only obvious place to document this seems to be
in the reference place for BEGIN, perhaps in the Notes section. I
don't think that's a great location - it seems like the sort of thing
that maybe ought to go someplace in section III - but there's no
related content there now.

Thoughts?

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

#4Bruce Momjian
bruce@momjian.us
In reply to: Robert Haas (#2)
bugsdocs
Re: Documentation bug: Chapter 35.4, paragraph 4

Robert Haas wrote:

On Tue, Nov 23, 2010 at 1:08 PM, Jonathan Pool <pool@utilika.org> 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 <enum> ADD
VALUE <label> (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 <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

Attachments:

/rtmp/doc.difftext/x-diffDownload+6-6
#5Jonathan Pool
pool@utilika.org
In reply to: Bruce Momjian (#4)
bugsdocs
Re: Documentation bug: Chapter 35.4, paragraph 4

I just made the wording more generic

Thanks much.
ˉ