Re: TODO: Add a GUC to control whether BEGIN inside

Lists: pgsql-hackers
From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: TODO: Add a GUC to control whether BEGIN inside a transcation should abort the transaction.
Date: 2006-12-28 17:38:56
Message-ID: 1167327536.24530.24.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

Is this really a TODO or is this someone being overzealous with the TODO
list?

Joshua D. Drake

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2006-12-28 17:57:25
Message-ID: 200612281757.kBSHvPP15655@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Joshua D. Drake wrote:
> Hello,
>
> Is this really a TODO or is this someone being overzealous with the TODO
> list?

> Add a GUC to control whether BEGIN inside a transcation should abort
> the transaction.

Well, right now, BEGIN inside a transaction just issues a warning:

test=> BEGIN;
BEGIN
test=> BEGIN;
WARNING: there is already a transaction in progress
BEGIN
test=> SELECT 1;
?column?
----------
1
(1 row)

test=> COMMIT;
COMMIT

I think you can make the case that this should be an error, or at least
that's how it got on the TODO list. I can always remove it if people
don't want the item completed.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2006-12-28 18:10:05
Message-ID: 1167329405.24530.41.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

> 1
> (1 row)
>
> test=> COMMIT;
> COMMIT
>
> I think you can make the case that this should be an error, or at least
> that's how it got on the TODO list. I can always remove it if people
> don't want the item completed.

Well I can tell you that my customers who are postgresql users ;) would
howl in fury if we did that. They are already significantly irritated
that certain errors are so strict. E.g.,

postgres=# BEGIN;
BEGIN
postgres=# ALTER TABLE baz ADD COLUMN bar text;
ERROR: relation "baz" does not exist
postgres=# SELECT * FROM foo;
ERROR: current transaction is aborted, commands ignored until end of
transaction block

You do not need to argue with me about the purpose :), I understand why
it is just really frustrating for many users.

I would say that a GUC variable for such behavior as listed in the TODO
is overzealous. We should either enforce it, or not. As we do not now,
there is no reason imo to change it.

Sincerely,

Joshua D. Drake

--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2006-12-28 18:52:26
Message-ID: 22676.1167331946@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

"Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> I would say that a GUC variable for such behavior as listed in the TODO
> is overzealous. We should either enforce it, or not. As we do not now,
> there is no reason imo to change it.

Not only is it overzealous, but the proposal to have one reflects a
failure to learn from history. GUC variables that change
transaction-boundary semantics are a bad idea, period: see autocommit.

regards, tom lane


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2006-12-28 19:02:16
Message-ID: 1167332536.24530.59.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thu, 2006-12-28 at 13:52 -0500, Tom Lane wrote:
> "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> > I would say that a GUC variable for such behavior as listed in the TODO
> > is overzealous. We should either enforce it, or not. As we do not now,
> > there is no reason imo to change it.
>
> Not only is it overzealous, but the proposal to have one reflects a
> failure to learn from history. GUC variables that change
> transaction-boundary semantics are a bad idea, period: see autocommit.

Nod. Let's get this TODO removed.

Sincerely,

Joshua D. Drake

>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
> http://archives.postgresql.org
>
--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate


From: Bruce Momjian <bruce(at)momjian(dot)us>
To: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2006-12-28 20:44:07
Message-ID: 200612282044.kBSKi7a04021@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Joshua D. Drake wrote:
> On Thu, 2006-12-28 at 13:52 -0500, Tom Lane wrote:
> > "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> > > I would say that a GUC variable for such behavior as listed in the TODO
> > > is overzealous. We should either enforce it, or not. As we do not now,
> > > there is no reason imo to change it.
> >
> > Not only is it overzealous, but the proposal to have one reflects a
> > failure to learn from history. GUC variables that change
> > transaction-boundary semantics are a bad idea, period: see autocommit.
>
> Nod. Let's get this TODO removed.

OK, removed.

--
Bruce Momjian bruce(at)momjian(dot)us
EnterpriseDB http://www.enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +


