On 03.11.25 12:16, Peter Eisentraut wrote:
The remaining patches to sort the list alphabetically have also been pushed.
Here are a few more small patches to fix related things I found afterwards or in passing.
The first one straightens out how the qsort comparison function for GUC records works, and also removes the implicit requirement that the name field is first in the struct.
The second one fixes up an NLS build rule for the recent changes. The third fixes some translation markers. This is an older problem.
From 2e267c1de1e44de4729547adfd296ecf4ee56fa7 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <[email protected]> Date: Fri, 7 Nov 2025 09:25:43 +0100 Subject: [PATCH 1/3] Clean up qsort comparison function for GUC entries guc_var_compare() is invoked from qsort() on an array of struct config_generic, but the function accesses these directly as strings (char *). This relies on the name being the first field, so this works. But we can write this more clearly by using the struct and then accessing the field through the struct. Before the reorganization of the GUC structs (commit a13833c35f9), the old code was probably more convenient, but now we can write this more clearly and correctly. After this change, it is no longer required that the name is the first field in struct config_generic, so remove that comment. --- src/backend/utils/misc/guc.c | 6 +++--- src/include/utils/guc_tables.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index 679846da42c..f3411d34f0c 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -1164,10 +1164,10 @@ find_option(const char *name, bool create_placeholders, bool skip_errors, static int guc_var_compare(const void *a, const void *b) { - const char *namea = **(const char **const *) a; - const char *nameb = **(const char **const *) b; + const struct config_generic *ca = *(struct config_generic *const *) a; + const struct config_generic *cb = *(struct config_generic *const *) b; - return guc_name_compare(namea, nameb); + return guc_name_compare(ca->name, cb->name); } /* diff --git a/src/include/utils/guc_tables.h b/src/include/utils/guc_tables.h index bbfcc633014..04cc60eb526 100644 --- a/src/include/utils/guc_tables.h +++ b/src/include/utils/guc_tables.h @@ -249,7 +249,7 @@ struct config_enum struct config_generic { /* constant fields, must be set correctly in initial value: */ - const char *name; /* name of variable - MUST BE FIRST */ + const char *name; /* name of variable */ GucContext context; /* context required to set the variable */ enum config_group group; /* to help organize variables by function */ const char *short_desc; /* short desc. of this variable's purpose */ -- 2.51.0
From b9510e237fa9c9f76206becee0943dfb23bfbcb8 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <[email protected]> Date: Fri, 7 Nov 2025 09:25:43 +0100 Subject: [PATCH 2/3] Fix backend init-po file list Backend NLS should also catch generated files in src/include/. This is necessary to find guc_tables.inc.c in a vpath build (as of commit 63599896545). --- src/backend/nls.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/nls.mk b/src/backend/nls.mk index 698b1083f4b..5204003e682 100644 --- a/src/backend/nls.mk +++ b/src/backend/nls.mk @@ -28,7 +28,7 @@ GETTEXT_FLAGS = $(BACKEND_COMMON_GETTEXT_FLAGS) \ error_cb:2:c-format gettext-files: generated-parser-sources generated-headers - find $(srcdir) $(srcdir)/../common $(srcdir)/../port $(srcdir)/../include/ \( -name '*.c' -o -name "proctypelist.h" \) -print | LC_ALL=C sort >$@ + find $(srcdir) $(srcdir)/../common $(srcdir)/../port $(srcdir)/../include/ ../include/ \( -name '*.c' -o -name "proctypelist.h" \) -print | LC_ALL=C sort >$@ my-clean: rm -f gettext-files -- 2.51.0
From 15c78de3b21234de96c29bcbc55b0df21316aad2 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <[email protected]> Date: Fri, 7 Nov 2025 09:25:43 +0100 Subject: [PATCH 3/3] Fix NLS for incorrect GUC enum value hint message The translation markers were applied at the wrong place, so no string was extracted for translation. --- src/backend/utils/misc/guc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index f3411d34f0c..7c967116ac8 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -3135,14 +3135,14 @@ parse_and_validate_value(const struct config_generic *record, char *hintmsg; hintmsg = config_enum_get_options(conf, - "Available values: ", - ".", ", "); + _("Available values: "), + _("."), _(", ")); ereport(elevel, (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("invalid value for parameter \"%s\": \"%s\"", record->name, value), - hintmsg ? errhint("%s", _(hintmsg)) : 0)); + hintmsg ? errhint("%s", hintmsg) : 0)); if (hintmsg) pfree(hintmsg); -- 2.51.0
