Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1adb6a9

Browse files
committed
finished cleaning up outnodes.c ...
1 parent 3cd3be9 commit 1adb6a9

File tree

1 file changed

+61
-117
lines changed

1 file changed

+61
-117
lines changed

src/backend/nodes/outfuncs.c

Lines changed: 61 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
* Copyright (c) 1994, Regents of the University of California
77
*
8-
* $Id: outfuncs.c,v 1.57 1998/12/18 14:45:08 wieck Exp $
8+
* $Id: outfuncs.c,v 1.58 1998/12/20 07:13:36 scrappy Exp $
99
*
1010
* NOTES
1111
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -71,10 +71,11 @@ _outCreateStmt(StringInfo str, CreateStmt *node)
7171
{
7272
appendStringInfo(str, " CREATE :relname %s :columns ",
7373
stringStringInfo(node->relname));
74-
7574
_outNode(str, node->tableElts);
75+
7676
appendStringInfo(str, " :inhRelnames ");
7777
_outNode(str, node->inhRelnames);
78+
7879
appendStringInfo(str, " :constraints ");
7980
_outNode(str, node->constraints);
8081
}
@@ -87,12 +88,14 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
8788
stringStringInfo(node->idxname),
8889
stringStringInfo(node->relname),
8990
stringStringInfo(node->accessMethod));
90-
9191
_outNode(str, node->indexParams);
92+
9293
appendStringInfo(str, " :withClause ");
9394
_outNode(str, node->withClause);
95+
9496
appendStringInfo(str, " :whereClause ");
9597
_outNode(str, node->whereClause);
98+
9699
appendStringInfo(str, " :rangetable ");
97100
_outNode(str, node->rangetable);
98101

@@ -112,8 +115,7 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
112115
static void
113116
_outFuncCall(StringInfo str, FuncCall *node)
114117
{
115-
appendStringInfo(str, "FUNCTION %s :args ",
116-
stringStringInfo(node->funcname));
118+
appendStringInfo(str, "FUNCTION %s :args ", stringStringInfo(node->funcname));
117119
_outNode(str, node->args);
118120
}
119121

@@ -153,8 +155,7 @@ _outIndexElem(StringInfo str, IndexElem *node)
153155
stringStringInfo(node->name));
154156
_outNode(str, node->args);
155157

156-
appendStringInfo(str, " :class %s :typename ",
157-
stringStringInfo(node->class));
158+
appendStringInfo(str, " :class %s :typename ", stringStringInfo(node->class));
158159
_outNode(str, node->typename);
159160
}
160161

@@ -727,8 +728,7 @@ _outArray(StringInfo str, Array *node)
727728
node->arrayelemlength,
728729
node->arrayelembyval ? 't' : 'f');
729730

