Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Shawn McKinney
OpenLDAP
Commits
27c8cee7
Commit
27c8cee7
authored
Aug 31, 2017
by
Howard Chu
Browse files
Add mdb_cursor_is_db()
Return 1 if the cursor is pointing to a named DB record
parent
e4cf9502
Changes
4
Hide whitespace changes
Inline
Side-by-side
libraries/liblmdb/lmdb.h
View file @
27c8cee7
...
...
@@ -1506,6 +1506,13 @@ MDB_txn *mdb_cursor_txn(MDB_cursor *cursor);
*/
MDB_dbi
mdb_cursor_dbi
(
MDB_cursor
*
cursor
);
/** @brief Check if the cursor is pointing to a named database record.
*
* @param[in] cursor A cursor handle returned by #mdb_cursor_open()
* @return 1 if current record is a named database, 0 otherwise.
*/
int
mdb_cursor_is_db
(
MDB_cursor
*
cursor
);
/** @brief Retrieve by cursor.
*
* This function retrieves key/data pairs from the database. The address and length
...
...
libraries/liblmdb/mdb.c
View file @
27c8cee7
...
...
@@ -9087,6 +9087,18 @@ mdb_cursor_dbi(MDB_cursor *mc)
return mc->mc_dbi;
}
int
mdb_cursor_is_db(MDB_cursor *mc)
{
if (mc && (mc->mc_flags & C_INITIALIZED) && mc->mc_snum) {
MDB_node *leaf = NODEPTR(mc->mc_pg[mc->mc_top], mc->mc_ki[mc->mc_top]);
if ((leaf->mn_flags & (F_DUPDATA|F_SUBDATA)) == F_SUBDATA)
return 1;
}
return 0;
}
/** 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.
...
...
libraries/liblmdb/mdb_dump.c
View file @
27c8cee7
...
...
@@ -272,7 +272,7 @@ int main(int argc, char *argv[])
}
while
((
rc
=
mdb_cursor_get
(
cursor
,
&
key
,
NULL
,
MDB_NEXT_NODUP
))
==
0
)
{
MDB_dbi
db2
;
if
(
memchr
(
key
.
mv_data
,
'\0'
,
key
.
mv_size
-
1
)
||
((
char
*
)
key
.
mv_data
)[
key
.
mv_size
=
1
]
!=
'\0'
)
if
(
!
mdb_cursor_is_db
(
cursor
)
)
continue
;
count
++
;
rc
=
mdb_dbi_open
(
txn
,
key
.
mv_data
,
0
,
&
db2
);
...
...
libraries/liblmdb/mdb_stat.c
View file @
27c8cee7
...
...
@@ -229,7 +229,7 @@ int main(int argc, char *argv[])
}
while
((
rc
=
mdb_cursor_get
(
cursor
,
&
key
,
NULL
,
MDB_NEXT_NODUP
))
==
0
)
{
MDB_dbi
db2
;
if
(
memchr
(
key
.
mv_data
,
'\0'
,
key
.
mv_size
-
1
)
||
((
char
*
)
key
.
mv_data
)[
key
.
mv_size
-
1
]
!=
'\0'
)
if
(
!
mdb_cursor_is_db
(
cursor
)
)
continue
;
rc
=
mdb_dbi_open
(
txn
,
key
.
mv_data
,
0
,
&
db2
);
if
(
rc
==
MDB_SUCCESS
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment