title: Sequences not affected by transactions?
body: <p>I have a table</p>
  
  <pre><code>create table testtable(
    testtable_rid serial not null,
    data integer not null,
    constraint pk_testtable primary key(testtable_rid)
  );
  </code></pre>
  
  <p>So lets say I do this code about 20 times:</p>
  
  <pre><code>begin;
  insert into testtable (data) values (0);
  rollback;
  </code></pre>
  
  <p>and then I do </p>
  
  <pre><code>begin;
  insert into testtable (data) values (0);
  commit;
  </code></pre>
  
  <p>And finally a </p>
  
  <pre><code>select * from testtable
  </code></pre>
  
  <pre>
  Result:
  row0: testtable_rid=21 | data=0
  Expected result:
  row0: testtable_rid=1 | data=0
  </pre>
  
  <p>As you can see, sequences do not appear to be affected by transaction rollbacks. They continue to increment as if the transaction was committed and then the row was deleted. Is there some way to prevent sequences from behaving in this way?</p>