730-
appendStringInfo(str, " :arrayndim %d ", node->arrayndim);
731-
appendStringInfo(str, " :arraylow ");
731+
appendStringInfo(str, " :arrayndim %d :arraylow ", node->arrayndim);
732732
for (i = 0; i < node->arrayndim; i++)
733733
{
734734
appendStringInfo(str, " %d ", node->arraylow.indx[i]);
@@ -1055,9 +1055,7 @@ _outOrderKey(StringInfo str, OrderKey *node)
10551055
static void
10561056
_outJoinKey(StringInfo str, JoinKey *node)
10571057
{
1058-
appendStringInfo(str, " JOINKEY ");
1059-
1060-
appendStringInfo(str, " :outer ");
1058+
appendStringInfo(str, " JOINKEY :outer ");
10611059
_outNode(str, node->outer);
10621060

10631061
appendStringInfo(str, " :inner ");
@@ -1071,21 +1069,16 @@ _outJoinKey(StringInfo str, JoinKey *node)
10711069
static void
10721070
_outMergeOrder(StringInfo str, MergeOrder *node)
10731071
{
1074-
char buf[500];
1075-
1076-
appendStringInfo(str, " MERGEORDER ");
1077-
1078-
sprintf(buf, " :join_operator %d ", node->join_operator);
1079-
appendStringInfo(str, buf);
1080-
sprintf(buf, " :left_operator %d ", node->left_operator);
1081-
appendStringInfo(str, buf);
1082-
sprintf(buf, " :right_operator %d ", node->right_operator);
1083-
appendStringInfo(str, buf);
1084-
sprintf(buf, " :left_type %d ", node->left_type);
1085-
appendStringInfo(str, buf);
1086-
sprintf(buf, " :right_type %d ", node->right_type);
1087-
appendStringInfo(str, buf);
1072+
appendStringInfo(str,
1073+
" MERGEORDER :join_operator %d :left_operator %d :right_operator %d ",
1074+
node->join_operator,
1075+
node->left_operator,
1076+
node->right_operator);
10881077

1078+
appendStringInfo(str,
1079+
" :left_type %d :right_type %d ",
1080+
node->left_type,
1081+
node->right_type);
10891082
}
10901083

10911084
/*
@@ -1094,26 +1087,19 @@ _outMergeOrder(StringInfo str, MergeOrder *node)
10941087
static void
10951088
_outClauseInfo(StringInfo str, ClauseInfo * node)
10961089
{
1097-
char buf[500];
1098-
1099-
appendStringInfo(str, " CINFO ");
1100-
1101-
appendStringInfo(str, " :clause ");
1090+
appendStringInfo(str, " CINFO :clause ");
11021091
_outNode(str, node->clause);
11031092

1104-
sprintf(buf, " :selectivity %f ", node->selectivity);
1105-
appendStringInfo(str, buf);
1106-
appendStringInfo(str, " :notclause ");
1107-
appendStringInfo(str, node->notclause ? "true" : "false");
1108-
1109-
appendStringInfo(str, " :indexids ");
1093+
appendStringInfo(str,
1094+
" :selectivity %f :notclause %s :indexids ",
1095+
node->selectivity,
1096+
node->notclause ? "true" : "false");
11101097
_outNode(str, node->indexids);
11111098

11121099
appendStringInfo(str, " :mergejoinorder ");
11131100
_outNode(str, node->mergejoinorder);
11141101

1115-
sprintf(buf, " :hashjoinoperator %u ", node->hashjoinoperator);
1116-
appendStringInfo(str, buf);
1102+
appendStringInfo(str, " :hashjoinoperator %u ", node->hashjoinoperator);
11171103

11181104
}
11191105

@@ -1123,15 +1109,11 @@ _outClauseInfo(StringInfo str, ClauseInfo * node)
11231109
static void
11241110
_outJoinMethod(StringInfo str, JoinMethod *node)
11251111
{
1126-
appendStringInfo(str, " JOINMETHOD ");
1127-
1128-
appendStringInfo(str, " :jmkeys ");
1112+
appendStringInfo(str, " JOINMETHOD :jmkeys ");
11291113
_outNode(str, node->jmkeys);
11301114

11311115
appendStringInfo(str, " :clauses ");
11321116
_outNode(str, node->clauses);
1133-
1134-
11351117
}
11361118

11371119
/*
@@ -1140,20 +1122,11 @@ _outJoinMethod(StringInfo str, JoinMethod *node)
11401122
static void
11411123
_outHInfo(StringInfo str, HInfo *node)
11421124
{
1143-
char buf[500];
1144-
1145-
appendStringInfo(str, " HASHINFO ");
1146-
1147-
appendStringInfo(str, " :hashop ");
1148-
sprintf(buf, " %u ", node->hashop);
1149-
appendStringInfo(str, buf);
1150-
1151-
appendStringInfo(str, " :jmkeys ");
1125+
appendStringInfo(str, " HASHINFO :hashop %u :jmkeys ", node->hashop);
11521126
_outNode(str, node->jmethod.jmkeys);
11531127

11541128
appendStringInfo(str, " :clauses ");
11551129
_outNode(str, node->jmethod.clauses);
1156-
11571130
}
11581131

11591132
/*
@@ -1162,19 +1135,15 @@ _outHInfo(StringInfo str, HInfo *node)
11621135
static void
11631136
_outJoinInfo(StringInfo str, JoinInfo * node)
11641137
{
1165-
appendStringInfo(str, " JINFO ");
1166-
1167-
appendStringInfo(str, " :otherrels ");
1138+
appendStringInfo(str, " JINFO :otherrels ");
11681139
_outIntList(str, node->otherrels);
11691140

11701141
appendStringInfo(str, " :jinfoclauseinfo ");
11711142
_outNode(str, node->jinfoclauseinfo);
11721143

1173-
appendStringInfo(str, " :mergejoinable ");
1174-
appendStringInfo(str, node->mergejoinable ? "true" : "false");
1175-
appendStringInfo(str, " :hashjoinable ");
1176-
appendStringInfo(str, node->hashjoinable ? "true" : "false");
1177-
1144+
appendStringInfo(str, " :mergejoinable %s :hashjoinable %s ",
1145+
node->mergejoinable ? "true" : "false",
1146+
node->hashjoinable ? "true" : "false");
11781147
}
11791148

11801149
/*
@@ -1183,12 +1152,11 @@ _outJoinInfo(StringInfo str, JoinInfo * node)
11831152
static void
11841153
_outDatum(StringInfo str, Datum value, Oid type)
11851154
{
1186-
char buf[500];
1155+
char *s;
11871156
Size length,
1188-
typeLength;
1157+
typeLength;
11891158
bool byValue;
11901159
int i;
1191-
char *s;
11921160

11931161
/*
11941162
* find some information about the type and the "real" length of the
@@ -1201,85 +1169,61 @@ _outDatum(StringInfo str, Datum value, Oid type)
12011169
if (byValue)
12021170
{
12031171
s = (char *) (&value);
1204-
sprintf(buf, " %d [ ", length);
1205-
appendStringInfo(str, buf);
1172+
appendStringInfo(str, " %d [ ", length);
12061173
for (i = 0; i < sizeof(Datum); i++)
12071174
{
1208-
sprintf(buf, " %d ", (int) (s[i]));
1209-
appendStringInfo(str, buf);
1175+
appendStringInfo(str, " %d ", (int) (s[i]));
12101176
}
1211-
sprintf(buf, "] ");
1212-
appendStringInfo(str, buf);
1177+
appendStringInfo(str, "] ");
12131178
}
12141179
else
12151180
{ /* !byValue */
12161181
s = (char *) DatumGetPointer(value);
12171182
if (!PointerIsValid(s))
12181183
{
1219-
sprintf(buf, " 0 [ ] ");
1220-
appendStringInfo(str, buf);
1184+
appendStringInfo(str, " 0 [ ] ");
12211185
}
12221186
else
12231187
{
1224-
12251188
/*
12261189
* length is unsigned - very bad to do < comparison to -1
12271190
* without casting it to int first!! -mer 8 Jan 1991
12281191
*/
12291192
if (((int) length) <= -1)
12301193
length = VARSIZE(s);
1231-
sprintf(buf, " %d [ ", length);
1232-
appendStringInfo(str, buf);
1194+
appendStringInfo(str, " %d [ ", length);
12331195
for (i = 0; i < length; i++)
12341196
{
1235-
sprintf(buf, " %d ", (int) (s[i]));
1236-
appendStringInfo(str, buf);
1197+
appendStringInfo(str, " %d ", (int) (s[i]));
12371198
}
1238-
sprintf(buf, "] ");
1239-
appendStringInfo(str, buf);
1199+
appendStringInfo(str, "] ");
12401200
}
12411201
}
12421202
}
12431203

