Re: Fix an incorrect assertion condition in mdwritev(). - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Fix an incorrect assertion condition in mdwritev().
Date
Msg-id 1992.1716696526@sss.pgh.pa.us
Whole thread Raw
In response to Re: Fix an incorrect assertion condition in mdwritev().  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Fix an incorrect assertion condition in mdwritev().
Re: Fix an incorrect assertion condition in mdwritev().
List pgsql-hackers
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 <= (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



pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: AIX support
Next
From: Junwang Zhao
Date:
Subject: Improve conditional compilation for direct I/O alignment checks