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_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", node->fldname)
 
#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)
 
static void _outConstraint (StringInfo str, const Constraint *node)
 
void outNode (StringInfo str, const void *obj)
 
char * nodeToString (const void *obj)
 
char * bmsToString (const Bitmapset *bms)
 

Macro Definition Documentation

◆ booltostr

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

Definition at line 133 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:310
const void size_t len
void appendStringInfoString(StringInfo str, const char *s)
Definition: stringinfo.c:176

Definition at line 109 of file outfuncs.c.

◆ WRITE_BITMAPSET_FIELD

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

Definition at line 99 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 129 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:133
void appendStringInfo(StringInfo str, const char *fmt,...)
Definition: stringinfo.c:91

Definition at line 80 of file outfuncs.c.

◆ WRITE_CHAR_FIELD

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

Definition at line 65 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 70 of file outfuncs.c.

◆ WRITE_FLOAT_FIELD

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

Definition at line 75 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 119 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 124 of file outfuncs.c.

◆ WRITE_INT_FIELD

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

Definition at line 44 of file outfuncs.c.

◆ WRITE_LOCATION_FIELD

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

Definition at line 90 of file outfuncs.c.

◆ WRITE_LONG_FIELD

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

Definition at line 61 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:129

Definition at line 104 of file outfuncs.c.

◆ WRITE_NODE_FIELD

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

Definition at line 94 of file outfuncs.c.

◆ WRITE_NODE_TYPE

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

Definition at line 40 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 114 of file outfuncs.c.

◆ WRITE_OID_FIELD

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

Definition at line 57 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:73
static void fmtstr(const char *value, int leftjust, int minlen, int maxwidth, int pointflag, PrintfTarget *target)
Definition: snprintf.c:967

Definition at line 224 of file outfuncs.c.

◆ WRITE_STRING_FIELD

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

Definition at line 85 of file outfuncs.c.

◆ WRITE_UINT64_FIELD

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

Definition at line 52 of file outfuncs.c.

◆ WRITE_UINT_FIELD

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

Definition at line 48 of file outfuncs.c.

Function Documentation

◆ _outA_Const()

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

Definition at line 687 of file outfuncs.c.

688 {
689  WRITE_NODE_TYPE("A_CONST");
690 
691  if (node->isnull)
692  appendStringInfoString(str, " NULL");
693  else
694  {
695  appendStringInfoString(str, " :val ");
696  outNode(str, &node->val);
697  }
698  WRITE_LOCATION_FIELD(location);
699 }
#define WRITE_NODE_TYPE(nodelabel)
Definition: outfuncs.c:40
void outNode(StringInfo str, const void *obj)
Definition: outfuncs.c:828
#define WRITE_LOCATION_FIELD(fldname)
Definition: outfuncs.c:90
bool isnull
Definition: parsenodes.h:361
union ValUnion val
Definition: parsenodes.h:360

References appendStringInfoString(), A_Const::isnull, outNode(), generate_unaccent_rules::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 572 of file outfuncs.c.

