Hello

> That's not OK.

hmm. Did you mean catching only needed errors by errcode? Something like 
attached?

regards, Sergei
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 1208eb9a68..2993b8aa08 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -11603,16 +11603,25 @@ check_recovery_target_time(char **newval, void **extra, GucSource source)
 		PG_CATCH();
 		{
 			ErrorData  *edata;
+			MemoryContext ecxt;
 
 			/* Save error info */
-			MemoryContextSwitchTo(oldcontext);
+			ecxt = MemoryContextSwitchTo(oldcontext);
 			edata = CopyErrorData();
-			FlushErrorState();
-
-			/* Pass the error message */
-			GUC_check_errdetail("%s", edata->message);
-			FreeErrorData(edata);
-			return false;
+			switch (edata->sqlerrcode)
+			{
+				case ERRCODE_INVALID_DATETIME_FORMAT:
+				case ERRCODE_DATETIME_FIELD_OVERFLOW:
+				case ERRCODE_INVALID_TIME_ZONE_DISPLACEMENT_VALUE:
+					FlushErrorState();
+					/* Pass the error message */
+					GUC_check_errdetail("%s", edata->message);
+					FreeErrorData(edata);
+					return false;
+				default:
+					MemoryContextSwitchTo(ecxt);
+					PG_RE_THROW();
+			}
 		}
 		PG_END_TRY();
 
@@ -11690,16 +11699,23 @@ check_recovery_target_lsn(char **newval, void **extra, GucSource source)
 		PG_CATCH();
 		{
 			ErrorData  *edata;
+			MemoryContext ecxt;
 
 			/* Save error info */
-			MemoryContextSwitchTo(oldcontext);
+			ecxt = MemoryContextSwitchTo(oldcontext);
 			edata = CopyErrorData();
-			FlushErrorState();
-
-			/* Pass the error message */
-			GUC_check_errdetail("%s", edata->message);
-			FreeErrorData(edata);
-			return false;
+			if (edata->sqlerrcode == ERRCODE_INVALID_TEXT_REPRESENTATION)
+			{
+				FlushErrorState();
+				GUC_check_errdetail("%s", edata->message);
+				FreeErrorData(edata);
+				return false;
+			}
+			else
+			{
+				MemoryContextSwitchTo(ecxt);
+				PG_RE_THROW();
+			}
 		}
 		PG_END_TRY();
 

Reply via email to