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);
1664 bool ndistinct_enabled;
1665 bool dependencies_enabled;
1680 elog(
ERROR,
"cache lookup failed for statistics object %u", statextid);
1684 has_exprs = !
heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
1699 Anum_pg_statistic_ext_stxexprs);
1708 ncolumns = statextrec->stxkeys.dim1 +
list_length(exprs);
1717 NameStr(statextrec->stxname)));
1724 Anum_pg_statistic_ext_stxkind);
1729 elog(
ERROR,
"stxkind is not a 1-D char array");
1732 ndistinct_enabled =
false;
1733 dependencies_enabled =
false;
1734 mcv_enabled =
false;
1738 if (enabled[
i] == STATS_EXT_NDISTINCT)
1739 ndistinct_enabled =
true;
1740 else if (enabled[
i] == STATS_EXT_DEPENDENCIES)
1741 dependencies_enabled =
true;
1742 else if (enabled[
i] == STATS_EXT_MCV)
1759 if ((!ndistinct_enabled || !dependencies_enabled || !mcv_enabled) &&
1762 bool gotone =
false;
1766 if (ndistinct_enabled)
1772 if (dependencies_enabled)
1788 for (colno = 0; colno < statextrec->stxkeys.dim1; colno++)
1802 statextrec->stxrelid);
1857 has_exprs = !
heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
1872 Anum_pg_statistic_ext_stxexprs);
1878 statextrec->stxrelid);
1938 bool attrsOnly,
bool missing_ok)
1958 elog(
ERROR,
"cache lookup failed for partition key of %u", relid);
1963 Assert(form->partrelid == relid);
1967 Anum_pg_partitioned_table_partclass);
1971 Anum_pg_partitioned_table_partcollation);
1980 if (!
heap_attisnull(tuple, Anum_pg_partitioned_table_partexprs, NULL))
1986 Anum_pg_partitioned_table_partexprs);
1991 elog(
ERROR,
"unexpected node type found in partexprs: %d",
2004 switch (form->partstrat)
2019 elog(
ERROR,
"unexpected partition strategy: %d",
2020 (
int) form->partstrat);
2026 for (keyno = 0; keyno < form->partnatts; keyno++)
2030 Oid keycolcollation;
2044 &keycoltype, &keycoltypmod,
2052 if (partexpr_item == NULL)
2053 elog(
ERROR,
"too few entries in partexprs list");
2055 partexpr_item =
lnext(partexprs, partexpr_item);
2071 partcoll = partcollation->
values[keyno];
2072 if (!attrsOnly &&
OidIsValid(partcoll) && partcoll != keycolcollation)
2107 if (constr_expr == NULL)
2116 false, prettyFlags, 0);
2194 int prettyFlags,
bool missing_ok)
2205 Anum_pg_constraint_oid,
2210 ConstraintOidIndexId,
2232 elog(
ERROR,
"could not find tuple for constraint %u", constraintId);
2264 switch (conForm->contype)
2266 case CONSTRAINT_FOREIGN:
2277 Anum_pg_constraint_conkey);
2289 Anum_pg_constraint_confkey);
2296 switch (conForm->confmatchtype)
2299 string =
" MATCH FULL";
2302 string =
" MATCH PARTIAL";
2308 elog(
ERROR,
"unrecognized confmatchtype: %d",
2309 conForm->confmatchtype);
2316 switch (conForm->confupdtype)
2322 string =
"RESTRICT";
2328 string =
"SET NULL";
2331 string =
"SET DEFAULT";
2334 elog(
ERROR,
"unrecognized confupdtype: %d",
2335 conForm->confupdtype);
2342 switch (conForm->confdeltype)
2348 string =
"RESTRICT";
2354 string =
"SET NULL";
2357 string =
"SET DEFAULT";
2360 elog(
ERROR,
"unrecognized confdeltype: %d",
2361 conForm->confdeltype);
2373 Anum_pg_constraint_confdelsetcols, &isnull);
2383 case CONSTRAINT_PRIMARY:
2384 case CONSTRAINT_UNIQUE:
2392 if (conForm->contype == CONSTRAINT_PRIMARY)
2397 indexId = conForm->conindid;
2401 elog(
ERROR,
"cache lookup failed for index %u", indexId);
2402 if (conForm->contype == CONSTRAINT_UNIQUE &&
2410 Anum_pg_constraint_conkey);
2413 if (conForm->conperiod)
2420 Anum_pg_index_indnatts);
2431 Anum_pg_index_indkey);
2434 &keys, NULL, &nKeys);
2436 for (
j = keyatts;
j < nKeys;
j++)
2477 case CONSTRAINT_CHECK:
2487 Anum_pg_constraint_conbin);
2522 conForm->connoinherit ?
" NO INHERIT" :
"");
2525 case CONSTRAINT_NOTNULL:
2527 if (conForm->conrelid)
2539 else if (conForm->contypid)
2547 case CONSTRAINT_TRIGGER:
2557 case CONSTRAINT_EXCLUSION:
2559 Oid indexOid = conForm->conindid;
2568 Anum_pg_constraint_conexclop);
2571 &elems, NULL, &nElems);
2574 for (
i = 0;
i < nElems;
i++)
2592 elog(
ERROR,
"invalid constraint type \"%c\"", conForm->contype);
2596 if (conForm->condeferrable)
2598 if (conForm->condeferred)
2602 if (!conForm->conenforced)
2604 else if (!conForm->convalidated)
2630 &keys, NULL, &nKeys);
2632 for (
j = 0;
j < nKeys;
j++)
2642 (withPeriod &&
j == nKeys - 1) ?
"PERIOD " :
"",
2739 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2740 errmsg(
"input is a query, not an expression")));
2751 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2752 errmsg(
"expression contains variables of more than one relation")));
2758 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2759 errmsg(
"expression contains variables")));
2815 *result = role_rec->rolname;
2857 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2858 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
2865 Anum_pg_depend_refclassid,
2869 Anum_pg_depend_refobjid,
2873 Anum_pg_depend_refobjsubid,
2889 if (deprec->classid == RelationRelationId &&
2890 deprec->objsubid == 0 &&
2895 sequenceId = deprec->objid;
2953 if (proc->prokind == PROKIND_AGGREGATE)
2955 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2956 errmsg(
"\"%s\" is an aggregate function",
name)));
2958 isfunction = (proc->prokind != PROKIND_PROCEDURE);
2966 isfunction ?
"FUNCTION" :
"PROCEDURE",
2985 if (proc->prokind == PROKIND_WINDOW)
2987 switch (proc->provolatile)
2989 case PROVOLATILE_IMMUTABLE:
2992 case PROVOLATILE_STABLE:
2995 case PROVOLATILE_VOLATILE:
2999 switch (proc->proparallel)
3001 case PROPARALLEL_SAFE:
3004 case PROPARALLEL_RESTRICTED:
3007 case PROPARALLEL_UNSAFE:
3011 if (proc->proisstrict)
3013 if (proc->prosecdef)
3015 if (proc->proleakproof)
3019 if (proc->prolang == INTERNALlanguageId ||
3020 proc->prolang == ClanguageId)
3024 if (proc->procost != procost)
3027 if (proc->prorows > 0 && proc->prorows != 1000)
3030 if (proc->prosupport)
3038 argtypes[0] = INTERNALOID;
3042 false, NULL,
false));
3045 if (oldlen !=
buf.len)
3049 tmp =
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_proconfig, &isnull);
3074 pos = strchr(configitem,
'=');
3107 elog(
ERROR,
"invalid list syntax in proconfig item");
3109 foreach(lc, namelist)
3111 char *curname = (
char *)
lfirst(lc);
3114 if (
lnext(namelist, lc))
3126 (void)
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
3127 if (proc->prolang == SQLlanguageId && !isnull)
3135 tmp =
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_probin, &isnull);
3156 while (strstr(prosrc, dq.
data) != NULL)
3268 if (proc->proretset)
3282 if (proc->proretset)
3299 bool print_table_args,
bool print_defaults)
3306 int insertorderbyat = -1;
3315 &argtypes, &argnames, &argmodes);
3317 nlackdefaults = numargs;
3318 if (print_defaults && proc->pronargdefaults > 0)
3320 Datum proargdefaults;
3324 Anum_pg_proc_proargdefaults,
3333 nextargdefault =
list_head(argdefaults);
3335 nlackdefaults = proc->pronargs -
list_length(argdefaults);
3340 if (proc->prokind == PROKIND_AGGREGATE)
3347 elog(
ERROR,
"cache lookup failed for aggregate %u",
3350 if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
3351 insertorderbyat = agg->aggnumdirectargs;
3357 for (
i = 0;
i < numargs;
i++)
3359 Oid argtype = argtypes[
i];
3360 char *argname = argnames ? argnames[
i] : NULL;
3361 char argmode = argmodes ? argmodes[
i] : PROARGMODE_IN;
3362 const char *modename;
3373 if (proc->prokind == PROKIND_PROCEDURE)
3379 case PROARGMODE_INOUT:
3380 modename =
"INOUT ";
3383 case PROARGMODE_OUT:
3387 case PROARGMODE_VARIADIC:
3388 modename =
"VARIADIC ";
3391 case PROARGMODE_TABLE:
3396 elog(
ERROR,
"invalid parameter mode '%c'", argmode);
3404 if (print_table_args != (argmode == PROARGMODE_TABLE))
3407 if (argsprinted == insertorderbyat)
3413 else if (argsprinted)
3417 if (argname && argname[0])
3420 if (print_defaults && isinput && inputargno > nlackdefaults)
3424 Assert(nextargdefault != NULL);
3426 nextargdefault =
lnext(argdefaults, nextargdefault);
3434 if (argsprinted == insertorderbyat &&
i == numargs - 1)
3438 print_defaults =
false;
3449 || argmodes[nth] == PROARGMODE_IN
3450 || argmodes[nth] == PROARGMODE_INOUT
3451 || argmodes[nth] == PROARGMODE_VARIADIC);
3469 for (
i = 0;
i < ntypes;
i++)
3501 Datum proargdefaults;
3510 if (nth_arg < 1 || nth_arg > numargs || !
is_input_argument(nth_arg - 1, argmodes))
3517 for (
i = 0;
i < nth_arg;
i++)
3522 Anum_pg_proc_proargdefaults,
3540 nth_default = nth_inputarg - 1 - (proc->pronargs - proc->pronargdefaults);
3542 if (nth_default < 0 || nth_default >=
list_length(argdefaults))
3547 node =
list_nth(argdefaults, nth_default);
3568 &argtypes, &argnames, &argmodes);
3624 (void)
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
3646 bool forceprefix,
bool showimplicit)
3649 showimplicit, 0, 0);
3673 bool forceprefix,
bool showimplicit,
3674 int prettyFlags,
int startIndent)
3719 rte->relkind = RELKIND_RELATION;
3722 rte->eref = rte->alias;
3723 rte->lateral =
false;
3725 rte->inFromCl =
true;
3777 Assert(crelid > 0 && crelid <= ntables);
3859 memset(&dpns, 0,
sizeof(dpns));
3906 names_hash =
hash_create(
"set_rtable_names names",
3912 foreach(lc, parent_namespaces)
3919 char *oldname = (
char *)
lfirst(lc2);
3921 if (oldname == NULL)
3934 foreach(lc, dpns->
rtable)
3947 else if (rte->alias)
3950 refname = rte->alias->aliasname;
3965 refname = rte->eref->aliasname;
3983 int refnamelen = strlen(refname);
3984 char *modname = (
char *)
palloc(refnamelen + 16);
3992 memcpy(modname, refname, refnamelen);
4030 List *parent_namespaces)
4162 if (
j->alias == NULL &&
j->usingClause)
4172 for (
int i = 0;
i < jrte->joinmergedcols;
i++)
4188 elog(
ERROR,
"unrecognized node type: %d",
4250 if (rte->alias == NULL)
4256 if (colname == NULL)
4260 if (leftattnos[
i] > 0)
4263 leftcolinfo->
colnames[leftattnos[
i] - 1] = colname;
4267 if (rightattnos[
i] > 0)
4270 rightcolinfo->
colnames[rightattnos[
i] - 1] = colname;
4308 foreach(lc,
j->usingClause)
4313 Assert(leftattnos[
i] != 0 && rightattnos[
i] != 0);
4321 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4334 parentUsing =
lappend(parentUsing, colname);
4337 if (leftattnos[
i] > 0)
4340 leftcolinfo->
colnames[leftattnos[
i] - 1] = colname;
4344 if (rightattnos[
i] > 0)
4347 rightcolinfo->
colnames[rightattnos[
i] - 1] = colname;
4363 elog(
ERROR,
"unrecognized node type: %d",
4379 char **real_colnames;
4399 ncolumns = tupdesc->
natts;
4400 real_colnames = (
char **)
palloc(ncolumns *
sizeof(
char *));
4402 for (
i = 0;
i < ncolumns;
i++)
4406 if (attr->attisdropped)
4407 real_colnames[
i] = NULL;
4438 true , &colnames, NULL);
4441 colnames = rte->eref->colnames;
4444 real_colnames = (
char **)
palloc(ncolumns *
sizeof(
char *));
4447 foreach(lc, colnames)
4455 if (
cname[0] ==
'\0')
4457 real_colnames[
i] =
cname;
4494 changed_any =
false;
4496 for (
i = 0;
i < ncolumns;
i++)
4498 char *real_colname = real_colnames[
i];
4502 if (real_colname == NULL)
4509 if (colname == NULL)
4512 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4515 colname = real_colname;
4531 if (!changed_any && strcmp(colname, real_colname) != 0)
4562 else if (rte->alias && rte->alias->colnames !=
NIL)
4617 changed_any =
false;
4638 if (real_colname == NULL)
4645 if (rte->alias == NULL)
4653 if (colname == NULL)
4656 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4659 colname = real_colname;
4669 if (!changed_any && strcmp(colname, real_colname) != 0)
4704 while (
i < noldcolumns &&
4730 while (ic < leftcolinfo->num_cols &&
4733 Assert(ic < leftcolinfo->num_cols);
4739 while (i < colinfo->num_cols &&
4742 Assert(i < colinfo->num_cols);
4754 if (rte->alias != NULL)
4780 while (ic < rightcolinfo->num_cols &&
4781 rightcolinfo->
colnames[ic] == NULL)
4783 Assert(ic < rightcolinfo->num_cols);
4789 while (i < colinfo->num_cols &&
4792 Assert(i < colinfo->num_cols);
4804 if (rte->alias != NULL)
4822#ifdef USE_ASSERT_CHECKING
4823 while (i < colinfo->num_cols && colinfo->
colnames[
i] == NULL)
4836 if (rte->alias != NULL)
4873 if (oldname && strcmp(oldname, colname) == 0)
4885 if (oldname && strcmp(oldname, colname) == 0)
4895 char *oldname = (
char *)
lfirst(lc);
4897 if (strcmp(oldname, colname) == 0)
4908 char *oldname = (
char *)
lfirst(lc);
4910 if (strcmp(oldname, colname) == 0)
4933 int colnamelen = strlen(colname);
4934 char *modname = (
char *)
palloc(colnamelen + 16);
4942 memcpy(modname, colname, colnamelen);
4943 sprintf(modname + colnamelen,
"_%d",
i);
5026 char *oldname = (
char *)
lfirst(lc);
5079 elog(
ERROR,
"unrecognized node type in jointree: %d",
5086 elog(
ERROR,
"unrecognized node type in jointree: %d",
5107 foreach(lc, jrte->joinleftcols)
5114 foreach(lc, jrte->joinrightcols)
5118 if (rcolno < jrte->joinmergedcols)
5124 Assert(jcolno == numjoincols);
5245 elog(
ERROR,
"could not find RecursiveUnion for WorkTableScan with wtParam %d",
5392 Assert(ev_action != NULL);
5395 elog(
ERROR,
"invalid empty ev_action list");
5432 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5433 errmsg(
"rule \"%s\" has unsupported event type %d",
5434 rulename, ev_type)));
5445 if (strcmp(ev_qual,
"<>") != 0)
5540 int prettyFlags,
int wrapColumn)
5578 Assert(ev_action != NULL);
5589 if (ev_type !=
'1' || !is_instead ||
5599 prettyFlags, wrapColumn, 0);
5625 TupleDesc resultDesc,
bool colNamesVisible,
5626 int prettyFlags,
int wrapColumn,
int startIndent)
5636 rtable_size = query->hasGroupRTE ?
5644 if (query->hasGroupRTE)
5713 elog(
ERROR,
"unrecognized query command type: %d",
5727 bool first_list =
true;
5732 foreach(vtl, values_lists)
5735 bool first_col =
true;
5744 foreach(lc, sublist)
5782 if (query->hasRecursive)
5783 sep =
"WITH RECURSIVE ";
5792 if (cte->aliascolnames)
5798 foreach(col, cte->aliascolnames)
5832 if (cte->search_clause)
5838 cte->search_clause->search_breadth_first ?
"BREADTH" :
"DEPTH");
5840 foreach(lc, cte->search_clause->search_col_list)
5853 if (cte->cycle_clause)
5860 foreach(lc, cte->cycle_clause->cycle_col_list)
5880 get_rule_expr(cte->cycle_clause->cycle_mark_value, context,
false);
5882 get_rule_expr(cte->cycle_clause->cycle_mark_default, context,
false);
5933 force_colno =
false;
5942 force_colno, context);
5977 if (query->hasForUpdate)
5991 elog(
ERROR,
"unrecognized LockClauseStrength %d",
6039 foreach(lc, query->
rtable)
6083 if (resultDesc && colno <= resultDesc->natts)
6086 colname = tle->resname;
6089 if (colname == NULL || strcmp(colname,
cname) != 0)
6126 if (query->isReturn)
6134 if (query->hasDistinctOn)
6170 bool save_ingroupby;
6233 bool last_was_multiline =
false;
6243 foreach(l, targetList)
6261 context->
buf = &targetbuf;
6297 colno - 1)->attname);
6299 colname = tle->resname;
6317 if (targetbuf.
len > 0 && targetbuf.
data[0] ==
'\n')
6320 leading_nl_pos = -1;
6323 if (leading_nl_pos >= 0)
6333 trailing_nl = strrchr(
buf->data,
'\n');
6334 if (trailing_nl == NULL)
6335 trailing_nl =
buf->data;
6345 ((strlen(trailing_nl) + targetbuf.
len > context->
wrapColumn) ||
6346 last_was_multiline))
6352 last_was_multiline =
6353 (strchr(targetbuf.
data + leading_nl_pos + 1,
'\n') != NULL);
6371 bool have_with =
false;
6377 if (query->returningOldAlias && strcmp(query->returningOldAlias,
"old") != 0)
6383 if (query->returningNewAlias && strcmp(query->returningNewAlias,
"new") != 0)
6419 Assert(subquery != NULL);
6427 need_paren = (subquery->
cteList ||
6446 bool save_colnamesvisible;
6541 elog(
ERROR,
"unrecognized node type: %d",
6626 bool omit_child_parens =
true;
6663 omit_child_parens =
false;
6689 foreach(l, orderList)
6698 force_colno, context);
6750 if (wc->name == NULL)
6775 bool needspace =
false;
6829 Node *startOffset,
Node *endOffset,
6889 buf->data[--(
buf->len)] =
'\0';
6898 Node *startOffset,
Node *endOffset,
6899 List *dpcontext,
bool forceprefix)
6937 List *strippedexprs;
6946 foreach(l, query->
rtable)
6953 elog(
ERROR,
"too many subquery RTEs in INSERT");
6960 elog(
ERROR,
"too many values RTEs in INSERT");
6964 if (select_rte && values_rte)
6965 elog(
ERROR,
"both subquery and values RTEs in INSERT");
6991 strippedexprs =
NIL;
7022 strippedexprs =
lappend(strippedexprs,
7029 if (query->override)
7045 else if (values_rte)
7050 else if (strippedexprs)
7081 bool save_varprefix;
7103 elog(
ERROR,
"cache lookup failed for constraint %u",
7199 int remaining_ma_columns;
7210 if (query->hasSubLinks)
7212 foreach(l, targetList)
7222 ma_sublinks =
lappend(ma_sublinks, sl);
7229 cur_ma_sublink = NULL;
7230 remaining_ma_columns = 0;
7234 foreach(l, targetList)
7250 if (next_ma_cell != NULL && cur_ma_sublink == NULL)
7296 next_ma_cell =
lnext(ma_sublinks, next_ma_cell);
7299 ((cur_ma_sublink->
subLinkId << 16) | 1));
7324 if (cur_ma_sublink != NULL)
7326 if (--remaining_ma_columns > 0)
7329 expr = (
Node *) cur_ma_sublink;
7330 cur_ma_sublink = NULL;
7397 bool haveNotMatchedBySource;
7432 haveNotMatchedBySource =
false;
7439 haveNotMatchedBySource =
true;
7451 switch (
action->matchKind)
7460 if (haveNotMatchedBySource)
7466 elog(
ERROR,
"unrecognized matchKind: %d",
7467 (
int)
action->matchKind);
7483 const char *sep =
"";
7490 foreach(lc2,
action->targetList)
7503 strippedexprs =
lappend(strippedexprs,
7572 elog(
ERROR,
"unexpected utility statement type");
7613 elog(
ERROR,
"bogus varlevelsup: %d offset %d",
7626 if (var->varnosyn > 0 && dpns->
plan == NULL)
7628 varno = var->varnosyn;
7629 varattno = var->varattnosyn;
7665 pvarattno = appinfo->parent_colnos[pvarattno - 1];
7685 varattno = pvarattno;
7729 elog(
ERROR,
"invalid attnum %d for relation \"%s\"",
7730 attnum, rte->eref->aliasname);
7732 Assert(netlevelsup == 0);
7763 if (rte->joinaliasvars ==
NIL)
7764 elog(
ERROR,
"cannot decompile join alias var in plan tree");
7771 if (aliasvar &&
IsA(aliasvar,
Var))
7774 istoplevel, context);
7792 elog(
ERROR,
"invalid attnum %d for relation \"%s\"",
7793 attnum, rte->eref->aliasname);
7838 colno - 1)->attname);
7840 colname = tle->resname;
7842 if (colname && strcmp(colname,
attname) == 0 &&
7843 !
equal(var, tle->expr))
7851 if (refname && need_prefix)
7911 (*callback) (node, context, callback_arg);
7986 (*callback) (node, context, callback_arg);
8028 if (fieldno > 0 && fieldno <=
list_length(r->colnames))
8060 var->vartype != RECORDOID)
8064 Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
8071 elog(
ERROR,
"bogus varlevelsup: %d offset %d",
8081 if (var->varnosyn > 0 && dpns->
plan == NULL)
8083 varno = var->varnosyn;
8084 varattno = var->varattnosyn;
8114 elog(
ERROR,
"bogus varattno for OUTER_VAR var: %d", varattno);
8116 Assert(netlevelsup == 0);
8133 elog(
ERROR,
"bogus varattno for INNER_VAR var: %d", varattno);
8135 Assert(netlevelsup == 0);
8151 elog(
ERROR,
"bogus varattno for INDEX_VAR var: %d", varattno);
8153 Assert(netlevelsup == 0);
8179 expr = (
Node *) var;
8202 if (ste == NULL || ste->resjunk)
8203 elog(
ERROR,
"subquery %s does not have attribute %d",
8204 rte->eref->aliasname,
attnum);
8218 List *parent_namespaces;
8261 char *dummy_name =
palloc(32);
8264 snprintf(dummy_name, 32,
"f%d", fieldno);
8271 elog(
ERROR,
"bogus varattno for subquery var: %d",
8273 Assert(netlevelsup == 0);
8286 if (rte->joinaliasvars ==
NIL)
8287 elog(
ERROR,
"cannot decompile join alias var in plan tree");
8325 foreach(lc, ctedpns->
ctes)
8338 if (ste == NULL || ste->resjunk)
8339 elog(
ERROR,
"CTE %s does not have attribute %d",
8340 rte->eref->aliasname,
attnum);
8341 expr = (
Node *) ste->expr;
8352 List *parent_namespaces;
8392 char *dummy_name =
palloc(32);
8395 snprintf(dummy_name, 32,
"f%d", fieldno);
8403 elog(
ERROR,
"bogus varattno for subquery var: %d",
8405 Assert(netlevelsup == 0);
8432 Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
8450 *ancestor_cell_p = NULL;
8464 child_plan = dpns->
plan;
8487 *ancestor_cell_p = lc;
8507 if (paramid == param->
paramid)
8525 *ancestor_cell_p = rest;
8529 elog(
ERROR,
"SubPlan cannot be outermost ancestor");
8543 child_plan = (
Plan *) ancestor;
8599 if (paramid == param->
paramid)
8624 if (paramid == param->
paramid)
8662 if (paramid == param->
paramid)
8695 bool save_varprefix;
8713 need_paren = !(
IsA(expr,
Var) ||
8765 bool should_qualify =
false;
8780 should_qualify =
true;
8826 if (strlen(op) == 1)
8850 case T_CoerceToDomainValue:
8851 case T_SetToDefault:
8852 case T_CurrentOfExpr:
8856 case T_SubscriptingRef:
8859 case T_CoalesceExpr:
8861 case T_SQLValueFunction:
8863 case T_NextValueExpr:
8866 case T_GroupingFunc:
8868 case T_MergeSupportFunc:
8870 case T_JsonConstructorExpr:
8894 case T_CoerceToDomain:
8904 case T_ArrayCoerceExpr:
8907 case T_ConvertRowtypeExpr:
8910 case T_ReturningExpr:
8920 const char *parentOp;
8923 bool is_lopriparent;
8924 bool is_hipriparent;
8931 is_lopriop = (strchr(
"+-", *op) != NULL);
8932 is_hipriop = (strchr(
"*/%", *op) != NULL);
8933 if (!(is_lopriop || is_hipriop))
8940 is_lopriparent = (strchr(
"+-", *parentOp) != NULL);
8941 is_hipriparent = (strchr(
"*/%", *parentOp) != NULL);
8942 if (!(is_lopriparent || is_hipriparent))
8945 if (is_hipriop && is_lopriparent)
8948 if (is_lopriop && is_hipriparent)
8967 case T_DistinctExpr:
8968 case T_JsonIsPredicate:
8983 case T_SubscriptingRef:
8986 case T_CoalesceExpr:
8991 case T_GroupingFunc:
9009 parentType = ((
BoolExpr *) parentNode)->boolop;
9035 case T_SubscriptingRef:
9038 case T_CoalesceExpr:
9043 case T_GroupingFunc:
9052 case T_JsonValueExpr:
9073 int indentBefore,
int indentAfter,
int indentPlus)
9106 indentAmount += indentPlus;
9128 while (
str->len > 0 &&
str->data[
str->len - 1] ==
' ')
9129 str->data[--(
str->len)] =
'\0';
9146 bool showimplicit,
Node *parentNode)
9170 const char *behavior_names[] =
9279 case T_GroupingFunc:
9293 case T_MergeSupportFunc:
9297 case T_SubscriptingRef:
9314 context, showimplicit);
9367 case T_NamedArgExpr:
9380 case T_DistinctExpr:
9407 case T_ScalarArrayOpExpr:
9421 expr->
useOr ?
"ANY" :
"ALL");
9590 case T_AlternativeSubPlan:
9606 if (
splan->useHashTable)
9622 const char *fieldname;
9696 relabel->resulttypmod,
9723 case T_ArrayCoerceExpr:
9738 acoerce->resulttypmod,
9744 case T_ConvertRowtypeExpr:
9791 foreach(temp, caseexpr->
args)
9841 case T_CaseTestExpr:
9867 if (arrayexpr->elements ==
NIL)
9886 if (rowexpr->row_typeid != RECORDOID)
9903 if (tupdesc == NULL ||
9913 if (tupdesc != NULL)
9915 while (i < tupdesc->natts)
9935 case T_RowCompareExpr:
9964 case T_CoalesceExpr:
9978 switch (minmaxexpr->
op)
9992 case T_SQLValueFunction:
10056 bool needcomma =
false;
10145 Assert(!con->constisnull);
10148 " PRESERVE WHITESPACE");
10151 " STRIP WHITESPACE");
10168 if (con->constisnull)
10176 ", STANDALONE YES");
10180 ", STANDALONE NO");
10184 ", STANDALONE NO VALUE");
10228 if (ntest->argisrow ||
10240 elog(
ERROR,
"unrecognized nulltesttype: %d",
10255 elog(
ERROR,
"unrecognized nulltesttype: %d",
10264 case T_BooleanTest:
10292 elog(
ERROR,
"unrecognized booltesttype: %d",
10300 case T_CoerceToDomain:
10315 ctest->resulttypmod,
10321 case T_CoerceToDomainValue:
10325 case T_SetToDefault:
10329 case T_CurrentOfExpr:
10342 case T_NextValueExpr:
10358 case T_InferenceElem:
10361 bool save_varprefix;
10379 need_parens =
false;
10405 case T_ReturningExpr:
10419 case T_PartitionBoundSpec:
10471 elog(
ERROR,
"unrecognized partition strategy: %d",
10478 case T_JsonValueExpr:
10487 case T_JsonConstructorExpr:
10491 case T_JsonIsPredicate:
10543 elog(
ERROR,
"unrecognized JsonExpr op: %d",
10557 bool needcomma =
false;
10594 foreach(l, (
List *) node)
10628 if (node &&
IsA(node,
Var))
10707 case T_CoalesceExpr:
10709 case T_SQLValueFunction:
10783 false, (
Node *) expr);
10795 Oid rettype = expr->funcresulttype;
10796 int32 coercedTypmod;
10802 rettype, coercedTypmod,
10825 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
10826 errmsg(
"too many arguments")));
10829 foreach(l, expr->
args)
10841 argnames, argtypes,
10842 expr->funcvariadic,
10846 foreach(l, expr->
args)
10850 if (use_variadic &&
lnext(expr->
args, l) == NULL)
10862 Aggref *original_aggref)
10875 const char *
options,
bool is_json_objectagg)
10880 bool use_variadic =
false;
10912 argtypes, aggref->aggvariadic,
10920 if (AGGKIND_IS_ORDERED_SET(aggref->aggkind))
10927 Assert(!aggref->aggvariadic);
10936 if (aggref->aggstar)
10944 foreach(l, aggref->
args)
10954 if (is_json_objectagg)
10968 if (use_variadic &&
i == nargs)
11002 Aggref *original_aggref = callback_arg;
11005 elog(
ERROR,
"combining Aggref does not point to an Aggref");
11007 aggref = (
Aggref *) node;
11028 bool is_json_objectagg)
11038 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
11039 errmsg(
"too many arguments")));
11042 foreach(l, wfunc->
args)
11054 argtypes,
false, NULL,
11060 if (wfunc->winstar)
11064 if (is_json_objectagg)
11102 elog(
ERROR,
"could not find window clause for winref %u",
11127 elog(
ERROR,
"could not find window clause for winref %u",
11146 case F_TIMEZONE_INTERVAL_TIMESTAMP:
11147 case F_TIMEZONE_INTERVAL_TIMESTAMPTZ:
11148 case F_TIMEZONE_INTERVAL_TIMETZ:
11149 case F_TIMEZONE_TEXT_TIMESTAMP:
11150 case F_TIMEZONE_TEXT_TIMESTAMPTZ:
11151 case F_TIMEZONE_TEXT_TIMETZ:
11162 case F_TIMEZONE_TIMESTAMP:
11163 case F_TIMEZONE_TIMESTAMPTZ:
11164 case F_TIMEZONE_TIMETZ:
11172 case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_INTERVAL:
11173 case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_TIMESTAMPTZ:
11174 case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_INTERVAL:
11175 case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ:
11176 case F_OVERLAPS_TIMESTAMP_INTERVAL_TIMESTAMP_INTERVAL:
11177 case F_OVERLAPS_TIMESTAMP_INTERVAL_TIMESTAMP_TIMESTAMP:
11178 case F_OVERLAPS_TIMESTAMP_TIMESTAMP_TIMESTAMP_INTERVAL:
11179 case F_OVERLAPS_TIMESTAMP_TIMESTAMP_TIMESTAMP_TIMESTAMP:
11180 case F_OVERLAPS_TIMETZ_TIMETZ_TIMETZ_TIMETZ:
11181 case F_OVERLAPS_TIME_INTERVAL_TIME_INTERVAL:
11182 case F_OVERLAPS_TIME_INTERVAL_TIME_TIME:
11183 case F_OVERLAPS_TIME_TIME_TIME_INTERVAL:
11184 case F_OVERLAPS_TIME_TIME_TIME_TIME:
11197 case F_EXTRACT_TEXT_DATE:
11198 case F_EXTRACT_TEXT_TIME:
11199 case F_EXTRACT_TEXT_TIMETZ:
11200 case F_EXTRACT_TEXT_TIMESTAMP:
11201 case F_EXTRACT_TEXT_TIMESTAMPTZ:
11202 case F_EXTRACT_TEXT_INTERVAL:
11210 !con->constisnull);
11218 case F_IS_NORMALIZED:
11230 !con->constisnull);
11237 case F_PG_COLLATION_FOR:
11254 !con->constisnull);
11261 case F_OVERLAY_BIT_BIT_INT4:
11262 case F_OVERLAY_BIT_BIT_INT4_INT4:
11263 case F_OVERLAY_BYTEA_BYTEA_INT4:
11264 case F_OVERLAY_BYTEA_BYTEA_INT4_INT4:
11265 case F_OVERLAY_TEXT_TEXT_INT4:
11266 case F_OVERLAY_TEXT_TEXT_INT4_INT4:
11282 case F_POSITION_BIT_BIT:
11283 case F_POSITION_BYTEA_BYTEA:
11284 case F_POSITION_TEXT_TEXT:
11293 case F_SUBSTRING_BIT_INT4:
11294 case F_SUBSTRING_BIT_INT4_INT4:
11295 case F_SUBSTRING_BYTEA_INT4:
11296 case F_SUBSTRING_BYTEA_INT4_INT4:
11297 case F_SUBSTRING_TEXT_INT4:
11298 case F_SUBSTRING_TEXT_INT4_INT4:
11312 case F_SUBSTRING_TEXT_TEXT_TEXT:
11323 case F_BTRIM_BYTEA_BYTEA:
11325 case F_BTRIM_TEXT_TEXT:
11338 case F_LTRIM_BYTEA_BYTEA:
11340 case F_LTRIM_TEXT_TEXT:
11353 case F_RTRIM_BYTEA_BYTEA:
11355 case F_RTRIM_TEXT_TEXT:
11368 case F_SYSTEM_USER:
11392 Oid resulttype,
int32 resulttypmod,
11413 ((
Const *)
arg)->consttype == resulttype &&
11414 ((
Const *)
arg)->consttypmod == -1)
11461 bool needlabel =
false;
11463 if (constval->constisnull)
11474 constval->consttypmod));
11481 &typoutput, &typIsVarlena);
11498 if (extval[0] !=
'-')
11514 if (isdigit((
unsigned char) extval[0]) &&
11515 strcspn(extval,
"eE.") != strlen(extval))
11527 if (strcmp(extval,
"t") == 0)
11567 needlabel |= (constval->consttypmod >= 0);
11573 if (needlabel || showtype > 0)
11576 constval->consttypmod));
11593 if (constval->constcollid != typcollation)
11624 " FORMAT JSONB" :
" FORMAT JSON");
11643 bool json_format_by_default)
11652 if (!json_format_by_default ||
11667 bool is_json_object;
11682 switch (ctor->
type)
11706 foreach(lc, ctor->
args)
11713 sep = (is_json_object && (curridx % 2) != 0) ?
" : " :
", ";
11759 const char *
funcname,
bool is_json_objectagg)
11773 is_json_objectagg);
11775 elog(
ERROR,
"invalid JsonConstructorExpr underlying node type: %d",
11785 const char *valptr;
11793 for (valptr =
val; *valptr; valptr++)
11814 char *opname = NULL;
11876 elog(
ERROR,
"unrecognized testexpr type: %d",
11889 if (strcmp(opname,
"=") == 0)
11906 need_paren =
false;
11911 elog(
ERROR,
"unrecognized sublink type: %d",
11941 if (tf->ns_uris !=
NIL)
11948 forboth(lc1, tf->ns_uris, lc2, tf->ns_names)
11958 if (ns_node != NULL)
11989 forfive(l1, tf->colnames, l2, tf->coltypes, l3, tf->coltypmods,
11990 l4, tf->
colexprs, l5, tf->coldefexprs)
11997 bool ordinality = (tf->ordinalitycol == colnum);
12005 ordinality ?
"FOR ORDINALITY" :
12010 if (coldefexpr != NULL)
12016 if (colexpr != NULL)
12083 forfour(lc_colname, tf->colnames,
12084 lc_coltype, tf->coltypes,
12085 lc_coltypmod, tf->coltypmods,
12086 lc_colvalexpr, tf->colvalexprs)
12100 if (scan->
colMin < 0 || colnum < scan->colMin)
12105 if (colnum > scan->
colMax)
12108 if (colnum > scan->
colMin)
12113 ordinality = !colexpr;
12118 ordinality ?
"FOR ORDINALITY" :
12137 bool typispreferred;
12141 if (typcategory == TYPCATEGORY_STRING)
12144 " FORMAT JSONB" :
" FORMAT JSON");
12197 bool needcomma =
false;
12282 if (!rte->inFromCl)
12305 context->
buf = &itembuf;
12316 if (itembuf.
len > 0 && itembuf.
data[0] ==
'\n')
12327 trailing_nl = strrchr(
buf->data,
'\n');
12328 if (trailing_nl == NULL)
12329 trailing_nl =
buf->data;
12337 if (strlen(trailing_nl) + itembuf.
len > context->
wrapColumn)
12430 rtfunc->funccolnames !=
NIL)
12432 all_unnest =
false;
12465 if (rtfunc->funccolnames !=
NIL)
12504 if (rtfunc1 && rtfunc1->funccolnames !=
NIL)
12523 bool need_paren_on_right;
12534 switch (
j->jointype)
12567 elog(
ERROR,
"unrecognized join type: %d",
12568 (
int)
j->jointype);
12571 if (need_paren_on_right)
12574 if (need_paren_on_right)
12577 if (
j->usingClause)
12586 char *colname = (
char *)
lfirst(lc);
12596 if (
j->join_using_alias)
12619 if (
j->alias != NULL)
12635 elog(
ERROR,
"unrecognized node type: %d",
12651 bool printalias =
false;
12653 if (rte->alias != NULL)
12700 if (strcmp(refname, rte->
ctename) != 0)
12706 use_as ?
" AS " :
" ",
12770 forfour(l1, rtfunc->funccoltypes,
12771 l2, rtfunc->funccoltypmods,
12772 l3, rtfunc->funccolcollations,
12773 l4, rtfunc->funccolnames)
12818 argtypes[0] = INTERNALOID;
12822 false, NULL,
false));
12825 foreach(l, tablesample->
args)
12861 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
12868 opcname =
NameStr(opcrec->opcname);
12896 return &
buf.data[1];
12929 elog(
ERROR,
"argument type %s of FieldStore is not a tuple type",
12970 node = (
Node *) cdomain->
arg;
12982 if (cdomain && node == (
Node *) cdomain->
arg)
12983 node = (
Node *) cdomain;
13038 for (ptr =
ident; *ptr; ptr++)
13042 if ((ch >=
'a' && ch <=
'z') ||
13043 (ch >=
'0' && ch <=
'9') ||
13078 result = (
char *)
palloc(strlen(
ident) + nquotes + 2 + 1);
13082 for (ptr =
ident; *ptr; ptr++)
13128 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13155 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13161 foreach(nslist, namespaces)
13166 foreach(ctlist, dpns->
ctes)
13213 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13219 elog(
ERROR,
"cache lookup failed for namespace %u",
13220 reltup->relnamespace);
13248 bool has_variadic,
bool *use_variadic_p,
13263 Oid *p_true_typeids;
13264 bool force_qualify =
false;
13268 elog(
ERROR,
"cache lookup failed for function %u", funcid);
13278 if (strcmp(
proname,
"cube") == 0 || strcmp(
proname,
"rollup") == 0)
13279 force_qualify =
true;
13292 if (use_variadic_p)
13296 use_variadic = has_variadic;
13297 *use_variadic_p = use_variadic;
13302 use_variadic =
false;
13312 if (!force_qualify)
13314 NIL, argnames, nargs, argtypes,
13315 !use_variadic,
true,
false,
13316 &p_funcid, &p_rettype,
13317 &p_retset, &p_nvargs, &p_vatype,
13318 &p_true_typeids, NULL);
13328 p_funcid == funcid)
13365 elog(
ERROR,
"cache lookup failed for operator %u", operid);
13367 oprname =
NameStr(operform->oprname);
13374 switch (operform->oprkind)
13385 elog(
ERROR,
"unrecognized oprkind: %d", operform->oprkind);
13390 if (p_result != NULL &&
oprid(p_result) == operid)
13403 if (p_result != NULL)
13430 const char *leftop,
Oid leftoptype,
13432 const char *rightop,
Oid rightoptype)
13441 elog(
ERROR,
"cache lookup failed for operator %u", opoid);
13443 Assert(operform->oprkind ==
'b');
13444 oprname =
NameStr(operform->oprname);
13449 if (leftoptype != operform->oprleft)
13454 if (rightoptype != operform->oprright)
13478 elog(
ERROR,
"cache lookup failed for type %u", typid);
13510 elog(
ERROR,
"cache lookup failed for type %u", typid);
13516 elog(
ERROR,
"cache lookup failed for namespace %u",
13517 typtup->typnamespace);
13545 collname =
NameStr(colltup->collname);
13635 char *result = NULL;
13642 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13645 Anum_pg_class_reloptions, &isnull);
13678 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)
void hash_destroy(HTAB *hashp)
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,...)
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, 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)
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)