errdetail-internal-2.patch

application/octet-stream

Filename: errdetail-internal-2.patch
Type: application/octet-stream
Part: 0
Message: Re: SSI error messages
*** a/doc/src/sgml/sources.sgml
--- b/doc/src/sgml/sources.sgml
***************
*** 214,219 **** ereport(ERROR,
--- 214,228 ----
     </listitem>
     <listitem>
      <para>
+      <function>errdetail_internal(const char *msg, ...)</function> is the same
+      as <function>errdetail</>, except that the message string will not be
+      translated nor included in the internationalization message dictionary.
+      This may be used when the detail consists of technical information which
+      would not translate well.
+     </para>
+    </listitem>
+    <listitem>
+     <para>
       <function>errdetail_log(const char *msg, ...)</function> is the same as
       <function>errdetail</> except that this string goes only to the server
       log, never to the client.  If both <function>errdetail</> and
*** a/src/backend/storage/lmgr/predicate.c
--- b/src/backend/storage/lmgr/predicate.c
***************
*** 3776,3782 **** CheckForSerializableConflictOut(bool visible, Relation relation,
  		ereport(ERROR,
  				(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  				 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 				 errdetail("Canceled on identification as a pivot, during conflict out checking."),
  				 errhint("The transaction might succeed if retried.")));
  	}
  
--- 3776,3782 ----
  		ereport(ERROR,
  				(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  				 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 				 errdetail_internal("Canceled on identification as a pivot, during conflict out checking."),
  				 errhint("The transaction might succeed if retried.")));
  	}
  
