1/*-------------------------------------------------------------------------
4 * various print routines (used mostly for debugging)
6 * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
7 * Portions Copyright (c) 1994, Regents of the University of California
11 * src/backend/nodes/print.c
14 * AUTHOR DATE MAJOR EVENT
15 * Andrew Yu Oct 26, 1994 file creation
17 *-------------------------------------------------------------------------
33 * print contents of Node to stdout
51 * pretty-print contents of Node to stdout
69 * send pretty-printed contents of Node to postmaster log
90 * Format a nodeToString output for display on a terminal.
92 * The result is a palloc'd string.
94 * This version just tries to break at whitespace.
116 /* ok to break at adjacent space */
121 for (k =
j - 1; k > 0; k--)
126 /* back up; will reprint all after space */
144 * Format a nodeToString output for display on a terminal.
146 * The result is a palloc'd string.
148 * This version tries to indent intelligently.
164 indentLev = 0;
/* logical indent level */
165 indentDist = 0;
/* physical indent distance */
169 for (
j = 0;
j < indentDist;
j++)
179 /* print data before the } */
183 /* print the } at indentDist */
184 line[indentDist] =
'}';
185 line[indentDist + 1] =
'0円';
194 /* j will equal indentDist on next loop iteration */
195 /* suppress whitespace just after } */
196 while (dump[
i + 1] ==
' ')
200 /* force line break after ), unless another ) follows */
201 if (dump[
i + 1] !=
')')
206 while (dump[
i + 1] ==
' ')
211 /* force line break before { */
220 for (
j = 0;
j < indentDist;
j++)
225 /* force line break before : */
251 * print contents of range table
259 printf(
"resno\trefname \trelid\tinFromCl\n");
260 printf(
"-----\t---------\t-----\t--------\n");
269 i, rte->eref->aliasname, rte->relid, rte->relkind);
272 printf(
"%d\t%s\t[subquery]",
273 i, rte->eref->aliasname);
277 i, rte->eref->aliasname);
280 printf(
"%d\t%s\t[rangefunction]",
281 i, rte->eref->aliasname);
284 printf(
"%d\t%s\t[table function]",
285 i, rte->eref->aliasname);
288 printf(
"%d\t%s\t[values list]",
289 i, rte->eref->aliasname);
293 i, rte->eref->aliasname);
296 printf(
"%d\t%s\t[tuplestore]",
297 i, rte->eref->aliasname);
300 printf(
"%d\t%s\t[result]",
301 i, rte->eref->aliasname);
305 i, rte->eref->aliasname);
308 printf(
"%d\t%s\t[unknown rtekind]",
309 i, rte->eref->aliasname);
313 (rte->
inh ?
"inh" :
""),
314 (rte->inFromCl ?
"inFromCl" :
""));
322 * print an expression
335 const Var *var = (
const Var *) expr;
360 relname = rte->eref->aliasname;
381 &typoutput, &typIsVarlena);
396 printf(
" %s ", ((opname != NULL) ? opname :
"(invalid operator)"));
401 printf(
"%s ", ((opname != NULL) ? opname :
"(invalid operator)"));
427 * pathkeys list of PathKeys
442 eclass = pathkey->pk_eclass;
443 /* chase up, in case pathkey is non-canonical */
448 foreach(k,
eclass->ec_members)
467 * print targetlist in a more legible way.
480 tle->resname ? tle->resname :
"<null>");
493 * print out the tuple with the given TupleTableSlot
500 printf(
"tuple is null.\n");
505 printf(
"no tuple descriptor.\n");
void pprint(const void *obj)
char * pretty_format_node_dump(const char *dump)
void print_pathkeys(const List *pathkeys, const List *rtable)
void print_rt(const List *rtable)
void print_slot(TupleTableSlot *slot)
void print(const void *obj)
void elog_node_display(int lev, const char *title, const void *obj, bool pretty)
void print_tl(const List *tlist, const List *rtable)
void print_expr(const Node *expr, const List *rtable)
char * format_node_dump(const char *dump)
int errmsg_internal(const char *fmt,...)
int errdetail_internal(const char *fmt,...)
#define ereport(elevel,...)
char * OidOutputFunctionCall(Oid functionId, Datum val)
Assert(PointerIsAligned(start, uint64))
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
char * get_opname(Oid opno)
char * get_func_name(Oid funcid)
void pfree(void *pointer)
static Node * get_rightop(const void *clause)
static Node * get_leftop(const void *clause)
#define IsA(nodeptr, _type_)
char * nodeToStringWithLocations(const void *obj)
char * get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
#define rt_fetch(rangetable_index, rangetable)
static int list_length(const List *l)
static ListCell * lnext(const List *l, const ListCell *c)
bool debugtup(TupleTableSlot *slot, DestReceiver *self)
static struct cvec * eclass(struct vars *v, chr c, int cases)
void appendStringInfo(StringInfo str, const char *fmt,...)
void initStringInfo(StringInfo str)
TupleDesc tts_tupleDescriptor