Thanks to visit codestin.com
Credit goes to doxygen.postgresql.org

PostgreSQL Source Code git master
outfuncs.c File Reference
#include "postgres.h"
#include <ctype.h>
#include "access/attnum.h"
#include "common/shortest_dec.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "nodes/bitmapset.h"
#include "nodes/nodes.h"
#include "nodes/pg_list.h"
#include "utils/datum.h"
#include "outfuncs.funcs.c"
#include "outfuncs.switch.c"
Include dependency graph for outfuncs.c:

Go to the source code of this file.

Macros

#define WRITE_NODE_TYPE(nodelabel)    appendStringInfoString(str, nodelabel)
 
#define WRITE_INT_FIELD(fldname)    appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)
 
#define WRITE_UINT_FIELD(fldname)    appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
 
#define WRITE_INT64_FIELD(fldname)
 
#define WRITE_UINT64_FIELD(fldname)
 
#define WRITE_OID_FIELD(fldname)    appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)
 
#define WRITE_LONG_FIELD(fldname)    appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)
 
#define WRITE_CHAR_FIELD(fldname)
 
#define WRITE_ENUM_FIELD(fldname, enumtype)
 
#define WRITE_FLOAT_FIELD(fldname)
 
#define WRITE_BOOL_FIELD(fldname)
 
#define WRITE_STRING_FIELD(fldname)
 
#define WRITE_LOCATION_FIELD(fldname)    appendStringInfo(str, " :" CppAsString(fldname) " %d", write_location_fields ? node->fldname : -1)
 
#define WRITE_NODE_FIELD(fldname)
 
#define WRITE_BITMAPSET_FIELD(fldname)
 
#define WRITE_NODE_ARRAY(fldname, len)
 
#define WRITE_ATTRNUMBER_ARRAY(fldname, len)
 
#define WRITE_OID_ARRAY(fldname, len)
 
#define WRITE_INDEX_ARRAY(fldname, len)
 
#define WRITE_INT_ARRAY(fldname, len)
 
#define WRITE_BOOL_ARRAY(fldname, len)
 
#define booltostr(x)   ((x) ? "true" : "false")
 
#define WRITE_SCALAR_ARRAY(fnname, datatype, fmtstr, convfunc)
 

Functions

static void outChar (StringInfo str, char c)
 
static void outDouble (StringInfo str, double d)
 
void outToken (StringInfo str, const char *s)
 
static void writeNodeArray (StringInfo str, const Node *const *arr, int len)
 
static void _outList (StringInfo str, const List *node)
 
void outBitmapset (StringInfo str, const Bitmapset *bms)
 
void outDatum (StringInfo str, Datum value, int typlen, bool typbyval)
 
static void _outConst (StringInfo str, const Const *node)
 
static void _outBoolExpr (StringInfo str, const BoolExpr *node)
 
static void _outForeignKeyOptInfo (StringInfo str, const ForeignKeyOptInfo *node)
 
static void _outEquivalenceClass (StringInfo str, const EquivalenceClass *node)
 
static void _outExtensibleNode (StringInfo str, const ExtensibleNode *node)
 
static void _outRangeTblEntry (StringInfo str, const RangeTblEntry *node)
 
static void _outA_Expr (StringInfo str, const A_Expr *node)
 
static void _outInteger (StringInfo str, const Integer *node)
 
static void _outFloat (StringInfo str, const Float *node)
 
static void _outBoolean (StringInfo str, const Boolean *node)
 
static void _outString (StringInfo str, const String *node)
 
static void _outBitString (StringInfo str, const BitString *node)
 
static void _outA_Const (StringInfo str, const A_Const *node)
 
void outNode (StringInfo str, const void *obj)
 
static char * nodeToStringInternal (const void *obj, bool write_loc_fields)
 
char * nodeToString (const void *obj)
 
char * nodeToStringWithLocations (const void *obj)
 
char * bmsToString (const Bitmapset *bms)
 

Variables

static bool write_location_fields = false
 

Macro Definition Documentation

◆ booltostr

#define booltostr (   x)    ((x) ? "true" : "false")

Definition at line 142 of file outfuncs.c.

◆ WRITE_ATTRNUMBER_ARRAY

#define WRITE_ATTRNUMBER_ARRAY (   fldname,
  len 
)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
writeAttrNumberCols(str, node->fldname, len))
#define CppAsString(identifier)
Definition: c.h:418
const char * str
const void size_t len
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:230

Definition at line 118 of file outfuncs.c.

◆ WRITE_BITMAPSET_FIELD

#define WRITE_BITMAPSET_FIELD (   fldname)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
outBitmapset(str, node->fldname))

Definition at line 108 of file outfuncs.c.

◆ WRITE_BOOL_ARRAY

#define WRITE_BOOL_ARRAY (   fldname,
  len 
)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
writeBoolCols(str, node->fldname, len))

Definition at line 138 of file outfuncs.c.

◆ WRITE_BOOL_FIELD

#define WRITE_BOOL_FIELD (   fldname)
Value:
appendStringInfo(str, " :" CppAsString(fldname) " %s", \
booltostr(node->fldname))
#define booltostr(x)
Definition: outfuncs.c:142
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:145

