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

Commit1112a2a

Browse files
committed
Make outfuncs/readfuncs treat OIDs properly as unsigned values. Clean up
inconsistent coding practices for handling Index values and booleans,too.
1 parenta4ddbbd commit1112a2a

File tree

2 files changed

+210
-159
lines changed

2 files changed

+210
-159
lines changed

‎src/backend/nodes/outfuncs.c

Lines changed: 66 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
66
* Portions Copyright (c) 1994, Regents of the University of California
77
*
8-
*$Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.136 2001/01/07 01:08:47 tgl Exp $
8+
*$Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.137 2001/01/08 00:31:43 tgl Exp $
99
*
1010
* NOTES
1111
* Every (plan) node in POSTGRES has an associated "out" routine which
@@ -27,6 +27,8 @@
2727
#include"utils/datum.h"
2828

2929

30+
#definebooltostr(x) ((x) ? "true" : "false")
31+
3032
staticvoid_outDatum(StringInfostr,Datumvalue,inttyplen,booltypbyval);
3133
staticvoid_outNode(StringInfostr,void*obj);
3234

@@ -56,7 +58,8 @@ _outToken(StringInfo str, char *s)
5658
*s=='\"'||
5759
*s=='@'||
5860
isdigit((unsignedchar)*s)||
59-
(*s=='-'&&isdigit((unsignedchar)s[1])))
61+
((*s=='+'||*s=='-')&&
62+
(isdigit((unsignedchar)s[1])||s[1]=='.')))
6063
appendStringInfoChar(str,'\\');
6164
while (*s)
6265
{
@@ -84,14 +87,29 @@ _outIntList(StringInfo str, List *list)
8487
appendStringInfoChar(str,')');
8588
}
8689

90+
/*
91+
* _outOidList -
92+
* converts a List of OIDs
93+
*/
94+
staticvoid
95+
_outOidList(StringInfostr,List*list)
96+
{
97+
List*l;
98+
99+
appendStringInfoChar(str,'(');
100+
foreach(l,list)
101+
appendStringInfo(str," %u", (Oid)lfirsti(l));
102+
appendStringInfoChar(str,')');
103+
}
104+
87105
staticvoid
88106
_outCreateStmt(StringInfostr,CreateStmt*node)
89107
{
90108
appendStringInfo(str," CREATE :relname ");
91109
_outToken(str,node->relname);
92110

93111
appendStringInfo(str," :istemp %s ",
94-
node->istemp ?"true" :"false");
112+
booltostr(node->istemp));
95113

96114
appendStringInfo(str,":columns ");
97115
_outNode(str,node->tableElts);
@@ -125,8 +143,8 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
125143
_outNode(str,node->rangetable);
126144

127145
appendStringInfo(str," :unique %s :primary %s ",
128-
node->unique ?"true" :"false",
129-
node->primary ?"true" :"false");
146+
booltostr(node->unique),
147+
booltostr(node->primary));
130148
}
131149

132150
staticvoid
@@ -145,8 +163,8 @@ _outFuncCall(StringInfo str, FuncCall *node)
145163
appendStringInfo(str," :args ");
146164
_outNode(str,node->args);
147165
appendStringInfo(str," :agg_star %s :agg_distinct %s ",
148-
node->agg_star ?"true" :"false",
149-
node->agg_distinct ?"true" :"false");
166+
booltostr(node->agg_star),
167+
booltostr(node->agg_distinct));
150168
}
151169

152170
staticvoid
@@ -157,8 +175,8 @@ _outColumnDef(StringInfo str, ColumnDef *node)
157175
appendStringInfo(str," :typename ");
158176
_outNode(str,node->typename);
159177
appendStringInfo(str," :is_not_null %s :is_sequence %s :raw_default ",
160-
node->is_not_null ?"true" :"false",
161-
node->is_sequence ?"true" :"false");
178+
booltostr(node->is_not_null),
179+
booltostr(node->is_sequence));
162180
_outNode(str,node->raw_default);
163181
appendStringInfo(str," :cooked_default ");
164182
_outToken(str,node->cooked_default);
@@ -172,8 +190,8 @@ _outTypeName(StringInfo str, TypeName *node)
172190
appendStringInfo(str," TYPENAME :name ");
173191
_outToken(str,node->name);
174192
appendStringInfo(str," :timezone %s :setof %s typmod %d :arrayBounds ",
175-
node->timezone ?"true" :"false",
176-
node->setof ?"true" :"false",
193+
booltostr(node->timezone),
194+
booltostr(node->setof),
177195
node->typmod);
178196
_outNode(str,node->arrayBounds);
179197
}
@@ -245,11 +263,11 @@ _outQuery(StringInfo str, Query *node)
245263

246264
appendStringInfo(str," :isPortal %s :isBinary %s :isTemp %s"
247265
" :hasAggs %s :hasSubLinks %s :rtable ",
248-
node->isPortal ?"true" :"false",
249-
node->isBinary ?"true" :"false",
250-
node->isTemp ?"true" :"false",
251-
node->hasAggs ?"true" :"false",
252-
node->hasSubLinks ?"true" :"false");
266+
booltostr(node->isPortal),
267+
booltostr(node->isBinary),
268+
booltostr(node->isTemp),
269+
booltostr(node->hasAggs),
270+
booltostr(node->hasSubLinks));
253271
_outNode(str,node->rtable);
254272

255273
appendStringInfo(str," :jointree ");
@@ -289,14 +307,14 @@ _outQuery(StringInfo str, Query *node)
289307
staticvoid
290308
_outSortClause(StringInfostr,SortClause*node)
291309
{
292-
appendStringInfo(str," SORTCLAUSE :tleSortGroupRef %d :sortop %u ",
310+
appendStringInfo(str," SORTCLAUSE :tleSortGroupRef %u :sortop %u ",
293311
node->tleSortGroupRef,node->sortop);
294312
}
295313

296314
staticvoid
297315
_outGroupClause(StringInfostr,GroupClause*node)
298316
{
299-
appendStringInfo(str," GROUPCLAUSE :tleSortGroupRef %d :sortop %u ",
317+
appendStringInfo(str," GROUPCLAUSE :tleSortGroupRef %u :sortop %u ",
300318
node->tleSortGroupRef,node->sortop);
301319
}
302320

@@ -305,12 +323,12 @@ _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
305323
{
306324
appendStringInfo(str," SETOPERATIONSTMT :op %d :all %s :larg ",
307325
(int)node->op,
308-
node->all ?"true" :"false");
326+
booltostr(node->all));
309327
_outNode(str,node->larg);
310328
appendStringInfo(str," :rarg ");
311329
_outNode(str,node->rarg);
312330
appendStringInfo(str," :colTypes ");
313-
_outIntList(str,node->colTypes);
331+
_outOidList(str,node->colTypes);
314332
}
315333

316334
/*
@@ -384,7 +402,7 @@ _outAppend(StringInfo str, Append *node)
384402
_outNode(str,node->appendplans);
385403

386404
appendStringInfo(str," :isTarget %s ",
387-
node->isTarget ?"true" :"false");
405+
booltostr(node->isTarget));
388406
}
389407

390408
/*
@@ -453,7 +471,7 @@ _outSubPlan(StringInfo str, SubPlan *node)
453471
appendStringInfo(str," SUBPLAN :plan ");
454472
_outNode(str,node->plan);
455473

456-
appendStringInfo(str," :planid %u :rtable ",node->plan_id);
474+
appendStringInfo(str," :planid %d :rtable ",node->plan_id);
457475
_outNode(str,node->rtable);
458476

459477
appendStringInfo(str," :setprm ");
@@ -500,7 +518,7 @@ _outIndexScan(StringInfo str, IndexScan *node)
500518
_outPlanInfo(str, (Plan*)node);
501519

502520
appendStringInfo(str," :scanrelid %u :indxid ",node->scan.scanrelid);
503-
_outIntList(str,node->indxid);
521+
_outOidList(str,node->indxid);
504522

505523
appendStringInfo(str," :indxqual ");
506524
_outNode(str,node->indxqual);
@@ -578,7 +596,7 @@ _outGroup(StringInfo str, Group *node)
578596
/* the actual Group fields */
579597
appendStringInfo(str," :numCols %d :tuplePerGroup %s ",
580598
node->numCols,
581-
node->tuplePerGroup ?"true" :"false");
599+
booltostr(node->tuplePerGroup));
582600
}
583601

584602
staticvoid
@@ -654,11 +672,11 @@ _outResdom(StringInfo str, Resdom *node)
654672
node->restype,
655673
node->restypmod);
656674
_outToken(str,node->resname);
657-
appendStringInfo(str," :reskey %d :reskeyop %u :ressortgroupref %d :resjunk %s ",
675+
appendStringInfo(str," :reskey %u :reskeyop %u :ressortgroupref %u :resjunk %s ",
658676
node->reskey,
659677
node->reskeyop,
660678
node->ressortgroupref,
661-
node->resjunk ?"true" :"false");
679+
booltostr(node->resjunk));
662680
}
663681

664682
staticvoid
@@ -667,7 +685,7 @@ _outFjoin(StringInfo str, Fjoin *node)
667685
inti;
668686

669687
appendStringInfo(str," FJOIN :initialized %s :nNodes %d ",
670-
node->fj_initialized ?"true" :"false",
688+
booltostr(node->fj_initialized),
671689
node->fj_nNodes);
672690

673691
appendStringInfo(str," :innerNode ");
@@ -677,7 +695,8 @@ _outFjoin(StringInfo str, Fjoin *node)
677695
node->fj_results);
678696

679697
for (i=0;i<node->fj_nNodes;i++)
680-
appendStringInfo(str, (node->fj_alwaysDone[i]) ?"true" :"false");
698+
appendStringInfo(str,
699+
booltostr(node->fj_alwaysDone[i]));
681700
}
682701

683702
/*
@@ -728,13 +747,13 @@ static void
728747
_outVar(StringInfostr,Var*node)
729748
{
730749
appendStringInfo(str,
731-
" VAR :varno %d :varattno %d :vartype %u :vartypmod %d ",
750+
" VAR :varno %u :varattno %d :vartype %u :vartypmod %d ",
732751
node->varno,
733752
node->varattno,
734753
node->vartype,
735754
node->vartypmod);
736755

737-
appendStringInfo(str," :varlevelsup %u :varnoold %d :varoattno %d",
756+
appendStringInfo(str," :varlevelsup %u :varnoold %u :varoattno %d",
738757
node->varlevelsup,
739758
node->varnoold,
740759
node->varoattno);
@@ -751,8 +770,8 @@ _outConst(StringInfo str, Const *node)
751770
" :constisnull %s :constvalue ",
752771
node->consttype,
753772
node->constlen,
754-
node->constbyval ?"true" :"false",
755-
node->constisnull ?"true" :"false");
773+
booltostr(node->constbyval),
774+
booltostr(node->constisnull));
756775

757776
if (node->constisnull)
758777
appendStringInfo(str,"<>");
@@ -773,8 +792,8 @@ _outAggref(StringInfo str, Aggref *node)
773792
_outNode(str,node->target);
774793

775794
appendStringInfo(str," :aggstar %s :aggdistinct %s ",
776-
node->aggstar ?"true" :"false",
777-
node->aggdistinct ?"true" :"false");
795+
booltostr(node->aggstar),
796+
booltostr(node->aggdistinct));
778797
/* aggno is not dumped */
779798
}
780799

