On 11/09/2026 21:58, Peter Eisentraut wrote:
> On 07.09.26 20:39, Tom Lane wrote:
>> Peter Eisentraut <[email protected]> writes:
>>> On 03.09.26 15:52, Tom Lane wrote:
>>>> But I concur with Andreas that 0005 looks a bit half-baked.
>>>> Maybe that's the right amount of effort for the back branches,
>>>> but something else should happen in HEAD.
>>
>>> Right. Here is another patch at the end (0006) that I propose for
>>> master only that makes using unsupported options an error. Some
>>> Windows-only options already behaved that way, so this just makes the
>>> rest consistent.
>>
>> With that addition, this looks fine to me.
>
> This has been committed and backpatched. There were a few more issues of this
> kind in the backbranches, which I have also fixed.
Building current master on macOS with a recent clang, I still get two of these
warnings, both in psql:
input.c:36:12: warning: variable 'history_lines_added' set but not used
[-Wunused-but-set-global]
tab-complete.in.c:225:13: warning: variable 'completion_last_char' set but not
used [-Wunused-but-set-global]
They only appear when psql is linked against a line-editing library that lacks
some optional functions, such as libedit, which ships with macOS. That is
probably why they didn't show up in your build.
See the sketch solution in the attached patch.
--
regards, Andrei Lepikhov,
pgEdge
From 776ea503e04f12b9599fb14430fee772ba61e9b8 Mon Sep 17 00:00:00 2001
From: Andrei Lepikhov <[email protected]>
Date: Tue, 24 Nov 2026 13:54:41 +0100
Subject: [PATCH v0] Silence -Wunused-but-set-global warnings with libedit
Commit 4e108ce790e removed the set-but-unused static globals reported by clang
23's new -Wunused-but-set-global warning, but two more remain in psql. They
show up only when psql is built against a line-editing library that lacks some
optional functions, such as the libedit that ships with macOS.
Put the declarations and all assignments under the same preprocessor
conditions as the reads.
---
src/bin/psql/input.c | 6 ++++++
src/bin/psql/tab-complete.in.c | 4 ++++
2 files changed, 10 insertions(+)
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 6d37359fc96..5412055c572 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -33,7 +33,9 @@ static bool useHistory;
static char *psql_history;
+#if defined(HAVE_HISTORY_TRUNCATE_FILE) && defined(HAVE_APPEND_HISTORY)
static int history_lines_added;
+#endif
/*
@@ -161,8 +163,10 @@ pg_send_history(PQExpBuffer history_buf)
prev_hist = pg_strdup(s);
/* And send it to readline */
add_history(s);
+#if defined(HAVE_HISTORY_TRUNCATE_FILE) && defined(HAVE_APPEND_HISTORY)
/* Count lines added to history for use later */
history_lines_added++;
+#endif
}
}
@@ -364,7 +368,9 @@ initializeInput(int flags)
useHistory = true;
using_history();
+#if defined(HAVE_HISTORY_TRUNCATE_FILE) && defined(HAVE_APPEND_HISTORY)
history_lines_added = 0;
+#endif
histfile = GetVariable(pset.vars, "HISTFILE");
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 96de78cd087..36353960a9e 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -222,7 +222,9 @@ static int completion_max_records;
* macros) and then used by the completion callback functions. Ugly but there
* is no better way.
*/
+#ifdef USE_FILENAME_QUOTING_FUNCTIONS
static char completion_last_char; /* last char of input word */
+#endif
static const char *completion_charp; /* to pass a string */
static const char *const *completion_charpp; /* to pass a list of strings */
static const VersionedQuery *completion_vquery; /* to pass a VersionedQuery */
@@ -1950,8 +1952,10 @@ psql_completion(const char *text, int start, int end)
char *text_copy = pnstrdup(rl_line_buffer + start, end - start);
text = text_copy;
+#ifdef USE_FILENAME_QUOTING_FUNCTIONS
/* Remember last char of the given input word. */
completion_last_char = (end > start) ? text[end - start - 1] : '\0';
+#endif
/* We usually want the append character to be a space. */
rl_completion_append_character = ' ';
--
2.56.1