Skip site navigation (1) Skip section navigation (2)

RE: postgres crash on CURSORS

From: "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Bruce Momjian" <pgman(at)candle(dot)pha(dot)pa(dot)us>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: RE: postgres crash on CURSORS
Date: 2000-04-05 06:00:19
Message-ID: 001701bf9ec4$38fdd0c0$2801007e@tpf.co.jp (view raw or flat)
Thread:
Lists: pgsql-hackers
> -----Original Message-----
> From: Tom Lane [mailto:tgl(at)sss(dot)pgh(dot)pa(dot)us]
> Sent: Wednesday, April 05, 2000 1:04 PM

>
> "Hiroshi Inoue" <Inoue(at)tpf(dot)co(dot)jp> writes:
> >>>> which are executed without having bothered to check for
> aborted state.
> >>>> I think this code should be removed from postgres.c, and the
> >>>> SetQuerySnapshot call instead made from the Fetch and Copy
> arms of the
> >>>> switch statement in ProcessUtility() (utility.c), after doing
> >>>> CHECK_IF_ABORTED in each case.
>
> > Is it bad to check ABORTED after yyparse() in parser.c ?
>
> Yes.  Try to execute an END (a/k/a ABORT, ROLLBACK, ...)
>
> The check for abort state has to happen in the appropriate paths of
> execution, not in the parser.  Not all statements should reject on
> abort state.
>

Are there any statements which should be executable on abort state
except ROLLBACK/COMMIT ?
The following is a sample patch for parser.c.

Regards.

Hiroshi Inoue
Inoue(at)tpf(dot)co(dot)jp

Index: parser.c
===================================================================
RCS file: /home/cvs/pgcurrent/backend/parser/parser.c,v
retrieving revision 1.2
diff -c -r1.2 parser.c
*** parser.c    2000/01/26 09:58:32     1.2
--- parser.c    2000/04/05 03:54:31
***************
*** 16,21 ****
--- 16,24 ----
  #include "parser/analyze.h"
  #include "parser/gramparse.h"
  #include "parser/parser.h"
+ #include "nodes/parsenodes.h"
+ #include "access/xact.h"
+ #include "parse.h"

  #if defined(FLEX_SCANNER)
  extern void DeleteBuffer(void);
***************
*** 48,53 ****
--- 51,82 ----
        parser_init(typev, nargs);
--- 51,82 ----
        parser_init(typev, nargs);
        yyresult = yyparse();

+       /* To avoid doing processing within an aborted transaction block. */
+       if (!yyresult && IsAbortedTransactionBlockState())
+       {
+               Node    *node = lfirst(parsetree);
+
+               if (IsA(node, TransactionStmt))
+               {
+                       TransactionStmt *stmt=(TransactionStmt *)node;
+                       switch (stmt->command)
+                       {
+                               case ROLLBACK:
+                               case COMMIT:
+                                       break;
+                               default:
+                                       yyresult = -1;
+                                       break;
+                       }
+               }
+               else
+                       yyresult = -1;
+               if (yyresult)
+               {
+                       elog(NOTICE, "(transaction already aborted): %s",
+                               "queries ignored until END");
+               }
+       }
  #if defined(FLEX_SCANNER)
        DeleteBuffer();
  #endif         /* FLEX_SCANNER */


In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2000-04-05 06:10:52
Subject: Re: postgres crash on CURSORS
Previous:From: Adriaan JoubertDate: 2000-04-05 05:37:43
Subject: Re: BIT datatype (Fixed)

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group