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.96) (envelope-from ) id 1x3yVK-006nha-2g for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2026 16:17:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x3yVJ-008Y9a-2e for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Sep 2026 16:17:01 +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.96) (envelope-from ) id 1x3yVJ-008Y9S-0D for pgsql-hackers@lists.postgresql.org; Tue, 08 Sep 2026 16:17:01 +0000 Received: from fhigh-a3-smtp.messagingengine.com ([103.168.172.154]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x3yVH-00000004ckD-03NR for pgsql-hackers@lists.postgresql.org; Tue, 08 Sep 2026 16:17:00 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id B1B0C1400067; Tue, 8 Sep 2026 12:16:57 -0400 (EDT) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-02.internal (MEProxy); Tue, 08 Sep 2026 12:16:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; h=cc:cc :content-transfer-encoding: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=1788884217; x=1788970617; bh=TFFLMktbHTd+OQwChK/i/cz/C0l40SrveZ9CXt/hHRc=; b= fUHF0ojl3zIpzL4mBsjd9WtRTuoS9BdE76xVEO8J7WRR2tWH+OZmcgW+PmPHYpkV dqwGeTr3yx1YR8l2hyqT6Hs1/dnsK1JXUC+xqZ0h2QkfEHMZx+QcZdxykTUisjG7 F0fLDkNllME8JA+gS7RKvdaT9grb+X+e89fuztNPWwUMS8NpxStQjCvxJDr6zLKS f6D150I1mzM52l93SEHoEp6p5j2wWmvqOHbMUu42SBFrqV95E4blYmWhcx4ipNPi SoH5kW7OZ1LfmIA8nx9MaQihu6xdigvEjN3aMo+WPtV5UfJCGDE8kQNtAgNdfMpy /4jy1hgYcSfihxWLsf4zeQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=1788884217; x= 1788970617; bh=TFFLMktbHTd+OQwChK/i/cz/C0l40SrveZ9CXt/hHRc=; b=X E+qD1EMvcr+I2g+iEkgVhdNv4ojKC+kdqglJwKt66VVOcl4m5N4Yzj3n0Gy62in+ cwkse3bHy86//pOQf78hAIeaTPEYM8sgTHdiHBJpStNyWe10tViHBl4d9tnS7tuw iaYuEZawPger0nvIdqEsImaumBPRME5BmidRQk2Sxd6BRQ3CBCcnIpMj5+LTSiOe 4FLUqfo3n19esDGuAvLhIrDF9ZR1ru8ljC1SazrTAM3yHCwneXsNu/zsmioBG6mK tgqH+/fU0+wHzpgROxfuvvMyqrVBnBrbNmpDnzgXXEuwIBgjiNb9EOF7yz1DsJqy Npvm/zb2fcQJs056OxuQg== X-ME-Sender: X-ME-Proxy-Cause: dmFkZTFOFplhHqSfF+X8wHydMVC3wsNTMR8WejrlS91DYMs7UPw7u/Rysus0T1tPmlJDSS zVemC89OQ6epAX/AYMO3YHtXlVzOzkSnaxQgCofLBpQp5cAfa/C97sSZPUAz96Bpj9+hKF 8p5bkT4lcrjtYHTkTFKyF9ZZmq+WPByxfMhWkfz8sIyvZ3VLw4LIZwvcZ7IxfGTAWcYoly gPXipy9+YWPEE2wQKBorbtsCunWLKGxK7KFhny0FmTnl055oH8pBq1gaejU1hA/T1LfgrJ uhFagaYZSk0/mOppMExDbUpLlkUOX++5PF8dUbyHskBiqSaySDTQPuDyFyvioO4M7MydD9 pMc5/NPZZk3nfOsYRnwu89bOa7RtVmqhT4jo/plYGqK+aV/LzQOBRFDxKvkO3N58Ab3JIe i5oKzTH5zdDkb9oFYFBhuGD7mKFozSSWQAbKIwb3yQexJt6GCD5mpzaZ0t18EEYL8KxBwl e/zq49hKUjgEfuBumWKk9eZsXBK62HRDz/wKoxQrGFGHiEfKpZ/wr/zIklDSKE83lZR/Fw 34SsU02saz8vfIolknslLBthpckmyIl9NWWqrWty5Ty+XgA2irsOm0su1M7WhCstkLovGM MpBBuY9vFUWkQnaj89fsv5SuF7pTHz/3zgUrPYf27aogEkQiBkVbnUZejdEA X-ME-Proxy: Feedback-ID: i675e48f3:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 21E85700069; Tue, 8 Sep 2026 12:16:57 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 Date: Tue, 08 Sep 2026 12:16:36 -0400 From: "Greg Burd" To: "Michael Paquier" , "Zsolt Parragi" Cc: "PostgreSQL Hackers" , aleksander@tigerdata.com Message-Id: <588e8d2d-b68d-480f-95a1-0c87183ebf99@app.fastmail.com> In-Reply-To: References: Subject: Re: Improve error handling in test modules: test_extensible, test_bitmapset Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, Sep 8, 2026, at 3:14 AM, Michael Paquier wrote: > I am not much a fan of spreading pg_strtok() calls more than > necessary in this module. How about extending > test_ext_node_next_token() with an "expected" argument to enforce some > validation? Agreed, one chokepoint for pg_strtok() is better. Worth being explicit in the comment that the two modes fail differently, though: with expected == NULL the function ereports on a short read, and with a non-NULL expected it has to hand a mismatch back to the caller so text_to_test_ext_node() can keep emitting its single "argument is not a serialized %s" error rather than four separate ones. That's a bit of behavior keyed off whether an argument is NULL, so it should be spelled out rather than inferred. > I am not convinced that we need to check all the input function calls > in 0001 and 0002. [...] Let's just pick up one, reduce the duplicates. +1, and for test_bitmapset there's a concrete reason it's safe: every SQL wrapper decodes through the same PG_ARG_GETBITMAPSET -> text_to_bitmapset() path, 48 call sites, and there's no second decode route. So one function exercises the whole thing and the rest is duplicate coverage. I'd fold test_bms_copy('{VAR}') into test_bms_num_members() with the others. I'd keep test_bms_copy('<>'), though. That one isn't testing rejection, it's checking that an empty set survives the round trip and comes back out as '<>', which num_members can't show you since it just returns 0. Different coverage, cheap to keep. I did confirm the bug is real before the fix: with 0002 reverted, SELECT test_bms_num_members('{QUERY}') takes the backend down and the cluster goes into recovery, no privileges needed. So this is worth fixing even for a test module. Thanks for catching it, Zsolt. One thing not yet mentioned: after the fix, bad input surfaces as elog(ERROR) out of _readBitmapset(), so you get ERROR: XX000: unrecognized token: "{" XX000 normally means "we hit a bug," not "you passed garbage." Those elogs are internal-error paths in readfuncs.c that were never meant to be user-reachable, and the SQL functions here make them reachable. I don't think this patch should try to fix readfuncs.c, and I'm fine with it as-is for a test module, but if we're holding this up as a template for extension authors then the honest version catches the bad input in text_to_bitmapset() and reports it with ERRCODE_INVALID_TEXT_REPRESENTATION, the way test_extensible already does for its own node. Happy to leave that as a follow-up if you'd rather keep these patches tight. best, -greg