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 1uyOnj-007Wg6-D9 for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Sep 2025 06:04:27 +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 1uyOng-00Fb2X-3M for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Sep 2025 06:04:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uyOnf-00Fb2P-QI for pgsql-hackers@lists.postgresql.org; Tue, 16 Sep 2025 06:04:24 +0000 Received: from fhigh-b2-smtp.messagingengine.com ([202.12.124.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uyOnc-0014is-29 for pgsql-hackers@lists.postgresql.org; Tue, 16 Sep 2025 06:04:24 +0000 Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfhigh.stl.internal (Postfix) with ESMTP id 651287A026B; Tue, 16 Sep 2025 02:04:20 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-06.internal (MEProxy); Tue, 16 Sep 2025 02:04:20 -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=fm1; t=1758002660; x=1758089060; bh=V951EcyvDy /T5992reqc1GoJEqvQCcEpdcSZ+u/rSvk=; b=Ofvfs8Ra/5Q3LiciJEXBa2woLE bmI2shgLRengekkQoHtX1Ywtg3ZojspNt22xJHLBGHbQvYKujlNA2qwOukJNaT8V yitXw1r+gyJO2Eh1jYgXoDiM9vGj5KNH5AQhzRa3g8g4PT7TzRxHoZVilSR5vRhM fUpOL3GJsZKqJifnCa+wfg+Y16YmXyv/ECNNEohnyscTwYFMqVOfYz2YsJYLYXvC CdGcRBviE5/Ytb+1FTwRb4W++7iC8rEe/2G7azpK492wsBg3zrQDAo3D3u+O7JOa uVb4n5vGvFJz4V6nRQNk6cJnfFhcu1pLVZeHrhNzO2TREqGevZN8MzjsFa+Q== 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=fm1; t= 1758002660; x=1758089060; bh=V951EcyvDy/T5992reqc1GoJEqvQCcEpdcS Z+u/rSvk=; b=dqi4lFa1l4T3NiBV4lOwcjJRAoYyscB3YDhTS8U3d5xQCcTGh1s Q1v3EjU/NLaK3U0xckBzu+FuWbkhP3nhJxbwbacr8VwqhQOr8X5HbreVc+g+0Eqw DfvCT4OsQuw/ssqPBlQFbqDOGfeajwu0t6fjH0+geKwB5WdbtR9Rpc0jAuntQhi7 iztl5lxMed29jOQyPSZmvx6OniuNqcnffrAS4sTB3Ej22V1eDJyVJCHyT7hD14x0 W85JmGI1blHtL6xMUGYBJjpeIU755m0pezMQnLF1uhAb9oBWmfKW8w/WgEmlvOK9 aeWD0NEKiGSAKpOpP4cHTPyStg9qWSleZXA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdefleektdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfghrlh cuvffnffculdejtddmnecujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvden ucfhrhhomhepofhitghhrggvlhcurfgrqhhuihgvrhcuoehmihgthhgrvghlsehprghquh hivghrrdighiiiqeenucggtffrrghtthgvrhhnpeetleeifedufffhhfdtteelgeeggeff hfekueevteeigfduudevudetgfegiedvjeenucevlhhushhtvghrufhiiigvpedtnecurf grrhgrmhepmhgrihhlfhhrohhmpehmihgthhgrvghlsehprghquhhivghrrdighiiipdhn sggprhgtphhtthhopeehpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopehgrhgvgh essghurhgurdhmvgdprhgtphhtthhopehrohgsvghrthhmhhgrrghssehgmhgrihhlrdgt ohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrsheslhhishhtshdrphhoshhtgh hrvghsqhhlrdhorhhgpdhrtghpthhtohepnhgrthhhrghnuggsohhsshgrrhhtsehgmhgr ihhlrdgtohhmpdhrtghpthhtohepshgrfigruggrrdhmshhhkhesghhmrghilhdrtghomh X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Sep 2025 02:04:17 -0400 (EDT) Date: Tue, 16 Sep 2025 15:04:03 +0900 From: Michael Paquier To: Greg Burd Cc: Robert Haas , PostgreSQL Hackers , Nathan Bossart , Masahiko Sawada Subject: Re: [PATCH] Add tests for Bitmapset Message-ID: References: <0FE0B26D-B94A-4BA7-BCA4-338C020609D9@greg.burd.me> <1CA731DE-B1BD-45C2-95B5-7E83FFE0E35C@greg.burd.me> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="Nfg+wjLtD+3D/Zbj" Content-Disposition: inline In-Reply-To: <1CA731DE-B1BD-45C2-95B5-7E83FFE0E35C@greg.burd.me> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Nfg+wjLtD+3D/Zbj Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 15, 2025 at 03:56:30PM -0400, Greg Burd wrote: > Reworked as indicated, thanks for pointing out the anti-pattern I'd > missed. Hmm. Should we try to get something closer in shape to what we do for the SLRU tests, with one SQL function mapping to each C function we are testing? This counts for bms_is_member(), bms_num_members(), add, del, mul, hash and make_singleton. +test_bms_del_member_negative(PG_FUNCTION_ARGS) +{ + /* This should throw an error for negative member */ + bms_del_member(NULL, -20); + PG_RETURN_VOID(); For example, this case could use a Bitmapset and a number (or an array of numbers for repeated operations), with NULL being one option for the input Bitmapset. This makes the tests a bit more representative of what they do at SQL level, hence there would be no need to double-check a given line where a failure happens. The Bitmapset could then be passed around as bytea blobs using \gset, for example. This should not be a problem as long as they are palloc'd in the=20 TopMemoryContext. The SQL output for true/false/NULL/non-NULL generated as output of the test could then be used instead of the EXPECT_*() macros reported then in the elogs. Perhaps my view of things is too cute and artistic, but when these test suites grow over time and differ across branches, having to dig into a specific line of a specific branch to get what a problem is about is more error-prone. Particularly annoying when calling one single function that does a lot of various actions, like the proposed test_bitmapset(). Side note: `git diff --check` is reporting a bunch of indents with spaces around the EXPECT macros. -- Michael --Nfg+wjLtD+3D/Zbj Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIyBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmjI/dMACgkQnvQgOdby QH2SAQ/4ybTlc1jj+LTQVhqQ0NAG817O8C7IArqDxhRFiqXdNr+tnNJHsMYnLwdD 8NMEMbLjutYk6uT6q0Zv8w6TKgiKdBxjwsmqxyGxCtzJYf51HYlxXiupfJU2IUf2 HjK+H/ygVASWI5R5ew0dDlSMfep+x1nSLgn7jrwhxs6NoyLqQ7s8PkGXTmtJG9Dl uQBDQM63WFGuAqMRZDTmcPGlar+f3ou8gsZKdwp2C2a8dAzcGoa1g7IEa5nTJQrU OHq4IznfY72q1QS2uYlLaHUPSOyYlCY1gSZdw5Iojy/eR6s4PVm+BNfRTnkoyvXz A7NTzofokeYFuJ5nAGpfQHYAeFu8oPdEjKpGj+jJDbj5mBueVK90rEnuys2yn91T xsqTuTmpT3CXE3zRtvw+MimEe4kir00xjyaLCQQ6hT2FhDFHDjHHpzIIhDWF8iP9 7IQfoTpmvbabLhkK1xHjmaDjp4TfJ2OZl7QUJbDcmDQunwDKRFkZmJl5SdSVc/Rs PLhjGWldzkhZDQwCf4UVsVVNTJVoIR6g+mkUKvPeAgMuMkAl2KoE2AThzbfJGbgS lt0mfJE4ToxGtm3PAql8nqTiE6wni8yCq8l+dy+O5yDy3vbhbAzC9DNEC/rlUYyh OiFnAYW0MdwCiXXmXtqxVcVMS0YE5skv2BHCnF7eN0Z9g3tV2A== =fiBb -----END PGP SIGNATURE----- --Nfg+wjLtD+3D/Zbj--