brin-inclusion-v05-remove-assert-checking.patch
application/octet-stream
Filename: brin-inclusion-v05-remove-assert-checking.patch
Type: application/octet-stream
Part: 3
Message:
Re: BRIN range operator class
Patch
Format: format-patch
Series: patch v5-0003
Subject: remove assert checking
| File | + | − |
|---|---|---|
| src/backend/access/brin/brin.c | 0 | 58 |
From 2dd8cf82ad68c351193d0c76823ecd4ac8ecd9e8 Mon Sep 17 00:00:00 2001
From: Emre Hasegeli <emre@hasegeli.com>
Date: Sun, 22 Mar 2015 17:31:09 +0100
Subject: [PATCH 3/8] remove assert checking
---
src/backend/access/brin/brin.c | 58 ------------------------------------------
1 file changed, 58 deletions(-)
diff --git a/src/backend/access/brin/brin.c b/src/backend/access/brin/brin.c
index 2b5fb8d..a6dd4bf 100644
--- a/src/backend/access/brin/brin.c
+++ b/src/backend/access/brin/brin.c
@@ -98,25 +98,20 @@ brininsert(PG_FUNCTION_ARGS)
revmap = brinRevmapInitialize(idxRel, &pagesPerRange);
for (;;)
{
bool need_insert = false;
OffsetNumber off;
BrinTuple *brtup;
BrinMemTuple *dtup;
BlockNumber heapBlk;
int keyno;
-#ifdef USE_ASSERT_CHECKING
- BrinTuple *tmptup;
- BrinMemTuple *tmpdtup;
- Size tmpsiz;
-#endif
CHECK_FOR_INTERRUPTS();
heapBlk = ItemPointerGetBlockNumber(heaptid);
/* normalize the block number to be the first block in the range */
heapBlk = (heapBlk / pagesPerRange) * pagesPerRange;
brtup = brinGetTupleForHeapBlock(revmap, heapBlk, &buf, &off, NULL,
BUFFER_LOCK_SHARE);
/* if range is unsummarized, there's nothing to do */
@@ -130,59 +125,20 @@ brininsert(PG_FUNCTION_ARGS)
tupcxt = AllocSetContextCreate(CurrentMemoryContext,
"brininsert cxt",
ALLOCSET_DEFAULT_MINSIZE,
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
oldcxt = MemoryContextSwitchTo(tupcxt);
}
dtup = brin_deform_tuple(bdesc, brtup);
-#ifdef USE_ASSERT_CHECKING
- {
- /*
- * When assertions are enabled, we use this as an opportunity to
- * test the "union" method, which would otherwise be used very
- * rarely: first create a placeholder tuple, and addValue the
- * value we just got into it. Then union the existing index tuple
- * with the updated placeholder tuple. The tuple resulting from
- * that union should be identical to the one resulting from the
- * regular operation (straight addValue) below.
- *
- * Here we create the tuple to compare with; the actual comparison
- * is below.
- */
- tmptup = brin_form_placeholder_tuple(bdesc, heapBlk, &tmpsiz);
- tmpdtup = brin_deform_tuple(bdesc, tmptup);
- for (keyno = 0; keyno < bdesc->bd_tupdesc->natts; keyno++)
- {
- BrinValues *bval;
- FmgrInfo *addValue;
-
- bval = &tmpdtup->bt_columns[keyno];
- addValue = index_getprocinfo(idxRel, keyno + 1,
- BRIN_PROCNUM_ADDVALUE);
- FunctionCall4Coll(addValue,
- idxRel->rd_indcollation[keyno],
- PointerGetDatum(bdesc),
- PointerGetDatum(bval),
- values[keyno],
- nulls[keyno]);
- }
-
- union_tuples(bdesc, tmpdtup, brtup);
-
- tmpdtup->bt_placeholder = dtup->bt_placeholder;
- tmptup = brin_form_tuple(bdesc, heapBlk, tmpdtup, &tmpsiz);
- }
-#endif
-
/*
* Compare the key values of the new tuple to the stored index values;
* our deformed tuple will get updated if the new tuple doesn't fit
* the original range (note this means we can't break out of the loop
* early). Make a note of whether this happens, so that we know to
* insert the modified tuple later.
*/
for (keyno = 0; keyno < bdesc->bd_tupdesc->natts; keyno++)
{
Datum result;
@@ -195,34 +151,20 @@ brininsert(PG_FUNCTION_ARGS)
result = FunctionCall4Coll(addValue,
idxRel->rd_indcollation[keyno],
PointerGetDatum(bdesc),
PointerGetDatum(bval),
values[keyno],
nulls[keyno]);
/* if that returned true, we need to insert the updated tuple */
need_insert |= DatumGetBool(result);
}
-#ifdef USE_ASSERT_CHECKING
- {
- /*
- * Now we can compare the tuple produced by the union function
- * with the one from plain addValue.
- */
- BrinTuple *cmptup;
- Size cmpsz;
-
- cmptup = brin_form_tuple(bdesc, heapBlk, dtup, &cmpsz);
- Assert(brin_tuples_equal(tmptup, tmpsiz, cmptup, cmpsz));
- }
-#endif
-
if (!need_insert)
{
/*
* The tuple is consistent with the new values, so there's nothing
* to do.
*/
LockBuffer(buf, BUFFER_LOCK_UNLOCK);
}
else
{
--
2.2.1