Re: Add hint message for check_log_destination()

Поиск
Список
Период
Сортировка
От Japin Li
Тема Re: Add hint message for check_log_destination()
Дата
Msg-id MEYP282MB1669A108ABC063143AAAB65DB62DA@MEYP282MB1669.AUSP282.PROD.OUTLOOK.COM
обсуждение исходный текст
Ответ на Re: Add hint message for check_log_destination()  (Masahiko Sawada <sawada.mshk@gmail.com>)
Ответы Re: Add hint message for check_log_destination()  (Michael Paquier <michael@paquier.xyz>)
Список pgsql-hackers
On Fri, 07 Jul 2023 at 16:21, Masahiko Sawada <sawada.mshk@gmail.com> wrote:
> On Fri, Jul 7, 2023 at 4:53 PM Japin Li <japinli@hotmail.com> wrote:
>>
>>
>> On Fri, 07 Jul 2023 at 14:46, jian he <jian.universality@gmail.com> wrote:
>> > On Fri, Jul 7, 2023 at 1:06 PM Japin Li <japinli@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?
>
> +1
>
> +           appendStringInfo(&errhint, "\"stderr\"");
> +#ifdef HAVE_SYSLOG
> +           appendStringInfo(&errhint, ", \"syslog\"");
> +#endif
> +#ifdef WIN32
> +           appendStringInfo(&errhint, ", \"eventlog\"");
> +#endif
> +           appendStringInfo(&errhint, ", \"csvlog\", and \"jsonlog\"");
>
> I think using appendStringInfoString() is a bit more natural and faster.
>

Thanks for your review! Fixed as per your suggession.

From e0338c5085e655f9a25f13cd5acea9a3110806fd Mon Sep 17 00:00:00 2001
From: Japin Li <japinli@hotmail.com>
Date: Fri, 7 Jul 2023 15:48:53 +0800
Subject: [PATCH v3 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..a7545dcbd9 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);
+            appendStringInfoString(&errhint, "\"stderr\"");
+#ifdef HAVE_SYSLOG
+            appendStringInfoString(&errhint, ", \"syslog\"");
+#endif
+#ifdef WIN32
+            appendStringInfoString(&errhint, ", \"eventlog\"");
+#endif
+            appendStringInfoString(&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


-- 
Regrads,
Japin Li.


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Thom Brown
Дата:
Сообщение: Re: Disabling Heap-Only Tuples
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: remaining sql/json patches