The DCE backing store interface allows you to maintain typed data between program invocations. For example, you might store application-specific configuration data in a backing store, and then retrieve it from the backing store when the application restarts. The backing store routines can be used in servers, in clients or in standalone programs that do not involve remote procedure calls (RPC). A program can have more than one backing store open at the same time.
Sometimes the backing store is called a database. For instance, the associated IDL file is dce/database.idl, and the name of the backing store routines begin with dce_db_. The backing store is, however, not a full-fledged database in the conventional sense, and it has no support for SQL or for any other query system.
The backing store interface provides for the tagged storage and retrieval of typed data. The tag (or retrieval key) can be either a UUID or a standard C string. For a specific backing store, the data type must be specified at compile time, and is established through the IDL Encoding Services. Each backing store can contain only a single data type.
Each data item (also called a data object or data record) consists of the data stored by a single call to a storage routine (dce_db_store(), dce_db_store_by_name(), or dce_db_store_by_uuid()). Optionally, data items can have headers. If a backing store has been created to use headers, then every data item must have a header. For a description of the data item header, see "Data Structures," below.
When a Remote Procedure Call (RPC) sends data between a client and a server, it serializes the user's data structures by using the IDL Encoding Services (ES), described in the OSF DCE Application Development Guide .
The backing store uses this same serialization scheme for encoding and decoding, informally called ``pickling,'' when storing data structures to disk. The IDL compiler, idl, writes the routine that encodes and decodes the data. This routine is passed to dce_db_open(), remembered in the handle, and used by the store and fetch routines:
When fetching data, the Encoding Services (ES) allocate memory for the data structures that are returned. These services accept a structure, and use rpc_sm_allocate() to provide additional memory needed to hold the data.
The backing store library does not know what memory has been allocated, and therefore cannot free it. For fetch calls that are made from a server stub, this is not a problem, because the memory is freed automatically when the server call terminates. For fetch calls that are made from a non-server, the programmer is responsible for freeing the memory.
Programs that call the fetch or store routines, such as dce_db_fetch(), outside of a server operation (for instance, if a server does some backing store initialization, or in a standalone program) must call rpc_sm_enable_allocate() first.
Many of the backing store routines appear in three versions: plain, by name, and by UUID. The plain version will work with backing stores that were created to be indexed either by name, or by UUID, while the restricted versions accept only the matching type. It is advantageous to use the restricted versions when they are appropriate, because they provide type checking by the compiler, as well as visual clarity of purpose.
The backing store routines are as follows, listed in alphabetical order:
The routine returns a handle by which subsequent routines can reference the opened backing store.
You can not use conformant arrays in objects stored to a backing store. This is because the idl-generated code that encodes (pickles) the structure has no way to predict or detect the size of the array. When the object is fetched, there will likely be insufficient space provided for the structure, and the array's data will destroy whatever is in memory after the structure.
database.idl, database.h, db.h, and dbif.h
Books: OSF DCE Application Development Guide