5
5
*
6
6
* Copyright (c) 1994, Regents of the University of California
7
7
*
8
- * $Id: outfuncs.c,v 1.56 1998/12/17 13:09:52 scrappy Exp $
8
+ * $Id: outfuncs.c,v 1.57 1998/12/18 14:45:08 wieck Exp $
9
9
*
10
10
* NOTES
11
11
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -69,7 +69,8 @@ _outIntList(StringInfo str, List *list)
69
69
static void
70
70
_outCreateStmt (StringInfo str , CreateStmt * node )
71
71
{
72
- appendStringInfo (str , " CREATE :relname %s :columns " , node -> relname );
72
+ appendStringInfo (str , " CREATE :relname %s :columns " ,
73
+ stringStringInfo (node -> relname ));
73
74
74
75
_outNode (str , node -> tableElts );
75
76
appendStringInfo (str , " :inhRelnames " );
@@ -83,7 +84,9 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
83
84
{
84
85
appendStringInfo (str ,
85
86
" INDEX :idxname %s :relname %s :accessMethod %s :indexParams " ,
86
- node -> idxname , node -> relname , node -> accessMethod );
87
+ stringStringInfo (node -> idxname ),
88
+ stringStringInfo (node -> relname ),
89
+ stringStringInfo (node -> accessMethod ));
87
90
88
91
_outNode (str , node -> indexParams );
89
92
appendStringInfo (str , " :withClause " );
@@ -109,7 +112,8 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
109
112
static void
110
113
_outFuncCall (StringInfo str , FuncCall * node )
111
114
{
112
- appendStringInfo (str , "FUNCTION %s :args " , node -> funcname );
115
+ appendStringInfo (str , "FUNCTION %s :args " ,
116
+ stringStringInfo (node -> funcname ));
113
117
_outNode (str , node -> args );
114
118
}
115
119
@@ -118,11 +122,13 @@ _outFuncCall(StringInfo str, FuncCall *node)
118
122
static void
119
123
_outColumnDef (StringInfo str , ColumnDef * node )
120
124
{
121
- appendStringInfo (str , " COLUMNDEF :colname %s :typename " , node -> colname );
125
+ appendStringInfo (str , " COLUMNDEF :colname %s :typename " ,
126
+ stringStringInfo (node -> colname ));
122
127
_outNode (str , node -> typename );
123
128
124
129
appendStringInfo (str , " :is_not_null %s :defval %s :constraints " ,
125
- node -> is_not_null ? "true" : "false" , node -> defval );
130
+ node -> is_not_null ? "true" : "false" ,
131
+ stringStringInfo (node -> defval ));
126
132
_outNode (str , node -> constraints );
127
133
}
128
134
@@ -131,7 +137,7 @@ _outTypeName(StringInfo str, TypeName *node)
131
137
{
132
138
appendStringInfo (str ,
133
139
" TYPENAME :name %s :timezone %s :setof %s typmod %d :arrayBounds " ,
134
- node -> name ,
140
+ stringStringInfo ( node -> name ) ,
135
141
node -> timezone ? "true" : "false" ,
136
142
node -> setof ? "true" : "false" ,
137
143
node -> typmod );
@@ -143,10 +149,12 @@ _outTypeName(StringInfo str, TypeName *node)
143
149
static void
144
150
_outIndexElem (StringInfo str , IndexElem * node )
145
151
{
146
- appendStringInfo (str , " INDEXELEM :name %s :args " , node -> name );
152
+ appendStringInfo (str , " INDEXELEM :name %s :args " ,
153
+ stringStringInfo (node -> name ));
147
154
_outNode (str , node -> args );
148
155
149
- appendStringInfo (str , " :class %s :typename " , node -> class );
156
+ appendStringInfo (str , " :class %s :typename " ,
157
+ stringStringInfo (node -> class ));
150
158
_outNode (str , node -> typename );
151
159
}
152
160
@@ -161,20 +169,20 @@ _outQuery(StringInfo str, Query *node)
161
169
{
162
170
case T_CreateStmt :
163
171
appendStringInfo (str , " :create %s " ,
164
- (( CreateStmt * ) (node -> utilityStmt ))-> relname );
172
+ stringStringInfo ((( CreateStmt * ) (node -> utilityStmt ))-> relname ) );
165
173
_outNode (str , node -> utilityStmt );
166
174
break ;
167
175
168
176
case T_IndexStmt :
169
177
appendStringInfo (str , " :index %s on %s " ,
170
- (( IndexStmt * ) (node -> utilityStmt ))-> idxname ,
171
- (( IndexStmt * ) (node -> utilityStmt ))-> relname );
178
+ stringStringInfo ((( IndexStmt * ) (node -> utilityStmt ))-> idxname ) ,
179
+ stringStringInfo ((( IndexStmt * ) (node -> utilityStmt ))-> relname ) );
172
180
_outNode (str , node -> utilityStmt );
173
181
break ;
174
182
175
183
case T_NotifyStmt :
176
184
appendStringInfo (str , " :utility %s " ,
177
- (( NotifyStmt * ) (node -> utilityStmt ))-> relname );
185
+ stringStringInfo ((( NotifyStmt * ) (node -> utilityStmt ))-> relname ) );
178
186
break ;
179
187
180
188
default :
@@ -183,18 +191,19 @@ _outQuery(StringInfo str, Query *node)
183
191
}
184
192
else
185
193
{
186
- appendStringInfo (str , " :utility %s" , NULL );
194
+ appendStringInfo (str , " :utility <>" );
187
195
}
188
196
189
197
appendStringInfo (str ,
190
198
" :resultRelation %d :into %s :isPortal %s :isBinary %s :unionall %s " ,
191
199
node -> resultRelation ,
192
- node -> into ,
200
+ stringStringInfo ( node -> into ) ,
193
201
node -> isPortal ? "true" : "false" ,
194
202
node -> isBinary ? "true" : "false" ,
195
203
node -> unionall ? "true" : "false" );
196
204
197
- appendStringInfo (str , " :unique %s :sortClause " , node -> uniqueFlag );
205
+ appendStringInfo (str , " :unique %s :sortClause " ,
206
+ stringStringInfo (node -> uniqueFlag ));
198
207
_outNode (str , node -> sortClause );
199
208
200
209
appendStringInfo (str , " :rtable " );
@@ -563,7 +572,7 @@ _outResdom(StringInfo str, Resdom *node)
563
572
node -> restypmod );
564
573
565
574
appendStringInfo (str , " :resname \"%s\" :reskey %d :reskeyop %u :resjunk %d" ,
566
- node -> resname ,
575
+ stringStringInfo ( node -> resname ) ,
567
576
node -> reskey ,
568
577
node -> reskeyop ,
569
578
node -> resjunk );
@@ -620,7 +629,7 @@ _outExpr(StringInfo str, Expr *node)
620
629
opstr = "subp" ;
621
630
break ;
622
631
}
623
- appendStringInfo (str , " :opType %s :oper " , opstr );
632
+ appendStringInfo (str , " :opType %s :oper " , stringStringInfo ( opstr ) );
624
633
_outNode (str , node -> oper );
625
634
626
635
appendStringInfo (str , " :args " );
@@ -675,7 +684,7 @@ _outAggreg(StringInfo str, Aggreg *node)
675
684
{
676
685
appendStringInfo (str ,
677
686
" AGGREG :aggname %s :basetype %u :aggtype %u :target " ,
678
- node -> aggname ,
687
+ stringStringInfo ( node -> aggname ) ,
679
688
node -> basetype ,
680
689
node -> aggtype );
681
690
_outNode (str , node -> target );
@@ -802,7 +811,7 @@ _outParam(StringInfo str, Param *node)
802
811
" PARAM :paramkind %d :paramid %d :paramname %s :paramtype %u " ,
803
812
node -> paramkind ,
804
813
node -> paramid ,
805
- node -> paramname ,
814
+ stringStringInfo ( node -> paramname ) ,
806
815
node -> paramtype );
807
816
808
817
appendStringInfo (str , " :param_tlist " );
@@ -887,8 +896,8 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
887
896
{
888
897
appendStringInfo (str ,
889
898
" RTE :relname %s :refname %s :relid %u :inh %s :inFromCl %s :skipAcl %s" ,
890
- node -> relname ,
891
- node -> refname ,
899
+ stringStringInfo ( node -> relname ) ,
900
+ stringStringInfo ( node -> refname ) ,
892
901
node -> relid ,
893
902
node -> inh ? "true" : "false" ,
894
903
node -> inFromCl ? "true" : "false" ,
@@ -1297,7 +1306,7 @@ _outAExpr(StringInfo str, A_Expr *node)
1297
1306
break ;
1298
1307
default :
1299
1308
#endif
1300
- appendStringInfo (str , node -> opname );
1309
+ appendStringInfo (str , stringStringInfo ( node -> opname ) );
1301
1310
#ifdef PARSEDEBUG
1302
1311
break ;
1303
1312
}
@@ -1310,21 +1319,17 @@ _outAExpr(StringInfo str, A_Expr *node)
1310
1319
static void
1311
1320
_outValue (StringInfo str , Value * value )
1312
1321
{
1313
- char buf [500 ];
1314
-
1315
1322
switch (value -> type )
1316
1323
{
1317
1324
case T_String :
1318
- sprintf ( buf , " \"%s\" " , value -> val . str );
1319
- appendStringInfo ( str , buf );
1325
+ appendStringInfo ( str , " \"%s\" " ,
1326
+ stringStringInfo ( value -> val . str ) );
1320
1327
break ;
1321
1328
case T_Integer :
1322
- sprintf (buf , " %ld " , value -> val .ival );
1323
- appendStringInfo (str , buf );
1329
+ appendStringInfo (str , " %ld " , value -> val .ival );
1324
1330
break ;
1325
1331
case T_Float :
1326
- sprintf (buf , " %f " , value -> val .dval );
1327
- appendStringInfo (str , buf );
1332
+ appendStringInfo (str , " %f " , value -> val .dval );
1328
1333
break ;
1329
1334
default :
1330
1335
break ;
@@ -1335,67 +1340,52 @@ _outValue(StringInfo str, Value *value)
1335
1340
static void
1336
1341
_outIdent (StringInfo str , Ident * node )
1337
1342
{
1338
- char buf [500 ];
1339
-
1340
- sprintf (buf , " IDENT \"%s\" " , node -> name );
1341
- appendStringInfo (str , buf );
1343
+ appendStringInfo (str , " IDENT \"%s\" " , stringStringInfo (node -> name ));
1342
1344
return ;
1343
1345
}
1344
1346
1345
1347
static void
1346
1348
_outAConst (StringInfo str , A_Const * node )
1347
1349
{
1348
- char buf [500 ];
1349
-
1350
- sprintf (buf , "CONST " );
1351
- appendStringInfo (str , buf );
1350
+ appendStringInfo (str , "CONST " );
1352
1351
_outValue (str , & (node -> val ));
1353
1352
return ;
1354
1353
}
1355
1354
1356
1355
static void
1357
1356
_outConstraint (StringInfo str , Constraint * node )
1358
1357
{
1359
- char buf [500 ];
1360
-
1361
- sprintf (buf ," %s :type" ,
1362
- ((node -> name != NULL )? node -> name : "<>" ));
1363
- appendStringInfo (str , buf );
1358
+ appendStringInfo (str ," %s :type" ,
1359
+ stringStringInfo (node -> name ));
1364
1360
1365
1361
switch (node -> contype )
1366
1362
{
1367
1363
case CONSTR_PRIMARY :
1368
- sprintf (buf ," PRIMARY KEY " );
1369
- appendStringInfo (str , buf );
1364
+ appendStringInfo (str , " PRIMARY KEY " );
1370
1365
_outNode (str , node -> keys );
1371
1366
break ;
1372
1367
1373
1368
case CONSTR_CHECK :
1374
- sprintf (buf ," CHECK " );
1375
- appendStringInfo (str , buf );
1376
- appendStringInfo (str , node -> def );
1369
+ appendStringInfo (str , " CHECK %s" ,
1370
+ stringStringInfo (node -> def ));
1377
1371
break ;
1378
1372
1379
1373
case CONSTR_DEFAULT :
1380
- sprintf (buf ," DEFAULT " );
1381
- appendStringInfo (str , buf );
1382
- appendStringInfo (str , node -> def );
1374
+ appendStringInfo (str , " DEFAULT %s" ,
1375
+ stringStringInfo (node -> def ));
1383
1376
break ;
1384
1377
1385
1378
case CONSTR_NOTNULL :
1386
- sprintf (buf ," NOT NULL " );
1387
- appendStringInfo (str , buf );
1379
+ appendStringInfo (str , " NOT NULL " );
1388
1380
break ;
1389
1381
1390
1382
case CONSTR_UNIQUE :
1391
- sprintf (buf ," UNIQUE " );
1392
- appendStringInfo (str , buf );
1383
+ appendStringInfo (str , " UNIQUE " );
1393
1384
_outNode (str , node -> keys );
1394
1385
break ;
1395
1386
1396
1387
default :
1397
- sprintf (buf ,"<unrecognized constraint>" );
1398
- appendStringInfo (str , buf );
1388
+ appendStringInfo (str , "<unrecognized constraint>" );
1399
1389
break ;
1400
1390
}
1401
1391
return ;
@@ -1404,27 +1394,19 @@ _outConstraint(StringInfo str, Constraint *node)
1404
1394
static void
1405
1395
_outCaseExpr (StringInfo str , CaseExpr * node )
1406
1396
{
1407
- char buf [500 ];
1408
-
1409
- sprintf (buf , "CASE " );
1410
- appendStringInfo (str , buf );
1397
+ appendStringInfo (str , "CASE " );
1411
1398
_outNode (str , node -> args );
1412
- sprintf (buf , " :default " );
1413
- appendStringInfo (str , buf );
1399
+ appendStringInfo (str , " :default " );
1414
1400
_outNode (str , node -> defresult );
1415
1401
return ;
1416
1402
}
1417
1403
1418
1404
static void
1419
1405
_outCaseWhen (StringInfo str , CaseWhen * node )
1420
1406
{
1421
- char buf [500 ];
1422
-
1423
- sprintf (buf , " WHEN " );
1424
- appendStringInfo (str , buf );
1407
+ appendStringInfo (str , " WHEN " );
1425
1408
_outNode (str , node -> expr );
1426
- sprintf (buf , " :then " );
1427
- appendStringInfo (str , buf );
1409
+ appendStringInfo (str , " :then " );
1428
1410
_outNode (str , node -> result );
1429
1411
return ;
1430
1412
}
0 commit comments