Definition at line 89 of file outfuncs.c.

◆ WRITE_CHAR_FIELD

#define WRITE_CHAR_FIELD (   fldname)
Value:
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
outChar(str, node->fldname))

Definition at line 74 of file outfuncs.c.

◆ WRITE_ENUM_FIELD

#define WRITE_ENUM_FIELD (   fldname,
  enumtype 
)
Value:
appendStringInfo(str, " :" CppAsString(fldname) " %d", \
(int) node->fldname)

Definition at line 79 of file outfuncs.c.

◆ WRITE_FLOAT_FIELD

#define WRITE_FLOAT_FIELD (   fldname)
Value:
(appendStringInfo(str, " :" CppAsString(fldname) " "), \
outDouble(str, node->fldname))

Definition at line 84 of file outfuncs.c.

◆ WRITE_INDEX_ARRAY

#define WRITE_INDEX_ARRAY (   fldname,
  len 
)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
writeIndexCols(str, node->fldname, len))

Definition at line 128 of file outfuncs.c.

◆ WRITE_INT64_FIELD

#define WRITE_INT64_FIELD (   fldname)
Value:
" :" CppAsString(fldname) " " INT64_FORMAT, \
node->fldname)
#define INT64_FORMAT
Definition: c.h:557

Definition at line 55 of file outfuncs.c.

◆ WRITE_INT_ARRAY

#define WRITE_INT_ARRAY (   fldname,
  len 
)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
writeIntCols(str, node->fldname, len))

Definition at line 133 of file outfuncs.c.

◆ WRITE_INT_FIELD

#define WRITE_INT_FIELD (   fldname)     appendStringInfo(str, " :" CppAsString(fldname) " %d", node->fldname)

Definition at line 47 of file outfuncs.c.

◆ WRITE_LOCATION_FIELD

#define WRITE_LOCATION_FIELD (   fldname)     appendStringInfo(str, " :" CppAsString(fldname) " %d", write_location_fields ? node->fldname : -1)

Definition at line 99 of file outfuncs.c.

◆ WRITE_LONG_FIELD

#define WRITE_LONG_FIELD (   fldname)     appendStringInfo(str, " :" CppAsString(fldname) " %ld", node->fldname)

Definition at line 70 of file outfuncs.c.

◆ WRITE_NODE_ARRAY

#define WRITE_NODE_ARRAY (   fldname,
  len 
)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
writeNodeArray(str, (const Node * const *) node->fldname, len))
Definition: nodes.h:135

Definition at line 113 of file outfuncs.c.

◆ WRITE_NODE_FIELD

#define WRITE_NODE_FIELD (   fldname)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
outNode(str, node->fldname))

Definition at line 103 of file outfuncs.c.

◆ WRITE_NODE_TYPE

#define WRITE_NODE_TYPE (   nodelabel)     appendStringInfoString(str, nodelabel)

Definition at line 43 of file outfuncs.c.

◆ WRITE_OID_ARRAY

#define WRITE_OID_ARRAY (   fldname,
  len 
)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
writeOidCols(str, node->fldname, len))

Definition at line 123 of file outfuncs.c.

◆ WRITE_OID_FIELD

#define WRITE_OID_FIELD (   fldname)     appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)

Definition at line 66 of file outfuncs.c.

◆ WRITE_SCALAR_ARRAY

#define WRITE_SCALAR_ARRAY (   fnname,
  datatype,
  fmtstr,
  convfunc 
)
Value:
static void \
fnname(StringInfo str, const datatype *arr, int len) \
{ \
if (arr != NULL) \
{ \
appendStringInfoChar(str, '('); \
for (int i = 0; i < len; i++) \
appendStringInfo(str, fmtstr, convfunc(arr[i])); \
appendStringInfoChar(str, ')'); \
} \
}
int i
Definition: isn.c:77
static void fmtstr(const char *value, int leftjust, int minlen, int maxwidth, int pointflag, PrintfTarget *target)
Definition: snprintf.c:1000

Definition at line 233 of file outfuncs.c.

◆ WRITE_STRING_FIELD

#define WRITE_STRING_FIELD (   fldname)
Value:
(appendStringInfoString(str, " :" CppAsString(fldname) " "), \
outToken(str, node->fldname))

Definition at line 94 of file outfuncs.c.

◆ WRITE_UINT64_FIELD

#define WRITE_UINT64_FIELD (   fldname)
Value:
node->fldname)
#define UINT64_FORMAT
Definition: c.h:558

Definition at line 61 of file outfuncs.c.

◆ WRITE_UINT_FIELD

#define WRITE_UINT_FIELD (   fldname)     appendStringInfo(str, " :" CppAsString(fldname) " %u", node->fldname)

Definition at line 51 of file outfuncs.c.

Function Documentation

◆ _outA_Const()

static void _outA_Const ( StringInfo  str,
const A_Const node 
)
static

Definition at line 710 of file outfuncs.c.

