8.0b4: COMMIT outside of a transaction echoes ROLLBACK

Lists: pgsql-hackers
From: Ian Barwick <barwick(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-26 19:19:14
Message-ID: 1d581afe04102612194fd0ae7c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

just wondering:

test=> select version();
version
------------------------------------------------------------------------------------------
PostgreSQL 8.0.0beta4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
3.3.3 (SuSE Linux)
(1 row)

test=> begin;
BEGIN
test=> commit;
COMMIT
test=> commit;
WARNING: there is no transaction in progress
ROLLBACK

Is there any reason ROLLBACK and not COMMIT is echoed here?

Ian Barwick
barwick(at)gmail(dot)com


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Ian Barwick <barwick(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-27 01:42:19
Message-ID: 200410270142.i9R1gJn16257@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Ian Barwick wrote:
> just wondering:
>
> test=> select version();
> version
> ------------------------------------------------------------------------------------------
> PostgreSQL 8.0.0beta4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
> 3.3.3 (SuSE Linux)
> (1 row)
>
> test=> begin;
> BEGIN
> test=> commit;
> COMMIT
> test=> commit;
> WARNING: there is no transaction in progress
> ROLLBACK
>
> Is there any reason ROLLBACK and not COMMIT is echoed here?

Because the transaction was not committed, but rather rolled back.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Ian Barwick <barwick(at)gmail(dot)com>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-27 06:42:13
Message-ID: 1d581afe04102623424ba97bfb@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 26 Oct 2004 21:42:19 -0400 (EDT), Bruce Momjian
<pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
> Ian Barwick wrote:
>
>
> > just wondering:
> >
> > test=> select version();
> > version
> > ------------------------------------------------------------------------------------------
> > PostgreSQL 8.0.0beta4 on i686-pc-linux-gnu, compiled by GCC gcc (GCC)
> > 3.3.3 (SuSE Linux)
> > (1 row)
> >
> > test=> begin;
> > BEGIN
> > test=> commit;
> > COMMIT
> > test=> commit;
> > WARNING: there is no transaction in progress
> > ROLLBACK
> >
> > Is there any reason ROLLBACK and not COMMIT is echoed here?
>
> Because the transaction was not committed, but rather rolled back.

Aha. It had me a little confused because between the first COMMIT and
the second there were several screens of data, and I wasn't sure if
I'd issued the first COMMIT. Seeing ROLLBACK made me unsure whether I
was still in a transaction which had in just been rolled back.

Pre 8.0 versions echo COMMIT in this situation.

Thanks

Ian Barwick
barwick(at)gmail(dot)com


From: Oliver Elphick <olly(at)lfix(dot)co(dot)uk>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Ian Barwick <barwick(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes
Date: 2004-10-27 14:59:21
Message-ID: 1098889161.32765.2.camel@linda
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Tue, 2004-10-26 at 21:42 -0400, Bruce Momjian wrote:
> > test=> begin;
> > BEGIN
> > test=> commit;
> > COMMIT
> > test=> commit;
> > WARNING: there is no transaction in progress
> > ROLLBACK
> >
> > Is there any reason ROLLBACK and not COMMIT is echoed here?
>
> Because the transaction was not committed, but rather rolled back.

It's still a misleading message; in those circumstances, how about
returning "NO ACTION" instead?

--
Oliver Elphick olly(at)lfix(dot)co(dot)uk
Isle of Wight http://www.lfix.co.uk/oliver
GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA
========================================
"If a man abide not in me, he is cast forth as a
branch, and is withered; and men gather them, and cast
them into the fire, and they are burned."
John 15:6


From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: olly(at)lfix(dot)co(dot)uk
Cc: Ian Barwick <barwick(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-27 18:00:25
Message-ID: 200410271800.i9RI0Po28721@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Oliver Elphick wrote:
> On Tue, 2004-10-26 at 21:42 -0400, Bruce Momjian wrote:
> > > test=> begin;
> > > BEGIN
> > > test=> commit;
> > > COMMIT
> > > test=> commit;
> > > WARNING: there is no transaction in progress
> > > ROLLBACK
> > >
> > > Is there any reason ROLLBACK and not COMMIT is echoed here?
> >
> > Because the transaction was not committed, but rather rolled back.
>
> It's still a misleading message; in those circumstances, how about
> returning "NO ACTION" instead?

Uh, it took a lot of discussion to agree on ROLLBACK. It would take
even more discussion to add a new tag return value.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: olly(at)lfix(dot)co(dot)uk, Ian Barwick <barwick(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-27 20:21:53
Message-ID: 24445.1098908513@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> writes:
> Oliver Elphick wrote:
>> On Tue, 2004-10-26 at 21:42 -0400, Bruce Momjian wrote:
>>> test=> begin;
>>> BEGIN
>>> test=> commit;
>>> COMMIT
>>> test=> commit;
>>> WARNING: there is no transaction in progress
>>> ROLLBACK
>>
>> It's still a misleading message; in those circumstances, how about
>> returning "NO ACTION" instead?

> Uh, it took a lot of discussion to agree on ROLLBACK. It would take
> even more discussion to add a new tag return value.

I don't care for "NO ACTION" either. However, the prior discussion had
to do with what to echo in the case that you are saying COMMIT in a
failed transaction. I don't think anyone thought about this particular
corner case, viz COMMIT outside any transaction. I think you could make
a reasonable argument that the tag should remain COMMIT for this case,
since we do not consider it an error.

On the other hand, it's also a pretty minor issue, and if it turns out
to require a lot of code rejiggering to make it do that, I'd not think
it worthwhile.

Comments?

regards, tom lane


From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, olly(at)lfix(dot)co(dot)uk, Ian Barwick <barwick(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-28 01:19:33
Message-ID: 20041028011933.GC6712@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 27, 2004 at 04:21:53PM -0400, Tom Lane wrote:

> On the other hand, it's also a pretty minor issue, and if it turns out
> to require a lot of code rejiggering to make it do that, I'd not think
> it worthwhile.

Patch attached. It passes the regression tests. It shouldn't have
secondary effects, but please test.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Pensar que el espectro que vemos es ilusorio no lo despoja de espanto,
sólo le suma el nuevo terror de la locura" (Perelandra, CSLewis)

Attachment Content-Type Size
commit.patch text/plain 879 bytes

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, olly(at)lfix(dot)co(dot)uk, Ian Barwick <barwick(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-28 01:29:21
Message-ID: 26773.1098926961@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> On Wed, Oct 27, 2004 at 04:21:53PM -0400, Tom Lane wrote:
>> On the other hand, it's also a pretty minor issue, and if it turns out
>> to require a lot of code rejiggering to make it do that, I'd not think
>> it worthwhile.

> Patch attached. It passes the regression tests. It shouldn't have
> secondary effects, but please test.

Wouldn't it be better to just stay in TBLOCK_STARTED state, as if the
COMMIT were just some random utility command?

In any case, the comment right above this needs adjustment ...

regards, tom lane


From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, olly(at)lfix(dot)co(dot)uk, Ian Barwick <barwick(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-30 19:07:30
Message-ID: 20041030190730.GA8484@surnet.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Wed, Oct 27, 2004 at 09:29:21PM -0400, Tom Lane wrote:
> Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> > On Wed, Oct 27, 2004 at 04:21:53PM -0400, Tom Lane wrote:
> >> On the other hand, it's also a pretty minor issue, and if it turns out
> >> to require a lot of code rejiggering to make it do that, I'd not think
> >> it worthwhile.
>
> > Patch attached. It passes the regression tests. It shouldn't have
> > secondary effects, but please test.
>
> Wouldn't it be better to just stay in TBLOCK_STARTED state, as if the
> COMMIT were just some random utility command?

It's the same thing, because CommitTransactionCommand acts identically
either way. I changed it anyway because it seems simpler.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
Licensee shall have no right to use the Licensed Software
for productive or commercial use. (Licencia de StarOffice 6.0 beta)

Attachment Content-Type Size
commit.patch text/plain 1.4 KB

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, olly(at)lfix(dot)co(dot)uk, Ian Barwick <barwick(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-30 20:45:22
Message-ID: 21303.1099169122@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> On Wed, Oct 27, 2004 at 09:29:21PM -0400, Tom Lane wrote:
>> Wouldn't it be better to just stay in TBLOCK_STARTED state, as if the
>> COMMIT were just some random utility command?

> It's the same thing, because CommitTransactionCommand acts identically
> either way. I changed it anyway because it seems simpler.

Patch applied.

regards, tom lane


From: Ian Barwick <barwick(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, olly(at)lfix(dot)co(dot)uk, pgsql-hackers(at)postgresql(dot)org
Subject: Re: 8.0b4: COMMIT outside of a transaction echoes ROLLBACK
Date: 2004-10-31 08:20:33
Message-ID: 1d581afe0410310120430636a7@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

On Sat, 30 Oct 2004 16:45:22 -0400, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl> writes:
> > On Wed, Oct 27, 2004 at 09:29:21PM -0400, Tom Lane wrote:
> >> Wouldn't it be better to just stay in TBLOCK_STARTED state, as if the
> >> COMMIT were just some random utility command?
>
> > It's the same thing, because CommitTransactionCommand acts identically
> > either way. I changed it anyway because it seems simpler.
>
> Patch applied.

Many thanks for this. I appreciate it's a fairly trivial issue, but
seeing the word "ROLLBACK" when a commit, or at least a non-operation
were expected, can do nasty things to one's blood pressure.

Ian Barwick
barwick(at)gmail(dot)net