diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index b3de79c..9353175 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -7831,7 +7831,7 @@ log_heap_update(Relation reln, Buffer oldbuf, bool need_tuple_data = RelationIsLogicallyLogged(reln); bool init; int bufflags; - bool warm_update; + bool warm_update = false; /* Caller should not call me on a non-WAL-logged relation */ Assert(RelationNeedsWAL(reln)); diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index e32deb1..39ee6ac 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -75,6 +75,9 @@ RelationPutHeapTuple(Relation relation, ItemId itemId = PageGetItemId(pageHeader, offnum); Item item = PageGetItem(pageHeader, itemId); + /* Copy t_ctid to set the correct block number */ + ((HeapTupleHeader) item)->t_ctid = tuple->t_self; + HeapTupleHeaderSetHeapLatest((HeapTupleHeader) item); if (OffsetNumberIsValid(root_offnum)) HeapTupleHeaderSetRootOffset((HeapTupleHeader) item, diff --git a/src/backend/executor/execIndexing.c b/src/backend/executor/execIndexing.c index 03c6b62..c24e486 100644 --- a/src/backend/executor/execIndexing.c +++ b/src/backend/executor/execIndexing.c @@ -801,7 +801,8 @@ retry: DirtySnapshot.speculativeToken && TransactionIdPrecedes(GetCurrentTransactionId(), xwait)))) { - ctid_wait = tup->t_data->t_ctid; + HeapTupleHeaderGetNextCtid(tup->t_data, &ctid_wait, + ItemPointerGetOffsetNumber(&tup->t_self)); reason_wait = indexInfo->ii_ExclusionOps ? XLTW_RecheckExclusionConstr : XLTW_InsertIndex; index_endscan(index_scan); diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 079a77f..466609c 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -2451,7 +2451,8 @@ EvalPlanQualFetch(EState *estate, Relation relation, int lockmode, } /* updated, so look at the updated row */ - tuple.t_self = tuple.t_data->t_ctid; + HeapTupleHeaderGetNextCtid(tuple.t_data, &tuple.t_self, + ItemPointerGetOffsetNumber(&tuple.t_self)); /* updated row should have xmin matching this xmax */ priorXmax = HeapTupleHeaderGetUpdateXid(tuple.t_data); ReleaseBuffer(buffer); diff --git a/src/backend/utils/adt/pgstatfuncs.c b/src/backend/utils/adt/pgstatfuncs.c index 25752b0..ef4f5b4 100644 --- a/src/backend/utils/adt/pgstatfuncs.c +++ b/src/backend/utils/adt/pgstatfuncs.c @@ -37,6 +37,7 @@ extern Datum pg_stat_get_tuples_inserted(PG_FUNCTION_ARGS); extern Datum pg_stat_get_tuples_updated(PG_FUNCTION_ARGS); extern Datum pg_stat_get_tuples_deleted(PG_FUNCTION_ARGS); extern Datum pg_stat_get_tuples_hot_updated(PG_FUNCTION_ARGS); +extern Datum pg_stat_get_tuples_warm_updated(PG_FUNCTION_ARGS); extern Datum pg_stat_get_live_tuples(PG_FUNCTION_ARGS); extern Datum pg_stat_get_dead_tuples(PG_FUNCTION_ARGS); extern Datum pg_stat_get_mod_since_analyze(PG_FUNCTION_ARGS); diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 37874ca..c6ef4e2 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -4487,6 +4487,12 @@ RelationGetIndexAttrBitmap(Relation relation, IndexAttrBitmapKind attrKind) pull_varattnos((Node *) indexInfo->ii_Predicate, 1, &exprindexattrs); /* + * indexattrs should include attributes referenced in index expressions + * and predicates too + */ + indexattrs = bms_add_members(indexattrs, exprindexattrs); + + /* * Check if the index has amrecheck method defined. If the method is * not defined, the index does not support WARM update. Completely * disable WARM updates on such tables