title: Is each plgpsql stored procedure a transaction?
body: <p>I couldn't find anywhere where this was defined, so looking to you all for help.  I have a long-ish running stored procedure (5 seconds) in plgpsql, but needed to place a lock inside for a particular section, so was planning on using a pg_advisory_xact_lock.  But I obviously don't want to lock for the entire 5 seconds, so am wondering if I break up the stored procedure into 2 or more stored procedures - one main one that calls the others, how does that work with transaction locks?  Does each stored procedure count as a transaction, so the lock would end when that stored procedure is finished (committed)?  Or does the entire chain of stored procedure calls count as one transaction?</p>
  <p>i.e.  if I have</p>
  <pre><code>procedure A
     call procedure B
     call procedure C
  end
  </code></pre>
  <p>If I put a transaction lock inside procedure B will it unlock before procedure C starts?  Or will it lock until procedure A returns?</p>
  <p>Thank you for any help or pointers to where I can find this info.</p>