Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: pgpool still broken; needs strchrnul() [Re: CVS: cvs.openbsd.org: ports]
To:
Landry Breuil <landry@cvs.openbsd.org>, ports@openbsd.org
Date:
Sat, 6 Jun 2026 15:29:45 +0200

Download raw body.

Thread
On Sat, Jun 06, 2026 at 02:51:22PM +0200, Theo Buehler wrote:
> On Sat, Jun 06, 2026 at 01:14:44PM +0100, Stuart Henderson wrote:
> > On 2026/06/05 02:24, Landry Breuil wrote:
> > > CVSROOT:	/cvs
> > > Module name:	ports
> > > Changes by:	landry@cvs.openbsd.org	2026/06/05 02:24:15
> > > 
> > > Modified files:
> > > 	databases/pgpool: Makefile distinfo 
> > > Removed files:
> > > 	databases/pgpool/patches: patch-src_include_utils_fe_ports_h 
> > > 	                          patch-src_include_watchdog_wd_utils_h 
> > > 	                          patch-src_utils_json_writer_c 
> > > 	                          patch-src_utils_ssl_utils_c 
> > > 	                          patch-src_watchdog_wd_escalation_c 
> > > 
> > > Log message:
> > > databases/pgpool: update to 4.6.7 and unbreak with llvm 22
> > > 
> > 
> > this wants strchrnul() which we don't have - an implementation is
> > available from Crystal though;
> > https://research.exoticsilicon.com/downloads/strchrnul_patchset_7.8.sig)
> 
> There's a compat impl in src/parse/snprintf.c. I suggest we copy a
> fixed version of that dance. Upstream should likely move all this into
> the appropriate compat header.
> 
> (I discussed this with landry, not sure if he missed a cvs add)
> 
> The port could also use a CFLAGS += -Wno-unknown-warning-option...

Here rebased on top of the %lld churn + fixes for remaining warnings:

config/pool_config_variables.c:3884:10: warning: format specifies type 'long long' but the argument has type 'int64' (aka 'long') [-Wformat]
 3883 |                                                         (errmsg("%lld is outside the valid range for parameter \"%s\" (%lld .. %lld)",
      |                                                                  ~~~~
      |                                                                  %ld
 3884 |                                                                         newval, name,
      |                                                                         ^~~~~~

etc. This is now relatively quiet (still some set but not used and str*
linker warnings).

Index: Makefile
===================================================================
RCS file: /cvs/ports/databases/pgpool/Makefile,v
diff -u -p -r1.22 Makefile
--- Makefile	6 Jun 2026 12:23:33 -0000	1.22
+++ Makefile	6 Jun 2026 13:13:12 -0000
@@ -25,6 +25,8 @@ COMPILER_LANG=	c
 CONFIGURE_STYLE= gnu
 CONFIGURE_ARGS=	--with-openssl
 
+CFLAGS+=	-Wno-unknown-warning-option
+
 USE_GMAKE=	Yes
 FAKE_FLAGS=	sysconfdir=${PREFIX}/share/examples/pgpool-II/
 
Index: patches/patch-src_config_pool_config_variables_c
===================================================================
RCS file: /cvs/ports/databases/pgpool/patches/patch-src_config_pool_config_variables_c,v
diff -u -p -r1.1 patch-src_config_pool_config_variables_c
--- patches/patch-src_config_pool_config_variables_c	6 Jun 2026 12:23:33 -0000	1.1
+++ patches/patch-src_config_pool_config_variables_c	6 Jun 2026 13:25:38 -0000
@@ -1,12 +1,16 @@
 Index: src/config/pool_config_variables.c
 --- src/config/pool_config_variables.c.orig
 +++ src/config/pool_config_variables.c
-@@ -3880,7 +3880,7 @@ setConfigOptionVar(struct config_generic *record, cons
+@@ -3880,9 +3880,9 @@ setConfigOptionVar(struct config_generic *record, cons
  				if (newval < conf->min || newval > conf->max)
  				{
  					ereport(elevel,
 -							(errmsg("%ld is outside the valid range for parameter \"%s\" (%ld .. %ld)",
+-									newval, name,
+-									conf->min, conf->max)));
 +							(errmsg("%lld is outside the valid range for parameter \"%s\" (%lld .. %lld)",
- 									newval, name,
- 									conf->min, conf->max)));
++									(long long)newval, name,
++									(long long)conf->min, (long long)conf->max)));
  					return false;
+ 				}
+ 
Index: patches/patch-src_query_cache_pool_memqcache_c
===================================================================
RCS file: /cvs/ports/databases/pgpool/patches/patch-src_query_cache_pool_memqcache_c,v
diff -u -p -r1.4 patch-src_query_cache_pool_memqcache_c
--- patches/patch-src_query_cache_pool_memqcache_c	6 Jun 2026 12:23:33 -0000	1.4
+++ patches/patch-src_query_cache_pool_memqcache_c	6 Jun 2026 13:23:09 -0000
@@ -15,14 +15,15 @@ Index: src/query_cache/pool_memqcache.c
  		ereport(FATAL,
  				(errmsg("invalid memory cache configuration"),
 -				 errdetail("memqcache_total_size %ld should be greater or equal to memqcache_cache_block_size %d",
+-						   pool_config->memqcache_total_size,
 +				 errdetail("memqcache_total_size %lld should be greater or equal to memqcache_cache_block_size %d",
- 						   pool_config->memqcache_total_size,
++						   (long long)pool_config->memqcache_total_size,
  						   pool_config->memqcache_cache_block_size)));
  
  	ereport(LOG,
  			(errmsg("memory cache initialized"),
 -			 errdetail("memcache blocks :%ld", num_blocks)));
-+			 errdetail("memcache blocks :%lld", num_blocks)));
++			 errdetail("memcache blocks :%lld", (long long)num_blocks)));
  	/* Remember # of blocks */
  	pool_set_memqcache_blocks(num_blocks);
  	size = pool_config->memqcache_cache_block_size * num_blocks;
