Tom Lane wrote:
>
> > I can imagine some cases where you would want to get a lock and keep it
> > until the end of the transaction, and other times when you would want to
> > release it before transaction end.
>
> I guess I'm not understanding something. How can it ever be correct
> practice to release a lock before transaction end? For example, if I
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Postgres does this for system tables only.
> write some changes in a table, and then release the lock, wouldn't that
> allow other backends to see the not-yet-committed changes? What if I
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
No. Backend uses xmin/xmax to know is tuple visible or not.
> then abort my transaction? Now the other backends have acted on
> information they should never have seen at all.
Backend will see that xmin(xmax) is not committed.
Vadim