diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c
index c7ad6f9..e5f0240 100644
*** a/src/backend/access/common/reloptions.c
--- b/src/backend/access/common/reloptions.c
*************** parseRelOptions(Datum options, bool vali
*** 912,925 ****
  	/* Done if no options */
  	if (PointerIsValid(DatumGetPointer(options)))
  	{
! 		ArrayType  *array;
  		Datum	   *optiondatums;
  		int			noptions;
  
- 		array = DatumGetArrayTypeP(options);
- 
- 		Assert(ARR_ELEMTYPE(array) == TEXTOID);
- 
  		deconstruct_array(array, TEXTOID, -1, false, 'i',
  						  &optiondatums, NULL, &noptions);
  
--- 912,921 ----
  	/* Done if no options */
  	if (PointerIsValid(DatumGetPointer(options)))
  	{
! 		ArrayType  *array = DatumGetArrayTypeP(options);
  		Datum	   *optiondatums;
  		int			noptions;
  
  		deconstruct_array(array, TEXTOID, -1, false, 'i',
  						  &optiondatums, NULL, &noptions);
  
*************** parseRelOptions(Datum options, bool vali
*** 959,964 ****
--- 955,965 ----
  						 errmsg("unrecognized parameter \"%s\"", s)));
  			}
  		}
+ 
+ 		/* It's worth avoiding memory leaks in this function */
+ 		pfree(optiondatums);
+ 		if (((void *) array) != DatumGetPointer(options))
+ 			pfree(array);
  	}
  
  	*numrelopts = numoptions;
diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c
index 10d300a..fd84853 100644
*** a/src/backend/utils/cache/relcache.c
--- b/src/backend/utils/cache/relcache.c
*************** RelationGetIndexList(Relation relation)
*** 3646,3651 ****
--- 3646,3652 ----
  	ScanKeyData skey;
  	HeapTuple	htup;
  	List	   *result;
+ 	List	   *oldlist;
  	char		replident = relation->rd_rel->relreplident;
  	Oid			oidIndex = InvalidOid;
  	Oid			pkeyIndex = InvalidOid;
*************** RelationGetIndexList(Relation relation)
*** 3737,3742 ****
--- 3738,3744 ----
  
  	/* Now save a copy of the completed list in the relcache entry. */
  	oldcxt = MemoryContextSwitchTo(CacheMemoryContext);
+ 	oldlist = relation->rd_indexlist;
  	relation->rd_indexlist = list_copy(result);
  	relation->rd_oidindex = oidIndex;
  	if (replident == REPLICA_IDENTITY_DEFAULT && OidIsValid(pkeyIndex))
*************** RelationGetIndexList(Relation relation)
*** 3748,3753 ****
--- 3750,3758 ----
  	relation->rd_indexvalid = 1;
  	MemoryContextSwitchTo(oldcxt);
  
+ 	/* Don't leak the old list, if there is one */
+ 	list_free(oldlist);
+ 
  	return result;
  }
  
*************** RelationGetIndexAttrBitmap(Relation rela
*** 4141,4146 ****
--- 4146,4159 ----
  
  	list_free(indexoidlist);
  
+ 	/* Don't leak any old values of these bitmaps */
+ 	bms_free(relation->rd_indexattr);
+ 	relation->rd_indexattr = NULL;
+ 	bms_free(relation->rd_keyattr);
+ 	relation->rd_keyattr = NULL;
+ 	bms_free(relation->rd_idattr);
+ 	relation->rd_idattr = NULL;
+ 
  	/*
  	 * Now save copies of the bitmaps in the relcache entry.  We intentionally
  	 * set rd_indexattr last, because that's the one that signals validity of
