Hi, hackers

When I try to change log_destination using ALTER SYSTEM with the wrong value,
it complains of the "Unrecognized key word" without available values.  This
patch tries to add a hint message that provides available values for
log_destination.  Any thoughts?

-- 
Regrads,
Japin Li.

>From 7d6b50c9deaba576cdc28e170bff541f630415f9 Mon Sep 17 00:00:00 2001
From: Japin Li <japi...@hotmail.com>
Date: Fri, 7 Jul 2023 12:59:09 +0800
Subject: [PATCH v1 1/1] Add hint message for log_destination

---
 src/backend/utils/error/elog.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 5898100acb..fdc6557a59 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2228,8 +2228,21 @@ check_log_destination(char **newval, void **extra, GucSource source)
 #endif
 		else
 		{
+			StringInfoData errhint;
+
+			initStringInfo(&errhint);
+			appendStringInfo(&errhint, "stderr, csvlog, jsonlog");
+#ifdef HAVE_SYSLOG
+			appendStringInfo(&errhint, ", syslog");
+#endif
+#ifdef WIN32
+			appendStringInfo(&errhint, ", eventlog");
+#endif
+
 			GUC_check_errdetail("Unrecognized key word: \"%s\".", tok);
+			GUC_check_errhint("Available values: %s.", errhint.data);
 			pfree(rawstring);
+			pfree(errhint.data);
 			list_free(elemlist);
 			return false;
 		}
-- 
2.25.1

Reply via email to