***************
*** 3865,3871 **** CheckForSerializableConflictOut(bool visible, Relation relation,
  				ereport(ERROR,
  						(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  						 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 				errdetail("Canceled on conflict out to old pivot %u.", xid),
  					  errhint("The transaction might succeed if retried.")));
  
  			if (SxactHasSummaryConflictIn(MySerializableXact)
--- 3865,3871 ----
  				ereport(ERROR,
  						(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  						 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 						 errdetail_internal("Canceled on conflict out to old pivot %u.", xid),
  					  errhint("The transaction might succeed if retried.")));
  
  			if (SxactHasSummaryConflictIn(MySerializableXact)
***************
*** 3873,3879 **** CheckForSerializableConflictOut(bool visible, Relation relation,
  				ereport(ERROR,
  						(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  						 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 						 errdetail("Canceled on identification as a pivot, with conflict out to old committed transaction %u.", xid),
  					  errhint("The transaction might succeed if retried.")));
  
  			MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
--- 3873,3879 ----
  				ereport(ERROR,
  						(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  						 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 						 errdetail_internal("Canceled on identification as a pivot, with conflict out to old committed transaction %u.", xid),
  					  errhint("The transaction might succeed if retried.")));
  
  			MySerializableXact->flags |= SXACT_FLAG_SUMMARY_CONFLICT_OUT;
***************
*** 3912,3918 **** CheckForSerializableConflictOut(bool visible, Relation relation,
  			ereport(ERROR,
  					(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  					 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 					 errdetail("Canceled on conflict out to old pivot."),
  					 errhint("The transaction might succeed if retried.")));
  		}
  	}
--- 3912,3918 ----
  			ereport(ERROR,
  					(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  					 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 				errdetail_internal("Canceled on conflict out to old pivot."),
  					 errhint("The transaction might succeed if retried.")));
  		}
  	}
***************
*** 4151,4157 **** CheckForSerializableConflictIn(Relation relation, HeapTuple tuple,
  		ereport(ERROR,
  				(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  				 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 				 errdetail("Canceled on identification as a pivot, during conflict in checking."),
  				 errhint("The transaction might succeed if retried.")));
  
  	/*
--- 4151,4157 ----
  		ereport(ERROR,
  				(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  				 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 				 errdetail_internal("Canceled on identification as a pivot, during conflict in checking."),
  				 errhint("The transaction might succeed if retried.")));
  
  	/*
***************
*** 4489,4495 **** OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
  			ereport(ERROR,
  					(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  					 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 					 errdetail("Canceled on identification as a pivot, during write."),
  					 errhint("The transaction might succeed if retried.")));
  		}
  		else if (SxactIsPrepared(writer))
--- 4489,4495 ----
  			ereport(ERROR,
  					(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  					 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 					 errdetail_internal("Canceled on identification as a pivot, during write."),
  					 errhint("The transaction might succeed if retried.")));
  		}
  		else if (SxactIsPrepared(writer))
***************
*** 4501,4507 **** OnConflict_CheckForSerializationFailure(const SERIALIZABLEXACT *reader,
  			ereport(ERROR,
  					(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  					 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 					 errdetail("Canceled on conflict out to pivot %u, during read.", writer->topXid),
  					 errhint("The transaction might succeed if retried.")));
  		}
  		writer->flags |= SXACT_FLAG_DOOMED;
--- 4501,4507 ----
  			ereport(ERROR,
  					(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  					 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 					 errdetail_internal("Canceled on conflict out to pivot %u, during read.", writer->topXid),
  					 errhint("The transaction might succeed if retried.")));
  		}
  		writer->flags |= SXACT_FLAG_DOOMED;
***************
*** 4543,4549 **** PreCommit_CheckForSerializationFailure(void)
  		ereport(ERROR,
  				(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  				 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 				 errdetail("Canceled on identification as a pivot, during commit attempt."),
  				 errhint("The transaction might succeed if retried.")));
  	}
  
--- 4543,4549 ----
  		ereport(ERROR,
  				(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  				 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 				 errdetail_internal("Canceled on identification as a pivot, during commit attempt."),
  				 errhint("The transaction might succeed if retried.")));
  	}
  
***************
*** 4581,4587 **** PreCommit_CheckForSerializationFailure(void)
  						ereport(ERROR,
  								(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  								 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 								 errdetail("Canceled on commit attempt with conflict in from prepared pivot."),
  								 errhint("The transaction might succeed if retried.")));
  					}
  					nearConflict->sxactOut->flags |= SXACT_FLAG_DOOMED;
--- 4581,4587 ----
  						ereport(ERROR,
  								(errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
  								 errmsg("could not serialize access due to read/write dependencies among transactions"),
! 								 errdetail_internal("Canceled on commit attempt with conflict in from prepared pivot."),
  								 errhint("The transaction might succeed if retried.")));
  					}
  					nearConflict->sxactOut->flags |= SXACT_FLAG_DOOMED;
*** a/src/backend/utils/error/elog.c
--- b/src/backend/utils/error/elog.c
***************
*** 843,848 **** errdetail(const char *fmt,...)
--- 843,871 ----
  
  
  /*
+  * errdetail_internal --- add a detail error message text to the current error
+  *
+  * This version has no translation, normally due to technical content.
+  */
+ int
+ errdetail_internal(const char *fmt,...)
+ {
+ 	ErrorData  *edata = &errordata[errordata_stack_depth];
+ 	MemoryContext oldcontext;
+ 
+ 	recursion_depth++;
+ 	CHECK_STACK_DEPTH();
+ 	oldcontext = MemoryContextSwitchTo(ErrorContext);
+ 
+ 	EVALUATE_MESSAGE(detail, false, false);
+ 
+ 	MemoryContextSwitchTo(oldcontext);
+ 	recursion_depth--;
+ 	return 0;					/* return value does not matter */
+ }
+ 
+ 
+ /*
   * errdetail_log --- add a detail_log error message text to the current error
   */
  int
*** a/src/include/utils/elog.h
--- b/src/include/utils/elog.h
***************
*** 147,152 **** errdetail(const char *fmt,...)
--- 147,158 ----
  __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
  
  extern int
+ errdetail_internal(const char *fmt,...)
+ /* This extension allows gcc to check the format string for consistency with
+    the supplied arguments. */
+ __attribute__((format(PG_PRINTF_ATTRIBUTE, 1, 2)));
+ 
+ extern int
  errdetail_log(const char *fmt,...)
  /* This extension allows gcc to check the format string for consistency with
     the supplied arguments. */