Thread: /src/include/access/htup_details.h some comments kind of confusing....

Hi, there...

drop table infomask_test;
CREATE TABLE infomask_test(acc_no integer PRIMARY KEY,amount
numeric,misc      text);
INSERT INTO infomask_test VALUES (1, 100.00,default), (2,
200.00,repeat('abc',700));

BEGIN;
SELECT  acc_no,ctid,xmin,xmax FROM infomask_test WHERE acc_no = 1 FOR KEY SHARE;
SELECT  acc_no,ctid,xmin,xmax FROM infomask_test WHERE acc_no = 2 FOR SHARE;

select t_ctid, raw_flags, combined_flags,t_xmin,t_xmax
FROM    heap_page_items(get_raw_page('infomask_test', 0))
        ,LATERAL heap_tuple_infomask_flags(t_infomask, t_infomask2)
order by t_ctid;

 t_ctid |                                              raw_flags
                                        |    combined_flags    |
t_xmin | t_xmax

--------+------------------------------------------------------------------------------------------------------+----------------------+--------+--------
 (0,1)  | {HEAP_HASNULL,HEAP_HASVARWIDTH,HEAP_XMAX_KEYSHR_LOCK,HEAP_XMAX_LOCK_ONLY,HEAP_XMIN_COMMITTED}
       | {}        |  25655 |  25656
 (0,2)  | {HEAP_HASVARWIDTH,HEAP_XMAX_KEYSHR_LOCK,HEAP_XMAX_EXCL_LOCK,HEAP_XMAX_LOCK_ONLY,HEAP_XMIN_COMMITTED}
| {HEAP_XMAX_SHR_LOCK} |  25655 |  25656

select  acc_no,ctid,xmin,xmax from infomask_test;
 acc_no | ctid  | xmin  | xmax
--------+-------+-------+-------
      1 | (0,1) | 25655 | 25656
      2 | (0,2) | 25655 | 25656
(2 rows)
rollback;
----------------------------------------------------------------------------------------------------------
/main/postgres/src/include/access/htup_details.h:

#define HEAP_XMAX_EXCL_LOCK 0x0040 /* xmax is exclusive locker */

while manual:
FOR SHARE: Behaves similarly to FOR NO KEY UPDATE, except that it
acquires a shared lock rather than exclusive lock on each retrieved
row. A shared lock blocks other transactions from performing UPDATE,
DELETE, SELECT FOR UPDATE or SELECT FOR NO KEY UPDATE on these rows,
but it does not prevent them from performing SELECT FOR SHARE or
SELECT FOR KEY SHARE.

I failed to distinguish/reconcile between exclusive locker (in source
code comment) and shared lock (in manual).
-----------------------------------------------------------------------
aslo in /src/include/access/htup_details.h

#define HEAP_UPDATED 0x2000 /* this is UPDATEd version of row */

personally I found this comment kind of confusing. Trigger concept old
table, the new table is very intuitive.