home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / h / access.h next >
Encoding:
C/C++ Source or Header  |  1992-09-18  |  5.0 KB  |  162 lines

  1. #
  2. /*
  3. **  ACCESS.H -- definitions relating to the access methods.
  4. **
  5. **    Version:
  6. **        @(#)access.h    8.3    5/1/86
  7. */
  8.  
  9. # ifndef PGSIZE
  10.  
  11.  
  12. /*
  13. **    PGSIZE is the physical size of a page.
  14. **    MAXTUP is the maximum size of a tuple, assuming only one
  15. **        tuple on the page.  This is PGSIZE-hdrsize, where
  16. **        hdrsize is the size of the page header (12 bytes).
  17. **    MAXLINENO is the maximum number of tuples on a page
  18. **        assuming minimum size tuples (1 byte).  This is
  19. **        constrained by the size of the lineid field of
  20. **        the tid.
  21. */
  22.  
  23. # define    PGSIZE        1024        /* size of page */
  24. # define    MAXTUP        1008        /* max size of a tuple */
  25. # define    MAXLINENO    254        /* max tuples per page */
  26. # define    PGPTRSIZ    4        /* size of a tid */
  27. # define    MAXTUPS        100        /* maximum number of tups */
  28.  
  29. /* storage structure flags; < 0 means compressed */
  30. # define    M_HEAP        5        /* paged heap */
  31. # define    M_ISAM        11        /* indexed sequential */
  32. # define    M_HASH        21        /* random hash */
  33. # define    M_BTREE        31        /* BTREES */
  34. # define    M_ORDER        41        /* ordered */
  35. # define    M_TRUNC        99        /* internal pseudo-mode: truncated */
  36.  
  37. # define    NACCBUFS    3        /* number of access method buffers */
  38.  
  39. /* error flags */
  40. # define    AMREAD_ERR    -1
  41. # define    AMWRITE_ERR    -2
  42. # define    AMNOFILE_ERR    -3    /* can't open file for a relation */
  43. # define    AMREL_ERR    -4    /* can't open relation relation */
  44. # define    AMATTR_ERR    -5    /* can't open attribute relation */
  45. # define    AMNOATTS_ERR    -6    /* attribute missing or xtra in att-rel */
  46. # define    AMCLOSE_ERR    -7    /* can't close relation */
  47. # define    AMFIND_ERR    -8    /* unidentifiable stora  Petructure in find */
  48. # define    AMINVL_ERR    -9    /* invalid TID */
  49. # define    AMOPNVIEW_ERR    -10    /* attempt to open a view for rd or wr */
  50.  
  51. /* the following is the access methods buffer */
  52. struct accbuf
  53. {
  54.     /* this stuff is actually stored in the relation */
  55.     long        mainpg;        /* next main page (0 - eof) */
  56.     long        ovflopg;    /* next ovflo page (0 - none) */
  57.     short        nxtlino;    /* next avail line no for this page */
  58.     char        firstup[PGSIZE - 12];    /* tuple space */
  59.     short        linetab[1];    /* line table at end of buffer - grows down */
  60.                     /* linetab[lineno] is offset into
  61.                     ** the buffer for that line; linetab[nxtlino]
  62.                     ** is free space pointer */
  63.  
  64.     /* this stuff is not stored in the relation */
  65.     long        rel_tupid;    /* unique relation id */
  66.     long        thispage;    /* page number of the current page */
  67.     int        filedesc;    /* file descriptor for this reln */
  68.     struct accbuf    *modf;        /* use time link list forward pointer */
  69.     struct accbuf    *modb;        /* back pointer */
  70.     int        bufstatus;    /* various bits defined below */
  71. };
  72.  
  73. /* The following assignments are status bits for accbuf.bufstatus */
  74. # define    BUF_DIRTY    001    /* page has been changed */
  75. # define    BUF_LOCKED    002    /* page has a page lock on it */
  76. # define    BUF_DIRECT    004    /* this is a page from isam direct */
  77.  
  78. /* access method buffer typed differently for various internal operations */
  79. char    acc_buf[NACCBUFS];
  80.  
  81. /* pointers to maintain the buffer */
  82. extern struct accbuf    *Acc_head;    /* head of the LRU list */
  83. extern struct accbuf    *Acc_tail;    /* tail of the LRU list */
  84. extern struct accbuf    Acc_buf[NACCBUFS];    /* the buffers themselves */
  85.  
  86.  
  87. /*
  88. **  ADMIN file struct
  89. **
  90. **    The ADMIN struct describes the initial part of the ADMIN file
  91. **    which exists in each database.  This file is used to initially
  92. **    create the database, to maintain some information about the
  93. **    database, and to access the RELATION and ATTRIBUTE relations
  94. **    on OPENR calls.
  95. */
  96.  
  97. struct adminhdr
  98. {
  99.     char    adowner[2];    /* user code of data base owner */
  100.     short    adflags;    /* database flags */
  101.     short    adlength;    /* length of adminhdr */
  102.     short    adversion;    /* database format stamp */
  103.     short    adreldsz;    /* length of relation descriptor */
  104.     short    adattdsz;    /* length of attribute descriptor */
  105. };
  106.  
  107. struct admin
  108. {
  109.     struct adminhdr        adhdr;
  110.     struct descriptor    adreld;
  111.     struct descriptor    adattd;
  112. };
  113.  
  114. /*
  115. **  Admin status bits
  116. **
  117. **    These bits define the status of the database.  They are
  118. **    contained in the adflags field of the admin struct.
  119. */
  120.  
  121. # define    A_DBCONCUR    0000001        /* set database concurrency */
  122. # define    A_QRYMOD    0000002        /* database uses query modification */
  123. # define    A_NEWFMT    0000004        /* database is post-6.2 */
  124.  
  125.  
  126. /* following is buffer space for data from admin file */
  127. extern struct admin        Admin;
  128.  
  129. /*
  130. **  PGTUPLE -- btree index key (a tid and an index key)
  131. */
  132.  
  133. struct pgtuple
  134. {
  135.     struct tup_id    childtid;        /* the pointer comes before */
  136.     char        childtup[MAXTUP];
  137. };
  138.  
  139. /*
  140. ** global counters for the number of UNIX read and write
  141. **  requests issued by the access methods.
  142. */
  143.  
  144. extern long    Accuread, Accuwrite;
  145.  
  146. /*
  147. **    Global values used by everything
  148. */
  149.  
  150. extern char    *Acctuple;        /* pointer to canonical tuple */
  151. extern        Accerror;        /* error no for fatal errors */
  152. extern char    Accanon[MAXTUP];    /* canonical tuple buffer */
  153.  
  154.  
  155. /* Macros for the return values of iutil/add_ovflo.c */
  156. # define    NOBUFFER    -1    /* can't get buffer for overflow page */
  157. # define    NOSETUP        -2    /* can't set up overflow page */
  158. # define    NOGETCURRENT    -3    /* can't get the current page */
  159. # define    NORMVMAIN    -4    /* can't remove the main page */
  160. # define    NOGETOVFLO    -5    /* can't get the overflow page */
  161. # endif PGSIZE
  162.