title: Does Postgres support nested or autonomous transactions?
body: <p>I have situation in which I have to commit a portion of code as transaction of its own.<br>
  I have created a table <code>subtransaction_tbl</code>:</p>
  
  <pre><code>CREATE TABLE subtransaction_tbl
  (
    entryval integer
  )
  </code></pre>
  
  <p>And a function in language plpython3u:</p>
  
  <pre><code>CREATE FUNCTION subtransaction_nested_test_t() RETURNS void
  AS $$
  plpy.execute("INSERT INTO subtransaction_tbl VALUES (1)")
  with plpy.subtransaction():
      plpy.execute("INSERT INTO subtransaction_tbl VALUES (2)")
  $$ LANGUAGE plpython3u;
  </code></pre>
  
  <p>First situation:</p>
  
  <pre><code>BEGIN TRANSACTION;
  INSERT INTO subtransaction_tbl VALUES (4);
  select  subtransaction_nested_test_t();
  COMMIT TRANSACTION;
  </code></pre>
  
  <p>Entries in table are correct: 1,2,4</p>
  
  <p>Second situation:</p>
  
  <pre><code>BEGIN TRANSACTION;
  INSERT INTO subtransaction_tbl VALUES (4);
  select  subtransaction_nested_test_t();
  ROLLBACK TRANSACTION;
  </code></pre>
  
  <p>Values in the table are not populated</p>
  
  <p>I expected <code>1</code> or <code>2</code> should be added to table <code>subtransaction_tbl</code> but to my surprise no value was inserted. I imagined a new subtransaction was opened by the function and it should not depend upon the parent transaction. Please let me know if I am right or not.</p>
  
  <p>Are there autonomous transactions in Postgres? Or do I have to modify my plpython3u function?</p>