-- File: DBStoragePagetags.mesa
-- Last edited by:
  -- MBrown on September 26, 1980  11:30 AM
  -- Cattell on January 14, 1983 2:04 pm


DIRECTORY
  DBEnvironment USING[InternalError];


DBStoragePagetags: DEFINITIONS
 IMPORTS DBEnvironment = BEGIN

  -- This interface defines the values of the page tags found on all pages in the system.  One
  --purpose of having a uniform page tag convention is to aid the scavenger.  The page tag is stored
  --in the first byte of each page.  The other byte of the first word is uncommitted.  The PageHeader
  --declaration below is included for purposes of illustration:

  PageHeader: TYPE = MACHINE DEPENDENT RECORD[
    pageTag: CARDINAL [0..256),
    dontCare: CARDINAL [0..256)
  ];--PageHeader
    -- First word of a page.


  -- Page tag values.

  Unused: CARDINAL = 0;         -- unused page, obtained by extending Juniper file
  Free: CARDINAL = 1;           -- page on segment or local free list
  AMap: CARDINAL = 2;           -- page used to store segment address-map values
  Tuple: CARDINAL = 3;          -- page used to store tuples
  SystemTuple: CARDINAL = 4;    -- page used to store system tuples
  OverflowTuple: CARDINAL = 5;  -- page used to store overflow tuples & long strings
  BTree: CARDINAL = 6;          -- page used to store part of a B-tree

  -- in future: HashTable, BitVector, etc...


  AssertPageIsTuplePage: PROC[p: LONG POINTER] = INLINE {
    SELECT LOOPHOLE[p,LONG POINTER TO PageHeader].pageTag FROM
      Tuple => {};
    ENDCASE => ERROR DBEnvironment.InternalError; -- BadPageTag
  };--AssertPageIsTuplePage

  AssertPageIsSystemTuplePage: PROC[p: LONG POINTER] = INLINE {
    SELECT LOOPHOLE[p,LONG POINTER TO PageHeader].pageTag FROM
      SystemTuple => {};
    ENDCASE => ERROR DBEnvironment.InternalError; -- BadPageTag
  };--AssertPageIsSystemTuplePage

  AssertPageIsAnyTuplePage: PROC[p: LONG POINTER] = INLINE {
    SELECT LOOPHOLE[p,LONG POINTER TO PageHeader].pageTag FROM
      Tuple, SystemTuple => {};
    ENDCASE => ERROR DBEnvironment.InternalError; -- BadPageTag
  };--AssertPageIsAnyTuplePage

  AssertPageIsOverflowTuplePage: PROC[p: LONG POINTER] = INLINE {
    SELECT LOOPHOLE[p,LONG POINTER TO PageHeader].pageTag FROM
      OverflowTuple => {};
    ENDCASE => ERROR DBEnvironment.InternalError; -- BadPageTag
  };--AssertPageIsOverflowTuplePage


END.--DBStoragePagetags


--  Module History

Created by MBrown on February 15, 1980  11:08 AM

Changed by MBrown on July 9, 1980  9:50 PM
-- Added AssertPageIsTuplePage, AssertPageIsSystemTuplePage, AssertPageIsAnyTuplePage.

Changed by MBrown on August 13, 1980  4:51 PM
-- Added AssertPageIsOverflowTuplePage.

Changed by MBrown on September 26, 1980  11:29 AM
-- Change to new DBException.