Index | Thread | Search

From:
Stuart Henderson <stu@spacehopper.org>
Subject:
Re: pgpool-II: Update to 4.6.0
To:
Martijn van Duren <openbsd+ports@list.imperialat.at>
Cc:
ports@openbsd.org
Date:
Thu, 29 May 2025 19:15:57 +0100

Download raw body.

Thread
I don't use this but the diff looks sane.

It would be good to add a comment to the head of
patch-src_utils_json_writer_c with a reference to the upstream
commit, it's usual to just include the git patch header e.g.

From 14c94473b5b59429186d8c65407bcce17a20cf99 Mon Sep 17 00:00:00 2001
From: Bo Peng <pengbo@sraoss.co.jp>
Date: Thu, 1 May 2025 11:36:55 +0900
Subject: [PATCH] Fix json_writer did not properly encode special characters.

Don't hold your breath waiting for a reply from the maintainer ;)


On 2025/05/29 17:56, Martijn van Duren wrote:
> ping
> 
> On Fri, 2025-05-02 at 15:28 +0200, Martijn van Duren wrote:
> > Hello ports@,
> > 
> > I'm currently experimenting with a setup where I expect to be using
> > pgpool-II. It appears that everything works as expected with the
> > update below. The only thing that doesn't seem to work is the new
> > wd_monitoring_interfaces_list functionality, for which I don't see
> > a direct need for my own setup and which probably needs some
> > OpenBSD specific code.
> > 
> > The json_writer.c bit is a bug I hit and got accepted upstream[0]
> > 
> > OK?
> > 
> > martijn@
> > 
> > [0] https://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=14c94473b5b59429186d8c65407bcce17a20cf99
> > 
> > diff /usr/ports
> > path + /usr/ports
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - 7b727f2f1bf26c69a4dc850af2467de70dc34498
> > file + databases/pgpool/Makefile
> > --- databases/pgpool/Makefile
> > +++ databases/pgpool/Makefile
> > @@ -1,7 +1,6 @@
> >  COMMENT= 	connection pool server for PostgreSQL
> >  
> > -DISTNAME= 	pgpool-II-3.7.18
> > -REVISION=	1
> > +DISTNAME= 	pgpool-II-4.6.0
> >  
> >  CATEGORIES= 	databases
> >  
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - 20e05c1a006ebc4e5571c61db88536c1b0fbd841
> > file + databases/pgpool/distinfo
> > --- databases/pgpool/distinfo
> > +++ databases/pgpool/distinfo
> > @@ -1,2 +1,2 @@
> > -SHA256 (pgpool-II-3.7.18.tar.gz) = 0I4zuZYUjHukHw5PWjMLU5Ec1srJTHh3gIewaMjaCX4=
> > -SIZE (pgpool-II-3.7.18.tar.gz) = 3447131
> > +SHA256 (pgpool-II-4.6.0.tar.gz) = 9oplcUQtfqU7afOddJrUV3kLABgOGbAZ/ILiNbqwcyE=
> > +SIZE (pgpool-II-4.6.0.tar.gz) = 5396128
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - /dev/null
> > file + databases/pgpool/patches/patch-src_include_utils_fe_ports_h (mode 644)
> > --- /dev/null
> > +++ databases/pgpool/patches/patch-src_include_utils_fe_ports_h
> > @@ -0,0 +1,11 @@
> > +Index: src/include/utils/fe_ports.h
> > +--- src/include/utils/fe_ports.h.orig
> > ++++ src/include/utils/fe_ports.h
> > +@@ -28,6 +28,7 @@
> > + #error "This file is not expected to be compiled for pgpool utilities only"
> > + #endif
> > + 
> > ++#include <stdarg.h>
> > + #include <stdlib.h>
> > + #ifndef FE_PORTS
> > + #define FE_PORTS
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - f557cc3cf3fd3092e985cbfd30ed054e91427d8c
> > file + /dev/null
> > --- databases/pgpool/patches/patch-src_query_cache_pool_memqcache_c
> > +++ /dev/null
> > @@ -1,36 +0,0 @@
> > -Fix 64-bit time_t issues
> > -
> > -Index: src/query_cache/pool_memqcache.c
> > ---- src/query_cache/pool_memqcache.c.orig
> > -+++ src/query_cache/pool_memqcache.c
> > -@@ -265,7 +265,7 @@ static int pool_commit_cache(POOL_CONNECTION_POOL *bac
> > - 	memqcache_expire = pool_config->memqcache_expire;
> > - 	ereport(DEBUG1,
> > - 		(errmsg("commiting SELECT results to cache storage"),
> > --			 errdetail("memqcache_expire = %ld", memqcache_expire)));
> > -+			 errdetail("memqcache_expire = %lld", (long long)memqcache_expire)));
> > - 
> > - 	if (pool_is_shmem_cache())
> > - 	{
> > -@@ -2536,8 +2536,8 @@ static POOL_CACHEID *pool_find_item_on_shmem_cache(POO
> > - 		{
> > - 			ereport(DEBUG1,
> > - 				(errmsg("memcache finding item"),
> > --					errdetail("cache expired: now: %ld timestamp: %ld",
> > --						   now, cih->timestamp + pool_config->memqcache_expire)));
> > -+					errdetail("cache expired: now: %lld timestamp: %lld",
> > -+						   (long long)now, (long long)cih->timestamp + pool_config->memqcache_expire)));
> > - 			pool_delete_item_shmem_cache(c);
> > - 			return NULL;
> > - 		}
> > -@@ -2826,8 +2826,8 @@ static void dump_shmem_cache(POOL_CACHE_BLOCKID blocki
> > - 		fprintf(stderr, "shmem: block: %d %d th item pointer(%lu bytes): offset:%d flags:%x\n",
> > - 				blockid, i, sizeof(*cip), cip->offset, cip->flags);
> > - 		cih = item_header((char *)bh, i);
> > --		fprintf(stderr, "shmem: block: %d %d th item header(%lu bytes): timestamp:%ld length:%d\n",
> > --				blockid, i, sizeof(*cih), cih->timestamp, cih->total_length);
> > -+		fprintf(stderr, "shmem: block: %d %d th item header(%lu bytes): timestamp:%lld length:%d\n",
> > -+				blockid, i, sizeof(*cih), (long long)cih->timestamp, cih->total_length);
> > - 	}
> > - }
> > - #endif
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - /dev/null
> > file + databases/pgpool/patches/patch-src_utils_json_writer_c (mode 644)
> > --- /dev/null
> > +++ databases/pgpool/patches/patch-src_utils_json_writer_c
> > @@ -0,0 +1,63 @@
> > +Index: src/utils/json_writer.c
> > +--- src/utils/json_writer.c.orig
> > ++++ src/utils/json_writer.c
> > +@@ -26,6 +26,7 @@
> > + #include "utils/palloc.h"
> > + #include "utils/json_writer.h"
> > + 
> > ++static void jw_put_string_escape(JsonNode * jNode, char *string);
> > + static inline int jw_get_current_element_count(JsonNode * jNode);
> > + static inline void jw_inc_current_element_count(JsonNode * jNode);
> > + static inline JWElementType jw_get_current_element_type(JsonNode * jNode);
> > +@@ -67,9 +68,50 @@ jw_put_string(JsonNode * jNode, char *key, char *value
> > + 
> > + 	if (jw_get_current_element_count(jNode) > 0)
> > + 		appendStringInfoChar(jNode->buf, ',');
> > +-	appendStringInfo(jNode->buf, "\"%s\":\"%s\"", key, value);
> > ++	jw_put_string_escape(jNode, key);
> > ++	appendStringInfoChar(jNode->buf, ':');
> > ++	jw_put_string_escape(jNode, value);
> > + 	jw_inc_current_element_count(jNode);
> > + 	return true;
> > ++}
> > ++
> > ++static void
> > ++jw_put_string_escape(JsonNode * jNode, char *string)
> > ++{
> > ++	int i;
> > ++
> > ++	appendStringInfoChar(jNode->buf, '"');
> > ++	for (i = 0; string[i] != '\0'; i++)
> > ++	{
> > ++		switch (string[i])
> > ++		{
> > ++			case '\"':
> > ++				appendStringInfo(jNode->buf, "\\\"");
> > ++				break;
> > ++			case '\\':
> > ++				appendStringInfo(jNode->buf, "\\\\");
> > ++				break;
> > ++			case '\b':
> > ++				appendStringInfo(jNode->buf, "\\b");
> > ++				break;
> > ++			case '\f':
> > ++				appendStringInfo(jNode->buf, "\\f");
> > ++				break;
> > ++			case '\n':
> > ++				appendStringInfo(jNode->buf, "\\n");
> > ++				break;
> > ++			case '\r':
> > ++				appendStringInfo(jNode->buf, "\\r");
> > ++				break;
> > ++			case '\t':
> > ++				appendStringInfo(jNode->buf, "\\t");
> > ++				break;
> > ++			default:
> > ++				appendStringInfoChar(jNode->buf, string[i]);
> > ++				break;
> > ++		}
> > ++	}
> > ++	appendStringInfoChar(jNode->buf, '"');
> > + }
> > + 
> > + /* for compatibility reasons we pack bool in int*/
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - 76606da9c6c164fc036ca5bbbc4e24bb2ddb3235
> > file + /dev/null
> > --- databases/pgpool/patches/patch-src_utils_pool_relcache_c
> > +++ /dev/null
> > @@ -1,14 +0,0 @@
> > -Fix 64-bit time_t issue
> > -
> > -Index: src/utils/pool_relcache.c
> > ---- src/utils/pool_relcache.c.orig
> > -+++ src/utils/pool_relcache.c
> > -@@ -148,7 +148,7 @@ void *pool_search_relcache(POOL_RELCACHE *relcache, PO
> > - 				{
> > - 					ereport(DEBUG1,
> > - 						(errmsg("searching relcache"),
> > --							 errdetail("relcache for database:%s table:%s expired. now:%ld expiration time:%ld", dbname, table, now, relcache->cache[i].expire)));
> > -+							 errdetail("relcache for database:%s table:%s expired. now:%lld expiration time:%lld", dbname, table, (long long)now, (long long)relcache->cache[i].expire)));
> > - 
> > - 					relcache->cache[i].refcnt = 0;
> > - 					break;
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - /dev/null
> > file + databases/pgpool/patches/patch-src_utils_ssl_utils_c (mode 644)
> > --- /dev/null
> > +++ databases/pgpool/patches/patch-src_utils_ssl_utils_c
> > @@ -0,0 +1,21 @@
> > +Index: src/utils/ssl_utils.c
> > +--- src/utils/ssl_utils.c.orig
> > ++++ src/utils/ssl_utils.c
> > +@@ -221,7 +221,7 @@ calculate_hmac_sha256(const char *data, int len, char 
> > + 	unsigned int res_len = WD_AUTH_HASH_LEN;
> > + 	HMAC_CTX   *ctx = NULL;
> > + 
> > +-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined (LIBRESSL_VERSION_NUMBER))
> > ++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
> > + 	ctx = HMAC_CTX_new();
> > + 	HMAC_CTX_reset(ctx);
> > + #else
> > +@@ -233,7 +233,7 @@ calculate_hmac_sha256(const char *data, int len, char 
> > + 	HMAC_Init_ex(ctx, key, strlen(key), EVP_sha256(), NULL);
> > + 	HMAC_Update(ctx, (unsigned char *) data, len);
> > + 	HMAC_Final(ctx, (unsigned char *) str, &res_len);
> > +-#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined (LIBRESSL_VERSION_NUMBER))
> > ++#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
> > + 	HMAC_CTX_reset(ctx);
> > + 	HMAC_CTX_free(ctx);
> > + #else
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - e86dbdc672216d188f8c9693552977e9d558866f
> > file + databases/pgpool/patches/patch-src_watchdog_wd_escalation_c
> > --- databases/pgpool/patches/patch-src_watchdog_wd_escalation_c
> > +++ databases/pgpool/patches/patch-src_watchdog_wd_escalation_c
> > @@ -1,12 +1,13 @@
> >  Index: src/watchdog/wd_escalation.c
> >  --- src/watchdog/wd_escalation.c.orig
> >  +++ src/watchdog/wd_escalation.c
> > -@@ -27,7 +27,7 @@
> > +@@ -27,9 +27,7 @@
> >   #include <unistd.h>
> >   #include <errno.h>
> >   
> >  -#ifdef __FreeBSD__
> > -+#if defined(__FreeBSD__) || defined(__OpenBSD__)
> >   #include <sys/wait.h>
> > - #endif
> > +-#endif
> >   
> > + #include "utils/pool_signal.h"
> > + #include "utils/elog.h"
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - a3e6cd33e21ff2261ca7a489f5b176dcb99c8ced
> > file + /dev/null
> > --- databases/pgpool/patches/patch-src_watchdog_wd_utils_c
> > +++ /dev/null
> > @@ -1,23 +0,0 @@
> > -Fix build with opaque HMAC_CTX in LibreSSL 3.5.
> > -
> > -Index: src/watchdog/wd_utils.c
> > ---- src/watchdog/wd_utils.c.orig
> > -+++ src/watchdog/wd_utils.c
> > -@@ -154,7 +154,7 @@ static void calculate_hmac_sha256(const char *data, in
> > - 	unsigned int res_len = WD_AUTH_HASH_LEN;
> > - 	HMAC_CTX *ctx = NULL;
> > - 
> > --#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined (LIBRESSL_VERSION_NUMBER))
> > -+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
> > - 	ctx = HMAC_CTX_new();
> > - 	HMAC_CTX_reset(ctx);
> > - #else
> > -@@ -165,7 +165,7 @@ static void calculate_hmac_sha256(const char *data, in
> > - 	HMAC_Init_ex(ctx, key, strlen(key), EVP_sha256(), NULL);
> > - 	HMAC_Update(ctx, (unsigned char*)data, len);
> > - 	HMAC_Final(ctx, (unsigned char*)str, &res_len);
> > --#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined (LIBRESSL_VERSION_NUMBER))
> > -+#if (OPENSSL_VERSION_NUMBER >= 0x10100000L)
> > - 	HMAC_CTX_reset(ctx);
> > - 	HMAC_CTX_free(ctx);
> > - #else
> > commit - 0fbcf24b3e32197a3a763c2c08e4480204b0b998
> > blob - f0b07253b47cf1f6356b8a1640750064b618f729
> > file + databases/pgpool/pkg/PLIST
> > --- databases/pgpool/pkg/PLIST
> > +++ databases/pgpool/pkg/PLIST
> > @@ -3,6 +3,9 @@
> >  @rcscript ${RCDIR}/pgpool
> >  @bin bin/pcp_attach_node
> >  @bin bin/pcp_detach_node
> > +@bin bin/pcp_health_check_stats
> > +@bin bin/pcp_invalidate_query_cache
> > +@bin bin/pcp_log_rotate
> >  @bin bin/pcp_node_count
> >  @bin bin/pcp_node_info
> >  @bin bin/pcp_pool_status
> > @@ -10,12 +13,16 @@
> >  @bin bin/pcp_proc_info
> >  @bin bin/pcp_promote_node
> >  @bin bin/pcp_recovery_node
> > +@bin bin/pcp_reload_config
> >  @bin bin/pcp_stop_pgpool
> >  @bin bin/pcp_watchdog_info
> > +@bin bin/pg_enc
> >  @bin bin/pg_md5
> >  @bin bin/pgpool
> >  bin/pgpool_setup
> > +@bin bin/pgproto
> >  bin/watchdog_setup
> > +@bin bin/wd_cli
> >  include/libpcp_ext.h
> >  include/pcp.h
> >  include/pool_process_reporting.h
> > @@ -26,16 +33,21 @@ lib/libpcp.la
> >  @so lib/postgresql/pgpool-regclass.so
> >  @man man/man8/pgpool.8
> >  share/examples/pgpool-II/
> > +share/examples/pgpool-II/aws_eip_if_cmd.sh.sample
> > +share/examples/pgpool-II/aws_rtb_if_cmd.sh.sample
> > +share/examples/pgpool-II/escalation.sh.sample
> > +share/examples/pgpool-II/failover.sh.sample
> > +share/examples/pgpool-II/follow_primary.sh.sample
> >  share/examples/pgpool-II/pcp.conf.sample
> >  @sample ${SYSCONFDIR}/pcp.conf
> >  share/examples/pgpool-II/pgpool.conf.sample
> >  @sample ${SYSCONFDIR}/pgpool.conf
> > -share/examples/pgpool-II/pgpool.conf.sample-logical
> > -share/examples/pgpool-II/pgpool.conf.sample-master-slave
> > -share/examples/pgpool-II/pgpool.conf.sample-replication
> > -share/examples/pgpool-II/pgpool.conf.sample-stream
> > +share/examples/pgpool-II/pgpool_remote_start.sample
> >  share/examples/pgpool-II/pool_hba.conf.sample
> >  @sample ${SYSCONFDIR}/pool_hba.conf
> > +share/examples/pgpool-II/recovery_1st_stage.sample
> > +share/examples/pgpool-II/replication_mode_recovery_1st_stage.sample
> > +share/examples/pgpool-II/replication_mode_recovery_2nd_stage.sample
> >  share/pgpool-II/
> >  share/pgpool-II/insert_lock.sql
> >  share/pgpool-II/pgpool.pam
> > 
>