title: How to wait during SELECT that pending INSERT commit?
body: <p>I'm using PostgreSQL 9.2 in a Windows environment.
  I'm in a 2PC (<a href="http://en.wikipedia.org/wiki/Two-phase_commit_protocol" rel="nofollow">2 phase commit</a>) environment using MSDTC.</p>
  
  <p>I have a client application, that starts a transaction at the SERIALIZABLE isolation level, inserts a new row of data in a table for a specific foreign key value (there is an index on the column), and vote for completion of the transaction (The transaction is PREPARED). The transaction will be COMMITED by the Transaction Coordinator.</p>
  
  <p>Immediatly after that, outside of a transaction, the same client requests all the rows for this same specific foreign key value.</p>
  
  <p>Because there may be a delay before the previous transaction is really commited, the SELECT clause may return a previous snapshot of the data. In fact, it does happen sometimes, and this is problematic. Of course the application may be redesigned but until then, I'm looking for a lock solution. Advisory Lock ?</p>
  
  <p>I already solved the problem while performing UPDATE on specific rows, then using SELECT...FOR SHARE, and it works well. The SELECT waits until the transaction commits and return old and new rows.</p>
  
  <p>Now I'm trying to solve it for INSERT. 
  SELECT...FOR SHARE does not block and return immediatley.</p>
  
  <p>There is no concurrency issue here as only one client deals with a specific set of rows. I already know about MVCC.</p>
  
  <p>Any help appreciated.</p>