diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c
index 11ee536..43ef4cd 100644
*** a/src/backend/catalog/catalog.c
--- b/src/backend/catalog/catalog.c
*************** GetNewRelFileNode(Oid reltablespace, Rel
*** 391,396 ****
--- 391,403 ----
  	bool		collides;
  	BackendId	backend;
  
+ 	/*
+ 	 * If we ever get here during pg_upgrade, there's something wrong; all
+ 	 * relfilenode assignments during a binary-upgrade run should be
+ 	 * determined by commands in the dump script.
+ 	 */
+ 	Assert(!IsBinaryUpgrade);
+ 
  	switch (relpersistence)
  	{
  		case RELPERSISTENCE_TEMP:
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 7e85b69..188429c 100644
*** a/src/backend/commands/sequence.c
--- b/src/backend/commands/sequence.c
*************** AlterSequence(ParseState *pstate, AlterS
*** 473,490 ****
  		GetTopTransactionId();
  
  	/*
! 	 * Create a new storage file for the sequence, making the state changes
! 	 * transactional.  We want to keep the sequence's relfrozenxid at 0, since
! 	 * it won't contain any unfrozen XIDs.  Same with relminmxid, since a
! 	 * sequence will never contain multixacts.
  	 */
! 	RelationSetNewRelfilenode(seqrel, seqrel->rd_rel->relpersistence,
! 							  InvalidTransactionId, InvalidMultiXactId);
  
! 	/*
! 	 * Insert the modified tuple into the new storage file.
! 	 */
! 	fill_seq_with_data(seqrel, newdatatuple);
  
  	/* process OWNED BY if given */
  	if (owned_by)
--- 473,499 ----
  		GetTopTransactionId();
  
  	/*
! 	 * If we are *only* doing OWNED BY, there is no need to rewrite the
! 	 * sequence file nor the pg_sequence tuple; and we mustn't do so because
! 	 * it breaks pg_upgrade by causing unwanted changes in the sequence's
! 	 * relfilenode.
  	 */
! 	if (!(owned_by && list_length(stmt->options) == 1))
! 	{
! 		/*
! 		 * Create a new storage file for the sequence, making the state
! 		 * changes transactional.  We want to keep the sequence's relfrozenxid
! 		 * at 0, since it won't contain any unfrozen XIDs.  Same with
! 		 * relminmxid, since a sequence will never contain multixacts.
! 		 */
! 		RelationSetNewRelfilenode(seqrel, seqrel->rd_rel->relpersistence,
! 								  InvalidTransactionId, InvalidMultiXactId);
  
! 		/*
! 		 * Insert the modified tuple into the new storage file.
! 		 */
! 		fill_seq_with_data(seqrel, newdatatuple);
! 	}
  
  	/* process OWNED BY if given */
  	if (owned_by)
