Re: GUC values - recommended way to declare the C variables? - Mailing list pgsql-hackers

From Justin Pryzby
Subject Re: GUC values - recommended way to declare the C variables?
Date
Msg-id 20221025200401.GO16921@telsasoft.com
Whole thread Raw
In response to Re: GUC values - recommended way to declare the C variables?  (Peter Smith <smithpb2250@gmail.com>)
Responses Re: GUC values - recommended way to declare the C variables?
List pgsql-hackers
+#ifdef USE_ASSERT_CHECKING
+               sanity_check_GUC_C_var(hentry->gucvar);
+#endif

=> You can conditionally define that as an empty function so #ifdefs
aren't needed in the caller:

void sanity_check_GUC_C_var()
{
#ifdef USE_ASSERT_CHECKING
    ...
#endif
}

+       /* Skip checking for dynamic (compiler-dependent) GUCs. */

=> This should say that the GUC's default is determined at compile-time.

But actually, I don't think you should use my patch.  You needed to
exclude update_process_title:

src/backend/utils/misc/ps_status.c:bool         update_process_title = true;
...
src/backend/utils/misc/guc_tables.c-#ifdef WIN32
src/backend/utils/misc/guc_tables.c-            false,
src/backend/utils/misc/guc_tables.c-#else
src/backend/utils/misc/guc_tables.c-            true,
src/backend/utils/misc/guc_tables.c-#endif
src/backend/utils/misc/guc_tables.c-            NULL, NULL, NULL

My patch would also exclude the 16 other GUCs with compile-time defaults
from your check.  It'd be better not to exclude them; I think the right
solution is to change the C variable initialization to a compile-time
constant:

#ifdef WIN32
bool         update_process_title = false;
#else
bool         update_process_title = true;
#endif

Or something more indirect like:

#ifdef WIN32
#define    DEFAULT_PROCESS_TITLE false
#else
#define    DEFAULT_PROCESS_TITLE true
#endif

bool         update_process_title = DEFAULT_PROCESS_TITLE;

I suspect there's not many GUCs that would need to change - this might
be the only one.  If this GUC were defined in the inverse (bool
skip_process_title), it wouldn't need special help, either.

-- 
Justin



pgsql-hackers by date:

Previous
From: Heikki Linnakangas
Date:
Subject: Re: Confused about TransactionIdSetTreeStatus
Next
From: Jacob Champion
Date:
Subject: Re: [PATCH] Add `verify-system` sslmode to use system CA pool for server cert