diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c
index 4cffd21..93fcd7b 100644
--- a/src/backend/access/heap/tuptoaster.c
+++ b/src/backend/access/heap/tuptoaster.c
@@ -70,6 +70,7 @@ static void toast_delete_datum(Relation rel, Datum value);
 static Datum toast_save_datum(Relation rel, Datum value,
 				 struct varlena * oldexternal, int options);
 static bool toastrel_valueid_exists(Relation toastrel, Oid valueid);
+static void toast_valueid_check_tuple(Relation toastrel, HeapTuple ttup, Oid valueid);
 static bool toastid_valueid_exists(Oid toastrelid, Oid valueid);
 static struct varlena *toast_fetch_datum(struct varlena * attr);
 static struct varlena *toast_fetch_datum_slice(struct varlena * attr,
@@ -1700,6 +1701,8 @@ toast_delete_datum(Relation rel, Datum value)
 										   SnapshotToast, 1, &toastkey);
 	while ((toasttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
 	{
+		toast_valueid_check_tuple(toastrel, toasttup, toast_pointer.va_valueid);
+
 		/*
 		 * Have a chunk, delete it
 		 */
@@ -1730,6 +1733,7 @@ toastrel_valueid_exists(Relation toastrel, Oid valueid)
 	int			num_indexes;
 	int			validIndex;
 	Relation   *toastidxs;
+	HeapTuple	ttup;
 
 	/* Fetch a valid index relation */
 	validIndex = toast_open_indexes(toastrel,
@@ -1752,8 +1756,12 @@ toastrel_valueid_exists(Relation toastrel, Oid valueid)
 								   RelationGetRelid(toastidxs[validIndex]),
 								   true, SnapshotToast, 1, &toastkey);
 
-	if (systable_getnext(toastscan) != NULL)
+	ttup = systable_getnext(toastscan);
+	if (ttup != NULL)
+	{
+		toast_valueid_check_tuple(toastrel, ttup, valueid);
 		result = true;
+	}
 
 	systable_endscan(toastscan);
 
@@ -1763,6 +1771,21 @@ toastrel_valueid_exists(Relation toastrel, Oid valueid)
 	return result;
 }
 
+static void
+toast_valueid_check_tuple(Relation toastrel, HeapTuple ttup, Oid valueid)
+{
+	Oid			checkOid;
+	bool		isnull;
+	TupleDesc   toasttupDesc = toastrel->rd_att;
+
+	checkOid = DatumGetObjectId(fastgetattr(ttup, 1, toasttupDesc, &isnull));
+	Assert(!isnull);
+
+	if (checkOid != valueid)
+		elog(ERROR, "toasted value has unexpected Oid (searched for %u, found %u)",
+						valueid, checkOid);
+}
+
 /* ----------
  * toastid_valueid_exists -
  *
@@ -1863,6 +1886,8 @@ toast_fetch_datum(struct varlena * attr)
 										   SnapshotToast, 1, &toastkey);
 	while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
 	{
+		toast_valueid_check_tuple(toastrel, ttup, toast_pointer.va_valueid);
+
 		/*
 		 * Have a chunk, extract the sequence number and the data
 		 */
@@ -2087,6 +2112,8 @@ toast_fetch_datum_slice(struct varlena * attr, int32 sliceoffset, int32 length)
 										 SnapshotToast, nscankeys, toastkey);
 	while ((ttup = systable_getnext_ordered(toastscan, ForwardScanDirection)) != NULL)
 	{
+		toast_valueid_check_tuple(toastrel, ttup, toast_pointer.va_valueid);
+
 		/*
 		 * Have a chunk, extract the sequence number and the data
 		 */