12441204
static void
12451205
_outIter(StringInfo str, Iter *node)
12461206
{
1247-
appendStringInfo(str, " ITER ");
1248-
1249-
appendStringInfo(str, " :iterexpr ");
1207+
appendStringInfo(str, " ITER :iterexpr ");
12501208
_outNode(str, node->iterexpr);
12511209
}
12521210

12531211
static void
12541212
_outStream(StringInfo str, Stream *node)
12551213
{
1256-
char buf[500];
1257-
1258-
appendStringInfo(str, " STREAM ");
1259-
1260-
sprintf(buf, " :pathptr @ 0x%x ", (int) (node->pathptr));
1261-
appendStringInfo(str, buf);
1262-
1263-
sprintf(buf, " :cinfo @ 0x%x ", (int) (node->cinfo));
1264-
appendStringInfo(str, buf);
1265-
1266-
sprintf(buf, " :clausetype %d ", (int) (node->clausetype));
1267-
appendStringInfo(str, buf);
1268-
1269-
sprintf(buf, " :upstream @ 0x%x ", (int) (node->upstream));
1270-
appendStringInfo(str, buf);
1271-
1272-
sprintf(buf, " :downstream @ 0x%x ", (int) (node->downstream));
1273-
appendStringInfo(str, buf);
1274-
1275-
sprintf(buf, " :groupup %d ", node->groupup);
1276-
appendStringInfo(str, buf);
1277-
1278-
sprintf(buf, " :groupcost %f ", node->groupcost);
1279-
appendStringInfo(str, buf);
1214+
appendStringInfo(str,
1215+
" STREAM :pathptr @ 0x%x :cinfo @ 0x%x :clausetype %d :upstream @ 0x%x ",
1216+
(int) node->pathptr,
1217+
(int) node->cinfo,
1218+
(int) node->clausetype,
1219+
(int) node->upstream);
12801220

1281-
sprintf(buf, " :groupsel %f ", node->groupsel);
1282-
appendStringInfo(str, buf);
1221+
appendStringInfo(str,
1222+
" :downstream @ 0x%x :groupup %d :groupcost %f :groupsel %f ",
1223+
(int) node->downstream,
1224+
node->groupup,
1225+
node->groupcost,
1226+
node->groupsel);
12831227
}
12841228

