DIRECTORY BasicTime, DB, DBStorage, DBModel, DBCommon, DBDefs, RefTab, Rope; DBModelPrivate: CEDAR DEFINITIONS = BEGIN OPEN DBCommon, DBDefs; ROPE: TYPE = Rope.ROPE; DefaultNameLength: CARDINAL = 12; OneWordDescriptor: DBStorage.FieldDescriptor = DBStorage.FieldDescriptor[OneWord[]]; TypeDescriptor: DBStorage.FieldDescriptor = DBStorage.FieldDescriptor[TwoWord[]]; NameDescriptor: DBStorage.FieldDescriptor = DBStorage.FieldDescriptor[VarByte[lengthHint: DefaultNameLength]]; TupleSetDescriptor: DBStorage.FieldDescriptor = DBStorage.FieldDescriptor[NWord[length: DBStorage.TuplesetObjectSize]]; IndexDescriptor: DBStorage.FieldDescriptor = DBStorage.FieldDescriptor[NWord[length: DBStorage.IndexObjectSize]]; HandleDescriptor: DBStorage.FieldDescriptor = DBStorage.FieldDescriptor[NWord[length: DBStorage.FieldObjectSize]]; NoTID: LONG CARDINAL = 0; -- used in tuple handles nullified by storage level DomainTSID: LONG CARDINAL = 1; RelationTSID: LONG CARDINAL = 2; IndexTSID: LONG CARDINAL = 3; IndexFactorTSID: LONG CARDINAL = 4; AttributeTSID: LONG CARDINAL = 5; SetSystemTable: PROC[tid: TID] RETURNS[tupleSet: DBStorage.SystemTuplesetHandle, tuple: TupleHandle]; IndexDomain: DBCommon.TupleHandle; IndexTupleSet: DBStorage.SystemTuplesetHandle; IndexCountField: DBStorage.FieldHandle; IndexRelationField: DBStorage.FieldHandle; IndexKeyField: DBStorage.FieldHandle; DomainDomain: DBCommon.TupleHandle; RelationDomain: DBCommon.TupleHandle; RelationTupleSet: DBStorage.SystemTuplesetHandle; DomainTupleSet: DBStorage.SystemTuplesetHandle; SegmentToHandle: PROC [segment: Segment] RETURNS [SegmentHandle]; InitializeDomainSchema: PROC[]; TupleToDomain: PROC[t: TupleHandle, segment: Segment, name: Rope.ROPE _ NIL] RETURNS[d: Domain]; CompatibleTypes: PROC[d: Domain, type: TypeCode] RETURNS[yes: BOOL]; NoSubtypes: PROC[d: Domain] RETURNS[yes: BOOL]; CheckDomainKey: PROC[d: Domain]; ReadDomain: PROC[d: Domain]; InitializeRelationSchema: PROC[]; CheckRelationKey: PROC[r: Relation]; TupleToRelation: PROC[t: TupleHandle, segment: Segment, name: Rope.ROPE _ NIL] RETURNS[r: Relation]; DestroyStoredRelations: PROC[d: Domain]; DestroySurrogates: PROC[d: Domain]; Unlink: PROC[t: TupleHandle, d: Domain]; CacheAttributes: PROC[r: Relation]; IsLegalIndex: PROC[r: Relation, index: Index, checkKeysOnly: BOOL _ FALSE] RETURNS[legal: BOOL]; DestroyRelshipTuple: PROC[t: TupleHandle, r: Relation]; InitializeIndexSchema: PROC[]; DestroyIndexTuple: PROC[handle: DBStorage.TupleHandle]; DeleteTupleFromIndex: PROC[t: TupleHandle, r: Relation, iHandle: IndexHandle]; AddTupleToIndex: PROC[t: TupleHandle, r: Relation, iHandle: IndexHandle]; CheckKeyInIndex: PROC[i: IndexHandle, key: Rope.ROPE] RETURNS [yes: BOOL]; NCode: PROC [v: Value] RETURNS [code: Rope.ROPE]; NCodeTuple: PROC[t: TupleHandle] RETURNS [code: Rope.ROPE]; NCodeRope: PROC[rope: Rope.ROPE] RETURNS [code: Rope.ROPE]; NCodeBool: PROC[bool: BOOL] RETURNS [code: Rope.ROPE]; NCodeInt: PROC[int: INT] RETURNS [code: Rope.ROPE]; NCodeTime: PROC[time: BasicTime.GMT] RETURNS [code: Rope.ROPE]; DCode: PROC[key: DBCommon.IndexKey, ropes: RopeSequence]; NameFromIndexKey: PUBLIC PROC[key: DBCommon.IndexKey] RETURNS[name: Rope.ROPE]; CacheIndices: PROC[r: Relation]; CheckForNull: PROC[t: TupleHandle]; CopyTupleHandle: PROC[t: TupleHandle] RETURNS[new: TupleHandle]; EmptyTupleSet: PROC[ts: TupleHandle] RETURNS[yes: BOOL]; GetNamedTuple: PROC[index: DBStorage.IndexHandle, name: Rope.ROPE] RETURNS[TupleHandle]; SetTupleField: PROC[t: TupleHandle, f: DBStorage.FieldHandle, val: TupleHandle]; NullifyTupleField: PROC[t: TupleHandle, f: DBStorage.FieldHandle]; GetTupleField: PROC[t: TupleHandle, f: DBStorage.FieldHandle] RETURNS[val: TupleHandle]; SetRopeField: PROC[t: TupleHandle, f: DBStorage.FieldHandle, val: Rope.ROPE]; GetRopeField: PROC[t: TupleHandle, f: DBStorage.FieldHandle] RETURNS[val: Rope.ROPE]; SetCardField: PROC[t: TupleHandle, f: DBStorage.FieldHandle, val: CARDINAL]; GetCardField: PROC[t: TupleHandle, f: DBStorage.FieldHandle] RETURNS[val: CARDINAL]; SetBoolField: PROC[t: TupleHandle, f: DBStorage.FieldHandle, val: BOOL]; GetBoolField: PROC[t: TupleHandle, f: DBStorage.FieldHandle] RETURNS[val: BOOL]; SetIntField: PROC[t: TupleHandle, f: DBStorage.FieldHandle, val: INT]; GetIntField: PROC[t: TupleHandle, f: DBStorage.FieldHandle] RETURNS[val: INT]; SetTimeField: PROC[t: TupleHandle, f: DBStorage.FieldHandle, val: BasicTime.GMT]; GetTimeField: PROC[t: TupleHandle, f: DBStorage.FieldHandle] RETURNS[val: BasicTime.GMT]; SetTypeField: PROC[t: TupleHandle, f: DBStorage.FieldHandle, val: DBDefs.TypeCode]; GetTypeField: PROC[t: TupleHandle, f: DBStorage.FieldHandle] RETURNS[val: DBDefs.TypeCode]; SetFieldField: PROC[t: TupleHandle, f: DBStorage.FieldHandle, val: DBStorage.FieldHandle]; GetFieldField: PROC[t: TupleHandle, f: DBStorage.FieldHandle] RETURNS[val: DBStorage.FieldHandle]; END. `File: DBModelPrivate.mesa Copyright c 1985 by Xerox Corporation. All rights reserved. File created by Rick Cattell, September 1980 Last edited by: Cattell on: November 8, 1983 11:10 am Willie-Sue on February 20, 1985 10:32:27 am PST Donahue, August 20, 1986 8:22:33 am PDT Widom, September 9, 1985 10:20:32 am PDT Types Global variables and constants The default descriptor for a tuple field used to hold the name of a domain, relation, etc. A field descriptor for setting the tuple set handle (first) fields of tuples that are used as tuplesets A field descriptor for setting the tuple set handle (first) fields of tuples that are used as indices A field descriptor for setting the tuple set handle (first) fields of tuples that are used as indices The tuple set ID of the DomainDomain The tuple set ID of the RelationDomain The tuple set ID of the IndexDomain The tuple set ID of the IndexFactorDomain The tuple set ID of the AttributeDomain Private Operations on Segments Maps the atom (client) representation of a segment to the internal descriptor Private Operations on Domains These operations define the interface between DBModelDomainImpl and the other pieces of DBModel  the InitializeSystemDomains operation is used by DBModelSegmentImpl and the other operations (both on domains and on entities) are used by DBModelRelationImpl Initialize the component of the Cypress database schema that is needed to interpret the operations on domains (this includes the DomainDomain and the IndexDomain). This procedure must be called before InitializeRelationSchema, since it also sets up the system tables necessary for InitializeRelationSchema! Return the domain object corresponding to the named tuple. If the name is not already known, then it will be read from the tuple Is d equivalent to or a subtype of type? I.e., can a value of the subType domain be stored in a field that has the typecode type? This is how the effects of the public operations DeclareSubType and DestroySubType can be observed TRUE iff the domain d has no subtypes Fails if the key is inconsistent with that of the segment table Ensure that all of the details of the domain are known Private Operations on Relations These operations define the interface between DBModelRelationImpl and the other pieces of DBModel  the operations on relations and relationships are the ones needed by DBModelDomainImpl and DBModelIndexImpl Return the relation object corresponding to the named tuple Return the relation object corresponding to the given tuple; if the name is not provided, then it will be read from the database Destroy all of the stored relations that contain fields of the domain type. This removes both the information in the database and also the cache entries corresponding to relations that are destroyed Destroy all of the information in the schema about surrogates for the domain For each stored relationship that contains a reference to the tuple t, destroy the relationship. For each surrogate relationship stored in t, remove t from the group for the relation (and set each of the entity- and rope-valued fields to NIL). Ensure that all of the information about the attributes of r is correct. Ensure that all of the information about the attributes of r is correct. Private Operations on Relationships Destroy the relationship pointed at by the tuple handle t from the relation r Index Maintenance Operations It is assumed that the tuple handle point to an index tuple; this also destroys all of the related index factor tuples Remove the tuple from the given index (the index handle gives the order in which the attribute values are used to compose the key for the tuple) Add the tuple to the given index (the index handle gives the order in which the attribute values are used to compose the key for the tuple) This procedure is composed from the more primitive procedures below This procedure assumes that the sequence passed in is precisely long enough to take the decoded version of the key Reads the key fields of index entries and returns them as ropes Read the database information on the indices for the given relation Operations that manipulate tuples directly Raises DBError.Nullified if the tuple has been nullified This copies the tid and cacheHint fields of a tuple into a new System Tuple (which is not touched when transactions are closed or aborted) This predicate is true iff the tuple set named by the given tid is empty Produce the tuple that in the specified index that has the given name Set the f field of t to point to the tuple val (f must refer to a DBStorage.FieldObjectSize field). val must point to a non-NIL tuple; to set a field to NIL use NullifyTupleField Κ4˜šœ™Jšœ Οmœ1™<—Jšœ,™,šœ™Jšœ&™&Jšœ/™/Icode™'Jšœ.™.J˜—šΟk ˜ Jšœ ˜ Jšžœ˜J˜ J˜J˜ J˜J˜J˜J˜—šœžœž ˜!J˜—Jšœžœžœ˜head1šœ™Jšžœžœžœ˜J˜—šœ™Jšœžœ˜!J˜JšœT˜TJ˜JšœQ˜QJ˜šœn˜nJšœZ™Z—J˜šœw˜wJšœg™g—J™šœq˜qJšœe™e—J˜šœr˜rJšœe™e—J˜JšœžœžœΟc3˜MJ˜šœ žœžœ˜Jšœ$™$—J˜šœžœžœ˜ Jšœ&™&—J˜šœ žœžœ˜Jšœ#™#—J˜šœžœžœ˜#Jšœ)™)—J˜šœžœžœ˜!Jšœ'™'—J˜JšΟnœžœžœžœ?˜eJ˜Jšœ"˜"J˜Jšœ.˜.J˜J˜'J˜J˜*J˜J˜%J˜Jšœ#˜#J˜Jšœ%˜%J˜Jšœ1˜1J˜Jšœ/˜/—™š œžœžœ˜AJ™M——™J™€J˜š œžœ˜J™³—J˜š   œžœ.žœžœžœ ˜`Jšœ™—J˜š œžœžœžœ˜DJšœζ™ζ—J˜š  œžœ žœžœ˜/J™%—J™š œžœ ˜ J™?—J˜š  œžœ ˜J™6——™J™ΟJ™š œžœ˜!Jšœ;™;—J˜Jš œžœ˜$J˜š  œžœ.žœžœžœ˜dJšœ€™€—J˜š œžœ ˜(JšœΗ™Η—J˜š œžœ ˜#JšœL™L—J˜š œžœ˜(J™τ—J˜š œžœ˜#J™H—J˜š   œžœ+žœžœžœžœ˜`J™H——™#š œžœ˜7JšœM™M——™Jš œžœ˜J˜š œžœ ˜7J™v—J˜š œžœ4˜NJ™—J˜š œžœ4˜IJ™‹—J˜Jš  œžœžœžœžœ˜JJ˜š œžœ žœ žœ˜1JšœC™C—J˜Jš  œžœžœ žœ˜;J˜Jš   œžœ žœžœ žœ˜;J˜Jš   œžœžœžœ žœ˜6J˜Jš  œžœžœžœ žœ˜3J˜Jš   œžœžœžœ žœ˜?J˜š œžœ.˜9Jšœr™r—J˜š  œžœžœžœ žœ˜OJšœ?™?—J˜š  œžœ˜ J™C——™*š  œžœ˜#J™8—J˜š œžœžœ˜@JšœŠ™Š—J˜š  œžœžœžœ˜8JšœH™H—J˜š  œžœ*žœžœ˜XJ™E—J˜š  œžœ=˜PJšœ³™³—J˜Jš œžœ+˜BJ˜Jš  œžœ+žœ˜XJ˜Jš  œžœ5žœ˜MJ˜Jš  œžœ+žœ žœ˜UJ˜Jš  œžœ0žœ˜LJ˜Jš  œžœ+žœžœ˜TJ˜Jš  œžœ0žœ˜HJ˜Jš  œžœ+žœžœ˜PJ˜Jš  œžœ0žœ˜FJ˜Jš  œžœ+žœžœ˜NJ˜Jš  œžœ:žœ˜QJ˜Jš  œžœ+žœžœ˜YJ˜Jš  œžœ6žœ ˜SJ˜Jš  œžœ+žœ žœ ˜[J˜Jš  œžœG˜ZJ˜Jš  œžœ+žœ˜bJ˜—Jšžœ˜J˜—…—\,π