5
5
*
6
6
* Copyright (c) 1994, Regents of the University of California
7
7
*
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 $
9
9
*
10
10
* NOTES
11
11
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -71,10 +71,11 @@ _outCreateStmt(StringInfo str, CreateStmt *node)
71
71
{
72
72
appendStringInfo (str , " CREATE :relname %s :columns " ,
73
73
stringStringInfo (node -> relname ));
74
-
75
74
_outNode (str , node -> tableElts );
75
+
76
76
appendStringInfo (str , " :inhRelnames " );
77
77
_outNode (str , node -> inhRelnames );
78
+
78
79
appendStringInfo (str , " :constraints " );
79
80
_outNode (str , node -> constraints );
80
81
}
@@ -87,12 +88,14 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
87
88
stringStringInfo (node -> idxname ),
88
89
stringStringInfo (node -> relname ),
89
90
stringStringInfo (node -> accessMethod ));
90
-
91
91
_outNode (str , node -> indexParams );
92
+
92
93
appendStringInfo (str , " :withClause " );
93
94
_outNode (str , node -> withClause );
95
+
94
96
appendStringInfo (str , " :whereClause " );
95
97
_outNode (str , node -> whereClause );
98
+
96
99
appendStringInfo (str , " :rangetable " );
97
100
_outNode (str , node -> rangetable );
98
101
@@ -112,8 +115,7 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
112
115
static void
113
116
_outFuncCall (StringInfo str , FuncCall * node )
114
117
{
115
- appendStringInfo (str , "FUNCTION %s :args " ,
116
- stringStringInfo (node -> funcname ));
118
+ appendStringInfo (str , "FUNCTION %s :args " , stringStringInfo (node -> funcname ));
117
119
_outNode (str , node -> args );
118
120
}
119
121
@@ -153,8 +155,7 @@ _outIndexElem(StringInfo str, IndexElem *node)
153
155
stringStringInfo (node -> name ));
154
156
_outNode (str , node -> args );
155
157
156
- appendStringInfo (str , " :class %s :typename " ,
157
- stringStringInfo (node -> class ));
158
+ appendStringInfo (str , " :class %s :typename " , stringStringInfo (node -> class ));
158
159
_outNode (str , node -> typename );
159
160
}
160
161
@@ -727,8 +728,7 @@ _outArray(StringInfo str, Array *node)
727
728
node -> arrayelemlength ,
728
729
node -> arrayelembyval ? 't' : 'f' );
729
730
730
- appendStringInfo (str , " :arrayndim %d " , node -> arrayndim );
731
- appendStringInfo (str , " :arraylow " );
731
+ appendStringInfo (str , " :arrayndim %d :arraylow " , node -> arrayndim );
732
732
for (i = 0 ; i < node -> arrayndim ; i ++ )
733
733
{
734
734
appendStringInfo (str , " %d " , node -> arraylow .indx [i ]);
@@ -1055,9 +1055,7 @@ _outOrderKey(StringInfo str, OrderKey *node)
1055
1055
static void
1056
1056
_outJoinKey (StringInfo str , JoinKey * node )
1057
1057
{
1058
- appendStringInfo (str , " JOINKEY " );
1059
-
1060
- appendStringInfo (str , " :outer " );
1058
+ appendStringInfo (str , " JOINKEY :outer " );
1061
1059
_outNode (str , node -> outer );
1062
1060
1063
1061
appendStringInfo (str , " :inner " );
@@ -1071,21 +1069,16 @@ _outJoinKey(StringInfo str, JoinKey *node)
1071
1069
static void
1072
1070
_outMergeOrder (StringInfo str , MergeOrder * node )
1073
1071
{
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 );
1088
1077
1078
+ appendStringInfo (str ,
1079
+ " :left_type %d :right_type %d " ,
1080
+ node -> left_type ,
1081
+ node -> right_type );
1089
1082
}
1090
1083
1091
1084
/*
@@ -1094,26 +1087,19 @@ _outMergeOrder(StringInfo str, MergeOrder *node)
1094
1087
static void
1095
1088
_outClauseInfo (StringInfo str , ClauseInfo * node )
1096
1089
{
1097
- char buf [500 ];
1098
-
1099
- appendStringInfo (str , " CINFO " );
1100
-
1101
- appendStringInfo (str , " :clause " );
1090
+ appendStringInfo (str , " CINFO :clause " );
1102
1091
_outNode (str , node -> clause );
1103
1092
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" );
1110
1097
_outNode (str , node -> indexids );
1111
1098
1112
1099
appendStringInfo (str , " :mergejoinorder " );
1113
1100
_outNode (str , node -> mergejoinorder );
1114
1101
1115
- sprintf (buf , " :hashjoinoperator %u " , node -> hashjoinoperator );
1116
- appendStringInfo (str , buf );
1102
+ appendStringInfo (str , " :hashjoinoperator %u " , node -> hashjoinoperator );
1117
1103
1118
1104
}
1119
1105
@@ -1123,15 +1109,11 @@ _outClauseInfo(StringInfo str, ClauseInfo * node)
1123
1109
static void
1124
1110
_outJoinMethod (StringInfo str , JoinMethod * node )
1125
1111
{
1126
- appendStringInfo (str , " JOINMETHOD " );
1127
-
1128
- appendStringInfo (str , " :jmkeys " );
1112
+ appendStringInfo (str , " JOINMETHOD :jmkeys " );
1129
1113
_outNode (str , node -> jmkeys );
1130
1114
1131
1115
appendStringInfo (str , " :clauses " );
1132
1116
_outNode (str , node -> clauses );
1133
-
1134
-
1135
1117
}
1136
1118
1137
1119
/*
@@ -1140,20 +1122,11 @@ _outJoinMethod(StringInfo str, JoinMethod *node)
1140
1122
static void
1141
1123
_outHInfo (StringInfo str , HInfo * node )
1142
1124
{
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 );
1152
1126
_outNode (str , node -> jmethod .jmkeys );
1153
1127
1154
1128
appendStringInfo (str , " :clauses " );
1155
1129
_outNode (str , node -> jmethod .clauses );
1156
-
1157
1130
}
1158
1131
1159
1132
/*
@@ -1162,19 +1135,15 @@ _outHInfo(StringInfo str, HInfo *node)
1162
1135
static void
1163
1136
_outJoinInfo (StringInfo str , JoinInfo * node )
1164
1137
{
1165
- appendStringInfo (str , " JINFO " );
1166
-
1167
- appendStringInfo (str , " :otherrels " );
1138
+ appendStringInfo (str , " JINFO :otherrels " );
1168
1139
_outIntList (str , node -> otherrels );
1169
1140
1170
1141
appendStringInfo (str , " :jinfoclauseinfo " );
1171
1142
_outNode (str , node -> jinfoclauseinfo );
1172
1143
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" );
1178
1147
}
1179
1148
1180
1149
/*
@@ -1183,12 +1152,11 @@ _outJoinInfo(StringInfo str, JoinInfo * node)
1183
1152
static void
1184
1153
_outDatum (StringInfo str , Datum value , Oid type )
1185
1154
{
1186
- char buf [ 500 ] ;
1155
+ char * s ;
1187
1156
Size length ,
1188
- typeLength ;
1157
+ typeLength ;
1189
1158
bool byValue ;
1190
1159
int i ;
1191
- char * s ;
1192
1160
1193
1161
/*
1194
1162
* find some information about the type and the "real" length of the
@@ -1201,85 +1169,61 @@ _outDatum(StringInfo str, Datum value, Oid type)
1201
1169
if (byValue )
1202
1170
{
1203
1171
s = (char * ) (& value );
1204
- sprintf (buf , " %d [ " , length );
1205
- appendStringInfo (str , buf );
1172
+ appendStringInfo (str , " %d [ " , length );
1206
1173
for (i = 0 ; i < sizeof (Datum ); i ++ )
1207
1174
{
1208
- sprintf (buf , " %d " , (int ) (s [i ]));
1209
- appendStringInfo (str , buf );
1175
+ appendStringInfo (str , " %d " , (int ) (s [i ]));
1210
1176
}
1211
- sprintf (buf , "] " );
1212
- appendStringInfo (str , buf );
1177
+ appendStringInfo (str , "] " );
1213
1178
}
1214
1179
else
1215
1180
{ /* !byValue */
1216
1181
s = (char * ) DatumGetPointer (value );
1217
1182
if (!PointerIsValid (s ))
1218
1183
{
1219
- sprintf (buf , " 0 [ ] " );
1220
- appendStringInfo (str , buf );
1184
+ appendStringInfo (str , " 0 [ ] " );
1221
1185
}
1222
1186
else
1223
1187
{
1224
-
1225
1188
/*
1226
1189
* length is unsigned - very bad to do < comparison to -1
1227
1190
* without casting it to int first!! -mer 8 Jan 1991
1228
1191
*/
1229
1192
if (((int ) length ) <= -1 )
1230
1193
length = VARSIZE (s );
1231
- sprintf (buf , " %d [ " , length );
1232
- appendStringInfo (str , buf );
1194
+ appendStringInfo (str , " %d [ " , length );
1233
1195
for (i = 0 ; i < length ; i ++ )
1234
1196
{
1235
- sprintf (buf , " %d " , (int ) (s [i ]));
1236
- appendStringInfo (str , buf );
1197
+ appendStringInfo (str , " %d " , (int ) (s [i ]));
1237
1198
}
1238
- sprintf (buf , "] " );
1239
- appendStringInfo (str , buf );
1199
+ appendStringInfo (str , "] " );
1240
1200
}
1241
1201
}
1242
1202
}
1243
1203
1244
1204
static void
1245
1205
_outIter (StringInfo str , Iter * node )
1246
1206
{
1247
- appendStringInfo (str , " ITER " );
1248
-
1249
- appendStringInfo (str , " :iterexpr " );
1207
+ appendStringInfo (str , " ITER :iterexpr " );
1250
1208
_outNode (str , node -> iterexpr );
1251
1209
}
1252
1210
1253
1211
static void
1254
1212
_outStream (StringInfo str , Stream * node )
1255
1213
{
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 );
1280
1220
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 );
1283
1227
}
1284
1228
1285
1229
static void
@@ -1322,8 +1266,7 @@ _outValue(StringInfo str, Value *value)
1322
1266
switch (value -> type )
1323
1267
{
1324
1268
case T_String :
1325
- appendStringInfo (str , " \"%s\" " ,
1326
- stringStringInfo (value -> val .str ));
1269
+ appendStringInfo (str , " \"%s\" " , stringStringInfo (value -> val .str ));
1327
1270
break ;
1328
1271
case T_Integer :
1329
1272
appendStringInfo (str , " %ld " , value -> val .ival );
@@ -1355,8 +1298,7 @@ _outAConst(StringInfo str, A_Const *node)
1355
1298
static void
1356
1299
_outConstraint (StringInfo str , Constraint * node )
1357
1300
{
1358
- appendStringInfo (str ," %s :type" ,
1359
- stringStringInfo (node -> name ));
1301
+ appendStringInfo (str ," %s :type" , stringStringInfo (node -> name ));
1360
1302
1361
1303
switch (node -> contype )
1362
1304
{
@@ -1366,13 +1308,11 @@ _outConstraint(StringInfo str, Constraint *node)
1366
1308
break ;
1367
1309
1368
1310
case CONSTR_CHECK :
1369
- appendStringInfo (str , " CHECK %s" ,
1370
- stringStringInfo (node -> def ));
1311
+ appendStringInfo (str , " CHECK %s" , stringStringInfo (node -> def ));
1371
1312
break ;
1372
1313
1373
1314
case CONSTR_DEFAULT :
1374
- appendStringInfo (str , " DEFAULT %s" ,
1375
- stringStringInfo (node -> def ));
1315
+ appendStringInfo (str , " DEFAULT %s" , stringStringInfo (node -> def ));
1376
1316
break ;
1377
1317
1378
1318
case CONSTR_NOTNULL :
@@ -1396,8 +1336,10 @@ _outCaseExpr(StringInfo str, CaseExpr *node)
1396
1336
{
1397
1337
appendStringInfo (str , "CASE " );
1398
1338
_outNode (str , node -> args );
1339
+
1399
1340
appendStringInfo (str , " :default " );
1400
1341
_outNode (str , node -> defresult );
1342
+
1401
1343
return ;
1402
1344
}
1403
1345
@@ -1406,8 +1348,10 @@ _outCaseWhen(StringInfo str, CaseWhen *node)
1406
1348
{
1407
1349
appendStringInfo (str , " WHEN " );
1408
1350
_outNode (str , node -> expr );
1351
+
1409
1352
appendStringInfo (str , " :then " );
1410
1353
_outNode (str , node -> result );
1354
+
1411
1355
return ;
1412
1356
}
1413
1357
0 commit comments