DBT: Key/Data Pairs API Ref

Storage and retrieval for the Berkeley DB access methods are based on key/data pairs. Both key and data items are represented by the DBT data structure. (The name DBT is a mnemonic for data base thang, and was used because no one could think of a reasonable name that wasn't already in use somewhere else.) Key and data byte strings may refer to strings of zero length up to strings of essentially unlimited length. See Database limits for more information.

typedef struct {
	void *data;
	u_int32_t size;
	u_int32_t ulen;
	u_int32_t dlen;
	u_int32_t doff;
	u_int32_t flags;
} DBT;

In order to ensure compatibility with future releases of Berkeley DB, all fields of the DBT structure that are not explicitly set should be initialized to nul bytes before the first time the structure is used. Do this by declaring the structure external or static, or by calling the C library routine bzero(3) or memset(3).

By default, the flags structure element is expected to be set to 0. In this default case, when the application is providing Berkeley DB a key or data item to store into the database, Berkeley DB expects the data structure element to point to a byte string of size bytes. When returning a key/data item to the application, Berkeley DB will store into the data structure element a pointer to a byte string of size bytes, and the memory to which the pointer refers will be allocated and managed by Berkeley DB.

The elements of the DBT structure are defined as follows:


void *data; u_int32_t size; u_int32_t ulen; u_int32_t dlen; u_int32_t doff; u_int32_t flags;

APIRef

Copyright (c) 1996,2008 Oracle. All rights reserved.