summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund2014-06-24 09:31:47 +0000
committerAndres Freund2014-06-24 09:33:03 +0000
commitcb40383c3aafbc23d26beabe05ba168b05f31adc (patch)
tree9cf4b1bdbf87edb25252b83f21bf545b8cb78300
parentc7887adb61098faded4fe3b60c57d6e9a3f61d90 (diff)
bdr, deparse: Deparse nondefault seqams correctly when default_seqam is set.bdr-next
This could lead to sequences being created as bdr sequences on one node and local sequences on others.
-rw-r--r--src/backend/commands/sequence.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c
index dc7ea3d224..3cbd49e314 100644
--- a/src/backend/commands/sequence.c
+++ b/src/backend/commands/sequence.c
@@ -89,6 +89,7 @@ Oid
DefineSequence(CreateSeqStmt *seq)
{
FormData_pg_sequence new;
+ Form_pg_seqam seqamForm;
List *owned_by;
CreateStmt *stmt = makeNode(CreateStmt);
Oid seqoid;
@@ -112,8 +113,17 @@ DefineSequence(CreateSeqStmt *seq)
/* Check and set all param values */
init_params(seq->options, true, &new, &owned_by);
+
seqamid = init_options(InvalidOid, seq->accessMethod, seq->amoptions);
+ /* change statement to reflect the seqam for deparsing */
+ tuple = SearchSysCache1(SEQAMOID, ObjectIdGetDatum(seqamid));
+ if (!HeapTupleIsValid(tuple))
+ elog(ERROR, "cache lookup failed for relation %u", seqamid);
+ seqamForm = (Form_pg_seqam) GETSTRUCT(tuple);
+ seq->accessMethod = NameStr(seqamForm->seqamname);
+ ReleaseSysCache(tuple);
+
/*
* Create relation (and fill value[] and null[] for the tuple)
*/