Berkeley DB: DbLog::put
Полезная информация

DbLog::put


#include <db_cxx.h>

int DbLog::put(DbLsn *lsn, const Dbt *data, u_int32_t flags);

Description

The DbLog::put method appends records to the log. The DbLsn of the put record is returned in the lsn argument. The flags argument may be set to one of the following values:

DB_CHECKPOINT
The log should write a checkpoint record, recording any information necessary to make the log structures recoverable after a crash.

DB_CURLSN
The DbLsn of the next record to be put is returned in the lsn argument.].

DB_FLUSH
The log is forced to disk after this record is written, guaranteeing that all records with DbLsn values less than or equal to the one being put are on disk before this function returns (this function is most often used for a transaction commit, see DbTxn::commit for more information).

The caller is responsible for providing any necessary structure to data. (For example, in a write-ahead logging protocol, the application must understand what part of data is an operation code, what part is redo information, and what part is undo information. In addition, most transaction managers will store in data the DbLsn of the previous log record for the same transaction, to support chaining back through the transaction's log records during undo.)

The DbLog::put method either returns errno or throws an exception that encapsulates an errno on failure, and 0 on success.

Errors

If a fatal error occurs in Berkeley DB, the DbLog::put method may fail and either return DB_RUNRECOVERY or throw an exception encapsulating DB_RUNRECOVERY, at which point all subsequent database calls will also fail in the same way. Methods marked as returning errno will, by default, throw an exception that encapsulates the error information. The default error behavior can be changed, see DbException.

The DbLog::put method may fail and throw an exception for any of the errors specified for the following Berkeley DB and C library functions: abort(3), close(3), dbenv->db_paniccall(3), fcntl(3), fflush(3), fprintf(3), free(3), fsync(3), getenv(3), getpid(3), getuid(3), isdigit(3), lseek(3), malloc(3), memcpy(3), memset(3), open(3), sigfillset(3), sigprocmask(3), snprintf(3), stat(3), strerror(3), strlen(3), time(3), unlink(3), vfprintf(3), vsnprintf(3), and write(3).

In addition, the DbLog::flush method may fail and throw an exception or return errno for the following conditions:

EINVAL
An invalid flag value or parameter was specified.

The record to be logged is larger than the maximum log record.

Class

DbLog

See Also

DbLog::archive, DbLog::close, DbLog::compare, DbLog::file, DbLog::flush, DbLog::get, DbLog::open, DbLog::put, DbLog::db_register, DbLog::stat, DbLog::unlink and DbLog::db_unregister.