mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-06 17:44:13 +08:00
mdbx: backport (comments) - Note functions which must set MDB_TXN_ERROR on failure.
Other functions depend on them to do so. For mdb_node_read(), instead remove such a dependence. Change-Id: I49c1c8bbb1c20527cbf76ef004cb7a1300ef465c
This commit is contained in:
parent
2fb5a54264
commit
ba688e63dc
13
mdb.c
13
mdb.c
@ -1542,6 +1542,7 @@ mdb_dcmp(MDB_txn *txn, MDB_dbi dbi, const MDB_val *a, const MDB_val *b)
|
|||||||
|
|
||||||
/** Allocate memory for a page.
|
/** Allocate memory for a page.
|
||||||
* Re-use old malloc'd pages first for singletons, otherwise just malloc.
|
* Re-use old malloc'd pages first for singletons, otherwise just malloc.
|
||||||
|
* Set #MDB_TXN_ERROR on failure.
|
||||||
*/
|
*/
|
||||||
static MDB_page *
|
static MDB_page *
|
||||||
mdb_page_malloc(MDB_txn *txn, unsigned num)
|
mdb_page_malloc(MDB_txn *txn, unsigned num)
|
||||||
@ -2045,7 +2046,7 @@ mdb_page_dirty(MDB_txn *txn, MDB_page *mp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Allocate page numbers and memory for writing. Maintain me_pglast,
|
/** Allocate page numbers and memory for writing. Maintain me_pglast,
|
||||||
* me_pghead and mt_next_pgno.
|
* me_pghead and mt_next_pgno. Set #MDB_TXN_ERROR on failure.
|
||||||
*
|
*
|
||||||
* If there are free pages available from older transactions, they
|
* If there are free pages available from older transactions, they
|
||||||
* are re-used first. Otherwise allocate a new page at mt_next_pgno.
|
* are re-used first. Otherwise allocate a new page at mt_next_pgno.
|
||||||
@ -2472,6 +2473,7 @@ mdb_page_unspill(MDB_txn *txn, MDB_page *mp, MDB_page **ret)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Touch a page: make it dirty and re-insert into tree with updated pgno.
|
/** Touch a page: make it dirty and re-insert into tree with updated pgno.
|
||||||
|
* Set #MDB_TXN_ERROR on failure.
|
||||||
* @param[in] mc cursor pointing to the page to be touched
|
* @param[in] mc cursor pointing to the page to be touched
|
||||||
* @return 0 on success, non-zero on failure.
|
* @return 0 on success, non-zero on failure.
|
||||||
*/
|
*/
|
||||||
@ -5355,7 +5357,9 @@ mdb_cursor_pop(MDB_cursor *mc)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Push a page onto the top of the cursor's stack. */
|
/** Push a page onto the top of the cursor's stack.
|
||||||
|
* Set #MDB_TXN_ERROR on failure.
|
||||||
|
*/
|
||||||
static int
|
static int
|
||||||
mdb_cursor_push(MDB_cursor *mc, MDB_page *mp)
|
mdb_cursor_push(MDB_cursor *mc, MDB_page *mp)
|
||||||
{
|
{
|
||||||
@ -5375,6 +5379,7 @@ mdb_cursor_push(MDB_cursor *mc, MDB_page *mp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Find the address of the page corresponding to a given page number.
|
/** Find the address of the page corresponding to a given page number.
|
||||||
|
* Set #MDB_TXN_ERROR on failure.
|
||||||
* @param[in] txn the transaction for this access.
|
* @param[in] txn the transaction for this access.
|
||||||
* @param[in] pgno the page number for the page to retrieve.
|
* @param[in] pgno the page number for the page to retrieve.
|
||||||
* @param[out] ret address of a pointer where the page's address will be stored.
|
* @param[out] ret address of a pointer where the page's address will be stored.
|
||||||
@ -7148,6 +7153,7 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Allocate and initialize new pages for a database.
|
/** Allocate and initialize new pages for a database.
|
||||||
|
* Set #MDB_TXN_ERROR on failure.
|
||||||
* @param[in] mc a cursor on the database being added to.
|
* @param[in] mc a cursor on the database being added to.
|
||||||
* @param[in] flags flags defining what type of page is being allocated.
|
* @param[in] flags flags defining what type of page is being allocated.
|
||||||
* @param[in] num the number of pages to allocate. This is usually 1,
|
* @param[in] num the number of pages to allocate. This is usually 1,
|
||||||
@ -7233,6 +7239,7 @@ mdb_branch_size(MDB_env *env, MDB_val *key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Add a node to the page pointed to by the cursor.
|
/** Add a node to the page pointed to by the cursor.
|
||||||
|
* Set #MDB_TXN_ERROR on failure.
|
||||||
* @param[in] mc The cursor for this operation.
|
* @param[in] mc The cursor for this operation.
|
||||||
* @param[in] indx The index on the page where the new node should be added.
|
* @param[in] indx The index on the page where the new node should be added.
|
||||||
* @param[in] key The key for the new node.
|
* @param[in] key The key for the new node.
|
||||||
@ -7747,6 +7754,7 @@ mdb_cursor_dbi(MDB_cursor *mc)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Replace the key for a branch node with a new key.
|
/** Replace the key for a branch node with a new key.
|
||||||
|
* Set #MDB_TXN_ERROR on failure.
|
||||||
* @param[in] mc Cursor pointing to the node to operate on.
|
* @param[in] mc Cursor pointing to the node to operate on.
|
||||||
* @param[in] key The new key to use.
|
* @param[in] key The new key to use.
|
||||||
* @return 0 on success, non-zero on failure.
|
* @return 0 on success, non-zero on failure.
|
||||||
@ -8577,6 +8585,7 @@ mdb_del0(MDB_txn *txn, MDB_dbi dbi,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Split a page and insert a new node.
|
/** Split a page and insert a new node.
|
||||||
|
* Set #MDB_TXN_ERROR on failure.
|
||||||
* @param[in,out] mc Cursor pointing to the page and desired insertion index.
|
* @param[in,out] mc Cursor pointing to the page and desired insertion index.
|
||||||
* The cursor will be updated to point to the actual page and index where
|
* The cursor will be updated to point to the actual page and index where
|
||||||
* the node got inserted after the split.
|
* the node got inserted after the split.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user