63 #include "utils/fmgroids.h"
82 #define PRETTYINDENT_STD 8
83 #define PRETTYINDENT_JOIN 4
84 #define PRETTYINDENT_VAR 4
86 #define PRETTYINDENT_LIMIT 40
89 #define PRETTYFLAG_PAREN 0x0001
90 #define PRETTYFLAG_INDENT 0x0002
91 #define PRETTYFLAG_SCHEMA 0x0004
94 #define GET_PRETTY_FLAGS(pretty) \
95 ((pretty) ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) \
99 #define WRAP_COLUMN_DEFAULT 0
102 #define PRETTY_PAREN(context) ((context)->prettyFlags & PRETTYFLAG_PAREN)
103 #define PRETTY_INDENT(context) ((context)->prettyFlags & PRETTYFLAG_INDENT)
104 #define PRETTY_SCHEMA(context) ((context)->prettyFlags & PRETTYFLAG_SCHEMA)
296 #define deparse_columns_fetch(rangetable_index, dpns) \
297 ((deparse_columns *) list_nth((dpns)->rtable_columns, (rangetable_index)-1))
320 static const char *
const query_getviewrule =
"SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2";
335 bool forceprefix,
bool showimplicit,
336 int prettyFlags,
int startIndent);
338 int prettyFlags,
int wrapColumn);
344 const Oid *excludeOps,
345 bool attrsOnly,
bool keysOnly,
346 bool showTblSpc,
bool inherits,
347 int prettyFlags,
bool missing_ok);
351 bool attrsOnly,
bool missing_ok);
353 int prettyFlags,
bool missing_ok);
356 bool print_table_args,
bool print_defaults);
363 List *parent_namespaces);
395 int prettyFlags,
int wrapColumn);
397 TupleDesc resultDesc,
bool colNamesVisible,
398 int prettyFlags,
int wrapColumn,
int startIndent);
402 TupleDesc resultDesc,
bool colNamesVisible);
404 bool colNamesVisible);
406 bool colNamesVisible);
411 bool colNamesVisible);
413 bool colNamesVisible);
416 TupleDesc resultDesc,
bool colNamesVisible);
418 TupleDesc resultDesc,
bool colNamesVisible);
421 TupleDesc resultDesc,
bool colNamesVisible);
448 int indentBefore,
int indentAfter,
int indentPlus);
466 const char *
options,
bool is_json_objectagg);
472 bool is_json_objectagg);
482 bool json_format_by_default);
490 bool is_json_objectagg);
517 bool has_variadic,
bool *use_variadic_p,
535 #define only_marker(rte) ((rte)->inh ? "" : "ONLY ")
612 argtypes[0] = OIDOID;
627 elog(
ERROR,
"failed to get pg_rewrite tuple for rule %u", ruleoid);
805 argtypes[0] = OIDOID;
806 argtypes[1] = NAMEOID;
823 elog(
ERROR,
"failed to get pg_rewrite tuple for view %u", viewoid);
932 tgname =
NameStr(trigrec->tgname);
934 OidIsValid(trigrec->tgconstraint) ?
"CONSTRAINT " :
"",
937 if (TRIGGER_FOR_BEFORE(trigrec->tgtype))
939 else if (TRIGGER_FOR_AFTER(trigrec->tgtype))
941 else if (TRIGGER_FOR_INSTEAD(trigrec->tgtype))
944 elog(
ERROR,
"unexpected tgtype value: %d", trigrec->tgtype);
946 if (TRIGGER_FOR_INSERT(trigrec->tgtype))
951 if (TRIGGER_FOR_DELETE(trigrec->tgtype))
959 if (TRIGGER_FOR_UPDATE(trigrec->tgtype))
967 if (trigrec->tgattr.dim1 > 0)
972 for (
i = 0;
i < trigrec->tgattr.dim1;
i++)
979 trigrec->tgattr.values[
i],
false);
984 if (TRIGGER_FOR_TRUNCATE(trigrec->tgtype))
1007 if (!trigrec->tgdeferrable)
1010 if (trigrec->tginitdeferred)
1028 if (tgoldtable != NULL || tgnewtable != NULL)
1031 if (tgoldtable != NULL)
1034 if (tgnewtable != NULL)
1039 if (TRIGGER_FOR_ROW(trigrec->tgtype))
1065 oldrte->
relid = trigrec->tgrelid;
1066 oldrte->relkind = relkind;
1069 oldrte->eref = oldrte->alias;
1070 oldrte->lateral =
false;
1071 oldrte->
inh =
false;
1072 oldrte->inFromCl =
true;
1076 newrte->
relid = trigrec->tgrelid;
1077 newrte->relkind = relkind;
1080 newrte->eref = newrte->alias;
1081 newrte->lateral =
false;
1082 newrte->
inh =
false;
1083 newrte->inFromCl =
true;
1086 memset(&dpns, 0,
sizeof(dpns));
1116 if (trigrec->tgnargs > 0)
1124 elog(
ERROR,
"tgargs is null for trigger %u", trigid);
1126 for (
i = 0;
i < trigrec->tgnargs;
i++)
1228 prettyFlags,
false);
1244 prettyFlags,
false);
1255 const Oid *excludeOps,
1256 bool attrsOnly,
bool keysOnly,
1257 bool showTblSpc,
bool inherits,
1258 int prettyFlags,
bool missing_ok)
1261 bool isConstraint = (excludeOps != NULL);
1275 Datum indclassDatum;
1276 Datum indoptionDatum;
1292 elog(
ERROR,
"cache lookup failed for index %u", indexrelid);
1296 indrelid = idxrec->indrelid;
1297 Assert(indexrelid == idxrec->indexrelid);
1301 Anum_pg_index_indcollation);
1305 Anum_pg_index_indclass);
1309 Anum_pg_index_indoption);
1317 elog(
ERROR,
"cache lookup failed for relation %u", indexrelid);
1325 elog(
ERROR,
"cache lookup failed for access method %u",
1343 Anum_pg_index_indexprs);
1365 idxrec->indisunique ?
"UNIQUE " :
"",
1367 idxrelrec->relkind == RELKIND_PARTITIONED_INDEX
1368 && !inherits ?
"ONLY " :
"",
1382 for (keyno = 0; keyno < idxrec->indnatts; keyno++)
1386 Oid keycolcollation;
1391 if (keysOnly && keyno >= idxrec->indnkeyatts)
1395 if (!colno && keyno == idxrec->indnkeyatts)
1412 if (!colno || colno == keyno + 1)
1415 &keycoltype, &keycoltypmod,
1423 if (indexpr_item == NULL)
1424 elog(
ERROR,
"too few entries in indexprs list");
1426 indexpr_item =
lnext(indexprs, indexpr_item);
1430 if (!colno || colno == keyno + 1)
1443 if (!attrsOnly && keyno < idxrec->indnkeyatts &&
1444 (!colno || colno == keyno + 1))
1447 Oid indcoll = indcollation->
values[keyno];
1449 bool has_options = attoptions != (
Datum) 0;
1452 if (
OidIsValid(indcoll) && indcoll != keycolcollation)
1471 if (opt & INDOPTION_DESC)
1475 if (!(opt & INDOPTION_NULLS_FIRST))
1480 if (opt & INDOPTION_NULLS_FIRST)
1486 if (excludeOps != NULL)
1498 if (idxrec->indnullsnotdistinct)
1539 Anum_pg_index_indpred);
1648 bool ndistinct_enabled;
1649 bool dependencies_enabled;
1664 elog(
ERROR,
"cache lookup failed for statistics object %u", statextid);
1668 has_exprs = !
heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
1683 Anum_pg_statistic_ext_stxexprs);
1692 ncolumns = statextrec->stxkeys.dim1 +
list_length(exprs);
1701 NameStr(statextrec->stxname)));
1708 Anum_pg_statistic_ext_stxkind);
1713 elog(
ERROR,
"stxkind is not a 1-D char array");
1716 ndistinct_enabled =
false;
1717 dependencies_enabled =
false;
1718 mcv_enabled =
false;
1722 if (enabled[
i] == STATS_EXT_NDISTINCT)
1723 ndistinct_enabled =
true;
1724 else if (enabled[
i] == STATS_EXT_DEPENDENCIES)
1725 dependencies_enabled =
true;
1726 else if (enabled[
i] == STATS_EXT_MCV)
1743 if ((!ndistinct_enabled || !dependencies_enabled || !mcv_enabled) &&
1746 bool gotone =
false;
1750 if (ndistinct_enabled)
1756 if (dependencies_enabled)
1772 for (colno = 0; colno < statextrec->stxkeys.dim1; colno++)
1786 statextrec->stxrelid);
1841 has_exprs = !
heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
1856 Anum_pg_statistic_ext_stxexprs);
1862 statextrec->stxrelid);
1922 bool attrsOnly,
bool missing_ok)
1942 elog(
ERROR,
"cache lookup failed for partition key of %u", relid);
1947 Assert(form->partrelid == relid);
1951 Anum_pg_partitioned_table_partclass);
1955 Anum_pg_partitioned_table_partcollation);
1964 if (!
heap_attisnull(tuple, Anum_pg_partitioned_table_partexprs, NULL))
1970 Anum_pg_partitioned_table_partexprs);
1975 elog(
ERROR,
"unexpected node type found in partexprs: %d",
1988 switch (form->partstrat)
2003 elog(
ERROR,
"unexpected partition strategy: %d",
2004 (
int) form->partstrat);
2010 for (keyno = 0; keyno < form->partnatts; keyno++)
2014 Oid keycolcollation;
2028 &keycoltype, &keycoltypmod,
2036 if (partexpr_item == NULL)
2037 elog(
ERROR,
"too few entries in partexprs list");
2039 partexpr_item =
lnext(partexprs, partexpr_item);
2055 partcoll = partcollation->
values[keyno];
2056 if (!attrsOnly &&
OidIsValid(partcoll) && partcoll != keycolcollation)
2091 if (constr_expr == NULL)
2100 false, prettyFlags, 0);
2178 int prettyFlags,
bool missing_ok)
2189 Anum_pg_constraint_oid,
2194 ConstraintOidIndexId,
2216 elog(
ERROR,
"could not find tuple for constraint %u", constraintId);
2248 switch (conForm->contype)
2250 case CONSTRAINT_FOREIGN:
2261 Anum_pg_constraint_conkey);
2273 Anum_pg_constraint_confkey);
2280 switch (conForm->confmatchtype)
2283 string =
" MATCH FULL";
2286 string =
" MATCH PARTIAL";
2292 elog(
ERROR,
"unrecognized confmatchtype: %d",
2293 conForm->confmatchtype);
2300 switch (conForm->confupdtype)
2306 string =
"RESTRICT";
2312 string =
"SET NULL";
2315 string =
"SET DEFAULT";
2318 elog(
ERROR,
"unrecognized confupdtype: %d",
2319 conForm->confupdtype);
2326 switch (conForm->confdeltype)
2332 string =
"RESTRICT";
2338 string =
"SET NULL";
2341 string =
"SET DEFAULT";
2344 elog(
ERROR,
"unrecognized confdeltype: %d",
2345 conForm->confdeltype);
2357 Anum_pg_constraint_confdelsetcols, &isnull);
2367 case CONSTRAINT_PRIMARY:
2368 case CONSTRAINT_UNIQUE:
2376 if (conForm->contype == CONSTRAINT_PRIMARY)
2381 indexId = conForm->conindid;
2385 elog(
ERROR,
"cache lookup failed for index %u", indexId);
2386 if (conForm->contype == CONSTRAINT_UNIQUE &&
2394 Anum_pg_constraint_conkey);
2397 if (conForm->conperiod)
2404 Anum_pg_index_indnatts);
2415 Anum_pg_index_indkey);
2418 &keys, NULL, &nKeys);
2420 for (
j = keyatts;
j < nKeys;
j++)
2461 case CONSTRAINT_CHECK:
2471 Anum_pg_constraint_conbin);
2506 conForm->connoinherit ?
" NO INHERIT" :
"");
2509 case CONSTRAINT_NOTNULL:
2511 if (conForm->conrelid)
2523 else if (conForm->contypid)
2531 case CONSTRAINT_TRIGGER:
2541 case CONSTRAINT_EXCLUSION:
2543 Oid indexOid = conForm->conindid;
2552 Anum_pg_constraint_conexclop);
2555 &elems, NULL, &nElems);
2558 for (
i = 0;
i < nElems;
i++)
2576 elog(
ERROR,
"invalid constraint type \"%c\"", conForm->contype);
2580 if (conForm->condeferrable)
2582 if (conForm->condeferred)
2584 if (!conForm->convalidated)
2610 &keys, NULL, &nKeys);
2612 for (
j = 0;
j < nKeys;
j++)
2622 (withPeriod &&
j == nKeys - 1) ?
"PERIOD " :
"",
2719 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2720 errmsg(
"input is a query, not an expression")));
2731 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2732 errmsg(
"expression contains variables of more than one relation")));
2738 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2739 errmsg(
"expression contains variables")));
2795 *result = role_rec->rolname;
2837 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2838 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
2845 Anum_pg_depend_refclassid,
2849 Anum_pg_depend_refobjid,
2853 Anum_pg_depend_refobjsubid,
2869 if (deprec->classid == RelationRelationId &&
2870 deprec->objsubid == 0 &&
2875 sequenceId = deprec->objid;
2933 if (proc->prokind == PROKIND_AGGREGATE)
2935 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2936 errmsg(
"\"%s\" is an aggregate function",
name)));
2938 isfunction = (proc->prokind != PROKIND_PROCEDURE);
2946 isfunction ?
"FUNCTION" :
"PROCEDURE",
2965 if (proc->prokind == PROKIND_WINDOW)
2967 switch (proc->provolatile)
2969 case PROVOLATILE_IMMUTABLE:
2972 case PROVOLATILE_STABLE:
2975 case PROVOLATILE_VOLATILE:
2979 switch (proc->proparallel)
2981 case PROPARALLEL_SAFE:
2984 case PROPARALLEL_RESTRICTED:
2987 case PROPARALLEL_UNSAFE:
2991 if (proc->proisstrict)
2993 if (proc->prosecdef)
2995 if (proc->proleakproof)
2999 if (proc->prolang == INTERNALlanguageId ||
3000 proc->prolang == ClanguageId)
3004 if (proc->procost != procost)
3007 if (proc->prorows > 0 && proc->prorows != 1000)
3010 if (proc->prosupport)
3018 argtypes[0] = INTERNALOID;
3025 if (oldlen !=
buf.len)
3029 tmp =
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_proconfig, &isnull);
3054 pos = strchr(configitem,
'=');
3087 elog(
ERROR,
"invalid list syntax in proconfig item");
3089 foreach(lc, namelist)
3091 char *curname = (
char *)
lfirst(lc);
3094 if (
lnext(namelist, lc))
3106 (void)
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
3107 if (proc->prolang == SQLlanguageId && !isnull)
3115 tmp =
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_probin, &isnull);
3136 while (strstr(prosrc, dq.
data) != NULL)
3248 if (proc->proretset)
3262 if (proc->proretset)
3279 bool print_table_args,
bool print_defaults)
3286 int insertorderbyat = -1;
3295 &argtypes, &argnames, &argmodes);
3297 nlackdefaults = numargs;
3298 if (print_defaults && proc->pronargdefaults > 0)
3300 Datum proargdefaults;
3304 Anum_pg_proc_proargdefaults,
3313 nextargdefault =
list_head(argdefaults);
3315 nlackdefaults = proc->pronargs -
list_length(argdefaults);
3320 if (proc->prokind == PROKIND_AGGREGATE)
3327 elog(
ERROR,
"cache lookup failed for aggregate %u",
3330 if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
3331 insertorderbyat = agg->aggnumdirectargs;
3337 for (
i = 0;
i < numargs;
i++)
3339 Oid argtype = argtypes[
i];
3340 char *argname = argnames ? argnames[
i] : NULL;
3341 char argmode = argmodes ? argmodes[
i] : PROARGMODE_IN;
3342 const char *modename;
3353 if (proc->prokind == PROKIND_PROCEDURE)
3359 case PROARGMODE_INOUT:
3360 modename =
"INOUT ";
3363 case PROARGMODE_OUT:
3367 case PROARGMODE_VARIADIC:
3368 modename =
"VARIADIC ";
3371 case PROARGMODE_TABLE:
3376 elog(
ERROR,
"invalid parameter mode '%c'", argmode);
3384 if (print_table_args != (argmode == PROARGMODE_TABLE))
3387 if (argsprinted == insertorderbyat)
3393 else if (argsprinted)
3397 if (argname && argname[0])
3400 if (print_defaults && isinput && inputargno > nlackdefaults)
3404 Assert(nextargdefault != NULL);
3406 nextargdefault =
lnext(argdefaults, nextargdefault);
3414 if (argsprinted == insertorderbyat &&
i == numargs - 1)
3418 print_defaults =
false;
3429 || argmodes[nth] == PROARGMODE_IN
3430 || argmodes[nth] == PROARGMODE_INOUT
3431 || argmodes[nth] == PROARGMODE_VARIADIC);
3449 for (
i = 0;
i < ntypes;
i++)
3481 Datum proargdefaults;
3490 if (nth_arg < 1 || nth_arg > numargs || !
is_input_argument(nth_arg - 1, argmodes))
3497 for (
i = 0;
i < nth_arg;
i++)
3502 Anum_pg_proc_proargdefaults,
3520 nth_default = nth_inputarg - 1 - (proc->pronargs - proc->pronargdefaults);
3522 if (nth_default < 0 || nth_default >=
list_length(argdefaults))
3527 node =
list_nth(argdefaults, nth_default);
3548 &argtypes, &argnames, &argmodes);
3604 (void)
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
3626 bool forceprefix,
bool showimplicit)
3629 showimplicit, 0, 0);
3653 bool forceprefix,
bool showimplicit,
3654 int prettyFlags,
int startIndent)
3661 context.namespaces = dpcontext;
3664 context.varprefix = forceprefix;
3665 context.prettyFlags = prettyFlags;
3667 context.indentLevel = startIndent;
3696 rte->relkind = RELKIND_RELATION;
3699 rte->eref = rte->alias;
3700 rte->lateral =
false;
3702 rte->inFromCl =
true;
3754 Assert(crelid > 0 && crelid <= ntables);
3826 memset(&dpns, 0,
sizeof(dpns));
3873 names_hash =
hash_create(
"set_rtable_names names",
3879 foreach(lc, parent_namespaces)
3886 char *oldname = (
char *)
lfirst(lc2);
3888 if (oldname == NULL)
3901 foreach(lc, dpns->
rtable)
3914 else if (rte->alias)
3917 refname = rte->alias->aliasname;
3932 refname = rte->eref->aliasname;
3950 int refnamelen = strlen(refname);
3951 char *modname = (
char *)
palloc(refnamelen + 16);
3959 memcpy(modname, refname, refnamelen);
3997 List *parent_namespaces)
4124 if (
j->alias == NULL &&
j->usingClause)
4134 for (
int i = 0;
i < jrte->joinmergedcols;
i++)
4150 elog(
ERROR,
"unrecognized node type: %d",
4208 if (rte->alias == NULL)
4214 if (colname == NULL)
4218 if (leftattnos[
i] > 0)
4221 leftcolinfo->
colnames[leftattnos[
i] - 1] = colname;
4225 if (rightattnos[
i] > 0)
4228 rightcolinfo->
colnames[rightattnos[
i] - 1] = colname;
4266 foreach(lc,
j->usingClause)
4271 Assert(leftattnos[
i] != 0 && rightattnos[
i] != 0);
4279 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4292 parentUsing =
lappend(parentUsing, colname);
4295 if (leftattnos[
i] > 0)
4298 leftcolinfo->
colnames[leftattnos[
i] - 1] = colname;
4302 if (rightattnos[
i] > 0)
4305 rightcolinfo->
colnames[rightattnos[
i] - 1] = colname;
4321 elog(
ERROR,
"unrecognized node type: %d",
4337 char **real_colnames;
4357 ncolumns = tupdesc->
natts;
4358 real_colnames = (
char **)
palloc(ncolumns *
sizeof(
char *));
4360 for (
i = 0;
i < ncolumns;
i++)
4364 if (attr->attisdropped)
4365 real_colnames[
i] = NULL;
4399 colnames = rte->eref->colnames;
4402 real_colnames = (
char **)
palloc(ncolumns *
sizeof(
char *));
4405 foreach(lc, colnames)
4413 if (
cname[0] ==
'\0')
4415 real_colnames[
i] =
cname;
4449 changed_any =
false;
4451 for (
i = 0;
i < ncolumns;
i++)
4453 char *real_colname = real_colnames[
i];
4457 if (real_colname == NULL)
4464 if (colname == NULL)
4467 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4470 colname = real_colname;
4485 if (!changed_any && strcmp(colname, real_colname) != 0)
4513 else if (rte->alias && rte->alias->colnames !=
NIL)
4565 changed_any =
false;
4586 if (real_colname == NULL)
4593 if (rte->alias == NULL)
4600 if (colname == NULL)
4603 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4606 colname = real_colname;
4615 if (!changed_any && strcmp(colname, real_colname) != 0)
4650 while (
i < noldcolumns &&
4676 while (ic < leftcolinfo->num_cols &&
4679 Assert(ic < leftcolinfo->num_cols);
4685 while (i < colinfo->num_cols &&
4688 Assert(i < colinfo->num_cols);
4700 if (rte->alias != NULL)
4725 while (ic < rightcolinfo->num_cols &&
4726 rightcolinfo->
colnames[ic] == NULL)
4728 Assert(ic < rightcolinfo->num_cols);
4734 while (i < colinfo->num_cols &&
4737 Assert(i < colinfo->num_cols);
4749 if (rte->alias != NULL)
4766 #ifdef USE_ASSERT_CHECKING
4767 while (i < colinfo->num_cols && colinfo->
colnames[
i] == NULL)
4777 if (rte->alias != NULL)
4800 if (oldname && strcmp(oldname, colname) == 0)
4812 if (oldname && strcmp(oldname, colname) == 0)
4819 char *oldname = (
char *)
lfirst(lc);
4821 if (strcmp(oldname, colname) == 0)
4828 char *oldname = (
char *)
lfirst(lc);
4830 if (strcmp(oldname, colname) == 0)
4853 int colnamelen = strlen(colname);
4854 char *modname = (
char *)
palloc(colnamelen + 16);
4862 memcpy(modname, colname, colnamelen);
4863 sprintf(modname + colnamelen,
"_%d",
i);
4915 elog(
ERROR,
"unrecognized node type in jointree: %d",
4922 elog(
ERROR,
"unrecognized node type in jointree: %d",
4943 foreach(lc, jrte->joinleftcols)
4950 foreach(lc, jrte->joinrightcols)
4954 if (rcolno < jrte->joinmergedcols)
4960 Assert(jcolno == numjoincols);
5081 elog(
ERROR,
"could not find RecursiveUnion for WorkTableScan with wtParam %d",
5228 Assert(ev_action != NULL);
5231 elog(
ERROR,
"invalid empty ev_action list");
5268 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5269 errmsg(
"rule \"%s\" has unsupported event type %d",
5270 rulename, ev_type)));
5281 if (strcmp(ev_qual,
"<>") != 0)
5316 context.prettyFlags = prettyFlags;
5373 int prettyFlags,
int wrapColumn)
5411 Assert(ev_action != NULL);
5422 if (ev_type !=
'1' || !is_instead ||
5432 prettyFlags, wrapColumn, 0);
5458 TupleDesc resultDesc,
bool colNamesVisible,
5459 int prettyFlags,
int wrapColumn,
int startIndent)
5483 context.varprefix = (parentnamespace !=
NIL ||
5485 context.prettyFlags = prettyFlags;
5486 context.wrapColumn = wrapColumn;
5487 context.indentLevel = startIndent;
5524 elog(
ERROR,
"unrecognized query command type: %d",
5538 bool first_list =
true;
5543 foreach(vtl, values_lists)
5546 bool first_col =
true;
5555 foreach(lc, sublist)
5593 if (query->hasRecursive)
5594 sep =
"WITH RECURSIVE ";
5603 if (cte->aliascolnames)
5609 foreach(col, cte->aliascolnames)
5643 if (cte->search_clause)
5649 cte->search_clause->search_breadth_first ?
"BREADTH" :
"DEPTH");
5651 foreach(lc, cte->search_clause->search_col_list)
5664 if (cte->cycle_clause)
5671 foreach(lc, cte->cycle_clause->cycle_col_list)
5718 TupleDesc resultDesc,
bool colNamesVisible)
5721 List *save_windowclause;
5722 List *save_windowtlist;
5730 save_windowclause =
context->windowClause;
5732 save_windowtlist =
context->windowTList;
5750 force_colno =
false;
5794 if (query->hasForUpdate)
5808 elog(
ERROR,
"unrecognized LockClauseStrength %d",
5839 context->windowClause = save_windowclause;
5840 context->windowTList = save_windowtlist;
5859 foreach(lc, query->
rtable)
5903 if (resultDesc && colno <= resultDesc->natts)
5906 colname = tle->resname;
5909 if (colname == NULL || strcmp(colname,
cname) != 0)
5919 TupleDesc resultDesc,
bool colNamesVisible)
5947 if (query->isReturn)
5955 if (query->hasDistinctOn)
5998 save_exprkind =
context->special_exprkind;
6027 context->special_exprkind = save_exprkind;
6053 TupleDesc resultDesc,
bool colNamesVisible)
6057 bool last_was_multiline =
false;
6067 foreach(l, targetList)
6110 attname = colNamesVisible ? NULL :
"?column?";
6119 if (resultDesc && colno <= resultDesc->natts)
6122 colname = tle->resname;
6140 if (targetbuf.
len > 0 && targetbuf.
data[0] ==
'\n')
6143 leading_nl_pos = -1;
6146 if (leading_nl_pos >= 0)
6156 trailing_nl = strrchr(
buf->data,
'\n');
6157 if (trailing_nl == NULL)
6158 trailing_nl =
buf->data;
6168 ((strlen(trailing_nl) + targetbuf.
len >
context->wrapColumn) ||
6169 last_was_multiline))
6175 last_was_multiline =
6176 (strchr(targetbuf.
data + leading_nl_pos + 1,
'\n') != NULL);
6189 TupleDesc resultDesc,
bool colNamesVisible)
6204 Assert(subquery != NULL);
6207 need_paren = (subquery->
cteList ||
6305 context->indentLevel -= subindent;
6311 elog(
ERROR,
"unrecognized node type: %d",
6348 else if (!expr ||
IsA(expr,
Var))
6384 bool omit_child_parens =
true;
6421 omit_child_parens =
false;
6447 foreach(l, orderList)
6508 if (wc->name == NULL)
6533 bool needspace =
false;
6639 bool colNamesVisible)
6647 List *strippedexprs;
6656 foreach(l, query->
rtable)
6663 elog(
ERROR,
"too many subquery RTEs in INSERT");
6670 elog(
ERROR,
"too many values RTEs in INSERT");
6674 if (select_rte && values_rte)
6675 elog(
ERROR,
"both subquery and values RTEs in INSERT");
6701 strippedexprs =
NIL;
6732 strippedexprs =
lappend(strippedexprs,
6739 if (query->override)
6755 else if (values_rte)
6760 else if (strippedexprs)
6791 bool save_varprefix;
6798 save_varprefix =
context->varprefix;
6805 context->varprefix = save_varprefix;
6813 elog(
ERROR,
"cache lookup failed for constraint %u",
6856 bool colNamesVisible)
6918 int remaining_ma_columns;
6929 if (query->hasSubLinks)
6931 foreach(l, targetList)
6941 ma_sublinks =
lappend(ma_sublinks, sl);
6948 cur_ma_sublink = NULL;
6949 remaining_ma_columns = 0;
6953 foreach(l, targetList)
6969 if (next_ma_cell != NULL && cur_ma_sublink == NULL)
7015 next_ma_cell =
lnext(ma_sublinks, next_ma_cell);
7018 ((cur_ma_sublink->
subLinkId << 16) | 1));
7043 if (cur_ma_sublink != NULL)
7045 if (--remaining_ma_columns > 0)
7048 expr = (
Node *) cur_ma_sublink;
7049 cur_ma_sublink = NULL;
7065 bool colNamesVisible)
7117 bool colNamesVisible)
7122 bool haveNotMatchedBySource;
7157 haveNotMatchedBySource =
false;
7164 haveNotMatchedBySource =
true;
7176 switch (
action->matchKind)
7185 if (haveNotMatchedBySource)
7191 elog(
ERROR,
"unrecognized matchKind: %d",
7192 (
int)
action->matchKind);
7208 const char *sep =
"";
7215 foreach(lc2,
action->targetList)
7228 strippedexprs =
lappend(strippedexprs,
7301 elog(
ERROR,
"unexpected utility statement type");
7341 elog(
ERROR,
"bogus varlevelsup: %d offset %d",
7354 if (var->varnosyn > 0 && dpns->
plan == NULL)
7356 varno = var->varnosyn;
7357 varattno = var->varattnosyn;
7393 pvarattno = appinfo->parent_colnos[pvarattno - 1];
7413 varattno = pvarattno;
7449 elog(
ERROR,
"invalid attnum %d for relation \"%s\"",
7450 attnum, rte->eref->aliasname);
7452 Assert(netlevelsup == 0);
7483 if (rte->joinaliasvars ==
NIL)
7484 elog(
ERROR,
"cannot decompile join alias var in plan tree");
7491 if (aliasvar &&
IsA(aliasvar,
Var))
7512 elog(
ERROR,
"invalid attnum %d for relation \"%s\"",
7513 attnum, rte->eref->aliasname);
7592 (*callback) (node,
context, callback_arg);
7620 save_appendparents =
context->appendparents;
7633 context->appendparents = save_appendparents;
7667 (*callback) (node,
context, callback_arg);
7709 if (fieldno > 0 && fieldno <=
list_length(r->colnames))
7741 var->vartype != RECORDOID)
7745 Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
7752 elog(
ERROR,
"bogus varlevelsup: %d offset %d",
7762 if (var->varnosyn > 0 && dpns->
plan == NULL)
7764 varno = var->varnosyn;
7765 varattno = var->varattnosyn;
7795 elog(
ERROR,
"bogus varattno for OUTER_VAR var: %d", varattno);
7797 Assert(netlevelsup == 0);
7814 elog(
ERROR,
"bogus varattno for INNER_VAR var: %d", varattno);
7816 Assert(netlevelsup == 0);
7832 elog(
ERROR,
"bogus varattno for INDEX_VAR var: %d", varattno);
7834 Assert(netlevelsup == 0);
7860 expr = (
Node *) var;
7883 if (ste == NULL || ste->resjunk)
7884 elog(
ERROR,
"subquery %s does not have attribute %d",
7885 rte->eref->aliasname,
attnum);
7899 List *parent_namespaces;
7909 context->namespaces =
lcons(&mydpns, parent_namespaces);
7914 context->namespaces = save_nslist;
7934 elog(
ERROR,
"failed to find plan for subquery %s",
7935 rte->eref->aliasname);
7938 elog(
ERROR,
"bogus varattno for subquery var: %d",
7940 Assert(netlevelsup == 0);
7953 if (rte->joinaliasvars ==
NIL)
7954 elog(
ERROR,
"cannot decompile join alias var in plan tree");
7992 foreach(lc, ctedpns->
ctes)
8005 if (ste == NULL || ste->resjunk)
8006 elog(
ERROR,
"CTE %s does not have attribute %d",
8007 rte->eref->aliasname,
attnum);
8008 expr = (
Node *) ste->expr;
8019 List *parent_namespaces;
8029 context->namespaces =
lcons(&mydpns, parent_namespaces);
8034 context->namespaces = save_nslist;
8056 elog(
ERROR,
"failed to find plan for CTE %s",
8057 rte->eref->aliasname);
8060 elog(
ERROR,
"bogus varattno for subquery var: %d",
8062 Assert(netlevelsup == 0);
8081 Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
8099 *ancestor_cell_p = NULL;
8113 child_plan = dpns->
plan;
8136 *ancestor_cell_p = lc;
8156 if (paramid == param->
paramid)
8174 *ancestor_cell_p = rest;
8178 elog(
ERROR,
"SubPlan cannot be outermost ancestor");
8192 child_plan = (
Plan *) ancestor;
8248 if (paramid == param->
paramid)
8273 if (paramid == param->
paramid)
8311 if (paramid == param->
paramid)
8344 bool save_varprefix;
8354 save_varprefix =
context->varprefix;
8362 need_paren = !(
IsA(expr,
Var) ||
8374 context->varprefix = save_varprefix;
8414 bool should_qualify =
false;
8423 foreach(lc,
context->namespaces)
8429 should_qualify =
true;
8475 if (strlen(op) == 1)
8499 case T_CoerceToDomainValue:
8500 case T_SetToDefault:
8501 case T_CurrentOfExpr:
8505 case T_SubscriptingRef:
8508 case T_CoalesceExpr:
8510 case T_SQLValueFunction:
8512 case T_NextValueExpr:
8515 case T_GroupingFunc:
8517 case T_MergeSupportFunc:
8519 case T_JsonConstructorExpr:
8543 case T_CoerceToDomain:
8553 case T_ArrayCoerceExpr:
8556 case T_ConvertRowtypeExpr:
8566 const char *parentOp;
8569 bool is_lopriparent;
8570 bool is_hipriparent;
8577 is_lopriop = (strchr(
"+-", *op) != NULL);
8578 is_hipriop = (strchr(
"*/%", *op) != NULL);
8579 if (!(is_lopriop || is_hipriop))
8586 is_lopriparent = (strchr(
"+-", *parentOp) != NULL);
8587 is_hipriparent = (strchr(
"*/%", *parentOp) != NULL);
8588 if (!(is_lopriparent || is_hipriparent))
8591 if (is_hipriop && is_lopriparent)
8594 if (is_lopriop && is_hipriparent)
8613 case T_DistinctExpr:
8614 case T_JsonIsPredicate:
8629 case T_SubscriptingRef:
8632 case T_CoalesceExpr:
8637 case T_GroupingFunc:
8655 parentType = ((
BoolExpr *) parentNode)->boolop;
8681 case T_SubscriptingRef:
8684 case T_CoalesceExpr:
8689 case T_GroupingFunc:
8698 case T_JsonValueExpr:
8719 int indentBefore,
int indentAfter,
int indentPlus)
8727 context->indentLevel += indentBefore;
8735 indentAmount =
Max(
context->indentLevel, 0) + indentPlus;
8752 indentAmount += indentPlus;
8758 context->indentLevel += indentAfter;
8774 while (
str->len > 0 &&
str->data[
str->len - 1] ==
' ')
8775 str->data[--(
str->len)] =
'\0';
8792 bool showimplicit,
Node *parentNode)
8816 const char *behavior_names[] =
8925 case T_GroupingFunc:
8939 case T_MergeSupportFunc:
8943 case T_SubscriptingRef:
9013 case T_NamedArgExpr:
9026 case T_DistinctExpr:
9053 case T_ScalarArrayOpExpr:
9067 expr->
useOr ?
"ANY" :
"ALL");
9236 case T_AlternativeSubPlan:
9252 if (
splan->useHashTable)
9268 const char *fieldname;
9342 relabel->resulttypmod,
9369 case T_ArrayCoerceExpr:
9384 acoerce->resulttypmod,
9390 case T_ConvertRowtypeExpr:
9437 foreach(temp, caseexpr->
args)
9487 case T_CaseTestExpr:
9532 if (rowexpr->row_typeid != RECORDOID)
9549 if (tupdesc == NULL ||
9559 if (tupdesc != NULL)
9561 while (i < tupdesc->natts)
9581 case T_RowCompareExpr:
9610 case T_CoalesceExpr:
9624 switch (minmaxexpr->
op)
9638 case T_SQLValueFunction:
9702 bool needcomma =
false;
9791 Assert(!con->constisnull);
9794 " PRESERVE WHITESPACE");
9797 " STRIP WHITESPACE");
9814 if (con->constisnull)
9822 ", STANDALONE YES");
9830 ", STANDALONE NO VALUE");
9867 if (ntest->argisrow ||
9879 elog(
ERROR,
"unrecognized nulltesttype: %d",
9894 elog(
ERROR,
"unrecognized nulltesttype: %d",
9931 elog(
ERROR,
"unrecognized booltesttype: %d",
9939 case T_CoerceToDomain:
9954 ctest->resulttypmod,
9960 case T_CoerceToDomainValue:
9964 case T_SetToDefault:
9968 case T_CurrentOfExpr:
9981 case T_NextValueExpr:
9997 case T_InferenceElem:
10000 bool save_varprefix;
10007 save_varprefix =
context->varprefix;
10018 need_parens =
false;
10027 context->varprefix = save_varprefix;
10044 case T_PartitionBoundSpec:
10096 elog(
ERROR,
"unrecognized partition strategy: %d",
10103 case T_JsonValueExpr:
10112 case T_JsonConstructorExpr:
10116 case T_JsonIsPredicate:
10168 elog(
ERROR,
"unrecognized JsonExpr op: %d",
10182 bool needcomma =
false;
10219 foreach(l, (
List *) node)
10253 if (node &&
IsA(node,
Var))
10332 case T_CoalesceExpr:
10334 case T_SQLValueFunction:
10408 false, (
Node *) expr);
10420 Oid rettype = expr->funcresulttype;
10421 int32 coercedTypmod;
10427 rettype, coercedTypmod,
10450 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
10451 errmsg(
"too many arguments")));
10454 foreach(l, expr->
args)
10466 argnames, argtypes,
10467 expr->funcvariadic,
10471 foreach(l, expr->
args)
10475 if (use_variadic &&
lnext(expr->
args, l) == NULL)
10487 Aggref *original_aggref)
10500 const char *
options,
bool is_json_objectagg)
10505 bool use_variadic =
false;
10537 argtypes, aggref->aggvariadic,
10545 if (AGGKIND_IS_ORDERED_SET(aggref->aggkind))
10552 Assert(!aggref->aggvariadic);
10561 if (aggref->aggstar)
10569 foreach(l, aggref->
args)
10579 if (is_json_objectagg)
10593 if (use_variadic &&
i == nargs)
10627 Aggref *original_aggref = callback_arg;
10630 elog(
ERROR,
"combining Aggref does not point to an Aggref");
10632 aggref = (
Aggref *) node;
10653 bool is_json_objectagg)
10663 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
10664 errmsg(
"too many arguments")));
10667 foreach(l, wfunc->
args)
10679 argtypes,
false, NULL,
10685 if (wfunc->winstar)
10689 if (is_json_objectagg)
10710 foreach(l,
context->windowClause)
10726 elog(
ERROR,
"could not find window clause for winref %u",
10751 case F_TIMEZONE_INTERVAL_TIMESTAMP:
10752 case F_TIMEZONE_INTERVAL_TIMESTAMPTZ:
10753 case F_TIMEZONE_INTERVAL_TIMETZ:
10754 case F_TIMEZONE_TEXT_TIMESTAMP:
10755 case F_TIMEZONE_TEXT_TIMESTAMPTZ:
10756 case F_TIMEZONE_TEXT_TIMETZ:
10767 case F_TIMEZONE_TIMESTAMP:
10768 case F_TIMEZONE_TIMESTAMPTZ:
10769 case F_TIMEZONE_TIMETZ:
10777 case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_INTERVAL:
10778 case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_TIMESTAMPTZ:
10779 case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_INTERVAL:
10780 case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ:
10781 case F_OVERLAPS_TIMESTAMP_INTERVAL_TIMESTAMP_INTERVAL:
10782 case F_OVERLAPS_TIMESTAMP_INTERVAL_TIMESTAMP_TIMESTAMP:
10783 case F_OVERLAPS_TIMESTAMP_TIMESTAMP_TIMESTAMP_INTERVAL:
10784 case F_OVERLAPS_TIMESTAMP_TIMESTAMP_TIMESTAMP_TIMESTAMP:
10785 case F_OVERLAPS_TIMETZ_TIMETZ_TIMETZ_TIMETZ:
10786 case F_OVERLAPS_TIME_INTERVAL_TIME_INTERVAL:
10787 case F_OVERLAPS_TIME_INTERVAL_TIME_TIME:
10788 case F_OVERLAPS_TIME_TIME_TIME_INTERVAL:
10789 case F_OVERLAPS_TIME_TIME_TIME_TIME:
10802 case F_EXTRACT_TEXT_DATE:
10803 case F_EXTRACT_TEXT_TIME:
10804 case F_EXTRACT_TEXT_TIMETZ:
10805 case F_EXTRACT_TEXT_TIMESTAMP:
10806 case F_EXTRACT_TEXT_TIMESTAMPTZ:
10807 case F_EXTRACT_TEXT_INTERVAL:
10815 !con->constisnull);
10823 case F_IS_NORMALIZED:
10835 !con->constisnull);
10842 case F_PG_COLLATION_FOR:
10859 !con->constisnull);
10866 case F_OVERLAY_BIT_BIT_INT4:
10867 case F_OVERLAY_BIT_BIT_INT4_INT4:
10868 case F_OVERLAY_BYTEA_BYTEA_INT4:
10869 case F_OVERLAY_BYTEA_BYTEA_INT4_INT4:
10870 case F_OVERLAY_TEXT_TEXT_INT4:
10871 case F_OVERLAY_TEXT_TEXT_INT4_INT4:
10887 case F_POSITION_BIT_BIT:
10888 case F_POSITION_BYTEA_BYTEA:
10889 case F_POSITION_TEXT_TEXT:
10898 case F_SUBSTRING_BIT_INT4:
10899 case F_SUBSTRING_BIT_INT4_INT4:
10900 case F_SUBSTRING_BYTEA_INT4:
10901 case F_SUBSTRING_BYTEA_INT4_INT4:
10902 case F_SUBSTRING_TEXT_INT4:
10903 case F_SUBSTRING_TEXT_INT4_INT4:
10917 case F_SUBSTRING_TEXT_TEXT_TEXT:
10928 case F_BTRIM_BYTEA_BYTEA:
10930 case F_BTRIM_TEXT_TEXT:
10943 case F_LTRIM_BYTEA_BYTEA:
10945 case F_LTRIM_TEXT_TEXT:
10958 case F_RTRIM_BYTEA_BYTEA:
10960 case F_RTRIM_TEXT_TEXT:
10973 case F_SYSTEM_USER:
10997 Oid resulttype,
int32 resulttypmod,
11018 ((
Const *)
arg)->consttype == resulttype &&
11019 ((
Const *)
arg)->consttypmod == -1)
11066 bool needlabel =
false;
11068 if (constval->constisnull)
11079 constval->consttypmod));
11086 &typoutput, &typIsVarlena);
11103 if (extval[0] !=
'-')
11119 if (isdigit((
unsigned char) extval[0]) &&
11120 strcspn(extval,
"eE.") != strlen(extval))
11132 if (strcmp(extval,
"t") == 0)
11172 needlabel |= (constval->consttypmod >= 0);
11178 if (needlabel || showtype > 0)
11181 constval->consttypmod));
11198 if (constval->constcollid != typcollation)
11229 " FORMAT JSONB" :
" FORMAT JSON");
11248 bool json_format_by_default)
11257 if (!json_format_by_default ||
11272 bool is_json_object;
11287 switch (ctor->
type)
11311 foreach(lc, ctor->
args)
11318 sep = (is_json_object && (curridx % 2) != 0) ?
" : " :
", ";
11364 const char *
funcname,
bool is_json_objectagg)
11378 is_json_objectagg);
11380 elog(
ERROR,
"invalid JsonConstructorExpr underlying node type: %d",
11390 const char *valptr;
11398 for (valptr =
val; *valptr; valptr++)
11419 char *opname = NULL;
11481 elog(
ERROR,
"unrecognized testexpr type: %d",
11494 if (strcmp(opname,
"=") == 0)
11511 need_paren =
false;
11516 elog(
ERROR,
"unrecognized sublink type: %d",
11546 if (tf->ns_uris !=
NIL)
11553 forboth(lc1, tf->ns_uris, lc2, tf->ns_names)
11563 if (ns_node != NULL)
11593 forfive(l1, tf->colnames, l2, tf->coltypes, l3, tf->coltypmods,
11594 l4, tf->
colexprs, l5, tf->coldefexprs)
11601 bool ordinality = (tf->ordinalitycol == colnum);
11609 ordinality ?
"FOR ORDINALITY" :
11614 if (coldefexpr != NULL)
11620 if (colexpr != NULL)
11688 forfour(lc_colname, tf->colnames,
11689 lc_coltype, tf->coltypes,
11690 lc_coltypmod, tf->coltypmods,
11691 lc_colvalexpr, tf->colvalexprs)
11705 if (scan->
colMin < 0 || colnum < scan->colMin)
11710 if (colnum > scan->
colMax)
11713 if (colnum > scan->
colMin)
11718 ordinality = !colexpr;
11723 ordinality ?
"FOR ORDINALITY" :
11738 bool typispreferred;
11742 if (typcategory == TYPCATEGORY_STRING)
11745 " FORMAT JSONB" :
" FORMAT JSON");
11801 bool needcomma =
false;
11886 if (!rte->inFromCl)
11920 if (itembuf.
len > 0 && itembuf.
data[0] ==
'\n')
11931 trailing_nl = strrchr(
buf->data,
'\n');
11932 if (trailing_nl == NULL)
11933 trailing_nl =
buf->data;
11941 if (strlen(trailing_nl) + itembuf.
len >
context->wrapColumn)
12034 rtfunc->funccolnames !=
NIL)
12036 all_unnest =
false;
12069 if (rtfunc->funccolnames !=
NIL)
12108 if (rtfunc1 && rtfunc1->funccolnames !=
NIL)
12127 bool need_paren_on_right;
12138 switch (
j->jointype)
12171 elog(
ERROR,
"unrecognized join type: %d",
12172 (
int)
j->jointype);
12175 if (need_paren_on_right)
12178 if (need_paren_on_right)
12181 if (
j->usingClause)
12190 char *colname = (
char *)
lfirst(lc);
12200 if (
j->join_using_alias)
12223 if (
j->alias != NULL)
12239 elog(
ERROR,
"unrecognized node type: %d",
12255 bool printalias =
false;
12257 if (rte->alias != NULL)
12304 if (strcmp(refname, rte->
ctename) != 0)
12310 use_as ?
" AS " :
" ",
12374 forfour(l1, rtfunc->funccoltypes,
12375 l2, rtfunc->funccoltypmods,
12376 l3, rtfunc->funccolcollations,
12377 l4, rtfunc->funccolnames)
12422 argtypes[0] = INTERNALOID;
12429 foreach(l, tablesample->
args)
12465 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
12472 opcname =
NameStr(opcrec->opcname);
12500 return &
buf.data[1];
12533 elog(
ERROR,
"argument type %s of FieldStore is not a tuple type",
12574 node = (
Node *) cdomain->
arg;
12586 if (cdomain && node == (
Node *) cdomain->
arg)
12587 node = (
Node *) cdomain;
12642 for (ptr =
ident; *ptr; ptr++)
12646 if ((ch >=
'a' && ch <=
'z') ||
12647 (ch >=
'0' && ch <=
'9') ||
12682 result = (
char *)
palloc(strlen(
ident) + nquotes + 2 + 1);
12686 for (ptr =
ident; *ptr; ptr++)
12732 elog(
ERROR,
"cache lookup failed for relation %u", relid);
12759 elog(
ERROR,
"cache lookup failed for relation %u", relid);
12765 foreach(nslist, namespaces)
12770 foreach(ctlist, dpns->
ctes)
12817 elog(
ERROR,
"cache lookup failed for relation %u", relid);
12823 elog(
ERROR,
"cache lookup failed for namespace %u",
12824 reltup->relnamespace);
12850 bool has_variadic,
bool *use_variadic_p,
12865 Oid *p_true_typeids;
12866 bool force_qualify =
false;
12870 elog(
ERROR,
"cache lookup failed for function %u", funcid);
12880 if (strcmp(
proname,
"cube") == 0 || strcmp(
proname,
"rollup") == 0)
12881 force_qualify =
true;
12894 if (use_variadic_p)
12898 use_variadic = has_variadic;
12899 *use_variadic_p = use_variadic;
12904 use_variadic =
false;
12914 if (!force_qualify)
12916 NIL, argnames, nargs, argtypes,
12917 !use_variadic,
true,
false,
12918 &p_funcid, &p_rettype,
12919 &p_retset, &p_nvargs, &p_vatype,
12920 &p_true_typeids, NULL);
12930 p_funcid == funcid)
12967 elog(
ERROR,
"cache lookup failed for operator %u", operid);
12969 oprname =
NameStr(operform->oprname);
12976 switch (operform->oprkind)
12987 elog(
ERROR,
"unrecognized oprkind: %d", operform->oprkind);
12992 if (p_result != NULL &&
oprid(p_result) == operid)
13005 if (p_result != NULL)
13032 const char *leftop,
Oid leftoptype,
13034 const char *rightop,
Oid rightoptype)
13043 elog(
ERROR,
"cache lookup failed for operator %u", opoid);
13045 Assert(operform->oprkind ==
'b');
13046 oprname =
NameStr(operform->oprname);
13051 if (leftoptype != operform->oprleft)
13056 if (rightoptype != operform->oprright)
13080 elog(
ERROR,
"cache lookup failed for type %u", typid);
13112 elog(
ERROR,
"cache lookup failed for type %u", typid);
13118 elog(
ERROR,
"cache lookup failed for namespace %u",
13119 typtup->typnamespace);
13147 collname =
NameStr(colltup->collname);
13237 char *result = NULL;
13244 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13247 Anum_pg_class_reloptions, &isnull);
13280 foreach(cell, bound_datums)
IndexAmRoutine * GetIndexAmRoutine(Oid amhandler)
#define DatumGetArrayTypeP(X)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
Datum array_ref(ArrayType *array, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
#define InvalidAttrNumber
char * get_tablespace_name(Oid spc_oid)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_make_singleton(int x)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
#define TextDatumGetCString(d)
#define Assert(condition)
#define SQL_STR_DOUBLE(ch, escape_backslash)
#define OidIsValid(objectId)
const uint8 ScanKeywordCategories[SCANKEYWORDS_NUM_KEYWORDS]
static void PGresult * res
void hash_destroy(HTAB *hashp)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define palloc0_array(type, count)
char * OidOutputFunctionCall(Oid functionId, Datum val)
#define PG_GETARG_TEXT_PP(n)
#define DatumGetByteaPP(X)
#define DirectFunctionCall1(func, arg1)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_NAME(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
int get_func_trftypes(HeapTuple procTup, Oid **p_trftypes)
int get_func_arg_info(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, char **p_argmodes)
TupleDesc get_expr_result_tupdesc(Node *expr, bool noError)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
int GetConfigOptionFlags(const char *name, bool missing_ok)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
#define HeapTupleIsValid(tuple)
static Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Oid GetDefaultOpClass(Oid type_id, Oid am_id)
if(TABLE==NULL||TABLE_index==NULL)
PGDLLIMPORT const ScanKeywordList ScanKeywords
#define UNRESERVED_KEYWORD
int ScanKeywordLookup(const char *str, const ScanKeywordList *keywords)
List * lappend(List *list, void *datum)
List * list_copy(const List *oldlist)
List * list_delete_first(List *list)
void list_free(List *list)
List * list_copy_tail(const List *oldlist, int nskip)
List * list_concat(List *list1, const List *list2)
List * lcons(void *datum, List *list)
char * get_language_name(Oid langoid, bool missing_ok)
AttrNumber get_attnum(Oid relid, const char *attname)
Oid get_opclass_input_type(Oid opclass)
char * get_namespace_name_or_temp(Oid nspid)
bool type_is_rowtype(Oid typid)
char * get_namespace_name(Oid nspid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Datum get_attoptions(Oid relid, int16 attnum)
char get_rel_relkind(Oid relid)
Oid get_typcollation(Oid typid)
char * get_rel_name(Oid relid)
char * get_constraint_name(Oid conoid)
Oid get_rel_tablespace(Oid relid)
Oid get_typ_typrelid(Oid typid)
Oid get_base_element_type(Oid typid)
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
void get_atttypetypmodcoll(Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
Alias * makeAlias(const char *aliasname, List *colnames)
int pg_mbcliplen(const char *mbstr, int len, int limit)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define CHECK_FOR_INTERRUPTS()
Datum namein(PG_FUNCTION_ARGS)
bool CollationIsVisible(Oid collid)
bool RelationIsVisible(Oid relid)
bool OpclassIsVisible(Oid opcid)
RangeVar * makeRangeVarFromNameList(const List *names)
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Oid exprType(const Node *expr)
bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
Node * strip_implicit_coercions(Node *node)
#define DO_AGGSPLIT_SKIPFINAL(as)
#define IsA(nodeptr, _type_)
#define DO_AGGSPLIT_COMBINE(as)
#define castNode(_type_, nodeptr)
#define repalloc0_array(pointer, type, oldcount, count)
int get_aggregate_argtypes(Aggref *aggref, Oid *inputTypes)
FuncDetailCode func_get_detail(List *funcname, List *fargs, List *fargnames, int nargs, Oid *argtypes, bool expand_variadic, bool expand_defaults, bool include_out_arguments, Oid *funcid, Oid *rettype, bool *retset, int *nvargs, Oid *vatype, Oid **true_typeids, List **argdefaults)
Operator left_oper(ParseState *pstate, List *op, Oid arg, bool noError, int location)
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
char * get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars)
#define FRAMEOPTION_END_CURRENT_ROW
#define FRAMEOPTION_END_OFFSET
#define FRAMEOPTION_EXCLUDE_CURRENT_ROW
#define FKCONSTR_ACTION_RESTRICT
#define FRAMEOPTION_END_OFFSET_PRECEDING
#define FRAMEOPTION_START_UNBOUNDED_PRECEDING
#define GetCTETargetList(cte)
#define FKCONSTR_ACTION_SETDEFAULT
@ PARTITION_STRATEGY_HASH
@ PARTITION_STRATEGY_LIST
@ PARTITION_STRATEGY_RANGE
#define FRAMEOPTION_START_CURRENT_ROW
#define FKCONSTR_MATCH_SIMPLE
#define FRAMEOPTION_START_OFFSET
@ PARTITION_RANGE_DATUM_MAXVALUE
@ PARTITION_RANGE_DATUM_MINVALUE
#define FKCONSTR_MATCH_PARTIAL
#define FRAMEOPTION_END_OFFSET_FOLLOWING
#define FRAMEOPTION_EXCLUDE_TIES
#define FRAMEOPTION_RANGE
#define FRAMEOPTION_EXCLUDE_GROUP
#define FKCONSTR_ACTION_CASCADE
#define FRAMEOPTION_GROUPS
#define FRAMEOPTION_BETWEEN
#define FKCONSTR_ACTION_SETNULL
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
#define FRAMEOPTION_START_OFFSET_PRECEDING
#define FRAMEOPTION_START_OFFSET_FOLLOWING
#define FRAMEOPTION_NONDEFAULT
#define FKCONSTR_MATCH_FULL
#define FKCONSTR_ACTION_NOACTION
PGDLLIMPORT bool standard_conforming_strings
#define rt_fetch(rangetable_index, rangetable)
Expr * get_partition_qual_relid(Oid relid)
FormData_pg_aggregate * Form_pg_aggregate
FormData_pg_am * Form_pg_am
FormData_pg_attribute * Form_pg_attribute
FormData_pg_authid * Form_pg_authid
FormData_pg_class * Form_pg_class
FormData_pg_collation * Form_pg_collation
AttrNumber extractNotNullColumn(HeapTuple constrTup)
FormData_pg_constraint * Form_pg_constraint
FormData_pg_depend * Form_pg_depend
FormData_pg_index * Form_pg_index
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define lsecond_node(type, l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_current_index(var_or_cell)
#define for_each_cell(cell, lst, initcell)
static ListCell * list_head(const List *l)
#define for_each_from(cell, lst, N)
#define foreach_node(type, var, lst)
#define forfour(cell1, list1, cell2, list2, cell3, list3, cell4, list4)
static void * list_nth(const List *list, int n)
static ListCell * lnext(const List *l, const ListCell *c)
#define forfive(cell1, list1, cell2, list2, cell3, list3, cell4, list4, cell5, list5)
#define list_make2(x1, x2)
#define foreach_int(var, lst)
static int list_cell_number(const List *l, const ListCell *c)
#define lthird_node(type, l)
FormData_pg_opclass * Form_pg_opclass
FormData_pg_operator * Form_pg_operator
FormData_pg_partitioned_table * Form_pg_partitioned_table
FormData_pg_proc * Form_pg_proc
FormData_pg_statistic_ext * Form_pg_statistic_ext
FormData_pg_trigger * Form_pg_trigger
FormData_pg_type * Form_pg_type
void check_stack_depth(void)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Name DatumGetName(Datum X)
static Oid DatumGetObjectId(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static char DatumGetChar(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int16 DatumGetInt16(Datum X)
static int32 DatumGetInt32(Datum X)
@ SVFOP_CURRENT_TIMESTAMP
@ SVFOP_CURRENT_TIMESTAMP_N
@ OVERRIDING_SYSTEM_VALUE
@ MERGE_WHEN_NOT_MATCHED_BY_TARGET
@ MERGE_WHEN_NOT_MATCHED_BY_SOURCE
void * stringToNode(const char *str)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
void AcquireRewriteLocks(Query *parsetree, bool forExecute, bool forUpdatePushedDown)
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
#define ViewSelectRuleName
Datum pg_get_triggerdef_ext(PG_FUNCTION_ARGS)
static void make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, int prettyFlags, int wrapColumn)
static void removeStringInfoSpaces(StringInfo str)
static bool looks_like_function(Node *node)
Datum pg_get_partition_constraintdef(PG_FUNCTION_ARGS)
static char * get_rtable_name(int rtindex, deparse_context *context)
Datum pg_get_viewdef_wrap(PG_FUNCTION_ARGS)
static int decompile_column_index_array(Datum column_index_array, Oid relId, bool withPeriod, StringInfo buf)
static void set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte, deparse_columns *colinfo)
static void appendContextKeyword(deparse_context *context, const char *str, int indentBefore, int indentAfter, int indentPlus)
Datum pg_get_indexdef_ext(PG_FUNCTION_ARGS)
static void set_using_names(deparse_namespace *dpns, Node *jtnode, List *parentUsing)
static Plan * find_recursive_union(deparse_namespace *dpns, WorkTableScan *wtscan)
static text * string_to_text(char *str)
static void get_values_def(List *values_lists, deparse_context *context)
char * deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit)
#define PRETTYINDENT_LIMIT
Datum pg_get_viewdef(PG_FUNCTION_ARGS)
static char * make_colname_unique(char *colname, deparse_namespace *dpns, deparse_columns *colinfo)
static void get_json_behavior(JsonBehavior *behavior, deparse_context *context, const char *on)
static const char * get_simple_binary_op_name(OpExpr *expr)
static void get_json_agg_constructor(JsonConstructorExpr *ctor, deparse_context *context, const char *funcname, bool is_json_objectagg)
Datum pg_get_constraintdef(PG_FUNCTION_ARGS)
static void set_deparse_for_query(deparse_namespace *dpns, Query *query, List *parent_namespaces)
static void print_function_trftypes(StringInfo buf, HeapTuple proctup)
void(* rsv_callback)(Node *node, deparse_context *context, void *callback_arg)
char * pg_get_constraintdef_command(Oid constraintId)
#define PRETTYINDENT_JOIN
static bool is_input_argument(int nth, const char *argmodes)
static void get_query_def(Query *query, StringInfo buf, List *parentnamespace, TupleDesc resultDesc, bool colNamesVisible, int prettyFlags, int wrapColumn, int startIndent)
static void get_tablesample_def(TableSampleClause *tablesample, deparse_context *context)
Datum pg_get_functiondef(PG_FUNCTION_ARGS)
Datum pg_get_function_result(PG_FUNCTION_ARGS)
const char * quote_identifier(const char *ident)
Datum pg_get_indexdef(PG_FUNCTION_ARGS)
static void get_sublink_expr(SubLink *sublink, deparse_context *context)
static void get_rte_alias(RangeTblEntry *rte, int varno, bool use_as, deparse_context *context)
Datum pg_get_function_arg_default(PG_FUNCTION_ARGS)
char * generate_opclass_name(Oid opclass)
static void get_parameter(Param *param, deparse_context *context)
Datum pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS)
Datum pg_get_ruledef(PG_FUNCTION_ARGS)
static void get_json_table_columns(TableFunc *tf, JsonTablePathScan *scan, deparse_context *context, bool showimplicit)
#define PRETTYFLAG_INDENT
List * deparse_context_for(const char *aliasname, Oid relid)
static void get_column_alias_list(deparse_columns *colinfo, deparse_context *context)
Datum pg_get_statisticsobjdef_columns(PG_FUNCTION_ARGS)
Datum pg_get_statisticsobjdef(PG_FUNCTION_ARGS)
static void simple_quote_literal(StringInfo buf, const char *val)
static bool colname_is_unique(const char *colname, deparse_namespace *dpns, deparse_columns *colinfo)
static void get_from_clause_coldeflist(RangeTblFunction *rtfunc, deparse_columns *colinfo, deparse_context *context)
static void get_from_clause(Query *query, const char *prefix, deparse_context *context)
static void get_basic_select_query(Query *query, deparse_context *context, TupleDesc resultDesc, bool colNamesVisible)
static bool get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
static void get_target_list(List *targetList, deparse_context *context, TupleDesc resultDesc, bool colNamesVisible)
Datum pg_get_partkeydef(PG_FUNCTION_ARGS)
static char * generate_qualified_relation_name(Oid relid)
static void set_simple_column_names(deparse_namespace *dpns)
static void get_json_expr_options(JsonExpr *jsexpr, deparse_context *context, JsonBehaviorType default_behavior)
#define PRETTY_INDENT(context)
static void get_rule_groupingset(GroupingSet *gset, List *targetlist, bool omit_parens, deparse_context *context)
static char * pg_get_indexdef_worker(Oid indexrelid, int colno, const Oid *excludeOps, bool attrsOnly, bool keysOnly, bool showTblSpc, bool inherits, int prettyFlags, bool missing_ok)
static char * pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, int prettyFlags, bool missing_ok)
static void get_rule_expr_funccall(Node *node, deparse_context *context, bool showimplicit)
static void expand_colnames_array_to(deparse_columns *colinfo, int n)
static SubPlan * find_param_generator(Param *param, deparse_context *context, int *column_p)
static void add_cast_to(StringInfo buf, Oid typid)
static void get_special_variable(Node *node, deparse_context *context, void *callback_arg)
static void get_select_query_def(Query *query, deparse_context *context, TupleDesc resultDesc, bool colNamesVisible)
static void get_windowfunc_expr_helper(WindowFunc *wfunc, deparse_context *context, const char *funcname, const char *options, bool is_json_objectagg)
static void get_rule_list_toplevel(List *lst, deparse_context *context, bool showimplicit)
char * pg_get_statisticsobjdef_string(Oid statextid)
static char * pg_get_statisticsobj_worker(Oid statextid, bool columns_only, bool missing_ok)
#define deparse_columns_fetch(rangetable_index, dpns)
static void get_json_constructor(JsonConstructorExpr *ctor, deparse_context *context, bool showimplicit)
static const char *const query_getrulebyoid
static char * generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes, bool has_variadic, bool *use_variadic_p, ParseExprKind special_exprkind)
static void get_json_path_spec(Node *path_spec, deparse_context *context, bool showimplicit)
static void printSubscripts(SubscriptingRef *sbsref, deparse_context *context)
static SubPlan * find_param_generator_initplan(Param *param, Plan *plan, int *column_p)
static void pop_ancestor_plan(deparse_namespace *dpns, deparse_namespace *save_dpns)
char * generate_collation_name(Oid collid)
static void get_rule_expr_paren(Node *node, deparse_context *context, bool showimplicit, Node *parentNode)
bool quote_all_identifiers
static void get_agg_expr(Aggref *aggref, deparse_context *context, Aggref *original_aggref)
static void get_const_collation(Const *constval, deparse_context *context)
static void get_delete_query_def(Query *query, deparse_context *context, bool colNamesVisible)
static SPIPlanPtr plan_getrulebyoid
static void get_json_table_nested_columns(TableFunc *tf, JsonTablePlan *plan, deparse_context *context, bool showimplicit, bool needcomma)
static char * deparse_expression_pretty(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit, int prettyFlags, int startIndent)
Datum pg_get_ruledef_ext(PG_FUNCTION_ARGS)
static void print_function_sqlbody(StringInfo buf, HeapTuple proctup)
static bool has_dangerous_join_using(deparse_namespace *dpns, Node *jtnode)
static Node * get_rule_sortgroupclause(Index ref, List *tlist, bool force_colno, deparse_context *context)
List * select_rtable_names_for_explain(List *rtable, Bitmapset *rels_used)
char * pg_get_partconstrdef_string(Oid partitionId, char *aliasname)
char * quote_qualified_identifier(const char *qualifier, const char *ident)
static char * pg_get_viewdef_worker(Oid viewoid, int prettyFlags, int wrapColumn)
static void push_ancestor_plan(deparse_namespace *dpns, ListCell *ancestor_cell, deparse_namespace *save_dpns)
static SPIPlanPtr plan_getviewrule
char * pg_get_partkeydef_columns(Oid relid, bool pretty)
#define WRAP_COLUMN_DEFAULT
static char * flatten_reloptions(Oid relid)
static text * pg_get_expr_worker(text *expr, Oid relid, int prettyFlags)
List * set_deparse_context_plan(List *dpcontext, Plan *plan, List *ancestors)
static Node * processIndirection(Node *node, deparse_context *context)
static void get_agg_combine_expr(Node *node, deparse_context *context, void *callback_arg)
#define PRETTY_PAREN(context)
Datum pg_get_triggerdef(PG_FUNCTION_ARGS)
Datum pg_get_function_sqlbody(PG_FUNCTION_ARGS)
Datum pg_get_expr(PG_FUNCTION_ARGS)
static char * generate_qualified_type_name(Oid typid)
static void get_xmltable(TableFunc *tf, deparse_context *context, bool showimplicit)
char * pg_get_indexdef_columns_extended(Oid indexrelid, bits16 flags)
static void get_utility_query_def(Query *query, deparse_context *context)
static char * get_relation_name(Oid relid)
Datum pg_get_expr_ext(PG_FUNCTION_ARGS)
char * get_list_partvalue_string(Const *val)
static void get_rule_windowclause(Query *query, deparse_context *context)
static void get_rule_windowspec(WindowClause *wc, List *targetList, deparse_context *context)
static void get_json_returning(JsonReturning *returning, StringInfo buf, bool json_format_by_default)
Datum pg_get_viewdef_name_ext(PG_FUNCTION_ARGS)
static Node * find_param_referent(Param *param, deparse_context *context, deparse_namespace **dpns_p, ListCell **ancestor_cell_p)
static void get_rule_orderby(List *orderList, List *targetList, bool force_colno, deparse_context *context)
static void pop_child_plan(deparse_namespace *dpns, deparse_namespace *save_dpns)
static const char * get_name_for_var_field(Var *var, int fieldno, int levelsup, deparse_context *context)
static void set_join_column_names(deparse_namespace *dpns, RangeTblEntry *rte, deparse_columns *colinfo)
Datum pg_get_constraintdef_ext(PG_FUNCTION_ARGS)
static void set_rtable_names(deparse_namespace *dpns, List *parent_namespaces, Bitmapset *rels_used)
static void get_update_query_targetlist_def(Query *query, List *targetList, deparse_context *context, RangeTblEntry *rte)
static void get_rule_expr(Node *node, deparse_context *context, bool showimplicit)
Datum pg_get_viewdef_ext(PG_FUNCTION_ARGS)
static char * pg_get_partkeydef_worker(Oid relid, int prettyFlags, bool attrsOnly, bool missing_ok)
static void get_oper_expr(OpExpr *expr, deparse_context *context)
char * pg_get_querydef(Query *query, bool pretty)
Datum pg_get_function_identity_arguments(PG_FUNCTION_ARGS)
static char * pg_get_triggerdef_worker(Oid trigid, bool pretty)
#define GET_PRETTY_FLAGS(pretty)
static void get_reloptions(StringInfo buf, Datum reloptions)
static void get_func_expr(FuncExpr *expr, deparse_context *context, bool showimplicit)
static void get_const_expr(Const *constval, deparse_context *context, int showtype)
void generate_operator_clause(StringInfo buf, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
static void get_setop_query(Node *setOp, Query *query, deparse_context *context, TupleDesc resultDesc, bool colNamesVisible)
static void make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, int prettyFlags)
static const char *const query_getviewrule
static char * pg_get_ruledef_worker(Oid ruleoid, int prettyFlags)
static int print_function_arguments(StringInfo buf, HeapTuple proctup, bool print_table_args, bool print_defaults)
static void identify_join_columns(JoinExpr *j, RangeTblEntry *jrte, deparse_columns *colinfo)
char * pg_get_indexdef_columns(Oid indexrelid, bool pretty)
static void print_function_rettype(StringInfo buf, HeapTuple proctup)
static RangeTblEntry * get_simple_values_rte(Query *query, TupleDesc resultDesc)
static void set_deparse_plan(deparse_namespace *dpns, Plan *plan)
static void resolve_special_varno(Node *node, deparse_context *context, rsv_callback callback, void *callback_arg)
static void get_merge_query_def(Query *query, deparse_context *context, bool colNamesVisible)
static void get_json_format(JsonFormat *format, StringInfo buf)
static void get_insert_query_def(Query *query, deparse_context *context, bool colNamesVisible)
static void get_tablefunc(TableFunc *tf, deparse_context *context, bool showimplicit)
static void get_rule_expr_toplevel(Node *node, deparse_context *context, bool showimplicit)
static void get_coercion_expr(Node *arg, deparse_context *context, Oid resulttype, int32 resulttypmod, Node *parentNode)
static void push_child_plan(deparse_namespace *dpns, Plan *plan, deparse_namespace *save_dpns)
static void get_json_constructor_options(JsonConstructorExpr *ctor, StringInfo buf)
char * get_range_partbound_string(List *bound_datums)
static bool isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
static void get_with_clause(Query *query, deparse_context *context)
char * pg_get_indexdef_string(Oid indexrelid)
List * deparse_context_for_plan_tree(PlannedStmt *pstmt, List *rtable_names)
static void get_update_query_def(Query *query, deparse_context *context, bool colNamesVisible)
static char * generate_relation_name(Oid relid, List *namespaces)
static void get_windowfunc_expr(WindowFunc *wfunc, deparse_context *context)
static char * get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
Datum pg_get_serial_sequence(PG_FUNCTION_ARGS)
static char * generate_operator_name(Oid operid, Oid arg1, Oid arg2)
static void get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
Datum pg_get_function_arguments(PG_FUNCTION_ARGS)
static void get_json_table(TableFunc *tf, deparse_context *context, bool showimplicit)
#define PRETTYFLAG_SCHEMA
static void get_opclass_name(Oid opclass, Oid actual_datatype, StringInfo buf)
Datum pg_get_viewdef_name(PG_FUNCTION_ARGS)
Datum pg_get_userbyid(PG_FUNCTION_ARGS)
static void get_agg_expr_helper(Aggref *aggref, deparse_context *context, Aggref *original_aggref, const char *funcname, const char *options, bool is_json_objectagg)
#define RULE_INDEXDEF_PRETTY
#define RULE_INDEXDEF_KEYS_ONLY
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Snapshot GetTransactionSnapshot(void)
void UnregisterSnapshot(Snapshot snapshot)
Snapshot RegisterSnapshot(Snapshot snapshot)
int SPI_fnumber(TupleDesc tupdesc, const char *fname)
SPITupleTable * SPI_tuptable
int SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls, bool read_only, long tcount)
SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes)
int SPI_keepplan(SPIPlanPtr plan)
char * SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation try_relation_open(Oid relationId, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
#define BTEqualStrategyNumber
StringInfo makeStringInfo(void)
void resetStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoSpaces(StringInfo str, int count)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
BoolTestType booltesttype
CTEMaterialize ctematerialized
JsonReturning * returning
JsonReturning * returning
NullTestType nulltesttype
PartitionRangeDatumKind kind
Node * mergeJoinCondition
OnConflictExpr * onConflict
struct TableSampleClause * tablesample
LockClauseStrength strength
LockWaitPolicy waitPolicy
Bitmapset * appendparents
ParseExprKind special_exprkind
AppendRelInfo ** appendrels
int16 values[FLEXIBLE_ARRAY_MEMBER]
Oid values[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
int count_nonjunk_tlist_entries(List *tlist)
#define ReleaseTupleDesc(tupdesc)
#define TupleDescAttr(tupdesc, i)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
String * makeString(char *str)
Relids pull_varnos(PlannerInfo *root, Node *node)
List * textToQualifiedNameList(text *textval)
bool SplitGUCList(char *rawstring, char separator, List **namelist)
char * text_to_cstring(const text *t)
text * cstring_to_text_with_len(const char *s, int len)
text * cstring_to_text(const char *s)
char * map_xml_name_to_sql_identifier(const char *name)
@ XML_STANDALONE_NO_VALUE
static void convert(const int32 val, char *const buf)