title: How to check for pending operations in a PostgreSQL transaction
body: <p>I have a session (SQLAlchemy) on PostgreSQL, with an active uncommitted transaction. I have just passed the session to some call tree that may or may not have issued SQL <code>INSERT</code>/<code>UPDATE</code>/<code>DELETE</code> statements, through <code>sqlalchemy.orm</code> or directly through the underlying connection.</p>
  
  <p>Is there a way to check whether there are any pending data-modifying statements in this transaction? I.e. whether commit would be a no-op or not, and whether rollback would discard something or not?</p>
  
  <p>I've seen people point out <code>v$transaction</code> in Oracle for the same thing (see <a href="https://stackoverflow.com/questions/1299694/oracle-how-to-find-out-if-there-is-a-transaction-pending">this SO question</a>). I'm looking for something similar to use on PostgreSQL.</p>