mirror of
https://github.com/isar/libmdbx.git
synced 2024-10-30 11:29:19 +08:00
mdbx: рефакторинг обработки MDBX_GET_MULTIPLE
добавление проверки key
на NULL
.
This commit is contained in:
parent
100e95957c
commit
b7605e8033
35
src/core.c
35
src/core.c
@ -17268,24 +17268,30 @@ static __hot int cursor_get(MDBX_cursor *mc, MDBX_val *key, MDBX_val *data,
|
|||||||
return MDBX_EINVAL;
|
return MDBX_EINVAL;
|
||||||
if (unlikely((mc->mc_db->md_flags & MDBX_DUPFIXED) == 0))
|
if (unlikely((mc->mc_db->md_flags & MDBX_DUPFIXED) == 0))
|
||||||
return MDBX_INCOMPATIBLE;
|
return MDBX_INCOMPATIBLE;
|
||||||
rc = (mc->mc_flags & C_INITIALIZED)
|
if ((mc->mc_flags & C_INITIALIZED) == 0) {
|
||||||
? MDBX_SUCCESS
|
if (unlikely(!key))
|
||||||
: cursor_set(mc, key, data, MDBX_SET).err;
|
return MDBX_EINVAL;
|
||||||
if ((mc->mc_xcursor->mx_cursor.mc_flags & (C_INITIALIZED | C_EOF)) !=
|
rc = cursor_set(mc, key, data, MDBX_SET).err;
|
||||||
C_INITIALIZED)
|
if (unlikely(rc != MDBX_SUCCESS))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
rc = MDBX_SUCCESS;
|
||||||
|
if (unlikely(C_INITIALIZED != (mc->mc_xcursor->mx_cursor.mc_flags &
|
||||||
|
(C_INITIALIZED | C_EOF)))) {
|
||||||
|
rc = MDBX_NOTFOUND;
|
||||||
break;
|
break;
|
||||||
goto fetchm;
|
}
|
||||||
|
goto fetch_multiple;
|
||||||
case MDBX_NEXT_MULTIPLE:
|
case MDBX_NEXT_MULTIPLE:
|
||||||
if (unlikely(data == NULL))
|
if (unlikely(!data))
|
||||||
return MDBX_EINVAL;
|
return MDBX_EINVAL;
|
||||||
if (unlikely(!(mc->mc_db->md_flags & MDBX_DUPFIXED)))
|
if (unlikely(!(mc->mc_db->md_flags & MDBX_DUPFIXED)))
|
||||||
return MDBX_INCOMPATIBLE;
|
return MDBX_INCOMPATIBLE;
|
||||||
rc = cursor_next(mc, key, data, MDBX_NEXT_DUP);
|
rc = cursor_next(mc, key, data, MDBX_NEXT_DUP);
|
||||||
if (rc == MDBX_SUCCESS) {
|
if (rc == MDBX_SUCCESS) {
|
||||||
if (mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) {
|
if (mc->mc_xcursor->mx_cursor.mc_flags & C_INITIALIZED) {
|
||||||
MDBX_cursor *mx;
|
fetch_multiple:;
|
||||||
fetchm:
|
MDBX_cursor *mx = &mc->mc_xcursor->mx_cursor;
|
||||||
mx = &mc->mc_xcursor->mx_cursor;
|
|
||||||
data->iov_len =
|
data->iov_len =
|
||||||
page_numkeys(mx->mc_pg[mx->mc_top]) * mx->mc_db->md_xsize;
|
page_numkeys(mx->mc_pg[mx->mc_top]) * mx->mc_db->md_xsize;
|
||||||
data->iov_base = page_data(mx->mc_pg[mx->mc_top]);
|
data->iov_base = page_data(mx->mc_pg[mx->mc_top]);
|
||||||
@ -17296,21 +17302,20 @@ static __hot int cursor_get(MDBX_cursor *mc, MDBX_val *key, MDBX_val *data,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case MDBX_PREV_MULTIPLE:
|
case MDBX_PREV_MULTIPLE:
|
||||||
if (data == NULL)
|
if (unlikely(!data))
|
||||||
return MDBX_EINVAL;
|
return MDBX_EINVAL;
|
||||||
if (!(mc->mc_db->md_flags & MDBX_DUPFIXED))
|
if (!(mc->mc_db->md_flags & MDBX_DUPFIXED))
|
||||||
return MDBX_INCOMPATIBLE;
|
return MDBX_INCOMPATIBLE;
|
||||||
rc = MDBX_SUCCESS;
|
rc = MDBX_SUCCESS;
|
||||||
if (!(mc->mc_flags & C_INITIALIZED))
|
if ((mc->mc_flags & C_INITIALIZED) == 0)
|
||||||
rc = cursor_last(mc, key, data);
|
rc = cursor_last(mc, key, data);
|
||||||
if (rc == MDBX_SUCCESS) {
|
if (rc == MDBX_SUCCESS) {
|
||||||
MDBX_cursor *mx = &mc->mc_xcursor->mx_cursor;
|
MDBX_cursor *mx = &mc->mc_xcursor->mx_cursor;
|
||||||
|
rc = MDBX_NOTFOUND;
|
||||||
if (mx->mc_flags & C_INITIALIZED) {
|
if (mx->mc_flags & C_INITIALIZED) {
|
||||||
rc = cursor_sibling(mx, SIBLING_LEFT);
|
rc = cursor_sibling(mx, SIBLING_LEFT);
|
||||||
if (rc == MDBX_SUCCESS)
|
if (rc == MDBX_SUCCESS)
|
||||||
goto fetchm;
|
goto fetch_multiple;
|
||||||
} else {
|
|
||||||
rc = MDBX_NOTFOUND;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user