On Fri, 07 Jul 2023 at 14:46, jian he <jian.universal...@gmail.com> wrote:
> On Fri, Jul 7, 2023 at 1:06 PM Japin Li <japi...@hotmail.com> wrote:
>>
>>
>> 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?
>>
>
> select  * from pg_settings where name ~* 'log.*destin*' \gx
>
> short_desc      | Sets the destination for server log output.
> extra_desc      | Valid values are combinations of "stderr", "syslog",
> "csvlog", "jsonlog", and "eventlog", depending on the platform.
>
> you can just reuse extra_desc in the pg_settings (view) column ?

Thanks for your review!

Yeah, the description of extra_desc is more accurate. Updated.

-- 
Regrads,
Japin Li.

>From 715f9811717c9d27f6b2f41db639b18e6ba58625 Mon Sep 17 00:00:00 2001
From: Japin Li <japi...@hotmail.com>
Date: Fri, 7 Jul 2023 15:48:53 +0800
Subject: [PATCH v2 1/1] Add hint message for check_log_destination

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

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

Reply via email to