diff options
Diffstat (limited to 'contrib/bloom')
-rw-r--r-- | contrib/bloom/blinsert.c | 29 | ||||
-rw-r--r-- | contrib/bloom/bloom.h | 2 | ||||
-rw-r--r-- | contrib/bloom/blutils.c | 8 |
3 files changed, 9 insertions, 30 deletions
diff --git a/contrib/bloom/blinsert.c b/contrib/bloom/blinsert.c index b42b9e6c41f..b90145148d4 100644 --- a/contrib/bloom/blinsert.c +++ b/contrib/bloom/blinsert.c @@ -129,7 +129,7 @@ blbuild(Relation heap, Relation index, IndexInfo *indexInfo) RelationGetRelationName(index)); /* Initialize the meta page */ - BloomInitMetapage(index); + BloomInitMetapage(index, MAIN_FORKNUM); /* Initialize the bloom build state */ memset(&buildstate, 0, sizeof(buildstate)); @@ -163,31 +163,8 @@ blbuild(Relation heap, Relation index, IndexInfo *indexInfo) void blbuildempty(Relation index) { - Page metapage; - - /* Construct metapage. */ - metapage = (Page) palloc_aligned(BLCKSZ, PG_IO_ALIGN_SIZE, 0); - BloomFillMetapage(index, metapage); - - /* - * Write the page and log it. It might seem that an immediate sync would - * be sufficient to guarantee that the file exists on disk, but recovery - * itself might remove it while replaying, for example, an - * XLOG_DBASE_CREATE* or XLOG_TBLSPC_CREATE record. Therefore, we need - * this even when wal_level=minimal. - */ - PageSetChecksumInplace(metapage, BLOOM_METAPAGE_BLKNO); - smgrwrite(RelationGetSmgr(index), INIT_FORKNUM, BLOOM_METAPAGE_BLKNO, - metapage, true); - log_newpage(&(RelationGetSmgr(index))->smgr_rlocator.locator, INIT_FORKNUM, - BLOOM_METAPAGE_BLKNO, metapage, true); - - /* - * An immediate sync is required even if we xlog'd the page, because the - * write did not go through shared_buffers and therefore a concurrent - * checkpoint may have moved the redo pointer past our xlog record. - */ - smgrimmedsync(RelationGetSmgr(index), INIT_FORKNUM); + /* Initialize the meta page */ + BloomInitMetapage(index, INIT_FORKNUM); } /* diff --git a/contrib/bloom/bloom.h b/contrib/bloom/bloom.h index efdf9415d15..330811ec608 100644 --- a/contrib/bloom/bloom.h +++ b/contrib/bloom/bloom.h @@ -177,7 +177,7 @@ typedef BloomScanOpaqueData *BloomScanOpaque; /* blutils.c */ extern void initBloomState(BloomState *state, Relation index); extern void BloomFillMetapage(Relation index, Page metaPage); -extern void BloomInitMetapage(Relation index); +extern void BloomInitMetapage(Relation index, ForkNumber forknum); extern void BloomInitPage(Page page, uint16 flags); extern Buffer BloomNewBuffer(Relation index); extern void signValue(BloomState *state, BloomSignatureWord *sign, Datum value, int attno); diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c index a017d58bbe4..f23fbb1d9e0 100644 --- a/contrib/bloom/blutils.c +++ b/contrib/bloom/blutils.c @@ -443,7 +443,7 @@ BloomFillMetapage(Relation index, Page metaPage) * Initialize metapage for bloom index. */ void -BloomInitMetapage(Relation index) +BloomInitMetapage(Relation index, ForkNumber forknum) { Buffer metaBuffer; Page metaPage; @@ -451,9 +451,11 @@ BloomInitMetapage(Relation index) /* * Make a new page; since it is first page it should be associated with - * block number 0 (BLOOM_METAPAGE_BLKNO). + * block number 0 (BLOOM_METAPAGE_BLKNO). No need to hold the extension + * lock because there cannot be concurrent inserters yet. */ - metaBuffer = BloomNewBuffer(index); + metaBuffer = ReadBufferExtended(index, forknum, P_NEW, RBM_NORMAL, NULL); + LockBuffer(metaBuffer, BUFFER_LOCK_EXCLUSIVE); Assert(BufferGetBlockNumber(metaBuffer) == BLOOM_METAPAGE_BLKNO); /* Initialize contents of meta page */ |