From a686a12c1870584e1de9f45b048cd00547db0b42 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Wed, 31 May 2017 17:03:10 -0700
Subject: [PATCH 2/2] Modify sequence catalog tuple before invoking post alter
 hook.

This seems to have been broken in the commit (1753b1b027035029) that
moved the sequence definition into pg_sequence.

Author: Andres Freund
Backpatch: Bug is in master/v10 only
---
 src/backend/commands/sequence.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index 4a56f03e8b..7e85b69ab8 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -490,12 +490,12 @@ AlterSequence(ParseState *pstate, AlterSeqStmt *stmt)
 	if (owned_by)
 		process_owned_by(seqrel, owned_by, stmt->for_identity);
 
+	CatalogTupleUpdate(rel, &seqtuple->t_self, seqtuple);
+
 	InvokeObjectPostAlterHook(RelationRelationId, relid, 0);
 
 	ObjectAddressSet(address, RelationRelationId, relid);
 
-	CatalogTupleUpdate(rel, &seqtuple->t_self, seqtuple);
-
 	heap_close(rel, RowExclusiveLock);
 	relation_close(seqrel, NoLock);
 
-- 
2.12.0.264.gd6db3f2165.dirty