Index: patches/patch-src_utils_pool_process_reporting_c
===================================================================
RCS file: /cvs/ports/databases/pgpool/patches/patch-src_utils_pool_process_reporting_c,v
diff -u -p -r1.1 patch-src_utils_pool_process_reporting_c
--- patches/patch-src_utils_pool_process_reporting_c	6 Jun 2026 12:23:33 -0000	1.1
+++ patches/patch-src_utils_pool_process_reporting_c	6 Jun 2026 13:12:29 -0000
@@ -1,7 +1,50 @@
 Index: src/utils/pool_process_reporting.c
 --- src/utils/pool_process_reporting.c.orig
 +++ src/utils/pool_process_reporting.c
-@@ -802,7 +802,7 @@ get_config(int *nrows)
+@@ -45,6 +45,42 @@ static void write_one_field_v2(POOL_CONNECTION * front
+ static char *db_node_status(int node);
+ static char *db_node_role(int node);
+ 
++/*
++ * XXX - taken from src/parser/snprintf.c
++ * This really belongs into a header. That the snprintf version isn't
++ * const correct is also not the greatest of ideas.
++ */
++/*
++ * If strchrnul exists (it's a glibc-ism), it's a good bit faster than the
++ * equivalent manual loop.  If it doesn't exist, provide a replacement.
++ *
++ * Note: glibc declares this as returning "char *", but that would require
++ * casting away const internally, so we don't follow that detail.
++ */
++#ifndef HAVE_STRCHRNUL
++
++static inline char *
++strchrnul(const char *s, int c)
++{
++	while (*s != '\0' && *s != (char)c)
++		s++;
++	return (char *)s;
++}
++
++#else
++
++/*
++ * glibc's <string.h> declares strchrnul only if _GNU_SOURCE is defined.
++ * While we typically use that on glibc platforms, configure will set
++ * HAVE_STRCHRNUL whether it's used or not.  Fill in the missing declaration
++ * so that this file will compile cleanly with or without _GNU_SOURCE.
++ */
++#ifndef _GNU_SOURCE
++extern char *strchrnul(const char *s, int c);
++#endif
++
++#endif							/* HAVE_STRCHRNUL */
++
+ void
+ send_row_description(POOL_CONNECTION * frontend, POOL_CONNECTION_POOL * backend,
+ 					 short num_fields, char **field_names)
+@@ -802,7 +838,7 @@ get_config(int *nrows)
  	/* OTHERS */
  
  	StrNCpy(status[i].name, "relcache_expire", POOLCONFIG_MAXNAMELEN);
@@ -10,7 +53,7 @@ Index: src/utils/pool_process_reporting.
  	StrNCpy(status[i].desc, "relation cache expiration time in seconds", POOLCONFIG_MAXDESCLEN);
  	i++;
  
-@@ -1076,7 +1076,7 @@ get_config(int *nrows)
+@@ -1076,7 +1112,7 @@ get_config(int *nrows)
  	i++;
  
  	StrNCpy(status[i].name, "memqcache_total_size", POOLCONFIG_MAXNAMELEN);