home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre4.z / postgre4 / src / lib / C / outfuncs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-27  |  32.4 KB  |  1,595 lines

  1. /*
  2.  * FILE: outfuncs.c
  3.  *
  4.  * $Header: /private/postgres/src/lib/C/RCS/outfuncs.c,v 1.18 1992/07/26 17:08:41 mer Exp $
  5.  *
  6.  * Every node in POSTGRES has an "out" routine associated with it which knows
  7.  * how to create its "ascii" representation. This ascii representation can
  8.  * be used to either print the node (for debugging purposes) or to store it
  9.  * as a string (like the tuple-level rule system does).
  10.  *
  11.  * NOTE: these functions return nothing (i.e. they are declared as "void")
  12.  * but they update the in/out argument of type StringInfo passed to them.
  13.  * This argument contains the string holding the ASCII representation plus
  14.  * some other information (string length, etc.)
  15.  * 
  16.  */
  17. #include <stdio.h>
  18. #include "tmp/postgres.h"
  19.  
  20. RcsId("$Header: /private/postgres/src/lib/C/RCS/outfuncs.c,v 1.18 1992/07/26 17:08:41 mer Exp $");
  21.  
  22. #include "access/heapam.h"
  23. #include "access/htup.h"
  24. #include "catalog/syscache.h"
  25. #include "utils/fmgr.h"
  26. #include "utils/log.h"
  27.  
  28. #include "nodes/nodes.h"
  29. #include "nodes/execnodes.h"
  30. #include "nodes/pg_lisp.h"
  31. #include "nodes/plannodes.h"
  32. #include "nodes/primnodes.h"
  33. #include "nodes/relation.h"
  34.  
  35. #include "catalog/pg_type.h"
  36. #include "tmp/stringinfo.h"
  37.  
  38. void _outDatum();
  39.  
  40. /*
  41.  * print the basic stuff of all nodes that inherit from Plan
  42.  */
  43. void
  44. _outPlanInfo(str, node)
  45.     StringInfo str;
  46.     Plan node;
  47. {
  48.     char buf[500];
  49.  
  50.     sprintf(buf, " :cost %g", node->cost );
  51.     appendStringInfo(str,buf);
  52.     sprintf(buf, " :size %d", node->plan_size);
  53.     appendStringInfo(str,buf);
  54.     sprintf(buf, " :width %d", node->plan_width);
  55.     appendStringInfo(str,buf);
  56.     sprintf(buf, " :fragment %d", node->fragment);
  57.     appendStringInfo(str,buf);
  58.     sprintf(buf, " :parallel %d", node->parallel);
  59.     appendStringInfo(str,buf);
  60.     sprintf(buf, " :state %s", (node->state == (struct EState *) NULL ?
  61.                 "nil" : "non-NIL"));
  62.     appendStringInfo(str,buf);
  63.     sprintf(buf, " :qptargetlist ");
  64.     appendStringInfo(str,buf);
  65.     _outLispValue(str, node->qptargetlist);
  66.     sprintf(buf, " :qpqual ");
  67.     appendStringInfo(str,buf);
  68.     _outLispValue(str, node->qpqual);
  69.     sprintf(buf, " :lefttree ");
  70.     appendStringInfo(str,buf);
  71.     _outLispValue(str, (LispValue)(node->lefttree));
  72.     sprintf(buf, " :righttree ");
  73.     appendStringInfo(str,buf); 
  74.     _outLispValue(str, (LispValue)(node->righttree));
  75.  
  76. }
  77.  
  78. /*
  79.  *  Stuff from plannodes.h
  80.  */
  81. void
  82. _outPlan(str, node)
  83.     StringInfo str;
  84.     Plan node;
  85. {
  86.     char buf[500];
  87.  
  88.     sprintf(buf, "plan");
  89.     appendStringInfo(str,buf);
  90.     _outPlanInfo(str, (Plan) node);
  91.  
  92. }
  93.  
  94. void
  95. _outFragment(str, node)
  96.     StringInfo str;
  97.     Fragment node;
  98. {
  99.     char buf[500];
  100.  
  101.     sprintf(buf, "fragment");
  102.     appendStringInfo(str,buf);
  103.     sprintf(buf, " :frag_root ");
  104.     appendStringInfo(str,buf);
  105.     _outLispValue(str, (LispValue)(node->frag_root));
  106.     sprintf(buf, " :frag_parallel %d", node->frag_parallel);
  107.     appendStringInfo(str,buf);
  108.     sprintf(buf, " :frag_subtrees ");
  109.     appendStringInfo(str,buf);
  110.     _outLispValue(str, (LispValue)(node->frag_subtrees));
  111.  
  112. }
  113.  
  114. void
  115. _outResult(str, node)
  116.     StringInfo str;
  117.     Result    node;
  118. {
  119.     char buf[500];
  120.  
  121.     sprintf(buf, "result");
  122.     appendStringInfo(str,buf);
  123.     _outPlanInfo(str, (Plan) node);
  124.  
  125.     sprintf(buf, " :resrellevelqual ");
  126.     appendStringInfo(str,buf);
  127.     _outLispValue(str, node->resrellevelqual);
  128.     sprintf(buf, " :resconstantqual ");
  129.     appendStringInfo(str,buf);
  130.     _outLispValue(str, node->resconstantqual);
  131.  
  132. }
  133.  
  134. /*
  135.  *  Existential is a subclass of Plan.
  136.  */
  137.  
  138. void
  139. _outExistential(str, node)
  140.     StringInfo str;
  141.     Existential    node;
  142. {
  143.     char buf[500];
  144.  
  145.     sprintf(buf, "existential");
  146.     appendStringInfo(str,buf);
  147.     _outPlanInfo(str, (Plan) node);
  148.  
  149.  
  150. }
  151.  
  152. /*
  153.  *  Append is a subclass of Plan.
  154.  */
  155.  
  156. _outAppend(str, node)
  157.     StringInfo str;
  158.     Append    node;
  159. {
  160.     char buf[500];
  161.  
  162.     sprintf(buf, "append");
  163.     appendStringInfo(str,buf);
  164.     _outPlanInfo(str, (Plan) node);
  165.  
  166.     sprintf(buf, " :unionplans ");
  167.     appendStringInfo(str,buf);
  168.     _outLispValue(str, node->unionplans);
  169.  
  170.     sprintf(buf, " :unionrelid %d", node->unionrelid);
  171.     appendStringInfo(str,buf);
  172.  
  173.     sprintf(buf, " :unionrtentries ");
  174.     appendStringInfo(str,buf);
  175.     _outLispValue(str, node->unionrtentries);
  176.  
  177. }
  178.  
  179. /*
  180.  *  JoinRuleInfo is a subclass of Node
  181.  */
  182. void
  183. _outJoinRuleInfo(str, node)
  184.     StringInfo str;
  185.     JoinRuleInfo node;
  186. {
  187.     char buf[500];
  188.  
  189.     char *s;
  190.  
  191.     sprintf(buf, "joinruleinfo");
  192.     appendStringInfo(str,buf);
  193.     sprintf(buf, " :operator %ld", node->jri_operator);
  194.     appendStringInfo(str,buf);
  195.     sprintf(buf, " :inattrno %hd", node->jri_inattrno);
  196.     appendStringInfo(str,buf);
  197.     sprintf(buf, " :outattrno %hd", node->jri_outattrno);
  198.     appendStringInfo(str,buf);
  199.     /*
  200.      * Note: we print the rule lock inside double quotes, so
  201.      * that is is easier to read it back...
  202.      */
  203.     s = RuleLockToString(node->jri_lock);
  204.     sprintf(buf, " :lock \"%s\"", s);
  205.     appendStringInfo(str,buf);
  206.     sprintf(buf, " :ruleid %ld", node->jri_ruleid);
  207.     appendStringInfo(str,buf);
  208.     sprintf(buf, " :stubid %d", node->jri_stubid);
  209.     appendStringInfo(str,buf);
  210.  
  211.     /*
  212.      * NOTE: node->stub is only used temprarily, so its
  213.      * actual value is of no interest. We only print it
  214.      * for debugging purposes.
  215.      */
  216.     sprintf(buf, " :stub 0x%xd", node->jri_stub);
  217.     appendStringInfo(str,buf);
  218.  
  219. }
  220.  
  221.  
  222.  
  223. /*
  224.  *  Join is a subclass of Plan
  225.  */
  226.  
  227. void
  228. _outJoin(str, node)
  229.     StringInfo str;
  230.     Join    node;
  231. {
  232.     char buf[500];
  233.  
  234.     sprintf(buf, "join");
  235.     appendStringInfo(str,buf);
  236.     _outPlanInfo(str, (Plan) node);
  237.  
  238.     sprintf(buf, " :ruleinfo ");
  239.     appendStringInfo(str,buf);
  240.     _outLispValue(str, (LispValue)(node->ruleinfo));
  241.  
  242.  
  243. }
  244.  
  245. /*
  246.  *  NestLoop is a subclass of Join
  247.  */
  248.  
  249. void
  250. _outNestLoop(str, node)
  251.     StringInfo str;
  252.     NestLoop    node;
  253. {
  254.     char buf[500];
  255.  
  256.     sprintf(buf, "nestloop");
  257.     appendStringInfo(str,buf);
  258.     _outPlanInfo(str, (Plan) node);
  259.  
  260.     sprintf(buf, " :ruleinfo ");
  261.     appendStringInfo(str,buf);
  262.     _outLispValue(str, (LispValue)(node->ruleinfo));
  263.  
  264. }
  265.  
  266. /*
  267.  *  MergeJoin is a subclass of Join
  268.  */
  269.  
  270. void
  271. _outMergeJoin(str, node)
  272.     StringInfo str;
  273.     MergeJoin    node;
  274. {
  275.     char buf[500];
  276.     LispValue x;
  277.  
  278.     sprintf(buf, "mergejoin");
  279.     appendStringInfo(str,buf);
  280.     _outPlanInfo(str, (Plan) node);
  281.  
  282.     sprintf(buf, " :ruleinfo ");
  283.     appendStringInfo(str,buf);
  284.     _outLispValue(str, (LispValue)(node->ruleinfo));
  285.  
  286.     sprintf(buf, " :mergeclauses ");
  287.     appendStringInfo(str,buf);
  288.     _outLispValue(str, (LispValue)(node->mergeclauses));
  289.  
  290.     sprintf(buf, " :mergesortop %ld", node->mergesortop);
  291.     appendStringInfo(str,buf);
  292.  
  293.     sprintf(buf, " :mergerightorder (");
  294.     appendStringInfo(str, buf);
  295.     foreach (x, node->mergerightorder) {
  296.         sprintf(buf, "%ld ", CAR(x));
  297.         appendStringInfo(str, buf);
  298.       } 
  299.     sprintf(buf, ")");
  300.     appendStringInfo(str, buf);
  301.  
  302.     sprintf(buf, " :mergeleftorder (");
  303.     appendStringInfo(str, buf);
  304.     foreach (x, node->mergeleftorder) {
  305.         sprintf(buf, "%ld ", CAR(x));
  306.         appendStringInfo(str, buf);
  307.       } 
  308.     sprintf(buf, ")");
  309.     appendStringInfo(str, buf);
  310.  
  311. }
  312.  
  313. /*
  314.  *  HashJoin is a subclass of Join.
  315.  */
  316.  
  317. void
  318. _outHashJoin(str, node)
  319.     StringInfo str;
  320.     HashJoin    node;
  321. {
  322.     char buf[500];
  323.  
  324.     sprintf(buf, "hashjoin");
  325.     appendStringInfo(str,buf);
  326.     _outPlanInfo(str, (Plan) node);
  327.  
  328.     sprintf(buf, " :ruleinfo ");
  329.     appendStringInfo(str,buf);
  330.     _outLispValue(str, (LispValue)(node->ruleinfo));
  331.  
  332.     sprintf(buf, " :hashclauses ");
  333.     appendStringInfo(str,buf);
  334.     _outLispValue(str, (LispValue)(node->hashclauses));
  335.  
  336.     sprintf(buf, " :hashjoinop %d",node->hashjoinop);
  337.     appendStringInfo(str,buf);
  338.     sprintf(buf, " :hashjointable 0x%x", node->hashjointable);
  339.     appendStringInfo(str,buf);
  340.     sprintf(buf, " :hashjointablekey %d", node->hashjointablekey);
  341.     appendStringInfo(str,buf);
  342.     sprintf(buf, " :hashjointablesize %d", node->hashjointablesize);
  343.     appendStringInfo(str,buf);
  344.     sprintf(buf, " :hashdone %d", node->hashdone);
  345.     appendStringInfo(str,buf);
  346.  
  347.  
  348. }
  349.  
  350. /*
  351.  *  Scan is a subclass of Node
  352.  */
  353.  
  354. void
  355. _outScan(str, node)
  356.     StringInfo str;
  357.     Scan    node;
  358. {
  359.     char buf[500];
  360.  
  361.     sprintf(buf, "scan");
  362.     appendStringInfo(str,buf);
  363.     _outPlanInfo(str, (Plan) node);
  364.  
  365.     sprintf(buf, " :scanrelid %d", node->scanrelid);
  366.     appendStringInfo(str,buf);
  367.  
  368. }
  369.  
  370. void
  371. _outScanTemps(str, node)
  372.     StringInfo str;
  373.     ScanTemps node;
  374. {
  375.     char buf[500];
  376.  
  377.     sprintf(buf, "scantemp");
  378.     appendStringInfo(str,buf);
  379.     sprintf(buf, " :temprelDesc ");
  380.     appendStringInfo(str,buf);
  381.     _outLispValue(str, (LispValue)(node->temprelDescs));
  382.  
  383. }
  384.  
  385. /*
  386.  *  SeqScan is a subclass of Scan
  387.  */
  388.  
  389. void
  390. _outSeqScan(str, node)
  391.     StringInfo str;
  392.     SeqScan    node;
  393. {
  394.     char buf[500];
  395.  
  396.     sprintf(buf, "seqscan");
  397.     appendStringInfo(str,buf);
  398.     _outPlanInfo(str, (Plan) node);
  399.  
  400.     sprintf(buf, " :scanrelid %d", node->scanrelid);
  401.     appendStringInfo(str,buf);
  402.     
  403.  
  404. }
  405.  
  406. /*
  407.  *  IndexScan is a subclass of Scan
  408.  */
  409.  
  410. void
  411. _outIndexScan(str, node)
  412.     StringInfo str;
  413.     IndexScan    node;
  414. {
  415.     char buf[500];
  416.  
  417.     sprintf(buf, "indexscan");
  418.     appendStringInfo(str,buf);
  419.     _outPlanInfo(str, (Plan) node);
  420.  
  421.     sprintf(buf, " :scanrelid %d", node->scanrelid);
  422.     appendStringInfo(str,buf);
  423.  
  424.     sprintf(buf, " :indxid ");
  425.     appendStringInfo(str,buf);
  426.     _outLispValue(str, node->indxid);
  427.  
  428.     sprintf(buf, " :indxqual ");
  429.     appendStringInfo(str,buf);
  430.     _outLispValue(str, node->indxqual);
  431.  
  432. }
  433.  
  434. /*
  435.  *  Temp is a subclass of Plan
  436.  */
  437.  
  438. void
  439. _outTemp(str, node)
  440.     StringInfo str;
  441.     Temp    node;
  442. {
  443.     char buf[500];
  444.  
  445.     sprintf(buf, "temp");
  446.     appendStringInfo(str,buf);
  447.     _outPlanInfo(str, (Plan) node);
  448.  
  449.     sprintf(buf, " :tempid %ld", node->tempid);
  450.     appendStringInfo(str,buf);
  451.     sprintf(buf, " :keycount %d", node->keycount);
  452.     appendStringInfo(str,buf);
  453.  
  454. }
  455.  
  456. /*
  457.  *  Sort is a subclass of Temp
  458.  */
  459. void
  460. _outSort(str, node)
  461.     StringInfo str;
  462.     Sort    node;
  463. {
  464.     char buf[500];
  465.  
  466.     sprintf(buf, "sort");
  467.     appendStringInfo(str,buf);
  468.     _outPlanInfo(str, (Plan) node);
  469.  
  470.     sprintf(buf, " :tempid %ld", node->tempid);
  471.     appendStringInfo(str,buf);
  472.     sprintf(buf, " :keycount %d", node->keycount);
  473.     appendStringInfo(str,buf);
  474.  
  475. }
  476.  
  477. void
  478. _outAgg(str, node)
  479.     StringInfo str;
  480.     Agg node;
  481. {
  482.     char buf[500];
  483.     sprintf(buf, "agg");
  484.     appendStringInfo(str,buf);
  485.     _outPlanInfo(str,(Plan)node);
  486.  
  487.     sprintf(buf, " :tempid %ld", node->tempid);
  488.     appendStringInfo(str, buf);
  489.     sprintf(buf, " :keycount %d", node->keycount);
  490.     appendStringInfo(str,buf);
  491. }
  492.  
  493.  
  494. /*
  495.  *  For some reason, unique is a subclass of Temp.
  496.  */
  497.  
  498. void
  499. _outUnique(str, node)
  500.     StringInfo str;
  501.     Unique node;
  502. {
  503.     char buf[500];
  504.  
  505.         sprintf(buf, "unique");
  506.     appendStringInfo(str,buf);
  507.     _outPlanInfo(str, (Plan) node);
  508.  
  509.     sprintf(buf, " :tempid %ld", node->tempid);
  510.     appendStringInfo(str,buf);
  511.     sprintf(buf, " :keycount %d", node->keycount);
  512.     appendStringInfo(str,buf);
  513.  
  514. }
  515.  
  516.  
  517. /*
  518.  *  Hash is a subclass of Temp
  519.  */
  520.  
  521. void
  522. _outHash(str, node)
  523.     StringInfo str;
  524.     Hash    node;
  525. {
  526.     char buf[500];
  527.  
  528.     sprintf(buf, "hash");
  529.     appendStringInfo(str,buf);
  530.     _outPlanInfo(str, (Plan) node);
  531.  
  532.     sprintf(buf, " :hashkey ");
  533.     appendStringInfo(str,buf);
  534.     _outLispValue(str, (LispValue)(node->hashkey));
  535.  
  536.     sprintf(buf, " :hashtable 0x%x", node->hashtable);
  537.     appendStringInfo(str,buf);
  538.     sprintf(buf, " :hashtablekey %d", node->hashtablekey);
  539.     appendStringInfo(str,buf);
  540.     sprintf(buf, " :hashtablesize %d", node->hashtablesize);
  541.     appendStringInfo(str,buf);
  542.  
  543.  
  544. }
  545. /*
  546.  *  Stuff from primnodes.h.
  547. */
  548.  
  549. /*
  550.  *  Resdom is a subclass of Node
  551.  */
  552.  
  553. void
  554. _outResdom(str, node)
  555.     StringInfo str;
  556.     Resdom    node;
  557. {
  558.     char buf[500];
  559.  
  560.     sprintf(buf, "resdom");
  561.     appendStringInfo(str,buf);
  562.     sprintf(buf, " :resno %hd", node->resno);
  563.     appendStringInfo(str,buf);
  564.     sprintf(buf, " :restype %ld", node->restype);
  565.     appendStringInfo(str,buf);
  566.     sprintf(buf, " :rescomplex %s", 
  567.         (node->rescomplex ? "true" : "nil"));
  568.     appendStringInfo(str,buf);
  569.     sprintf(buf, " :reslen %d", node->reslen);
  570.     appendStringInfo(str,buf);
  571.     sprintf(buf, " :resname \"%s\"",
  572.            ((node->resname) ? ((char *) node->resname) : "null"));
  573.     appendStringInfo(str,buf);
  574.     sprintf(buf, " :reskey %d", node->reskey);
  575.     appendStringInfo(str,buf);
  576.     sprintf(buf, " :reskeyop %ld", (long int) node->reskeyop);
  577.     appendStringInfo(str,buf);
  578.     sprintf(buf, " :resjunk %d", node->resjunk);
  579.     appendStringInfo(str,buf);
  580.  
  581. }
  582.  
  583. void
  584. _outFjoin(str, node)
  585.     StringInfo str;
  586.     Fjoin    node;
  587. {
  588.     char buf[500];
  589.     char *s;
  590.     int i;
  591.  
  592.     sprintf(buf, "fjoin");
  593.     appendStringInfo(str,buf);
  594.     sprintf(buf, " :initialized %s", node->fj_initialized ? "true":"nil");
  595.     appendStringInfo(str,buf);
  596.     sprintf(buf, " :nNodes %d", node->fj_nNodes);
  597.     appendStringInfo(str,buf);
  598.     s = lispOut(node->fj_innerNode);
  599.     appendStringInfo(str," :innerNode ");
  600.     appendStringInfo(str,s);
  601.     pfree(s);
  602.     /* balance the extra ( */
  603.     appendStringInfo( str, ") :alwaysdone (" ); /* balance the extra ) */
  604.     for (i = 0; i++; i<node->fj_nNodes)
  605.     {
  606.         sprintf(buf, " %s ", ((node->fj_alwaysDone[i]) ? "true" : "nil"));
  607.         appendStringInfo(str, buf);
  608.     }
  609.     /* balance the extra ( */
  610.     appendStringInfo(str,")");
  611. }
  612. /*
  613.  *  Expr is a subclass of Node
  614.  */
  615.  
  616. void
  617. _outExpr(str, node)
  618.     StringInfo str;
  619.     Expr    node;
  620. {
  621.     char buf[500];
  622.  
  623.     sprintf(buf, "expr)");
  624.     appendStringInfo(str,buf);
  625.  
  626. }
  627.  
  628. /*
  629.  *  Var is a subclass of Expr
  630.  */
  631.  
  632. void
  633. _outVar(str, node)
  634.     StringInfo str;
  635.     Var node;
  636. {
  637.     char buf[500];
  638.  
  639.     sprintf(buf, "var");
  640.     appendStringInfo(str,buf);
  641.     sprintf(buf, " :varno %d", node->varno);
  642.     appendStringInfo(str,buf);
  643.     sprintf(buf, " :varattno %hd", node->varattno);
  644.     appendStringInfo(str,buf);
  645.     sprintf(buf, " :vartype %ld", node->vartype);
  646.     appendStringInfo(str,buf);
  647.     sprintf(buf, " :varid ");
  648.     appendStringInfo(str,buf);
  649.  
  650.     _outLispValue(str, node->varid);
  651. }
  652.  
  653. /*
  654.  *  Const is a subclass of Expr
  655.  */
  656.  
  657. void
  658. _outConst(str, node)
  659.     StringInfo str;
  660.     Const    node;
  661. {
  662.     char buf[500];
  663.  
  664.     sprintf(buf, "const");
  665.     appendStringInfo(str,buf);
  666.     sprintf(buf, " :consttype %ld", node->consttype);
  667.     appendStringInfo(str,buf);
  668.     sprintf(buf, " :constlen %hd", node->constlen);
  669.     appendStringInfo(str,buf);
  670.     sprintf(buf, " :constisnull %s", (node->constisnull ? "true" : "nil"));
  671.     appendStringInfo(str,buf);
  672.     sprintf(buf, " :constvalue ");
  673.     appendStringInfo(str,buf);
  674.     if (node->constisnull) {
  675.         sprintf(buf, "NIL ");
  676.         appendStringInfo(str,buf);
  677.     } else {
  678.         _outDatum(str, node->constvalue, node->consttype);
  679.     }
  680.     sprintf(buf, " :constbyval %s", (node->constbyval ? "true" : "nil"));
  681.     appendStringInfo(str,buf);
  682.  
  683. }
  684.  
  685. /*
  686.  *  Array is a subclass of Expr
  687.  */
  688.  
  689. void
  690. _outArray(str, node)
  691.     StringInfo str;
  692.     Array    node;
  693. {
  694.     char buf[500];
  695.     sprintf(buf, "array");
  696.     appendStringInfo(str, buf);
  697.     sprintf(buf, " :arrayelemtype %d", node->arrayelemtype);
  698.     appendStringInfo(str, buf);
  699.     sprintf(buf, " :arrayelemlength %d", node->arrayelemlength);
  700.     appendStringInfo(str, buf);
  701.     sprintf(buf, " :arrayelembyval %c", (node->arrayelembyval) ? 't' : 'f');
  702.     appendStringInfo(str, buf);
  703.     sprintf(buf, " :arraylow %d", node->arraylow);
  704.     appendStringInfo(str, buf);
  705.     sprintf(buf, " :arrayhigh %d", node->arrayhigh);
  706.     appendStringInfo(str, buf);
  707.     sprintf(buf, " :arraylen %d", node->arraylen);
  708.     appendStringInfo(str, buf);
  709. }
  710.  
  711. /*
  712.  *  ArrayRef is a subclass of Expr
  713.  */
  714.  
  715. void
  716. _outArrayRef(str, node)
  717.     StringInfo str;
  718.     ArrayRef node;
  719. {
  720.     char *s;
  721.     char buf[500];
  722.  
  723.     sprintf(buf, "arrayref");
  724.     appendStringInfo(str, buf);
  725.     sprintf(buf, " :refelemtype %d", node->refelemtype);
  726.     appendStringInfo(str, buf);
  727.     sprintf(buf, " :refattrlength %d", node->refattrlength);
  728.     appendStringInfo(str, buf);
  729.     sprintf(buf, " :refelemlength %d", node->refelemlength);
  730.     appendStringInfo(str, buf);
  731.     sprintf(buf, " :refelembyval %c", (node->refelembyval) ? 't' : 'f');
  732.     appendStringInfo(str, buf);
  733.     sprintf(buf, " :refindex ");
  734.     appendStringInfo(str, buf);
  735.     s = lispOut(node->refindexpr);
  736.     appendStringInfo(str, s);
  737.     sprintf(buf, " :refexpr ");
  738.     appendStringInfo(str, buf);
  739.     s = lispOut(node->refexpr);
  740.     appendStringInfo(str, s);
  741. }
  742.  
  743. /*
  744.  *  Func is a subclass of Expr
  745.  */
  746.  
  747. void
  748. _outFunc(str, node)
  749.     StringInfo str;
  750.     Func    node;
  751. {
  752.     char buf[500];
  753.     char *s;
  754.  
  755.     sprintf(buf, "func");
  756.     appendStringInfo(str,buf);
  757.     sprintf(buf, " :funcid %ld", node->funcid);
  758.     appendStringInfo(str,buf);
  759.     sprintf(buf, " :functype %ld", node->functype);
  760.     appendStringInfo(str,buf);
  761.     sprintf(buf, " :funcisindex %s",
  762.         (node->funcisindex ? "true" : "nil"));
  763.     appendStringInfo(str,buf);
  764.     appendStringInfo(str, " :func_tlist ");
  765.     s = lispOut(node->func_tlist);
  766.     appendStringInfo(str, s);
  767.     appendStringInfo(str, " :func_planlist ");
  768.     s = lispOut(node->func_planlist);
  769.     appendStringInfo(str, s);
  770.     pfree(s);
  771. }
  772.  
  773. /*
  774.  *  Oper is a subclass of Expr
  775.  */
  776.  
  777. void
  778. _outOper(str, node)
  779.     StringInfo str;
  780.     Oper    node;
  781. {
  782.     char buf[500];
  783.  
  784.     sprintf(buf, "oper");
  785.     appendStringInfo(str,buf);
  786.     sprintf(buf, " :opno %ld", node->opno);
  787.     appendStringInfo(str,buf);
  788.     sprintf(buf, " :opid %ld", node->opid);
  789.     appendStringInfo(str,buf);
  790.     sprintf(buf, " :oprelationlevel %s",
  791.         (node->oprelationlevel ? "non-nil" : "nil"));
  792.     appendStringInfo(str,buf);
  793.     sprintf(buf, " :opresulttype %ld", node->opresulttype);
  794.     appendStringInfo(str,buf);
  795.  
  796. }
  797.  
  798. /*
  799.  *  Param is a subclass of Expr
  800.  */
  801.  
  802. void
  803. _outParam(str, node)
  804.     StringInfo str;
  805.     Param    node;
  806. {
  807.     char buf[500];
  808.     char *s;
  809.  
  810.     sprintf(buf, "param");
  811.     appendStringInfo(str,buf);
  812.     sprintf(buf, " :paramkind %d", node->paramkind);
  813.     appendStringInfo(str,buf);
  814.     sprintf(buf, " :paramid %hd", node->paramid);
  815.     appendStringInfo(str,buf);
  816.     sprintf(buf, " :paramname \"%s\"", node->paramname);
  817.     appendStringInfo(str,buf);
  818.     sprintf(buf, " :paramtype %ld", node->paramtype);
  819.     appendStringInfo(str,buf);
  820.  
  821.     appendStringInfo(str, " :param_tlist ");
  822.     s = lispOut(node->param_tlist);
  823.     appendStringInfo(str, s);
  824.     pfree(s);
  825.  
  826. }
  827.  
  828. /*
  829.  *  Stuff from execnodes.h
  830.  */
  831.  
  832. /*
  833.  *  EState is a subclass of Node.
  834.  */
  835.  
  836. void
  837. _outEState(str, node)
  838.     StringInfo str;
  839.     EState    node;
  840. {
  841.     char buf[500];
  842.  
  843.     sprintf(buf, "estate");
  844.     appendStringInfo(str,buf);
  845.     sprintf(buf, " :direction %d", node->es_direction);
  846.     appendStringInfo(str,buf);
  847.     sprintf(buf, " :time %lu", node->es_time);
  848.     appendStringInfo(str,buf);
  849.     sprintf(buf, " :owner %ld", node->es_owner);
  850.     appendStringInfo(str,buf);
  851.  
  852.     sprintf(buf, " :locks ");
  853.     appendStringInfo(str,buf);
  854.     _outLispValue(str, node->es_locks);
  855.  
  856.     sprintf(buf, " :subplan_info ");
  857.     appendStringInfo(str,buf);
  858.     _outLispValue(str, node->es_subplan_info);
  859.  
  860.     sprintf(buf, " :error_message \"%s\"", node->es_error_message);
  861.     appendStringInfo(str,buf);
  862.  
  863.     sprintf(buf, " :range_table ");
  864.     appendStringInfo(str,buf);
  865.     _outLispValue(str, node->es_range_table);
  866.  
  867.     /*
  868.      *  Could be more thorough on the types below, printing more
  869.      *  info.  Just need to burst out the values in the structs
  870.      *  pointed to by the entries in the EState node.  For now,
  871.      *  we'll just print the addresses of the hard stuff.
  872.      */
  873.  
  874.     sprintf(buf, " :qualification_tuple @ 0x%x",
  875.             node->es_qualification_tuple);
  876.     appendStringInfo(str,buf);
  877.     sprintf(buf, " :qualification_tuple_id @ 0x%x",
  878.             node->es_qualification_tuple_id);
  879.     appendStringInfo(str,buf);
  880.     sprintf(str, " :relation_relation_descriptor @ 0x%x",
  881.             node->es_relation_relation_descriptor);
  882.     appendStringInfo(str,buf);
  883.  
  884.     sprintf(str, " :result_relation_info @ 0x%x",
  885.             node->es_result_relation_info);
  886.     appendStringInfo(str,buf);
  887.  
  888. }
  889.  
  890. /*
  891.  *  Stuff from relation.h
  892.  */
  893.  
  894. void
  895. _outRel(str, node)
  896.     StringInfo str;
  897.     Rel    node;
  898. {
  899.     char buf[500];
  900.  
  901.     sprintf(buf, "rel");
  902.     appendStringInfo(str,buf);
  903.  
  904.     sprintf(buf, " :relids ");
  905.     appendStringInfo(str,buf);
  906.     _outLispValue(str, node->relids);
  907.  
  908.     sprintf(buf, " :indexed %s", (node->indexed ? "true" : "nil"));
  909.     appendStringInfo(str,buf);
  910.     sprintf(buf, " :pages %u", node->pages);
  911.     appendStringInfo(str,buf);
  912.     sprintf(buf, " :tuples %u", node->tuples);
  913.     appendStringInfo(str,buf);
  914.     sprintf(buf, " :size %u", node->size);
  915.     appendStringInfo(str,buf);
  916.     sprintf(buf, " :width %u", node->width);
  917.     appendStringInfo(str,buf);
  918.  
  919.     sprintf(buf, " :targetlist ");
  920.     appendStringInfo(str,buf);
  921.     _outLispValue(str, node->targetlist);
  922.  
  923.     sprintf(buf, " :pathlist ");
  924.     appendStringInfo(str,buf);
  925.     _outLispValue(str, node->pathlist);
  926.  
  927.     /*
  928.      *  Not sure if these are nodes or not.  They're declared as
  929.      *  struct Path *.  Since i don't know, i'll just print the
  930.      *  addresses for now.  This can be changed later, if necessary.
  931.      */
  932.  
  933.     sprintf(buf, " :unorderedpath @ 0x%x", node->unorderedpath);
  934.     appendStringInfo(str,buf);
  935.     sprintf(buf, " :cheapestpath @ 0x%x", node->cheapestpath);
  936.     appendStringInfo(str,buf);
  937.  
  938.     sprintf(buf, " :classlist ");
  939.     appendStringInfo(str,buf);
  940.     _outLispValue(str, node->classlist);
  941.  
  942.     sprintf(buf, " :indexkeys ");
  943.     appendStringInfo(str,buf);
  944.     _outLispValue(str, node->indexkeys);
  945.  
  946.     sprintf(buf, " :ordering ");
  947.     appendStringInfo(str,buf);
  948.     _outLispValue(str, node->ordering);
  949.  
  950.     sprintf(buf, " :clauseinfo ");
  951.     appendStringInfo(str,buf);
  952.     _outLispValue(str, node->clauseinfo);
  953.  
  954.     sprintf(buf, " :joininfo ");
  955.     appendStringInfo(str,buf);
  956.     _outLispValue(str, node->joininfo);
  957.  
  958.     sprintf(buf, " :innerjoin ");
  959.     appendStringInfo(str,buf);
  960.     _outLispValue(str, node->innerjoin);
  961.  
  962. }
  963.  
  964. /*
  965.  *  TLE is a subclass of Node.
  966.  */
  967. /*
  968. void
  969. _outTLE(str, node)
  970.     StringInfo str;
  971.     TLE    node;
  972. {
  973.     char buf[500];
  974.  
  975.     sprintf(buf, "TLE ");
  976.     appendStringInfo(str,buf);
  977.     sprintf(buf, " :resdom ");
  978.     appendStringInfo(str,buf);
  979.     node->resdom->outFunc(str, node->resdom);
  980.  
  981.     sprintf(buf, " :expr ");
  982.     appendStringInfo(str,buf);
  983.     node->expr->outFunc(str, node->expr);
  984.  
  985. }
  986. */
  987. /*
  988.  *  TL is a subclass of Node.
  989.  */
  990. /*
  991. void
  992. _outTL(str, node)
  993.     StringInfo str;
  994.     TL    node;
  995. {
  996.     char buf[500];
  997.  
  998.     sprintf(buf, "tl ");
  999.     appendStringInfo(str,buf);
  1000.     sprintf(buf, " :entry ");
  1001.     appendStringInfo(str,buf);
  1002.     node->entry->outFunc(str, node->entry);
  1003.  
  1004.     sprintf(buf, " :joinlist ");
  1005.     appendStringInfo(str,buf);
  1006.     _outLispValue(str, node->joinlist);
  1007.  
  1008. }
  1009. */
  1010. /*
  1011.  *  SortKey is a subclass of Node.
  1012.  */
  1013.  
  1014. void
  1015. _outSortKey(str, node)
  1016.     StringInfo str;
  1017.     SortKey        node;
  1018. {
  1019.     char buf[500];
  1020.  
  1021.     sprintf(buf, "sortkey");
  1022.     appendStringInfo(str,buf);
  1023.  
  1024.     sprintf(buf, " :varkeys ");
  1025.     appendStringInfo(str,buf);
  1026.     _outLispValue(str, node->varkeys);
  1027.  
  1028.     sprintf(buf, " :sortkeys ");
  1029.     appendStringInfo(str,buf);
  1030.     _outLispValue(str, node->sortkeys);
  1031.  
  1032.     sprintf(buf, " :relid ");
  1033.     appendStringInfo(str,buf);
  1034.     _outLispValue(str, node->relid);
  1035.  
  1036.     sprintf(buf, " :sortorder ");
  1037.     appendStringInfo(str,buf);
  1038.     _outLispValue(str, node->sortorder);
  1039.  
  1040. }
  1041.  
  1042. /*
  1043.  *  Path is a subclass of Node.
  1044.  */
  1045.  
  1046. void
  1047. _outPath(str, node)
  1048.     StringInfo str;
  1049.     Path    node;
  1050. {
  1051.     char buf[500];
  1052.  
  1053.     sprintf(buf, "path");
  1054.     appendStringInfo(str,buf);
  1055.  
  1056.     sprintf(buf, " :pathtype %ld", node->pathtype);
  1057.     appendStringInfo(str,buf);
  1058.  
  1059. /*    sprintf(buf, " :parent ");
  1060.  *      appendStringInfo(str,buf);
  1061.  *    _outLispValue(str, node->parent);
  1062.  */
  1063.     sprintf(buf, " :cost %f", node->path_cost);
  1064.     appendStringInfo(str,buf);
  1065.  
  1066.     sprintf(buf, " :p_ordering ");
  1067.     appendStringInfo(str,buf);
  1068.     _outLispValue(str, node->p_ordering);
  1069.  
  1070.     sprintf(buf, " :keys ");
  1071.     appendStringInfo(str,buf);
  1072.     _outLispValue(str, node->keys);
  1073.  
  1074.     sprintf(buf, " :pathsortkey ");
  1075.     appendStringInfo(str,buf);
  1076.     _outLispValue(str, (LispValue)(node->pathsortkey));
  1077.  
  1078. }
  1079.  
  1080. /*
  1081.  *  IndexPath is a subclass of Path.
  1082.  */
  1083.  
  1084. void
  1085. _outIndexPath(str, node)
  1086.     StringInfo str;
  1087.     IndexPath    node;
  1088. {
  1089.     char buf[500];
  1090.  
  1091.     sprintf(buf, "indexpath");
  1092.     appendStringInfo(str,buf);
  1093.  
  1094.     sprintf(buf, " :pathtype %ld", node->pathtype);
  1095.     appendStringInfo(str,buf);
  1096.  
  1097. /*    sprintf(buf, " :parent ");
  1098.     appendStringInfo(str,buf);
  1099.     _outLispValue(str, node->parent); */
  1100.  
  1101.     sprintf(buf, " :cost %f", node->path_cost);
  1102.     appendStringInfo(str,buf);
  1103.  
  1104.     sprintf(buf, " :p_ordering ");
  1105.     appendStringInfo(str,buf);
  1106.     _outLispValue(str, node->p_ordering);
  1107.  
  1108.     sprintf(buf, " :keys ");
  1109.     appendStringInfo(str,buf);
  1110.     _outLispValue(str, node->keys);
  1111.  
  1112.     sprintf(buf, " :pathsortkey ");
  1113.     appendStringInfo(str,buf);
  1114.     _outLispValue(str, (LispValue)(node->pathsortkey));
  1115.  
  1116.     sprintf(buf, " :indexid ");
  1117.     appendStringInfo(str,buf);
  1118.     _outLispValue(str, node->indexid);
  1119.  
  1120.     sprintf(buf, " :indexqual ");
  1121.     appendStringInfo(str,buf);
  1122.     _outLispValue(str, node->indexqual);
  1123.  
  1124. }
  1125.  
  1126. /*
  1127.  *  JoinPath is a subclass of Path
  1128.  */
  1129.  
  1130. void
  1131. _outJoinPath(str, node)
  1132.     StringInfo str;
  1133.     JoinPath    node;
  1134. {
  1135.     char buf[500];
  1136.  
  1137.     sprintf(buf, "joinpath");
  1138.     appendStringInfo(str,buf);
  1139.  
  1140.     sprintf(buf, " :pathtype %ld", node->pathtype);
  1141.     appendStringInfo(str,buf);
  1142.  
  1143. /*    sprintf(buf, " :parent ");
  1144.     appendStringInfo(str,buf);
  1145.     _outLispValue(str, node->parent); */
  1146.  
  1147.     sprintf(buf, " :cost %f", node->path_cost);
  1148.     appendStringInfo(str,buf);
  1149.  
  1150.     sprintf(buf, " :p_ordering ");
  1151.     appendStringInfo(str,buf);
  1152.     _outLispValue(str, node->p_ordering);
  1153.  
  1154.     sprintf(buf, " :keys ");
  1155.     appendStringInfo(str,buf);
  1156.     _outLispValue(str, node->keys);
  1157.  
  1158.     sprintf(buf, " :pathsortkey ");
  1159.     appendStringInfo(str,buf);
  1160.     _outLispValue(str, (LispValue)(node->pathsortkey));
  1161.  
  1162.     sprintf(buf, " :pathclauseinfo ");
  1163.     appendStringInfo(str,buf);
  1164.     _outLispValue(str, (LispValue)(node->pathclauseinfo));
  1165.  
  1166.     /*
  1167.      *  Not sure if these are nodes; they're declared as "struct path *".
  1168.      *  For now, i'll just print the addresses.
  1169.      */
  1170.  
  1171.     sprintf(buf, " :outerjoinpath @ 0x%x", node->outerjoinpath);
  1172.     appendStringInfo(str,buf);
  1173.     sprintf(buf, " :innerjoinpath @ 0x%x", node->innerjoinpath);
  1174.     appendStringInfo(str,buf);
  1175.  
  1176.     sprintf(buf, " :outerjoincost %f", node->outerjoincost);
  1177.     appendStringInfo(str,buf);
  1178.  
  1179.     sprintf(buf, " :joinid ");
  1180.     appendStringInfo(str,buf);
  1181.     _outLispValue(str, node->joinid);
  1182.  
  1183. }
  1184.  
  1185. /*
  1186.  *  MergePath is a subclass of JoinPath.
  1187.  */
  1188.  
  1189. void
  1190. _outMergePath(str, node)
  1191.     StringInfo str;
  1192.     MergePath    node;
  1193. {
  1194.     char buf[500];
  1195.  
  1196.     sprintf(buf, "mergepath");
  1197.     appendStringInfo(str,buf);
  1198.  
  1199.     sprintf(buf, " :pathtype %ld", node->pathtype);
  1200.     appendStringInfo(str,buf);
  1201.  
  1202. /*    sprintf(buf, " :parent ");
  1203.     appendStringInfo(str,buf);
  1204.     _outLispValue(str, node->parent);  */
  1205.  
  1206.     sprintf(buf, " :cost %f", node->path_cost);
  1207.     appendStringInfo(str,buf);
  1208.  
  1209.     sprintf(buf, " :p_ordering ");
  1210.     appendStringInfo(str,buf);
  1211.     _outLispValue(str, node->p_ordering);
  1212.  
  1213.     sprintf(buf, " :keys ");
  1214.     appendStringInfo(str,buf);
  1215.     _outLispValue(str, node->keys);
  1216.  
  1217.     sprintf(buf, " :pathsortkey ");
  1218.     appendStringInfo(str,buf);
  1219.     _outLispValue(str, (LispValue)(node->pathsortkey));
  1220.  
  1221.     sprintf(buf, " :pathclauseinfo ");
  1222.     appendStringInfo(str,buf);
  1223.     _outLispValue(str, (LispValue)(node->pathclauseinfo));
  1224.  
  1225.     /*
  1226.      *  Not sure if these are nodes; they're declared as "struct path *".
  1227.      *  For now, i'll just print the addresses.
  1228.      */
  1229.  
  1230.     sprintf(buf, " :outerjoinpath @ 0x%x", node->outerjoinpath);
  1231.     appendStringInfo(str,buf);
  1232.     sprintf(buf, " :innerjoinpath @ 0x%x", node->innerjoinpath);
  1233.     appendStringInfo(str,buf);
  1234.  
  1235.     sprintf(buf, " :outerjoincost %f", node->outerjoincost);
  1236.     appendStringInfo(str,buf);
  1237.  
  1238.     sprintf(buf, " :joinid ");
  1239.     appendStringInfo(str,buf);
  1240.     _outLispValue(str, node->joinid);
  1241.  
  1242.     sprintf(buf, " :path_mergeclauses ");
  1243.     appendStringInfo(str,buf);
  1244.     _outLispValue(str, node->path_mergeclauses);
  1245.  
  1246.     sprintf(buf, " :outersortkeys ");
  1247.     appendStringInfo(str,buf);
  1248.     _outLispValue(str, node->outersortkeys);
  1249.  
  1250.     sprintf(buf, " :innersortkeys ");
  1251.     appendStringInfo(str,buf);
  1252.     _outLispValue(str, node->innersortkeys);
  1253.  
  1254. }
  1255.  
  1256. /*
  1257.  *  HashPath is a subclass of JoinPath.
  1258.  */
  1259.  
  1260. void
  1261. _outHashPath(str, node)
  1262.     StringInfo str;
  1263.     HashPath    node;
  1264. {
  1265.     char buf[500];
  1266.  
  1267.     sprintf(buf, "hashpath");
  1268.     appendStringInfo(str,buf);
  1269.  
  1270.     sprintf(buf, " :pathtype %ld", node->pathtype);
  1271.     appendStringInfo(str,buf);
  1272.  
  1273. /*    sprintf(buf, " :parent ");
  1274.     appendStringInfo(str,buf);
  1275.     _outLispValue(str, node->parent); */
  1276.  
  1277.     sprintf(buf, " :cost %f", node->path_cost);
  1278.     appendStringInfo(str,buf);
  1279.  
  1280.     sprintf(buf, " :p_ordering ");
  1281.     appendStringInfo(str,buf);
  1282.     _outLispValue(str, node->p_ordering);
  1283.  
  1284.     sprintf(buf, " :keys ");
  1285.     appendStringInfo(str,buf);
  1286.     _outLispValue(str, node->keys);
  1287.  
  1288.     sprintf(buf, " :pathsortkey ");
  1289.     appendStringInfo(str,buf);
  1290.     _outLispValue(str, (LispValue)(node->pathsortkey));
  1291.  
  1292.     sprintf(buf, " :pathclauseinfo ");
  1293.     appendStringInfo(str,buf);
  1294.     _outLispValue(str, (LispValue)(node->pathclauseinfo));
  1295.  
  1296.     /*
  1297.      *  Not sure if these are nodes; they're declared as "struct path *".
  1298.      *  For now, i'll just print the addresses.
  1299.      */
  1300.  
  1301.     sprintf(buf, " :outerjoinpath @ 0x%x", node->outerjoinpath);
  1302.     appendStringInfo(str,buf);
  1303.     sprintf(buf, " :innerjoinpath @ 0x%x", node->innerjoinpath);
  1304.     appendStringInfo(str,buf);
  1305.  
  1306.     sprintf(buf, " :outerjoincost %f", node->outerjoincost);
  1307.     appendStringInfo(str,buf);
  1308.  
  1309.     sprintf(buf, " :joinid ");
  1310.     appendStringInfo(str,buf);
  1311.     _outLispValue(str, node->joinid);
  1312.  
  1313.     sprintf(buf, " :path_hashclauses ");
  1314.     appendStringInfo(str,buf);
  1315.     _outLispValue(str, node->path_hashclauses);
  1316.  
  1317.     sprintf(buf, " :outerhashkeys ");
  1318.     appendStringInfo(str,buf);
  1319.     _outLispValue(str, node->outerhashkeys);
  1320.  
  1321.     sprintf(buf, " :innerhashkeys ");
  1322.     appendStringInfo(str,buf);
  1323.     _outLispValue(str, node->innerhashkeys);
  1324.  
  1325. }
  1326.  
  1327. /*
  1328.  *  OrderKey is a subclass of Node.
  1329.  */
  1330.  
  1331. void
  1332. _outOrderKey(str, node)
  1333.     StringInfo str;
  1334.     OrderKey    node;
  1335. {
  1336.     char buf[500];
  1337.  
  1338.     sprintf(buf, "orderkey");
  1339.     appendStringInfo(str,buf);
  1340.     sprintf(buf, " :attribute_number %d", node->attribute_number);
  1341.     appendStringInfo(str,buf);
  1342.     sprintf(buf, " :array_index %d", node->array_index);
  1343.     appendStringInfo(str,buf);
  1344.  
  1345. }
  1346.  
  1347. /*
  1348.  *  JoinKey is a subclass of Node.
  1349.  */
  1350.  
  1351. void
  1352. _outJoinKey(str, node)
  1353.     StringInfo str;
  1354.     JoinKey        node;
  1355. {
  1356.     char buf[500];
  1357.  
  1358.     sprintf(buf, "joinkey");
  1359.     appendStringInfo(str,buf);
  1360.  
  1361.     sprintf(buf, " :outer ");
  1362.     appendStringInfo(str,buf);
  1363.     _outLispValue(str, node->outer);
  1364.  
  1365.     sprintf(buf, " :inner ");
  1366.     appendStringInfo(str,buf);
  1367.     _outLispValue(str, node->inner);
  1368.  
  1369. }
  1370.  
  1371. /*
  1372.  *  MergeOrder is a subclass of Node.
  1373.  */
  1374.  
  1375. void
  1376. _outMergeOrder(str, node)
  1377.     StringInfo str;
  1378.     MergeOrder    node;
  1379. {
  1380.     char buf[500];
  1381.  
  1382.     sprintf(buf, "mergeorder");
  1383.     appendStringInfo(str,buf);
  1384.  
  1385.     sprintf(buf, " :join_operator %ld", node->join_operator);
  1386.     appendStringInfo(str,buf);
  1387.     sprintf(buf, " :left_operator %ld", node->left_operator);
  1388.     appendStringInfo(str,buf);
  1389.     sprintf(buf, " :right_operator %ld", node->right_operator);
  1390.     appendStringInfo(str,buf);
  1391.     sprintf(buf, " :left_type %ld", node->left_type);
  1392.     appendStringInfo(str,buf);
  1393.     sprintf(buf, " :right_type %ld", node->right_type);
  1394.     appendStringInfo(str,buf);
  1395.  
  1396. }
  1397.  
  1398. /*
  1399.  *  CInfo is a subclass of Node.
  1400.  */
  1401.  
  1402. void
  1403. _outCInfo(str, node)
  1404.     StringInfo str;
  1405.     CInfo    node;
  1406. {
  1407.     char buf[500];
  1408.  
  1409.     sprintf(buf, "cinfo");
  1410.     appendStringInfo(str,buf);
  1411.  
  1412.     sprintf(buf, " :clause ");
  1413.     appendStringInfo(str,buf);
  1414.     _outLispValue(str, (LispValue)(node->clause));
  1415.  
  1416.     sprintf(buf, " :selectivity %f", node->selectivity);
  1417.     appendStringInfo(str,buf);
  1418.     sprintf(buf, " :notclause %s", (node->notclause ? "true" : "nil"));
  1419.     appendStringInfo(str,buf);
  1420.  
  1421.     sprintf(buf, " :indexids ");
  1422.     appendStringInfo(str,buf);
  1423.     _outLispValue(str, node->indexids);
  1424.  
  1425.     sprintf(buf, " :mergesortorder ");
  1426.     appendStringInfo(str,buf);
  1427.     _outLispValue(str, (LispValue)(node->mergesortorder));
  1428.  
  1429.     sprintf(buf, " :hashjoinoperator %ld", node->hashjoinoperator);
  1430.     appendStringInfo(str,buf);
  1431.  
  1432. }
  1433.  
  1434. /*
  1435.  *  JoinMethod is a subclass of Node.
  1436.  */
  1437.  
  1438. void
  1439. _outJoinMethod(str, node)
  1440.     StringInfo str;
  1441.     register JoinMethod node;
  1442. {
  1443.     char buf[500];
  1444.  
  1445.     sprintf(buf, "joinmethod");
  1446.     appendStringInfo(str,buf);
  1447.  
  1448.     sprintf(buf, " :jmkeys ");
  1449.     appendStringInfo(str,buf);
  1450.     _outLispValue(str, node->jmkeys);
  1451.  
  1452.     sprintf(buf, " :clauses ");
  1453.     appendStringInfo(str,buf);
  1454.     _outLispValue(str, node->clauses);
  1455.  
  1456.  
  1457. }
  1458.  
  1459. /*
  1460.  * HInfo is a subclass of JoinMethod.
  1461.  */
  1462.  
  1463. void
  1464. _outHInfo(str, node)
  1465.     StringInfo str;
  1466.      register HInfo node;
  1467. {
  1468.     char buf[500];
  1469.  
  1470.     sprintf(buf, "hashinfo");
  1471.     appendStringInfo(str,buf);
  1472.  
  1473.     sprintf(buf, " :hashop ");
  1474.     appendStringInfo(str,buf);
  1475.     sprintf(buf, "%d",node->hashop);
  1476.     appendStringInfo(str,buf);
  1477.  
  1478.     sprintf(buf, " :jmkeys ");
  1479.     appendStringInfo(str,buf);
  1480.     _outLispValue(str, node->jmkeys);
  1481.  
  1482.     sprintf(buf, " :clauses ");
  1483.     appendStringInfo(str,buf);
  1484.     _outLispValue(str, node->clauses);
  1485.  
  1486. }
  1487.  
  1488. /*
  1489.  *  JInfo is a subclass of Node.
  1490.  */
  1491.  
  1492. void
  1493. _outJInfo(str, node)
  1494.     StringInfo str;
  1495.     JInfo    node;
  1496. {
  1497.     char buf[500];
  1498.  
  1499.     sprintf(buf, "jinfo");
  1500.     appendStringInfo(str,buf);
  1501.  
  1502.     sprintf(buf, " :otherrels ");
  1503.     appendStringInfo(str,buf);
  1504.     _outLispValue(str, node->otherrels);
  1505.  
  1506.     sprintf(buf, " :jinfoclauseinfo ");
  1507.     appendStringInfo(str,buf);
  1508.     _outLispValue(str, node->jinfoclauseinfo);
  1509.  
  1510.     sprintf(buf, " :mergesortable %s",
  1511.             (node->mergesortable ? "true" : "nil"));
  1512.     appendStringInfo(str,buf);
  1513.     sprintf(buf, " :hashjoinable %s",
  1514.             (node->hashjoinable ? "true" : "nil"));
  1515.     appendStringInfo(str,buf);
  1516.  
  1517. }
  1518.  
  1519. /*
  1520.  * Print the value of a Datum given its type.
  1521.  */
  1522. void
  1523. _outDatum(str, value, type) 
  1524. StringInfo str;
  1525. Datum value;
  1526. ObjectId type;
  1527. {
  1528.     char buf[500];
  1529.     Size length, typeLength;
  1530.     bool byValue;
  1531.     HeapTuple typeTuple;
  1532.     int i;
  1533.     char *s;
  1534.  
  1535.     /*
  1536.      * find some information about the type and the "real" length
  1537.      * of the datum.
  1538.      */
  1539.     byValue = get_typbyval(type);
  1540.     typeLength = get_typlen(type);
  1541.     length = datumGetSize(value, type, byValue, typeLength);
  1542.  
  1543.     if (byValue) {
  1544.     s = (char *) (&value);
  1545.     sprintf(buf, " %d { ", length);
  1546.     appendStringInfo(str,buf);
  1547.     for (i=0; i<sizeof(Datum); i++) {
  1548.         sprintf(buf, "%d ", (int) (s[i]) );
  1549.     appendStringInfo(str,buf);
  1550.     }
  1551.     sprintf(buf, "} ");
  1552.     appendStringInfo(str,buf);
  1553.     } else { /* !byValue */
  1554.     s = (char *) DatumGetPointer(value);
  1555.     if (!PointerIsValid(s)) {
  1556.         sprintf(buf, " 0 { } ");
  1557.     appendStringInfo(str,buf);
  1558.     } else {
  1559.         /*
  1560.          * length is unsigned - very bad to do < comparison to -1 without
  1561.          * casting it to int first!! -mer 8 Jan 1991
  1562.          */
  1563.         if (((int)length) <= -1) {
  1564.         length = VARSIZE(s);
  1565.         }
  1566.         sprintf(buf, " %d { ", length);
  1567.     appendStringInfo(str,buf);
  1568.         for (i=0; i<length; i++) {
  1569.         sprintf(buf, "%d ", (int) (s[i]) );
  1570.     appendStringInfo(str,buf);
  1571.         }
  1572.         sprintf(buf, "} ");
  1573.     appendStringInfo(str,buf);
  1574.     }
  1575.     }
  1576.  
  1577. }
  1578.  
  1579. void
  1580. _outIter(str, node)
  1581.     StringInfo str;
  1582.     Iter    node;
  1583. {
  1584.     char *s;
  1585.  
  1586.     appendStringInfo(str,"iter");
  1587.  
  1588.     appendStringInfo(str," :iterexpr ");
  1589.  
  1590.     s = lispOut(node->iterexpr);
  1591.     appendStringInfo(str, s);
  1592.  
  1593.     pfree(s);
  1594. }
  1595.