海山数据库(He3DB)源码详解:ResourceOwnerData及ResourceArray结构体解析
本文介绍了事务执行过程中,检查一个堆元组是否对当前事务可见,用于确保事务可以看到正确的数据版本。
ResourceOwnerData 结构体的作用
ResourceOwnerData 是 PostgreSQL 中用于管理资源所有权的核心结构体。它定义了一个资源所有者(ResourceOwner)的内部数据结构,用于跟踪和管理事务或子事务中占用的各种资源。这些资源包括缓冲区、缓存引用、文件、锁等。以下是对 ResourceOwnerData 结构体及其成员的详细解读:
1. 树状结构
所有的ResourceOwnerData数据会构成树状结构,如下图所示:

TopTransaction作为父节点,通过firstchild指针连接三个子节点;- 三个子节点分别通过
nextchild指针构成链表;
2. 结构体定义
typedef struct ResourceOwnerData
{
ResourceOwner parent; /* NULL if no parent (toplevel owner) */
ResourceOwner firstchild; /* head of linked list of children */
ResourceOwner nextchild; /* next child of same parent */
const char *name; /* name (just for debugging) */
/* We have built-in support for remembering: */
ResourceArray bufferarr; /* owned buffers */
ResourceArray catrefarr; /* catcache references */
ResourceArray catlistrefarr; /* catcache-list pins */
ResourceArray relrefarr; /* relcache references */
ResourceArray planrefarr; /* plancache references */
ResourceArray tupdescarr; /* tupdesc references */
ResourceArray snapshotarr; /* snapshot references */
ResourceArray filearr; /* open temporary files */
ResourceArray dsmarr; /* dynamic shmem segments */
ResourceArray jitarr; /* JIT contexts */
ResourceArray cryptohasharr; /* cryptohash contexts */
ResourceArray hmacarr; /* HMAC contexts */
/* We can remember up to MAX_RESOWNER_LOCKS references to local locks. */
int nlocks; /* number of owned locks */
LOCALLOCK *locks[MAX_RESOWNER_LOCKS]; /* list of owned locks */
} ResourceOwnerData;
1. 树状结构成员
-
ResourceOwner parent;- 类型:
ResourceOwner(指向另一个ResourceOwnerData的指针) - 作用:指向当前资源所有者的父节点。如果当前所有者
- 类型:

最低0.47元/天 解锁文章
1292

被折叠的 条评论
为什么被折叠?



