• Tom Lane's avatar
    Overdue code review for transaction-level advisory locks patch. · 71b9549d
    Tom Lane authored
    Commit 62c7bd31 had assorted problems, most
    visibly that it broke PREPARE TRANSACTION in the presence of session-level
    advisory locks (which should be ignored by PREPARE), as per a recent
    complaint from Stephen Rees.  More abstractly, the patch made the
    LockMethodData.transactional flag not merely useless but outright
    dangerous, because in point of fact that flag no longer tells you anything
    at all about whether a lock is held transactionally.  This fix therefore
    removes that flag altogether.  We now rely entirely on the convention
    already in use in lock.c that transactional lock holds must be owned by
    some ResourceOwner, while session holds are never so owned.  Setting the
    locallock struct's owner link to NULL thus denotes a session hold, and
    there is no redundant marker for that.
    
    PREPARE TRANSACTION now works again when there are session-level advisory
    locks, and it is also able to transfer transactional advisory locks to the
    prepared transaction, but for implementation reasons it throws an error if
    we hold both types of lock on a single lockable object.  Perhaps it will be
    worth improving that someday.
    
    Assorted other minor cleanup and documentation editing, as well.
    
    Back-patch to 9.1, except that in the 9.1 branch I did not remove the
    LockMethodData.transactional flag for fear of causing an ABI break for
    any external code that might be examining those structs.
    71b9549d
lock.h 20.1 KB