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.98.2) (envelope-from ) id 1x7Zmo-00000000UUg-0RUT for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Sep 2026 14:41:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x7Zmn-00000001a26-1GdK for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Sep 2026 14:41:57 +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.98.2) (envelope-from ) id 1x7Zm2-00000001XPU-3Bez for pgsql-hackers@lists.postgresql.org; Fri, 18 Sep 2026 14:41:10 +0000 Received: from mail-qv2-x16.google.com ([2607:f8b0:4864:33::16]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x7Zm0-000000002qA-2L9C for pgsql-hackers@lists.postgresql.org; Fri, 18 Sep 2026 14:41:10 +0000 Received: by mail-qv2-x16.google.com with SMTP id 6a1803df08f44-90cdfc6db0bso7160446d6.3 for ; Fri, 18 Sep 2026 07:41:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1789742467; x=1790347267; darn=lists.postgresql.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=QBg4tb8eNEaCr7XiSD6SUCRXwuyfOWlW6M3KJkAHNZY=; b=TqcvbqgfqE+UUn9gyJ16+QNAtF5U+NcdvPYle6j/jvGYa93+NUJkNtL38zhFkf5rrk QO7nfiNisvILodNzQf6VWhqhY2jxzgyillScjiQ7zpUzs4ErRm37xgYxx5SbGp4dU0m3 UcoPMsh0WBdJnkJYik7XXrJj0CuWKbmqoN/ZErtTavDGx9yTSqSj9dt8jTfP34HbKGDl XCTvDlmdKMBr9YtfbOchvQObElMJdAVydy/DY9gYUdNSOroaNzXo2ozJiaMVtOELVwTW 8csfEeYZY1gR9JIyLDr2SVdmfp8HERyBCpdDUkoi+xpVl5JdvVqmHp4OKtS2d68FcfGU v0rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1789742467; x=1790347267; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=QBg4tb8eNEaCr7XiSD6SUCRXwuyfOWlW6M3KJkAHNZY=; b=2syc38tOV88cP3/RShYvlA3Tp3fuVZ2hOVukuS4KAUlSKBtQIXUmo/ix0bSjoYobnR yAS8PFJTHbXTwWcsom2IKK0SSkT98HMV3NGCDZ4N/pCoxuyETyJen0svYg0NrTMgOssW h1HkQ2mpBbTDocm0557WStgkb6wNWUtkedxUuA/mIVJb0ExQPlgRSsH8MtfKwf3ytaIf Mya47eJQM1LuM27zTYjcbTlYbl0LNiG8xV2uPvbwL+pnZ3pTLRa6xCBYrbhDFRcWfZEa ZWZTnR5JHcVCN/bIvjR/OVVrMJJYvAx3iesnhUoCDZKjrvAlrkl5qNczxiLBa5cLVI7p 43TA== X-Gm-Message-State: AFuF++lZQe8HF4ImB0yzl8c2bxT1db7GBj8mkk9jzZW8wGsIH5yPh4T8 Mku7GRjlzD+0Oh4L9ezAJmLTdgjJ7VkruM/GQOtaM1kerKIbEtWYiLk0 X-Gm-Gg: AYBFou3WucBrl0VlvKXNWJBa0bfdKKTwagBNf+u8FPJkQVcV1kPBNXdTihkA7l6LSP+ XQm61img1jodNTxBJtpNkR4Yld4fbFkNaBsDZEmOrxOhpcY0SDS3vVEk7jgDWRSW8KcpFAPLbxy 1PyqrSSrvT9kkG12uLcHyEfTCbo5UvSC0QmqYKyLY/dKc/xeS5M/kIqTregKdeZAodlVFGmBFoS ecNaTe+wCq7DLypJFYhM/k4uRyR9W3Uvzh8qWQkW9wQ8kWY+V37KXjO+32jXmzyt5tIC7lkjRk9 P+7m78IqHfv5eUsVQy1MuiT0X+Q7p+mplA40XQy2l3HwGTIVS/nzcpUbZ1/R7cP/FnKzftjojdd igu2url1gKVnjJkpUUHdFqioQFuORw5ZnweLLTvmF2LwKrBVrY18hZnYM4k4zWXjfItbcb2UYqs gyoFR3e+h+8A8E3lUzfdSfpfkCtmvG4y8R+Ln1E0wWesI0YUS7c5RjwjRWePYn4cS3Pc836Ysa+ YGrYz13vRjNQlorKa7WqCF4U9lnNn0u/IGSWb9I+TFEOBakMWbQSCzZaBaYt8+v/c4U3zhSuL71 rXNnI71EdbLmsT8kvLrPkh7Q6g== X-Received: by 2002:a05:6214:5b02:b0:912:517b:856 with SMTP id 6a1803df08f44-91254d1628emr41305576d6.58.1789742466708; Fri, 18 Sep 2026 07:41:06 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-91258034fb4sm13891866d6.25.2026.09.18.07.41.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Sep 2026 07:41:06 -0700 (PDT) Date: Fri, 18 Sep 2026 09:41:04 -0500 From: Nathan Bossart To: CharSyam Cc: pgsql-hackers Subject: Re: [PATCH] Reject nonpositive Bloom filter element estimates Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Sep 18, 2026 at 07:31:04PM +0900, CharSyam wrote: > bloom_create() currently accepts a zero total_elems estimate. This > causes optimal_k() to divide by zero and then convert infinity to int, > which is undefined behavior. > > The attached patch rejects nonpositive estimates before the calculation. For backend functions like this, I don't see much value in checking the arguments like this. It seems highly unlikely that any caller will provide a total_elems setting of 0. Maybe an assertion would be more appropriate, but IMHO we can still do without it. > It also performs the bitset size multiplication as unsigned arithmetic > to avoid signed overflow for very large positive estimates, and adds a > regression test for the zero case. Again, it seems highly unlikely that any caller will provide a total_elems value even close to 4.6 quintillion. -- nathan