573 {
574  WRITE_NODE_TYPE("A_EXPR");
575 
576  switch (node->kind)
577  {
578  case AEXPR_OP:
580  break;
581  case AEXPR_OP_ANY:
582  appendStringInfoString(str, " ANY");
584  break;
585  case AEXPR_OP_ALL:
586  appendStringInfoString(str, " ALL");
588  break;
589  case AEXPR_DISTINCT:
590  appendStringInfoString(str, " DISTINCT");
592  break;
593  case AEXPR_NOT_DISTINCT:
594  appendStringInfoString(str, " NOT_DISTINCT");
596  break;
597  case AEXPR_NULLIF:
598  appendStringInfoString(str, " NULLIF");
600  break;
601  case AEXPR_IN:
602  appendStringInfoString(str, " IN");
604  break;
605  case AEXPR_LIKE:
606  appendStringInfoString(str, " LIKE");
608  break;
609  case AEXPR_ILIKE:
610  appendStringInfoString(str, " ILIKE");
612  break;
613  case AEXPR_SIMILAR:
614  appendStringInfoString(str, " SIMILAR");
616  break;
617  case AEXPR_BETWEEN:
618  appendStringInfoString(str, " BETWEEN");
620  break;
621  case AEXPR_NOT_BETWEEN:
622  appendStringInfoString(str, " NOT_BETWEEN");
624  break;
625  case AEXPR_BETWEEN_SYM:
626  appendStringInfoString(str, " BETWEEN_SYM");
628  break;
630  appendStringInfoString(str, " NOT_BETWEEN_SYM");
632  break;
633  default:
634  elog(ERROR, "unrecognized A_Expr_Kind: %d", (int) node->kind);
635  break;
636  }
637 
638  WRITE_NODE_FIELD(lexpr);
639  WRITE_NODE_FIELD(rexpr);
640  WRITE_LOCATION_FIELD(location);
641 }
#define ERROR
Definition: elog.h:39
const char * name
Definition: encode.c:571
#define WRITE_NODE_FIELD(fldname)
Definition: outfuncs.c:94
@ AEXPR_BETWEEN
Definition: parsenodes.h:321
@ AEXPR_NULLIF
Definition: parsenodes.h:316
@ AEXPR_NOT_DISTINCT
Definition: parsenodes.h:315
@ AEXPR_BETWEEN_SYM
Definition: parsenodes.h:323
@ AEXPR_NOT_BETWEEN_SYM
Definition: parsenodes.h:324
@ AEXPR_ILIKE
Definition: parsenodes.h:319
@ AEXPR_IN
Definition: parsenodes.h:317
@ AEXPR_NOT_BETWEEN
Definition: parsenodes.h:322
@ AEXPR_DISTINCT
Definition: parsenodes.h:314
@ AEXPR_SIMILAR
Definition: parsenodes.h:320
@ AEXPR_LIKE
Definition: parsenodes.h:318
@ AEXPR_OP
Definition: parsenodes.h:311
@ AEXPR_OP_ANY
Definition: parsenodes.h:312
@ AEXPR_OP_ALL
Definition: parsenodes.h:313
A_Expr_Kind kind
Definition: parsenodes.h:332

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, generate_unaccent_rules::str, WRITE_LOCATION_FIELD, WRITE_NODE_FIELD, and WRITE_NODE_TYPE.

◆ _outBitString()

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

Definition at line 680 of file outfuncs.c.

681 {
682  /* internal representation already has leading 'b' */
684 }
char * bsval
Definition: value.h:76

References appendStringInfoString(), BitString::bsval, and generate_unaccent_rules::str.

Referenced by outNode().

◆ _outBoolean()

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

Definition at line 660 of file outfuncs.c.

661 {
662  appendStringInfoString(str, node->boolval ? "true" : "false");
663 }
bool boolval
Definition: value.h:60

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

Referenced by outNode().

◆ _outBoolExpr()

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

Definition at line 399 of file outfuncs.c.

400 {
401  char *opstr = NULL;
402 
403  WRITE_NODE_TYPE("BOOLEXPR");
404 
405  /* do-it-yourself enum representation */
406  switch (node->boolop)
407  {
408  case AND_EXPR:
409  opstr = "and";
410  break;
411  case OR_EXPR:
412  opstr = "or";
413  break;
414  case NOT_EXPR:
415  opstr = "not";
416  break;
417  }
418  appendStringInfoString(str, " :boolop ");
419  outToken(str, opstr);
420 
422  WRITE_LOCATION_FIELD(location);
423 }
void outToken(StringInfo str, const char *s)
Definition: outfuncs.c:146
@ AND_EXPR
Definition: primnodes.h:858
@ OR_EXPR
Definition: primnodes.h:858
@ NOT_EXPR
Definition: primnodes.h:858
BoolExprType boolop
Definition: primnodes.h:866

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

◆ _outConst()

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

Definition at line 379 of file outfuncs.c.

