============================================================
*** src/backend/catalog/index.c	c360fcfd1002ffa557c1a376d3e74c9c2a0924db
--- src/backend/catalog/index.c	7201f06c5c1ad213a6acb6b694b666dd38358234
*************** BuildIndexInfo(Relation index)
*** 999,1004 ****
--- 999,1005 ----
  
  	/* other info */
  	ii->ii_Unique = indexStruct->indisunique;
+ 	ii->ii_Primary = indexStruct->indisprimary;
  	ii->ii_ReadyForInserts = indexStruct->indisready;
  
  	/* initialize index-build state to default */
============================================================
*** src/backend/executor/execUtils.c	54719433b61db70e6b433cd165c9c7a7b15e6531
--- src/backend/executor/execUtils.c	62756367e3fb34d96e0bb8c1bff4ee25f6402a4a
*************** ExecOpenIndices(ResultRelInfo *resultRel
*** 935,940 ****
--- 935,943 ----
  		/* extract index key information from the index's pg_index info */
  		ii = BuildIndexInfo(indexDesc);
  
+ 		if (ii->ii_Primary)
+ 			resultRelInfo->ri_PrimaryKey = i;
+ 
  		relationDescs[i] = indexDesc;
  		indexInfoArray[i] = ii;
  		i++;
============================================================
*** src/include/nodes/execnodes.h	9c75d10763d7bedc0a4db62a319d31e1549ad542
--- src/include/nodes/execnodes.h	3bc5ba3ad42bfdb298878f69ea3538fa96ba0815
*************** typedef struct IndexInfo
*** 59,64 ****
--- 59,65 ----
  	List	   *ii_Predicate;	/* list of Expr */
  	List	   *ii_PredicateState;		/* list of ExprState */
  	bool		ii_Unique;
+ 	bool		ii_Primary;
  	bool		ii_ReadyForInserts;
  	bool		ii_Concurrent;
  	bool		ii_BrokenHotChain;
*************** typedef struct ResultRelInfo
*** 289,294 ****
--- 290,296 ----
  	Index		ri_RangeTableIndex;
  	Relation	ri_RelationDesc;
  	int			ri_NumIndices;
+ 	int			ri_PrimaryKey;
  	RelationPtr ri_IndexRelationDescs;
  	IndexInfo **ri_IndexRelationInfo;
  	TriggerDesc *ri_TrigDesc;
