title: How to not execute INSERT in read-only transaction
body: <p>Postgres server is in hot standbuy mode.
  Asynchronou streaming binary replication is used.</p>
  
  <p>Command like </p>
  
  <pre><code>INSERT INTO logfile (logdate) values (current_date)
  </code></pre>
  
  <p>Causes error</p>
  
  <blockquote>
    <p>cannot execute INSERT in a read-only transaction.</p>
  </blockquote>
  
  <p>Maybe it should be changed to </p>
  
  <pre><code>INSERT INTO logfile (logdate) 
  SELECT current_date
  WHERE   ???
  </code></pre>
  
  <p>What where condition should used ? 
  It should work starting at Postgres 9.0
  If direct where clause is not possible, maybe some plpgsql function can used in where.</p>
  
  <p>Maybe </p>
  
  <pre><code>show transaction_read_only
  </code></pre>
  
  <p>result should captured or some function can used.</p>
  
  <p>Alternately application can determine if database is read-only in startup. Should show transaction_read_only   result used for this.</p>