Re: A bad behavior under autocommit off mode - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: A bad behavior under autocommit off mode
Date
Msg-id 200303210607.h2L67C111371@candle.pha.pa.us
Whole thread Raw
In response to Re: A bad behavior under autocommit off mode  (Hiroshi Inoue <Inoue@tpf.co.jp>)
List pgsql-hackers
Hiroshi Inoue wrote:
> Tom Lane wrote:
> >
> > Hiroshi Inoue <Inoue@tpf.co.jp> writes:
> > > My proposal also fixes the bug though Tom objected to it.
> >
> > I've forgotten what your proposal was?
>
> Because WARNING isn't an ERROR, treat it in the same way
> as NORMAL, i.e after the WARNING, simply set the blockState
> to TBLOCK_END without calling AbortTransaction. Also
> remove the WARNING in case of autocommit off mode.

I think our current code is working fine _except_ for the
multi-statement query case.

I lost the vote on changing the current behavior, so this patch merely
turns off this grouping when autocommit is off.  That seems like the
easiest solution.

The next issue is that we don't have the current behavior documented
anywhere.  I think it needs to be added to libpq's PQexec() and psql -c.
It will say:

    With autocommit on, if multiple statements are sent in a single
    string, all statements are grouped into a single transaction.

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/backend/tcop/postgres.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/backend/tcop/postgres.c,v
retrieving revision 1.318
diff -c -c -r1.318 postgres.c
*** src/backend/tcop/postgres.c    20 Mar 2003 07:02:10 -0000    1.318
--- src/backend/tcop/postgres.c    21 Mar 2003 05:25:59 -0000
***************
*** 83,88 ****
--- 83,90 ----
  bool        Warn_restart_ready = false;
  bool        InError = false;

+ extern bool    autocommit;
+
  static bool EchoQuery = false;    /* default don't echo */

  /*
***************
*** 893,899 ****
           * historical Postgres behavior, we do not force a transaction
           * boundary between queries appearing in a single query string.
           */
!         if (lnext(parsetree_item) == NIL && xact_started)
          {
              finish_xact_command(false);
              xact_started = false;
--- 895,901 ----
           * historical Postgres behavior, we do not force a transaction
           * boundary between queries appearing in a single query string.
           */
!         if ((lnext(parsetree_item) == NIL || !autocommit) && xact_started)
          {
              finish_xact_command(false);
              xact_started = false;

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: probs with postgres
Next
From: "Christopher Kings-Lynne"
Date:
Subject: Re: [GENERAL] Extracting time from timestamp