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 1sB5Bk-00EAkb-28 for pgsql-hackers@arkaria.postgresql.org; Sun, 26 May 2024 04:08:53 +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 1sB5Bj-003RG9-Qe for pgsql-hackers@arkaria.postgresql.org; Sun, 26 May 2024 04:08:51 +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 1sB5Bj-003RG1-H5 for pgsql-hackers@lists.postgresql.org; Sun, 26 May 2024 04:08:51 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sB5Bg-000nVa-Qn for pgsql-hackers@lists.postgresql.org; Sun, 26 May 2024 04:08:50 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 44Q48kwn944459; Sun, 26 May 2024 00:08:46 -0400 From: Tom Lane To: Michael Paquier cc: Xing Guo , pgsql-hackers@lists.postgresql.org Subject: Re: Fix an incorrect assertion condition in mdwritev(). In-reply-to: <1933.1716695945@sss.pgh.pa.us> References: <1933.1716695945@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Sat, 25 May 2024 23:59:05 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1991.1716696526.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sun, 26 May 2024 00:08:46 -0400 Message-ID: <1992.1716696526@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk I wrote: > Hmm ... I agree that this is better normally. But there's an > edge case where it would fail to notice a problem that the > existing code does notice: if blocknum is close to UINT32_MAX > and adding nblocks causes it to wrap around to a small value. > Is there an inexpensive way to catch that? After a few minutes' thought, how about: Assert((uint64) blocknum + (uint64) nblocks <=3D (uint64) mdnblocks(reln,= forknum)); This'd stop being helpful if we ever widen BlockNumber to 64 bits, but I think that's unlikely. (Partitioning seems like a better answer for giant tables.) regards, tom lane