title: Check if a statement will update records before executing it
body: <p>I have a system that takes a random SQL statement and returns the result of the execution. I would like to limit the system to execute read-only statements and reject any statements that would update/insert/delete etc. any records.</p>
  
  <p><strong>Is there a way to ask the database if a statement is a read-only statement without actually executing it?</strong></p>
  
  <p>Notes:</p>
  
  <ul>
  <li>The system is only accessible to a few "trusted" users who have full access to the database anyway - so what I want is an "oops" safeguard - I understand that this is not the way to handle SQL injection attacks etc.</li>
  <li><p>Regex validation is probably too complicated, because "forbidden words" are ok if they are in comments or column names for example.<br>
  This should be a valid input:</p>
  
  <pre><code>SELECT
    a AS update_value,
    'INSERT FOR FUN' AS q
  FROM t --comment: should we delete stuff?
  /*why not as long as you don't drop database*/
  </code></pre>
  
  <p>But this should be rejected:</p>
  
  <pre><code>UPDATE t SET a = 1
  </code></pre></li>
  <li>I'd rather not create a separate read-only user</li>
  </ul>