Berkeley DB Reference Version 5.3.33

DB->cursor()

#include <db.h>

int
DB->cursor(DB *db, DB_TXN *txnid, DBC **cursorp, u_int32_t flags);  

The DB->cursor() method returns a created database cursor.

Cursors may span threads, but only serially, that is, the application must serialize access to the cursor handle.

The DB->cursor() method returns a non-zero error value on failure and 0 on success.

Parameters

txnid

To transaction-protect cursor operations, cursors must be opened and closed within the context of a transaction. The txnid parameter specifies the transaction context in which the cursor may be used.

Cursor operations are not automatically transaction-protected, even if the DB_AUTO_COMMIT flag is specified to the DB_ENV->set_flags() or DB->open() methods. If cursor operations are to be transaction-protected, the txnid parameter must be a transaction handle returned from DB_ENV->txn_begin(); otherwise, NULL.

cursorp

The cursorp parameter references memory into which a pointer to the allocated cursor is copied.

flags

The flags parameter must be set to 0 or by bitwise inclusively OR'ing together one or more of the following values:

Errors

The DB->cursor() method may fail and return one of the following non-zero errors:

DB_REP_HANDLE_DEAD

When a client synchronizes with the master, it is possible for committed transactions to be rolled back. This invalidates all the database and cursor handles opened in the replication environment. Once this occurs, an attempt to use such a handle will return DB_REP_HANDLE_DEAD. The application will need to discard the handle and open a new one in order to continue processing.

DB_REP_LOCKOUT

The operation was blocked by client/master synchronization.

EINVAL

An invalid flag value or parameter was specified.

Class

DB

See Also

Database Cursors and Related Methods