DBcursor->c_get |
![]() ![]() |
#include <db.h>int DBcursor->c_get(DBC *cursor, DBT *key, DBT *data, u_int32_t flags);
The DBcursor->c_get function retrieves key/data pairs from the database. The address and length of the key are returned in the object referenced by key (except for the case of the DB_SET flag where the key object is unchanged), and the address and length of the data are returned in the object referenced by data.
Modifications to the database during a sequential scan will be reflected in the scan, i.e. records inserted behind a cursor will not be returned while records inserted in front of a cursor will be returned.
In Queue and Recno databases, missing entries (i.e., entries that were never explicitly created or that were created and then deleted), will be skipped during a sequential scan.
If multiple threads or processes insert items into the same database file without using locking, the results are undefined. For more detail, see cursor stability.
The flags parameter must be set to one of the following values:
A record is available if it is not deleted and is not currently locked. For DB_CONSUME to be specified, the underlying database must be of type Queue.
If the cursor key/data pair was deleted, DBcursor->c_get will return DB_KEYEMPTY.
If the cursor is not yet initialized, the DBcursor->c_get function will return EINVAL.
If the database is a Queue or Recno database, DBcursor->c_get using the DB_FIRST flag will skip any keys that exist but were never explicitly created by the application or were created and later deleted.
If the database is empty, DBcursor->c_get will return DB_NOTFOUND.
For DB_GET_BOTH to be specified, the underlying database must be of type Btree or Hash.
For DB_GET_RECNO to be specified, the underlying database must be of type Btree and it must have been created with the DB_RECNUM flag.
For DB_JOIN_ITEM to be specified, the underlying cursor must have been returned from the DB->join function.
If the database is a Queue or Recno database, DBcursor->c_get using the DB_LAST flag will skip any keys that exist but were never explicitly created by the application or were created and later deleted.
If the database is empty, DBcursor->c_get will return DB_NOTFOUND.
Otherwise, the cursor is moved to the next key/data pair of the database, and that pair is returned. In the presence of duplicate key values, the value of the key may not change.
If the database is a Queue or Recno database, DBcursor->c_get using the DB_NEXT flag will skip any keys that exist but were never explicitly created by the application or were created and later deleted.
If the cursor is already on the last record in the database, DBcursor->c_get will return DB_NOTFOUND.
If the cursor is not yet initialized, the DBcursor->c_get function will return EINVAL.
Otherwise, the cursor is moved to the previous key/data pair of the database, and that pair is returned. In the presence of duplicate key values, the value of the key may not change.
If the database is a Queue or Recno database, DBcursor->c_get using the DB_PREV flag will skip any keys that exist but were never explicitly created by the application or were created and later deleted.
If the cursor is already on the first record in the database, DBcursor->c_get will return DB_NOTFOUND.
In the presence of duplicate key values, DBcursor->c_get will return the first data item for the given key.
If the database is a Queue or Recno database and the requested key exists, but was never explicitly created by the application or was later deleted, DBcursor->c_get will return DB_KEYEMPTY.
If no matching keys are found, DBcursor->c_get will return DB_NOTFOUND.
For DB_SET_RECNO to be specified, the underlying database must be of type Btree and it must have been created with the DB_RECNUM flag.
In addition, the following value may be set by bitwise inclusively OR'ing it into the flags parameter:
Otherwise, the DBcursor->c_get function returns a non-zero error value on failure and 0 on success.
If DBcursor->c_get fails for any reason, the state of the cursor will be unchanged.
In addition, the DBcursor->c_get function may fail and return a non-zero error for the following conditions:
The specified cursor was not currently initialized.
The DB_THREAD flag was specified to DB->open and none of the DB_DBT_MALLOC, DB_DBT_REALLOC or DB_DBT_USERMEM flags were set in the DBT.
In addition, the DBcursor->c_get function may fail and return a non-zero error for errors specified for other Berkeley DB and C library or system functions.
![]() ![]() |