commit f8a872414d7644f84166ab0467e489e6dd558369
Author: Alexander Korotkov <akorotkov@postgresql.org>
Date:   Fri Nov 1 02:05:51 2019 +0300

    Improve check for pg_index.xmin
    
    Use more precise check according to transaction snapshot, not just xmin.

diff --git a/src/backend/access/heap/README.HOT b/src/backend/access/heap/README.HOT
index 68c6709aa88..02fd0ceb12b 100644
--- a/src/backend/access/heap/README.HOT
+++ b/src/backend/access/heap/README.HOT
@@ -319,8 +319,8 @@ too, but since the case is unexpected we prefer to throw an error.)
 
 Practically, we prevent certain transactions from using the new index by
 setting pg_index.indcheckxmin to TRUE.  Transactions are allowed to use
-such an index only after pg_index.xmin is below their TransactionXmin
-horizon, thereby ensuring that any incompatible rows in HOT chains are
+such an index only after pg_index.xmin is below their active snapshot,
+thereby ensuring that any incompatible rows in HOT chains are
 dead to them. (pg_index.xmin will be the XID of the CREATE INDEX
 transaction.  The reason for using xmin rather than a normal column is
 that the regular vacuum freezing mechanism will take care of converting
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index e5f9e04d659..ab207c4481d 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -228,8 +228,8 @@ get_relation_info(PlannerInfo *root, Oid relationObjectId, bool inhparent,
 			 * src/backend/access/heap/README.HOT for discussion.
 			 */
 			if (index->indcheckxmin &&
-				!TransactionIdPrecedes(HeapTupleHeaderGetXmin(indexRelation->rd_indextuple->t_data),
-									   TransactionXmin))
+				XidInMVCCSnapshot(HeapTupleHeaderGetXmin(indexRelation->rd_indextuple->t_data),
+								  GetActiveSnapshot()))
 			{
 				root->glob->transientPlan = true;
 				index_close(indexRelation, NoLock);