711{
712 WRITE_NODE_TYPE("A_CONST");
713
714 if (node->isnull)
715 appendStringInfoString(str, " NULL");
716 else
717 {
718 appendStringInfoString(str, " :val ");
719 outNode(str, &node->val);
720 }
721 WRITE_LOCATION_FIELD(location);
722}
#define WRITE_NODE_TYPE(nodelabel)
Definition: outfuncs.c:43
void outNode(StringInfo str, const void *obj)
Definition: outfuncs.c:730
#define WRITE_LOCATION_FIELD(fldname)
Definition: outfuncs.c:99
bool isnull
Definition: parsenodes.h:388
union ValUnion val
Definition: parsenodes.h:387

References appendStringInfoString(), A_Const::isnull, outNode(), str, A_Const::val, WRITE_LOCATION_FIELD, and WRITE_NODE_TYPE.

◆ _outA_Expr()

static void _outA_Expr ( StringInfo  str,
const A_Expr node 
)
static

Definition at line 588 of file outfuncs.c.

589{
590 WRITE_NODE_TYPE("A_EXPR");
591
592 switch (node->kind)
593 {
594 case AEXPR_OP:
596 break;
597 case AEXPR_OP_ANY:
600 break;
601 case AEXPR_OP_ALL:
604 break;
605 case AEXPR_DISTINCT:
606 appendStringInfoString(str, " DISTINCT");
608 break;
610 appendStringInfoString(str, " NOT_DISTINCT");
612 break;
613 case AEXPR_NULLIF:
614 appendStringInfoString(str, " NULLIF");
616 break;
617 case AEXPR_IN:
620 break;
621 case AEXPR_LIKE:
622 appendStringInfoString(str, " LIKE");
624 break;
625 case AEXPR_ILIKE:
626 appendStringInfoString(str, " ILIKE");
628 break;
629 case AEXPR_SIMILAR:
630 appendStringInfoString(str, " SIMILAR");
632 break;
633 case AEXPR_BETWEEN:
634 appendStringInfoString(str, " BETWEEN");
636 break;
638 appendStringInfoString(str, " NOT_BETWEEN");
640 break;
642 appendStringInfoString(str, " BETWEEN_SYM");
644 break;
646 appendStringInfoString(str, " NOT_BETWEEN_SYM");
648 break;
649 default:
650 elog(ERROR, "unrecognized A_Expr_Kind: %d", (int) node->kind);
651 break;
652 }
653
654 WRITE_NODE_FIELD(lexpr);
655 WRITE_NODE_FIELD(rexpr);
656 WRITE_LOCATION_FIELD(rexpr_list_start);
657 WRITE_LOCATION_FIELD(rexpr_list_end);
658 WRITE_LOCATION_FIELD(location);
659}
#define ERROR
Definition: elog.h:39
#define elog(elevel,...)
Definition: elog.h:226
#define WRITE_NODE_FIELD(fldname)
Definition: outfuncs.c:103
@ AEXPR_BETWEEN
Definition: parsenodes.h:340
@ AEXPR_NULLIF
Definition: parsenodes.h:335
@ AEXPR_NOT_DISTINCT
Definition: parsenodes.h:334
@ AEXPR_BETWEEN_SYM
Definition: parsenodes.h:342
@ AEXPR_NOT_BETWEEN_SYM
Definition: parsenodes.h:343
@ AEXPR_ILIKE
Definition: parsenodes.h:338
@ AEXPR_IN
Definition: parsenodes.h:336
@ AEXPR_NOT_BETWEEN
Definition: parsenodes.h:341
@ AEXPR_DISTINCT
Definition: parsenodes.h:333
@ AEXPR_SIMILAR
Definition: parsenodes.h:339
@ AEXPR_LIKE
Definition: parsenodes.h:337
@ AEXPR_OP
Definition: parsenodes.h:330
@ AEXPR_OP_ANY
Definition: parsenodes.h:331
@ AEXPR_OP_ALL
Definition: parsenodes.h:332
A_Expr_Kind kind
Definition: parsenodes.h:351
const char * name

References AEXPR_BETWEEN, AEXPR_BETWEEN_SYM, AEXPR_DISTINCT, AEXPR_ILIKE, AEXPR_IN, AEXPR_LIKE, AEXPR_NOT_BETWEEN, AEXPR_NOT_BETWEEN_SYM, AEXPR_NOT_DISTINCT, AEXPR_NULLIF, AEXPR_OP, AEXPR_OP_ALL, AEXPR_OP_ANY, AEXPR_SIMILAR, appendStringInfoString(), elog, ERROR, A_Expr::kind, name, str, WRITE_LOCATION_FIELD, WRITE_NODE_FIELD, and WRITE_NODE_TYPE.

◆ _outBitString()

static void _outBitString ( StringInfo  str,
const BitString node 
)
static

Definition at line 698 of file outfuncs.c.

699{
700 /*
701 * The lexer will always produce a string starting with 'b' or 'x'. There
702 * might be characters following that that need escaping, but outToken
703 * won't escape the 'b' or 'x'. This is relied on by nodeTokenType.
704 */
705 Assert(node->bsval[0] == 'b' || node->bsval[0] == 'x');
706 outToken(str, node->bsval);
707}
Assert(PointerIsAligned(start, uint64))
void outToken(StringInfo str, const char *s)
Definition: outfuncs.c:155
char * bsval
Definition: value.h:76

References Assert(), BitString::bsval, outToken(), and str.

Referenced by outNode().

◆ _outBoolean()

static void _outBoolean ( StringInfo  str,
const Boolean node 
)
static

Definition at line 678 of file outfuncs.c.

679{
680 appendStringInfoString(str, node->boolval ? "true" : "false");
681}
bool boolval
Definition: value.h:60

References appendStringInfoString(), Boolean::boolval, and str.

Referenced by outNode().

◆ _outBoolExpr()

static void _outBoolExpr ( StringInfo  str,
const BoolExpr node 
)
static

Definition at line 408 of file outfuncs.c.

409{
410 char *opstr = NULL;
411
412 WRITE_NODE_TYPE("BOOLEXPR");
413
414 /* do-it-yourself enum representation */
415 switch (node->boolop)
416 {
417 case AND_EXPR:
418 opstr = "and";
419 break;
420 case OR_EXPR:
421 opstr = "or";
422 break;
423 case NOT_EXPR:
424 opstr = "not";
425 break;
426 }
427 appendStringInfoString(str, " :boolop ");
428 outToken(str, opstr);
429
431 WRITE_LOCATION_FIELD(location);
432}
@ AND_EXPR
Definition: primnodes.h:950
@ OR_EXPR
Definition: primnodes.h:950
@ NOT_EXPR
Definition: primnodes.h:950
BoolExprType boolop
Definition: primnodes.h:958

References AND_EXPR, appendStringInfoString(), generate_unaccent_rules::args, BoolExpr::boolop, NOT_EXPR, OR_EXPR, outToken(), str, WRITE_LOCATION_FIELD, WRITE_NODE_FIELD, and WRITE_NODE_TYPE.

◆ _outConst()

static void _outConst ( StringInfo  str,
const Const node 
)
static

Definition at line 388 of file outfuncs.c.

389{
390 WRITE_NODE_TYPE("CONST");
391
392 WRITE_OID_FIELD(consttype);
393 WRITE_INT_FIELD(consttypmod);
394 WRITE_OID_FIELD(constcollid);
395 WRITE_INT_FIELD(constlen);
396 WRITE_BOOL_FIELD(constbyval);
397 WRITE_BOOL_FIELD(constisnull);
398 WRITE_LOCATION_FIELD(location);
399
400 appendStringInfoString(str, " :constvalue ");
401 if (node->constisnull)
403 else
404 outDatum(str, node->constvalue, node->constlen, node->constbyval);
405}
#define WRITE_OID_FIELD(fldname)
Definition: outfuncs.c:66
void outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
Definition: outfuncs.c:347
#define WRITE_BOOL_FIELD(fldname)
Definition: outfuncs.c:89
#define WRITE_INT_FIELD(fldname)
Definition: outfuncs.c:47

References appendStringInfoString(), outDatum(), str, WRITE_BOOL_FIELD, WRITE_INT_FIELD, WRITE_LOCATION_FIELD, WRITE_NODE_TYPE, and WRITE_OID_FIELD.

◆ _outEquivalenceClass()

static void _outEquivalenceClass ( StringInfo  str,
const EquivalenceClass node 
)
static

Definition at line 461 of file outfuncs.c.

462{
463 /*
464 * To simplify reading, we just chase up to the topmost merged EC and
465 * print that, without bothering to show the merge-ees separately.
466 */
467 while (node->ec_merged)
468 node = node->ec_merged;
469
470 WRITE_NODE_TYPE("EQUIVALENCECLASS");
471
472 WRITE_NODE_FIELD(ec_opfamilies);
473 WRITE_OID_FIELD(ec_collation);
474 WRITE_INT_FIELD(ec_childmembers_size);
475 WRITE_NODE_FIELD(ec_members);
476 WRITE_NODE_ARRAY(ec_childmembers, node->ec_childmembers_size);
477 WRITE_NODE_FIELD(ec_sources);
478 /* Only ec_derives_list is written; hash is not serialized. */
479 WRITE_NODE_FIELD(ec_derives_list);
480 WRITE_BITMAPSET_FIELD(ec_relids);
481 WRITE_BOOL_FIELD(ec_has_const);
482 WRITE_BOOL_FIELD(ec_has_volatile);
483 WRITE_BOOL_FIELD(ec_broken);
484 WRITE_UINT_FIELD(ec_sortref);
485 WRITE_UINT_FIELD(ec_min_security);
486 WRITE_UINT_FIELD(ec_max_security);
487}
#define WRITE_NODE_ARRAY(fldname, len)
Definition: outfuncs.c:113
#define WRITE_BITMAPSET_FIELD(fldname)
Definition: outfuncs.c:108
#define WRITE_UINT_FIELD(fldname)
Definition: outfuncs.c:51
int ec_childmembers_size
Definition: pathnodes.h:1474
struct EquivalenceClass * ec_merged
Definition: pathnodes.h:1490

References EquivalenceClass::ec_childmembers_size, EquivalenceClass::ec_merged, WRITE_BITMAPSET_FIELD, WRITE_BOOL_FIELD, WRITE_INT_FIELD, WRITE_NODE_ARRAY, WRITE_NODE_FIELD, WRITE_NODE_TYPE, WRITE_OID_FIELD, and WRITE_UINT_FIELD.

