I. General Notes
1. use a cursor to access db internally. cursor connects lock/txn/logging/AM, etc.
To get a page, first create a cursor if don't have one, then call __db_lget to lock the page, then call __memp_fget to get the page from cache,
then you have the page's pointer. after use, call __TLPUT OR __LPUT to release lock, then call __memp_fput to release page.
2. How to lock/unlock a page and get/put a page from mpool?
See __bam_read_lock.
3. Cursor Ajudgement
Cursor adjustments are logged if they are for subtransactions. This is
because it's possible for a subtransaction to adjust cursors which will
still be active after the subtransaction aborts, and so which must be
restored to their previous locations. Cursors that can be both affected
by our cursor adjustments and active after our transaction aborts can
only be found in our parent transaction -- cursors in other transactions,
including other child transactions of our parent, must have conflicting
locker IDs, and so cannot be affected by adjustments in this transaction.
When an key/data pair is deleted, there can be other cursors pointing to it so
we don't physically delete it immediately, but mark the key/data pair deleted, and mark
all cursors pointing at this k/d with C_DELETED (which is called a
Berkeley DB 源代码分析 (1) --- 代码特征与游标的实现
最新推荐文章于 2019-07-22 16:02:08 发布