WalnutSchema.mesa
Copyright Ó 1984, 1987, 1988, 1992 by Xerox Corporation. All rights reserved.
Willie-Sue, June 28, 1988 3:56:11 pm PDT
Donahue, March 24, 1986 2:44:52 pm PST
Jack Kent, April 21, 1987 5:58:27 pm PDT
Doug Terry, November 8, 1989 5:00:00 pm PST
Types and entities in the Walnut message database
(Added NewMail and Archive log position info for restart)
(Changed mDAInfo to be mInfo and changed mAccepted to be mShow -- in multiple log case, this attribute will be used for both Active and Deleted message set enumerations)
NEW: All information is stored as entries (records) in a LoganBerry database. For the most part, everything that was a relationship in the Cypress database is now an entry in the LoganBerry database. Some things are combined together into the same entry (though it shouldn't really matter to clients if they use GetAttr to extract data from entries). Since LoganBerry requires a complete entry to be rewritten (and reindexed) everytime one of its attributes changes, the packaging of information into entries is a performance consideration.
Primary keys for entries are generated in one of several ways: For information that pertains to the database as a whole (global information), the primary key is just a character string that does not conflict with any other primary key. For information about a message, the primary key is some string, such as "MSG-", prepended to the message's unique ID. For information about a message set, the primary key is some string, such as "MSGSET-", prepended to the message set's name. For information about a server, the primary key is some string, such as "SERVER-", prepended to the server's name.
DIRECTORY
BasicTime USING [GMT],
LoganBerry USING [Entry, AttributeType],
RefTab USING [Ref],
Rope USING [ROPE],
WalnutDefs USING [MsgSet, WalnutOpsHandle];
WalnutSchema: CEDAR DEFINITIONS
= BEGIN
Types
ROPE: TYPE = Rope.ROPE;
AttributeType: TYPE = LoganBerry.AttributeType;
MsgSet: TYPE = WalnutDefs.MsgSet;
WalnutOpsHandle: TYPE = WalnutDefs.WalnutOpsHandle;
Schema Variables
Schema handles are no longer needed. The definition is left here for source compatibility in other modules. ???
SchemaHandle: TYPE = REF SchemaHandleRec;
SchemaHandleRec: TYPE = RECORD[
Global information
gRootInfo: ROPE,   -- primary key for root info
gRootFileStamp: AttributeType, -- rootFile create date for this db (gmt)
gRootFileKey: AttributeType, -- key from rootFile for this db (rope)
gMailFor: AttributeType,  -- RName (rope)
gLogInfo: ROPE,
gLogFileID: AttributeType,    -- int
gOpInProgressPos: AttributeType,   -- int - long running operation Pos
gFirstDestroyedMsgPos: AttributeType, -- int
gBytesInDestroyedMsgs: AttributeType, -- int
gTimeOfLastScavenge: AttributeType, -- gmt
gParseLogInfo: ROPE,
gParseLogInProgress: AttributeType, -- bool
gParseLogPos: AttributeType, -- int
gExpungeInfo: ROPE,
gLogExpungePhase: AttributeType, -- int
gExpungeFileID: AttributeType, -- int
gCurrentLogPos: AttributeType, -- int
gExpungeLogPos: AttributeType, -- int
gTimeOfLastExpunge: AttributeType, -- gmt
gNewMailInfo: ROPE,
gNewMailLogLength: AttributeType,  -- int
gCopyNewMailLogPos: AttributeType,  -- int
gAcceptNewMailLogPos: AttributeType, -- int
gAddingServerMsgs: AttributeType,  -- bool
gLastNewMailTimeStamp: AttributeType, -- time
gReadArchiveInfo: ROPE,
gReadArchiveLogPos: AttributeType,  -- int
gCopyReadArchiveLogPos: AttributeType, -- int
gVersionInfo: ROPE,
gMsgCount: AttributeType, -- int (number of msgs)
gMsgSetCount: AttributeType, -- int (number of msgSets)
gMsgSetsVersion: AttributeType, -- int (version number for msgSets)
Server entity Relation
sBasicInfo: ROPE, -- One per Server
sBIOf: AttributeType,  -- Server
sBINum: AttributeType,  -- int (number of msgs)
MsgSet entity relation
msBasicInfo: ROPE, -- One per MsgSet
msBIOf: AttributeType,  -- MsgSet
msBICount: AttributeType,  -- int (number of member msgs)
msBIVersion: AttributeType,  -- int
msPrintNameIs: AttributeType, -- rope
Msg displaying relation
mMsgInfo: ROPE, -- One per Msg
mMIOf: AttributeType,   -- Msg
mMIHerald: AttributeType, -- rope
mMIShortNameLen: AttributeType, -- int (for icon label, etc)
mMIEntryStart: AttributeType, -- int (start of entry in log)
mMITextOffset: AttributeType, -- int (offset for text)
mMITextLen: AttributeType, -- int (length of text)
mMIFormatLen: AttributeType, -- int (length of formatting)
mMIDate: AttributeType,  -- time
mMISubject: AttributeType, -- Subject (truncated to 20 chars)
mMISubjectText: AttributeType, -- rope (up to 99 chars)
mMIIsInReplyTo: AttributeType, -- bool
mMISender: AttributeType, -- Address (only one allowed)
Msg in MsgSet displayer relation
mDisplayInfo: ROPE, -- One per Msg
mDIOf: AttributeType,   -- Msg
mDITOCHeadEntry: AttributeType, -- rope
mDIHasBeenRead: AttributeType, -- bool
Msg Date/Show relation
mInfo: ROPE, -- One per Msg
mInfoOf: AttributeType,   -- Msg
mDateIs: AttributeType,  -- time
mShowIs: AttributeType,  -- Unaccepted
Category/Date relation
cdRelation: ROPE, -- One per Msg
cdMsg: AttributeType,   -- Msg
cdMsgSet: AttributeType,  -- MsgSet (multiple allowed)
cdDate: AttributeType,   -- time (of the Msg)
Msg/To relation
toRelation: ROPE, -- One per Msg
toMsg: AttributeType,   -- Msg
toAddress: AttributeType,  -- Address (multiple allowed)
toDate: AttributeType,   -- time (of the Msg)
Msg/CC relation
ccRelation: ROPE, -- One per Msg
ccMsg: AttributeType,   -- Msg
ccAddress: AttributeType,  -- Address (multiple allowed)
ccDate: AttributeType,   -- time (of the Msg)
Msg/From relation
fromRelation: ROPE, -- One per Msg
fromMsg: AttributeType,  -- Msg
fromAddress: AttributeType,  -- Address (multiple allowed)
fromDate: AttributeType,  -- time (of the Msg)
useful "local" items
lastMsgEntity: LoganBerry.Entry,  -- used only during expunge
activeEntity: ROPE,
deletedEntity: ROPE,
activeMsgSet: ROPE,
deletedMsgSet: ROPE,
unacceptedEntity: ROPE,
msgSetsTable: RefTab.Ref
];
cdIndex: READONLY Index;
toIndex: READONLY Index;
ccIndex: READONLY Index;
senderIndex: READONLY Index;
fromIndex: READONLY Index;
dateIndex: READONLY Index;
subjectIndex: READONLY Index;
Procedures
Initialize: PROC [opsH: WalnutOpsHandle] RETURNS[ok: BOOL];
SchemaMismatch[explanation] -- schema version mismatch
This is SIGNALed. If you RESUME the signal, the database will be erased. This is normally what you want, unless you want to preserve the database, or accidentally used the wrong version of the software.
SetSchemaVersion: PROC[opsH: WalnutOpsHandle];
this proc erases the open database, declares and sets the correct schema version stamp, and then commits the database; it catches NO errors
GetSchemaVersion: PROC[opsH: WalnutOpsHandle]
RETURNS[actual, shouldBe: BasicTime.GMT]
returns what the schema date actually is and what it should be - used by NewWalnutUser
END.