Обсуждение: Give me more details of some bits in infomask!!
here are the source codes from src/include/access/htup_details.h.
/*
* information stored in t_infomask:
*/
#define HEAP_HASNULL 0x0001 /* has null attribute(s) */
#define HEAP_HASVARWIDTH 0x0002 /* has variable-width attribute(s) */
#define HEAP_HASEXTERNAL 0x0004 /* has external stored attribute(s) */
#define HEAP_HASOID_OLD 0x0008 /* has an object-id field */
#define HEAP_XMAX_KEYSHR_LOCK 0x0010 /* xmax is a key-shared locker */
#define HEAP_COMBOCID 0x0020 /* t_cid is a combo CID */
#define HEAP_XMAX_EXCL_LOCK 0x0040 /* xmax is exclusive locker */
#define HEAP_XMAX_LOCK_ONLY 0x0080 /* xmax, if valid, is only a locker */
And I can't understand these attrs:
1. external stored attribute(s), what is this? can you give a create statement to show me?
2. xmax is a key-shared locker/exclusive locker/only a locker, so how you use this? can you give me a scenario?
let me try to explain it:
if there is a txn is trying to read this heaptuple, the HEAP_XMAX_KEYSHR_LOCK bit will be set to 1.
if there is a txn is trying to delete/update this heaptuple, the HEAP_XMAX_EXCL_LOCK bit will be set to 1.
but for HEAP_XMAX_LOCK_ONLY, I can't understand.
And another thought is that these three bit can have only one to be set 1 at most.
3. t_cid is a combo CID? what's a CID? give me an example please.
--------------------------------------
jacktby@gmail.com
On 2/26/23 15:30, jacktby@gmail.com wrote: > here are the source codes from src/include/access/htup_details.h. > /* > * information stored in t_infomask: > */ > #define HEAP_HASNULL0x0001/* has null attribute(s) */ > #define HEAP_HASVARWIDTH0x0002/* has variable-width attribute(s) */ > #define HEAP_HASEXTERNAL0x0004/* has external stored attribute(s) */ > #define HEAP_HASOID_OLD0x0008/* has an object-id field */ > #define HEAP_XMAX_KEYSHR_LOCK0x0010/* xmax is a key-shared locker */ > #define HEAP_COMBOCID0x0020/* t_cid is a combo CID */ > #define HEAP_XMAX_EXCL_LOCK0x0040/* xmax is exclusive locker */ > #define HEAP_XMAX_LOCK_ONLY0x0080/* xmax, if valid, is only a locker */ > > And I can't understand these attrs: I suggest you try something like 'git grep HEAP_HASEXTERNAL' which shows you where the flag is used, which should tell you what it means. These short descriptions generally assume you know enough about the internals. > 1. external stored attribute(s), what is this? can you give a create > statement to show me? external = value stored in a TOAST table > 2. xmax is a key-shared locker/exclusive locker/only a locker, so how > you use this? can you give me a scenario? > let me try to explain it: > if there is a txn is trying to read this heaptuple, > the HEAP_XMAX_KEYSHR_LOCK bit will be set to 1. > if there is a txn is trying to delete/update this heaptuple, > the HEAP_XMAX_EXCL_LOCK bit will be set to 1. > but for HEAP_XMAX_LOCK_ONLY, I can't understand. > And another thought is that these three bit can have only one to be set > 1 at most. I believe HEAP_XMAX_LOCK_ONLY means the xmax transaction only locked the tuple, without deleting/updating it. > 3. t_cid is a combo CID? what's a CID? give me an example please. CID means "command ID" i.e. sequential ID assigned to commands in a single session (for visibility checks, so that a query doesn't see data deleted by earlier commands in the same session). See src/backend/utils/time/combocid.c for basic explanation of what "combo CID" is. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
From: Tomas VondraDate: 2023-02-26 23:23Subject: Re: Give me more details of some bits in infomask!!On 2/26/23 15:30, jacktby@gmail.com wrote:> here are the source codes from src/include/access/htup_details.h.> /*> * information stored in t_infomask:> */> #define HEAP_HASNULL0x0001/* has null attribute(s) */> #define HEAP_HASVARWIDTH0x0002/* has variable-width attribute(s) */> #define HEAP_HASEXTERNAL0x0004/* has external stored attribute(s) */> #define HEAP_HASOID_OLD0x0008/* has an object-id field */> #define HEAP_XMAX_KEYSHR_LOCK0x0010/* xmax is a key-shared locker */> #define HEAP_COMBOCID0x0020/* t_cid is a combo CID */> #define HEAP_XMAX_EXCL_LOCK0x0040/* xmax is exclusive locker */> #define HEAP_XMAX_LOCK_ONLY0x0080/* xmax, if valid, is only a locker */>> And I can't understand these attrs:I suggest you try something like 'git grep HEAP_HASEXTERNAL' which showsyou where the flag is used, which should tell you what it means. Theseshort descriptions generally assume you know enough about the internals.> 1. external stored attribute(s), what is this? can you give a create> statement to show me?external = value stored in a TOAST table> 2. xmax is a key-shared locker/exclusive locker/only a locker, so how> you use this? can you give me a scenario?> let me try to explain it:> if there is a txn is trying to read this heaptuple,> the HEAP_XMAX_KEYSHR_LOCK bit will be set to 1.> if there is a txn is trying to delete/update this heaptuple,> the HEAP_XMAX_EXCL_LOCK bit will be set to 1.> but for HEAP_XMAX_LOCK_ONLY, I can't understand.> And another thought is that these three bit can have only one to be set> 1 at most.I believe HEAP_XMAX_LOCK_ONLY means the xmax transaction only locked thetuple, without deleting/updating it.> 3. t_cid is a combo CID? what's a CID? give me an example please.CID means "command ID" i.e. sequential ID assigned to commands in asingle session (for visibility checks, so that a query doesn't see datadeleted by earlier commands in the same session). Seesrc/backend/utils/time/combocid.c for basic explanation of what "comboCID" is.regards--Tomas VondraEnterpriseDB: http://www.enterprisedb.comThe Enterprise PostgreSQL Company> I believe HEAP_XMAX_LOCK_ONLY means the xmax transaction only locked the> tuple, without deleting/updating it.if so, you mean when I read this tuple, this bit will be set 1, but I think this is duplicat with HEAP_XMAX_KEYSHR_LOCK.> CID means "command ID" i.e. sequential ID assigned to commands in a> single session (for visibility checks, so that a query doesn't see data> deleted by earlier commands in the same session). See> src/backend/utils/time/combocid.c for basic explanation of what "combo> CID" is.I think if cid is used for visibility checks in one session, that's meaingless, beacause we can use the t_xmin and t_xmax toget this goal. Is tis
On Sun, Feb 26, 2023 at 8:36 AM jacktby@gmail.com <jacktby@gmail.com> wrote:
> CID means "command ID" i.e. sequential ID assigned to commands in a> single session (for visibility checks, so that a query doesn't see data> deleted by earlier commands in the same session). See> src/backend/utils/time/combocid.c for basic explanation of what "combo> CID" is.I think if cid is used for visibility checks in one session, that's meaingless, beacause we can use the t_xmin and t_xmax toget this goal. Is tis
I think the word "session" is wrong. It should be "transaction".
IIUC, it is what is changed when one issues CommandCounterIncrement within a transaction. And you need somewhere to save which CCI step deletes rows, in particular due to the savepoint feature.
David J.