380 {
381  WRITE_NODE_TYPE("CONST");
382 
383  WRITE_OID_FIELD(consttype);
384  WRITE_INT_FIELD(consttypmod);
385  WRITE_OID_FIELD(constcollid);
386  WRITE_INT_FIELD(constlen);
387  WRITE_BOOL_FIELD(constbyval);
388  WRITE_BOOL_FIELD(constisnull);
389  WRITE_LOCATION_FIELD(location);
390 
391  appendStringInfoString(str, " :constvalue ");
392  if (node->constisnull)
394  else
395  outDatum(str, node->constvalue, node->constlen, node->constbyval);
396 }
#define WRITE_OID_FIELD(fldname)
Definition: outfuncs.c:57
void outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
Definition: outfuncs.c:338
#define WRITE_BOOL_FIELD(fldname)
Definition: outfuncs.c:80
#define WRITE_INT_FIELD(fldname)
Definition: outfuncs.c:44

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

◆ _outConstraint()

static void _outConstraint ( StringInfo  str,
const Constraint node 
)
static

Definition at line 702 of file outfuncs.c.

703 {
704  WRITE_NODE_TYPE("CONSTRAINT");
705 
706  WRITE_STRING_FIELD(conname);
707  WRITE_BOOL_FIELD(deferrable);
708  WRITE_BOOL_FIELD(initdeferred);
709  WRITE_LOCATION_FIELD(location);
710 
711  appendStringInfoString(str, " :contype ");
712  switch (node->contype)
713  {
714  case CONSTR_NULL:
715  appendStringInfoString(str, "NULL");
716  break;
717 
718  case CONSTR_NOTNULL:
719  appendStringInfoString(str, "NOT_NULL");
720  break;
721 
722  case CONSTR_DEFAULT:
723  appendStringInfoString(str, "DEFAULT");
724  WRITE_NODE_FIELD(raw_expr);
725  WRITE_STRING_FIELD(cooked_expr);
726  break;
727 
728  case CONSTR_IDENTITY:
729  appendStringInfoString(str, "IDENTITY");
731  WRITE_CHAR_FIELD(generated_when);
732  break;
733 
734  case CONSTR_GENERATED:
735  appendStringInfoString(str, "GENERATED");
736  WRITE_NODE_FIELD(raw_expr);
737  WRITE_STRING_FIELD(cooked_expr);
738  WRITE_CHAR_FIELD(generated_when);
739  break;
740 
741  case CONSTR_CHECK:
742  appendStringInfoString(str, "CHECK");
743  WRITE_BOOL_FIELD(is_no_inherit);
744  WRITE_NODE_FIELD(raw_expr);
745  WRITE_STRING_FIELD(cooked_expr);
746  WRITE_BOOL_FIELD(skip_validation);
747  WRITE_BOOL_FIELD(initially_valid);
748  break;
749 
750  case CONSTR_PRIMARY:
751  appendStringInfoString(str, "PRIMARY_KEY");
752  WRITE_NODE_FIELD(keys);
753  WRITE_NODE_FIELD(including);
755  WRITE_STRING_FIELD(indexname);
756  WRITE_STRING_FIELD(indexspace);
757  WRITE_BOOL_FIELD(reset_default_tblspc);
758  /* access_method and where_clause not currently used */
759  break;
760 
761  case CONSTR_UNIQUE:
762  appendStringInfoString(str, "UNIQUE");
763  WRITE_BOOL_FIELD(nulls_not_distinct);
764  WRITE_NODE_FIELD(keys);
765  WRITE_NODE_FIELD(including);
767  WRITE_STRING_FIELD(indexname);
768  WRITE_STRING_FIELD(indexspace);
769  WRITE_BOOL_FIELD(reset_default_tblspc);
770  /* access_method and where_clause not currently used */
771  break;
772 
773  case CONSTR_EXCLUSION:
774  appendStringInfoString(str, "EXCLUSION");
775  WRITE_NODE_FIELD(exclusions);
776  WRITE_NODE_FIELD(including);
778  WRITE_STRING_FIELD(indexname);
779  WRITE_STRING_FIELD(indexspace);
780  WRITE_BOOL_FIELD(reset_default_tblspc);
781  WRITE_STRING_FIELD(access_method);
782  WRITE_NODE_FIELD(where_clause);
783  break;
784 
785  case CONSTR_FOREIGN:
786  appendStringInfoString(str, "FOREIGN_KEY");
787  WRITE_NODE_FIELD(pktable);
788  WRITE_NODE_FIELD(fk_attrs);
789  WRITE_NODE_FIELD(pk_attrs);
790  WRITE_CHAR_FIELD(fk_matchtype);
791  WRITE_CHAR_FIELD(fk_upd_action);
792  WRITE_CHAR_FIELD(fk_del_action);
793  WRITE_NODE_FIELD(fk_del_set_cols);
794  WRITE_NODE_FIELD(old_conpfeqop);
795  WRITE_OID_FIELD(old_pktable_oid);
796  WRITE_BOOL_FIELD(skip_validation);
797  WRITE_BOOL_FIELD(initially_valid);
798  break;
799 
801  appendStringInfoString(str, "ATTR_DEFERRABLE");
802  break;
803 
805  appendStringInfoString(str, "ATTR_NOT_DEFERRABLE");
806  break;
807 
809  appendStringInfoString(str, "ATTR_DEFERRED");
810  break;
811 
813  appendStringInfoString(str, "ATTR_IMMEDIATE");
814  break;
815 
816  default:
817  elog(ERROR, "unrecognized ConstrType: %d", (int) node->contype);
818  break;
819  }
820 }
#define WRITE_CHAR_FIELD(fldname)
Definition: outfuncs.c:65
#define WRITE_STRING_FIELD(fldname)
Definition: outfuncs.c:85
@ CONSTR_FOREIGN
Definition: parsenodes.h:2532
@ CONSTR_ATTR_DEFERRED
Definition: parsenodes.h:2535
@ CONSTR_IDENTITY
Definition: parsenodes.h:2526
@ CONSTR_UNIQUE
Definition: parsenodes.h:2530
@ CONSTR_ATTR_NOT_DEFERRABLE
Definition: parsenodes.h:2534
@ CONSTR_DEFAULT
Definition: parsenodes.h:2525
@ CONSTR_NOTNULL
Definition: parsenodes.h:2524
@ CONSTR_ATTR_IMMEDIATE
Definition: parsenodes.h:2536
@ CONSTR_CHECK
Definition: parsenodes.h:2528
@ CONSTR_NULL
Definition: parsenodes.h:2522
@ CONSTR_GENERATED
Definition: parsenodes.h:2527
@ CONSTR_EXCLUSION
Definition: parsenodes.h:2531
@ CONSTR_ATTR_DEFERRABLE
Definition: parsenodes.h:2533
@ CONSTR_PRIMARY
Definition: parsenodes.h:2529
ConstrType contype
Definition: parsenodes.h:2556

References appendStringInfoString(), CONSTR_ATTR_DEFERRABLE, CONSTR_ATTR_DEFERRED, CONSTR_ATTR_IMMEDIATE, CONSTR_ATTR_NOT_DEFERRABLE, CONSTR_CHECK, CONSTR_DEFAULT, CONSTR_EXCLUSION, CONSTR_FOREIGN, CONSTR_GENERATED, CONSTR_IDENTITY, CONSTR_NOTNULL, CONSTR_NULL, CONSTR_PRIMARY, CONSTR_UNIQUE, Constraint::contype, elog(), ERROR, generate_unaccent_rules::str, WRITE_BOOL_FIELD, WRITE_CHAR_FIELD, WRITE_LOCATION_FIELD, WRITE_NODE_FIELD, WRITE_NODE_TYPE, WRITE_OID_FIELD, and WRITE_STRING_FIELD.

◆ _outEquivalenceClass()

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

Definition at line 452 of file outfuncs.c.

453 {
454  /*
455  * To simplify reading, we just chase up to the topmost merged EC and
456  * print that, without bothering to show the merge-ees separately.
457  */
458  while (node->ec_merged)
459  node = node->ec_merged;
460 
461  WRITE_NODE_TYPE("EQUIVALENCECLASS");
462 
463  WRITE_NODE_FIELD(ec_opfamilies);
464  WRITE_OID_FIELD(ec_collation);
465  WRITE_NODE_FIELD(ec_members);
466  WRITE_NODE_FIELD(ec_sources);
467  WRITE_NODE_FIELD(ec_derives);
468  WRITE_BITMAPSET_FIELD(ec_relids);
469  WRITE_BOOL_FIELD(ec_has_const);
470  WRITE_BOOL_FIELD(ec_has_volatile);
471  WRITE_BOOL_FIELD(ec_broken);
472  WRITE_UINT_FIELD(ec_sortref);
473  WRITE_UINT_FIELD(ec_min_security);
474  WRITE_UINT_FIELD(ec_max_security);
475 }
#define WRITE_BITMAPSET_FIELD(fldname)
Definition: outfuncs.c:99
#define WRITE_UINT_FIELD(fldname)
Definition: outfuncs.c:48
struct EquivalenceClass * ec_merged
Definition: pathnodes.h:1381

