Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v3niL-003m4M-LG for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Oct 2025 03:41:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v3niI-00ExhK-02 for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Oct 2025 03:41:10 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1v3niH-00Exdp-2Q for pgsql-hackers@lists.postgresql.org; Wed, 01 Oct 2025 03:41:10 +0000 Received: from fout-b4-smtp.messagingengine.com ([202.12.124.147]) by makus.postgresql.org with smtp (Exim 4.96) (envelope-from ) id 1v3niB-000nl8-0O for pgsql-hackers@lists.postgresql.org; Wed, 01 Oct 2025 03:41:08 +0000 Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfout.stl.internal (Postfix) with ESMTP id 6E9631D001C5; Tue, 30 Sep 2025 23:41:02 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Tue, 30 Sep 2025 23:41:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1759290062; x=1759376462; bh=0T/e/1O5WP pXfFtTjKtG6au/L7AGQrcLSq3TGQKx1yg=; b=SvaxohAlov67wSck7NQgwtpW11 sK0sVI8d8JulpxGDld5aQUkrgmG6CUF9CfPtTfeGzeU+OePsLp1KBJhzAdmHCQ18 qlnZgAq7sC0jo8weSdAT/A+sFcGHSrm4SpBKfJxEGkumZDBR4uItvOk16Du79+jV JObv5/vzh+vic5UVHt4aFaOUVX9v0BysDoy5LKdxgTJGwUKqzNru4JvQQ7SOKLCF XHtyaMHZ/o4NtE5jjZiIUTttrMDoUoDkn+PPCzpCQtSeu3y9tcxytWx4MkYGHIas G3eS+D5pJTxrd+VEafX6GlPUtb70+drl+ttBE9UdPqw3jeZqsTpiW1ZhL3RQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t= 1759290062; x=1759376462; bh=0T/e/1O5WPpXfFtTjKtG6au/L7AGQrcLSq3 TGQKx1yg=; b=uANKIBN2ERPJZobm+E26y3zHO9dFSXML59uFvAzo80jl/yst16o nb8NgH6o8UFzJNj01mCqbRHOreEloU4rsn1iln+94nPfSZ8g6ggnuCbpE0igp6OU q8eem9M1ojIW1YPC728Q5kPa2G3F+kn4oXDWjPlxWCtzat/F7o0zxDhOq2VZxeMO 8xooqE7rPu+2yhT20hDkJYD31X2OjCnQwL0Vx4F71HK5IkCiIPXhSvy2mRb2PimL 5Dxjf9Ig8N1GfbT4sHWS8FY4E2dc619KO3SG7NyFeYhvEQy2XmsUCjXK74DFCF/r H7Cys1JBy12fR6OaY83Wsd91ZIMuIqD80dg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdekvddtkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeefpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegughhroh iflhgvhihmlhesghhmrghilhdrtghomhdprhgtphhtthhopehgrhgvghessghurhgurdhm vgdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehlihhsthhsrdhpohhsthhgrh gvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 30 Sep 2025 23:41:00 -0400 (EDT) Date: Wed, 1 Oct 2025 12:40:43 +0900 From: Michael Paquier To: David Rowley Cc: Greg Burd , PostgreSQL Hackers Subject: Re: [PATCH] Add tests for Bitmapset Message-ID: References: <76DBEF5D-EA47-4C30-8D28-97B3B88E2E2D@greg.burd.me> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HXHPcvGWWoBgrN3A" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --HXHPcvGWWoBgrN3A Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Oct 01, 2025 at 01:07:10PM +1300, David Rowley wrote: > On Wed, 1 Oct 2025 at 12:37, Michael Paquier wrote: >> This is also something I've considered as embedding in a macro, and >> discarded it. The reason was code readability, because it gives to >> the reader a quick knowledge of what can be freed once a call to a >> specific bitmapset.c routine is done, acting as a kind of reference >> template. Here, the free call knowledge gets hidden. test_bms_copy() >> becomes more confusing to me. This argument comes down to one's taste >> and philosophy on the matter of test modules. These are for me tools >> of coverage, but also can work as reference templates when calling an >> internal routine because we also document some of its implied >> behaviors, like the inputs recycled. >=20 > This sounds like another argument towards getting rid of the bms_frees > from the module. With the RETURN macro in mind, which itself cuts quite a little bit of code, I'd rather do as you are suggesting and remove the free calls, then. Embedding this knowledge in the return macro seems not much adapted to me, but I don't object to this macro idea per-se. > I'm not a huge fan of that part either. I didn't feel strongly enough > to change it when adjusting Greg's v2. For me, I don't see the problem > with leaving it up to nodeToString(), which will return "<>" for an > empty set. I think it's fine to leave it to nodeToString(). It is able to handle a NULL input on its own. > Thanks for explaining. Is anything being lost with the -1 return? > Since that's not a valid member for a set, -1 can only be returned if > bms_get_singleton_member() returned false. + if (!bms_get_singleton_member(bms, &member)) + member =3D -1; Hmm. On second look, if you do that, there's no knowledge lost, I guess. > Because you're not happy with embedding the bms_free() in with > PG_RETURN_BITMAPSET_AS_TEXT(), why don't we just get rid of all the > bms_free's? It's just a test module. If anyone ever comes complaining > about memory usage then we can reconsider. I think it's nice to keep > these wrappers as thin as possible in terms of the amount of C code. > Having conditional logic in them, IMO, risk hiding the true behaviour > of the underlying code that's being tested. Okay. Let's just remove as much code as possible, then. This is roughly what you have sent, minus the hardcoded empty set and the free calls. I'll just go do that in a bit. -- Michael --HXHPcvGWWoBgrN3A Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmjcorsACgkQnvQgOdby QH3A2g/8DJJkZeTQ2bBX7IGjnG7UdknDfjoupjOyT8ypxNtu1zCtw9uj8PZoQWFG Ksn5yNUNAViSI6QTS2stDUBrf1/p70+3kGhiOEszK1bYt81oJOaYqyAdyDnQAV9r LEvMA0h7RjfYglUcsaa1MDB8dptarQN+c1lHM3TDlOS9dj3Z3R4Ce1AwJdv3AyKn 6uy5v19T63jkQhQ7wZMkhZyxo9AoA8DI4QJDs9dEUOzJCH2Jcj8SyV4johyf1QX3 Vm8zHbq3ZUn3esKt4JaaekKIc+B2Vo/HVJV8QSOoEtRoGGCTspk0708PnVsQbyZL dEqGbx6b3jQHm8kXwsiMFdYAATyGgl1KwmZggoy+LhMPlHjRwzWuE2YNUkf6mihA 1xqmFDSVLblf0RVFSw1e30ev2ZP2No9hzHuY4XNtMyqLYPrIfdgxkxKh23EvBjdb ns8ezSDnckLOV5+ZI2a6tuwvKwEzq+kA9P79FnBFzOZ+2r7BD5p8wBTZWDuYKg5j Ql4W/GXkOGT3EEOuzy8V8p9mzCFujcoqWGrM6iO67ws2JCQYvWOg6uqQnTbm6Mbe HmNQhc4p8hyoQrsJFC9LNvMJ/b2fs95xciUgrN+XVCzzKmQktGfj6Z/y8+IMw+GR DG4FRmFRBJNdJGQdIXXulOJbZ2G0EaWMeIdav7xVwVwSHJkwDAU= =ugM4 -----END PGP SIGNATURE----- --HXHPcvGWWoBgrN3A--