mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-19 20:00:51 +08:00
Remove redundant memset(0) calls for page init of some index AMs
Bloom, GIN, GiST and SP-GiST rely on PageInit() to initialize the contents of a page, and this routine fills entirely a page with zeros for a size of BLCKSZ, including the special space. Those index AMs have been using an extra memset() call to fill with zeros the special page space, or even the whole page, which is not necessary as PageInit() already does this work, so let's remove them. GiST was not doing this extra call, but has commented out a system call that did so since 6236991. While on it, remove one MAXALIGN() for SP-GiST as PageInit() takes care of that. This makes the whole page initialization logic more consistent across all index AMs. Author: Bharath Rupireddy Reviewed-by: Vignesh C, Mahendra Singh Thalor Discussion: https://postgr.es/m/CALj2ACViOo2qyaPT7krWm4LRyRTw9kOXt+g6PfNmYuGA=YHj9A@mail.gmail.com
This commit is contained in:
parent
9afffcb833
commit
4c0239cb7a
@ -63,7 +63,6 @@ flushCachedPage(Relation index, BloomBuildState *buildstate)
|
||||
static void
|
||||
initCachedPage(BloomBuildState *buildstate)
|
||||
{
|
||||
memset(buildstate->data.data, 0, BLCKSZ);
|
||||
BloomInitPage(buildstate->data.data, 0);
|
||||
buildstate->count = 0;
|
||||
}
|
||||
|
@ -411,7 +411,6 @@ BloomInitPage(Page page, uint16 flags)
|
||||
PageInit(page, BLCKSZ, sizeof(BloomPageOpaqueData));
|
||||
|
||||
opaque = BloomPageGetOpaque(page);
|
||||
memset(opaque, 0, sizeof(BloomPageOpaqueData));
|
||||
opaque->flags = flags;
|
||||
opaque->bloom_page_id = BLOOM_PAGE_ID;
|
||||
}
|
||||
|
@ -348,7 +348,6 @@ GinInitPage(Page page, uint32 f, Size pageSize)
|
||||
PageInit(page, pageSize, sizeof(GinPageOpaqueData));
|
||||
|
||||
opaque = GinPageGetOpaque(page);
|
||||
memset(opaque, 0, sizeof(GinPageOpaqueData));
|
||||
opaque->flags = f;
|
||||
opaque->rightlink = InvalidBlockNumber;
|
||||
}
|
||||
|
@ -761,8 +761,6 @@ gistinitpage(Page page, uint32 f)
|
||||
PageInit(page, pageSize, sizeof(GISTPageOpaqueData));
|
||||
|
||||
opaque = GistPageGetOpaque(page);
|
||||
/* page was already zeroed by PageInit, so this is not needed: */
|
||||
/* memset(&(opaque->nsn), 0, sizeof(GistNSN)); */
|
||||
opaque->rightlink = InvalidBlockNumber;
|
||||
opaque->flags = f;
|
||||
opaque->gist_page_id = GIST_PAGE_ID;
|
||||
|
@ -677,9 +677,8 @@ SpGistInitPage(Page page, uint16 f)
|
||||
{
|
||||
SpGistPageOpaque opaque;
|
||||
|
||||
PageInit(page, BLCKSZ, MAXALIGN(sizeof(SpGistPageOpaqueData)));
|
||||
PageInit(page, BLCKSZ, sizeof(SpGistPageOpaqueData));
|
||||
opaque = SpGistPageGetOpaque(page);
|
||||
memset(opaque, 0, sizeof(SpGistPageOpaqueData));
|
||||
opaque->flags = f;
|
||||
opaque->spgist_page_id = SPGIST_PAGE_ID;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user