From: | Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Shaik Mohammad Mujeeb <mujeeb(dot)sk(at)zohocorp(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, mujeebskdev <mujeeb(dot)sk(dot)dev(at)gmail(dot)com> |
Subject: | Re: [Util] Warn and Remove Invalid GUCs |
Date: | 2025-05-22 08:46:13 |
Message-ID: | CAFC+b6oZNNf0922EAaPr67cZ1XETpS=nevh89_UzLykGZqLrdA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi,
On Thu, May 22, 2025 at 2:09 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Shaik Mohammad Mujeeb <mujeeb(dot)sk(at)zohocorp(dot)com> writes:
> > Currently, if there's a typo in an extension name while adding a GUC to
> postgresql.conf, PostgreSQL server starts up silently without any warning.
> This can be misleading, as one might assume the configuration has been
> correctly applied, when in fact the value hasn’t been set due to the typo.
>
> Well, yeah, because the core server has no way to identify bogus
> extension GUCs if the relevant extension isn't loaded. We do
> already complain about such things at extension load time.
>
the extension is loaded and then i entered the bogus extension GUC into
postgresql.conf and restarted, i did not observe any complain/warning .
> > To improve this experience, I’m proposing a patch that issues a
> > warning for such invalid GUC entries.
>
> How will you know they are invalid? All I see in the patch is
> a syntactic check, which looks quite redundant with
> assignable_custom_variable_name().
>
after the extension is loaded, MarkGUCPrefixReserved() appends
reserved_class_prefix with extension name ,so this patch has code to check
if the the GUC's prefix from the postgresql.conf is in the
reserved_class_prefix or not ,if not it invalidates and throws
warning.Please correct me if i am wrong.
+static bool
+has_valid_class_prefix(const char *name){
+ /* If there's no separator, it can't be a custom variable */
+ const char *sep = strchr(name, GUC_QUALIFIER_SEPARATOR);
+ size_t class_len = sep - name;
+ ListCell *lc;
+ foreach(lc, reserved_class_prefix)
+ {
+ const char *rcprefix = lfirst(lc);
+
+ if (strlen(rcprefix) == class_len &&
+ strncmp(name, rcprefix, class_len) == 0)
+ {
+ return true;
+ }
+ }
+
+ return false;
+}
+void WarnAndRemoveInvalidGUCs(){
+ HASH_SEQ_STATUS status;
+ GUCHashEntry *hentry;
+
+ /* Warn and remove invalid placeholders. */
+ hash_seq_init(&status, guc_hashtab);
+ while ((hentry = (GUCHashEntry *) hash_seq_search(&status)) != NULL)
+ {
+ struct config_generic *var = hentry->gucvar;
+
+ if((var->flags & GUC_CUSTOM_PLACEHOLDER) != 0 &&
!has_valid_class_prefix(var->name)){
+ ereport(WARNING,
+ (errcode(ERRCODE_INVALID_NAME),
+ errmsg("invalid configuration parameter name \"%s\", removing it",
+ var->name),
+ errdetail("\"%s\" doesn't has a reserved prefix.",
+ var->name)));
+ remove_gucvar(var);
+ }
+ }
+}
+
--
Thanks,
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/
From | Date | Subject | |
---|---|---|---|
Next Message | Andy Fan | 2025-05-22 08:51:51 | Re: Expression push down from Join Node to below node. |
Previous Message | Jim Jones | 2025-05-22 08:42:46 | Re: [PATCH] Add pretty-printed XML output option |