title: postgres autoincrement not updated on explicit id inserts
body: <p>I have the following table in postgres:</p>
  
  <pre><code>CREATE TABLE "test" (
      "id" serial NOT NULL PRIMARY KEY,
      "value" text
  )
  </code></pre>
  
  <p>I am doing following insertions:</p>
  
  <pre><code>insert into test (id, value) values (1, 'alpha')
  insert into test (id, value) values (2, 'beta')
  
  insert into test (value) values ('gamma')
  </code></pre>
  
  <p>In the first 2 inserts I am explicitly mentioning the id. However the table's auto increment pointer is not updated in this case. Hence in the 3rd insert I get the error:</p>
  
  <pre><code>ERROR:  duplicate key value violates unique constraint "test_pkey"
  DETAIL:  Key (id)=(1) already exists.
  </code></pre>
  
  <p>I never faced this problem in Mysql in both MyISAM and INNODB engines. Explicit or not, mysql always update autoincrement pointer based on the max row id.</p>
  
  <p>What is the workaround for this problem in postgres? I need it because I want a tighter control for some ids in my table.</p>
  
  <p><strong>UPDATE:</strong>
  I need it because for some values I need to have a fixed id. For other new entries I dont mind creating new ones.</p>
  
  <p>I think it may be possible by manually incrementing the <code>nextval</code> pointer to <code>max(id) + 1</code> whenever I am explicitly inserting the ids. But I am not sure how to do that.</p>