5
5
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
6
6
* Portions Copyright (c) 1994, Regents of the University of California
7
7
*
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 $
9
9
*
10
10
* NOTES
11
11
* Every (plan) node in POSTGRES has an associated "out" routine which
27
27
#include "utils/datum.h"
28
28
29
29
30
+ #define booltostr (x ) ((x) ? "true" : "false")
31
+
30
32
static void _outDatum (StringInfo str , Datum value , int typlen , bool typbyval );
31
33
static void _outNode (StringInfo str , void * obj );
32
34
@@ -56,7 +58,8 @@ _outToken(StringInfo str, char *s)
56
58
* s == '\"' ||
57
59
* s == '@' ||
58
60
isdigit ((unsigned char ) * s ) ||
59
- (* s == '-' && isdigit ((unsigned char ) s [1 ])))
61
+ ((* s == '+' || * s == '-' ) &&
62
+ (isdigit ((unsigned char ) s [1 ]) || s [1 ] == '.' )))
60
63
appendStringInfoChar (str , '\\' );
61
64
while (* s )
62
65
{
@@ -84,14 +87,29 @@ _outIntList(StringInfo str, List *list)
84
87
appendStringInfoChar (str , ')' );
85
88
}
86
89
90
+ /*
91
+ * _outOidList -
92
+ * converts a List of OIDs
93
+ */
94
+ static void
95
+ _outOidList (StringInfo str , 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
+
87
105
static void
88
106
_outCreateStmt (StringInfo str , CreateStmt * node )
89
107
{
90
108
appendStringInfo (str , " CREATE :relname " );
91
109
_outToken (str , node -> relname );
92
110
93
111
appendStringInfo (str , " :istemp %s " ,
94
- node -> istemp ? "true" : "false" );
112
+ booltostr ( node -> istemp ) );
95
113
96
114
appendStringInfo (str , " :columns " );
97
115
_outNode (str , node -> tableElts );
@@ -125,8 +143,8 @@ _outIndexStmt(StringInfo str, IndexStmt *node)
125
143
_outNode (str , node -> rangetable );
126
144
127
145
appendStringInfo (str , " :unique %s :primary %s " ,
128
- node -> unique ? "true" : "false" ,
129
- node -> primary ? "true" : "false" );
146
+ booltostr ( node -> unique ) ,
147
+ booltostr ( node -> primary ) );
130
148
}
131
149
132
150
static void
@@ -145,8 +163,8 @@ _outFuncCall(StringInfo str, FuncCall *node)
145
163
appendStringInfo (str , " :args " );
146
164
_outNode (str , node -> args );
147
165
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 ) );
150
168
}
151
169
152
170
static void
@@ -157,8 +175,8 @@ _outColumnDef(StringInfo str, ColumnDef *node)
157
175
appendStringInfo (str , " :typename " );
158
176
_outNode (str , node -> typename );
159
177
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 ) );
162
180
_outNode (str , node -> raw_default );
163
181
appendStringInfo (str , " :cooked_default " );
164
182
_outToken (str , node -> cooked_default );
@@ -172,8 +190,8 @@ _outTypeName(StringInfo str, TypeName *node)
172
190
appendStringInfo (str , " TYPENAME :name " );
173
191
_outToken (str , node -> name );
174
192
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 ) ,
177
195
node -> typmod );
178
196
_outNode (str , node -> arrayBounds );
179
197
}
@@ -245,11 +263,11 @@ _outQuery(StringInfo str, Query *node)
245
263
246
264
appendStringInfo (str , " :isPortal %s :isBinary %s :isTemp %s"
247
265
" :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 ) );
253
271
_outNode (str , node -> rtable );
254
272
255
273
appendStringInfo (str , " :jointree " );
@@ -289,14 +307,14 @@ _outQuery(StringInfo str, Query *node)
289
307
static void
290
308
_outSortClause (StringInfo str , SortClause * node )
291
309
{
292
- appendStringInfo (str , " SORTCLAUSE :tleSortGroupRef %d :sortop %u " ,
310
+ appendStringInfo (str , " SORTCLAUSE :tleSortGroupRef %u :sortop %u " ,
293
311
node -> tleSortGroupRef , node -> sortop );
294
312
}
295
313
296
314
static void
297
315
_outGroupClause (StringInfo str , GroupClause * node )
298
316
{
299
- appendStringInfo (str , " GROUPCLAUSE :tleSortGroupRef %d :sortop %u " ,
317
+ appendStringInfo (str , " GROUPCLAUSE :tleSortGroupRef %u :sortop %u " ,
300
318
node -> tleSortGroupRef , node -> sortop );
301
319
}
302
320
@@ -305,12 +323,12 @@ _outSetOperationStmt(StringInfo str, SetOperationStmt *node)
305
323
{
306
324
appendStringInfo (str , " SETOPERATIONSTMT :op %d :all %s :larg " ,
307
325
(int ) node -> op ,
308
- node -> all ? "true" : "false" );
326
+ booltostr ( node -> all ) );
309
327
_outNode (str , node -> larg );
310
328
appendStringInfo (str , " :rarg " );
311
329
_outNode (str , node -> rarg );
312
330
appendStringInfo (str , " :colTypes " );
313
- _outIntList (str , node -> colTypes );
331
+ _outOidList (str , node -> colTypes );
314
332
}
315
333
316
334
/*
@@ -384,7 +402,7 @@ _outAppend(StringInfo str, Append *node)
384
402
_outNode (str , node -> appendplans );
385
403
386
404
appendStringInfo (str , " :isTarget %s " ,
387
- node -> isTarget ? "true" : "false" );
405
+ booltostr ( node -> isTarget ) );
388
406
}
389
407
390
408
/*
@@ -453,7 +471,7 @@ _outSubPlan(StringInfo str, SubPlan *node)
453
471
appendStringInfo (str , " SUBPLAN :plan " );
454
472
_outNode (str , node -> plan );
455
473
456
- appendStringInfo (str , " :planid %u :rtable " , node -> plan_id );
474
+ appendStringInfo (str , " :planid %d :rtable " , node -> plan_id );
457
475
_outNode (str , node -> rtable );
458
476
459
477
appendStringInfo (str , " :setprm " );
@@ -500,7 +518,7 @@ _outIndexScan(StringInfo str, IndexScan *node)
500
518
_outPlanInfo (str , (Plan * ) node );
501
519
502
520
appendStringInfo (str , " :scanrelid %u :indxid " , node -> scan .scanrelid );
503
- _outIntList (str , node -> indxid );
521
+ _outOidList (str , node -> indxid );
504
522
505
523
appendStringInfo (str , " :indxqual " );
506
524
_outNode (str , node -> indxqual );
@@ -578,7 +596,7 @@ _outGroup(StringInfo str, Group *node)
578
596
/* the actual Group fields */
579
597
appendStringInfo (str , " :numCols %d :tuplePerGroup %s " ,
580
598
node -> numCols ,
581
- node -> tuplePerGroup ? "true" : "false" );
599
+ booltostr ( node -> tuplePerGroup ) );
582
600
}
583
601
584
602
static void
@@ -654,11 +672,11 @@ _outResdom(StringInfo str, Resdom *node)
654
672
node -> restype ,
655
673
node -> restypmod );
656
674
_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 " ,
658
676
node -> reskey ,
659
677
node -> reskeyop ,
660
678
node -> ressortgroupref ,
661
- node -> resjunk ? "true" : "false" );
679
+ booltostr ( node -> resjunk ) );
662
680
}
663
681
664
682
static void
@@ -667,7 +685,7 @@ _outFjoin(StringInfo str, Fjoin *node)
667
685
int i ;
668
686
669
687
appendStringInfo (str , " FJOIN :initialized %s :nNodes %d " ,
670
- node -> fj_initialized ? "true" : "false" ,
688
+ booltostr ( node -> fj_initialized ) ,
671
689
node -> fj_nNodes );
672
690
673
691
appendStringInfo (str , " :innerNode " );
@@ -677,7 +695,8 @@ _outFjoin(StringInfo str, Fjoin *node)
677
695
node -> fj_results );
678
696
679
697
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 ]));
681
700
}
682
701
683
702
/*
@@ -728,13 +747,13 @@ static void
728
747
_outVar (StringInfo str , Var * node )
729
748
{
730
749
appendStringInfo (str ,
731
- " VAR :varno %d :varattno %d :vartype %u :vartypmod %d " ,
750
+ " VAR :varno %u :varattno %d :vartype %u :vartypmod %d " ,
732
751
node -> varno ,
733
752
node -> varattno ,
734
753
node -> vartype ,
735
754
node -> vartypmod );
736
755
737
- appendStringInfo (str , " :varlevelsup %u :varnoold %d :varoattno %d" ,
756
+ appendStringInfo (str , " :varlevelsup %u :varnoold %u :varoattno %d" ,
738
757
node -> varlevelsup ,
739
758
node -> varnoold ,
740
759
node -> varoattno );
@@ -751,8 +770,8 @@ _outConst(StringInfo str, Const *node)
751
770
" :constisnull %s :constvalue " ,
752
771
node -> consttype ,
753
772
node -> constlen ,
754
- node -> constbyval ? "true" : "false" ,
755
- node -> constisnull ? "true" : "false" );
773
+ booltostr ( node -> constbyval ) ,
774
+ booltostr ( node -> constisnull ) );
756
775
757
776
if (node -> constisnull )
758
777
appendStringInfo (str , "<>" );
@@ -773,8 +792,8 @@ _outAggref(StringInfo str, Aggref *node)
773
792
_outNode (str , node -> target );
774
793
775
794
appendStringInfo (str , " :aggstar %s :aggdistinct %s " ,
776
- node -> aggstar ? "true" : "false" ,
777
- node -> aggdistinct ? "true" : "false" );
795
+ booltostr ( node -> aggstar ) ,
796
+ booltostr ( node -> aggdistinct ) );
778
797
/* aggno is not dumped */
779
798
}
780
799
@@ -787,7 +806,7 @@ _outSubLink(StringInfo str, SubLink *node)
787
806
appendStringInfo (str ,
788
807
" SUBLINK :subLinkType %d :useor %s :lefthand " ,
789
808
node -> subLinkType ,
790
- node -> useor ? "true" : "false" );
809
+ booltostr ( node -> useor ) );
791
810
_outNode (str , node -> lefthand );
792
811
793
812
appendStringInfo (str , " :oper " );
@@ -916,7 +935,7 @@ _outJoinExpr(StringInfo str, JoinExpr *node)
916
935
{
917
936
appendStringInfo (str , " JOINEXPR :jointype %d :isNatural %s :larg " ,
918
937
(int ) node -> jointype ,
919
- node -> isNatural ? "true" : "false" );
938
+ booltostr ( node -> isNatural ) );
920
939
_outNode (str , node -> larg );
921
940
appendStringInfo (str , " :rarg " );
922
941
_outNode (str , node -> rarg );
@@ -955,9 +974,9 @@ _outRelOptInfo(StringInfo str, RelOptInfo *node)
955
974
_outNode (str , node -> cheapest_total_path );
956
975
957
976
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 ) ,
961
980
node -> pages ,
962
981
node -> tuples );
963
982
_outNode (str , node -> subplan );
@@ -1010,10 +1029,10 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
1010
1029
_outNode (str , node -> eref );
1011
1030
appendStringInfo (str , " :inh %s :inFromCl %s :checkForRead %s"
1012
1031
" :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 ) ,
1017
1036
node -> checkAsUser );
1018
1037
}
1019
1038
@@ -1045,7 +1064,7 @@ _outIndexPath(StringInfo str, IndexPath *node)
1045
1064
_outNode (str , node -> path .pathkeys );
1046
1065
1047
1066
appendStringInfo (str , " :indexid " );
1048
- _outIntList (str , node -> indexid );
1067
+ _outOidList (str , node -> indexid );
1049
1068
1050
1069
appendStringInfo (str , " :indexqual " );
1051
1070
_outNode (str , node -> indexqual );
@@ -1055,7 +1074,7 @@ _outIndexPath(StringInfo str, IndexPath *node)
1055
1074
_outIntList (str , node -> joinrelids );
1056
1075
1057
1076
appendStringInfo (str , " :alljoinquals %s :rows %.2f " ,
1058
- node -> alljoinquals ? "true" : "false" ,
1077
+ booltostr ( node -> alljoinquals ) ,
1059
1078
node -> rows );
1060
1079
}
1061
1080
@@ -1192,7 +1211,7 @@ _outRestrictInfo(StringInfo str, RestrictInfo *node)
1192
1211
_outNode (str , node -> clause );
1193
1212
1194
1213
appendStringInfo (str , " :ispusheddown %s :subclauseindices " ,
1195
- node -> ispusheddown ? "true" : "false" );
1214
+ booltostr ( node -> ispusheddown ) );
1196
1215
_outNode (str , node -> subclauseindices );
1197
1216
1198
1217
appendStringInfo (str , " :mergejoinoperator %u " , node -> mergejoinoperator );
@@ -1313,7 +1332,7 @@ _outValue(StringInfo str, Value *value)
1313
1332
{
1314
1333
switch (value -> type )
1315
1334
{
1316
- case T_Integer :
1335
+ case T_Integer :
1317
1336
appendStringInfo (str , " %ld " , value -> val .ival );
1318
1337
break ;
1319
1338
case T_Float :
0 commit comments