DIRECTORY Rope USING [ROPE], LoganBerry; LoganBerryStub: CEDAR DEFINITIONS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; AttributeType: TYPE = LoganBerry.AttributeType; AttributeValue: TYPE = LoganBerry.AttributeValue; Attribute: TYPE = LoganBerry.Attribute; Entry: TYPE = LoganBerry.Entry; LogID: TYPE = LoganBerry.LogID; activityLog: LogID = LoganBerry.activityLog; -- default log for updates Cursor: TYPE = LoganBerry.Cursor; CursorDirection: TYPE = LoganBerry.CursorDirection; OpenDB: TYPE = LoganBerry.OpenDB; SchemaInfo: TYPE = LoganBerry.SchemaInfo; Conv: TYPE = LoganBerry.Conv; Error: ERROR [ec: ErrorCode, explanation: ROPE _ NIL]; ErrorCode: TYPE = LoganBerry.ErrorCode; Open: PROC [conv: Conv _ NIL, dbName: ROPE] RETURNS [db: OpenDB]; Describe: PROC [conv: Conv _ NIL, db: OpenDB] RETURNS [info: SchemaInfo]; ReadEntry: PROC [conv: Conv _ NIL, db: OpenDB, key: AttributeType, value: AttributeValue] RETURNS [entry: Entry, others: BOOLEAN]; EntryProc: TYPE = LoganBerry.EntryProc; EnumerateEntries: PROC [db: OpenDB, key: AttributeType, start: AttributeValue _ NIL, end: AttributeValue _ NIL, proc: EntryProc] RETURNS []; GenerateEntries: PROC [conv: Conv _ NIL, db: OpenDB, key: AttributeType, start: AttributeValue _ NIL, end: AttributeValue _ NIL] RETURNS [cursor: Cursor]; NextEntry: PROC [conv: Conv _ NIL, cursor: Cursor, dir: CursorDirection _ increasing] RETURNS [entry: Entry]; EndGenerate: PROC [conv: Conv _ NIL, cursor: Cursor] RETURNS []; WriteEntry: PROC [conv: Conv _ NIL, db: OpenDB, entry: Entry, log: LogID _ activityLog, replace: BOOLEAN _ FALSE] RETURNS []; DeleteEntry: PROC [conv: Conv _ NIL, db: OpenDB, key: AttributeType, value: AttributeValue] RETURNS []; Close: PROC [conv: Conv _ NIL, db: OpenDB] RETURNS []; BuildIndices: PROC [conv: Conv _ NIL, db: OpenDB] RETURNS []; CompactLogs: PROC [conv: Conv _ NIL, db: OpenDB] RETURNS []; END. €LoganBerryStub.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. Doug Terry, April 22, 1986 1:40:01 pm PST LoganBerryStub provides easy access to local or remote LoganBerry database servers. It attempts to hide any RPC details. That is, it (1) catches RPC failures and attempts to either recover or turn them into LoganBerry errors, (2) imports RPC interfaces from multiple servers on demand, (3) uses secure RPC conversations, and (4) tries to keep LoganBerry databases open. The interface is identical to LoganBerry.mesa. The possible ErrorCodes are: $BadSchema, -- the schema can not be parsed $CantOpenSchema, -- the schema file could not be opened $BadDBHandle, -- an invalid OpenDB handle was passed to some routine $BadCursor, -- an invalid cursor was passed to some routine $NoIndex, -- the key presented in a read or delete operation has no associated index $NoPrimaryKey, -- a new entry being written does not contain a primary key $ValueNotUnique, -- a new entry being written contains the same primary key value as an existing entry, or the value supplied for a delete does not uniquely specifiy an entry $CantOpenLog, -- a log file could not be opened $BadLogEntry, -- a log entry is of the wrong format $LogReadOnly, -- the specified log can not be updated $InvalidReplace, -- an entry being replaced is in a different log than its replacement $CantOpenIndex, -- a btree file could not be opened $BadIndex, -- a btree index is corrupted $DBClosed, -- the database has been closed $DBNotAvailable, -- the database has been taken out of general service $InternalError -- indicates some miscellaneous internal error Initiates database activity and checks for consistency. This can be called any number of times to get a new OpenDB handle or reopen a database that has been closed. Indices are automatically rebuilt if any are missing or if a partially-completed update left them out-of-date. Errors: CantOpenSchema, BadSchema, CantOpenLog, BadIndex Returns schema information about the database. Errors: BadDBHandle Returns an entry that contains the given attribute value for the given key; returns NIL if none exists. If the key refers to the primary index then the unique entry is returned and `others' is FALSE. If the key is secondary and several entries exist with the same value for the key, then an arbitrary entry is returned and `others' is set to TRUE; use EnumerateEntries to get all of the matching entries. Errors: BadDBHandle, NoIndex, DBClosed, BadIndex, BadLogEntry Calls `proc' for each entry in the specified range of key values. The enumeration is halted when either the range of entries is exhausted or `proc' returns FALSE. A NIL value for `start' represents the least attribute value, while a NIL value for `end' represents the largest attribute value. Thus, the complete database can be enumerated by specifying start=NIL and end=NIL with `key' equal to the primary key. WARNING: THIS ROUTINE CAN NOT BE USED ACROSS AN RPC CONNECTION; USE GenerateEntries INSTEAD. Errors: BadDBHandle, NoIndex, DBClosed, BadIndex, BadLogEntry Similar to EnumerateEntries, but creates a cursor so that entries in the specified range of key values can be retrieved using NextEntry (defined below). Initially, the cursor points to the start of the sequence. A NIL value for `start' represents the least attribute value, while a NIL value for `end' represents the largest attribute value. Thus, the complete database can be enumerated by specifying start=NIL and end=NIL with `key' equal to the primary key. Errors: BadDBHandle, NoIndex Retrieves the next entry relative to the given cursor. The cursor, and thus the sequence of desired entries, must have been previously created by a call to GenerateEntries. The cursor is automatically updated so that NextEntry may be repeatedly called to enumerate entries. NIL is returned if the cursor is at the end of the sequence and dir=increasing or at the start of the sequence and dir=decreasing. Errors: BadCursor, DBClosed, BadIndex, BadLogEntry Releases the cursor; no further operations may be performed using the given cursor. This must be called once for every call to GenerateEntries. Adds a new entry to the database. The entry is added to the activity log unless another log is explicitly requested. The entry must have an attribute for the primary key. The primary attribute value must be unique throughout the database unless replace=TRUE; in this case, an existing entry with the same primary attribute value is atomically replaced with the new entry (both must reside in the same log). Errors: BadDBHandle, NoPrimaryKey, ValueNotUnique, LogReadOnly, InvalidReplace, DBClosed, BadIndex Deletes the entry that contains the given attribute value for the given key. If the key is for a secondary index and the value is not unique then an Error[ValueNotUnique] is raised. Deletes are actually performed by logging the delete request (so that the log can be replayed at a later time) and then updating all of the indices. Errors: BadDBHandle, NoIndex, DBClosed, BadIndex, ValueNotUnique, LogReadOnly, BadLogEntry Terminates database activity and closes all log and index files. Databases are always maintained consistently on disk so it doesn't hurt to leave a database open. The main reason for calling Close is to release the FS locks on the log files so they can be manually edited. WARNING: THIS SHOULD NOT BE CALLED IF THE DATABASE IS BEING SHARED BY MULTIPLE CLIENTS. Errors: BadDBHandle Rebuilds the indices by scanning the logs and performing WriteEntry or DeleteEntry operations. Removes deleted entries from the logs by enumerating the primary index and writing new logs. Doug Terry, April 17, 1986 5:41:43 pm PST created to mimic LoganBerry.mesa Κ)˜codešœ™Kšœ Οmœ1™—K˜š Οnœžœžœ žœžœ˜AKšœ•™•Kšœ8™8—K˜š‘œžœžœžœ˜IK™.Kšœ™—K˜š ‘ œžœžœ9žœžœ˜‚Kšœ–™–Kšœ=™=—K˜Kš‘ œžœ˜'K˜š ‘œžœ:žœžœžœ˜ŒKšœž™žKšΟsDœ’ ™\Kšœ=™=—K˜š ‘œžœžœ:žœžœžœ˜šKšœΟ™ΟKšœ™—K™š‘ œžœžœ5žœ˜mKšœ—™—Kšœ2™2—K˜š‘ œžœžœžœ˜@Kšœ™—K˜š ‘ œžœžœ?žœžœžœ˜}Kšœ€žœ–™šKšœb™b—K˜š‘ œžœžœ9žœ˜gKšœΜ™ΜKšœZ™Z—K˜š‘œžœžœžœ˜6K™’Kš’X™XKšœ™—Iblock˜š‘ œžœžœžœ˜=Kšœ^™^—K˜š‘ œžœžœžœ˜