Re: Error code for "terminating connection due to conflict with recovery" - Mailing list pgsql-hackers

From Tatsuo Ishii
Subject Re: Error code for "terminating connection due to conflict with recovery"
Date
Msg-id 20110113.161309.142637155940518140.t-ishii@sraoss.co.jp
Whole thread Raw
In response to Re: Error code for "terminating connection due to conflict with recovery"  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Error code for "terminating connection due to conflict with recovery"
List pgsql-hackers
>>> That doesn't sound right to me.  I'd have thought something in class 40.
>>
>> What about:
>>
>> 40004 CONFLICT WITH RECOVERY conflict_with_recovery
>
> We should respect the following convention, from errcodes.h:
>
>  * The convention is that new error codes defined by PostgreSQL in a
>  * class defined by the standard have a subclass value that begins
>  * with 'P'. In addition, error codes defined by PostgreSQL clients
>  * (such as ecpg) have a class value that begins with 'Y'.
>
> And don't forget there are three places where the new error code would
> need to be added.
>
> Otherwise, +1.

Ok. Here is the patch for this. I use 40P02, instead of 40004.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp
*** a/doc/src/sgml/errcodes.sgml
--- b/doc/src/sgml/errcodes.sgml
***************
*** 985,990 ****
--- 985,995 ---- <entry>deadlock_detected</entry> </row> 
+ <row>
+ <entry><literal>40P02</literal></entry>
+ <entry>CONFLICT WITH RECOVERY</entry>
+ <entry>conflict_with_recovery</entry>
+ </row>  <row> <entry spanname="span13"><emphasis role="bold">Class 42 — Syntax Error or Access Rule
Violation</></entry>
*** a/src/backend/tcop/postgres.c
--- b/src/backend/tcop/postgres.c
***************
*** 2909,2915 **** ProcessInterrupts(void)                      errdetail_recovery_conflict()));         else if
(RecoveryConflictPending)            ereport(FATAL,
 
!                     (errcode(ERRCODE_ADMIN_SHUTDOWN),               errmsg("terminating connection due to conflict
withrecovery"),                      errdetail_recovery_conflict()));         else
 
--- 2909,2915 ----                      errdetail_recovery_conflict()));         else if (RecoveryConflictPending)
      ereport(FATAL,
 
!                     (errcode(ERRCODE_CONFLICT_WITH_RECOVERY),               errmsg("terminating connection due to
conflictwith recovery"),                      errdetail_recovery_conflict()));         else
 
*** a/src/include/utils/errcodes.h
--- b/src/include/utils/errcodes.h
***************
*** 243,248 ****
--- 243,249 ---- #define ERRCODE_T_R_SERIALIZATION_FAILURE    MAKE_SQLSTATE('4','0', '0','0','1') #define
ERRCODE_T_R_STATEMENT_COMPLETION_UNKNOWN   MAKE_SQLSTATE('4','0', '0','0','3') #define ERRCODE_T_R_DEADLOCK_DETECTED
   MAKE_SQLSTATE('4','0', 'P','0','1')
 
+ #define ERRCODE_CONFLICT_WITH_RECOVERY    MAKE_SQLSTATE('4','0', 'P','0','2')  /* Class 42 - Syntax Error or Access
RuleViolation */ #define ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION        MAKE_SQLSTATE('4','2', '0','0','0')
 
*** a/src/pl/plpgsql/src/plerrcodes.h
--- b/src/pl/plpgsql/src/plerrcodes.h
***************
*** 484,489 ****
--- 484,493 ---- },  {
+     "conflict_with_recovery", ERRCODE_CONFLICT_WITH_RECOVERY
+ },
+ 
+ {     "syntax_error_or_access_rule_violation", ERRCODE_SYNTAX_ERROR_OR_ACCESS_RULE_VIOLATION },

pgsql-hackers by date:

Previous
From: Alex Hunsaker
Date:
Subject: Re: arrays as pl/perl input arguments [PATCH]
Next
From: Fujii Masao
Date:
Subject: Change pg_last_xlog_receive_location not to move backwards