Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cursor moves from UPS_CURSOR_FIRST to UPS_CURSOR_PREVIOUS without UPS_KEY_NOT_FOUND #107

Open
Amadeszueusz opened this issue Jan 10, 2018 · 0 comments

Comments

@Amadeszueusz
Copy link

Please consider sample:

int main()
{
    ups_env_t* env;
    ups_env_create(&env, "test.db", UPS_ENABLE_TRANSACTIONS, 0664, 0);
    //ups_env_create(&env, "test.db", 0, 0664, 0);

    ups_parameter_t params[] = {
    {UPS_PARAM_KEY_TYPE, UPS_TYPE_UINT32},
    {0, }
    };

    ups_db_t* db;
    ups_env_create_db(env, &db, 1, 0, &params[0]);

    const int item_count = 57; // required

    for (int i = 0; i < item_count; i++)
    {
        ups_key_t key = ups_make_key(&i, sizeof(i));
        ups_record_t record = {0};

        ups_db_insert(db, 0, &key, &record, 0);
    }

    ups_cursor_t* cur;

    ups_cursor_create(&cur, db, 0, 0);

    int key_data = 0;
    ups_key_t key = {0}; key.data = &key_data; key.size = sizeof(key_data);
    ups_record_t rec = {0};

    ups_cursor_move(cur, &key, &rec, UPS_CURSOR_FIRST);
    if((UPS_SUCCESS == ups_cursor_move(cur, &key, &rec, UPS_CURSOR_PREVIOUS)))
    {
        std::cout << "Cursor moved from FIRST to PREVIOUS without UPS_KEY_NOT_FOUND" << std::endl;
    }

    ups_cursor_close(cur);

    ups_db_close(db, 0);

    return 0;
}

In standard output:

Cursor moved from FIRST to PREVIOUS without UPS_KEY_NOT_FOUND

Issue occurs for item_count=57 and not for example for item_count=50
Transactions must be enabled to observe the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant