Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteeff2c9

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Fixed nodeToString() to put out "<>" for NULL strings again.
More cleanups to appendStringInfo() usage in node/outfuncs.c.Jan
1 parent3498d87 commiteeff2c9

File tree

3 files changed

+66
-78
lines changed

3 files changed

+66
-78
lines changed

‎src/backend/commands/explain.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
* Copyright (c) 1994-5, Regents of the University of California
66
*
7-
* $Id: explain.c,v 1.29 1998/12/14 08:11:00 scrappy Exp $
7+
* $Id: explain.c,v 1.30 1998/12/18 14:45:07 wieck Exp $
88
*
99
*/
1010
#include<stdio.h>
@@ -144,8 +144,7 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
144144
{
145145
List*l;
146146
Relationrelation;
147-
char*pname,
148-
buf[1000];
147+
char*pname;
149148
inti;
150149

151150
if (plan==NULL)
@@ -216,7 +215,8 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
216215
{
217216
appendStringInfo(str,", ");
218217
}
219-
appendStringInfo(str, (RelationGetRelationName(relation))->data);
218+
appendStringInfo(str,
219+
stringStringInfo((RelationGetRelationName(relation))->data));
220220
}
221221
caseT_SeqScan:
222222
if (((Scan*)plan)->scanrelid>0)
@@ -226,10 +226,10 @@ explain_outNode(StringInfo str, Plan *plan, int indent, ExplainState *es)
226226
appendStringInfo(str," on ");
227227
if (strcmp(rte->refname,rte->relname)!=0)
228228
{
229-
snprintf(buf,1000,"%s ",rte->relname);
230-
appendStringInfo(str,buf);
229+
appendStringInfo(str,"%s ",
230+
stringStringInfo(rte->relname));
231231
}
232-
appendStringInfo(str,rte->refname);
232+
appendStringInfo(str,stringStringInfo(rte->refname));
233233
}
234234
break;
235235
default:

‎src/backend/nodes/outfuncs.c

Lines changed: 52 additions & 70 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.56 1998/12/17 13:09:52 scrappy Exp $
8+
* $Id: outfuncs.c,v 1.57 1998/12/18 14:45:08 wieck Exp $
99
*
1010
* NOTES
1111
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -69,7 +69,8 @@ _outIntList(StringInfo str, List *list)
6969
staticvoid
7070
_outCreateStmt(StringInfostr,CreateStmt*node)
7171
{
72-
appendStringInfo(str," CREATE :relname %s :columns ",node->relname);
72+
appendStringInfo(str," CREATE :relname %s :columns ",
73+
stringStringInfo(node->relname));
7374

7475
_outNode(str,node->tableElts);
7576
appendStringInfo(str," :inhRelnames ");
@@ -83,7 +84,9 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
8384
{
8485
appendStringInfo(str,
8586
" 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));
8790

8891
_outNode(str,node->indexParams);
8992
appendStringInfo(str," :withClause ");
@@ -109,7 +112,8 @@ _outSelectStmt(StringInfo str, SelectStmt *node)
109112
staticvoid
110113
_outFuncCall(StringInfostr,FuncCall*node)
111114
{
112-
appendStringInfo(str,"FUNCTION %s :args ",node->funcname);
115+
appendStringInfo(str,"FUNCTION %s :args ",
116+
stringStringInfo(node->funcname));
113117
_outNode(str,node->args);
114118
}
115119

@@ -118,11 +122,13 @@ _outFuncCall(StringInfo str, FuncCall *node)
118122
staticvoid
119123
_outColumnDef(StringInfostr,ColumnDef*node)
120124
{
121-
appendStringInfo(str," COLUMNDEF :colname %s :typename ",node->colname);
125+
appendStringInfo(str," COLUMNDEF :colname %s :typename ",
126+
stringStringInfo(node->colname));
122127
_outNode(str,node->typename);
123128

124129
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));
126132
_outNode(str,node->constraints);
127133
}
128134

@@ -131,7 +137,7 @@ _outTypeName(StringInfo str, TypeName *node)
131137
{
132138
appendStringInfo(str,
133139
" TYPENAME :name %s :timezone %s :setof %s typmod %d :arrayBounds ",
134-
node->name,
140+
stringStringInfo(node->name),
135141
node->timezone ?"true" :"false",
136142
node->setof ?"true" :"false",
137143
node->typmod);
@@ -143,10 +149,12 @@ _outTypeName(StringInfo str, TypeName *node)
143149
staticvoid
144150
_outIndexElem(StringInfostr,IndexElem*node)
145151
{
146-
appendStringInfo(str," INDEXELEM :name %s :args ",node->name);
152+
appendStringInfo(str," INDEXELEM :name %s :args ",
153+
stringStringInfo(node->name));
147154
_outNode(str,node->args);
148155

149-
appendStringInfo(str," :class %s :typename ",node->class);
156+
appendStringInfo(str," :class %s :typename ",
157+
stringStringInfo(node->class));
150158
_outNode(str,node->typename);
151159
}
152160

@@ -161,20 +169,20 @@ _outQuery(StringInfo str, Query *node)
161169
{
162170
caseT_CreateStmt:
163171
appendStringInfo(str," :create %s ",
164-
((CreateStmt*) (node->utilityStmt))->relname);
172+
stringStringInfo(((CreateStmt*) (node->utilityStmt))->relname));
165173
_outNode(str,node->utilityStmt);
166174
break;
167175

168176
caseT_IndexStmt:
169177
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));
172180
_outNode(str,node->utilityStmt);
173181
break;
174182

175183
caseT_NotifyStmt:
176184
appendStringInfo(str," :utility %s ",
177-
((NotifyStmt*) (node->utilityStmt))->relname);
185+
stringStringInfo(((NotifyStmt*) (node->utilityStmt))->relname));
178186
break;
179187

180188
default:
@@ -183,18 +191,19 @@ _outQuery(StringInfo str, Query *node)
183191
}
184192
else
185193
{
186-
appendStringInfo(str," :utility%s",NULL);
194+
appendStringInfo(str," :utility<>");
187195
}
188196

189197
appendStringInfo(str,
190198
" :resultRelation %d :into %s :isPortal %s :isBinary %s :unionall %s ",
191199
node->resultRelation,
192-
node->into,
200+
stringStringInfo(node->into),
193201
node->isPortal ?"true" :"false",
194202
node->isBinary ?"true" :"false",
195203
node->unionall ?"true" :"false");
196204

197-
appendStringInfo(str," :unique %s :sortClause ",node->uniqueFlag);
205+
appendStringInfo(str," :unique %s :sortClause ",
206+
stringStringInfo(node->uniqueFlag));
198207
_outNode(str,node->sortClause);
199208

200209
appendStringInfo(str," :rtable ");
@@ -563,7 +572,7 @@ _outResdom(StringInfo str, Resdom *node)
563572
node->restypmod);
564573

565574
appendStringInfo(str," :resname \"%s\" :reskey %d :reskeyop %u :resjunk %d",
566-
node->resname,
575+
stringStringInfo(node->resname),
567576
node->reskey,
568577
node->reskeyop,
569578
node->resjunk);
@@ -620,7 +629,7 @@ _outExpr(StringInfo str, Expr *node)
620629
opstr="subp";
621630
break;
622631
}
623-
appendStringInfo(str," :opType %s :oper ",opstr);
632+
appendStringInfo(str," :opType %s :oper ",stringStringInfo(opstr));
624633
_outNode(str,node->oper);
625634

626635
appendStringInfo(str," :args ");
@@ -675,7 +684,7 @@ _outAggreg(StringInfo str, Aggreg *node)
675684
{
676685
appendStringInfo(str,
677686
" AGGREG :aggname %s :basetype %u :aggtype %u :target ",
678-
node->aggname,
687+
stringStringInfo(node->aggname),
679688
node->basetype,
680689
node->aggtype);
681690
_outNode(str,node->target);
@@ -802,7 +811,7 @@ _outParam(StringInfo str, Param *node)
802811
" PARAM :paramkind %d :paramid %d :paramname %s :paramtype %u ",
803812
node->paramkind,
804813
node->paramid,
805-
node->paramname,
814+
stringStringInfo(node->paramname),
806815
node->paramtype);
807816

808817
appendStringInfo(str," :param_tlist ");
@@ -887,8 +896,8 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
887896
{
888897
appendStringInfo(str,
889898
" 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),
892901
node->relid,
893902
node->inh ?"true" :"false",
894903
node->inFromCl ?"true" :"false",
@@ -1297,7 +1306,7 @@ _outAExpr(StringInfo str, A_Expr *node)
12971306
break;
12981307
default:
12991308
#endif
1300-
appendStringInfo(str,node->opname);
1309+
appendStringInfo(str,stringStringInfo(node->opname));
13011310
#ifdefPARSEDEBUG
13021311
break;
13031312
}
@@ -1310,21 +1319,17 @@ _outAExpr(StringInfo str, A_Expr *node)
13101319
staticvoid
13111320
_outValue(StringInfostr,Value*value)
13121321
{
1313-
charbuf[500];
1314-
13151322
switch (value->type)
13161323
{
13171324
caseT_String:
1318-
sprintf(buf," \"%s\" ",value->val.str);
1319-
appendStringInfo(str,buf);
1325+
appendStringInfo(str," \"%s\" ",
1326+
stringStringInfo(value->val.str));
13201327
break;
13211328
caseT_Integer:
1322-
sprintf(buf," %ld ",value->val.ival);
1323-
appendStringInfo(str,buf);
1329+
appendStringInfo(str," %ld ",value->val.ival);
13241330
break;
13251331
caseT_Float:
1326-
sprintf(buf," %f ",value->val.dval);
1327-
appendStringInfo(str,buf);
1332+
appendStringInfo(str," %f ",value->val.dval);
13281333
break;
13291334
default:
13301335
break;
@@ -1335,67 +1340,52 @@ _outValue(StringInfo str, Value *value)
13351340
staticvoid
13361341
_outIdent(StringInfostr,Ident*node)
13371342
{
1338-
charbuf[500];
1339-
1340-
sprintf(buf," IDENT \"%s\" ",node->name);
1341-
appendStringInfo(str,buf);
1343+
appendStringInfo(str," IDENT \"%s\" ",stringStringInfo(node->name));
13421344
return;
13431345
}
13441346

13451347
staticvoid
13461348
_outAConst(StringInfostr,A_Const*node)
13471349
{
1348-
charbuf[500];
1349-
1350-
sprintf(buf,"CONST ");
1351-
appendStringInfo(str,buf);
1350+
appendStringInfo(str,"CONST ");
13521351
_outValue(str,&(node->val));
13531352
return;
13541353
}
13551354

13561355
staticvoid
13571356
_outConstraint(StringInfostr,Constraint*node)
13581357
{
1359-
charbuf[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));
13641360

13651361
switch (node->contype)
13661362
{
13671363
caseCONSTR_PRIMARY:
1368-
sprintf(buf," PRIMARY KEY ");
1369-
appendStringInfo(str,buf);
1364+
appendStringInfo(str," PRIMARY KEY ");
13701365
_outNode(str,node->keys);
13711366
break;
13721367

13731368
caseCONSTR_CHECK:
1374-
sprintf(buf," CHECK ");
1375-
appendStringInfo(str,buf);
1376-
appendStringInfo(str,node->def);
1369+
appendStringInfo(str," CHECK %s",
1370+
stringStringInfo(node->def));
13771371
break;
13781372

13791373
caseCONSTR_DEFAULT:
1380-
sprintf(buf," DEFAULT ");
1381-
appendStringInfo(str,buf);
1382-
appendStringInfo(str,node->def);
1374+
appendStringInfo(str," DEFAULT %s",
1375+
stringStringInfo(node->def));
13831376
break;
13841377

13851378
caseCONSTR_NOTNULL:
1386-
sprintf(buf," NOT NULL ");
1387-
appendStringInfo(str,buf);
1379+
appendStringInfo(str," NOT NULL ");
13881380
break;
13891381

13901382
caseCONSTR_UNIQUE:
1391-
sprintf(buf," UNIQUE ");
1392-
appendStringInfo(str,buf);
1383+
appendStringInfo(str," UNIQUE ");
13931384
_outNode(str,node->keys);
13941385
break;
13951386

13961387
default:
1397-
sprintf(buf,"<unrecognized constraint>");
1398-
appendStringInfo(str,buf);
1388+
appendStringInfo(str,"<unrecognized constraint>");
13991389
break;
14001390
}
14011391
return;
@@ -1404,27 +1394,19 @@ _outConstraint(StringInfo str, Constraint *node)
14041394
staticvoid
14051395
_outCaseExpr(StringInfostr,CaseExpr*node)
14061396
{
1407-
charbuf[500];
1408-
1409-
sprintf(buf,"CASE ");
1410-
appendStringInfo(str,buf);
1397+
appendStringInfo(str,"CASE ");
14111398
_outNode(str,node->args);
1412-
sprintf(buf," :default ");
1413-
appendStringInfo(str,buf);
1399+
appendStringInfo(str," :default ");
14141400
_outNode(str,node->defresult);
14151401
return;
14161402
}
14171403

14181404
staticvoid
14191405
_outCaseWhen(StringInfostr,CaseWhen*node)
14201406
{
1421-
charbuf[500];
1422-
1423-
sprintf(buf," WHEN ");
1424-
appendStringInfo(str,buf);
1407+
appendStringInfo(str," WHEN ");
14251408
_outNode(str,node->expr);
1426-
sprintf(buf," :then ");
1427-
appendStringInfo(str,buf);
1409+
appendStringInfo(str," :then ");
14281410
_outNode(str,node->result);
14291411
return;
14301412
}

‎src/include/lib/stringinfo.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: stringinfo.h,v 1.8 1998/12/14 08:11:17 scrappy Exp $
9+
* $Id: stringinfo.h,v 1.9 1998/12/18 14:45:09 wieck Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -44,4 +44,10 @@ extern StringInfo makeStringInfo(void);
4444
*/
4545
externvoidappendStringInfo(StringInfostr,constchar*fmt,...);
4646

47+
/*------------------------
48+
* nullStringInfo
49+
* return the string itself or "<>" if it is NULL
50+
*/
51+
#definestringStringInfo(s) (((s) == NULL) ? "<>" : (s))
52+
4753
#endif/* STRINGINFO_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp