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

  1. /*
  2.  * heapam.h --
  3.  *    POSTGRES heap access method definitions.
  4.  */
  5.  
  6. #ifndef    HeapAMIncluded        /* Include this file only once */
  7. #define HeapAMIncluded    1
  8.  
  9. /*
  10.  * Identification:
  11.  */
  12. #define HEAPAM_H    "$Header: /private/postgres/src/lib/H/access/RCS/heapam.h,v 1.15 1992/05/05 18:54:59 mer Exp $"
  13.  
  14. #include <sys/types.h>
  15.  
  16. #include "tmp/postgres.h"
  17.  
  18. #include "access/att.h"
  19. #include "access/attnum.h"
  20. #include "access/htup.h"
  21. #include "access/relscan.h"
  22. #include "access/skey.h"
  23. #include "access/tqual.h"
  24. #include "access/tupdesc.h"
  25.  
  26. #include "storage/smgr.h"
  27.  
  28. #include "rules/rlock.h"
  29. #include "utils/rel.h"
  30.  
  31. /* ----------------------------------------------------------------
  32.  *        heap access method statistics
  33.  * ----------------------------------------------------------------
  34.  */
  35.  
  36. typedef struct HeapAccessStatisticsData {
  37.     time_t  init_global_timestamp;    /* time global statistics started */
  38.     time_t  local_reset_timestamp;    /* last time local reset was done */
  39.     time_t  last_request_timestamp;    /* last time stats were requested */
  40.  
  41.     int global_open;            
  42.     int global_openr;
  43.     int global_close;
  44.     int global_beginscan;
  45.     int global_rescan;
  46.     int global_endscan;
  47.     int global_getnext;
  48.     int global_fetch;
  49.     int global_insert;
  50.     int global_delete;
  51.     int global_replace; 
  52.     int global_markpos; 
  53.     int global_restrpos;
  54.     int global_BufferGetRelation;
  55.     int global_RelationIdGetRelation;
  56.     int global_RelationIdGetRelation_Buf;
  57.     int global_RelationNameGetRelation;
  58.     int global_getreldesc;
  59.     int global_heapgettup;
  60.     int global_RelationPutHeapTuple;
  61.     int global_RelationPutLongHeapTuple;
  62.  
  63.     int local_open;            
  64.     int local_openr;
  65.     int local_close;
  66.     int local_beginscan;
  67.     int local_rescan;
  68.     int local_endscan;
  69.     int local_getnext;
  70.     int local_fetch;
  71.     int local_insert;
  72.     int local_delete;
  73.     int local_replace; 
  74.     int local_markpos; 
  75.     int local_restrpos;
  76.     int local_BufferGetRelation;
  77.     int local_RelationIdGetRelation;
  78.     int local_RelationIdGetRelation_Buf;
  79.     int local_RelationNameGetRelation;
  80.     int local_getreldesc;
  81.     int local_heapgettup;
  82.     int local_RelationPutHeapTuple;
  83.     int local_RelationPutLongHeapTuple;
  84. } HeapAccessStatisticsData;
  85.  
  86. typedef HeapAccessStatisticsData *HeapAccessStatistics;
  87.  
  88. #define IncrHeapAccessStat(x) \
  89.     (heap_access_stats == NULL ? 0 : (heap_access_stats->x)++)
  90.  
  91. extern HeapAccessStatistics heap_access_stats;
  92.  
  93. /* ----------------
  94.  *    function prototypes for heap access method
  95.  * ----------------
  96.  */
  97. /* heap_create, heap_creatr, and heap_destroy are declared in catalog/heap.h */
  98. #include "lib/heap.h"
  99. extern Relation     heap_open();
  100. extern Relation     heap_openr();
  101. extern void        heap_close();
  102. extern HeapTuple    heap_fetch();
  103. extern ObjectId     heap_insert();
  104. extern RuleLock     heap_delete();
  105. extern RuleLock     heap_replace();
  106. extern char *       heap_getattr();
  107. extern HeapScanDesc     heap_beginscan();
  108. extern void         heap_rescan();
  109. extern void         heap_endscan();
  110. extern void         heap_markpos();
  111. extern void         heap_restrpos();
  112. extern HeapTuple     heap_getnext();
  113.  
  114. extern int        heap_attisnull();
  115. extern int        heap_sysattrlen();
  116. extern bool        heap_sysattrbyval();
  117. extern HeapTuple    heap_addheader();
  118. extern HeapTuple    heap_copytuple();
  119. extern HeapTuple    heap_formtuple();
  120. extern HeapTuple    heap_modifytuple();
  121.  
  122. /* ----------------
  123.  *    misc
  124.  * ----------------
  125.  */
  126. extern
  127. RuleLock
  128. doinsert ARGS((
  129.     Relation    relation,
  130.     HeapTuple    heapTuple
  131. ));
  132.  
  133. /* ----------------------------------------------------------------
  134.  *           obsolete heap access method interfaces
  135.  * ----------------------------------------------------------------
  136.  */
  137.  
  138. /*
  139.  * RelationNameCreateHeapRelation --
  140.  *    Returns relation id of a newly created cataloged heap relation.
  141.  */
  142. #define RelationNameCreateHeapRelation(relname, arch, natts, smgr, tupdesc) \
  143.     heap_create(relname, arch, natts, smgr, tupdesc)
  144.  
  145. #define amcreate(relname, arch, natts, smgr, tupdesc) \
  146.     heap_create(relname, arch, natts, smgr, tupdesc)
  147.  
  148. /*
  149.  * RelationNameCreateTemporaryRelation --
  150.  *    Creates a temporary heap relation.
  151.  */
  152. #define RelationNameCreateTemporaryRelation(relname, natts, att) \
  153.     heap_creatr(relname, natts, DEFAULT_SMGR, att)
  154.  
  155. #define amcreatr(relname, natts, smgr, att) \
  156.     heap_creatr(relname, natts, smgr, att)
  157.  
  158. /*
  159.  * RelationNameDestroyHeapRelation --
  160.  *    Destroys a heap relation.
  161.  */
  162. #define RelationNameDestroyHeapRelation(relationName) \
  163.     heap_destroy(relationName)
  164.  
  165. #define amdestroy(relationName) \
  166.     heap_destroy(relationName)
  167.  
  168. /*
  169.  * ObjectIdOpenHeapRelation --
  170.  *    Opens a heap relation by its object identifier.
  171.  */
  172. #define ObjectIdOpenHeapRelation(relationId) \
  173.     heap_open(relationId)
  174.  
  175. #define amopen(relid) \
  176.     heap_open(relid)
  177.  
  178. /*
  179.  * RelationNameOpenHeapRelation --
  180.  *    Opens a heap relation by name.
  181.  */
  182. #define RelationNameOpenHeapRelation(relationName) \
  183.     heap_openr(relationName)
  184.  
  185. #define amopenr(relationName) \
  186.     heap_openr(relationName)
  187.  
  188. /*
  189.  * RelationCloseHeapRelation --
  190.  *    Closes a heap relation.
  191.  */
  192. #define RelationCloseHeapRelation(relation) \
  193.     heap_close(relation)
  194.  
  195. #define amclose(relation) \
  196.     heap_close(relation)
  197.  
  198. /*
  199.  * RelationGetHeapTupleByItemPointer --
  200.  *    Retrieves a heap tuple by its item pointer.
  201.  */
  202. #define RelationGetHeapTupleByItemPointer(relation, timeQual, tid, b) \
  203.     heap_fetch(relation, timeQual, tid, b)
  204.  
  205. #define amgetunique(relation, timeQual, tid, b) \
  206.     heap_fetch(relation, timeQual, tid, b)
  207.  
  208. /*
  209.  * RelationInsertHeapTuple --
  210.  *    Inserts a heap tuple.
  211.  */
  212. #define RelationInsertHeapTuple(relation, heapTuple, offsetOutP) \
  213.     heap_insert(relation, heapTuple, offsetOutP)
  214.  
  215. #define aminsert(relation, heapTuple, offsetOutP) \
  216.     heap_insert(relation, heapTuple, offsetOutP)
  217.  
  218. /*
  219.  * RelationDeleteHeapTuple --
  220.  *    Deletes a heap tuple.
  221.  */
  222. #define RelationDeleteHeapTuple(relation, heapItem) \
  223.     heap_delete(relation, heapItem)
  224.  
  225. #define amdelete(relation, heapItem) \
  226.     heap_delete(relation, heapItem)
  227.  
  228. /*
  229.  * RelationReplaceHeapTuple --
  230.  *    Replaces a heap tuple.  OffsetOutP is obsolete.
  231.  */
  232. #define RelationReplaceHeapTuple(relation, heapItem, tuple, offsetOutP) \
  233.     heap_replace(relation, heapItem, tuple)
  234.  
  235. #define amreplace(relation, heapItem, tuple) \
  236.     heap_replace(relation, heapItem, tuple)
  237.  
  238. /*
  239.  * HeapTupleGetAttributeValue --
  240.  *    Returns an attribute of a heap tuple.
  241.  */
  242. #define HeapTupleGetAttributeValue(tup, b, attnum, att, isnull) \
  243.     PointerGetDatum(heap_getattr(tup, b, attnum, att, isnull))
  244.  
  245. /*
  246.  * RelationBeginHeapScan --
  247.  *    General access method initialize heap scan routine.
  248.  */
  249. #define RelationBeginHeapScan(relation, atend, timeQual, nkeys, key) \
  250.     heap_beginscan(relation, atend, timeQual, nkeys, key)
  251.  
  252. #define ambeginscan(relation, atend, timeQual, nkeys, key) \
  253.     heap_beginscan(relation, atend, timeQual, nkeys, key)
  254.  
  255. /*
  256.  * HeapScanRestart --
  257.  *    General access method restart heap scan routine.
  258.  */
  259. #define HeapScanRestart(scan, restartScanAtEnd, key) \
  260.     heap_rescan(scan, restartScanAtEnd, key)
  261.  
  262. #define amrescan(scan, restartScanAtEnd, key) \
  263.     heap_rescan(scan, restartScanAtEnd, key)
  264.  
  265. /*
  266.  * HeapScanEnd --
  267.  *    General access method end heap scan routine.
  268.  */
  269. #define HeapScanEnd(scan) \
  270.     heap_endscan(scan)
  271.  
  272. #define amendscan(scan) \
  273.     heap_endscan(scan)
  274.  
  275. /*
  276.  * HeapScanMarkPosition --
  277.  *    General access method mark heap scan position routine.
  278.  */
  279. #define HeapScanMarkPosition(scan) \
  280.     heap_markpos(scan)
  281.  
  282. #define ammarkpos(scan) \
  283.     heap_markpos(scan)
  284.  
  285. /*
  286.  * HeapScanRestorePosition --
  287.  *    General access method restore heap scan position routine.
  288.  */
  289. #define HeapScanRestorePosition(scan) \
  290.     heap_restrpos(scan)
  291.  
  292. #define amrestrpos(scan) \
  293.     heap_restrpos(scan)
  294.  
  295. /*
  296.  * HeapScanGetNextTuple --
  297.  *    General access method get heap tuple routine.
  298.  */
  299. #define HeapScanGetNextTuple(scan, backwards, bufferOutP) \
  300.     heap_getnext(scan, backwards, bufferOutP)
  301.  
  302. #define amgetnext(scan, backwards, bufferOutP) \
  303.     heap_getnext(scan, backwards, bufferOutP)
  304.  
  305. /*
  306.  * sysattrlen
  307.  */
  308. #define sysattrlen(attno) \
  309.     heap_sysattrlen(attno)
  310.  
  311. /*
  312.  * sysattrbyval
  313.  */
  314. #define sysattrbyval(attno) \
  315.     heap_sysattrbyval(attno)
  316.  
  317. /*
  318.  * amgetattr
  319.  */
  320. #define amgetattr(tup, b, attnum, att, isnull) \
  321.     heap_getattr(tup, b, attnum, att, isnull)
  322.  
  323. /*
  324.  * palloctup
  325.  */
  326. #define palloctup(tuple, buffer, relation) \
  327.     heap_copytuple(tuple, buffer, relation)
  328.  
  329. #endif    /* !defined(HeapAMIncluded) */
  330.