From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2006-12-29 04:24:28
Message-ID: 200612282324.29083.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Thursday 28 December 2006 15:44, Bruce Momjian wrote:
> Joshua D. Drake wrote:
> > On Thu, 2006-12-28 at 13:52 -0500, Tom Lane wrote:
> > > "Joshua D. Drake" <jd(at)commandprompt(dot)com> writes:
> > > > I would say that a GUC variable for such behavior as listed in the
> > > > TODO is overzealous. We should either enforce it, or not. As we do
> > > > not now, there is no reason imo to change it.
> > >
> > > Not only is it overzealous, but the proposal to have one reflects a
> > > failure to learn from history. GUC variables that change
> > > transaction-boundary semantics are a bad idea, period: see autocommit.
> >
> > Nod. Let's get this TODO removed.
>
> OK, removed.

I thought this was needed for spec compliance? If we have no plans to even
attempt to support it, istm that ought to be noted someplace.

--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Bruce Momjian <bruce(at)momjian(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2006-12-29 04:39:37
Message-ID: 28156.1167367177@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> writes:
> I thought this was needed for spec compliance?

BEGIN isn't in the spec at all ...

Now you could point to the spec for START TRANSACTION, which saith

1) If a <start transaction statement> statement is executed when an
SQL-transaction is currently active, then an exception condition
is raised: invalid transaction state - active SQL-transaction.

However, seeing that the spec doesn't think that an exception necessarily
aborts the transaction, I think the case for saying that ERROR is more
spec-compliant here than WARNING is mighty thin.

And if you want to hold our feet to the fire about whether errors abort
transactions or not, this particular point is not one thousandth part
of what would need to change.

regards, tom lane


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 10:50:41
Message-ID: 200701021150.43684.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Am Donnerstag, 28. Dezember 2006 19:52 schrieb Tom Lane:
> Not only is it overzealous, but the proposal to have one reflects a
> failure to learn from history. GUC variables that change
> transaction-boundary semantics are a bad idea, period: see autocommit.

