Here's an example of what I think the advantages might be:
The Scenario:
A user logs in and starts to edit a file. When he makes the request to edit, a check is performed and the file being available, the user starts to edit.
The user gets pulled away to something else, and ends up logging out before updating the changes made during the edit.
The Potential Solutions
I could set a session variable which would hold a value indicating if a user is editing a file, and when logging out I could perform a check to see if a file was being edited and stop the logout.
However, I think this would not stop the problem if the user were to simply close the browser window.
Even if I wrapped all necessary queries in a transaction, what would happen if the user were to log out or close the browser window?
However, with PL/PGSQL I could probably do the same purely on an SQL level, defining rollback points such that as soon as the connection was terminated if the transaction had not completed the data would be returned to its original state and the file released for others to edit.
Hope this is a good example of what I'm looking to do here.
P.