diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
new file mode 100644
index d525ca4..261473d
*** a/src/backend/utils/adt/selfuncs.c
--- b/src/backend/utils/adt/selfuncs.c
*************** get_actual_variable_range(PlannerInfo *r
*** 4958,4963 ****
--- 4958,4964 ----
  			HeapTuple	tup;
  			Datum		values[INDEX_MAX_KEYS];
  			bool		isnull[INDEX_MAX_KEYS];
+ 			SnapshotData	SnapshotDirty;
  
  			estate = CreateExecutorState();
  			econtext = GetPerTupleExprContext(estate);
*************** get_actual_variable_range(PlannerInfo *r
*** 4980,4985 ****
--- 4981,4987 ----
  			slot = MakeSingleTupleTableSlot(RelationGetDescr(heapRel));
  			econtext->ecxt_scantuple = slot;
  			get_typlenbyval(vardata->atttype, &typLen, &typByVal);
+ 			InitDirtySnapshot(SnapshotDirty);
  
  			/* set up an IS NOT NULL scan key so that we ignore nulls */
  			ScanKeyEntryInitialize(&scankeys[0],
*************** get_actual_variable_range(PlannerInfo *r
*** 4997,5003 ****
  			if (min)
  			{
  				index_scan = index_beginscan(heapRel, indexRel,
! 											 GetActiveSnapshot(), 1, 0);
  				index_rescan(index_scan, scankeys, 1, NULL, 0);
  
  				/* Fetch first tuple in sortop's direction */
--- 4999,5005 ----
  			if (min)
  			{
  				index_scan = index_beginscan(heapRel, indexRel,
! 											 &SnapshotDirty, 1, 0);
  				index_rescan(index_scan, scankeys, 1, NULL, 0);
  
  				/* Fetch first tuple in sortop's direction */
*************** get_actual_variable_range(PlannerInfo *r
*** 5029,5035 ****
  			if (max && have_data)
  			{
  				index_scan = index_beginscan(heapRel, indexRel,
! 											 GetActiveSnapshot(), 1, 0);
  				index_rescan(index_scan, scankeys, 1, NULL, 0);
  
  				/* Fetch first tuple in reverse direction */
--- 5031,5037 ----
  			if (max && have_data)
  			{
  				index_scan = index_beginscan(heapRel, indexRel,
! 											 &SnapshotDirty, 1, 0);
  				index_rescan(index_scan, scankeys, 1, NULL, 0);
  
  				/* Fetch first tuple in reverse direction */
