diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2019-01-15 12:07:10 -0500 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2019-01-15 12:07:10 -0500 |
commit | 1c53c4dec3985512f7f2f53c9d76a5295cd0a2dd (patch) | |
tree | d73a6f1954718d48d622162c98bfa6ca5ddc2422 /src/backend/access | |
parent | 0944ec54de389b4b8a471ca1f40f1b9d81de1f30 (diff) | |
download | postgresql-1c53c4dec3985512f7f2f53c9d76a5295cd0a2dd.tar.gz postgresql-1c53c4dec3985512f7f2f53c9d76a5295cd0a2dd.zip |
Finish reverting "recheck_on_update" patch.
This reverts commit c203d6cf8 and some follow-on fixes, completing the
task begun in commit 5d28c9bd7. If that feature is ever resurrected,
the code will look quite a bit different from this, so it seems best
to start from a clean slate.
The v11 branch is not touched; in that branch, the recheck_on_update
storage option remains present, but nonfunctional and undocumented.
Discussion: https://postgr.es/m/20190114223409.3tcvejfhlvbucrv5@alap3.anarazel.de
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/common/reloptions.c | 45 | ||||
-rw-r--r-- | src/backend/access/heap/heapam.c | 109 |
2 files changed, 8 insertions, 146 deletions
diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index f5efe94b7b9..cdf1f4af62d 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -131,15 +131,6 @@ static relopt_bool boolRelOpts[] = }, { { - "recheck_on_update", - "Recheck functional index expression for changed value after update", - RELOPT_KIND_INDEX, - ShareUpdateExclusiveLock /* since only applies to later UPDATEs */ - }, - true - }, - { - { "security_barrier", "View acts as a row security barrier", RELOPT_KIND_VIEW, @@ -1343,7 +1334,7 @@ fillRelOptions(void *rdopts, Size basesize, break; } } - if (validate && !found && options[i].gen->kinds != RELOPT_KIND_INDEX) + if (validate && !found) elog(ERROR, "reloption \"%s\" not found in parse table", options[i].gen->name); } @@ -1502,40 +1493,6 @@ index_reloptions(amoptions_function amoptions, Datum reloptions, bool validate) } /* - * Parse generic options for all indexes. - * - * reloptions options as text[] datum - * validate error flag - */ -bytea * -index_generic_reloptions(Datum reloptions, bool validate) -{ - int numoptions; - GenericIndexOpts *idxopts; - relopt_value *options; - static const relopt_parse_elt tab[] = { - {"recheck_on_update", RELOPT_TYPE_BOOL, offsetof(GenericIndexOpts, recheck_on_update)} - }; - - options = parseRelOptions(reloptions, validate, - RELOPT_KIND_INDEX, - &numoptions); - - /* if none set, we're done */ - if (numoptions == 0) - return NULL; - - idxopts = allocateReloptStruct(sizeof(GenericIndexOpts), options, numoptions); - - fillRelOptions((void *) idxopts, sizeof(GenericIndexOpts), options, numoptions, - validate, tab, lengthof(tab)); - - pfree(options); - - return (bytea *) idxopts; -} - -/* * Option parser for attribute reloptions */ bytea * diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 3a184f2eccb..f7b08ffdd13 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -57,7 +57,6 @@ #include "access/xlogutils.h" #include "catalog/catalog.h" #include "catalog/namespace.h" -#include "catalog/index.h" #include "miscadmin.h" #include "pgstat.h" #include "port/atomics.h" @@ -76,9 +75,7 @@ #include "utils/snapmgr.h" #include "utils/syscache.h" #include "utils/tqual.h" -#include "utils/memutils.h" -#include "nodes/execnodes.h" -#include "executor/executor.h" + /* GUC variable */ bool synchronize_seqscans = true; @@ -130,7 +127,6 @@ static bool ConditionalMultiXactIdWait(MultiXactId multi, MultiXactStatus status static XLogRecPtr log_heap_new_cid(Relation relation, HeapTuple tup); static HeapTuple ExtractReplicaIdentity(Relation rel, HeapTuple tup, bool key_modified, bool *copy); -static bool ProjIndexIsUnchanged(Relation relation, HeapTuple oldtup, HeapTuple newtup); /* @@ -3511,7 +3507,6 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, HTSU_Result result; TransactionId xid = GetCurrentTransactionId(); Bitmapset *hot_attrs; - Bitmapset *proj_idx_attrs; Bitmapset *key_attrs; Bitmapset *id_attrs; Bitmapset *interesting_attrs; @@ -3575,11 +3570,12 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, * Note that we get copies of each bitmap, so we need not worry about * relcache flush happening midway through. */ - hot_attrs = RelationGetIndexAttrBitmap(relation, INDEX_ATTR_BITMAP_HOT); - proj_idx_attrs = RelationGetIndexAttrBitmap(relation, INDEX_ATTR_BITMAP_PROJ); + hot_attrs = RelationGetIndexAttrBitmap(relation, INDEX_ATTR_BITMAP_ALL); key_attrs = RelationGetIndexAttrBitmap(relation, INDEX_ATTR_BITMAP_KEY); id_attrs = RelationGetIndexAttrBitmap(relation, INDEX_ATTR_BITMAP_IDENTITY_KEY); + + block = ItemPointerGetBlockNumber(otid); buffer = ReadBuffer(relation, block); page = BufferGetPage(buffer); @@ -3599,7 +3595,6 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup, if (!PageIsFull(page)) { interesting_attrs = bms_add_members(interesting_attrs, hot_attrs); - interesting_attrs = bms_add_members(interesting_attrs, proj_idx_attrs); hot_attrs_checked = true; } interesting_attrs = bms_add_members(interesting_attrs, key_attrs); @@ -3883,7 +3878,6 @@ l2: if (vmbuffer != InvalidBuffer) ReleaseBuffer(vmbuffer); bms_free(hot_attrs); - bms_free(proj_idx_attrs); bms_free(key_attrs); bms_free(id_attrs); bms_free(modified_attrs); @@ -4191,18 +4185,11 @@ l2: /* * Since the new tuple is going into the same page, we might be able * to do a HOT update. Check if any of the index columns have been - * changed, or if we have projection functional indexes, check whether - * the old and the new values are the same. If the page was already - * full, we may have skipped checking for index columns. If so, HOT - * update is possible. + * changed. If the page was already full, we may have skipped checking + * for index columns. If so, HOT update is possible. */ - if (hot_attrs_checked - && !bms_overlap(modified_attrs, hot_attrs) - && (!bms_overlap(modified_attrs, proj_idx_attrs) - || ProjIndexIsUnchanged(relation, &oldtup, newtup))) - { + if (hot_attrs_checked && !bms_overlap(modified_attrs, hot_attrs)) use_hot_update = true; - } } else { @@ -4364,7 +4351,6 @@ l2: heap_freetuple(old_key_tuple); bms_free(hot_attrs); - bms_free(proj_idx_attrs); bms_free(key_attrs); bms_free(id_attrs); bms_free(modified_attrs); @@ -4451,87 +4437,6 @@ heap_tuple_attr_equals(TupleDesc tupdesc, int attrnum, } /* - * Check whether the value is unchanged after update of a projection - * functional index. Compare the new and old values of the indexed - * expression to see if we are able to use a HOT update or not. - */ -static bool -ProjIndexIsUnchanged(Relation relation, HeapTuple oldtup, HeapTuple newtup) -{ - ListCell *l; - List *indexoidlist = RelationGetIndexList(relation); - EState *estate = CreateExecutorState(); - ExprContext *econtext = GetPerTupleExprContext(estate); - TupleTableSlot *slot = MakeSingleTupleTableSlot(RelationGetDescr(relation), - &TTSOpsHeapTuple); - bool equals = true; - Datum old_values[INDEX_MAX_KEYS]; - bool old_isnull[INDEX_MAX_KEYS]; - Datum new_values[INDEX_MAX_KEYS]; - bool new_isnull[INDEX_MAX_KEYS]; - int indexno = 0; - - econtext->ecxt_scantuple = slot; - - foreach(l, indexoidlist) - { - if (bms_is_member(indexno, relation->rd_projidx)) - { - Oid indexOid = lfirst_oid(l); - Relation indexDesc = index_open(indexOid, AccessShareLock); - IndexInfo *indexInfo = BuildIndexInfo(indexDesc); - int i; - - ResetExprContext(econtext); - ExecStoreHeapTuple(oldtup, slot, false); - FormIndexDatum(indexInfo, - slot, - estate, - old_values, - old_isnull); - - ExecStoreHeapTuple(newtup, slot, false); - FormIndexDatum(indexInfo, - slot, - estate, - new_values, - new_isnull); - - for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++) - { - if (old_isnull[i] != new_isnull[i]) - { - equals = false; - break; - } - else if (!old_isnull[i]) - { - Form_pg_attribute att = TupleDescAttr(RelationGetDescr(indexDesc), i); - - if (!datumIsEqual(old_values[i], new_values[i], att->attbyval, att->attlen)) - { - equals = false; - break; - } - } - } - index_close(indexDesc, AccessShareLock); - - if (!equals) - { - break; - } - } - indexno += 1; - } - ExecDropSingleTupleTableSlot(slot); - FreeExecutorState(estate); - - return equals; -} - - -/* * Check which columns are being updated. * * Given an updated tuple, determine (and return into the output bitmapset), |