home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / H / nodes / relation.h < prev   
Encoding:
C/C++ Source or Header  |  1992-08-27  |  8.5 KB  |  360 lines

  1. /*
  2.  * relation.h --
  3.  *    Definitions for internal planner nodes.
  4.  *
  5.  * Identification:
  6.  *    $Header: /private/postgres/src/lib/H/nodes/RCS/relation.h,v 1.28 1992/07/12 11:00:26 joey Exp $
  7.  */
  8.  
  9. #ifndef RelationIncluded
  10. #define RelationIncluded
  11.  
  12. #include "tmp/c.h"
  13. #include "nodes/pg_lisp.h"
  14. #include "nodes/primnodes.h"
  15. #include "nodes/nodes.h"
  16.  
  17. #define TLE LispValue
  18. #define TL LispValue
  19.  
  20. #include "nodes/relation.gen"
  21.  
  22. /*
  23.  *  These #defines indicate that we have supplied print routines for the
  24.  *  named classes.  The routines are in lib/C/printfuncs.c; interface routines
  25.  *  are automatically generated from this .h file.  When time permits, this
  26.  *  system ought to be redesigned.
  27.  */
  28.  
  29. #define    PrintRelExists
  30. #define    PrintSortKeyExists
  31. #define    PrintPathExists
  32. #define    PrintIndexPathExists
  33. #define    PrintJoinPathExists
  34. #define    PrintMergePathExists
  35. #define    PrintHashPathExists
  36. #define    PrintOrderKeyExists
  37. #define    PrintJoinKeyExists
  38. #define    PrintMergeOrderExists
  39. #define    PrintCInfoExists
  40. #define    PrintJInfoExists
  41. #define PrintHInfoExists
  42. #define PrintJoinMethodExists
  43.  
  44. extern void     PrintRel();
  45. extern void    PrintSortKey();
  46. extern void    PrintPath();
  47. extern void    PrintIndexPath();
  48. extern void    PrintJoinPath();
  49. extern void    PrintMergePath();
  50. extern void    PrintHashPath();
  51. extern void    PrintOrderKey();
  52. extern void    PrintJoinKey();
  53. extern void    PrintMergeOrder();
  54. extern void    PrintCInfo();
  55. extern void    PrintJInfo();
  56. extern void     PrintHInfo();
  57. extern void     PrintJoinMethod();
  58.  
  59. /* equal funcs that exist in lib/C/equalfunc.c and aren't defined elsewhere*/
  60. #define EqualCInfoExists 1
  61. #define EqualJoinMethodExists 1
  62. #define EqualPathExists 1
  63. #define EqualIndexPathExists 1
  64. #define EqualJoinPathExists 1
  65. #define EqualMergePathExists 1
  66. #define EqualHashPathExists 1
  67. #define EqualJoinKeyExists 1
  68. #define EqualMergeOrderExists 1
  69. #define EqualHInfoExists 1
  70. #define EqualIndexScanExists 1
  71. #define EqualJInfoExists 1
  72. #define EqualEStateExists 1
  73. #define EqualHeapTupleExists 1
  74. #define EqualRelationExists 1
  75. #define EqualLispValueExists 1
  76. #define EqualIterExists 1
  77.  
  78.  
  79. /* copy funcs that exist in lib/C/copyfunc.c and aren't defined elsewhere*/
  80. #define CopyNodeExists 1
  81. #define CopyMaterialExists 1
  82. #define CopyRelExists 1
  83. #define CopySortKeyExists 1
  84. #define CopyPathExists 1
  85. #define CopyIndexPathExists 1
  86. #define CopyJoinPathExists 1
  87. #define CopyMergePathExists 1
  88. #define CopyHashPathExists 1
  89. #define CopyOrderKeyExists 1
  90. #define CopyJoinKeyExists 1
  91. #define CopyMergeOrderExists 1
  92. #define CopyCInfoExists 1
  93. #define CopyJoinMethodExists 1
  94. #define CopyHInfoExists 1
  95. #define CopyMInfoExists 1
  96. #define CopyJInfoExists 1
  97. #define CopyIterExists 1
  98.  
  99. /* out funcs from lib/C/outfuncs.c that aren't defined elsewhere */
  100. #define OutPlanInfoExists 1
  101. #define OutRelExists 1
  102. #define OutTLEExists 1
  103. #define OutTLExists 1
  104. #define OutSortKeyExists 1
  105. #define OutPathExists 1
  106. #define OutIndexPathExists 1
  107. #define OutJoinPathExists 1
  108. #define OutMergePathExists 1
  109. #define OutHashPathExists 1
  110. #define OutOrderKeyExists 1
  111. #define OutJoinKeyExists 1
  112. #define OutMergeOrderExists 1
  113. #define OutCInfoExists 1
  114. #define OutJoinMethodExists 1
  115. #define OutHInfoExists 1
  116. #define OutJInfoExists 1
  117. #define OutDatumExists 1
  118. #define OutIterExists 1
  119.  
  120.  
  121. /*
  122.  * Relid
  123.  *    List of relation identifiers (indexes into the rangetable).
  124.  */
  125.  
  126. typedef    List    Relid;
  127.  
  128. /*
  129.  * Rel
  130.  *    Per-base-relation information
  131.  *
  132.  *    Parts of this data structure are specific to various scan and join
  133.  *    mechanisms.  It didn't seem worth creating new node types for them.
  134.  *
  135.  *    relids - List of relation indentifiers
  136.  *    indexed - true if the relation has secondary indices
  137.  *    pages - number of pages in the relation
  138.  *    tuples - number of tuples in the relation
  139.  *    size - number of tuples in the relation after restrictions clauses
  140.  *           have been applied
  141.  *    width - number of bytes per tuple in the relation after the
  142.  *        appropriate projections have been done
  143.  *    targetlist - List of TargetList nodes
  144.  *    pathlist - List of Path nodes, one for each possible method of
  145.  *           generating the relation
  146.  *    unorderedpath - a Path node generating this relation whose resulting
  147.  *            tuples are unordered (this isn't necessarily a
  148.  *            sequential scan path, e.g., scanning with a hash index
  149.  *            leaves the tuples unordered)
  150.  *    cheapestpath -  least expensive Path (regardless of final order)
  151.  *
  152.  *   * If the relation is a (secondary) index it will have the following
  153.  *    three fields:
  154.  *
  155.  *    class - List of PG_AMOPCLASS OIDs for the index
  156.  *    indexkeys - List of base-relation attribute numbers that are index keys
  157.  *    ordering - List of PG_OPERATOR OIDs which order the indexscan result
  158.  *
  159.  *   * The presence of the remaining fields depends on the restrictions
  160.  *    and joins which the relation participates in:
  161.  *
  162.  *    clauseinfo - List of ClauseInfo nodes, containing info about each
  163.  *             qualification clause in which this relation participates
  164.  *    joininfo  - List of JoinInfo nodes, containing info about each join
  165.  *            clause in which this relation participates
  166.  *    innerjoin - List of Path nodes that represent indices that may be used
  167.  *            as inner paths of nestloop joins
  168.  */
  169.  
  170. /* hack */
  171.  
  172. /* the following typedef's were added and 
  173.  * 'struct Blah *blah' replaced with 'BlahPtr blah' in the #define's.  
  174.  * the reason?  sprite cannot handle 'struct Blah *blah'.         
  175.  * - ron 'blah blah' choi
  176.  */
  177. typedef struct Path *PathPtr;
  178.  
  179. class (Rel) public (Node) {
  180.     inherits0(Node);
  181.   /* all relations: */
  182.     Relid    relids;
  183.   /* catalog statistics information */
  184.     bool    indexed;
  185.     Count    pages;
  186.     Count    tuples;
  187.     Count    size;
  188.     Count    width;
  189.   /* materialization information */
  190.     List    targetlist;
  191.     List    pathlist;
  192.     PathPtr    unorderedpath;
  193.     PathPtr    cheapestpath;
  194.   /* used solely by indices: */
  195.     List    classlist;
  196.     List    indexkeys;
  197.     oid    indproc;
  198.   /* used by various scans and joins: */
  199.     List    ordering;
  200.     List    clauseinfo;
  201.     List    joininfo;
  202.     List    innerjoin;
  203.     List    superrels;
  204. };
  205. #undef Path
  206.  
  207. extern Var get_expr ARGS(( TLE foo));
  208. extern Resdom get_resdom ARGS(( TLE foo));
  209. extern TLE get_entry  ARGS(( TL foo));
  210. extern List get_joinlist ARGS(( TL foo));
  211.  
  212. class (SortKey) public (Node) {
  213.     inherits0(Node);
  214.     List        varkeys;
  215.     List        sortkeys;
  216.     Relid        relid;
  217.     List        sortorder;
  218. };
  219.  
  220.  
  221.  
  222. class (Path) public (Node) {
  223. #define    PathDefs \
  224.     inherits0(Node); \
  225.     int32        pathtype; \
  226.     Rel        parent; \
  227.     Cost        path_cost; \
  228.     List        p_ordering; \
  229.     List        keys; \
  230.     SortKey        pathsortkey; \
  231.     Cost        outerjoincost; \
  232.     Relid        joinid; \
  233.     List            locclauseinfo
  234. /* private: */
  235.     PathDefs;
  236.  /* public: */
  237. };
  238.  
  239.  
  240. class (IndexPath) public (Path) {
  241.     inherits1(Path);
  242.  /* private: */
  243.     List        indexid;
  244.     List        indexqual;
  245.  /* public: */
  246. };
  247.  
  248. /* the following typedef's were added and 
  249.  * 'struct Blah *blah' replaced with 'BlahPtr blah' in the #define's.  
  250.  * the reason?  sprite cannot handle 'struct Blah *blah'.         
  251.  * - ron 'blah blah' choi
  252.  */
  253. typedef struct path *pathPtr;
  254.  
  255. class (JoinPath) public (Path) {
  256. #define JoinPathDefs \
  257.     inherits1(Path); \
  258.     List        pathclauseinfo; \
  259.     pathPtr    outerjoinpath; \
  260.     pathPtr    innerjoinpath
  261.  /* private: */
  262.     JoinPathDefs;
  263.  /* public: */
  264. };
  265.  
  266. class (MergePath) public (JoinPath) {
  267.     inherits2(JoinPath);
  268.  /* private: */
  269.     List        path_mergeclauses;
  270.     List        outersortkeys;
  271.     List        innersortkeys;
  272.  /* public: */
  273. };
  274.  
  275. class (HashPath) public (JoinPath) {
  276.     inherits2(JoinPath);
  277.  /* private: */
  278.     List        path_hashclauses;
  279.     List        outerhashkeys;
  280.     List        innerhashkeys;
  281.  /* public: */
  282. };
  283.  
  284. /******
  285.  * Keys
  286.  ******/
  287.  
  288. class (OrderKey) public (Node) {
  289.     inherits0(Node);
  290.     int     attribute_number;
  291.     Index    array_index;
  292. };
  293.  
  294. class (JoinKey) public (Node) {
  295.     inherits0(Node);
  296.     LispValue outer;
  297.     LispValue  inner;
  298. };
  299.  
  300. class (MergeOrder) public (Node) {
  301.     inherits0(Node);
  302.     ObjectId join_operator;
  303.     ObjectId left_operator;
  304.     ObjectId right_operator;
  305.     ObjectId left_type;
  306.     ObjectId right_type;
  307. };
  308.  
  309. /*******
  310.  * clause info
  311.  *******/
  312.  
  313. class (CInfo) public (Node) {
  314.     inherits0(Node);
  315.     LispValue    clause;
  316.     Cost        selectivity;
  317.     bool        notclause;
  318.     List        indexids;
  319. /* mergesort only */
  320.     MergeOrder    mergesortorder;
  321. /* hashjoin only */
  322.     ObjectId    hashjoinoperator;
  323.     Relid        cinfojoinid;
  324. };
  325.  
  326. class (JoinMethod) public (Node) {
  327. #define JoinMethodDefs \
  328.     inherits0(Node); \
  329.     List            jmkeys; \
  330.     List            clauses
  331.  /* private: */
  332.     JoinMethodDefs;
  333.  /* public: */
  334. };
  335.  
  336. class (HInfo) public (JoinMethod) {
  337.     inherits1(JoinMethod);
  338.     ObjectId        hashop;
  339. };
  340.  
  341. class (MInfo) public (JoinMethod) {
  342.     inherits1(JoinMethod);
  343.     MergeOrder         m_ordering;
  344. };
  345.  
  346. class (JInfo) public (Node) {
  347.     inherits0(Node);
  348.     List        otherrels;
  349.     List        jinfoclauseinfo;
  350.     bool        mergesortable;
  351.     bool        hashjoinable;
  352.     bool        inactive;
  353. };
  354.  
  355. class (Iter) public (Node) {
  356.         inherits0(Node);
  357.     LispValue            iterexpr;
  358. };
  359. #endif /* RelationIncluded */
  360.