References EquivalenceClass::ec_merged, WRITE_BITMAPSET_FIELD, WRITE_BOOL_FIELD, 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 478 of file outfuncs.c.

479 {
480  const ExtensibleNodeMethods *methods;
481 
482  methods = GetExtensibleNodeMethods(node->extnodename, false);
483 
484  WRITE_NODE_TYPE("EXTENSIBLENODE");
485 
486  WRITE_STRING_FIELD(extnodename);
487 
488  /* serialize the private fields */
489  methods->nodeOut(str, node);
490 }
const ExtensibleNodeMethods * GetExtensibleNodeMethods(const char *extnodename, bool missing_ok)
Definition: extensible.c:125
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, generate_unaccent_rules::str, WRITE_NODE_TYPE, and WRITE_STRING_FIELD.

◆ _outFloat()

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

Definition at line 650 of file outfuncs.c.

651 {
652  /*
653  * We assume the value is a valid numeric literal and so does not need
654  * quoting.
655  */
657 }
char * fval
Definition: value.h:52

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

Referenced by outNode().

◆ _outForeignKeyOptInfo()

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

Definition at line 426 of file outfuncs.c.

427 {
428  int i;
429 
430  WRITE_NODE_TYPE("FOREIGNKEYOPTINFO");
431 
432  WRITE_UINT_FIELD(con_relid);
433  WRITE_UINT_FIELD(ref_relid);
434  WRITE_INT_FIELD(nkeys);
435  WRITE_ATTRNUMBER_ARRAY(conkey, node->nkeys);
436  WRITE_ATTRNUMBER_ARRAY(confkey, node->nkeys);
437  WRITE_OID_ARRAY(conpfeqop, node->nkeys);
438  WRITE_INT_FIELD(nmatched_ec);
439  WRITE_INT_FIELD(nconst_ec);
440  WRITE_INT_FIELD(nmatched_rcols);
441  WRITE_INT_FIELD(nmatched_ri);
442  /* for compactness, just print the number of matches per column: */
443  appendStringInfoString(str, " :eclass");
444  for (i = 0; i < node->nkeys; i++)
445  appendStringInfo(str, " %d", (node->eclass[i] != NULL));
446  appendStringInfoString(str, " :rinfos");
447  for (i = 0; i < node->nkeys; i++)
448  appendStringInfo(str, " %d", list_length(node->rinfos[i]));
449 }
#define WRITE_ATTRNUMBER_ARRAY(fldname, len)
Definition: outfuncs.c:109
#define WRITE_OID_ARRAY(fldname, len)
Definition: outfuncs.c:114
static int list_length(const List *l)
Definition: pg_list.h:152
struct EquivalenceClass * eclass[INDEX_MAX_KEYS]
Definition: pathnodes.h:1235
List * rinfos[INDEX_MAX_KEYS]
Definition: pathnodes.h:1239

References appendStringInfo(), appendStringInfoString(), ForeignKeyOptInfo::eclass, i, list_length(), ForeignKeyOptInfo::nkeys, ForeignKeyOptInfo::rinfos, generate_unaccent_rules::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 644 of file outfuncs.c.

645 {
646  appendStringInfo(str, "%d", node->ival);
647 }
int ival
Definition: value.h:33

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

Referenced by outNode().

◆ _outList()

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

Definition at line 272 of file outfuncs.c.

273 {
274  const ListCell *lc;
275 
277 
278  if (IsA(node, IntList))
280  else if (IsA(node, OidList))
282  else if (IsA(node, XidList))
284 
285  foreach(lc, node)
286  {
287  /*
288  * For the sake of backward compatibility, we emit a slightly
289  * different whitespace format for lists of nodes vs. other types of
290  * lists. XXX: is this necessary?
291  */
292  if (IsA(node, List))
293  {
294  outNode(str, lfirst(lc));
295  if (lnext(node, lc))
297  }
298  else if (IsA(node, IntList))
299  appendStringInfo(str, " %d", lfirst_int(lc));
300  else if (IsA(node, OidList))
301  appendStringInfo(str, " %u", lfirst_oid(lc));
302  else if (IsA(node, XidList))
303  appendStringInfo(str, " %u", lfirst_xid(lc));
304  else
305  elog(ERROR, "unrecognized list node type: %d",
306  (int) node->type);
307  }
308 
310 }
#define IsA(nodeptr, _type_)
Definition: nodes.h:179
#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:188
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(), generate_unaccent_rules::str, and List::type.

Referenced by outNode().

◆ _outRangeTblEntry()

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

Definition at line 493 of file outfuncs.c.

494 {
495  WRITE_NODE_TYPE("RANGETBLENTRY");
496 
497  /* put alias + eref first to make dump more legible */
498  WRITE_NODE_FIELD(alias);
499  WRITE_NODE_FIELD(eref);
500  WRITE_ENUM_FIELD(rtekind, RTEKind);
501 
502  switch (node->rtekind)
503  {
504  case RTE_RELATION:
505  WRITE_OID_FIELD(relid);
506  WRITE_CHAR_FIELD(relkind);
507  WRITE_INT_FIELD(rellockmode);
508  WRITE_NODE_FIELD(tablesample);
509  WRITE_UINT_FIELD(perminfoindex);
510  break;
511  case RTE_SUBQUERY:
512  WRITE_NODE_FIELD(subquery);
513  WRITE_BOOL_FIELD(security_barrier);
514  /* we re-use these RELATION fields, too: */
515  WRITE_OID_FIELD(relid);
516  WRITE_INT_FIELD(rellockmode);
517  WRITE_UINT_FIELD(perminfoindex);
518  break;
519  case RTE_JOIN:
520  WRITE_ENUM_FIELD(jointype, JoinType);
521  WRITE_INT_FIELD(joinmergedcols);
522  WRITE_NODE_FIELD(joinaliasvars);
523  WRITE_NODE_FIELD(joinleftcols);
524  WRITE_NODE_FIELD(joinrightcols);
525  WRITE_NODE_FIELD(join_using_alias);
526  break;
527  case RTE_FUNCTION:
529  WRITE_BOOL_FIELD(funcordinality);
530  break;
531  case RTE_TABLEFUNC:
532  WRITE_NODE_FIELD(tablefunc);
533  break;
534  case RTE_VALUES:
535  WRITE_NODE_FIELD(values_lists);
536  WRITE_NODE_FIELD(coltypes);
537  WRITE_NODE_FIELD(coltypmods);
538  WRITE_NODE_FIELD(colcollations);
539  break;
540  case RTE_CTE:
541  WRITE_STRING_FIELD(ctename);
542  WRITE_UINT_FIELD(ctelevelsup);
543  WRITE_BOOL_FIELD(self_reference);
544  WRITE_NODE_FIELD(coltypes);
545  WRITE_NODE_FIELD(coltypmods);
546  WRITE_NODE_FIELD(colcollations);
547  break;
548  case RTE_NAMEDTUPLESTORE:
549  WRITE_STRING_FIELD(enrname);
550  WRITE_FLOAT_FIELD(enrtuples);
551  WRITE_NODE_FIELD(coltypes);
552  WRITE_NODE_FIELD(coltypmods);
553  WRITE_NODE_FIELD(colcollations);
554  /* we re-use these RELATION fields, too: */
555  WRITE_OID_FIELD(relid);
556  break;
557  case RTE_RESULT:
558  /* no extra fields */
559  break;
560  default:
561  elog(ERROR, "unrecognized RTE kind: %d", (int) node->rtekind);
562  break;
563  }
564 
565  WRITE_BOOL_FIELD(lateral);
566  WRITE_BOOL_FIELD(inh);
567  WRITE_BOOL_FIELD(inFromCl);
568  WRITE_NODE_FIELD(securityQuals);
569 }
JoinType
Definition: nodes.h:299
#define WRITE_ENUM_FIELD(fldname, enumtype)
Definition: outfuncs.c:70
#define WRITE_FLOAT_FIELD(fldname)
Definition: outfuncs.c:75
RTEKind
Definition: parsenodes.h:1013
@ RTE_JOIN
Definition: parsenodes.h:1016
@ RTE_CTE
Definition: parsenodes.h:1020
@ RTE_NAMEDTUPLESTORE
Definition: parsenodes.h:1021
@ RTE_VALUES
Definition: parsenodes.h:1019
@ RTE_SUBQUERY
Definition: parsenodes.h:1015
@ RTE_RESULT
Definition: parsenodes.h:1022
@ RTE_FUNCTION
Definition: parsenodes.h:1017
@ RTE_TABLEFUNC
Definition: parsenodes.h:1018
@ RTE_RELATION
Definition: parsenodes.h:1014
static const struct fns functions
Definition: regcomp.c:356
RTEKind rtekind
Definition: parsenodes.h:1033

References elog(), ERROR, functions, RTE_CTE, RTE_FUNCTION, 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 666 of file outfuncs.c.

667 {
668  /*
669  * We use outToken to provide escaping of the string's content, but we
670  * don't want it to convert an empty string to '""', because we're putting
671  * double quotes around the string already.
672  */
674  if (node->sval[0] != '\0')
675  outToken(str, node->sval);
677 }
char * sval
Definition: value.h:68

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

Referenced by outNode().

◆ bmsToString()

char* bmsToString ( const Bitmapset bms)

Definition at line 892 of file outfuncs.c.

893 {
895 
896  /* see stringinfo.h for an explanation of this maneuver */
898  outBitmapset(&str, bms);
899  return str.data;
900 }
void outBitmapset(StringInfo str, const Bitmapset *bms)
Definition: outfuncs.c:322
void initStringInfo(StringInfo str)
Definition: stringinfo.c:59

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

Referenced by search_indexed_tlist_for_phv(), and search_indexed_tlist_for_var().

◆ nodeToString()

◆ outBitmapset()

void outBitmapset ( StringInfo  str,
const Bitmapset bms 
)

Definition at line 322 of file outfuncs.c.

323 {
324  int x;
325 
328  x = -1;
329  while ((x = bms_next_member(bms, x)) >= 0)
330  appendStringInfo(str, " %d", x);
332 }
int bms_next_member(const Bitmapset *a, int prevbit)
Definition: bitmapset.c:1039
int x
Definition: isn.c:71

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

Referenced by bmsToString(), and outNode().

◆ outChar()

static void outChar ( StringInfo  str,
char  c 
)
static

Definition at line 187 of file outfuncs.c.

188 {
189  char in[2];
190 
191  /* Traditionally, we've represented \0 as <>, so keep doing that */
192  if (c == '\0')
193  {
195  return;
196  }
197 
198  in[0] = c;
199  in[1] = '\0';
200 
201  outToken(str, in);
202 }
char * c

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

◆ outDatum()

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

Definition at line 338 of file outfuncs.c.

339 {
340  Size length,
341  i;
342  char *s;
343 
344  length = datumGetSize(value, typbyval, typlen);
345 
346  if (typbyval)
347  {
348  s = (char *) (&value);
349  appendStringInfo(str, "%u [ ", (unsigned int) length);
350  for (i = 0; i < (Size) sizeof(Datum); i++)
351  appendStringInfo(str, "%d ", (int) (s[i]));
353  }
354  else
355  {
356  s = (char *) DatumGetPointer(value);
357  if (!PointerIsValid(s))
358  appendStringInfoString(str, "0 [ ]");
359  else
360  {
361  appendStringInfo(str, "%u [ ", (unsigned int) length);
362  for (i = 0; i < length; i++)
363  appendStringInfo(str, "%d ", (int) (s[i]));
365  }
366  }
367 }
#define PointerIsValid(pointer)
Definition: c.h:747
size_t Size
Definition: c.h:589
Size datumGetSize(Datum value, bool typByVal, int typLen)
Definition: datum.c:65
static struct @147 value
uintptr_t Datum
Definition: postgres.h:64
static Pointer DatumGetPointer(Datum X)
Definition: postgres.h:312

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

Referenced by _outConst().

◆ outDouble()

static void outDouble ( StringInfo  str,
double  d 
)
static

Definition at line 208 of file outfuncs.c.

209 {
211 
214 }
int double_to_shortest_decimal_buf(double f, char *result)
Definition: d2s.c:1053
static char * buf
Definition: pg_test_fsync.c:67
#define DOUBLE_SHORTEST_DECIMAL_LEN
Definition: shortest_dec.h:44

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

◆ outNode()

void outNode ( StringInfo  str,
const void *  obj 
)

Definition at line 828 of file outfuncs.c.

829 {
830  /* Guard against stack overflow due to overly complex expressions */
832 
833  if (obj == NULL)
835  else if (IsA(obj, List) || IsA(obj, IntList) || IsA(obj, OidList) ||
836  IsA(obj, XidList))
837  _outList(str, obj);
838  /* nodeRead does not want to see { } around these! */
839  else if (IsA(obj, Integer))
840  _outInteger(str, (Integer *) obj);
841  else if (IsA(obj, Float))
842  _outFloat(str, (Float *) obj);
843  else if (IsA(obj, Boolean))
844  _outBoolean(str, (Boolean *) obj);
845  else if (IsA(obj, String))
846  _outString(str, (String *) obj);
847  else if (IsA(obj, BitString))
848  _outBitString(str, (BitString *) obj);
849  else if (IsA(obj, Bitmapset))
850  outBitmapset(str, (Bitmapset *) obj);
851  else
852  {
854  switch (nodeTag(obj))
855  {
856 #include "outfuncs.switch.c"
857 
858  default:
859 
860  /*
861  * This should be an ERROR, but it's too useful to be able to
862  * dump structures that outNode only understands part of.
863  */
864  elog(WARNING, "could not dump unrecognized node type: %d",
865  (int) nodeTag(obj));
866  break;
867  }
869  }
870 }
#define WARNING
Definition: elog.h:36
#define nodeTag(nodeptr)
Definition: nodes.h:133
static void _outString(StringInfo str, const String *node)
Definition: outfuncs.c:666
static void _outInteger(StringInfo str, const Integer *node)
Definition: outfuncs.c:644
static void _outList(StringInfo str, const List *node)
Definition: outfuncs.c:272
static void _outFloat(StringInfo str, const Float *node)
Definition: outfuncs.c:650
static void _outBitString(StringInfo str, const BitString *node)
Definition: outfuncs.c:680
static void _outBoolean(StringInfo str, const Boolean *node)
Definition: outfuncs.c:660
void check_stack_depth(void)
Definition: postgres.c:3508
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(), generate_unaccent_rules::str, and WARNING.

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

◆ outToken()

void outToken ( StringInfo  str,
const char *  s 
)

Definition at line 146 of file outfuncs.c.

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

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

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

◆ writeNodeArray()

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

Definition at line 252 of file outfuncs.c.

253 {
254  if (arr != NULL)
255  {
257  for (int i = 0; i < len; i++)
258  {
260  outNode(str, arr[i]);
261  }
263  }
264  else
266 }

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