finished cleaning up outnodes.c ...

This commit is contained in:
Marc G. Fournier 1998-12-20 07:13:36 +00:00
parent 3cd3be92ff
commit 1adb6a9d18

View File

@ -5,7 +5,7 @@
* *
* Copyright (c) 1994, Regents of the University of California * Copyright (c) 1994, Regents of the University of California
* *
* $Id: outfuncs.c,v 1.57 1998/12/18 14:45:08 wieck Exp $ * $Id: outfuncs.c,v 1.58 1998/12/20 07:13:36 scrappy Exp $
* *
* NOTES * NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which * Every (plan) node in POSTGRES has an associated "out" routine which
@ -71,10 +71,11 @@ _outCreateStmt(StringInfo str, CreateStmt *node)
{ {
appendStringInfo(str, " CREATE :relname %s :columns ", appendStringInfo(str, " CREATE :relname %s :columns ",
stringStringInfo(node->relname)); stringStringInfo(node->relname));
_outNode(str, node->tableElts); _outNode(str, node->tableElts);
appendStringInfo(str, " :inhRelnames "); appendStringInfo(str, " :inhRelnames ");
_outNode(str, node->inhRelnames); _outNode(str, node->inhRelnames);
appendStringInfo(str, " :constraints "); appendStringInfo(str, " :constraints ");
_outNode(str, node->constraints); _outNode(str, node->constraints);
} }
@ -87,12 +88,14 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
stringStringInfo(node->idxname), stringStringInfo(node->idxname),
stringStringInfo(node->relname), stringStringInfo(node->relname),
stringStringInfo(node->accessMethod)); stringStringInfo(node->accessMethod));
_outNode(str, node->indexParams); _outNode(str, node->indexParams);
appendStringInfo(str, " :withClause "); appendStringInfo(str, " :withClause ");
_outNode(str, node->withClause); _outNode(str, node->withClause);
appendStringInfo(str, " :whereClause "); appendStringInfo(str, " :whereClause ");
_outNode(str, node->whereClause); _outNode(str, node->whereClause);
appendStringInfo(str, " :rangetable "); appendStringInfo(str, " :rangetable ");
_outNode(str, node->rangetable); _outNode(str, node->rangetable);
@ -112,8 +115,7 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
static void static void
_outFuncCall(StringInfo str, FuncCall *node) _outFuncCall(StringInfo str, FuncCall *node)
{ {
appendStringInfo(str, "FUNCTION %s :args ", appendStringInfo(str, "FUNCTION %s :args ", stringStringInfo(node->funcname));
stringStringInfo(node->funcname));
_outNode(str, node->args); _outNode(str, node->args);
} }
@ -153,8 +155,7 @@ _outIndexElem(StringInfo str, IndexElem *node)
stringStringInfo(node->name)); stringStringInfo(node->name));
_outNode(str, node->args); _outNode(str, node->args);
appendStringInfo(str, " :class %s :typename ", appendStringInfo(str, " :class %s :typename ", stringStringInfo(node->class));
stringStringInfo(node->class));
_outNode(str, node->typename); _outNode(str, node->typename);
} }
@ -727,8 +728,7 @@ _outArray(StringInfo str, Array *node)
node->arrayelemlength, node->arrayelemlength,
node->arrayelembyval ? 't' : 'f'); node->arrayelembyval ? 't' : 'f');
appendStringInfo(str, " :arrayndim %d ", node->arrayndim); appendStringInfo(str, " :arrayndim %d :arraylow ", node->arrayndim);
appendStringInfo(str, " :arraylow ");
for (i = 0; i < node->arrayndim; i++) for (i = 0; i < node->arrayndim; i++)
{ {
appendStringInfo(str, " %d ", node->arraylow.indx[i]); appendStringInfo(str, " %d ", node->arraylow.indx[i]);
@ -1055,9 +1055,7 @@ _outOrderKey(StringInfo str, OrderKey *node)
static void static void
_outJoinKey(StringInfo str, JoinKey *node) _outJoinKey(StringInfo str, JoinKey *node)
{ {
appendStringInfo(str, " JOINKEY "); appendStringInfo(str, " JOINKEY :outer ");
appendStringInfo(str, " :outer ");
_outNode(str, node->outer); _outNode(str, node->outer);
appendStringInfo(str, " :inner "); appendStringInfo(str, " :inner ");
@ -1071,21 +1069,16 @@ _outJoinKey(StringInfo str, JoinKey *node)
static void static void
_outMergeOrder(StringInfo str, MergeOrder *node) _outMergeOrder(StringInfo str, MergeOrder *node)
{ {
char buf[500]; appendStringInfo(str,
" MERGEORDER :join_operator %d :left_operator %d :right_operator %d ",
appendStringInfo(str, " MERGEORDER "); node->join_operator,
node->left_operator,
sprintf(buf, " :join_operator %d ", node->join_operator); node->right_operator);
appendStringInfo(str, buf);
sprintf(buf, " :left_operator %d ", node->left_operator);
appendStringInfo(str, buf);
sprintf(buf, " :right_operator %d ", node->right_operator);
appendStringInfo(str, buf);
sprintf(buf, " :left_type %d ", node->left_type);
appendStringInfo(str, buf);
sprintf(buf, " :right_type %d ", node->right_type);
appendStringInfo(str, buf);
appendStringInfo(str,
" :left_type %d :right_type %d ",
node->left_type,
node->right_type);
} }
/* /*
@ -1094,26 +1087,19 @@ _outMergeOrder(StringInfo str, MergeOrder *node)
static void static void
_outClauseInfo(StringInfo str, ClauseInfo * node) _outClauseInfo(StringInfo str, ClauseInfo * node)
{ {
char buf[500]; appendStringInfo(str, " CINFO :clause ");
appendStringInfo(str, " CINFO ");
appendStringInfo(str, " :clause ");
_outNode(str, node->clause); _outNode(str, node->clause);
sprintf(buf, " :selectivity %f ", node->selectivity); appendStringInfo(str,
appendStringInfo(str, buf); " :selectivity %f :notclause %s :indexids ",
appendStringInfo(str, " :notclause "); node->selectivity,
appendStringInfo(str, node->notclause ? "true" : "false"); node->notclause ? "true" : "false");
appendStringInfo(str, " :indexids ");
_outNode(str, node->indexids); _outNode(str, node->indexids);
appendStringInfo(str, " :mergejoinorder "); appendStringInfo(str, " :mergejoinorder ");
_outNode(str, node->mergejoinorder); _outNode(str, node->mergejoinorder);
sprintf(buf, " :hashjoinoperator %u ", node->hashjoinoperator); appendStringInfo(str, " :hashjoinoperator %u ", node->hashjoinoperator);
appendStringInfo(str, buf);
} }
@ -1123,15 +1109,11 @@ _outClauseInfo(StringInfo str, ClauseInfo * node)
static void static void
_outJoinMethod(StringInfo str, JoinMethod *node) _outJoinMethod(StringInfo str, JoinMethod *node)
{ {
appendStringInfo(str, " JOINMETHOD "); appendStringInfo(str, " JOINMETHOD :jmkeys ");
appendStringInfo(str, " :jmkeys ");
_outNode(str, node->jmkeys); _outNode(str, node->jmkeys);
appendStringInfo(str, " :clauses "); appendStringInfo(str, " :clauses ");
_outNode(str, node->clauses); _outNode(str, node->clauses);
} }
/* /*
@ -1140,20 +1122,11 @@ _outJoinMethod(StringInfo str, JoinMethod *node)
static void static void
_outHInfo(StringInfo str, HInfo *node) _outHInfo(StringInfo str, HInfo *node)
{ {
char buf[500]; appendStringInfo(str, " HASHINFO :hashop %u :jmkeys ", node->hashop);
appendStringInfo(str, " HASHINFO ");
appendStringInfo(str, " :hashop ");
sprintf(buf, " %u ", node->hashop);
appendStringInfo(str, buf);
appendStringInfo(str, " :jmkeys ");
_outNode(str, node->jmethod.jmkeys); _outNode(str, node->jmethod.jmkeys);
appendStringInfo(str, " :clauses "); appendStringInfo(str, " :clauses ");
_outNode(str, node->jmethod.clauses); _outNode(str, node->jmethod.clauses);
} }
/* /*
@ -1162,19 +1135,15 @@ _outHInfo(StringInfo str, HInfo *node)
static void static void
_outJoinInfo(StringInfo str, JoinInfo * node) _outJoinInfo(StringInfo str, JoinInfo * node)
{ {
appendStringInfo(str, " JINFO "); appendStringInfo(str, " JINFO :otherrels ");
appendStringInfo(str, " :otherrels ");
_outIntList(str, node->otherrels); _outIntList(str, node->otherrels);
appendStringInfo(str, " :jinfoclauseinfo "); appendStringInfo(str, " :jinfoclauseinfo ");
_outNode(str, node->jinfoclauseinfo); _outNode(str, node->jinfoclauseinfo);
appendStringInfo(str, " :mergejoinable "); appendStringInfo(str, " :mergejoinable %s :hashjoinable %s ",
appendStringInfo(str, node->mergejoinable ? "true" : "false"); node->mergejoinable ? "true" : "false",
appendStringInfo(str, " :hashjoinable "); node->hashjoinable ? "true" : "false");
appendStringInfo(str, node->hashjoinable ? "true" : "false");
} }
/* /*
@ -1183,12 +1152,11 @@ _outJoinInfo(StringInfo str, JoinInfo * node)
static void static void
_outDatum(StringInfo str, Datum value, Oid type) _outDatum(StringInfo str, Datum value, Oid type)
{ {
char buf[500]; char *s;
Size length, Size length,
typeLength; typeLength;
bool byValue; bool byValue;
int i; int i;
char *s;
/* /*
* find some information about the type and the "real" length of the * find some information about the type and the "real" length of the
@ -1201,42 +1169,34 @@ _outDatum(StringInfo str, Datum value, Oid type)
if (byValue) if (byValue)
{ {
s = (char *) (&value); s = (char *) (&value);
sprintf(buf, " %d [ ", length); appendStringInfo(str, " %d [ ", length);
appendStringInfo(str, buf);
for (i = 0; i < sizeof(Datum); i++) for (i = 0; i < sizeof(Datum); i++)
{ {
sprintf(buf, " %d ", (int) (s[i])); appendStringInfo(str, " %d ", (int) (s[i]));
appendStringInfo(str, buf);
} }
sprintf(buf, "] "); appendStringInfo(str, "] ");
appendStringInfo(str, buf);
} }
else else
{ /* !byValue */ { /* !byValue */
s = (char *) DatumGetPointer(value); s = (char *) DatumGetPointer(value);
if (!PointerIsValid(s)) if (!PointerIsValid(s))
{ {
sprintf(buf, " 0 [ ] "); appendStringInfo(str, " 0 [ ] ");
appendStringInfo(str, buf);
} }
else else
{ {
/* /*
* length is unsigned - very bad to do < comparison to -1 * length is unsigned - very bad to do < comparison to -1
* without casting it to int first!! -mer 8 Jan 1991 * without casting it to int first!! -mer 8 Jan 1991
*/ */
if (((int) length) <= -1) if (((int) length) <= -1)
length = VARSIZE(s); length = VARSIZE(s);
sprintf(buf, " %d [ ", length); appendStringInfo(str, " %d [ ", length);
appendStringInfo(str, buf);
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
sprintf(buf, " %d ", (int) (s[i])); appendStringInfo(str, " %d ", (int) (s[i]));
appendStringInfo(str, buf);
} }
sprintf(buf, "] "); appendStringInfo(str, "] ");
appendStringInfo(str, buf);
} }
} }
} }
@ -1244,42 +1204,26 @@ _outDatum(StringInfo str, Datum value, Oid type)
static void static void
_outIter(StringInfo str, Iter *node) _outIter(StringInfo str, Iter *node)
{ {
appendStringInfo(str, " ITER "); appendStringInfo(str, " ITER :iterexpr ");
appendStringInfo(str, " :iterexpr ");
_outNode(str, node->iterexpr); _outNode(str, node->iterexpr);
} }
static void static void
_outStream(StringInfo str, Stream *node) _outStream(StringInfo str, Stream *node)
{ {
char buf[500]; appendStringInfo(str,
" STREAM :pathptr @ 0x%x :cinfo @ 0x%x :clausetype %d :upstream @ 0x%x ",
(int) node->pathptr,
(int) node->cinfo,
(int) node->clausetype,
(int) node->upstream);
appendStringInfo(str, " STREAM "); appendStringInfo(str,
" :downstream @ 0x%x :groupup %d :groupcost %f :groupsel %f ",
sprintf(buf, " :pathptr @ 0x%x ", (int) (node->pathptr)); (int) node->downstream,
appendStringInfo(str, buf); node->groupup,
node->groupcost,
sprintf(buf, " :cinfo @ 0x%x ", (int) (node->cinfo)); node->groupsel);
appendStringInfo(str, buf);
sprintf(buf, " :clausetype %d ", (int) (node->clausetype));
appendStringInfo(str, buf);
sprintf(buf, " :upstream @ 0x%x ", (int) (node->upstream));
appendStringInfo(str, buf);
sprintf(buf, " :downstream @ 0x%x ", (int) (node->downstream));
appendStringInfo(str, buf);
sprintf(buf, " :groupup %d ", node->groupup);
appendStringInfo(str, buf);
sprintf(buf, " :groupcost %f ", node->groupcost);
appendStringInfo(str, buf);
sprintf(buf, " :groupsel %f ", node->groupsel);
appendStringInfo(str, buf);
} }
static void static void
@ -1322,8 +1266,7 @@ _outValue(StringInfo str, Value *value)
switch (value->type) switch (value->type)
{ {
case T_String: case T_String:
appendStringInfo(str, " \"%s\" ", appendStringInfo(str, " \"%s\" ", stringStringInfo(value->val.str));
stringStringInfo(value->val.str));
break; break;
case T_Integer: case T_Integer:
appendStringInfo(str, " %ld ", value->val.ival); appendStringInfo(str, " %ld ", value->val.ival);
@ -1355,8 +1298,7 @@ _outAConst(StringInfo str, A_Const *node)
static void static void
_outConstraint(StringInfo str, Constraint *node) _outConstraint(StringInfo str, Constraint *node)
{ {
appendStringInfo(str," %s :type", appendStringInfo(str," %s :type", stringStringInfo(node->name));
stringStringInfo(node->name));
switch (node->contype) switch (node->contype)
{ {
@ -1366,13 +1308,11 @@ _outConstraint(StringInfo str, Constraint *node)
break; break;
case CONSTR_CHECK: case CONSTR_CHECK:
appendStringInfo(str, " CHECK %s", appendStringInfo(str, " CHECK %s", stringStringInfo(node->def));
stringStringInfo(node->def));
break; break;
case CONSTR_DEFAULT: case CONSTR_DEFAULT:
appendStringInfo(str, " DEFAULT %s", appendStringInfo(str, " DEFAULT %s", stringStringInfo(node->def));
stringStringInfo(node->def));
break; break;
case CONSTR_NOTNULL: case CONSTR_NOTNULL:
@ -1396,8 +1336,10 @@ _outCaseExpr(StringInfo str, CaseExpr *node)
{ {
appendStringInfo(str, "CASE "); appendStringInfo(str, "CASE ");
_outNode(str, node->args); _outNode(str, node->args);
appendStringInfo(str, " :default "); appendStringInfo(str, " :default ");
_outNode(str, node->defresult); _outNode(str, node->defresult);
return; return;
} }
@ -1406,8 +1348,10 @@ _outCaseWhen(StringInfo str, CaseWhen *node)
{ {
appendStringInfo(str, " WHEN "); appendStringInfo(str, " WHEN ");
_outNode(str, node->expr); _outNode(str, node->expr);
appendStringInfo(str, " :then "); appendStringInfo(str, " :then ");
_outNode(str, node->result); _outNode(str, node->result);
return; return;
} }