Re: Assert in pageinspect with NULL pages

Julien Rouhaud <rjuju123@gmail.com>

From: Julien Rouhaud <rjuju123@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Daria Lepikhova <d.lepikhova@postgrespro.ru>, pgsql-hackers@postgresql.org
Date: 2022-02-17T09:40:41Z
Lists: pgsql-hackers
On Thu, Feb 17, 2022 at 05:57:49PM +0900, Michael Paquier wrote:
> On Thu, Feb 17, 2022 at 01:46:40PM +0500, Daria Lepikhova wrote:
> > INSERT INTO test1(y) SELECT 0 FROM generate_series(1,1E6) AS x;
> > SELECT page_checksum(repeat(E'\\000', 8192)::bytea, 1);
> 
> Indeed.  Good catch, and that seems pretty old at quick glance for the
> checksum part.  I'll try to look at all that tomorrow.

Indeed, the problem in page_checksum() has been there since the beginning as
far as I can see.

About the patch, it's incorrectly using a hardcoded 8192 block-size rather than
using the computed :block_size (or computing one when it's not already the
case).

I'm also wondering if it wouldn't be better to return NULL rather than throwing
an error for uninitialized pages.

While at it, it could also be worthwhile to add tests for invalid blkno and
block size in page_checksum().



Commits

  1. pageinspect: Fix handling of all-zero pages

  2. pageinspect: Add more sanity checks to prevent out-of-bound reads

  3. pageinspect: Fix handling of page sizes and AM types

  4. Teach pageinspect about nbtree deduplication.