PostgreSQL Source Code: src/backend/nodes/outfuncs.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
16
17#include <ctype.h>
18
27
28
30
33
34
35
36
37
38
39
40
41
42
43#define WRITE_NODE_TYPE(nodelabel) \
44 appendStringInfoString(str, nodelabel)
45
46
47#define WRITE_INT_FIELD(fldname) \
48 appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
49
50
51#define WRITE_UINT_FIELD(fldname) \
52 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
53
54
55#define WRITE_UINT64_FIELD(fldname) \
56 appendStringInfo(str, " :" CppAsString(fldname) " " UINT64_FORMAT, \
57 node->fldname)
58
59
60#define WRITE_OID_FIELD(fldname) \
61 appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
62
63
64#define WRITE_LONG_FIELD(fldname) \
65 appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
66
67
68#define WRITE_CHAR_FIELD(fldname) \
69 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
70 outChar(str, node->fldname))
71
72
73#define WRITE_ENUM_FIELD(fldname, enumtype) \
74 appendStringInfo(str, " :" CppAsString(fldname) " %d", \
75 (int) node->fldname)
76
77
78#define WRITE_FLOAT_FIELD(fldname) \
79 (appendStringInfo(str, " :" CppAsString(fldname) " "), \
80 outDouble(str, node->fldname))
81
82
83#define WRITE_BOOL_FIELD(fldname) \
84 appendStringInfo(str, " :" CppAsString(fldname) " %s", \
85 booltostr(node->fldname))
86
87
88#define WRITE_STRING_FIELD(fldname) \
89 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
90 outToken(str, node->fldname))
91
92
93#define WRITE_LOCATION_FIELD(fldname) \
94 appendStringInfo(str, " :" CppAsString(fldname) " %d", write_location_fields ? node->fldname : -1)
95
96
97#define WRITE_NODE_FIELD(fldname) \
98 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
99 outNode(str, node->fldname))
100
101
102#define WRITE_BITMAPSET_FIELD(fldname) \
103 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
104 outBitmapset(str, node->fldname))
105
106
107#define WRITE_NODE_ARRAY(fldname, len) \
108 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
109 writeNodeArray(str, (const Node * const *) node->fldname, len))
110
111
112#define WRITE_ATTRNUMBER_ARRAY(fldname, len) \
113 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
114 writeAttrNumberCols(str, node->fldname, len))
115
116
117#define WRITE_OID_ARRAY(fldname, len) \
118 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
119 writeOidCols(str, node->fldname, len))
120
121
122#define WRITE_INDEX_ARRAY(fldname, len) \
123 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
124 writeIndexCols(str, node->fldname, len))
125
126
127#define WRITE_INT_ARRAY(fldname, len) \
128 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
129 writeIntCols(str, node->fldname, len))
130
131
132#define WRITE_BOOL_ARRAY(fldname, len) \
133 (appendStringInfoString(str, " :" CppAsString(fldname) " "), \
134 writeBoolCols(str, node->fldname, len))
135
136#define booltostr(x) ((x) ? "true" : "false")
137
138
139
140
141
142
143
144
145
146
147
148void
150{
151 if (s == NULL)
152 {
154 return;
155 }
156 if (*s == '\0')
157 {
159 return;
160 }
161
162
163
164
165
166
167
168 if (*s == '<' ||
169 *s == '"' ||
170 isdigit((unsigned char) *s) ||
171 ((*s == '+' || *s == '-') &&
172 (isdigit((unsigned char) s[1]) || s[1] == '.')))
174 while (*s)
175 {
176
177 if (*s == ' ' || *s == '\n' || *s == '\t' ||
178 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
179 *s == '\\')
182 }
183}
184
185
186
187
188
189static void
191{
192 char in[2];
193
194
195 if (c == '\0')
196 {
198 return;
199 }
200
201 in[0] = c;
202 in[1] = '\0';
203
205}
206
207
208
209
210static void
212{
214
217}
218
219
220
221
222
223
224
225
226
227#define WRITE_SCALAR_ARRAY(fnname, datatype, fmtstr, convfunc) \
228static void \
229fnname(StringInfo str, const datatype *arr, int len) \
230{ \
231 if (arr != NULL) \
232 { \
233 appendStringInfoChar(str, '('); \
234 for (int i = 0; i < len; i++) \
235 appendStringInfo(str, fmtstr, convfunc(arr[i])); \
236 appendStringInfoChar(str, ')'); \
237 } \
238 else \
239 appendStringInfoString(str, "<>"); \
240}
241
247
248
249
250
251
252
253
254static void
256{
257 if (arr != NULL)
258 {
260 for (int i = 0; i < len; i++)
261 {
264 }
266 }
267 else
269}
270
271
272
273
274static void
276{
278
280
281 if (IsA(node, IntList))
283 else if (IsA(node, OidList))
285 else if (IsA(node, XidList))
287
288 foreach(lc, node)
289 {
290
291
292
293
294
296 {
298 if (lnext(node, lc))
300 }
301 else if (IsA(node, IntList))
303 else if (IsA(node, OidList))
305 else if (IsA(node, XidList))
307 else
308 elog(ERROR, "unrecognized list node type: %d",
309 (int) node->type);
310 }
311
313}
314
315
316
317
318
319
320
321
322
323
324void
326{
327 int x;
328
331 x = -1;
335}
336
337
338
339
340void
342{
344 i;
345 char *s;
346
348
349 if (typbyval)
350 {
351 s = (char *) (&value);
356 }
357 else
358 {
362 else
363 {
365 for (i = 0; i < length; i++)
368 }
369 }
370}
371
372
373#include "outfuncs.funcs.c"
374
375
376
377
378
379
380
381static void
383{
385
393
395 if (node->constisnull)
397 else
398 outDatum(str, node->constvalue, node->constlen, node->constbyval);
399}
400
401static void
403{
404 char *opstr = NULL;
405
407
408
409 switch (node->boolop)
410 {
412 opstr = "and";
413 break;
415 opstr = "or";
416 break;
418 opstr = "not";
419 break;
420 }
423
426}
427
428static void
430{
431 int i;
432
434
445
447 for (i = 0; i < node->nkeys; i++)
450 for (i = 0; i < node->nkeys; i++)
452}
453
454static void
456{
457
458
459
460
463
465
472
481}
482
483static void
485{
487
489
491
493
494
496}
497
498static void
500{
502
506
508 {
516 break;
520
526 break;
534 break;
538 break;
541 break;
547 break;
555 break;
562
564 break;
566
567 break;
570 break;
571 default:
572 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
573 break;
574 }
575
579}
580
581static void
583{
585
586 switch (node->kind)
587 {
590 break;
594 break;
598 break;
602 break;
606 break;
610 break;
614 break;
618 break;
622 break;
626 break;
630 break;
634 break;
638 break;
642 break;
643 default:
644 elog(ERROR, "unrecognized A_Expr_Kind: %d", (int) node->kind);
645 break;
646 }
647
651}
652
653static void
655{
657}
658
659static void
661{
662
663
664
665
667}
668
669static void
671{
673}
674
675static void
677{
678
679
680
681
682
684 if (node->sval[0] != '\0')
687}
688
689static void
691{
692
693
694
695
696
699}
700
701static void
703{
705
708 else
709 {
712 }
714}
715
716
717
718
719
720
721void
723{
724
726
727 if (obj == NULL)
729 else if (IsA(obj, List) || IsA(obj, IntList) || IsA(obj, OidList) ||
730 IsA(obj, XidList))
732
745 else
746 {
749 {
750#include "outfuncs.switch.c"
751
752 default:
753
754
755
756
757
758 elog(WARNING, "could not dump unrecognized node type: %d",
760 break;
761 }
763 }
764}
765
766
767
768
769
770
771
772
773
774
775static char *
777{
779 bool save_write_location_fields;
780
783
784
787
789
790 return str.data;
791}
792
793
794
795
796char *
798{
800}
801
802char *
804{
806}
807
808
809
810
811
812
813char *
815{
817
818
821 return str.data;
822}
int bms_next_member(const Bitmapset *a, int prevbit)
#define PointerIsValid(pointer)
int double_to_shortest_decimal_buf(double f, char *result)
Size datumGetSize(Datum value, bool typByVal, int typLen)
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
Assert(PointerIsAligned(start, uint64))
#define IsA(nodeptr, _type_)
static void _outString(StringInfo str, const String *node)
#define WRITE_NODE_ARRAY(fldname, len)
#define WRITE_OID_FIELD(fldname)
#define WRITE_BITMAPSET_FIELD(fldname)
void outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
static void outChar(StringInfo str, char c)
static void _outExtensibleNode(StringInfo str, const ExtensibleNode *node)
static void _outA_Const(StringInfo str, const A_Const *node)
static void _outBoolExpr(StringInfo str, const BoolExpr *node)
#define WRITE_ENUM_FIELD(fldname, enumtype)
static void _outForeignKeyOptInfo(StringInfo str, const ForeignKeyOptInfo *node)
static void outDouble(StringInfo str, double d)
#define WRITE_ATTRNUMBER_ARRAY(fldname, len)
#define WRITE_FLOAT_FIELD(fldname)
char * nodeToStringWithLocations(const void *obj)
#define WRITE_NODE_FIELD(fldname)
#define WRITE_SCALAR_ARRAY(fnname, datatype, fmtstr, convfunc)
#define WRITE_NODE_TYPE(nodelabel)
static void _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
static void _outConst(StringInfo str, const Const *node)
#define WRITE_BOOL_FIELD(fldname)
void outToken(StringInfo str, const char *s)
static void _outInteger(StringInfo str, const Integer *node)
#define WRITE_UINT_FIELD(fldname)
char * nodeToString(const void *obj)
#define WRITE_OID_ARRAY(fldname, len)
static void _outA_Expr(StringInfo str, const A_Expr *node)
static void _outList(StringInfo str, const List *node)
char * bmsToString(const Bitmapset *bms)
#define WRITE_CHAR_FIELD(fldname)
static bool write_location_fields
void outNode(StringInfo str, const void *obj)
#define WRITE_LOCATION_FIELD(fldname)
static void _outFloat(StringInfo str, const Float *node)
#define WRITE_STRING_FIELD(fldname)
#define WRITE_INT_FIELD(fldname)
static char * nodeToStringInternal(const void *obj, bool write_loc_fields)
static void _outBitString(StringInfo str, const BitString *node)
static void _outBoolean(StringInfo str, const Boolean *node)
static void writeNodeArray(StringInfo str, const Node *const *arr, int len)
static void _outEquivalenceClass(StringInfo str, const EquivalenceClass *node)
void outBitmapset(StringInfo str, const Bitmapset *bms)
static int list_length(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
static Pointer DatumGetPointer(Datum X)
static const struct fns functions
#define DOUBLE_SHORTEST_DECIMAL_LEN
void check_stack_depth(void)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
struct EquivalenceClass * ec_merged
void(* nodeOut)(struct StringInfoData *str, const struct ExtensibleNode *node)
struct EquivalenceClass * eclass[INDEX_MAX_KEYS]
List * rinfos[INDEX_MAX_KEYS]