From: Pavan Deolasee Date: Thu, 15 Jun 2017 05:26:40 +0000 (+0530) Subject: Fix couple of merge issues in sequence handling code X-Git-Tag: XL_10_R1BETA1~275 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=36ccc8d64e61fe9d77bb7ac62267945f7c146baa;p=postgres-xl.git Fix couple of merge issues in sequence handling code At one place we missed out an END_CRIT_SECTION(), so put that back. Also, GetGlobalSeqName() was using a wrong relation while generating the sequence name. This was caused as a result of the merge which introduced a new code block in between, thus setting the local variable referring the sequence relation to the pg_catalog.pg_sequence relation. --- diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index 0ccbe37a1b..ed50208d51 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -182,6 +182,7 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq) GTM_Sequence increment = 1; bool cycle = false; bool is_restart; + char *seqname; #endif /* Unlogged sequences are not implemented -- not clear if useful. */ @@ -279,6 +280,8 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq) if (owned_by) process_owned_by(rel, owned_by, seq->for_identity); + seqname = GetGlobalSeqName(rel, NULL, NULL); + heap_close(rel, NoLock); /* fill in pg_sequence */ @@ -309,8 +312,6 @@ DefineSequence(ParseState *pstate, CreateSeqStmt *seq) */ if (IS_PGXC_LOCAL_COORDINATOR) { - char *seqname = GetGlobalSeqName(rel, NULL, NULL); - /* We also need to create it on the GTM */ if (CreateSequenceGTM(seqname, increment, @@ -1212,6 +1213,7 @@ do_setval(Oid relid, int64 next, bool iscalled) { xl_seq_rec xlrec; XLogRecPtr recptr; + Page page = BufferGetPage(buf); XLogBeginInsert(); XLogRegisterBuffer(0, buf, REGBUF_WILL_INIT); @@ -1222,9 +1224,12 @@ do_setval(Oid relid, int64 next, bool iscalled) recptr = XLogInsert(RM_SEQ_ID, XLOG_SEQ_LOG); + PageSetLSN(page, recptr); elm->cached = elm->last; } + END_CRIT_SECTION(); + UnlockReleaseBuffer(buf); relation_close(seqrel, NoLock);