#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"">

PostgreSQL Source Code: src/backend/nodes/outfuncs.c File Reference (original) (raw)

#include "[postgres.h](postgres%5F8h%5Fsource.html)"
#include <ctype.h>
#include "[access/attnum.h](attnum%5F8h%5Fsource.html)"
#include "[common/shortest_dec.h](shortest%5F%5Fdec%5F8h%5Fsource.html)"
#include "[lib/stringinfo.h](stringinfo%5F8h%5Fsource.html)"
#include "[miscadmin.h](miscadmin%5F8h%5Fsource.html)"
#include "[nodes/bitmapset.h](bitmapset%5F8h%5Fsource.html)"
#include "[nodes/nodes.h](nodes%5F8h%5Fsource.html)"
#include "[nodes/pg_list.h](pg%5F%5Flist%5F8h%5Fsource.html)"
#include "[utils/datum.h](datum%5F8h%5Fsource.html)"
#include "outfuncs.funcs.c"
#include "outfuncs.switch.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_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)

booltostr

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

WRITE_ATTRNUMBER_ARRAY

| #define WRITE_ATTRNUMBER_ARRAY | ( | | fldname, | | ------------------------------------------------------------------------------- | - | | -------- | | | len | | | | | ) | | | |

Value:

writeAttrNumberCols(str, node->fldname, len))

#define CppAsString(identifier)

void appendStringInfoString(StringInfo str, const char *s)

Definition at line 112 of file outfuncs.c.

WRITE_BITMAPSET_FIELD

| #define WRITE_BITMAPSET_FIELD | ( | | fldname | ) | | ------------------------------- | - | | ------- | - |

Value:

outBitmapset(str, node->fldname))

Definition at line 102 of file outfuncs.c.

WRITE_BOOL_ARRAY

| #define WRITE_BOOL_ARRAY | ( | | fldname, | | ------------------------------------------------------------------------------- | - | | -------- | | | len | | | | | ) | | | |

WRITE_BOOL_FIELD

| #define WRITE_BOOL_FIELD | ( | | fldname | ) | | -------------------------- | - | | ------- | - |

Value:

void appendStringInfo(StringInfo str, const char *fmt,...)

Definition at line 83 of file outfuncs.c.

WRITE_CHAR_FIELD

| #define WRITE_CHAR_FIELD | ( | | fldname | ) | | -------------------------- | - | | ------- | - |

Value:

outChar(str, node->fldname))

Definition at line 68 of file outfuncs.c.

WRITE_ENUM_FIELD

| #define WRITE_ENUM_FIELD | ( | | fldname, | | -------------------------- | - | | -------- | | | enumtype | | | | | ) | | | |

WRITE_FLOAT_FIELD

| #define WRITE_FLOAT_FIELD | ( | | fldname | ) | | --------------------------- | - | | ------- | - |

Value:

outDouble(str, node->fldname))

Definition at line 78 of file outfuncs.c.

WRITE_INDEX_ARRAY

| #define WRITE_INDEX_ARRAY | ( | | fldname, | | ------------------------------------------------------------------------------- | - | | -------- | | | len | | | | | ) | | | |

WRITE_INT_ARRAY

| #define WRITE_INT_ARRAY | ( | | fldname, | | ------------------------------------------------------------------------------- | - | | -------- | | | len | | | | | ) | | | |

WRITE_INT_FIELD

WRITE_LOCATION_FIELD

WRITE_LONG_FIELD

WRITE_NODE_ARRAY

| #define WRITE_NODE_ARRAY | ( | | fldname, | | ------------------------------------------------------------------------------- | - | | -------- | | | len | | | | | ) | | | |

WRITE_NODE_FIELD

| #define WRITE_NODE_FIELD | ( | | fldname | ) | | -------------------------- | - | | ------- | - |

Value:

outNode(str, node->fldname))

Definition at line 97 of file outfuncs.c.

WRITE_NODE_TYPE

WRITE_OID_ARRAY

| #define WRITE_OID_ARRAY | ( | | fldname, | | ------------------------------------------------------------------------------- | - | | -------- | | | len | | | | | ) | | | |

WRITE_OID_FIELD

WRITE_SCALAR_ARRAY

| #define WRITE_SCALAR_ARRAY | ( | | fnname, | | ------------------------------------------------------------------ | - | | ------- | | | datatype, | | | | | | fmtstr, | | | | | | convfunc | | | | | ) | | | |

Value:

static void \

{ \

if (arr != NULL) \

{ \

appendStringInfoChar(str, '('); \

for (int i = 0; i < len; i++) \

appendStringInfoChar(str, ')'); \

}

static void fmtstr(const char *value, int leftjust, int minlen, int maxwidth, int pointflag, PrintfTarget *target)

Definition at line 227 of file outfuncs.c.

WRITE_STRING_FIELD

| #define WRITE_STRING_FIELD | ( | | fldname | ) | | ---------------------------- | - | | ------- | - |

Value:

outToken(str, node->fldname))

Definition at line 88 of file outfuncs.c.

WRITE_UINT64_FIELD

| #define WRITE_UINT64_FIELD | ( | | fldname | ) | | ---------------------------- | - | | ------- | - |

WRITE_UINT_FIELD

_outA_Const()

_outA_Expr()

Definition at line 582 of file outfuncs.c.

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}

#define WRITE_NODE_FIELD(fldname)

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()

_outBoolean()

_outBoolExpr()

Definition at line 402 of file outfuncs.c.

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}

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()

Definition at line 382 of file outfuncs.c.

383{

385

393

395 if (node->constisnull)

397 else

398 outDatum(str, node->constvalue, node->constlen, node->constbyval);

399}

#define WRITE_OID_FIELD(fldname)

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

#define WRITE_BOOL_FIELD(fldname)

#define WRITE_INT_FIELD(fldname)

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

_outEquivalenceClass()

Definition at line 455 of file outfuncs.c.

456{

457

458

459

460

463

465

472

481}

#define WRITE_NODE_ARRAY(fldname, len)

#define WRITE_BITMAPSET_FIELD(fldname)

#define WRITE_UINT_FIELD(fldname)

struct EquivalenceClass * ec_merged

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()

_outFloat()

_outForeignKeyOptInfo()

Definition at line 429 of file outfuncs.c.

430{

431 int i;

432

434

445

447 for (i = 0; i < node->nkeys; i++)

450 for (i = 0; i < node->nkeys; i++)

452}

#define WRITE_ATTRNUMBER_ARRAY(fldname, len)

#define WRITE_OID_ARRAY(fldname, len)

static int list_length(const List *l)

struct EquivalenceClass * eclass[INDEX_MAX_KEYS]

List * rinfos[INDEX_MAX_KEYS]

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()

_outList()

Definition at line 275 of file outfuncs.c.

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}

#define IsA(nodeptr, _type_)

static ListCell * lnext(const List *l, const ListCell *c)

void appendStringInfoChar(StringInfo str, char ch)

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

Referenced by outNode().

_outRangeTblEntry()

Definition at line 499 of file outfuncs.c.

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}

#define WRITE_ENUM_FIELD(fldname, enumtype)

#define WRITE_FLOAT_FIELD(fldname)

#define WRITE_CHAR_FIELD(fldname)

static const struct fns functions

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()

bmsToString()

nodeToString()

char * nodeToString ( const void * obj )

Definition at line 797 of file outfuncs.c.

798{

800}

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

References nodeToStringInternal().

Referenced by AlterDomainDefault(), AlterPolicy(), CreatePolicy(), CreateStatistics(), CreateTriggerFiringOn(), DefineDomain(), DetachAddConstraintIfNeeded(), domainAddCheckConstraint(), ExecSerializePlan(), expandTableLikeClause(), InsertRule(), ProcedureCreate(), publication_add_relation(), StoreAttrDefault(), StorePartitionBound(), StorePartitionKey(), StoreRelCheck(), and UpdateIndexRelation().

nodeToStringInternal()

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

nodeToStringWithLocations()

char * nodeToStringWithLocations ( const void * obj )

outBitmapset()

outChar()

static void outChar ( StringInfo str, char c ) static

outDatum()

Definition at line 341 of file outfuncs.c.

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}

#define PointerIsValid(pointer)

Size datumGetSize(Datum value, bool typByVal, int typLen)

static Pointer DatumGetPointer(Datum X)

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

Referenced by _outConst().

outDouble()

static void outDouble ( StringInfo str, double d ) static

outNode()

Definition at line 722 of file outfuncs.c.

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}

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

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

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

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

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

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

void check_stack_depth(void)

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()

Definition at line 149 of file outfuncs.c.

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}

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

write_location_fields

bool write_location_fields = false static