On Wed, Sep 29, 2021 at 2:36 PM Melanie Plageman <melanieplage...@gmail.com> wrote: > unbuffered_write() and unbuffered_extend() might be able to be used even > if unbuffered_prep() and unbuffered_finish() are not used -- for example > hash indexes do something I don't entirely understand in which they call > smgrextend() directly when allocating buckets but then initialize the > new bucket pages using the bufmgr machinery.
My first thought was that someone might do this to make sure that we don't run out of disk space after initializing some but not all of the buckets. Someone might have some reason for wanting to avoid that corner case. However, in _hash_init() that explanation doesn't make any sense, because an abort would destroy the entire relation. And in _hash_alloc_buckets() the variable "zerobuf" points to a buffer that is not, in fact, all zeroes. So my guess is this is just old, crufty code - either whatever reasons somebody had for doing it that way are no longer valid, or there wasn't any good reason even at the time. -- Robert Haas EDB: http://www.enterprisedb.com