◆ _outExtensibleNode()

static void _outExtensibleNode ( StringInfo  str,
const ExtensibleNode node 
)
static

Definition at line 490 of file outfuncs.c.

491{
492 const ExtensibleNodeMethods *methods;
493
494 methods = GetExtensibleNodeMethods(node->extnodename, false);
495
496 WRITE_NODE_TYPE("EXTENSIBLENODE");
497
498 WRITE_STRING_FIELD(extnodename);
499
500 /* serialize the private fields */
501 methods->nodeOut(str, node);
502}
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
Definition: extensible.c:125
#define WRITE_STRING_FIELD(fldname)
Definition: outfuncs.c:94
void(* nodeOut)(struct StringInfoData *str, const struct ExtensibleNode *node)
Definition: extensible.h:70
const char * extnodename
Definition: extensible.h:37

References ExtensibleNode::extnodename, GetExtensibleNodeMethods(), ExtensibleNodeMethods::nodeOut, str, WRITE_NODE_TYPE, and WRITE_STRING_FIELD.

◆ _outFloat()

static void _outFloat ( StringInfo  str,
const Float node 
)
static

Definition at line 668 of file outfuncs.c.

669{
670 /*
671 * We assume the value is a valid numeric literal and so does not need
672 * quoting.
673 */
675}
char * fval
Definition: value.h:52

References appendStringInfoString(), Float::fval, and str.

Referenced by outNode().

◆ _outForeignKeyOptInfo()

static void _outForeignKeyOptInfo ( StringInfo  str,
const ForeignKeyOptInfo node 
)
static

Definition at line 435 of file outfuncs.c.

436{
437 int i;
438
439 WRITE_NODE_TYPE("FOREIGNKEYOPTINFO");
440
441 WRITE_UINT_FIELD(con_relid);
442 WRITE_UINT_FIELD(ref_relid);
443 WRITE_INT_FIELD(nkeys);
444 WRITE_ATTRNUMBER_ARRAY(conkey, node->nkeys);
445 WRITE_ATTRNUMBER_ARRAY(confkey, node->nkeys);
446 WRITE_OID_ARRAY(conpfeqop, node->nkeys);
447 WRITE_INT_FIELD(nmatched_ec);
448 WRITE_INT_FIELD(nconst_ec);
449 WRITE_INT_FIELD(nmatched_rcols);
450 WRITE_INT_FIELD(nmatched_ri);
451 /* for compactness, just print the number of matches per column: */
452 appendStringInfoString(str, " :eclass");
453 for (i = 0; i < node->nkeys; i++)
454 appendStringInfo(str, " %d", (node->eclass[i] != NULL));
455 appendStringInfoString(str, " :rinfos");
456 for (i = 0; i < node->nkeys; i++)
457 appendStringInfo(str, " %d", list_length(node->rinfos[i]));
458}
#define WRITE_ATTRNUMBER_ARRAY(fldname, len)
Definition: outfuncs.c:118
#define WRITE_OID_ARRAY(fldname, len)
Definition: outfuncs.c:123
static int list_length(const List *l)
Definition: pg_list.h:152
struct EquivalenceClass * eclass[INDEX_MAX_KEYS]
Definition: pathnodes.h:1309
List * rinfos[INDEX_MAX_KEYS]
Definition: pathnodes.h:1313

References appendStringInfo(), appendStringInfoString(), ForeignKeyOptInfo::eclass, i, list_length(), ForeignKeyOptInfo::nkeys, ForeignKeyOptInfo::rinfos, str, WRITE_ATTRNUMBER_ARRAY, WRITE_INT_FIELD, WRITE_NODE_TYPE, WRITE_OID_ARRAY, and WRITE_UINT_FIELD.

◆ _outInteger()

static void _outInteger ( StringInfo  str,
const Integer node 
)
static

Definition at line 662 of file outfuncs.c.

663{
664 appendStringInfo(str, "%d", node->ival);
665}
int ival
Definition: value.h:33

References appendStringInfo(), Integer::ival, and str.

Referenced by outNode().

◆ _outList()

static void _outList ( StringInfo  str,
const List node 
)
static

Definition at line 281 of file outfuncs.c.

282{
283 const ListCell *lc;
284
286
287 if (IsA(node, IntList))
289 else if (IsA(node, OidList))
291 else if (IsA(node, XidList))
293
294 foreach(lc, node)
295 {
296 /*
297 * For the sake of backward compatibility, we emit a slightly
298 * different whitespace format for lists of nodes vs. other types of
299 * lists. XXX: is this necessary?
300 */
301 if (IsA(node, List))
302 {
303 outNode(str, lfirst(lc));
304 if (lnext(node, lc))
306 }
307 else if (IsA(node, IntList))
308 appendStringInfo(str, " %d", lfirst_int(lc));
309 else if (IsA(node, OidList))
310 appendStringInfo(str, " %u", lfirst_oid(lc));
311 else if (IsA(node, XidList))
312 appendStringInfo(str, " %u", lfirst_xid(lc));
313 else
314 elog(ERROR, "unrecognized list node type: %d",
315 (int) node->type);
316 }
317
319}
#define IsA(nodeptr, _type_)
Definition: nodes.h:164
#define lfirst(lc)
Definition: pg_list.h:172
#define lfirst_int(lc)
Definition: pg_list.h:173
static ListCell * lnext(const List *l, const ListCell *c)
Definition: pg_list.h:343
#define lfirst_oid(lc)
Definition: pg_list.h:174
#define lfirst_xid(lc)
Definition: pg_list.h:175
void appendStringInfoChar(StringInfo str, char ch)
Definition: stringinfo.c:242
Definition: pg_list.h:54
NodeTag type
Definition: pg_list.h:55