12851229
static void
@@ -1322,8 +1266,7 @@ _outValue(StringInfo str, Value *value)
13221266
switch (value->type)
13231267
{
13241268
case T_String:
1325-
appendStringInfo(str, " \"%s\" ",
1326-
stringStringInfo(value->val.str));
1269+
appendStringInfo(str, " \"%s\" ", stringStringInfo(value->val.str));
13271270
break;
13281271
case T_Integer:
13291272
appendStringInfo(str, " %ld ", value->val.ival);
@@ -1355,8 +1298,7 @@ _outAConst(StringInfo str, A_Const *node)
13551298
static void
13561299
_outConstraint(StringInfo str, Constraint *node)
13571300
{
1358-
appendStringInfo(str," %s :type",
1359-
stringStringInfo(node->name));
1301+
appendStringInfo(str," %s :type", stringStringInfo(node->name));
13601302

13611303
switch (node->contype)
13621304
{
@@ -1366,13 +1308,11 @@ _outConstraint(StringInfo str, Constraint *node)
13661308
break;
13671309

13681310
case CONSTR_CHECK:
1369-
appendStringInfo(str, " CHECK %s",
1370-
stringStringInfo(node->def));
1311+
appendStringInfo(str, " CHECK %s", stringStringInfo(node->def));
13711312
break;
13721313

13731314
case CONSTR_DEFAULT:
1374-
appendStringInfo(str, " DEFAULT %s",
1375-
stringStringInfo(node->def));
1315+
appendStringInfo(str, " DEFAULT %s", stringStringInfo(node->def));
13761316
break;
13771317

13781318
case CONSTR_NOTNULL:
@@ -1396,8 +1336,10 @@ _outCaseExpr(StringInfo str, CaseExpr *node)
13961336
{
13971337
appendStringInfo(str, "CASE ");
13981338
_outNode(str, node->args);
1339+
13991340
appendStringInfo(str, " :default ");
14001341
_outNode(str, node->defresult);
1342+
14011343
return;
14021344
}
14031345

@@ -1406,8 +1348,10 @@ _outCaseWhen(StringInfo str, CaseWhen *node)
14061348
{
14071349
appendStringInfo(str, " WHEN ");
14081350
_outNode(str, node->expr);
1351+
14091352
appendStringInfo(str, " :then ");
14101353
_outNode(str, node->result);
1354+
14111355
return;
14121356
}
14131357

0 commit comments

Comments
 (0)