@@ -787,7 +806,7 @@ _outSubLink(StringInfo str, SubLink *node)
787806
appendStringInfo(str,
788807
" SUBLINK :subLinkType %d :useor %s :lefthand ",
789808
node->subLinkType,
790-
node->useor ?"true" :"false");
809+
booltostr(node->useor));
791810
_outNode(str,node->lefthand);
792811

793812
appendStringInfo(str," :oper ");
@@ -916,7 +935,7 @@ _outJoinExpr(StringInfo str, JoinExpr *node)
916935
{
917936
appendStringInfo(str," JOINEXPR :jointype %d :isNatural %s :larg ",
918937
(int)node->jointype,
919-
node->isNatural ?"true" :"false");
938+
booltostr(node->isNatural));
920939
_outNode(str,node->larg);
921940
appendStringInfo(str," :rarg ");
922941
_outNode(str,node->rarg);
@@ -955,9 +974,9 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
955974
_outNode(str,node->cheapest_total_path);
956975

957976
appendStringInfo(str," :pruneable %s :issubquery %s :indexed %s :pages %ld :tuples %.0f :subplan ",
958-
node->pruneable ?"true" :"false",
959-
node->issubquery ?"true" :"false",
960-
node->indexed ?"true" :"false",
977+
booltostr(node->pruneable),
978+
booltostr(node->issubquery),
979+
booltostr(node->indexed),
961980
node->pages,
962981
node->tuples);
963982
_outNode(str,node->subplan);
@@ -1010,10 +1029,10 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
10101029
_outNode(str,node->eref);
10111030
appendStringInfo(str," :inh %s :inFromCl %s :checkForRead %s"
10121031
" :checkForWrite %s :checkAsUser %u",
1013-
node->inh ?"true" :"false",
1014-
node->inFromCl ?"true" :"false",
1015-
node->checkForRead ?"true" :"false",
1016-
node->checkForWrite ?"true" :"false",
1032+
booltostr(node->inh),
1033+
booltostr(node->inFromCl),
1034+
booltostr(node->checkForRead),
1035+
booltostr(node->checkForWrite),
10171036
node->checkAsUser);
10181037
}
10191038

@@ -1045,7 +1064,7 @@ _outIndexPath(StringInfo str, IndexPath *node)
10451064
_outNode(str,node->path.pathkeys);
10461065

10471066
appendStringInfo(str," :indexid ");
1048-
_outIntList(str,node->indexid);
1067+
_outOidList(str,node->indexid);
10491068

10501069
appendStringInfo(str," :indexqual ");
10511070
_outNode(str,node->indexqual);
@@ -1055,7 +1074,7 @@ _outIndexPath(StringInfo str, IndexPath *node)
10551074
_outIntList(str,node->joinrelids);
10561075

10571076
appendStringInfo(str," :alljoinquals %s :rows %.2f ",
1058-
node->alljoinquals ?"true" :"false",
1077+
booltostr(node->alljoinquals),
10591078
node->rows);
10601079
}
10611080

@@ -1192,7 +1211,7 @@ _outRestrictInfo(StringInfo str, RestrictInfo *node)
11921211
_outNode(str,node->clause);
11931212

11941213
appendStringInfo(str," :ispusheddown %s :subclauseindices ",
1195-
node->ispusheddown ?"true" :"false");
1214+
booltostr(node->ispusheddown));
11961215
_outNode(str,node->subclauseindices);
11971216

11981217
appendStringInfo(str," :mergejoinoperator %u ",node->mergejoinoperator);
@@ -1313,7 +1332,7 @@ _outValue(StringInfo str, Value *value)
13131332
{
13141333
switch (value->type)
13151334
{
1316-
caseT_Integer:
1335+
caseT_Integer:
13171336
appendStringInfo(str," %ld ",value->val.ival);
13181337
break;
13191338
caseT_Float:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp