Re: A bad behavior under autocommit off mode

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Hiroshi Inoue <Inoue(at)tpf(dot)co(dot)jp>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: A bad behavior under autocommit off mode
Date: 2003-03-20 02:37:49
Message-ID: 200303200237.h2K2bnU28282@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hiroshi Inoue wrote:
> Bruce Momjian wrote:
> >
> > OK, I have a patch to fix this bug. The basic problem is that when a
> > multi-query string is passed to the backend, it is treated as a single
> > transaction _unless_ a transaction or GUC command appears in the string.
> > When they appear, a transaction is forced, but the normal transaction
> > state machine has been bypassed, meaning in:
> >
> > SET autocommit TO off; SELECT 1; COMMIT;
> >
> > when the COMMIT arrives, the transaction state machines hasn't seen the
> > SELECT because the mechanism is bypassing the state machine to try and
> > get everything into the same transaction.
> >
> > This patch removes that "stuff all queries into a single transaction"
> > behavior and makes them function just like queries arriving separately.
> > This does BREAK BACKWARD COMPATIBILITY. However, if they want the old
> > behavior, they just need to wrap BEGIN/COMMIT around the query string.
>
> Does the change worth the trouble ?
> Please don't break BACKWARD COMPATIBILITY easily.

It clearly fixes an existing bug, and I asked on general to see if
anyone has any problem with the change. My guess is that more people
are surprised by the group-string-as-a-single-transaction as people who
use the feature, so I see it as the removal of surprising functionality.

We will mention it in the release notes, and I can even supply a patch
for those who want it kept. In fact, I can easily make it a compile
option --- the change is only a single conditional test.

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-03-20 02:38:21 Re: Nested transactions: low level stuff
Previous Message Alvaro Herrera 2003-03-20 02:23:06 Re: Open 7.4 features