But this option would not, in fact, change the transaction-boundary semantics.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Bruce Momjian <bruce(at)momjian(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 10:53:17
Message-ID: 200701021153.18689.peter_e@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Am Donnerstag, 28. Dezember 2006 18:57 schrieb Bruce Momjian:
> I think you can make the case that this should be an error, or at least
> that's how it got on the TODO list. I can always remove it if people
> don't want the item completed.

The reason this was added is that modular applications expect that a locally
issued BEGIN ... COMMIT executes a transaction, whereas now you don't know
what you're getting. I think this change would have merit.

--
Peter Eisentraut
http://developer.postgresql.org/~petere/


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Bruce Momjian <bruce(at)momjian(dot)us>, "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 15:00:24
Message-ID: 3340.1167750024@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
> Am Donnerstag, 28. Dezember 2006 18:57 schrieb Bruce Momjian:
>> I think you can make the case that this should be an error, or at least
>> that's how it got on the TODO list. I can always remove it if people
>> don't want the item completed.

> The reason this was added is that modular applications expect that a locally
> issued BEGIN ... COMMIT executes a transaction, whereas now you don't know
> what you're getting. I think this change would have merit.

But how is making BEGIN an error going to improve life for such an
application? It'll be just as broken. In fact, if the app depends on
getting an error from BEGIN in any critical way, it'll be *more* broken
if it's ever run under the default warning-only setting.

regards, tom lane


From: "news(dot)postgresql(dot)org" <smith(at)pooteeweet(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 16:34:05
Message-ID: 459A897D.1060601@pooteeweet.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Peter Eisentraut <peter_e(at)gmx(dot)net> writes:
>> Am Donnerstag, 28. Dezember 2006 18:57 schrieb Bruce Momjian:
>>> I think you can make the case that this should be an error, or at least
>>> that's how it got on the TODO list. I can always remove it if people
>>> don't want the item completed.
>
>> The reason this was added is that modular applications expect that a locally
>> issued BEGIN ... COMMIT executes a transaction, whereas now you don't know
>> what you're getting. I think this change would have merit.
>
> But how is making BEGIN an error going to improve life for such an
> application? It'll be just as broken. In fact, if the app depends on
> getting an error from BEGIN in any critical way, it'll be *more* broken
> if it's ever run under the default warning-only setting.

While we are on the topic, I have implemented a poor mans nested
transaction feature into my database access layer. essentially
subsequent calls to begin a transaction after the initial begin simply
increase an internal counter and set a savepoint. as you commit the
transactions the counter is decreased and the savepoints are released.
maybe this could be implemented inside postgresql to make the life of
modular programmers easier?

regards,
Lukas


From: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
To: "news(dot)postgresql(dot)org" <smith(at)pooteeweet(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 16:42:36
Message-ID: 20070102164236.GC21867@alvh.no-ip.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

news.postgresql.org wrote:

> While we are on the topic, I have implemented a poor mans nested
> transaction feature into my database access layer. essentially
> subsequent calls to begin a transaction after the initial begin simply
> increase an internal counter and set a savepoint. as you commit the
> transactions the counter is decreased and the savepoints are released.
> maybe this could be implemented inside postgresql to make the life of
> modular programmers easier?

Yeah, it's called "SAVEPOINT foo" and "RELEASE foo".

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support


From: Lukas Kahwe Smith <smith(at)pooteeweet(dot)org>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 16:48:15
Message-ID: 459A8CCF.1090408@pooteeweet.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera wrote:
> news.postgresql.org wrote:
>
>> While we are on the topic, I have implemented a poor mans nested
>> transaction feature into my database access layer. essentially
>> subsequent calls to begin a transaction after the initial begin simply
>> increase an internal counter and set a savepoint. as you commit the
>> transactions the counter is decreased and the savepoints are released.
>> maybe this could be implemented inside postgresql to make the life of
>> modular programmers easier?
>
> Yeah, it's called "SAVEPOINT foo" and "RELEASE foo".

Err, I think you misunderstood what I said. My implementation uses
SAVEPOINTs already. The point is having some API where you do not have
to care of you are already in a transaction or not. Depending on if you
are it will either open a new transaction or simply place a savepoint.

with the following invented commands:
MBEGIN FOO1 // open transaction; set counter to 1
MBEGIN FOO2 // set savepoint FOO2; set counter to 2
MBEGIN FOO3 // set savepoint FOO3; set counter to 3
MROLLBACK FOO3 // rollback to FOO3; set counter to 2
MCOMMIT FOO2 // release FOO2; set counter to 1
MCOMMIT FOO1 // commit

regards,
Lukas

regards,
Lukas


From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: pgsql-hackers(at)postgresql(dot)org, Bruce Momjian <bruce(at)momjian(dot)us>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 17:26:05
Message-ID: 1167758765.8485.7.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2007-01-02 at 11:53 +0100, Peter Eisentraut wrote:
> Am Donnerstag, 28. Dezember 2006 18:57 schrieb Bruce Momjian:
> > I think you can make the case that this should be an error, or at least
> > that's how it got on the TODO list. I can always remove it if people
> > don't want the item completed.
>
> The reason this was added is that modular applications expect that a locally
> issued BEGIN ... COMMIT executes a transaction, whereas now you don't know
> what you're getting. I think this change would have merit.

Interesting point. My only comment is, "Do it one way or the other,
don't give me a user or a distribution packager a foot gun."

E.g., no GUC parameter. Just change the behavior or don't.

Joshua D. Drake

>
--

=== The PostgreSQL Company: Command Prompt, Inc. ===
Sales/Support: +1.503.667.4564 || 24x7/Emergency: +1.800.492.2240
Providing the most comprehensive PostgreSQL solutions since 1997
http://www.commandprompt.com/

Donate to the PostgreSQL Project: http://www.postgresql.org/about/donate


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Lukas Kahwe Smith <smith(at)pooteeweet(dot)org>
Cc: Alvaro Herrera <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 17:33:25
Message-ID: 5932.1167759205@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Lukas Kahwe Smith <smith(at)pooteeweet(dot)org> writes:
> Err, I think you misunderstood what I said. My implementation uses
> SAVEPOINTs already. The point is having some API where you do not have
> to care of you are already in a transaction or not.

It's not that hard, is it?

if (PQtransactionStatus(conn) == PQTRANS_IDLE)
PQexec(conn, "BEGIN");
else
PQexec(conn, "SAVEPOINT foo");

regards, tom lane


From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: "PGSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Cc: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 18:04:46
Message-ID: 65937bea0701021004l459dd3e2ob6366d5e78742136@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 1/2/07, Joshua D. Drake <jd(at)commandprompt(dot)com> wrote:
>
> E.g., no GUC parameter. Just change the behavior or don't.
>
>
Please refer the conversation beginning at:
http://archives.postgresql.org/pgsql-hackers/2006-05/msg00249.php

That is where this TODO item came from. In the conversation, it was
understood that such a change would break many applications, hence one of
the option was to introduce a GUC var and keep it on by default, and a
couple of releases later, remove the GUC and make the behaviour default (
http://archives.postgresql.org/pgsql-hackers/2006-05/msg00273.php).

This would help the programmers can realize that they are doing something
wrong, and they can make appropriate changes to their code.

The usability of the GUC comes in a production environment, where it is not
possible to change the application. The DBA can buy some time by turning the
GUC var off.

I submitted a patch, which was incorrect and incomplete as I was _very_ new
to PGSQL. I could not follow up on it as I was switching jobs at the time.

Tom objected to the default=ON setting for the GUC.

The TODO has been declared "misconceived", but I guess there's still
interest out here. Would like to finish it once we reach a consensus.

Best regards,

--
gurjeet[(dot)singh](at)EnterpriseDB(dot)com
singh(dot)gurjeet(at){ gmail | hotmail | yahoo }.com


From: Lukas Kahwe Smith <smith(at)pooteeweet(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-02 19:01:57
Message-ID: 459AAC25.4060207@pooteeweet.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Tom Lane wrote:
> Lukas Kahwe Smith <smith(at)pooteeweet(dot)org> writes:
>> Err, I think you misunderstood what I said. My implementation uses
>> SAVEPOINTs already. The point is having some API where you do not have
>> to care of you are already in a transaction or not.
>
> It's not that hard, is it?
>
> if (PQtransactionStatus(conn) == PQTRANS_IDLE)
> PQexec(conn, "BEGIN");
> else
> PQexec(conn, "SAVEPOINT foo");

Its not exactly convenient either, especially in the case of modular
code that may be developed by different people. Anyways, like I said I
have a solution in my framework to make life of module developers
easier. Obviously proper nested transactions would be the ideal, but so
it goes. I was just throwing this out here when I saw Peter's comment.

regards,
Lukas


From: Jim Nasby <decibel(at)decibel(dot)org>
To: Lukas Kahwe Smith <smith(at)pooteeweet(dot)org>
Cc: pgsql-hackers(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-03 15:40:38
Message-ID: A1794C03-B429-4C3E-8394-26FBDE88786C@decibel.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Jan 2, 2007, at 2:01 PM, Lukas Kahwe Smith wrote:
> Tom Lane wrote:
>> Lukas Kahwe Smith <smith(at)pooteeweet(dot)org> writes:
>>> Err, I think you misunderstood what I said. My implementation
>>> uses SAVEPOINTs already. The point is having some API where you
>>> do not have to care of you are already in a transaction or not.
>> It's not that hard, is it?
>> if (PQtransactionStatus(conn) == PQTRANS_IDLE)
>> PQexec(conn, "BEGIN");
>> else
>> PQexec(conn, "SAVEPOINT foo");
>
> Its not exactly convenient either, especially in the case of
> modular code that may be developed by different people. Anyways,
> like I said I have a solution in my framework to make life of
> module developers easier. Obviously proper nested transactions
> would be the ideal, but so it goes. I was just throwing this out
> here when I saw Peter's comment.

+1. Right now it's not as big a deal since we don't allow transaction
control inside functions, but if we ever get that ability it will
become much more of a pain to write modular code that deals with
savepoints/subtransactions.
--
Jim Nasby jim(at)nasby(dot)net
EnterpriseDB http://enterprisedb.com 512.569.9461 (cell)


From: "Jaime Casanova" <systemguards(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Lukas Kahwe Smith" <smith(at)pooteeweet(dot)org>, "Alvaro Herrera" <alvherre(at)commandprompt(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: TODO: Add a GUC to control whether BEGIN inside
Date: 2007-01-04 01:42:20
Message-ID: c2d9e70e0701031742y7046407eu6e46b84a02afb6bf@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On 1/2/07, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Lukas Kahwe Smith <smith(at)pooteeweet(dot)org> writes:
> > Err, I think you misunderstood what I said. My implementation uses
> > SAVEPOINTs already. The point is having some API where you do not have
> > to care of you are already in a transaction or not.
>
> It's not that hard, is it?
>
> if (PQtransactionStatus(conn) == PQTRANS_IDLE)
> PQexec(conn, "BEGIN");
> else
> PQexec(conn, "SAVEPOINT foo");
>
> regards, tom lane
>

and how the releases and commit will happen? all at once or one by one?

--
regards,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
Richard Cook