I was testing postgresql sequences (using http://sqlfiddle.com with PostgreSQL 9.3 I dont have a PostgreSQL setup locally at the moment), but I was seeing strange behaviour.
Create a sequence
CREATE SEQUENCE counter_seq;
ALTER SEQUENCE counter_seq RESTART 9223372036854775805;
Then select the next value fromt the sequence:
SELECT nextval('counter_seq');
The result was 9223372036854776000 which is outside the range of BIGINT!?!?
The sequence itself seemed to update properly (it would fail after a couple of selects with ERROR: nextval: reached maximum value of sequence "counter_seq" (9223372036854775807)) but the result of nextval was incorrect when it did run.
I then tried setting the sequence to much lower:
ALTER SEQUENCE counter_seq RESTART 5223372036854775805;
SELECT nextval('counter_seq');
But the result was:
5223372036854776000
I couldn't get reliable behaviour until I dropped the sequence value to 5000000000000000.
Is this a postgresql bug or sqlfiddle?