Thread

  1. Re: obtaining row locking information

    Tatsuo Ishii <t-ishii@sra.co.jp> — 2005-08-12T03:27:25Z

    > Hi,
    > 
    > With a help from Bruce, I wrote a small function which returns row
    > locking information(see attached file if you are interested). Here is
    > a sample result:
    > 
    > test=# select * from pgrowlocks('t1');
    >  locked_row | lock_type | locker | multi 
    > ------------+-----------+--------+-------
    >       (0,1) | Shared    |      1 | t
    >       (0,3) | Exclusive |    575 | f
    > (2 rows)
    > 
    > I think it will be more usefull if actual xids are shown in the case
    > "locker" is a multixid. It seems GetMultiXactIdMembers() does the
    > job. Unfortunately that is a static funtcion, however. Is there any
    > chance GetMultiXactIdMembers() becomes public funtion?
    
    I enhanced pgrowlocks() to use GetMultiXactIdMembers() so that it
    displays each xid belonging to particular multi xid (see attached
    source code).
    
    test=# select * from pgrowlocks('t1');
     locked_row | lock_type | locker | multi |   xids    
    ------------+-----------+--------+-------+-----------
          (0,1) | Shared    |      3 | t     | {646,647}
    (1 row)
    
    However even one of transactions, for example 647 commits, still it
    shows as if 647 is a member of muitixid 3.
    
    test=# select * from pgrowlocks('t1');
     locked_row | lock_type | locker | multi |   xids    
    ------------+-----------+--------+-------+-----------
          (0,1) | Shared    |      3 | t     | {646,647}
    (1 row)
    
    Am I missing something?
    --
    Tatsuo Ishii