References appendStringInfo(), appendStringInfoChar(), elog, ERROR, IsA, lfirst, lfirst_int, lfirst_oid, lfirst_xid, lnext(), outNode(), str, and List::type.

Referenced by outNode().

◆ _outRangeTblEntry()

static void _outRangeTblEntry ( StringInfo  str,
const RangeTblEntry node 
)
static

Definition at line 505 of file outfuncs.c.

506{
507 WRITE_NODE_TYPE("RANGETBLENTRY");
508
509 WRITE_NODE_FIELD(alias);
510 WRITE_NODE_FIELD(eref);
511 WRITE_ENUM_FIELD(rtekind, RTEKind);
512
513 switch (node->rtekind)
514 {
515 case RTE_RELATION:
516 WRITE_OID_FIELD(relid);
517 WRITE_BOOL_FIELD(inh);
518 WRITE_CHAR_FIELD(relkind);
519 WRITE_INT_FIELD(rellockmode);
520 WRITE_UINT_FIELD(perminfoindex);
521 WRITE_NODE_FIELD(tablesample);
522 break;
523 case RTE_SUBQUERY:
524 WRITE_NODE_FIELD(subquery);
525 WRITE_BOOL_FIELD(security_barrier);
526 /* we re-use these RELATION fields, too: */
527 WRITE_OID_FIELD(relid);
528 WRITE_BOOL_FIELD(inh);
529 WRITE_CHAR_FIELD(relkind);
530 WRITE_INT_FIELD(rellockmode);
531 WRITE_UINT_FIELD(perminfoindex);
532 break;
533 case RTE_JOIN:
534 WRITE_ENUM_FIELD(jointype, JoinType);
535 WRITE_INT_FIELD(joinmergedcols);
536 WRITE_NODE_FIELD(joinaliasvars);
537 WRITE_NODE_FIELD(joinleftcols);
538 WRITE_NODE_FIELD(joinrightcols);
539 WRITE_NODE_FIELD(join_using_alias);
540 break;
541 case RTE_FUNCTION:
543 WRITE_BOOL_FIELD(funcordinality);
544 break;
545 case RTE_TABLEFUNC:
546 WRITE_NODE_FIELD(tablefunc);
547 break;
548 case RTE_VALUES:
549 WRITE_NODE_FIELD(values_lists);
550 WRITE_NODE_FIELD(coltypes);
551 WRITE_NODE_FIELD(coltypmods);
552 WRITE_NODE_FIELD(colcollations);
553 break;
554 case RTE_CTE:
555 WRITE_STRING_FIELD(ctename);
556 WRITE_UINT_FIELD(ctelevelsup);
557 WRITE_BOOL_FIELD(self_reference);
558 WRITE_NODE_FIELD(coltypes);
559 WRITE_NODE_FIELD(coltypmods);
560 WRITE_NODE_FIELD(colcollations);
561 break;
563 WRITE_STRING_FIELD(enrname);
564 WRITE_FLOAT_FIELD(enrtuples);
565 WRITE_NODE_FIELD(coltypes);
566 WRITE_NODE_FIELD(coltypmods);
567 WRITE_NODE_FIELD(colcollations);
568 /* we re-use these RELATION fields, too: */
569 WRITE_OID_FIELD(relid);
570 break;
571 case RTE_RESULT:
572 /* no extra fields */
573 break;
574 case RTE_GROUP:
575 WRITE_NODE_FIELD(groupexprs);
576 break;
577 default:
578 elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
579 break;
580 }
581
582 WRITE_BOOL_FIELD(lateral);
583 WRITE_BOOL_FIELD(inFromCl);
584 WRITE_NODE_FIELD(securityQuals);
585}
JoinType
Definition: nodes.h:298
#define WRITE_ENUM_FIELD(fldname, enumtype)
Definition: outfuncs.c:79
#define WRITE_FLOAT_FIELD(fldname)
Definition: outfuncs.c:84
#define WRITE_CHAR_FIELD(fldname)
Definition: outfuncs.c:74
RTEKind
Definition: parsenodes.h:1041
@ RTE_JOIN
Definition: parsenodes.h:1044
@ RTE_CTE
Definition: parsenodes.h:1048
@ RTE_NAMEDTUPLESTORE
Definition: parsenodes.h:1049
@ RTE_VALUES
Definition: parsenodes.h:1047
@ RTE_SUBQUERY
Definition: parsenodes.h:1043
@ RTE_RESULT
Definition: parsenodes.h:1050
@ RTE_FUNCTION
Definition: parsenodes.h:1045
@ RTE_TABLEFUNC
Definition: parsenodes.h:1046
@ RTE_GROUP
Definition: parsenodes.h:1053
@ RTE_RELATION
Definition: parsenodes.h:1042
static const struct fns functions
Definition: regcomp.c:358
RTEKind rtekind
Definition: parsenodes.h:1077

References elog, ERROR, functions, RTE_CTE, RTE_FUNCTION, RTE_GROUP, RTE_JOIN, RTE_NAMEDTUPLESTORE, RTE_RELATION, RTE_RESULT, RTE_SUBQUERY, RTE_TABLEFUNC, RTE_VALUES, RangeTblEntry::rtekind, WRITE_BOOL_FIELD, WRITE_CHAR_FIELD, WRITE_ENUM_FIELD, WRITE_FLOAT_FIELD, WRITE_INT_FIELD, WRITE_NODE_FIELD, WRITE_NODE_TYPE, WRITE_OID_FIELD, WRITE_STRING_FIELD, and WRITE_UINT_FIELD.

◆ _outString()

static void _outString ( StringInfo  str,
const String node 
)
static

Definition at line 684 of file outfuncs.c.

685{
686 /*
687 * We use outToken to provide escaping of the string's content, but we
688 * don't want it to convert an empty string to '""', because we're putting
689 * double quotes around the string already.
690 */
692 if (node->sval[0] != '\0')
693 outToken(str, node->sval);
695}
char * sval
Definition: value.h:68

References appendStringInfoChar(), outToken(), str, and String::sval.

Referenced by outNode().

◆ bmsToString()

char * bmsToString ( const Bitmapset bms)

Definition at line 822 of file outfuncs.c.

823{
825
826 /* see stringinfo.h for an explanation of this maneuver */
828 outBitmapset(&str, bms);
829 return str.data;
830}
void outBitmapset(StringInfo str, const Bitmapset *bms)
Definition: outfuncs.c:331
void initStringInfo(StringInfo str)
Definition: stringinfo.c:97

References initStringInfo(), outBitmapset(), and str.

Referenced by ExecInitPartitionExecPruning(), search_indexed_tlist_for_phv(), and search_indexed_tlist_for_var().

◆ nodeToString()

◆ nodeToStringInternal()

static char * nodeToStringInternal ( const void *  obj,
bool  write_loc_fields 
)
static

Definition at line 784 of file outfuncs.c.

785{
787 bool save_write_location_fields;
788
789 save_write_location_fields = write_location_fields;
790 write_location_fields = write_loc_fields;
791
792 /* see stringinfo.h for an explanation of this maneuver */
794 outNode(&str, obj);
795
796 write_location_fields = save_write_location_fields;
797
798 return str.data;
799}
static bool write_location_fields
Definition: outfuncs.c:29

References initStringInfo(), outNode(), str, and write_location_fields.

Referenced by nodeToString(), and nodeToStringWithLocations().

◆ nodeToStringWithLocations()

char * nodeToStringWithLocations ( const void *  obj)

Definition at line 811 of file outfuncs.c.

812{
813 return nodeToStringInternal(obj, true);
814}

References nodeToStringInternal().

Referenced by elog_node_display(), pg_parse_query(), pg_plan_query(), pg_rewrite_query(), pprint(), and print().

◆ outBitmapset()

void outBitmapset ( StringInfo  str,
const Bitmapset bms 
)

Definition at line 331 of file outfuncs.c.

332{
333 int x;
334
337 x = -1;
338 while ((x = bms_next_member(bms, x)) >= 0)
339 appendStringInfo(str, " %d", x);
341}
int bms_next_member(const Bitmapset *a, int prevbit)
Definition: bitmapset.c:1306
int x
Definition: isn.c:75

References appendStringInfo(), appendStringInfoChar(), bms_next_member(), str, and x.

Referenced by bmsToString(), and outNode().

◆ outChar()

static void outChar ( StringInfo  str,
char  c 
)
static

Definition at line 196 of file outfuncs.c.

197{
198 char in[2];
199
200 /* Traditionally, we've represented \0 as <>, so keep doing that */
201 if (c == '\0')
202 {
204 return;
205 }
206
207 in[0] = c;
208 in[1] = '\0';
209
210 outToken(str, in);
211}
char * c

References appendStringInfoString(), outToken(), and str.

◆ outDatum()

void outDatum ( StringInfo  str,
Datum  value,
int  typlen,
bool  typbyval 
)

Definition at line 347 of file outfuncs.c.

348{
349 Size length,
350 i;
351 char *s;
352
353 length = datumGetSize(value, typbyval, typlen);
354
355 if (typbyval)
356 {
357 s = (char *) (&value);
358 appendStringInfo(str, "%u [ ", (unsigned int) length);
359 for (i = 0; i < (Size) sizeof(Datum); i++)
360 appendStringInfo(str, "%d ", (int) (s[i]));
362 }
363 else
364 {
365 s = (char *) DatumGetPointer(value);
366 if (!s)
367 appendStringInfoString(str, "0 [ ]");
368 else
369 {
370 appendStringInfo(str, "%u [ ", (unsigned int) length);
371 for (i = 0; i < length; i++)
372 appendStringInfo(str, "%d ", (int) (s[i]));
374 }
375 }
376}
size_t Size
Definition: c.h:611
Size datumGetSize(Datum value, bool typByVal, int typLen)
Definition: datum.c:65
static struct @166 value
uint64_t Datum
Definition: postgres.h:70
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:322

