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().