On 18/08/2026 12:04, Peter Eisentraut wrote:
The attached patches fix more cases where qualifiers (const, volatile)
are cast away either accidentally, or unnecessarily, or where it can be
worked around easily.
I split these into tiny bits to simplify review and to show that they
are all independent. But they could perhaps be committed all together.
(See also similar commit 3f988629805.)
Thanks for the cleanups!
diff --git a/src/backend/utils/misc/guc_funcs.c
b/src/backend/utils/misc/guc_funcs.c
index e2c2919484e..defaa796a0c 100644
--- a/src/backend/utils/misc/guc_funcs.c
+++ b/src/backend/utils/misc/guc_funcs.c
@@ -971,6 +971,7 @@ show_all_settings(PG_FUNCTION_ARGS)
while (call_cntr < max_calls) /* do when there is more left to
send */
{
struct config_generic *conf = guc_vars[call_cntr];
+ const char *cvalues[NUM_PG_SETTINGS_ATTS];
char *values[NUM_PG_SETTINGS_ATTS];
HeapTuple tuple;
Datum result;
@@ -984,7 +985,14 @@ show_all_settings(PG_FUNCTION_ARGS)
}
/* extract values for the current variable */
- GetConfigOptionValues(conf, (const char **) values);
+ GetConfigOptionValues(conf, cvalues);
+
+ /*
+ * This is so that both GetConfigOptionValues() and
+ * BuildTupleFromCStrings() are satisfied about the const-ness
without
+ * triggering warnings.
+ */
+ memcpy(values, cvalues, sizeof(cvalues));
/* build a tuple */
tuple = BuildTupleFromCStrings(attinmeta, values);
This seems hacky. Can we change BuildTupleFromCStrings() to take a const
instead? Maybe that was part of your "difficult half" already?
I guess that requires changing all the callers: You get a warning if
pass a "char **" to a "const char **". Is there a way with some macro
magic or something that you could accept both?
All else look good to me at a quick glance.
- Heikki