NutOps.mesa
useful database utilities
Implemented by: NutOpsImpl
Created by: Donahue on: January 20, 1983 3:48 pm
last edited by: Donahue, July 12, 1983 9:21 am
Last Edited by: Willie-sue, February 22, 1983 3:44 pm
Last Edited by: Cattell, July 22, 1983 2:59 pm
DIRECTORY
DB,
ViewerClasses USING[ Viewer ],
Rope USING [ROPE];
NutOps: CEDAR DEFINITIONS =
BEGIN
OPEN DB, Rope;
**********************************************
Handy DB routines, implemented by NutOpsImpl.mesa
**********************************************
IsSystemDomain:PROC[d: Domain] RETURNS[BOOLEAN];
IsSystemRelation: PROC[r: Relation] RETURNS[BOOLEAN];
AttributesOf:
PROC[r: Relation]
RETURNS[AttributeList];
Returns list of r's attributes
FirstAttributeOf:
PROC[r: Relation]
RETURNS[Attribute];
returns AttributesOf[r].first
EntityValued:
PROC [a: Attribute]
RETURNS[
BOOL];
returns TRUE iff the value stored in attribute a should be an entity
GetUniquenessString:
PROC[a: Attribute]
RETURNS[
ROPE];
returns the uniqueness of a: Key, OptionalKey, etc., as a printable string
RSetSize:
PROC[rs: RelshipSet]
RETURNS[
INT];
returns the length of rs, and does a ReleaseRelshipSet
GetTuples:
PROC[e: Entity, a: Attribute]
RETURNS [tl:
LIST
OF Relship];
returns all the tuples that reference e via attribute a
GetRelation:
PROC[a: Attribute]
RETURNS[r: Relation];
finds a's relation
GetRefAttributes:
PROC[d: Domain]
RETURNS[al:
LIST
OF Attribute];
returns all the attributes that can reference an entity from domain d
RemoveAttribute:
PROC[a: Attribute, al: AttributeList]
RETURNS[AttributeList];
destructively removes a from al
AppendAttributes:
PROC [al1, al2: AttributeList]
RETURNS [al: AttributeList];
destructively appends al1 and al2 and returns the result
***********************************************
Opening segments and transactions for them
***********************************************
SetUpSegment:
PROC[segmentFile:
ROPE, seg:
DB.Segment, number:
NAT← 0, makeReadOnly:
BOOL←
FALSE]
RETURNS [success:
BOOL, readOnly:
BOOL];
Do: PROC[proc: PROC[ REF ANY ], clientData: REF ANY ← NIL, reTry: BOOL ← FALSE, msgViewer: ViewerClasses.Viewer ← NIL ] RETURNS [succeeded: BOOL];
Evaluates the procedure supplied in an environment where the Aborted and Failed signals
that may be raised from DB will be caught; the procedure will be retried after a restart
if reTry is TRUE (otherwise a restart will be performed on failure without retrying the proc.
Any messages produced will be printed in the msgViewer if one is supplied.
We return succeeded=TRUE iff no errors occured in executing proc.
TryRestart:
PROC[trans:
DB.Transaction];
Attempts to re-open an aborted transaction if user confirms.
AtomFromSegment: PROC[ segR: ROPE ] RETURNS[ ATOM ];
IsLocalName: PROC[ segR: ROPE ] RETURNS[ BOOL ];
END.