pg.ddx.io pgsql-docs@postgresql.org mailing list archive
help / color / mirror / Atom feedProcedures
24+ messages / 6 participants
[nested] [flat]
Commits from this thread:
2020-08-31 243a3b92a6 5277f493dd bed05fff6f 785affc1d6 doc: clarify the useful features of procedures
* Procedures
@ 2020-08-04 10:33 PG Doc comments form <noreply@postgresql.org>
0 siblings, 1 reply; 24+ messages in thread
From: PG Doc comments form @ 2020-08-04 10:33 UTC (permalink / raw)
To: pgsql-docs@lists.postgresql.org; +Cc: robin.abbi@downley.net
The following documentation comment has been logged on the website:
Page: https://www.postgresql.org/docs/11/sql-createprocedure.html
Description:
The information on procedures could helpfully include that the feature is
new from PostgreSQL 11 and give an explanation of how it differs from
functions. I found the information I needed here
https://dba.stackexchange.com/a/262662, but I think it would really benefit
others if the information was provided in the official documentation.
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-06 00:17 Bruce Momjian <bruce@momjian.us>
parent: PG Doc comments form <noreply@postgresql.org>
0 siblings, 1 reply; 24+ messages in thread
From: Bruce Momjian @ 2020-08-06 00:17 UTC (permalink / raw)
To: robin.abbi@downley.net; pgsql-docs@lists.postgresql.org
On Tue, Aug 4, 2020 at 10:33:49AM +0000, PG Doc comments form wrote:
> The following documentation comment has been logged on the website:
>
> Page: https://www.postgresql.org/docs/11/sql-createprocedure.html
> Description:
>
> The information on procedures could helpfully include that the feature is
> new from PostgreSQL 11 and give an explanation of how it differs from
> functions. I found the information I needed here
> https://dba.stackexchange.com/a/262662, but I think it would really benefit
> others if the information was provided in the official documentation.
We don't normally mention what release added a features. However, I do
see your problem with finding that procedures can issue transaction
control statements. I see this for procedures:
https://www.postgresql.org/docs/12/xproc.html
but that has no mention of transactions, just a mention of using CALL,
then this pl/pgSQL section about transaction control mentions CALL:
https://www.postgresql.org/docs/12/plpgsql-transactions.html
Is this what you think needs improving?
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-06 10:32 Dave Cramer <davecramer@postgres.rocks>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 24+ messages in thread
From: Dave Cramer @ 2020-08-06 10:32 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: robin.abbi@downley.net; pgsql-docs@lists.postgresql.org
On Wed, 5 Aug 2020 at 20:18, Bruce Momjian <bruce@momjian.us> wrote:
> On Tue, Aug 4, 2020 at 10:33:49AM +0000, PG Doc comments form wrote:
> > The following documentation comment has been logged on the website:
> >
> > Page: https://www.postgresql.org/docs/11/sql-createprocedure.html
> > Description:
> >
> > The information on procedures could helpfully include that the feature is
> > new from PostgreSQL 11 and give an explanation of how it differs from
> > functions. I found the information I needed here
> > https://dba.stackexchange.com/a/262662, but I think it would really
> benefit
> > others if the information was provided in the official documentation.
>
> We don't normally mention what release added a features. However, I do
> see your problem with finding that procedures can issue transaction
> control statements. I see this for procedures:
>
> https://www.postgresql.org/docs/12/xproc.html
>
> but that has no mention of transactions, just a mention of using CALL,
> then this pl/pgSQL section about transaction control mentions CALL:
>
> https://www.postgresql.org/docs/12/plpgsql-transactions.html
>
> Is this what you think needs improving?
>
> Neither of those places mention that procedures cannot be called inside a
transaction.
So ya I think there there is some room for improvement
Dave Cramer
www.postgres.rocks
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-06 13:30 Robin Abbi <robin.abbi@downley.net>
parent: Dave Cramer <davecramer@postgres.rocks>
0 siblings, 1 reply; 24+ messages in thread
From: Robin Abbi @ 2020-08-06 13:30 UTC (permalink / raw)
To: Dave Cramer <davecramer@postgres.rocks>; +Cc: Bruce Momjian <bruce@momjian.us>; pgsql-docs@lists.postgresql.org
PostgreSQL went as far as release 10 without procedures.
Some third party resources written before 11 loosely conflate procedures
with functions.
Some third party resources written before 11 accurately state PostgreSQL
has functions but not procedures.
Referring to the PostgreSQL docs for 11 on, procedures have been added.
For someone like me, coming to the subject without much of a hinterland
other than googling around, it seemed clear that there was a motivating
case that caused Procedures to be added to PostgreSQL, but I was not
sufficiently familiar with the domain to be able to readily intuit what it
might have been.
For example, Procedures say they have no return value, yet Functions can
return void. Not the same I agree, but I wouldn't be aware in which
circumstances it mattered.
For me, perhaps the most useful thing would have been a small example
highlighting the essential thing(s) that procedures can do that functions
could not.
Robin
On Thu, 6 Aug 2020 at 11:32, Dave Cramer <davecramer@postgres.rocks> wrote:
>
>
> On Wed, 5 Aug 2020 at 20:18, Bruce Momjian <bruce@momjian.us> wrote:
>
>> On Tue, Aug 4, 2020 at 10:33:49AM +0000, PG Doc comments form wrote:
>> > The following documentation comment has been logged on the website:
>> >
>> > Page: https://www.postgresql.org/docs/11/sql-createprocedure.html
>> > Description:
>> >
>> > The information on procedures could helpfully include that the feature
>> is
>> > new from PostgreSQL 11 and give an explanation of how it differs from
>> > functions. I found the information I needed here
>> > https://dba.stackexchange.com/a/262662, but I think it would really
>> benefit
>> > others if the information was provided in the official documentation.
>>
>> We don't normally mention what release added a features. However, I do
>> see your problem with finding that procedures can issue transaction
>> control statements. I see this for procedures:
>>
>> https://www.postgresql.org/docs/12/xproc.html
>>
>> but that has no mention of transactions, just a mention of using CALL,
>> then this pl/pgSQL section about transaction control mentions CALL:
>>
>> https://www.postgresql.org/docs/12/plpgsql-transactions.html
>>
>> Is this what you think needs improving?
>>
>> Neither of those places mention that procedures cannot be called inside a
> transaction.
> So ya I think there there is some room for improvement
>
> Dave Cramer
> www.postgres.rocks
>
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-06 22:10 Bruce Momjian <bruce@momjian.us>
parent: Robin Abbi <robin.abbi@downley.net>
0 siblings, 1 reply; 24+ messages in thread
From: Bruce Momjian @ 2020-08-06 22:10 UTC (permalink / raw)
To: Robin Abbi <robin.abbi@downley.net>; +Cc: Dave Cramer <davecramer@postgres.rocks>; pgsql-docs@lists.postgresql.org
On Thu, Aug 6, 2020 at 02:30:55PM +0100, Robin Abbi wrote:
> PostgreSQL went as far as release 10 without procedures.
> Some third party resources written before 11 loosely conflate procedures with
> functions.
> Some third party resources written before 11 accurately state PostgreSQL has
> functions but not procedures.
> Referring to the PostgreSQL docs for 11 on, procedures have been added.
>
> For someone like me, coming to the subject without much of a hinterland other
> than googling around, it seemed clear that there was a motivating case that
> caused Procedures to be added to PostgreSQL, but I was not sufficiently
> familiar with the domain to be able to readily intuit what it might have been.
>
> For example, Procedures say they have no return value, yet Functions can return
> void. Not the same I agree, but I wouldn't be aware in which circumstances it
> mattered.
>
> For me, perhaps the most useful thing would have been a small example
> highlighting the essential thing(s) that procedures can do that functions could
> not.
Agreed, this doc area needs help.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-21 22:52 Bruce Momjian <bruce@momjian.us>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 2 replies; 24+ messages in thread
From: Bruce Momjian @ 2020-08-21 22:52 UTC (permalink / raw)
To: Robin Abbi <robin.abbi@downley.net>; +Cc: Dave Cramer <davecramer@postgres.rocks>; pgsql-docs@lists.postgresql.org
On Thu, Aug 6, 2020 at 06:10:52PM -0400, Bruce Momjian wrote:
> On Thu, Aug 6, 2020 at 02:30:55PM +0100, Robin Abbi wrote:
> > PostgreSQL went as far as release 10 without procedures.
> > Some third party resources written before 11 loosely conflate procedures with
> > functions.
> > Some third party resources written before 11 accurately state PostgreSQL has
> > functions but not procedures.
> > Referring to the PostgreSQL docs for 11 on, procedures have been added.
> >
> > For someone like me, coming to the subject without much of a hinterland other
> > than googling around, it seemed clear that there was a motivating case that
> > caused Procedures to be added to PostgreSQL, but I was not sufficiently
> > familiar with the domain to be able to readily intuit what it might have been.
> >
> > For example, Procedures say they have no return value, yet Functions can return
> > void. Not the same I agree, but I wouldn't be aware in which circumstances it
> > mattered.
> >
> > For me, perhaps the most useful thing would have been a small example
> > highlighting the essential thing(s) that procedures can do that functions could
> > not.
>
> Agreed, this doc area needs help.
I developed the attached patach for this. Is this sufficient?
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
Attachments:
proc.diff (text/x-diff, 653B) download
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index 6de464c654..0b52feffe5 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -83,7 +83,8 @@
<para>
A procedure is a database object similar to a function. The difference is
that a procedure does not return a value, so there is no return type
- declaration. While a function is called as part of a query or DML
+ declaration. Procedures can also begin and commit transactions.
+ While a function is called as part of a query or DML
command, a procedure is called explicitly using
the <xref linkend="sql-call"/> statement.
</para>
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-22 02:42 David G. Johnston <david.g.johnston@gmail.com>
parent: Bruce Momjian <bruce@momjian.us>
1 sibling, 1 reply; 24+ messages in thread
From: David G. Johnston @ 2020-08-22 02:42 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
On Fri, Aug 21, 2020 at 3:52 PM Bruce Momjian <bruce@momjian.us> wrote:
>
> > Agreed, this doc area needs help.
>
> I developed the attached patach for this. Is this sufficient?
>
For consistency I would change "statement" to "command" at the end of that
paragraph .
the <xref linkend="sql-call"/> command.
and to contrast with "a part of" I would modify the following fragment to
read:
a procedure is called in isolation
Taken together:
While a function is called as part of a query or DML command, a procedure
is called in isolation using the <xref linked="sql-call"/> command.
And then swap the order of, and tweak, the transaction and isolation
sentences:
[...] the CALL command. If the CALL command is not part of an explicit
transaction a procedure can also manage multiple transactions during its
execution.
David J.
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-22 11:05 Robin Abbi <robin.abbi@downley.net>
parent: Bruce Momjian <bruce@momjian.us>
1 sibling, 2 replies; 24+ messages in thread
From: Robin Abbi @ 2020-08-22 11:05 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Dave Cramer <davecramer@postgres.rocks>; pgsql-docs@lists.postgresql.org
On Fri, 21 Aug 2020 at 23:52, Bruce Momjian <bruce@momjian.us> wrote:
> I developed the attached patach for this. Is this sufficient?
>
Would it be appropriate to consider including some language with a similar
information content to this
> " ... prior to PostgreSQL 11, these functions were unable to manage their
> own transactions. PostgreSQL 11 adds SQL procedures that can perform full
> transaction management within the body of a function, enabling developers
> to create more advanced server-side applications, such as ones involving
> incremental bulk data loading."
>
from here https://www.postgresql.org/about/news/1894/ .
Robin Abbi
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-22 15:34 David G. Johnston <david.g.johnston@gmail.com>
parent: Robin Abbi <robin.abbi@downley.net>
1 sibling, 0 replies; 24+ messages in thread
From: David G. Johnston @ 2020-08-22 15:34 UTC (permalink / raw)
To: Jürgen Purtz <juergen@purtz.de>; +Cc: pgsql-docs@lists.postgresql.org <pgsql-docs@lists.postgresql.org>
On Saturday, August 22, 2020, Jürgen Purtz <juergen@purtz.de> wrote:
> On 22.08.20 13:05, Robin Abbi wrote:
>
> On Fri, 21 Aug 2020 at 23:52, Bruce Momjian <bruce@momjian.us> wrote:
>
>> I developed the attached patach for this. Is this sufficient?
>>
>
> Would it be appropriate to consider including some language with a similar
> information content to this
>
>> " ... prior to PostgreSQL 11, these functions were unable to manage their
>> own transactions. PostgreSQL 11 adds SQL procedures that can perform full
>> transaction management within the body of a function, enabling developers
>> to create more advanced server-side applications, such as ones involving
>> incremental bulk data loading."
>>
> from here https://www.postgresql.org/about/news/1894/ .
>
> Robin Abbi
>
> Can we more clearly distinguish between "function" and "procedure"? eg:
> "Developers have been able to create user-defined functions in PostgreSQL
> since decades, but functions are unable to manage their own transactions.
> PostgreSQL 11 adds SQL procedures that can perform full transaction
> management within their body, enabling developers to create more advanced
> server-side applications, such as ones involving incremental bulk data
> loading."
>
> as a modification of the original release notes:
>
> "Developers have been able to create user-defined functions in PostgreSQL
> for over 20 years, but prior to PostgreSQL 11, these functions were unable
> to manage their own transactions. PostgreSQL 11 adds SQL procedures that
> can perform full transaction management within the body of a function,
> enabling developers to create more advanced server-side applications, such
> as ones involving incremental bulk data loading."
>
Neither the 20 years or mention of specific versions are included in the
main body of the documentation. If a feature exists its documented in that
version in such a manner as “this is how things are”.
Replacing “their body” with “the body of a function” isn’t an improvement.
David J.
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-22 17:08 Bruce Momjian <bruce@momjian.us>
parent: Robin Abbi <robin.abbi@downley.net>
1 sibling, 0 replies; 24+ messages in thread
From: Bruce Momjian @ 2020-08-22 17:08 UTC (permalink / raw)
To: Robin Abbi <robin.abbi@downley.net>; +Cc: Dave Cramer <davecramer@postgres.rocks>; pgsql-docs@lists.postgresql.org
On Sat, Aug 22, 2020 at 12:05:24PM +0100, Robin Abbi wrote:
> On Fri, 21 Aug 2020 at 23:52, Bruce Momjian <bruce@momjian.us> wrote:
>
> I developed the attached patach for this. Is this sufficient?
>
>
> Would it be appropriate to consider including some language with a similar
> information content to this
>
> " ... prior to PostgreSQL 11, these functions were unable to manage their
> own transactions. PostgreSQL 11 adds SQL procedures that can perform full
> transaction management within the body of a function, enabling developers
> to create more advanced server-side applications, such as ones involving
> incremental bulk data loading."
>
> from here https://www.postgresql.org/about/news/1894/ .
No, we would only mention it if there some kind of incompatibility here.
We always have to balance adding text with making the text longer and
harder to read.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-22 20:21 David G. Johnston <david.g.johnston@gmail.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 24+ messages in thread
From: David G. Johnston @ 2020-08-22 20:21 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
On Sat, Aug 22, 2020 at 10:14 AM Bruce Momjian <bruce@momjian.us> wrote:
> On Fri, Aug 21, 2020 at 07:42:35PM -0700, David G. Johnston wrote:
>
> > [...] the CALL command. If the CALL command is not part of an explicit
> > transaction a procedure can also manage multiple transactions during its
> > execution.
>
> OK, how is this updated patch?
>
Looks good. I felt "begin and commit" was a bit wordy but it works.
David J.
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-24 15:00 Bruce Momjian <bruce@momjian.us>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 1 reply; 24+ messages in thread
From: Bruce Momjian @ 2020-08-24 15:00 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
On Sat, Aug 22, 2020 at 01:21:43PM -0700, David G. Johnston wrote:
> On Sat, Aug 22, 2020 at 10:14 AM Bruce Momjian <bruce@momjian.us> wrote:
>
> On Fri, Aug 21, 2020 at 07:42:35PM -0700, David G. Johnston wrote:
>
> > [...] the CALL command. If the CALL command is not part of an explicit
> > transaction a procedure can also manage multiple transactions during its
> > execution.
>
> OK, how is this updated patch?
>
>
> Looks good. I felt "begin and commit" was a bit wordy but it works.
So, I was worried that "manage multiple transactions" could imply
something like savepoints, which can be managed by functions. It is
really the top-level begin/commit that is unique for procedures.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-24 15:24 Pavel Stehule <pavel.stehule@gmail.com>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 24+ messages in thread
From: Pavel Stehule @ 2020-08-24 15:24 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
po 24. 8. 2020 v 17:01 odesílatel Bruce Momjian <bruce@momjian.us> napsal:
> On Sat, Aug 22, 2020 at 01:21:43PM -0700, David G. Johnston wrote:
> > On Sat, Aug 22, 2020 at 10:14 AM Bruce Momjian <bruce@momjian.us> wrote:
> >
> > On Fri, Aug 21, 2020 at 07:42:35PM -0700, David G. Johnston wrote:
> >
> > > [...] the CALL command. If the CALL command is not part of an
> explicit
> > > transaction a procedure can also manage multiple transactions
> during its
> > > execution.
> >
> > OK, how is this updated patch?
> >
> >
> > Looks good. I felt "begin and commit" was a bit wordy but it works.
>
> So, I was worried that "manage multiple transactions" could imply
> something like savepoints, which can be managed by functions. It is
> really the top-level begin/commit that is unique for procedures.
>
Functions is executed under outer transaction every time - rollback to save
point hasn't impact on outer transaction. Inside procedures (in special
case) can be transactions ended (by statements COMMIT or ROLLBACK).
Immediately is started new transaction.
>
> --
> Bruce Momjian <bruce@momjian.us> https://momjian.us
> EnterpriseDB https://enterprisedb.com
>
> The usefulness of a cup is in its emptiness, Bruce Lee
>
>
>
>
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-24 15:35 Bruce Momjian <bruce@momjian.us>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 1 reply; 24+ messages in thread
From: Bruce Momjian @ 2020-08-24 15:35 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
On Mon, Aug 24, 2020 at 05:24:19PM +0200, Pavel Stehule wrote:
>
>
> po 24. 8. 2020 v 17:01 odesílatel Bruce Momjian <bruce@momjian.us> napsal:
>
> On Sat, Aug 22, 2020 at 01:21:43PM -0700, David G. Johnston wrote:
> > On Sat, Aug 22, 2020 at 10:14 AM Bruce Momjian <bruce@momjian.us> wrote:
> >
> > On Fri, Aug 21, 2020 at 07:42:35PM -0700, David G. Johnston wrote:
> >
> > > [...] the CALL command. If the CALL command is not part of an
> explicit
> > > transaction a procedure can also manage multiple transactions
> during its
> > > execution.
> >
> > OK, how is this updated patch?
> >
> >
> > Looks good. I felt "begin and commit" was a bit wordy but it works.
>
> So, I was worried that "manage multiple transactions" could imply
> something like savepoints, which can be managed by functions. It is
> really the top-level begin/commit that is unique for procedures.
>
> Functions is executed under outer transaction every time - rollback to save
> point hasn't impact on outer transaction. Inside procedures (in special case)
> can be transactions ended (by statements COMMIT or ROLLBACK). Immediately is
> started new transaction.
Well, savepoints control what commands are considered _part_ of the
outer transaction, so in a way you are managing what is in the outer
transaction. This is why begin/commit was clearer for me. Maybe "start
and commit" is clearer?
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-24 15:51 Pavel Stehule <pavel.stehule@gmail.com>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 1 reply; 24+ messages in thread
From: Pavel Stehule @ 2020-08-24 15:51 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
po 24. 8. 2020 v 17:38 odesílatel Bruce Momjian <bruce@momjian.us> napsal:
> On Mon, Aug 24, 2020 at 11:35:57AM -0400, Bruce Momjian wrote:
> > On Mon, Aug 24, 2020 at 05:24:19PM +0200, Pavel Stehule wrote:
> > >
> > >
> > > po 24. 8. 2020 v 17:01 odesílatel Bruce Momjian <bruce@momjian.us>
> napsal:
> > >
> > > On Sat, Aug 22, 2020 at 01:21:43PM -0700, David G. Johnston wrote:
> > > > On Sat, Aug 22, 2020 at 10:14 AM Bruce Momjian <bruce@momjian.us>
> wrote:
> > > >
> > > > On Fri, Aug 21, 2020 at 07:42:35PM -0700, David G. Johnston
> wrote:
> > > >
> > > > > [...] the CALL command. If the CALL command is not part
> of an
> > > explicit
> > > > > transaction a procedure can also manage multiple
> transactions
> > > during its
> > > > > execution.
> > > >
> > > > OK, how is this updated patch?
> > > >
> > > >
> > > > Looks good. I felt "begin and commit" was a bit wordy but it
> works.
> > >
> > > So, I was worried that "manage multiple transactions" could imply
> > > something like savepoints, which can be managed by functions. It
> is
> > > really the top-level begin/commit that is unique for procedures.
> > >
> > > Functions is executed under outer transaction every time - rollback to
> save
> > > point hasn't impact on outer transaction. Inside procedures (in
> special case)
> > > can be transactions ended (by statements COMMIT or ROLLBACK).
> Immediately is
> > > started new transaction.
> >
> > Well, savepoints control what commands are considered _part_ of the
> > outer transaction, so in a way you are managing what is in the outer
> > transaction. This is why begin/commit was clearer for me. Maybe "start
> > and commit" is clearer?
>
> Should the new text be?
>
> a procedure can commit and begin new transactions during its
> execution.
>
sure. Maybe enhancing about sentence like "it is not possible in a
function."
and
"a procedure can commit (or rollback) and begin new transactions during its
execution"
> --
> Bruce Momjian <bruce@momjian.us> https://momjian.us
> EnterpriseDB https://enterprisedb.com
>
> The usefulness of a cup is in its emptiness, Bruce Lee
>
>
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-24 16:00 Bruce Momjian <bruce@momjian.us>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 2 replies; 24+ messages in thread
From: Bruce Momjian @ 2020-08-24 16:00 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
On Mon, Aug 24, 2020 at 05:51:29PM +0200, Pavel Stehule wrote:
> sure. Maybe enhancing about sentence like "it is not possible in a function."
>
> and
>
> "a procedure can commit (or rollback) and begin new transactions during its
> execution"
OK, updated patch.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
Attachments:
proc.diff (text/x-diff, 823B) download
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index 6de464c654..5dda2a80af 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -84,8 +84,11 @@
A procedure is a database object similar to a function. The difference is
that a procedure does not return a value, so there is no return type
declaration. While a function is called as part of a query or DML
- command, a procedure is called explicitly using
- the <xref linkend="sql-call"/> statement.
+ command, a procedure is called in isolation using
+ the <xref linkend="sql-call"/> command. If the CALL command is not
+ part of an explicit transaction, a procedure can commit, rollback,
+ and begin new transactions during its execution, which is not possible
+ in functions.
</para>
<para>
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-24 16:08 Pavel Stehule <pavel.stehule@gmail.com>
parent: Bruce Momjian <bruce@momjian.us>
1 sibling, 1 reply; 24+ messages in thread
From: Pavel Stehule @ 2020-08-24 16:08 UTC (permalink / raw)
To: Bruce Momjian <bruce@momjian.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
po 24. 8. 2020 v 18:00 odesílatel Bruce Momjian <bruce@momjian.us> napsal:
> On Mon, Aug 24, 2020 at 05:51:29PM +0200, Pavel Stehule wrote:
> > sure. Maybe enhancing about sentence like "it is not possible in a
> function."
> >
> > and
> >
> > "a procedure can commit (or rollback) and begin new transactions during
> its
> > execution"
>
> OK, updated patch.
>
it is clean for me
> --
> Bruce Momjian <bruce@momjian.us> https://momjian.us
> EnterpriseDB https://enterprisedb.com
>
> The usefulness of a cup is in its emptiness, Bruce Lee
>
>
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-24 16:35 David G. Johnston <david.g.johnston@gmail.com>
parent: Pavel Stehule <pavel.stehule@gmail.com>
0 siblings, 0 replies; 24+ messages in thread
From: David G. Johnston @ 2020-08-24 16:35 UTC (permalink / raw)
To: Pavel Stehule <pavel.stehule@gmail.com>; +Cc: Bruce Momjian <bruce@momjian.us>; Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
On Mon, Aug 24, 2020 at 9:09 AM Pavel Stehule <pavel.stehule@gmail.com>
wrote:
>
>
> po 24. 8. 2020 v 18:00 odesílatel Bruce Momjian <bruce@momjian.us> napsal:
>
>> On Mon, Aug 24, 2020 at 05:51:29PM +0200, Pavel Stehule wrote:
>> > sure. Maybe enhancing about sentence like "it is not possible in a
>> function."
>> >
>> > and
>> >
>> > "a procedure can commit (or rollback) and begin new transactions during
>> its
>> > execution"
>>
>> OK, updated patch.
>>
>
> it is clean for me
>
Works for me. I wasn't thinking about the implication of the wording with
respect to Savepoints in functions.
David J.
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-25 19:03 Bruce Momjian <bruce@momjian.us>
parent: Bruce Momjian <bruce@momjian.us>
1 sibling, 1 reply; 24+ messages in thread
From: Bruce Momjian @ 2020-08-25 19:03 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Pavel Stehule <pavel.stehule@gmail.com>; David G. Johnston <david.g.johnston@gmail.com>; Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
On Tue, Aug 25, 2020 at 08:38:11PM +0200, Peter Eisentraut wrote:
> On 2020-08-24 18:00, Bruce Momjian wrote:
> > - command, a procedure is called explicitly using
> > - the <xref linkend="sql-call"/> statement.
> > + command, a procedure is called in isolation using
> > + the <xref linkend="sql-call"/> command. If the CALL command is not
> > + part of an explicit transaction, a procedure can commit, rollback,
> > + and begin new transactions during its execution, which is not possible
> > + in functions.
>
> There are additional conditions for when a procedure can do transaction
> control, and it also depends on the language. It's not clear how much
> detail we should give in a general section like this. Often people read
> this and then wonder why it doesn't work.
I have updated the patch to mention it is dependend on the server-side
language.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
Attachments:
proc.diff (text/x-diff, 853B) download
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index 6de464c654..732d935521 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -84,8 +84,11 @@
A procedure is a database object similar to a function. The difference is
that a procedure does not return a value, so there is no return type
declaration. While a function is called as part of a query or DML
- command, a procedure is called explicitly using
- the <xref linkend="sql-call"/> statement.
+ command, a procedure is called in isolation using
+ the <xref linkend="sql-call"/> command. If the CALL command is not
+ part of an explicit transaction, a procedure in many server-side
+ languages can commit, rollback, and begin new transactions during
+ its execution, which is not possible in functions.
</para>
<para>
^ permalink raw reply [nested|flat] 24+ messages in thread
* Re: Procedures
@ 2020-08-31 17:20 Bruce Momjian <bruce@momjian.us>
parent: Bruce Momjian <bruce@momjian.us>
0 siblings, 0 replies; 24+ messages in thread
From: Bruce Momjian @ 2020-08-31 17:20 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Pavel Stehule <pavel.stehule@gmail.com>; David G. Johnston <david.g.johnston@gmail.com>; Robin Abbi <robin.abbi@downley.net>; Dave Cramer <davecramer@postgres.rocks>; Pg Docs <pgsql-docs@lists.postgresql.org>
On Tue, Aug 25, 2020 at 03:03:13PM -0400, Bruce Momjian wrote:
> On Tue, Aug 25, 2020 at 08:38:11PM +0200, Peter Eisentraut wrote:
> > On 2020-08-24 18:00, Bruce Momjian wrote:
> > > - command, a procedure is called explicitly using
> > > - the <xref linkend="sql-call"/> statement.
> > > + command, a procedure is called in isolation using
> > > + the <xref linkend="sql-call"/> command. If the CALL command is not
> > > + part of an explicit transaction, a procedure can commit, rollback,
> > > + and begin new transactions during its execution, which is not possible
> > > + in functions.
> >
> > There are additional conditions for when a procedure can do transaction
> > control, and it also depends on the language. It's not clear how much
> > detail we should give in a general section like this. Often people read
> > this and then wonder why it doesn't work.
>
> I have updated the patch to mention it is dependend on the server-side
> language.
Patch applied back through PG 11.
--
Bruce Momjian <bruce@momjian.us> https://momjian.us
EnterpriseDB https://enterprisedb.com
The usefulness of a cup is in its emptiness, Bruce Lee
^ permalink raw reply [nested|flat] 24+ messages in thread
end of thread, other threads:[~2020-08-31 17:20 UTC | newest]
Thread overview: 24+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-08-04 10:33 Procedures PG Doc comments form <noreply@postgresql.org>
2020-08-06 00:17 ` Bruce Momjian <bruce@momjian.us>
2020-08-06 10:32 ` Dave Cramer <davecramer@postgres.rocks>
2020-08-06 13:30 ` Robin Abbi <robin.abbi@downley.net>
2020-08-06 22:10 ` Bruce Momjian <bruce@momjian.us>
2020-08-21 22:52 ` Bruce Momjian <bruce@momjian.us>
2020-08-22 02:42 ` David G. Johnston <david.g.johnston@gmail.com>
2020-08-22 20:21 ` David G. Johnston <david.g.johnston@gmail.com>
2020-08-24 15:00 ` Bruce Momjian <bruce@momjian.us>
2020-08-24 15:24 ` Pavel Stehule <pavel.stehule@gmail.com>
2020-08-24 15:35 ` Bruce Momjian <bruce@momjian.us>
2020-08-24 15:51 ` Pavel Stehule <pavel.stehule@gmail.com>
2020-08-24 16:00 ` Bruce Momjian <bruce@momjian.us>
2020-08-24 16:08 ` Pavel Stehule <pavel.stehule@gmail.com>
2020-08-24 16:35 ` David G. Johnston <david.g.johnston@gmail.com>
2020-08-25 19:03 ` Bruce Momjian <bruce@momjian.us>
2020-08-31 17:20 ` Bruce Momjian <bruce@momjian.us>
2020-08-22 11:05 ` Robin Abbi <robin.abbi@downley.net>
2020-08-22 15:34 ` David G. Johnston <david.g.johnston@gmail.com>
2020-08-22 17:08 ` Bruce Momjian <bruce@momjian.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox