Re: [HACKERS] BEGIN inside transaction should be an error

From: "Gurjeet Singh" <singh(dot)gurjeet(at)gmail(dot)com>
To: Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] BEGIN inside transaction should be an error
Date: 2006-05-26 16:15:25
Message-ID: 65937bea0605260915p1f0fe603s37ef39a5b77deaae@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On 5/26/06, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:
>
> Please read the developers FAQ:
> http://www.postgresql.org/docs/faqs.FAQ_DEV.html
>
> For the most part, patches are probably best generated relative to the
> root directory of your CVS checkout.
>
> cheers
>
> andrew
>
> Gurjeet Singh wrote:
> > I wish to
> > know the standard procedure (command) to generate a patch; and from
> > which level in the source directory should I execute it?
> >
> > On 5/18/06, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
> >>
> >> Added to TODO:
> >>
> >> * Add a GUC to control whether BEGIN inside a transcation
> >> should abort
> >> the transaction.

Thanks Andrew.

Reposting the patch since my version on guc.c wasn't at the HEAD.

Index: src/backend/access/transam/xact.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/access/transam/xact.c,v
retrieving revision 1.220
diff -c -p -r1.220 xact.c
*** src/backend/access/transam/xact.c 25 Apr 2006 00:25:17 -0000 1.220
--- src/backend/access/transam/xact.c 21 May 2006 15:40:00 -0000
*************** bool XactReadOnly;
*** 59,64 ****
--- 59,65 ----
int CommitDelay = 0; /* precommit delay in microseconds */
int CommitSiblings = 5; /* # concurrent xacts needed to sleep */

+ bool BeginInXactIsError = true;

/*
* transaction states - transaction state from server perspective
*************** BeginTransactionBlock(void)
*** 2725,2731 ****
case TBLOCK_SUBINPROGRESS:
case TBLOCK_ABORT:
case TBLOCK_SUBABORT:
! ereport(WARNING,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("there is already a transaction in progress")));
break;
--- 2726,2732 ----
case TBLOCK_SUBINPROGRESS:
case TBLOCK_ABORT:
case TBLOCK_SUBABORT:
! ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("there is already a transaction in progress")));
break;
Index: src/backend/utils/misc/guc.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/misc/guc.c,v
retrieving revision 1.320
diff -c -p -r1.320 guc.c
*** src/backend/utils/misc/guc.c 21 May 2006 20:10:42 -0000 1.320
--- src/backend/utils/misc/guc.c 26 May 2006 16:10:40 -0000
***************
*** 66,71 ****
--- 66,72 ----
#include "utils/pg_locale.h"
#include "pgstat.h"
#include "access/gin.h"
+ #include "access/xact.h"

#ifndef PG_KRB_SRVTAB
#define PG_KRB_SRVTAB ""
*************** static struct config_bool ConfigureNames
*** 1008,1013 ****
--- 1009,1024 ----
false, NULL, NULL
},

+ {
+ {"begin_inside_transaction_is_error", PGC_USERSET, COMPAT_OPTIONS,
+ gettext_noop("A BEGIN statement inside a transaction raises ERROR."),
+ gettext_noop("It is provided to catch buggy applications. "
+ "Disable it to let the buggy application run.")
+ },
+ &BeginInXactIsError,
+ true, NULL, NULL
+ },
+
/* End-of-list marker */
{
{NULL, 0, 0, NULL, NULL}, NULL, false, NULL, NULL
Index: src/include/access/xact.h
===================================================================
RCS file: /projects/cvsroot/pgsql/src/include/access/xact.h,v
retrieving revision 1.82
diff -c -p -r1.82 xact.h
*** src/include/access/xact.h 25 Apr 2006 00:25:19 -0000 1.82
--- src/include/access/xact.h 21 May 2006 15:13:10 -0000
*************** extern int XactIsoLevel;
*** 41,46 ****
--- 41,49 ----
extern bool DefaultXactReadOnly;
extern bool XactReadOnly;

+ /* A BEGIN statement inside a transaction raises ERROR */
+ extern bool BeginInXactIsError;
+
/*
* start- and end-of-transaction callbacks for dynamically loaded modules
*/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim C. Nasby 2006-05-26 16:31:08 Re: Compression and on-disk sorting
Previous Message Gurjeet Singh 2006-05-26 16:00:22 Re: [HACKERS] BEGIN inside transaction should be an error

Browse pgsql-patches by date

  From Date Subject
Next Message Alvaro Herrera 2006-05-26 16:35:41 Re: [HACKERS] BEGIN inside transaction should be an error
Previous Message Gurjeet Singh 2006-05-26 16:00:22 Re: [HACKERS] BEGIN inside transaction should be an error