pgsql: Clean up qsort comparison function for GUC entries

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Clean up qsort comparison function for GUC entries
Date: 2025-11-11 07:03:45
Message-ID: E1vIiPp-0061uc-0u@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

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.

Reviewed-by: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Discussion: https://www.postgresql.org/message-id/2c961fa1-14f6-44a2-985c-e30b95654e8d%40eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d2f24df19b7a42a0944a6926a0ca54168dcefe3a

Modified Files
--------------
src/backend/utils/misc/guc.c | 6 +++---
src/include/utils/guc_tables.h | 2 +-
2 files changed, 4 insertions(+), 4 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Robert Haas 2025-11-11 13:22:14 Re: pgsql: Drop unnamed portal immediately after execution to completion
Previous Message Michael Paquier 2025-11-10 23:31:26 Re: pgsql: Drop unnamed portal immediately after execution to completion