References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), DatumGetPointer(), datumGetSize(), i, str, and value.

Referenced by _outConst().

◆ outDouble()

static void outDouble ( StringInfo  str,
double  d 
)
static

Definition at line 217 of file outfuncs.c.

218{
220
223}
int double_to_shortest_decimal_buf(double f, char *result)
Definition: d2s.c:1053
static char * buf
Definition: pg_test_fsync.c:72
#define DOUBLE_SHORTEST_DECIMAL_LEN
Definition: shortest_dec.h:44

References appendStringInfoString(), buf, DOUBLE_SHORTEST_DECIMAL_LEN, double_to_shortest_decimal_buf(), and str.

◆ outNode()

void outNode ( StringInfo  str,
const void *  obj 
)

Definition at line 730 of file outfuncs.c.

731{
732 /* Guard against stack overflow due to overly complex expressions */
734
735 if (obj == NULL)
737 else if (IsA(obj, List) || IsA(obj, IntList) || IsA(obj, OidList) ||
738 IsA(obj, XidList))
739 _outList(str, obj);
740 /* nodeRead does not want to see { } around these! */
741 else if (IsA(obj, Integer))
742 _outInteger(str, (Integer *) obj);
743 else if (IsA(obj, Float))
744 _outFloat(str, (Float *) obj);
745 else if (IsA(obj, Boolean))
746 _outBoolean(str, (Boolean *) obj);
747 else if (IsA(obj, String))
748 _outString(str, (String *) obj);
749 else if (IsA(obj, BitString))
750 _outBitString(str, (BitString *) obj);
751 else if (IsA(obj, Bitmapset))
752 outBitmapset(str, (Bitmapset *) obj);
753 else
754 {
756 switch (nodeTag(obj))
757 {
758#include "outfuncs.switch.c"
759
760 default:
761
762 /*
763 * This should be an ERROR, but it's too useful to be able to
764 * dump structures that outNode only understands part of.
765 */
766 elog(WARNING, "could not dump unrecognized node type: %d",
767 (int) nodeTag(obj));
768 break;
769 }
771 }
772}
#define WARNING
Definition: elog.h:36
#define nodeTag(nodeptr)
Definition: nodes.h:139
static void _outString(StringInfo str, const String *node)
Definition: outfuncs.c:684
static void _outInteger(StringInfo str, const Integer *node)
Definition: outfuncs.c:662
static void _outList(StringInfo str, const List *node)
Definition: outfuncs.c:281
static void _outFloat(StringInfo str, const Float *node)
Definition: outfuncs.c:668
static void _outBitString(StringInfo str, const BitString *node)
Definition: outfuncs.c:698
static void _outBoolean(StringInfo str, const Boolean *node)
Definition: outfuncs.c:678
void check_stack_depth(void)
Definition: stack_depth.c:95
Definition: value.h:56
Definition: value.h:48
Definition: value.h:29
Definition: value.h:64

References _outBitString(), _outBoolean(), _outFloat(), _outInteger(), _outList(), _outString(), appendStringInfoChar(), appendStringInfoString(), check_stack_depth(), elog, IsA, nodeTag, outBitmapset(), str, and WARNING.

Referenced by _outA_Const(), _outList(), nodeToStringInternal(), and writeNodeArray().

◆ outToken()

void outToken ( StringInfo  str,
const char *  s 
)

Definition at line 155 of file outfuncs.c.

156{
157 if (s == NULL)
158 {
160 return;
161 }
162 if (*s == '\0')
163 {
165 return;
166 }
167
168 /*
169 * Look for characters or patterns that are treated specially by read.c
170 * (either in pg_strtok() or in nodeRead()), and therefore need a
171 * protective backslash.
172 */
173 /* These characters only need to be quoted at the start of the string */
174 if (*s == '<' ||
175 *s == '"' ||
176 isdigit((unsigned char) *s) ||
177 ((*s == '+' || *s == '-') &&
178 (isdigit((unsigned char) s[1]) || s[1] == '.')))
180 while (*s)
181 {
182 /* These chars must be backslashed anywhere in the string */
183 if (*s == ' ' || *s == '\n' || *s == '\t' ||
184 *s == '(' || *s == ')' || *s == '{' || *s == '}' ||
185 *s == '\\')
188 }
189}

References appendStringInfoChar(), appendStringInfoString(), and str.

Referenced by _outBitString(), _outBoolExpr(), _outString(), and outChar().

◆ writeNodeArray()

static void writeNodeArray ( StringInfo  str,
const Node *const *  arr,
int  len 
)
static

Definition at line 261 of file outfuncs.c.

262{
263 if (arr != NULL)
264 {
266 for (int i = 0; i < len; i++)
267 {
269 outNode(str, arr[i]);
270 }
272 }
273 else
275}

References appendStringInfoChar(), appendStringInfoString(), i, len, outNode(), and str.

Variable Documentation

◆ write_location_fields

bool write_location_fields = false
static

Definition at line 29 of file outfuncs.c.

Referenced by nodeToStringInternal().