From: Jonathan Gonzalez V. <jonathan.abdiel@gmail.com>
To: pgsql-hackers@lists.postgresql.org
Subject: Coverage (lcov) failing with inconsistent error in versions 2.x
Date: Wed, 01 Jul 2026 14:12:35 +0200
Message-ID: <87ldbuc3ik.fsf@gmail.com> (raw)
Hi all
While working on another patch I was suggested to check the coverage of
the tests, but I hit some errors while trying to build the coverage.
The first error and that it's fixed here are:
lcov: ERROR: (inconsistent) "/home/zeus/src/postgresql/src/interfaces/libpq/fe-auth-oauth.c":869: duplicate function 'use_builtin_flow' starts on line "/home/zeus/src/postgresql/src/interfaces/libpq/fe-auth-oauth.c":869 but previous definition started on 991 while capturing from /home/zeus/src/postgresql/build/src/interfaces/libpq/libpq.so.5.19.p/fe-auth-oauth.c.gcno.
(use "lcov --ignore-errors inconsistent ..." to bypass this error)
lcov: ERROR: (inconsistent) "/home/zeus/src/postgresql/worktrees/lcov/src/include/lib/simplehash.h":450: duplicate function 'blockreftable_create' starts on line "/home/zeus/src/postgresql/worktrees/lcov/src/include/lib/simplehash.h":450 but previous definition started on 447 while capturing from /home/zeus/src/postgresql/worktrees/lcov/build/src/common/libpgcommon_srv.a.p/blkreftable.c.gcno.
(use "lcov --ignore-errors inconsistent ..." to bypass this error)
These error are due to duplicated declaration of SH_CREATE() and
use_builtin_flow(), and will only appear in version of lcov >= 2.0
which is the version, but with version 1.16 this doesn't happens.
These failure has already been discussed here[0], but this is a
patch on the code rather than add an exception. That thread still having
some valid points related to another failure that should be discussed
there.
[0] https://www.postgresql.org/message-id/flat/CAHsn6_xCDQWe8_vVFhtFk27_xTdyVV%2BDr0yWzaooBZ6%2B-VH-5w%4...
--
Jonathan Gonzalez V.
EDB
https://www.enterprisedb.comAttachments:
[text/x-diff] v1-0001-libpq-oauth-collapse-use_builtin_flow-into-a-sing.patch (3.5K, ../87ldbuc3ik.fsf@gmail.com/2-v1-0001-libpq-oauth-collapse-use_builtin_flow-into-a-sing.patch)
download | inline diff:
From 3f9a98a046f18588e77a9f1e53da7a3ee92c10cf Mon Sep 17 00:00:00 2001
From: "Jonathan Gonzalez V." <jonathan.abdiel@gmail.com>
Date: Wed, 1 Jul 2026 12:31:55 +0200
Subject: [PATCH v1 1/2] libpq-oauth: collapse use_builtin_flow() into a single
definition
There was three separated definition of the function making lcov v2.x fail
with an error.
---
src/interfaces/libpq/fe-auth-oauth.c | 61 +++++++++++-----------------
1 file changed, 24 insertions(+), 37 deletions(-)
diff --git a/src/interfaces/libpq/fe-auth-oauth.c b/src/interfaces/libpq/fe-auth-oauth.cindex 826f7461cb3..7a35647feb8 100644--- a/src/interfaces/libpq/fe-auth-oauth.c+++ b/src/interfaces/libpq/fe-auth-oauth.c@@ -833,41 +833,42 @@ cleanup_oauth_flow(PGconn *conn)
* failure, and positive indicates success.
*/
-#if !defined(USE_LIBCURL)+#if defined(USE_LIBCURL) && defined(USE_DYNAMIC_OAUTH)
/*
- * This configuration doesn't support the builtin flow.+ * Use the builtin flow in the libpq-oauth plugin, which is loaded at runtime.
*/
-static int-use_builtin_flow(PGconn *conn, fe_oauth_state *state, PGoauthBearerRequestV2 *request)-{- return 0;-}+typedef char *(*libpq_gettext_func) (const char *msgid);-#elif defined(USE_DYNAMIC_OAUTH)+#elif defined(USE_LIBCURL)
/*
- * Use the builtin flow in the libpq-oauth plugin, which is loaded at runtime.+ * For static builds, we can just call pg_start_oauthbearer() directly. It's+ * provided by libpq-oauth.a.
*/
+extern int pg_start_oauthbearer(PGconn *conn, PGoauthBearerRequestV2 *request);-typedef char *(*libpq_gettext_func) (const char *msgid);+#endif-/*- * Loads the libpq-oauth plugin via dlopen(), initializes it, and plugs its- * callbacks into the connection's async auth handlers.- *- * Failure to load here results in a relatively quiet connection error, to- * handle the use case where the build supports loading a flow but a user does- * not want to install it. Troubleshooting of linker/loader failures can be done- * via PGOAUTHDEBUG.- *- * The lifetime of *request ends shortly after this call, so it must be copied- * to longer-lived storage.- */
static int
use_builtin_flow(PGconn *conn, fe_oauth_state *state, PGoauthBearerRequestV2 *request)
{
+#if !defined(USE_LIBCURL)+ return 0;+#elif defined(USE_DYNAMIC_OAUTH)+ /*+ * Load the libpq-oauth plugin via dlopen(), initialize it, and plug its+ * callbacks into the connection's async auth handlers.+ *+ * Failure to load here results in a relatively quiet connection error, to+ * handle the use case where the build supports loading a flow but a user+ * does not want to install it. Troubleshooting of linker/loader failures+ * can be done via PGOAUTHDEBUG.+ *+ * The lifetime of *request ends shortly after this call, so it must be+ * copied to longer-lived storage.+ */
static bool initialized = false;
static pthread_mutex_t init_mutex = PTHREAD_MUTEX_INITIALIZER;
int lockerr;
@@ -976,24 +977,10 @@ use_builtin_flow(PGconn *conn, fe_oauth_state *state, PGoauthBearerRequestV2 *re
}
return (start_flow(conn, request) == 0) ? 1 : -1;
-}-
#else
--/*- * For static builds, we can just call pg_start_oauthbearer() directly. It's- * provided by libpq-oauth.a.- */--extern int pg_start_oauthbearer(PGconn *conn, PGoauthBearerRequestV2 *request);--static int-use_builtin_flow(PGconn *conn, fe_oauth_state *state, PGoauthBearerRequestV2 *request)-{
return (pg_start_oauthbearer(conn, request) == 0) ? 1 : -1;
-}-
#endif /* USE_LIBCURL */
+}
/*
--
2.53.0
[text/x-diff] v1-0002-Collapse-SH_CREATE-into-a-single-definition.patch (2.4K, ../87ldbuc3ik.fsf@gmail.com/3-v1-0002-Collapse-SH_CREATE-into-a-single-definition.patch)
download | inline diff:
From aa10a3818d3ec7c40b13880788780738856c6dca Mon Sep 17 00:00:00 2001
From: "Jonathan Gonzalez V." <jonathan.abdiel@gmail.com>
Date: Wed, 1 Jul 2026 12:36:52 +0200
Subject: [PATCH v1 2/2] Collapse SH_CREATE() into a single definition
The function had two conditional definitions that make lcov v2.x fail.
---
src/include/lib/simplehash.h | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/src/include/lib/simplehash.h b/src/include/lib/simplehash.hindex 15af488abfb..cda4347e60b 100644--- a/src/include/lib/simplehash.h+++ b/src/include/lib/simplehash.h@@ -138,6 +138,14 @@
#define SH_INSERT_HASH_INTERNAL SH_MAKE_NAME(insert_hash_internal)
#define SH_LOOKUP_HASH_INTERNAL SH_MAKE_NAME(lookup_hash_internal)
+#ifdef SH_RAW_ALLOCATOR+/* <prefix>_hash <prefix>_create(uint32 nelements, void *private_data) */+#define SH_CREATE_PARAMETERS uint32 nelements, void *private_data+#else+/* <prefix>_hash <prefix>_create(MemoryContext ctx, uint32 nelements, void *private_data) */+#define SH_CREATE_PARAMETERS MemoryContext ctx, uint32 nelements, void *private_data+#endif+
/* generate forward declarations necessary to use the hash table */
#ifdef SH_DECLARE
@@ -186,17 +194,7 @@ typedef struct SH_ITERATOR
} SH_ITERATOR;
/* externally visible function prototypes */
-#ifdef SH_RAW_ALLOCATOR-/* <prefix>_hash <prefix>_create(uint32 nelements, void *private_data) */-SH_SCOPE SH_TYPE *SH_CREATE(uint32 nelements, void *private_data);-#else-/*- * <prefix>_hash <prefix>_create(MemoryContext ctx, uint32 nelements,- * void *private_data)- */-SH_SCOPE SH_TYPE *SH_CREATE(MemoryContext ctx, uint32 nelements,- void *private_data);-#endif+SH_SCOPE SH_TYPE *SH_CREATE(SH_CREATE_PARAMETERS);
/* void <prefix>_destroy(<prefix>_hash *tb) */
SH_SCOPE void SH_DESTROY(SH_TYPE * tb);
@@ -442,13 +440,8 @@ SH_FREE(SH_TYPE * type, void *pointer)
* Memory other than for the array of elements will still be allocated from
* the passed-in context.
*/
-#ifdef SH_RAW_ALLOCATOR
SH_SCOPE SH_TYPE *
-SH_CREATE(uint32 nelements, void *private_data)-#else-SH_SCOPE SH_TYPE *-SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)-#endif+SH_CREATE(SH_CREATE_PARAMETERS)
{
SH_TYPE *tb;
uint64 size;
@@ -1217,6 +1210,7 @@ SH_STAT(SH_TYPE * tb)
#undef SH_GROW_MAX_MOVE
#undef SH_GROW_MIN_FILLFACTOR
#undef SH_MAX_SIZE
+#undef SH_CREATE_PARAMETERS
/* types */
#undef SH_TYPE
--
2.53.0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: jonathan.abdiel@gmail.com, pgsql-hackers@lists.postgresql.org
Subject: Re: Coverage (lcov) failing with inconsistent error in versions 2.x
In-Reply-To: <87ldbuc3ik.fsf@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox