summaryrefslogtreecommitdiff
path: root/contrib/bloom
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bloom')
-rw-r--r--contrib/bloom/blcost.c6
-rw-r--r--contrib/bloom/blinsert.c27
-rw-r--r--contrib/bloom/bloom.h8
-rw-r--r--contrib/bloom/blscan.c2
-rw-r--r--contrib/bloom/blutils.c8
-rw-r--r--contrib/bloom/blvacuum.c4
-rw-r--r--contrib/bloom/blvalidate.c3
-rw-r--r--contrib/bloom/t/001_wal.pl2
8 files changed, 35 insertions, 25 deletions
diff --git a/contrib/bloom/blcost.c b/contrib/bloom/blcost.c
index 989789850e..ba39f627fd 100644
--- a/contrib/bloom/blcost.c
+++ b/contrib/bloom/blcost.c
@@ -3,7 +3,7 @@
* blcost.c
* Cost estimate function for bloom indexes.
*
- * Copyright (c) 2016, PostgreSQL Global Development Group
+ * Copyright (c) 2016-2017, PostgreSQL Global Development Group
*
* IDENTIFICATION
* contrib/bloom/blcost.c
@@ -24,7 +24,8 @@
void
blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
Cost *indexStartupCost, Cost *indexTotalCost,
- Selectivity *indexSelectivity, double *indexCorrelation)
+ Selectivity *indexSelectivity, double *indexCorrelation,
+ double *indexPages)
{
IndexOptInfo *index = path->indexinfo;
List *qinfos;
@@ -45,4 +46,5 @@ blcostestimate(PlannerInfo *root, IndexPath *path, double loop_count,
*indexTotalCost = costs.indexTotalCost;
*indexSelectivity = costs.indexSelectivity;
*indexCorrelation = costs.indexCorrelation;
+ *indexPages = costs.numIndexPages;
}
diff --git a/contrib/bloom/blinsert.c b/contrib/bloom/blinsert.c
index 78eec5c67e..0d506e3c1a 100644
--- a/contrib/bloom/blinsert.c
+++ b/contrib/bloom/blinsert.c
@@ -3,7 +3,7 @@
* blinsert.c
* Bloom index build and insert functions.
*
- * Copyright (c) 2016, PostgreSQL Global Development Group
+ * Copyright (c) 2016-2017, PostgreSQL Global Development Group
*
* IDENTIFICATION
* contrib/bloom/blinsert.c
@@ -130,9 +130,7 @@ blbuild(Relation heap, Relation index, IndexInfo *indexInfo)
initBloomState(&buildstate.blstate, index);
buildstate.tmpCtx = AllocSetContextCreate(CurrentMemoryContext,
"Bloom build temporary context",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ ALLOCSET_DEFAULT_SIZES);
initCachedPage(&buildstate);
/* Do the heap scan */
@@ -166,13 +164,18 @@ blbuildempty(Relation index)
metapage = (Page) palloc(BLCKSZ);
BloomFillMetapage(index, metapage);
- /* Write the page. If archiving/streaming, XLOG it. */
+ /*
+ * 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(index->rd_smgr, INIT_FORKNUM, BLOOM_METAPAGE_BLKNO,
(char *) metapage, true);
- if (XLogIsNeeded())
- log_newpage(&index->rd_smgr->smgr_rnode.node, INIT_FORKNUM,
- BLOOM_METAPAGE_BLKNO, metapage, false);
+ log_newpage(&index->rd_smgr->smgr_rnode.node, INIT_FORKNUM,
+ BLOOM_METAPAGE_BLKNO, metapage, false);
/*
* An immediate sync is required even if we xlog'd the page, because the
@@ -187,7 +190,9 @@ blbuildempty(Relation index)
*/
bool
blinsert(Relation index, Datum *values, bool *isnull,
- ItemPointer ht_ctid, Relation heapRel, IndexUniqueCheck checkUnique)
+ ItemPointer ht_ctid, Relation heapRel,
+ IndexUniqueCheck checkUnique,
+ IndexInfo *indexInfo)
{
BloomState blstate;
BloomTuple *itup;
@@ -204,9 +209,7 @@ blinsert(Relation index, Datum *values, bool *isnull,
insertCtx = AllocSetContextCreate(CurrentMemoryContext,
"Bloom insert temporary context",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
+ ALLOCSET_DEFAULT_SIZES);
oldCtx = MemoryContextSwitchTo(insertCtx);
diff --git a/contrib/bloom/bloom.h b/contrib/bloom/bloom.h
index bc451a00db..0cfe49aad8 100644
--- a/contrib/bloom/bloom.h
+++ b/contrib/bloom/bloom.h
@@ -3,7 +3,7 @@
* bloom.h
* Header for bloom index.
*
- * Copyright (c) 2016, PostgreSQL Global Development Group
+ * Copyright (c) 2016-2017, PostgreSQL Global Development Group
*
* IDENTIFICATION
* contrib/bloom/bloom.h
@@ -174,7 +174,6 @@ typedef BloomScanOpaqueData *BloomScanOpaque;
/* blutils.c */
extern void _PG_init(void);
-extern Datum blhandler(PG_FUNCTION_ARGS);
extern void initBloomState(BloomState *state, Relation index);
extern void BloomFillMetapage(Relation index, Page metaPage);
extern void BloomInitMetapage(Relation index);
@@ -190,7 +189,8 @@ extern bool blvalidate(Oid opclassoid);
/* index access method interface functions */
extern bool blinsert(Relation index, Datum *values, bool *isnull,
ItemPointer ht_ctid, Relation heapRel,
- IndexUniqueCheck checkUnique);
+ IndexUniqueCheck checkUnique,
+ struct IndexInfo *indexInfo);
extern IndexScanDesc blbeginscan(Relation r, int nkeys, int norderbys);
extern int64 blgetbitmap(IndexScanDesc scan, TIDBitmap *tbm);
extern void blrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
@@ -208,6 +208,6 @@ extern bytea *bloptions(Datum reloptions, bool validate);
extern void blcostestimate(PlannerInfo *root, IndexPath *path,
double loop_count, Cost *indexStartupCost,
Cost *indexTotalCost, Selectivity *indexSelectivity,
- double *indexCorrelation);
+ double *indexCorrelation, double *indexPages);
#endif
diff --git a/contrib/bloom/blscan.c b/contrib/bloom/blscan.c
index 316a906734..b8fa2d0a71 100644
--- a/contrib/bloom/blscan.c
+++ b/contrib/bloom/blscan.c
@@ -3,7 +3,7 @@
* blscan.c
* Bloom index scan functions.
*
- * Copyright (c) 2016, PostgreSQL Global Development Group
+ * Copyright (c) 2016-2017, PostgreSQL Global Development Group
*
* IDENTIFICATION
* contrib/bloom/blscan.c
diff --git a/contrib/bloom/blutils.c b/contrib/bloom/blutils.c
index debf4f46eb..00a65875b0 100644
--- a/contrib/bloom/blutils.c
+++ b/contrib/bloom/blutils.c
@@ -3,7 +3,7 @@
* blutils.c
* Bloom index utilities.
*
- * Portions Copyright (c) 2016, PostgreSQL Global Development Group
+ * Portions Copyright (c) 2016-2017, PostgreSQL Global Development Group
* Portions Copyright (c) 1990-1993, Regents of the University of California
*
* IDENTIFICATION
@@ -75,7 +75,7 @@ _PG_init(void)
bl_relopt_tab[i + 1].optname = MemoryContextStrdup(TopMemoryContext,
buf);
bl_relopt_tab[i + 1].opttype = RELOPT_TYPE_INT;
- bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[i]);
+ bl_relopt_tab[i + 1].offset = offsetof(BloomOptions, bitSize[0]) +sizeof(int) * i;
}
}
@@ -119,6 +119,7 @@ blhandler(PG_FUNCTION_ARGS)
amroutine->amstorage = false;
amroutine->amclusterable = false;
amroutine->ampredlocks = false;
+ amroutine->amcanparallel = false;
amroutine->amkeytype = InvalidOid;
amroutine->ambuild = blbuild;
@@ -138,6 +139,9 @@ blhandler(PG_FUNCTION_ARGS)
amroutine->amendscan = blendscan;
amroutine->ammarkpos = NULL;
amroutine->amrestrpos = NULL;
+ amroutine->amestimateparallelscan = NULL;
+ amroutine->aminitparallelscan = NULL;
+ amroutine->amparallelrescan = NULL;
PG_RETURN_POINTER(amroutine);
}
diff --git a/contrib/bloom/blvacuum.c b/contrib/bloom/blvacuum.c
index 482242f1c2..04abd0f6b6 100644
--- a/contrib/bloom/blvacuum.c
+++ b/contrib/bloom/blvacuum.c
@@ -3,7 +3,7 @@
* blvacuum.c
* Bloom VACUUM functions.
*
- * Copyright (c) 2016, PostgreSQL Global Development Group
+ * Copyright (c) 2016-2017, PostgreSQL Global Development Group
*
* IDENTIFICATION
* contrib/bloom/blvacuum.c
@@ -51,7 +51,7 @@ blbulkdelete(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
initBloomState(&state, index);
/*
- * Interate over the pages. We don't care about concurrently added pages,
+ * Iterate over the pages. We don't care about concurrently added pages,
* they can't contain tuples to delete.
*/
npages = RelationGetNumberOfBlocks(index);
diff --git a/contrib/bloom/blvalidate.c b/contrib/bloom/blvalidate.c
index 12e7c7dbda..cb75d23199 100644
--- a/contrib/bloom/blvalidate.c
+++ b/contrib/bloom/blvalidate.c
@@ -3,7 +3,7 @@
* blvalidate.c
* Opclass validator for bloom.
*
- * Copyright (c) 2016, PostgreSQL Global Development Group
+ * Copyright (c) 2016-2017, PostgreSQL Global Development Group
*
* IDENTIFICATION
* contrib/bloom/blvalidate.c
@@ -21,6 +21,7 @@
#include "catalog/pg_type.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
+#include "utils/regproc.h"
#include "utils/syscache.h"
#include "bloom.h"
diff --git a/contrib/bloom/t/001_wal.pl b/contrib/bloom/t/001_wal.pl
index 56c6618d3d..dbba198254 100644
--- a/contrib/bloom/t/001_wal.pl
+++ b/contrib/bloom/t/001_wal.pl
@@ -16,7 +16,7 @@ sub test_index_replay
# Wait for standby to catch up
my $applname = $node_standby->name;
my $caughtup_query =
-"SELECT pg_current_xlog_location() <= write_location FROM pg_stat_replication WHERE application_name = '$applname';";
+"SELECT pg_current_wal_lsn() <= write_lsn FROM pg_stat_replication WHERE application_name = '$applname';";
$node_master->poll_query_until('postgres', $caughtup_query)
or die "Timed out while waiting for standby 1 to catch up";