bdr: Disallow calling setval() on distributed sequences.
authorAndres Freund <andres@anarazel.de>
Fri, 29 Aug 2014 15:16:42 +0000 (17:16 +0200)
committerAndres Freund <andres@anarazel.de>
Mon, 8 Sep 2014 15:49:59 +0000 (17:49 +0200)
We actually allow setval() to be called, as long as it's not changing
values. That's required because the relevant code is called from other
contexts as well.

bdr_seq.c

index 5fed563a904763f55c7041016a5c269806edd7cb..57c6bbb3f68091ece12561ea4ad6a8366730198d 100644 (file)
--- a/bdr_seq.c
+++ b/bdr_seq.c
@@ -1263,6 +1263,15 @@ bdr_sequence_setval(PG_FUNCTION_ARGS)
    Page        page = BufferGetPage(buf);
    Form_pg_sequence seq = (Form_pg_sequence) GETSTRUCT(seqtuple);
 
+   if (seq->last_value != next ||
+       seq->is_called != iscalled)
+       ereport(ERROR,
+               (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
+                errmsg("cannot call setval() on global sequence %s.%s ",
+                       get_namespace_name(RelationGetNamespace(seqrel)),
+                       RelationGetRelationName(seqrel))));
+
+
    /* ready to change the on-disk (or really, in-buffer) tuple */
    START_CRIT_SECTION();