62#include "utils/fmgroids.h"
81#define PRETTYINDENT_STD 8
82#define PRETTYINDENT_JOIN 4
83#define PRETTYINDENT_VAR 4
85#define PRETTYINDENT_LIMIT 40
88#define PRETTYFLAG_PAREN 0x0001
89#define PRETTYFLAG_INDENT 0x0002
90#define PRETTYFLAG_SCHEMA 0x0004
93#define GET_PRETTY_FLAGS(pretty) \
94 ((pretty) ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) \
98#define WRAP_COLUMN_DEFAULT 0
101#define PRETTY_PAREN(context) ((context)->prettyFlags & PRETTYFLAG_PAREN)
102#define PRETTY_INDENT(context) ((context)->prettyFlags & PRETTYFLAG_INDENT)
103#define PRETTY_SCHEMA(context) ((context)->prettyFlags & PRETTYFLAG_SCHEMA)
312#define deparse_columns_fetch(rangetable_index, dpns) \
313 ((deparse_columns *) list_nth((dpns)->rtable_columns, (rangetable_index)-1))
336static const char *
const query_getviewrule =
"SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2";
351 bool forceprefix,
bool showimplicit,
352 int prettyFlags,
int startIndent);
354 int prettyFlags,
int wrapColumn);
360 const Oid *excludeOps,
361 bool attrsOnly,
bool keysOnly,
362 bool showTblSpc,
bool inherits,
363 int prettyFlags,
bool missing_ok);
367 bool attrsOnly,
bool missing_ok);
369 int prettyFlags,
bool missing_ok);
372 bool print_table_args,
bool print_defaults);
379 List *parent_namespaces);
414 int prettyFlags,
int wrapColumn);
416 TupleDesc resultDesc,
bool colNamesVisible,
417 int prettyFlags,
int wrapColumn,
int startIndent);
463 int indentBefore,
int indentAfter,
int indentPlus);
481 const char *
options,
bool is_json_objectagg);
487 bool is_json_objectagg);
497 bool json_format_by_default);
505 bool is_json_objectagg);
532 bool has_variadic,
bool *use_variadic_p,
550#define only_marker(rte) ((rte)->inh ? "" : "ONLY ")
626 argtypes[0] = OIDOID;
641 elog(
ERROR,
"failed to get pg_rewrite tuple for rule %u", ruleoid);
818 argtypes[0] = OIDOID;
819 argtypes[1] = NAMEOID;
836 elog(
ERROR,
"failed to get pg_rewrite tuple for view %u", viewoid);
945 tgname =
NameStr(trigrec->tgname);
947 OidIsValid(trigrec->tgconstraint) ?
"CONSTRAINT " :
"",
950 if (TRIGGER_FOR_BEFORE(trigrec->tgtype))
952 else if (TRIGGER_FOR_AFTER(trigrec->tgtype))
954 else if (TRIGGER_FOR_INSTEAD(trigrec->tgtype))
957 elog(
ERROR,
"unexpected tgtype value: %d", trigrec->tgtype);
959 if (TRIGGER_FOR_INSERT(trigrec->tgtype))
964 if (TRIGGER_FOR_DELETE(trigrec->tgtype))
972 if (TRIGGER_FOR_UPDATE(trigrec->tgtype))
980 if (trigrec->tgattr.dim1 > 0)
985 for (
i = 0;
i < trigrec->tgattr.dim1;
i++)
992 trigrec->tgattr.values[
i],
false);
997 if (TRIGGER_FOR_TRUNCATE(trigrec->tgtype))
1020 if (!trigrec->tgdeferrable)
1023 if (trigrec->tginitdeferred)
1041 if (tgoldtable != NULL || tgnewtable != NULL)
1044 if (tgoldtable != NULL)
1047 if (tgnewtable != NULL)
1052 if (TRIGGER_FOR_ROW(trigrec->tgtype))
1078 oldrte->relid = trigrec->tgrelid;
1079 oldrte->relkind = relkind;
1082 oldrte->eref = oldrte->alias;
1083 oldrte->lateral =
false;
1084 oldrte->
inh =
false;
1085 oldrte->inFromCl =
true;
1089 newrte->relid = trigrec->tgrelid;
1090 newrte->relkind = relkind;
1093 newrte->eref = newrte->alias;
1094 newrte->lateral =
false;
1095 newrte->
inh =
false;
1096 newrte->inFromCl =
true;
1099 memset(&dpns, 0,
sizeof(dpns));
1130 false, NULL,
false));
1132 if (trigrec->tgnargs > 0)
1140 elog(
ERROR,
"tgargs is null for trigger %u", trigid);
1142 for (
i = 0;
i < trigrec->tgnargs;
i++)
1244 prettyFlags,
false);
1260 prettyFlags,
false);
1271 const Oid *excludeOps,
1272 bool attrsOnly,
bool keysOnly,
1273 bool showTblSpc,
bool inherits,
1274 int prettyFlags,
bool missing_ok)
1277 bool isConstraint = (excludeOps != NULL);
1291 Datum indclassDatum;
1292 Datum indoptionDatum;
1308 elog(
ERROR,
"cache lookup failed for index %u", indexrelid);
1312 indrelid = idxrec->indrelid;
1313 Assert(indexrelid == idxrec->indexrelid);
1317 Anum_pg_index_indcollation);
1321 Anum_pg_index_indclass);
1325 Anum_pg_index_indoption);
1333 elog(
ERROR,
"cache lookup failed for relation %u", indexrelid);
1341 elog(
ERROR,
"cache lookup failed for access method %u",
1359 Anum_pg_index_indexprs);
1381 idxrec->indisunique ?
"UNIQUE " :
"",
1383 idxrelrec->relkind == RELKIND_PARTITIONED_INDEX
1384 && !inherits ?
"ONLY " :
"",
1398 for (keyno = 0; keyno < idxrec->indnatts; keyno++)
1402 Oid keycolcollation;
1407 if (keysOnly && keyno >= idxrec->indnkeyatts)
1411 if (!colno && keyno == idxrec->indnkeyatts)
1428 if (!colno || colno == keyno + 1)
1431 &keycoltype, &keycoltypmod,
1439 if (indexpr_item == NULL)
1440 elog(
ERROR,
"too few entries in indexprs list");
1442 indexpr_item =
lnext(indexprs, indexpr_item);
1446 if (!colno || colno == keyno + 1)
1459 if (!attrsOnly && keyno < idxrec->indnkeyatts &&
1460 (!colno || colno == keyno + 1))
1463 Oid indcoll = indcollation->
values[keyno];
1465 bool has_options = attoptions != (
Datum) 0;
1468 if (
OidIsValid(indcoll) && indcoll != keycolcollation)
1487 if (opt & INDOPTION_DESC)
1491 if (!(opt & INDOPTION_NULLS_FIRST))
1496 if (opt & INDOPTION_NULLS_FIRST)
1502 if (excludeOps != NULL)
1514 if (idxrec->indnullsnotdistinct)
1555 Anum_pg_index_indpred);
1663 bool ndistinct_enabled;
1664 bool dependencies_enabled;
1679 elog(
ERROR,
"cache lookup failed for statistics object %u", statextid);
1683 has_exprs = !
heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
1698 Anum_pg_statistic_ext_stxexprs);
1707 ncolumns = statextrec->stxkeys.dim1 +
list_length(exprs);
1716 NameStr(statextrec->stxname)));
1723 Anum_pg_statistic_ext_stxkind);
1728 elog(
ERROR,
"stxkind is not a 1-D char array");
1731 ndistinct_enabled =
false;
1732 dependencies_enabled =
false;
1733 mcv_enabled =
false;
1737 if (enabled[
i] == STATS_EXT_NDISTINCT)
1738 ndistinct_enabled =
true;
1739 else if (enabled[
i] == STATS_EXT_DEPENDENCIES)
1740 dependencies_enabled =
true;
1741 else if (enabled[
i] == STATS_EXT_MCV)
1758 if ((!ndistinct_enabled || !dependencies_enabled || !mcv_enabled) &&
1761 bool gotone =
false;
1765 if (ndistinct_enabled)
1771 if (dependencies_enabled)
1787 for (colno = 0; colno < statextrec->stxkeys.dim1; colno++)
1801 statextrec->stxrelid);
1856 has_exprs = !
heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
1871 Anum_pg_statistic_ext_stxexprs);
1877 statextrec->stxrelid);
1937 bool attrsOnly,
bool missing_ok)
1957 elog(
ERROR,
"cache lookup failed for partition key of %u", relid);
1962 Assert(form->partrelid == relid);
1966 Anum_pg_partitioned_table_partclass);
1970 Anum_pg_partitioned_table_partcollation);
1979 if (!
heap_attisnull(tuple, Anum_pg_partitioned_table_partexprs, NULL))
1985 Anum_pg_partitioned_table_partexprs);
1990 elog(
ERROR,
"unexpected node type found in partexprs: %d",
2003 switch (form->partstrat)
2018 elog(
ERROR,
"unexpected partition strategy: %d",
2019 (
int) form->partstrat);
2025 for (keyno = 0; keyno < form->partnatts; keyno++)
2029 Oid keycolcollation;
2043 &keycoltype, &keycoltypmod,
2051 if (partexpr_item == NULL)
2052 elog(
ERROR,
"too few entries in partexprs list");
2054 partexpr_item =
lnext(partexprs, partexpr_item);
2070 partcoll = partcollation->
values[keyno];
2071 if (!attrsOnly &&
OidIsValid(partcoll) && partcoll != keycolcollation)
2106 if (constr_expr == NULL)
2115 false, prettyFlags, 0);
2193 int prettyFlags,
bool missing_ok)
2204 Anum_pg_constraint_oid,
2209 ConstraintOidIndexId,
2231 elog(
ERROR,
"could not find tuple for constraint %u", constraintId);
2263 switch (conForm->contype)
2265 case CONSTRAINT_FOREIGN:
2276 Anum_pg_constraint_conkey);
2288 Anum_pg_constraint_confkey);
2295 switch (conForm->confmatchtype)
2298 string =
" MATCH FULL";
2301 string =
" MATCH PARTIAL";
2307 elog(
ERROR,
"unrecognized confmatchtype: %d",
2308 conForm->confmatchtype);
2315 switch (conForm->confupdtype)
2321 string =
"RESTRICT";
2327 string =
"SET NULL";
2330 string =
"SET DEFAULT";
2333 elog(
ERROR,
"unrecognized confupdtype: %d",
2334 conForm->confupdtype);
2341 switch (conForm->confdeltype)
2347 string =
"RESTRICT";
2353 string =
"SET NULL";
2356 string =
"SET DEFAULT";
2359 elog(
ERROR,
"unrecognized confdeltype: %d",
2360 conForm->confdeltype);
2372 Anum_pg_constraint_confdelsetcols, &isnull);
2382 case CONSTRAINT_PRIMARY:
2383 case CONSTRAINT_UNIQUE:
2391 if (conForm->contype == CONSTRAINT_PRIMARY)
2396 indexId = conForm->conindid;
2400 elog(
ERROR,
"cache lookup failed for index %u", indexId);
2401 if (conForm->contype == CONSTRAINT_UNIQUE &&
2409 Anum_pg_constraint_conkey);
2412 if (conForm->conperiod)
2419 Anum_pg_index_indnatts);
2430 Anum_pg_index_indkey);
2433 &keys, NULL, &nKeys);
2435 for (
j = keyatts;
j < nKeys;
j++)
2476 case CONSTRAINT_CHECK:
2486 Anum_pg_constraint_conbin);
2521 conForm->connoinherit ?
" NO INHERIT" :
"");
2524 case CONSTRAINT_NOTNULL:
2526 if (conForm->conrelid)
2538 else if (conForm->contypid)
2546 case CONSTRAINT_TRIGGER:
2556 case CONSTRAINT_EXCLUSION:
2558 Oid indexOid = conForm->conindid;
2567 Anum_pg_constraint_conexclop);
2570 &elems, NULL, &nElems);
2573 for (
i = 0;
i < nElems;
i++)
2591 elog(
ERROR,
"invalid constraint type \"%c\"", conForm->contype);
2595 if (conForm->condeferrable)
2597 if (conForm->condeferred)
2601 if (!conForm->conenforced)
2603 else if (!conForm->convalidated)
2629 &keys, NULL, &nKeys);
2631 for (
j = 0;
j < nKeys;
j++)
2641 (withPeriod &&
j == nKeys - 1) ?
"PERIOD " :
"",
2738 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2739 errmsg(
"input is a query, not an expression")));
2750 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2751 errmsg(
"expression contains variables of more than one relation")));
2757 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2758 errmsg(
"expression contains variables")));
2814 *result = role_rec->rolname;
2856 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2857 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
2864 Anum_pg_depend_refclassid,
2868 Anum_pg_depend_refobjid,
2872 Anum_pg_depend_refobjsubid,
2888 if (deprec->classid == RelationRelationId &&
2889 deprec->objsubid == 0 &&
2894 sequenceId = deprec->objid;
2952 if (proc->prokind == PROKIND_AGGREGATE)
2954 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2955 errmsg(
"\"%s\" is an aggregate function",
name)));
2957 isfunction = (proc->prokind != PROKIND_PROCEDURE);
2965 isfunction ?
"FUNCTION" :
"PROCEDURE",
2984 if (proc->prokind == PROKIND_WINDOW)
2986 switch (proc->provolatile)
2988 case PROVOLATILE_IMMUTABLE:
2991 case PROVOLATILE_STABLE:
2994 case PROVOLATILE_VOLATILE:
2998 switch (proc->proparallel)
3000 case PROPARALLEL_SAFE:
3003 case PROPARALLEL_RESTRICTED:
3006 case PROPARALLEL_UNSAFE:
3010 if (proc->proisstrict)
3012 if (proc->prosecdef)
3014 if (proc->proleakproof)
3018 if (proc->prolang == INTERNALlanguageId ||
3019 proc->prolang == ClanguageId)
3023 if (proc->procost != procost)
3026 if (proc->prorows > 0 && proc->prorows != 1000)
3029 if (proc->prosupport)
3037 argtypes[0] = INTERNALOID;
3041 false, NULL,
false));
3044 if (oldlen !=
buf.len)
3048 tmp =
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_proconfig, &isnull);
3073 pos = strchr(configitem,
'=');
3106 elog(
ERROR,
"invalid list syntax in proconfig item");
3108 foreach(lc, namelist)
3110 char *curname = (
char *)
lfirst(lc);
3113 if (
lnext(namelist, lc))
3125 (void)
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
3126 if (proc->prolang == SQLlanguageId && !isnull)
3134 tmp =
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_probin, &isnull);
3155 while (strstr(prosrc, dq.
data) != NULL)
3267 if (proc->proretset)
3281 if (proc->proretset)
3298 bool print_table_args,
bool print_defaults)
3305 int insertorderbyat = -1;
3314 &argtypes, &argnames, &argmodes);
3316 nlackdefaults = numargs;
3317 if (print_defaults && proc->pronargdefaults > 0)
3319 Datum proargdefaults;
3323 Anum_pg_proc_proargdefaults,
3332 nextargdefault =
list_head(argdefaults);
3334 nlackdefaults = proc->pronargs -
list_length(argdefaults);
3339 if (proc->prokind == PROKIND_AGGREGATE)
3346 elog(
ERROR,
"cache lookup failed for aggregate %u",
3349 if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
3350 insertorderbyat = agg->aggnumdirectargs;
3356 for (
i = 0;
i < numargs;
i++)
3358 Oid argtype = argtypes[
i];
3359 char *argname = argnames ? argnames[
i] : NULL;
3360 char argmode = argmodes ? argmodes[
i] : PROARGMODE_IN;
3361 const char *modename;
3372 if (proc->prokind == PROKIND_PROCEDURE)
3378 case PROARGMODE_INOUT:
3379 modename =
"INOUT ";
3382 case PROARGMODE_OUT:
3386 case PROARGMODE_VARIADIC:
3387 modename =
"VARIADIC ";
3390 case PROARGMODE_TABLE:
3395 elog(
ERROR,
"invalid parameter mode '%c'", argmode);
3403 if (print_table_args != (argmode == PROARGMODE_TABLE))
3406 if (argsprinted == insertorderbyat)
3412 else if (argsprinted)
3416 if (argname && argname[0])
3419 if (print_defaults && isinput && inputargno > nlackdefaults)
3423 Assert(nextargdefault != NULL);
3425 nextargdefault =
lnext(argdefaults, nextargdefault);
3433 if (argsprinted == insertorderbyat &&
i == numargs - 1)
3437 print_defaults =
false;
3448 || argmodes[nth] == PROARGMODE_IN
3449 || argmodes[nth] == PROARGMODE_INOUT
3450 || argmodes[nth] == PROARGMODE_VARIADIC);
3468 for (
i = 0;
i < ntypes;
i++)
3500 Datum proargdefaults;
3509 if (nth_arg < 1 || nth_arg > numargs || !
is_input_argument(nth_arg - 1, argmodes))
3516 for (
i = 0;
i < nth_arg;
i++)
3521 Anum_pg_proc_proargdefaults,
3539 nth_default = nth_inputarg - 1 - (proc->pronargs - proc->pronargdefaults);
3541 if (nth_default < 0 || nth_default >=
list_length(argdefaults))
3546 node =
list_nth(argdefaults, nth_default);
3567 &argtypes, &argnames, &argmodes);
3623 (void)
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
3645 bool forceprefix,
bool showimplicit)
3648 showimplicit, 0, 0);
3672 bool forceprefix,
bool showimplicit,
3673 int prettyFlags,
int startIndent)
3718 rte->relkind = RELKIND_RELATION;
3721 rte->eref = rte->alias;
3722 rte->lateral =
false;
3724 rte->inFromCl =
true;
3776 Assert(crelid > 0 && crelid <= ntables);
3858 memset(&dpns, 0,
sizeof(dpns));
3905 names_hash =
hash_create(
"set_rtable_names names",
3911 foreach(lc, parent_namespaces)
3918 char *oldname = (
char *)
lfirst(lc2);
3920 if (oldname == NULL)
3933 foreach(lc, dpns->
rtable)
3946 else if (rte->alias)
3949 refname = rte->alias->aliasname;
3964 refname = rte->eref->aliasname;
3982 int refnamelen = strlen(refname);
3983 char *modname = (
char *)
palloc(refnamelen + 16);
3991 memcpy(modname, refname, refnamelen);
4029 List *parent_namespaces)
4161 if (
j->alias == NULL &&
j->usingClause)
4171 for (
int i = 0;
i < jrte->joinmergedcols;
i++)
4187 elog(
ERROR,
"unrecognized node type: %d",
4249 if (rte->alias == NULL)
4255 if (colname == NULL)
4259 if (leftattnos[
i] > 0)
4262 leftcolinfo->
colnames[leftattnos[
i] - 1] = colname;
4266 if (rightattnos[
i] > 0)
4269 rightcolinfo->
colnames[rightattnos[
i] - 1] = colname;
4307 foreach(lc,
j->usingClause)
4312 Assert(leftattnos[
i] != 0 && rightattnos[
i] != 0);
4320 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4333 parentUsing =
lappend(parentUsing, colname);
4336 if (leftattnos[
i] > 0)
4339 leftcolinfo->
colnames[leftattnos[
i] - 1] = colname;
4343 if (rightattnos[
i] > 0)
4346 rightcolinfo->
colnames[rightattnos[
i] - 1] = colname;
4362 elog(
ERROR,
"unrecognized node type: %d",
4378 char **real_colnames;
4398 ncolumns = tupdesc->
natts;
4399 real_colnames = (
char **)
palloc(ncolumns *
sizeof(
char *));
4401 for (
i = 0;
i < ncolumns;
i++)
4405 if (attr->attisdropped)
4406 real_colnames[
i] = NULL;
4437 true , &colnames, NULL);
4440 colnames = rte->eref->colnames;
4443 real_colnames = (
char **)
palloc(ncolumns *
sizeof(
char *));
4446 foreach(lc, colnames)
4454 if (
cname[0] ==
'\0')
4456 real_colnames[
i] =
cname;
4493 changed_any =
false;
4495 for (
i = 0;
i < ncolumns;
i++)
4497 char *real_colname = real_colnames[
i];
4501 if (real_colname == NULL)
4508 if (colname == NULL)
4511 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4514 colname = real_colname;
4530 if (!changed_any && strcmp(colname, real_colname) != 0)
4561 else if (rte->alias && rte->alias->colnames !=
NIL)
4616 changed_any =
false;
4637 if (real_colname == NULL)
4644 if (rte->alias == NULL)
4652 if (colname == NULL)
4655 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4658 colname = real_colname;
4668 if (!changed_any && strcmp(colname, real_colname) != 0)
4703 while (
i < noldcolumns &&
4729 while (ic < leftcolinfo->num_cols &&
4732 Assert(ic < leftcolinfo->num_cols);
4738 while (i < colinfo->num_cols &&
4741 Assert(i < colinfo->num_cols);
4753 if (rte->alias != NULL)
4779 while (ic < rightcolinfo->num_cols &&
4780 rightcolinfo->
colnames[ic] == NULL)
4782 Assert(ic < rightcolinfo->num_cols);
4788 while (i < colinfo->num_cols &&
4791 Assert(i < colinfo->num_cols);
4803 if (rte->alias != NULL)
4821#ifdef USE_ASSERT_CHECKING
4822 while (i < colinfo->num_cols && colinfo->
colnames[
i] == NULL)
4835 if (rte->alias != NULL)
4872 if (oldname && strcmp(oldname, colname) == 0)
4884 if (oldname && strcmp(oldname, colname) == 0)
4894 char *oldname = (
char *)
lfirst(lc);
4896 if (strcmp(oldname, colname) == 0)
4907 char *oldname = (
char *)
lfirst(lc);
4909 if (strcmp(oldname, colname) == 0)
4932 int colnamelen = strlen(colname);
4933 char *modname = (
char *)
palloc(colnamelen + 16);
4941 memcpy(modname, colname, colnamelen);
4942 sprintf(modname + colnamelen,
"_%d",
i);
5025 char *oldname = (
char *)
lfirst(lc);
5078 elog(
ERROR,
"unrecognized node type in jointree: %d",
5085 elog(
ERROR,
"unrecognized node type in jointree: %d",
5106 foreach(lc, jrte->joinleftcols)
5113 foreach(lc, jrte->joinrightcols)
5117 if (rcolno < jrte->joinmergedcols)
5123 Assert(jcolno == numjoincols);
5244 elog(
ERROR,
"could not find RecursiveUnion for WorkTableScan with wtParam %d",
5391 Assert(ev_action != NULL);
5394 elog(
ERROR,
"invalid empty ev_action list");
5431 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5432 errmsg(
"rule \"%s\" has unsupported event type %d",
5433 rulename, ev_type)));
5444 if (strcmp(ev_qual,
"<>") != 0)
5539 int prettyFlags,
int wrapColumn)
5577 Assert(ev_action != NULL);
5588 if (ev_type !=
'1' || !is_instead ||
5598 prettyFlags, wrapColumn, 0);
5624 TupleDesc resultDesc,
bool colNamesVisible,
5625 int prettyFlags,
int wrapColumn,
int startIndent)
5635 rtable_size = query->hasGroupRTE ?
5643 if (query->hasGroupRTE)
5712 elog(
ERROR,
"unrecognized query command type: %d",
5726 bool first_list =
true;
5731 foreach(vtl, values_lists)
5734 bool first_col =
true;
5743 foreach(lc, sublist)
5781 if (query->hasRecursive)
5782 sep =
"WITH RECURSIVE ";
5791 if (cte->aliascolnames)
5797 foreach(col, cte->aliascolnames)
5831 if (cte->search_clause)
5837 cte->search_clause->search_breadth_first ?
"BREADTH" :
"DEPTH");
5839 foreach(lc, cte->search_clause->search_col_list)
5852 if (cte->cycle_clause)
5859 foreach(lc, cte->cycle_clause->cycle_col_list)
5879 get_rule_expr(cte->cycle_clause->cycle_mark_value, context,
false);
5881 get_rule_expr(cte->cycle_clause->cycle_mark_default, context,
false);
5932 force_colno =
false;
5941 force_colno, context);
5986 if (query->hasForUpdate)
6000 elog(
ERROR,
"unrecognized LockClauseStrength %d",
6048 foreach(lc, query->
rtable)
6092 if (resultDesc && colno <= resultDesc->natts)
6095 colname = tle->resname;
6098 if (colname == NULL || strcmp(colname,
cname) != 0)
6135 if (query->isReturn)
6143 if (query->hasDistinctOn)
6179 bool save_ingroupby;
6242 bool last_was_multiline =
false;
6252 foreach(l, targetList)
6270 context->
buf = &targetbuf;
6306 colno - 1)->attname);
6308 colname = tle->resname;
6326 if (targetbuf.
len > 0 && targetbuf.
data[0] ==
'\n')
6329 leading_nl_pos = -1;
6332 if (leading_nl_pos >= 0)
6342 trailing_nl = strrchr(
buf->data,
'\n');
6343 if (trailing_nl == NULL)
6344 trailing_nl =
buf->data;
6354 ((strlen(trailing_nl) + targetbuf.
len > context->
wrapColumn) ||
6355 last_was_multiline))
6361 last_was_multiline =
6362 (strchr(targetbuf.
data + leading_nl_pos + 1,
'\n') != NULL);
6380 bool have_with =
false;
6386 if (query->returningOldAlias && strcmp(query->returningOldAlias,
"old") != 0)
6392 if (query->returningNewAlias && strcmp(query->returningNewAlias,
"new") != 0)
6428 Assert(subquery != NULL);
6436 need_paren = (subquery->
cteList ||
6455 bool save_colnamesvisible;
6550 elog(
ERROR,
"unrecognized node type: %d",
6635 bool omit_child_parens =
true;
6672 omit_child_parens =
false;
6698 foreach(l, orderList)
6707 force_colno, context);
6759 if (wc->name == NULL)
6784 bool needspace =
false;
6838 Node *startOffset,
Node *endOffset,
6898 buf->data[--(
buf->len)] =
'\0';
6907 Node *startOffset,
Node *endOffset,
6908 List *dpcontext,
bool forceprefix)
6946 List *strippedexprs;
6955 foreach(l, query->
rtable)
6962 elog(
ERROR,
"too many subquery RTEs in INSERT");
6969 elog(
ERROR,
"too many values RTEs in INSERT");
6973 if (select_rte && values_rte)
6974 elog(
ERROR,
"both subquery and values RTEs in INSERT");
7000 strippedexprs =
NIL;
7031 strippedexprs =
lappend(strippedexprs,
7038 if (query->override)
7054 else if (values_rte)
7059 else if (strippedexprs)
7090 bool save_varprefix;
7112 elog(
ERROR,
"cache lookup failed for constraint %u",
7208 int remaining_ma_columns;
7219 if (query->hasSubLinks)
7221 foreach(l, targetList)
7231 ma_sublinks =
lappend(ma_sublinks, sl);
7238 cur_ma_sublink = NULL;
7239 remaining_ma_columns = 0;
7243 foreach(l, targetList)
7259 if (next_ma_cell != NULL && cur_ma_sublink == NULL)
7305 next_ma_cell =
lnext(ma_sublinks, next_ma_cell);
7308 ((cur_ma_sublink->
subLinkId << 16) | 1));
7333 if (cur_ma_sublink != NULL)
7335 if (--remaining_ma_columns > 0)
7338 expr = (
Node *) cur_ma_sublink;
7339 cur_ma_sublink = NULL;
7406 bool haveNotMatchedBySource;
7441 haveNotMatchedBySource =
false;
7448 haveNotMatchedBySource =
true;
7460 switch (
action->matchKind)
7469 if (haveNotMatchedBySource)
7475 elog(
ERROR,
"unrecognized matchKind: %d",
7476 (
int)
action->matchKind);
7492 const char *sep =
"";
7499 foreach(lc2,
action->targetList)
7512 strippedexprs =
lappend(strippedexprs,
7581 elog(
ERROR,
"unexpected utility statement type");
7622 elog(
ERROR,
"bogus varlevelsup: %d offset %d",
7635 if (var->varnosyn > 0 && dpns->
plan == NULL)
7637 varno = var->varnosyn;
7638 varattno = var->varattnosyn;
7674 pvarattno = appinfo->parent_colnos[pvarattno - 1];
7694 varattno = pvarattno;
7738 elog(
ERROR,
"invalid attnum %d for relation \"%s\"",
7739 attnum, rte->eref->aliasname);
7741 Assert(netlevelsup == 0);
7772 if (rte->joinaliasvars ==
NIL)
7773 elog(
ERROR,
"cannot decompile join alias var in plan tree");
7780 if (aliasvar &&
IsA(aliasvar,
Var))
7783 istoplevel, context);
7801 elog(
ERROR,
"invalid attnum %d for relation \"%s\"",
7802 attnum, rte->eref->aliasname);
7847 colno - 1)->attname);
7849 colname = tle->resname;
7851 if (colname && strcmp(colname,
attname) == 0 &&
7852 !
equal(var, tle->expr))
7860 if (refname && need_prefix)
7920 (*callback) (node, context, callback_arg);
7995 (*callback) (node, context, callback_arg);
8037 if (fieldno > 0 && fieldno <=
list_length(r->colnames))
8069 var->vartype != RECORDOID)
8073 Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
8080 elog(
ERROR,
"bogus varlevelsup: %d offset %d",
8090 if (var->varnosyn > 0 && dpns->
plan == NULL)
8092 varno = var->varnosyn;
8093 varattno = var->varattnosyn;
8123 elog(
ERROR,
"bogus varattno for OUTER_VAR var: %d", varattno);
8125 Assert(netlevelsup == 0);
8142 elog(
ERROR,
"bogus varattno for INNER_VAR var: %d", varattno);
8144 Assert(netlevelsup == 0);
8160 elog(
ERROR,
"bogus varattno for INDEX_VAR var: %d", varattno);
8162 Assert(netlevelsup == 0);
8188 expr = (
Node *) var;
8211 if (ste == NULL || ste->resjunk)
8212 elog(
ERROR,
"subquery %s does not have attribute %d",
8213 rte->eref->aliasname,
attnum);
8227 List *parent_namespaces;
8270 char *dummy_name =
palloc(32);
8273 snprintf(dummy_name, 32,
"f%d", fieldno);
8280 elog(
ERROR,
"bogus varattno for subquery var: %d",
8282 Assert(netlevelsup == 0);
8295 if (rte->joinaliasvars ==
NIL)
8296 elog(
ERROR,
"cannot decompile join alias var in plan tree");
8334 foreach(lc, ctedpns->
ctes)
8347 if (ste == NULL || ste->resjunk)
8348 elog(
ERROR,
"CTE %s does not have attribute %d",
8349 rte->eref->aliasname,
attnum);
8350 expr = (
Node *) ste->expr;
8361 List *parent_namespaces;
8401 char *dummy_name =
palloc(32);
8404 snprintf(dummy_name, 32,
"f%d", fieldno);
8412 elog(
ERROR,
"bogus varattno for subquery var: %d",
8414 Assert(netlevelsup == 0);
8441 Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
8459 *ancestor_cell_p = NULL;
8473 child_plan = dpns->
plan;
8496 *ancestor_cell_p = lc;
8516 if (paramid == param->
paramid)
8534 *ancestor_cell_p = rest;
8538 elog(
ERROR,
"SubPlan cannot be outermost ancestor");
8552 child_plan = (
Plan *) ancestor;
8608 if (paramid == param->
paramid)
8633 if (paramid == param->
paramid)
8671 if (paramid == param->
paramid)
8704 bool save_varprefix;
8722 need_paren = !(
IsA(expr,
Var) ||
8774 bool should_qualify =
false;
8789 should_qualify =
true;
8835 if (strlen(op) == 1)
8859 case T_CoerceToDomainValue:
8860 case T_SetToDefault:
8861 case T_CurrentOfExpr:
8865 case T_SubscriptingRef:
8868 case T_CoalesceExpr:
8870 case T_SQLValueFunction:
8872 case T_NextValueExpr:
8875 case T_GroupingFunc:
8877 case T_MergeSupportFunc:
8879 case T_JsonConstructorExpr:
8903 case T_CoerceToDomain:
8913 case T_ArrayCoerceExpr:
8916 case T_ConvertRowtypeExpr:
8919 case T_ReturningExpr:
8929 const char *parentOp;
8932 bool is_lopriparent;
8933 bool is_hipriparent;
8940 is_lopriop = (strchr(
"+-", *op) != NULL);
8941 is_hipriop = (strchr(
"*/%", *op) != NULL);
8942 if (!(is_lopriop || is_hipriop))
8949 is_lopriparent = (strchr(
"+-", *parentOp) != NULL);
8950 is_hipriparent = (strchr(
"*/%", *parentOp) != NULL);
8951 if (!(is_lopriparent || is_hipriparent))
8954 if (is_hipriop && is_lopriparent)
8957 if (is_lopriop && is_hipriparent)
8976 case T_DistinctExpr:
8977 case T_JsonIsPredicate:
8992 case T_SubscriptingRef:
8995 case T_CoalesceExpr:
9000 case T_GroupingFunc:
9018 parentType = ((
BoolExpr *) parentNode)->boolop;
9044 case T_SubscriptingRef:
9047 case T_CoalesceExpr:
9052 case T_GroupingFunc:
9061 case T_JsonValueExpr:
9082 int indentBefore,
int indentAfter,
int indentPlus)
9115 indentAmount += indentPlus;
9137 while (
str->len > 0 &&
str->data[
str->len - 1] ==
' ')
9138 str->data[--(
str->len)] =
'\0';
9155 bool showimplicit,
Node *parentNode)
9179 const char *behavior_names[] =
9288 case T_GroupingFunc:
9302 case T_MergeSupportFunc:
9306 case T_SubscriptingRef:
9323 context, showimplicit);
9376 case T_NamedArgExpr:
9389 case T_DistinctExpr:
9416 case T_ScalarArrayOpExpr:
9430 expr->
useOr ?
"ANY" :
"ALL");
9599 case T_AlternativeSubPlan:
9631 const char *fieldname;
9705 relabel->resulttypmod,
9732 case T_ArrayCoerceExpr:
9747 acoerce->resulttypmod,
9753 case T_ConvertRowtypeExpr:
9800 foreach(temp, caseexpr->
args)
9850 case T_CaseTestExpr:
9876 if (arrayexpr->elements ==
NIL)
9895 if (rowexpr->row_typeid != RECORDOID)
9912 if (tupdesc == NULL ||
9922 if (tupdesc != NULL)
9924 while (i < tupdesc->natts)
9944 case T_RowCompareExpr:
9973 case T_CoalesceExpr:
9987 switch (minmaxexpr->
op)
10001 case T_SQLValueFunction:
10065 bool needcomma =
false;
10154 Assert(!con->constisnull);
10157 " PRESERVE WHITESPACE");
10160 " STRIP WHITESPACE");
10177 if (con->constisnull)
10185 ", STANDALONE YES");
10189 ", STANDALONE NO");
10193 ", STANDALONE NO VALUE");
10237 if (ntest->argisrow ||
10249 elog(
ERROR,
"unrecognized nulltesttype: %d",
10264 elog(
ERROR,
"unrecognized nulltesttype: %d",
10273 case T_BooleanTest:
10301 elog(
ERROR,
"unrecognized booltesttype: %d",
10309 case T_CoerceToDomain:
10324 ctest->resulttypmod,
10330 case T_CoerceToDomainValue:
10334 case T_SetToDefault:
10338 case T_CurrentOfExpr:
10351 case T_NextValueExpr:
10367 case T_InferenceElem:
10370 bool save_varprefix;
10388 need_parens =
false;
10414 case T_ReturningExpr:
10428 case T_PartitionBoundSpec:
10480 elog(
ERROR,
"unrecognized partition strategy: %d",
10487 case T_JsonValueExpr:
10496 case T_JsonConstructorExpr:
10500 case T_JsonIsPredicate:
10552 elog(
ERROR,
"unrecognized JsonExpr op: %d",
10566 bool needcomma =
false;
10603 foreach(l, (
List *) node)
10637 if (node &&
IsA(node,
Var))
10716 case T_CoalesceExpr:
10718 case T_SQLValueFunction:
10792 false, (
Node *) expr);
10804 Oid rettype = expr->funcresulttype;
10805 int32 coercedTypmod;
10811 rettype, coercedTypmod,
10834 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
10835 errmsg(
"too many arguments")));
10838 foreach(l, expr->
args)
10850 argnames, argtypes,
10851 expr->funcvariadic,
10855 foreach(l, expr->
args)
10859 if (use_variadic &&
lnext(expr->
args, l) == NULL)
10871 Aggref *original_aggref)
10884 const char *
options,
bool is_json_objectagg)
10889 bool use_variadic =
false;
10921 argtypes, aggref->aggvariadic,
10929 if (AGGKIND_IS_ORDERED_SET(aggref->aggkind))
10936 Assert(!aggref->aggvariadic);
10945 if (aggref->aggstar)
10953 foreach(l, aggref->
args)
10963 if (is_json_objectagg)
10977 if (use_variadic &&
i == nargs)
11011 Aggref *original_aggref = callback_arg;
11014 elog(
ERROR,
"combining Aggref does not point to an Aggref");
11016 aggref = (
Aggref *) node;
11037 bool is_json_objectagg)
11047 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
11048 errmsg(
"too many arguments")));
11051 foreach(l, wfunc->
args)
11063 argtypes,
false, NULL,
11069 if (wfunc->winstar)
11073 if (is_json_objectagg)
11111 elog(
ERROR,
"could not find window clause for winref %u",
11136 elog(
ERROR,
"could not find window clause for winref %u",
11155 case F_TIMEZONE_INTERVAL_TIMESTAMP:
11156 case F_TIMEZONE_INTERVAL_TIMESTAMPTZ:
11157 case F_TIMEZONE_INTERVAL_TIMETZ:
11158 case F_TIMEZONE_TEXT_TIMESTAMP:
11159 case F_TIMEZONE_TEXT_TIMESTAMPTZ:
11160 case F_TIMEZONE_TEXT_TIMETZ:
11171 case F_TIMEZONE_TIMESTAMP:
11172 case F_TIMEZONE_TIMESTAMPTZ:
11173 case F_TIMEZONE_TIMETZ:
11181 case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_INTERVAL:
11182 case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_TIMESTAMPTZ:
11183 case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_INTERVAL:
11184 case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ:
11185 case F_OVERLAPS_TIMESTAMP_INTERVAL_TIMESTAMP_INTERVAL:
11186 case F_OVERLAPS_TIMESTAMP_INTERVAL_TIMESTAMP_TIMESTAMP:
11187 case F_OVERLAPS_TIMESTAMP_TIMESTAMP_TIMESTAMP_INTERVAL:
11188 case F_OVERLAPS_TIMESTAMP_TIMESTAMP_TIMESTAMP_TIMESTAMP:
11189 case F_OVERLAPS_TIMETZ_TIMETZ_TIMETZ_TIMETZ:
11190 case F_OVERLAPS_TIME_INTERVAL_TIME_INTERVAL:
11191 case F_OVERLAPS_TIME_INTERVAL_TIME_TIME:
11192 case F_OVERLAPS_TIME_TIME_TIME_INTERVAL:
11193 case F_OVERLAPS_TIME_TIME_TIME_TIME:
11206 case F_EXTRACT_TEXT_DATE:
11207 case F_EXTRACT_TEXT_TIME:
11208 case F_EXTRACT_TEXT_TIMETZ:
11209 case F_EXTRACT_TEXT_TIMESTAMP:
11210 case F_EXTRACT_TEXT_TIMESTAMPTZ:
11211 case F_EXTRACT_TEXT_INTERVAL:
11219 !con->constisnull);
11227 case F_IS_NORMALIZED:
11239 !con->constisnull);
11246 case F_PG_COLLATION_FOR:
11263 !con->constisnull);
11270 case F_OVERLAY_BIT_BIT_INT4:
11271 case F_OVERLAY_BIT_BIT_INT4_INT4:
11272 case F_OVERLAY_BYTEA_BYTEA_INT4:
11273 case F_OVERLAY_BYTEA_BYTEA_INT4_INT4:
11274 case F_OVERLAY_TEXT_TEXT_INT4:
11275 case F_OVERLAY_TEXT_TEXT_INT4_INT4:
11291 case F_POSITION_BIT_BIT:
11292 case F_POSITION_BYTEA_BYTEA:
11293 case F_POSITION_TEXT_TEXT:
11302 case F_SUBSTRING_BIT_INT4:
11303 case F_SUBSTRING_BIT_INT4_INT4:
11304 case F_SUBSTRING_BYTEA_INT4:
11305 case F_SUBSTRING_BYTEA_INT4_INT4:
11306 case F_SUBSTRING_TEXT_INT4:
11307 case F_SUBSTRING_TEXT_INT4_INT4:
11321 case F_SUBSTRING_TEXT_TEXT_TEXT:
11332 case F_BTRIM_BYTEA_BYTEA:
11334 case F_BTRIM_TEXT_TEXT:
11347 case F_LTRIM_BYTEA_BYTEA:
11349 case F_LTRIM_TEXT_TEXT:
11362 case F_RTRIM_BYTEA_BYTEA:
11364 case F_RTRIM_TEXT_TEXT:
11377 case F_SYSTEM_USER:
11401 Oid resulttype,
int32 resulttypmod,
11422 ((
Const *)
arg)->consttype == resulttype &&
11423 ((
Const *)
arg)->consttypmod == -1)
11470 bool needlabel =
false;
11472 if (constval->constisnull)
11483 constval->consttypmod));
11490 &typoutput, &typIsVarlena);
11507 if (extval[0] !=
'-')
11523 if (isdigit((
unsigned char) extval[0]) &&
11524 strcspn(extval,
"eE.") != strlen(extval))
11536 if (strcmp(extval,
"t") == 0)
11576 needlabel |= (constval->consttypmod >= 0);
11582 if (needlabel || showtype > 0)
11585 constval->consttypmod));
11602 if (constval->constcollid != typcollation)
11633 " FORMAT JSONB" :
" FORMAT JSON");
11652 bool json_format_by_default)
11661 if (!json_format_by_default ||
11676 bool is_json_object;
11691 switch (ctor->
type)
11715 foreach(lc, ctor->
args)
11722 sep = (is_json_object && (curridx % 2) != 0) ?
" : " :
", ";
11768 const char *
funcname,
bool is_json_objectagg)
11782 is_json_objectagg);
11784 elog(
ERROR,
"invalid JsonConstructorExpr underlying node type: %d",
11794 const char *valptr;
11802 for (valptr =
val; *valptr; valptr++)
11823 char *opname = NULL;
11885 elog(
ERROR,
"unrecognized testexpr type: %d",
11898 if (strcmp(opname,
"=") == 0)
11915 need_paren =
false;
11920 elog(
ERROR,
"unrecognized sublink type: %d",
11950 if (tf->ns_uris !=
NIL)
11957 forboth(lc1, tf->ns_uris, lc2, tf->ns_names)
11967 if (ns_node != NULL)
11998 forfive(l1, tf->colnames, l2, tf->coltypes, l3, tf->coltypmods,
11999 l4, tf->
colexprs, l5, tf->coldefexprs)
12006 bool ordinality = (tf->ordinalitycol == colnum);
12014 ordinality ?
"FOR ORDINALITY" :
12019 if (coldefexpr != NULL)
12025 if (colexpr != NULL)
12092 forfour(lc_colname, tf->colnames,
12093 lc_coltype, tf->coltypes,
12094 lc_coltypmod, tf->coltypmods,
12095 lc_colvalexpr, tf->colvalexprs)
12109 if (scan->
colMin < 0 || colnum < scan->colMin)
12114 if (colnum > scan->
colMax)
12117 if (colnum > scan->
colMin)
12122 ordinality = !colexpr;
12127 ordinality ?
"FOR ORDINALITY" :
12146 bool typispreferred;
12150 if (typcategory == TYPCATEGORY_STRING)
12153 " FORMAT JSONB" :
" FORMAT JSON");
12206 bool needcomma =
false;
12291 if (!rte->inFromCl)
12314 context->
buf = &itembuf;
12325 if (itembuf.
len > 0 && itembuf.
data[0] ==
'\n')
12336 trailing_nl = strrchr(
buf->data,
'\n');
12337 if (trailing_nl == NULL)
12338 trailing_nl =
buf->data;
12346 if (strlen(trailing_nl) + itembuf.
len > context->
wrapColumn)
12439 rtfunc->funccolnames !=
NIL)
12441 all_unnest =
false;
12474 if (rtfunc->funccolnames !=
NIL)
12513 if (rtfunc1 && rtfunc1->funccolnames !=
NIL)
12532 bool need_paren_on_right;
12543 switch (
j->jointype)
12576 elog(
ERROR,
"unrecognized join type: %d",
12577 (
int)
j->jointype);
12580 if (need_paren_on_right)
12583 if (need_paren_on_right)
12586 if (
j->usingClause)
12595 char *colname = (
char *)
lfirst(lc);
12605 if (
j->join_using_alias)
12628 if (
j->alias != NULL)
12644 elog(
ERROR,
"unrecognized node type: %d",
12660 bool printalias =
false;
12662 if (rte->alias != NULL)
12709 if (strcmp(refname, rte->
ctename) != 0)
12715 use_as ?
" AS " :
" ",
12779 forfour(l1, rtfunc->funccoltypes,
12780 l2, rtfunc->funccoltypmods,
12781 l3, rtfunc->funccolcollations,
12782 l4, rtfunc->funccolnames)
12827 argtypes[0] = INTERNALOID;
12831 false, NULL,
false));
12834 foreach(l, tablesample->
args)
12870 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
12877 opcname =
NameStr(opcrec->opcname);
12905 return &
buf.data[1];
12938 elog(
ERROR,
"argument type %s of FieldStore is not a tuple type",
12979 node = (
Node *) cdomain->
arg;
12991 if (cdomain && node == (
Node *) cdomain->
arg)
12992 node = (
Node *) cdomain;
13047 for (ptr =
ident; *ptr; ptr++)
13051 if ((ch >=
'a' && ch <=
'z') ||
13052 (ch >=
'0' && ch <=
'9') ||
13087 result = (
char *)
palloc(strlen(
ident) + nquotes + 2 + 1);
13091 for (ptr =
ident; *ptr; ptr++)
13137 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13164 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13170 foreach(nslist, namespaces)
13175 foreach(ctlist, dpns->
ctes)
13222 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13228 elog(
ERROR,
"cache lookup failed for namespace %u",
13229 reltup->relnamespace);
13257 bool has_variadic,
bool *use_variadic_p,
13273 Oid *p_true_typeids;
13274 bool force_qualify =
false;
13278 elog(
ERROR,
"cache lookup failed for function %u", funcid);
13288 if (strcmp(
proname,
"cube") == 0 || strcmp(
proname,
"rollup") == 0)
13289 force_qualify =
true;
13302 if (use_variadic_p)
13306 use_variadic = has_variadic;
13307 *use_variadic_p = use_variadic;
13312 use_variadic =
false;
13322 if (!force_qualify)
13324 NIL, argnames, nargs, argtypes,
13325 !use_variadic,
true,
false,
13327 &p_funcid, &p_rettype,
13328 &p_retset, &p_nvargs, &p_vatype,
13329 &p_true_typeids, NULL);
13339 p_funcid == funcid)
13376 elog(
ERROR,
"cache lookup failed for operator %u", operid);
13378 oprname =
NameStr(operform->oprname);
13385 switch (operform->oprkind)
13396 elog(
ERROR,
"unrecognized oprkind: %d", operform->oprkind);
13401 if (p_result != NULL &&
oprid(p_result) == operid)
13414 if (p_result != NULL)
13441 const char *leftop,
Oid leftoptype,
13443 const char *rightop,
Oid rightoptype)
13452 elog(
ERROR,
"cache lookup failed for operator %u", opoid);
13454 Assert(operform->oprkind ==
'b');
13455 oprname =
NameStr(operform->oprname);
13460 if (leftoptype != operform->oprleft)
13465 if (rightoptype != operform->oprright)
13489 elog(
ERROR,
"cache lookup failed for type %u", typid);
13521 elog(
ERROR,
"cache lookup failed for type %u", typid);
13527 elog(
ERROR,
"cache lookup failed for namespace %u",
13528 typtup->typnamespace);
13556 collname =
NameStr(colltup->collname);
13646 char *result = NULL;
13653 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13656 Anum_pg_class_reloptions, &isnull);
13689 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)
Bitmapset * bms_make_singleton(int x)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
#define TextDatumGetCString(d)
#define SQL_STR_DOUBLE(ch, escape_backslash)
#define OidIsValid(objectId)
const uint8 ScanKeywordCategories[SCANKEYWORDS_NUM_KEYWORDS]
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, int64 nelem, const HASHCTL *info, int flags)
void hash_destroy(HTAB *hashp)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
#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)
Assert(PointerIsAligned(start, uint64))
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
#define HeapTupleIsValid(tuple)
static void * GETSTRUCT(const HeapTupleData *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_tail(const List *oldlist, int nskip)
List * list_delete_first(List *list)
List * list_concat(List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lcons(void *datum, List *list)
void list_free(List *list)
char * get_rel_name(Oid relid)
AttrNumber get_attnum(Oid relid, const char *attname)
Oid get_opclass_input_type(Oid opclass)
bool type_is_rowtype(Oid typid)
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_language_name(Oid langoid, bool missing_ok)
char * get_namespace_name_or_temp(Oid nspid)
char * get_constraint_name(Oid conoid)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
Oid get_rel_tablespace(Oid relid)
Oid get_typ_typrelid(Oid typid)
Oid get_base_element_type(Oid typid)
char * get_namespace_name(Oid nspid)
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
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, int *fgc_flags, 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)
char * get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, VarReturningType returning_type, 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
#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)
#define for_each_from(cell, lst, N)
static void * list_nth(const List *list, int n)
#define foreach_node(type, var, lst)
#define forfour(cell1, list1, cell2, list2, cell3, list3, cell4, list4)
static ListCell * list_head(const List *l)
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
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
@ JSON_BEHAVIOR_EMPTY_ARRAY
@ 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)
List * deparse_context_for_plan_tree(PlannedStmt *pstmt, List *rtable_names)
char * pg_get_statisticsobjdef_string(Oid statextid)
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)
#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 * quote_qualified_identifier(const char *qualifier, const char *ident)
static void get_setop_query(Node *setOp, Query *query, deparse_context *context)
#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)
Datum pg_get_indexdef(PG_FUNCTION_ARGS)
static void get_sublink_expr(SubLink *sublink, deparse_context *context)
static const char * get_name_for_var_field(Var *var, int fieldno, int levelsup, 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)
static void get_parameter(Param *param, deparse_context *context)
static void build_colinfo_names_hash(deparse_columns *colinfo)
Datum pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS)
static void get_delete_query_def(Query *query, deparse_context *context)
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
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 add_to_names_hash(deparse_columns *colinfo, const char *name)
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)
char * pg_get_partkeydef_columns(Oid relid, bool pretty)
static void get_from_clause(Query *query, const char *prefix, deparse_context *context)
List * deparse_context_for(const char *aliasname, Oid relid)
static bool get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
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)
char * pg_get_indexdef_columns(Oid indexrelid, bool pretty)
#define PRETTY_INDENT(context)
static void get_rule_groupingset(GroupingSet *gset, List *targetlist, bool omit_parens, deparse_context *context)
char * pg_get_indexdef_columns_extended(Oid indexrelid, bits16 flags)
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 char * generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes, bool has_variadic, bool *use_variadic_p, bool inGroupBy)
static void expand_colnames_array_to(deparse_columns *colinfo, int n)
static void get_returning_clause(Query *query, deparse_context *context)
List * set_deparse_context_plan(List *dpcontext, Plan *plan, List *ancestors)
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_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)
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 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)
static void get_window_frame_options(int frameOptions, Node *startOffset, Node *endOffset, deparse_context *context)
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_target_list(List *targetList, deparse_context *context)
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)
char * pg_get_indexdef_string(Oid indexrelid)
static void get_insert_query_def(Query *query, deparse_context *context)
char * pg_get_querydef(Query *query, bool pretty)
static void print_function_sqlbody(StringInfo buf, HeapTuple proctup)
static bool has_dangerous_join_using(deparse_namespace *dpns, Node *jtnode)
const char * quote_identifier(const char *ident)
static Node * get_rule_sortgroupclause(Index ref, List *tlist, bool force_colno, deparse_context *context)
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
#define WRAP_COLUMN_DEFAULT
static char * flatten_reloptions(Oid relid)
static text * pg_get_expr_worker(text *expr, Oid relid, int prettyFlags)
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)
List * select_rtable_names_for_explain(List *rtable, Bitmapset *rels_used)
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)
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)
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)
char * generate_collation_name(Oid collid)
char * pg_get_constraintdef_command(Oid constraintId)
char * pg_get_partconstrdef_string(Oid partitionId, char *aliasname)
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)
char * get_window_frame_options_for_explain(int frameOptions, Node *startOffset, Node *endOffset, List *dpcontext, bool forceprefix)
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)
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)
char * deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit)
void generate_operator_clause(StringInfo buf, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
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)
static void print_function_rettype(StringInfo buf, HeapTuple proctup)
char * generate_opclass_name(Oid opclass)
static void set_deparse_plan(deparse_namespace *dpns, Plan *plan)
static void get_merge_query_def(Query *query, deparse_context *context)
static void resolve_special_varno(Node *node, deparse_context *context, rsv_callback callback, void *callback_arg)
static void get_json_format(JsonFormat *format, StringInfo buf)
char * get_range_partbound_string(List *bound_datums)
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 RangeTblEntry * get_simple_values_rte(Query *query, TupleDesc resultDesc)
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_update_query_def(Query *query, deparse_context *context)
static void get_json_constructor_options(JsonConstructorExpr *ctor, StringInfo buf)
static void get_basic_select_query(Query *query, deparse_context *context)
static bool isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
static void get_with_clause(Query *query, deparse_context *context)
static void destroy_colinfo_names_hash(deparse_columns *colinfo)
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_select_query_def(Query *query, deparse_context *context)
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
bool standard_conforming_strings
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)
void check_stack_depth(void)
#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
VarReturningType varreturningtype
Bitmapset * appendparents
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)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
String * makeString(char *str)
Node * flatten_group_exprs(PlannerInfo *root, Query *query, Node *node)
Relids pull_varnos(PlannerInfo *root, Node *node)
static char * VARDATA_ANY(const void *PTR)
text * cstring_to_text_with_len(const char *s, int len)
bool SplitGUCList(char *rawstring, char separator, List **namelist)
text * cstring_to_text(const char *s)
char * text_to_cstring(const text *t)
List * textToQualifiedNameList(text *textval)
char * map_xml_name_to_sql_identifier(const char *name)
@ XML_STANDALONE_NO_VALUE
static void convert(const int32 val, char *const buf)