*
* 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
* Every (plan) node in POSTGRES has an associated "out" routine which
{
appendStringInfo(str, " CREATE :relname %s :columns ",
stringStringInfo(node->relname));
-
_outNode(str, node->tableElts);
+
appendStringInfo(str, " :inhRelnames ");
_outNode(str, node->inhRelnames);
+
appendStringInfo(str, " :constraints ");
_outNode(str, node->constraints);
}
stringStringInfo(node->idxname),
stringStringInfo(node->relname),
stringStringInfo(node->accessMethod));
-
_outNode(str, node->indexParams);
+
appendStringInfo(str, " :withClause ");
_outNode(str, node->withClause);
+
appendStringInfo(str, " :whereClause ");
_outNode(str, node->whereClause);
+
appendStringInfo(str, " :rangetable ");
_outNode(str, node->rangetable);
static void
_outFuncCall(StringInfo str, FuncCall *node)
{
- appendStringInfo(str, "FUNCTION %s :args ",
- stringStringInfo(node->funcname));
+ appendStringInfo(str, "FUNCTION %s :args ", stringStringInfo(node->funcname));
_outNode(str, node->args);
}
stringStringInfo(node->name));
_outNode(str, node->args);
- appendStringInfo(str, " :class %s :typename ",
- stringStringInfo(node->class));
+ appendStringInfo(str, " :class %s :typename ", stringStringInfo(node->class));
_outNode(str, node->typename);
}
node->arrayelemlength,
node->arrayelembyval ? 't' : 'f');
- appendStringInfo(str, " :arrayndim %d ", node->arrayndim);
- appendStringInfo(str, " :arraylow ");
+ appendStringInfo(str, " :arrayndim %d :arraylow ", node->arrayndim);
for (i = 0; i < node->arrayndim; i++)
{
appendStringInfo(str, " %d ", node->arraylow.indx[i]);
static void
_outJoinKey(StringInfo str, JoinKey *node)
{
- appendStringInfo(str, " JOINKEY ");
-
- appendStringInfo(str, " :outer ");
+ appendStringInfo(str, " JOINKEY :outer ");
_outNode(str, node->outer);
appendStringInfo(str, " :inner ");
static void
_outMergeOrder(StringInfo str, MergeOrder *node)
{
- char buf[500];
-
- appendStringInfo(str, " MERGEORDER ");
-
- sprintf(buf, " :join_operator %d ", node->join_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,
+ " MERGEORDER :join_operator %d :left_operator %d :right_operator %d ",
+ node->join_operator,
+ node->left_operator,
+ node->right_operator);
+ appendStringInfo(str,
+ " :left_type %d :right_type %d ",
+ node->left_type,
+ node->right_type);
}
/*
static void
_outClauseInfo(StringInfo str, ClauseInfo * node)
{
- char buf[500];
-
- appendStringInfo(str, " CINFO ");
-
- appendStringInfo(str, " :clause ");
+ appendStringInfo(str, " CINFO :clause ");
_outNode(str, node->clause);
- sprintf(buf, " :selectivity %f ", node->selectivity);
- appendStringInfo(str, buf);
- appendStringInfo(str, " :notclause ");
- appendStringInfo(str, node->notclause ? "true" : "false");
-
- appendStringInfo(str, " :indexids ");
+ appendStringInfo(str,
+ " :selectivity %f :notclause %s :indexids ",
+ node->selectivity,
+ node->notclause ? "true" : "false");
_outNode(str, node->indexids);
appendStringInfo(str, " :mergejoinorder ");
_outNode(str, node->mergejoinorder);
- sprintf(buf, " :hashjoinoperator %u ", node->hashjoinoperator);
- appendStringInfo(str, buf);
+ appendStringInfo(str, " :hashjoinoperator %u ", node->hashjoinoperator);
}
static void
_outJoinMethod(StringInfo str, JoinMethod *node)
{
- appendStringInfo(str, " JOINMETHOD ");
-
- appendStringInfo(str, " :jmkeys ");
+ appendStringInfo(str, " JOINMETHOD :jmkeys ");
_outNode(str, node->jmkeys);
appendStringInfo(str, " :clauses ");
_outNode(str, node->clauses);
-
-
}
/*
static void
_outHInfo(StringInfo str, HInfo *node)
{
- char buf[500];
-
- appendStringInfo(str, " HASHINFO ");
-
- appendStringInfo(str, " :hashop ");
- sprintf(buf, " %u ", node->hashop);
- appendStringInfo(str, buf);
-
- appendStringInfo(str, " :jmkeys ");
+ appendStringInfo(str, " HASHINFO :hashop %u :jmkeys ", node->hashop);
_outNode(str, node->jmethod.jmkeys);
appendStringInfo(str, " :clauses ");
_outNode(str, node->jmethod.clauses);
-
}
/*
static void
_outJoinInfo(StringInfo str, JoinInfo * node)
{
- appendStringInfo(str, " JINFO ");
-
- appendStringInfo(str, " :otherrels ");
+ appendStringInfo(str, " JINFO :otherrels ");
_outIntList(str, node->otherrels);
appendStringInfo(str, " :jinfoclauseinfo ");
_outNode(str, node->jinfoclauseinfo);
- appendStringInfo(str, " :mergejoinable ");
- appendStringInfo(str, node->mergejoinable ? "true" : "false");
- appendStringInfo(str, " :hashjoinable ");
- appendStringInfo(str, node->hashjoinable ? "true" : "false");
-
+ appendStringInfo(str, " :mergejoinable %s :hashjoinable %s ",
+ node->mergejoinable ? "true" : "false",
+ node->hashjoinable ? "true" : "false");
}
/*
static void
_outDatum(StringInfo str, Datum value, Oid type)
{
- char buf[500];
+ char *s;
Size length,
- typeLength;
+ typeLength;
bool byValue;
int i;
- char *s;
/*
* find some information about the type and the "real" length of the
if (byValue)
{
s = (char *) (&value);
- sprintf(buf, " %d [ ", length);
- appendStringInfo(str, buf);
+ appendStringInfo(str, " %d [ ", length);
for (i = 0; i < sizeof(Datum); i++)
{
- sprintf(buf, " %d ", (int) (s[i]));
- appendStringInfo(str, buf);
+ appendStringInfo(str, " %d ", (int) (s[i]));
}
- sprintf(buf, "] ");
- appendStringInfo(str, buf);
+ appendStringInfo(str, "] ");
}
else
{ /* !byValue */
s = (char *) DatumGetPointer(value);
if (!PointerIsValid(s))
{
- sprintf(buf, " 0 [ ] ");
- appendStringInfo(str, buf);
+ appendStringInfo(str, " 0 [ ] ");
}
else
{
-
/*
* length is unsigned - very bad to do < comparison to -1
* without casting it to int first!! -mer 8 Jan 1991
*/
if (((int) length) <= -1)
length = VARSIZE(s);
- sprintf(buf, " %d [ ", length);
- appendStringInfo(str, buf);
+ appendStringInfo(str, " %d [ ", length);
for (i = 0; i < length; i++)
{
- sprintf(buf, " %d ", (int) (s[i]));
- appendStringInfo(str, buf);
+ appendStringInfo(str, " %d ", (int) (s[i]));
}
- sprintf(buf, "] ");
- appendStringInfo(str, buf);
+ appendStringInfo(str, "] ");
}
}
}
static void
_outIter(StringInfo str, Iter *node)
{
- appendStringInfo(str, " ITER ");
-
- appendStringInfo(str, " :iterexpr ");
+ appendStringInfo(str, " ITER :iterexpr ");
_outNode(str, node->iterexpr);
}
static void
_outStream(StringInfo str, Stream *node)
{
- char buf[500];
-
- appendStringInfo(str, " STREAM ");
-
- sprintf(buf, " :pathptr @ 0x%x ", (int) (node->pathptr));
- appendStringInfo(str, buf);
-
- sprintf(buf, " :cinfo @ 0x%x ", (int) (node->cinfo));
- 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);
+ 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);
- sprintf(buf, " :groupsel %f ", node->groupsel);
- appendStringInfo(str, buf);
+ appendStringInfo(str,
+ " :downstream @ 0x%x :groupup %d :groupcost %f :groupsel %f ",
+ (int) node->downstream,
+ node->groupup,
+ node->groupcost,
+ node->groupsel);
}
static void
switch (value->type)
{
case T_String:
- appendStringInfo(str, " \"%s\" ",
- stringStringInfo(value->val.str));
+ appendStringInfo(str, " \"%s\" ", stringStringInfo(value->val.str));
break;
case T_Integer:
appendStringInfo(str, " %ld ", value->val.ival);
static void
_outConstraint(StringInfo str, Constraint *node)
{
- appendStringInfo(str," %s :type",
- stringStringInfo(node->name));
+ appendStringInfo(str," %s :type", stringStringInfo(node->name));
switch (node->contype)
{
break;
case CONSTR_CHECK:
- appendStringInfo(str, " CHECK %s",
- stringStringInfo(node->def));
+ appendStringInfo(str, " CHECK %s", stringStringInfo(node->def));
break;
case CONSTR_DEFAULT:
- appendStringInfo(str, " DEFAULT %s",
- stringStringInfo(node->def));
+ appendStringInfo(str, " DEFAULT %s", stringStringInfo(node->def));
break;
case CONSTR_NOTNULL:
{
appendStringInfo(str, "CASE ");
_outNode(str, node->args);
+
appendStringInfo(str, " :default ");
_outNode(str, node->defresult);
+
return;
}
{
appendStringInfo(str, " WHEN ");
_outNode(str, node->expr);
+
appendStringInfo(str, " :then ");
_outNode(str, node->result);
+
return;
}