RE: postgres crash on CURSORS - Mailing list pgsql-hackers

From Hiroshi Inoue
Subject RE: postgres crash on CURSORS
Date
Msg-id 001701bf9ec4$38fdd0c0$2801007e@tpf.co.jp
Whole thread Raw
In response to Re: postgres crash on CURSORS  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: postgres crash on CURSORS  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
> -----Original Message-----
> From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
> Sent: Wednesday, April 05, 2000 1:04 PM

>
> "Hiroshi Inoue" <Inoue@tpf.co.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@tpf.co.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 */



pgsql-hackers by date:

Previous
From: Adriaan Joubert
Date:
Subject: Re: BIT datatype (Fixed)
Next
From: Tom Lane
Date:
Subject: Re: postgres crash on CURSORS