home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / access / amutil.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  1.5 KB  |  70 lines

  1. /*
  2.  *  amutil.h -- utility headers for rtree code
  3.  *
  4.  *    $Header: /private/postgres/src/lib/H/access/RCS/amutil.h,v 1.6 1992/03/05 00:39:41 hong Exp $
  5.  */
  6.  
  7. /* DISK I/O IS ALL DONE FROM BUFMGR.C */
  8.  
  9.  
  10. #include "storage/bufmgr.h"
  11. #include "storage/itemptr.h"
  12.  
  13. /* utilities for writing and retrieving data from postgres buffers */
  14.  
  15. /*#define  GET_HEAP_TID(ITUP)        (&(ITUP)->t_tid)*/
  16. /*ItemPointerData   temp2 = {3,56,456}*/
  17. #define  GET_HEAP_TID(ITUP)        (temp2)
  18.  
  19.  
  20.     
  21. #define FillTid(itup, tid)    ItemPointerCopy(tid, &(itup)->t_tid)
  22.  
  23. /*---------------------*/
  24.  
  25. struct nodetid {
  26.     int    blocknum,
  27.         pageoff;
  28.     };
  29.  
  30. typedef    struct nodetid    NodeTid;
  31.  
  32. struct    logical_page_struct{    /* the info. that getting a page returns */
  33.     NodeTid    tid;
  34.     char   *bs;
  35.     int        pinned;
  36.     int        locked;
  37.     char    *pt;    /* pointer to start of page if pinned */
  38.     };
  39.  
  40. typedef struct logical_page_struct    *LPage;
  41.  
  42. char    *LPage_Pin_Data();
  43. void     LPage_UnPin_Data();
  44.  
  45. #define    PIN_PAGE_DATA(page)        (LPage_Pin_Data(page))
  46. #define    UNPIN_PAGE_DATA(page)        (LPage_UnPin_Data(page))
  47. #define    PAGE_TID(page)        ((page)->tid)
  48.  
  49. typedef    int    freespace; /* the offset to start of freespace in a buffer, */
  50.                     /* stored at the head of the buffer.    */
  51.  
  52. /* Definition of the root nodetid of a tree */
  53. static    NodeTid    Root_Tid = {0, sizeof(freespace)};
  54.  
  55. #define    ROOT_TID    Root_Tid
  56.  
  57. #define ABOVEROOT    ((int)0x00ffffff)
  58.  
  59.  
  60. #define ABOVE_ROOT(tid)    (tid.pageoff == ABOVEROOT)
  61.  
  62. #define    max(a,b)    ((a) < (b) ? (b) : (a))
  63. #define    min(a,b)    ((b) < (a) ? (b) : (a))
  64.  
  65.     
  66. LPage GetPage();
  67. LPage GetNewPage();
  68. void FlushBuffers();
  69. void InitBuffers();
  70.