63 #include "utils/fmgroids.h"
82 #define PRETTYINDENT_STD 8
83 #define PRETTYINDENT_JOIN 4
84 #define PRETTYINDENT_VAR 4
86 #define PRETTYINDENT_LIMIT 40
89 #define PRETTYFLAG_PAREN 0x0001
90 #define PRETTYFLAG_INDENT 0x0002
91 #define PRETTYFLAG_SCHEMA 0x0004
94 #define GET_PRETTY_FLAGS(pretty) \
95 ((pretty) ? (PRETTYFLAG_PAREN | PRETTYFLAG_INDENT | PRETTYFLAG_SCHEMA) \
99 #define WRAP_COLUMN_DEFAULT 0
102 #define PRETTY_PAREN(context) ((context)->prettyFlags & PRETTYFLAG_PAREN)
103 #define PRETTY_INDENT(context) ((context)->prettyFlags & PRETTYFLAG_INDENT)
104 #define PRETTY_SCHEMA(context) ((context)->prettyFlags & PRETTYFLAG_SCHEMA)
296 #define deparse_columns_fetch(rangetable_index, dpns) \
297 ((deparse_columns *) list_nth((dpns)->rtable_columns, (rangetable_index)-1))
320 static const char *
const query_getviewrule =
"SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2";
335 bool forceprefix,
bool showimplicit,
336 int prettyFlags,
int startIndent);
338 int prettyFlags,
int wrapColumn);
344 const Oid *excludeOps,
345 bool attrsOnly,
bool keysOnly,
346 bool showTblSpc,
bool inherits,
347 int prettyFlags,
bool missing_ok);
351 bool attrsOnly,
bool missing_ok);
353 int prettyFlags,
bool missing_ok);
356 bool print_table_args,
bool print_defaults);
363 List *parent_namespaces);
395 int prettyFlags,
int wrapColumn);
397 TupleDesc resultDesc,
bool colNamesVisible,
398 int prettyFlags,
int wrapColumn,
int startIndent);
402 TupleDesc resultDesc,
bool colNamesVisible);
404 bool colNamesVisible);
406 bool colNamesVisible);
411 bool colNamesVisible);
413 bool colNamesVisible);
416 TupleDesc resultDesc,
bool colNamesVisible);
418 TupleDesc resultDesc,
bool colNamesVisible);
421 TupleDesc resultDesc,
bool colNamesVisible);
448 int indentBefore,
int indentAfter,
int indentPlus);
466 const char *
options,
bool is_json_objectagg);
472 bool is_json_objectagg);
482 bool json_format_by_default);
490 bool is_json_objectagg);
517 bool has_variadic,
bool *use_variadic_p,
535 #define only_marker(rte) ((rte)->inh ? "" : "ONLY ")
612 argtypes[0] = OIDOID;
627 elog(
ERROR,
"failed to get pg_rewrite tuple for rule %u", ruleoid);
805 argtypes[0] = OIDOID;
806 argtypes[1] = NAMEOID;
823 elog(
ERROR,
"failed to get pg_rewrite tuple for view %u", viewoid);
932 tgname =
NameStr(trigrec->tgname);
934 OidIsValid(trigrec->tgconstraint) ?
"CONSTRAINT " :
"",
937 if (TRIGGER_FOR_BEFORE(trigrec->tgtype))
939 else if (TRIGGER_FOR_AFTER(trigrec->tgtype))
941 else if (TRIGGER_FOR_INSTEAD(trigrec->tgtype))
944 elog(
ERROR,
"unexpected tgtype value: %d", trigrec->tgtype);
946 if (TRIGGER_FOR_INSERT(trigrec->tgtype))
951 if (TRIGGER_FOR_DELETE(trigrec->tgtype))
959 if (TRIGGER_FOR_UPDATE(trigrec->tgtype))
967 if (trigrec->tgattr.dim1 > 0)
972 for (
i = 0;
i < trigrec->tgattr.dim1;
i++)
979 trigrec->tgattr.values[
i],
false);
984 if (TRIGGER_FOR_TRUNCATE(trigrec->tgtype))
1007 if (!trigrec->tgdeferrable)
1010 if (trigrec->tginitdeferred)
1028 if (tgoldtable != NULL || tgnewtable != NULL)
1031 if (tgoldtable != NULL)
1034 if (tgnewtable != NULL)
1039 if (TRIGGER_FOR_ROW(trigrec->tgtype))
1065 oldrte->
relid = trigrec->tgrelid;
1066 oldrte->relkind = relkind;
1069 oldrte->eref = oldrte->alias;
1070 oldrte->lateral =
false;
1071 oldrte->
inh =
false;
1072 oldrte->inFromCl =
true;
1076 newrte->
relid = trigrec->tgrelid;
1077 newrte->relkind = relkind;
1080 newrte->eref = newrte->alias;
1081 newrte->lateral =
false;
1082 newrte->
inh =
false;
1083 newrte->inFromCl =
true;
1086 memset(&dpns, 0,
sizeof(dpns));
1116 if (trigrec->tgnargs > 0)
1124 elog(
ERROR,
"tgargs is null for trigger %u", trigid);
1126 for (
i = 0;
i < trigrec->tgnargs;
i++)
1228 prettyFlags,
false);
1244 prettyFlags,
false);
1255 const Oid *excludeOps,
1256 bool attrsOnly,
bool keysOnly,
1257 bool showTblSpc,
bool inherits,
1258 int prettyFlags,
bool missing_ok)
1261 bool isConstraint = (excludeOps != NULL);
1275 Datum indclassDatum;
1276 Datum indoptionDatum;
1292 elog(
ERROR,
"cache lookup failed for index %u", indexrelid);
1296 indrelid = idxrec->indrelid;
1297 Assert(indexrelid == idxrec->indexrelid);
1301 Anum_pg_index_indcollation);
1305 Anum_pg_index_indclass);
1309 Anum_pg_index_indoption);
1317 elog(
ERROR,
"cache lookup failed for relation %u", indexrelid);
1325 elog(
ERROR,
"cache lookup failed for access method %u",
1343 Anum_pg_index_indexprs);
1365 idxrec->indisunique ?
"UNIQUE " :
"",
1367 idxrelrec->relkind == RELKIND_PARTITIONED_INDEX
1368 && !inherits ?
"ONLY " :
"",
1382 for (keyno = 0; keyno < idxrec->indnatts; keyno++)
1386 Oid keycolcollation;
1391 if (keysOnly && keyno >= idxrec->indnkeyatts)
1395 if (!colno && keyno == idxrec->indnkeyatts)
1412 if (!colno || colno == keyno + 1)
1415 &keycoltype, &keycoltypmod,
1423 if (indexpr_item == NULL)
1424 elog(
ERROR,
"too few entries in indexprs list");
1426 indexpr_item =
lnext(indexprs, indexpr_item);
1430 if (!colno || colno == keyno + 1)
1443 if (!attrsOnly && keyno < idxrec->indnkeyatts &&
1444 (!colno || colno == keyno + 1))
1447 Oid indcoll = indcollation->
values[keyno];
1449 bool has_options = attoptions != (
Datum) 0;
1452 if (
OidIsValid(indcoll) && indcoll != keycolcollation)
1471 if (opt & INDOPTION_DESC)
1475 if (!(opt & INDOPTION_NULLS_FIRST))
1480 if (opt & INDOPTION_NULLS_FIRST)
1486 if (excludeOps != NULL)
1498 if (idxrec->indnullsnotdistinct)
1539 Anum_pg_index_indpred);
1648 bool ndistinct_enabled;
1649 bool dependencies_enabled;
1664 elog(
ERROR,
"cache lookup failed for statistics object %u", statextid);
1668 has_exprs = !
heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
1683 Anum_pg_statistic_ext_stxexprs);
1692 ncolumns = statextrec->stxkeys.dim1 +
list_length(exprs);
1701 NameStr(statextrec->stxname)));
1708 Anum_pg_statistic_ext_stxkind);
1713 elog(
ERROR,
"stxkind is not a 1-D char array");
1716 ndistinct_enabled =
false;
1717 dependencies_enabled =
false;
1718 mcv_enabled =
false;
1722 if (enabled[
i] == STATS_EXT_NDISTINCT)
1723 ndistinct_enabled =
true;
1724 else if (enabled[
i] == STATS_EXT_DEPENDENCIES)
1725 dependencies_enabled =
true;
1726 else if (enabled[
i] == STATS_EXT_MCV)
1743 if ((!ndistinct_enabled || !dependencies_enabled || !mcv_enabled) &&
1746 bool gotone =
false;
1750 if (ndistinct_enabled)
1756 if (dependencies_enabled)
1772 for (colno = 0; colno < statextrec->stxkeys.dim1; colno++)
1786 statextrec->stxrelid);
1841 has_exprs = !
heap_attisnull(statexttup, Anum_pg_statistic_ext_stxexprs, NULL);
1856 Anum_pg_statistic_ext_stxexprs);
1862 statextrec->stxrelid);
1922 bool attrsOnly,
bool missing_ok)
1942 elog(
ERROR,
"cache lookup failed for partition key of %u", relid);
1947 Assert(form->partrelid == relid);
1951 Anum_pg_partitioned_table_partclass);
1955 Anum_pg_partitioned_table_partcollation);
1964 if (!
heap_attisnull(tuple, Anum_pg_partitioned_table_partexprs, NULL))
1970 Anum_pg_partitioned_table_partexprs);
1975 elog(
ERROR,
"unexpected node type found in partexprs: %d",
1988 switch (form->partstrat)
2003 elog(
ERROR,
"unexpected partition strategy: %d",
2004 (
int) form->partstrat);
2010 for (keyno = 0; keyno < form->partnatts; keyno++)
2014 Oid keycolcollation;
2028 &keycoltype, &keycoltypmod,
2036 if (partexpr_item == NULL)
2037 elog(
ERROR,
"too few entries in partexprs list");
2039 partexpr_item =
lnext(partexprs, partexpr_item);
2055 partcoll = partcollation->
values[keyno];
2056 if (!attrsOnly &&
OidIsValid(partcoll) && partcoll != keycolcollation)
2091 if (constr_expr == NULL)
2100 false, prettyFlags, 0);
2178 int prettyFlags,
bool missing_ok)
2189 Anum_pg_constraint_oid,
2194 ConstraintOidIndexId,
2216 elog(
ERROR,
"could not find tuple for constraint %u", constraintId);
2248 switch (conForm->contype)
2250 case CONSTRAINT_FOREIGN:
2261 Anum_pg_constraint_conkey);
2272 Anum_pg_constraint_confkey);
2279 switch (conForm->confmatchtype)
2282 string =
" MATCH FULL";
2285 string =
" MATCH PARTIAL";
2291 elog(
ERROR,
"unrecognized confmatchtype: %d",
2292 conForm->confmatchtype);
2299 switch (conForm->confupdtype)
2305 string =
"RESTRICT";
2311 string =
"SET NULL";
2314 string =
"SET DEFAULT";
2317 elog(
ERROR,
"unrecognized confupdtype: %d",
2318 conForm->confupdtype);
2325 switch (conForm->confdeltype)
2331 string =
"RESTRICT";
2337 string =
"SET NULL";
2340 string =
"SET DEFAULT";
2343 elog(
ERROR,
"unrecognized confdeltype: %d",
2344 conForm->confdeltype);
2356 Anum_pg_constraint_confdelsetcols, &isnull);
2366 case CONSTRAINT_PRIMARY:
2367 case CONSTRAINT_UNIQUE:
2375 if (conForm->contype == CONSTRAINT_PRIMARY)
2380 indexId = conForm->conindid;
2384 elog(
ERROR,
"cache lookup failed for index %u", indexId);
2385 if (conForm->contype == CONSTRAINT_UNIQUE &&
2393 Anum_pg_constraint_conkey);
2401 Anum_pg_index_indnatts);
2412 Anum_pg_index_indkey);
2415 &keys, NULL, &nKeys);
2417 for (
j = keyatts;
j < nKeys;
j++)
2458 case CONSTRAINT_CHECK:
2468 Anum_pg_constraint_conbin);
2503 conForm->connoinherit ?
" NO INHERIT" :
"");
2506 case CONSTRAINT_TRIGGER:
2516 case CONSTRAINT_EXCLUSION:
2518 Oid indexOid = conForm->conindid;
2527 Anum_pg_constraint_conexclop);
2530 &elems, NULL, &nElems);
2533 for (
i = 0;
i < nElems;
i++)
2551 elog(
ERROR,
"invalid constraint type \"%c\"", conForm->contype);
2555 if (conForm->condeferrable)
2557 if (conForm->condeferred)
2559 if (!conForm->convalidated)
2585 &keys, NULL, &nKeys);
2587 for (
j = 0;
j < nKeys;
j++)
2692 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2693 errmsg(
"input is a query, not an expression")));
2704 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2705 errmsg(
"expression contains variables of more than one relation")));
2711 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
2712 errmsg(
"expression contains variables")));
2768 *result = role_rec->rolname;
2810 (
errcode(ERRCODE_UNDEFINED_COLUMN),
2811 errmsg(
"column \"%s\" of relation \"%s\" does not exist",
2818 Anum_pg_depend_refclassid,
2822 Anum_pg_depend_refobjid,
2826 Anum_pg_depend_refobjsubid,
2842 if (deprec->classid == RelationRelationId &&
2843 deprec->objsubid == 0 &&
2848 sequenceId = deprec->objid;
2906 if (proc->prokind == PROKIND_AGGREGATE)
2908 (
errcode(ERRCODE_WRONG_OBJECT_TYPE),
2909 errmsg(
"\"%s\" is an aggregate function",
name)));
2911 isfunction = (proc->prokind != PROKIND_PROCEDURE);
2919 isfunction ?
"FUNCTION" :
"PROCEDURE",
2938 if (proc->prokind == PROKIND_WINDOW)
2940 switch (proc->provolatile)
2942 case PROVOLATILE_IMMUTABLE:
2945 case PROVOLATILE_STABLE:
2948 case PROVOLATILE_VOLATILE:
2952 switch (proc->proparallel)
2954 case PROPARALLEL_SAFE:
2957 case PROPARALLEL_RESTRICTED:
2960 case PROPARALLEL_UNSAFE:
2964 if (proc->proisstrict)
2966 if (proc->prosecdef)
2968 if (proc->proleakproof)
2972 if (proc->prolang == INTERNALlanguageId ||
2973 proc->prolang == ClanguageId)
2977 if (proc->procost != procost)
2980 if (proc->prorows > 0 && proc->prorows != 1000)
2983 if (proc->prosupport)
2991 argtypes[0] = INTERNALOID;
2998 if (oldlen !=
buf.len)
3002 tmp =
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_proconfig, &isnull);
3027 pos = strchr(configitem,
'=');
3060 elog(
ERROR,
"invalid list syntax in proconfig item");
3062 foreach(lc, namelist)
3064 char *curname = (
char *)
lfirst(lc);
3067 if (
lnext(namelist, lc))
3079 (void)
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
3080 if (proc->prolang == SQLlanguageId && !isnull)
3088 tmp =
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_probin, &isnull);
3109 while (strstr(prosrc, dq.
data) != NULL)
3221 if (proc->proretset)
3235 if (proc->proretset)
3252 bool print_table_args,
bool print_defaults)
3259 int insertorderbyat = -1;
3268 &argtypes, &argnames, &argmodes);
3270 nlackdefaults = numargs;
3271 if (print_defaults && proc->pronargdefaults > 0)
3273 Datum proargdefaults;
3277 Anum_pg_proc_proargdefaults,
3286 nextargdefault =
list_head(argdefaults);
3288 nlackdefaults = proc->pronargs -
list_length(argdefaults);
3293 if (proc->prokind == PROKIND_AGGREGATE)
3300 elog(
ERROR,
"cache lookup failed for aggregate %u",
3303 if (AGGKIND_IS_ORDERED_SET(agg->aggkind))
3304 insertorderbyat = agg->aggnumdirectargs;
3310 for (
i = 0;
i < numargs;
i++)
3312 Oid argtype = argtypes[
i];
3313 char *argname = argnames ? argnames[
i] : NULL;
3314 char argmode = argmodes ? argmodes[
i] : PROARGMODE_IN;
3315 const char *modename;
3326 if (proc->prokind == PROKIND_PROCEDURE)
3332 case PROARGMODE_INOUT:
3333 modename =
"INOUT ";
3336 case PROARGMODE_OUT:
3340 case PROARGMODE_VARIADIC:
3341 modename =
"VARIADIC ";
3344 case PROARGMODE_TABLE:
3349 elog(
ERROR,
"invalid parameter mode '%c'", argmode);
3357 if (print_table_args != (argmode == PROARGMODE_TABLE))
3360 if (argsprinted == insertorderbyat)
3366 else if (argsprinted)
3370 if (argname && argname[0])
3373 if (print_defaults && isinput && inputargno > nlackdefaults)
3377 Assert(nextargdefault != NULL);
3379 nextargdefault =
lnext(argdefaults, nextargdefault);
3387 if (argsprinted == insertorderbyat &&
i == numargs - 1)
3391 print_defaults =
false;
3402 || argmodes[nth] == PROARGMODE_IN
3403 || argmodes[nth] == PROARGMODE_INOUT
3404 || argmodes[nth] == PROARGMODE_VARIADIC);
3422 for (
i = 0;
i < ntypes;
i++)
3454 Datum proargdefaults;
3463 if (nth_arg < 1 || nth_arg > numargs || !
is_input_argument(nth_arg - 1, argmodes))
3470 for (
i = 0;
i < nth_arg;
i++)
3475 Anum_pg_proc_proargdefaults,
3493 nth_default = nth_inputarg - 1 - (proc->pronargs - proc->pronargdefaults);
3495 if (nth_default < 0 || nth_default >=
list_length(argdefaults))
3500 node =
list_nth(argdefaults, nth_default);
3521 &argtypes, &argnames, &argmodes);
3577 (void)
SysCacheGetAttr(PROCOID, proctup, Anum_pg_proc_prosqlbody, &isnull);
3599 bool forceprefix,
bool showimplicit)
3602 showimplicit, 0, 0);
3626 bool forceprefix,
bool showimplicit,
3627 int prettyFlags,
int startIndent)
3634 context.namespaces = dpcontext;
3637 context.varprefix = forceprefix;
3638 context.prettyFlags = prettyFlags;
3640 context.indentLevel = startIndent;
3669 rte->relkind = RELKIND_RELATION;
3672 rte->eref = rte->alias;
3673 rte->lateral =
false;
3675 rte->inFromCl =
true;
3727 Assert(crelid > 0 && crelid <= ntables);
3799 memset(&dpns, 0,
sizeof(dpns));
3846 names_hash =
hash_create(
"set_rtable_names names",
3852 foreach(lc, parent_namespaces)
3859 char *oldname = (
char *)
lfirst(lc2);
3861 if (oldname == NULL)
3874 foreach(lc, dpns->
rtable)
3887 else if (rte->alias)
3890 refname = rte->alias->aliasname;
3905 refname = rte->eref->aliasname;
3923 int refnamelen = strlen(refname);
3924 char *modname = (
char *)
palloc(refnamelen + 16);
3932 memcpy(modname, refname, refnamelen);
3970 List *parent_namespaces)
4097 if (
j->alias == NULL &&
j->usingClause)
4107 for (
int i = 0;
i < jrte->joinmergedcols;
i++)
4123 elog(
ERROR,
"unrecognized node type: %d",
4181 if (rte->alias == NULL)
4187 if (colname == NULL)
4191 if (leftattnos[
i] > 0)
4194 leftcolinfo->
colnames[leftattnos[
i] - 1] = colname;
4198 if (rightattnos[
i] > 0)
4201 rightcolinfo->
colnames[rightattnos[
i] - 1] = colname;
4239 foreach(lc,
j->usingClause)
4244 Assert(leftattnos[
i] != 0 && rightattnos[
i] != 0);
4252 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4265 parentUsing =
lappend(parentUsing, colname);
4268 if (leftattnos[
i] > 0)
4271 leftcolinfo->
colnames[leftattnos[
i] - 1] = colname;
4275 if (rightattnos[
i] > 0)
4278 rightcolinfo->
colnames[rightattnos[
i] - 1] = colname;
4294 elog(
ERROR,
"unrecognized node type: %d",
4310 char **real_colnames;
4330 ncolumns = tupdesc->
natts;
4331 real_colnames = (
char **)
palloc(ncolumns *
sizeof(
char *));
4333 for (
i = 0;
i < ncolumns;
i++)
4337 if (attr->attisdropped)
4338 real_colnames[
i] = NULL;
4372 colnames = rte->eref->colnames;
4375 real_colnames = (
char **)
palloc(ncolumns *
sizeof(
char *));
4378 foreach(lc, colnames)
4386 if (
cname[0] ==
'\0')
4388 real_colnames[
i] =
cname;
4422 changed_any =
false;
4424 for (
i = 0;
i < ncolumns;
i++)
4426 char *real_colname = real_colnames[
i];
4430 if (real_colname == NULL)
4437 if (colname == NULL)
4440 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4443 colname = real_colname;
4458 if (!changed_any && strcmp(colname, real_colname) != 0)
4486 else if (rte->alias && rte->alias->colnames !=
NIL)
4538 changed_any =
false;
4559 if (real_colname == NULL)
4566 if (rte->alias == NULL)
4573 if (colname == NULL)
4576 if (rte->alias &&
i <
list_length(rte->alias->colnames))
4579 colname = real_colname;
4588 if (!changed_any && strcmp(colname, real_colname) != 0)
4623 while (
i < noldcolumns &&
4649 while (ic < leftcolinfo->num_cols &&
4652 Assert(ic < leftcolinfo->num_cols);
4658 while (i < colinfo->num_cols &&
4661 Assert(i < colinfo->num_cols);
4673 if (rte->alias != NULL)
4698 while (ic < rightcolinfo->num_cols &&
4699 rightcolinfo->
colnames[ic] == NULL)
4701 Assert(ic < rightcolinfo->num_cols);
4707 while (i < colinfo->num_cols &&
4710 Assert(i < colinfo->num_cols);
4722 if (rte->alias != NULL)
4739 #ifdef USE_ASSERT_CHECKING
4740 while (i < colinfo->num_cols && colinfo->
colnames[
i] == NULL)
4750 if (rte->alias != NULL)
4773 if (oldname && strcmp(oldname, colname) == 0)
4785 if (oldname && strcmp(oldname, colname) == 0)
4792 char *oldname = (
char *)
lfirst(lc);
4794 if (strcmp(oldname, colname) == 0)
4801 char *oldname = (
char *)
lfirst(lc);
4803 if (strcmp(oldname, colname) == 0)
4826 int colnamelen = strlen(colname);
4827 char *modname = (
char *)
palloc(colnamelen + 16);
4835 memcpy(modname, colname, colnamelen);
4836 sprintf(modname + colnamelen,
"_%d",
i);
4888 elog(
ERROR,
"unrecognized node type in jointree: %d",
4895 elog(
ERROR,
"unrecognized node type in jointree: %d",
4916 foreach(lc, jrte->joinleftcols)
4923 foreach(lc, jrte->joinrightcols)
4927 if (rcolno < jrte->joinmergedcols)
4933 Assert(jcolno == numjoincols);
5054 elog(
ERROR,
"could not find RecursiveUnion for WorkTableScan with wtParam %d",
5201 Assert(ev_action != NULL);
5204 elog(
ERROR,
"invalid empty ev_action list");
5241 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5242 errmsg(
"rule \"%s\" has unsupported event type %d",
5243 rulename, ev_type)));
5254 if (strcmp(ev_qual,
"<>") != 0)
5289 context.prettyFlags = prettyFlags;
5346 int prettyFlags,
int wrapColumn)
5384 Assert(ev_action != NULL);
5395 if (ev_type !=
'1' || !is_instead ||
5405 prettyFlags, wrapColumn, 0);
5431 TupleDesc resultDesc,
bool colNamesVisible,
5432 int prettyFlags,
int wrapColumn,
int startIndent)
5456 context.varprefix = (parentnamespace !=
NIL ||
5458 context.prettyFlags = prettyFlags;
5459 context.wrapColumn = wrapColumn;
5460 context.indentLevel = startIndent;
5497 elog(
ERROR,
"unrecognized query command type: %d",
5511 bool first_list =
true;
5516 foreach(vtl, values_lists)
5519 bool first_col =
true;
5528 foreach(lc, sublist)
5566 if (query->hasRecursive)
5567 sep =
"WITH RECURSIVE ";
5576 if (cte->aliascolnames)
5582 foreach(col, cte->aliascolnames)
5616 if (cte->search_clause)
5622 cte->search_clause->search_breadth_first ?
"BREADTH" :
"DEPTH");
5624 foreach(lc, cte->search_clause->search_col_list)
5637 if (cte->cycle_clause)
5644 foreach(lc, cte->cycle_clause->cycle_col_list)
5691 TupleDesc resultDesc,
bool colNamesVisible)
5694 List *save_windowclause;
5695 List *save_windowtlist;
5703 save_windowclause =
context->windowClause;
5705 save_windowtlist =
context->windowTList;
5723 force_colno =
false;
5767 if (query->hasForUpdate)
5781 elog(
ERROR,
"unrecognized LockClauseStrength %d",
5812 context->windowClause = save_windowclause;
5813 context->windowTList = save_windowtlist;
5832 foreach(lc, query->
rtable)
5876 if (resultDesc && colno <= resultDesc->natts)
5879 colname = tle->resname;
5882 if (colname == NULL || strcmp(colname,
cname) != 0)
5892 TupleDesc resultDesc,
bool colNamesVisible)
5920 if (query->isReturn)
5928 if (query->hasDistinctOn)
5971 save_exprkind =
context->special_exprkind;
6000 context->special_exprkind = save_exprkind;
6026 TupleDesc resultDesc,
bool colNamesVisible)
6030 bool last_was_multiline =
false;
6040 foreach(l, targetList)
6083 attname = colNamesVisible ? NULL :
"?column?";
6092 if (resultDesc && colno <= resultDesc->natts)
6095 colname = tle->resname;
6113 if (targetbuf.
len > 0 && targetbuf.
data[0] ==
'\n')
6116 leading_nl_pos = -1;
6119 if (leading_nl_pos >= 0)
6129 trailing_nl = strrchr(
buf->data,
'\n');
6130 if (trailing_nl == NULL)
6131 trailing_nl =
buf->data;
6141 ((strlen(trailing_nl) + targetbuf.
len >
context->wrapColumn) ||
6142 last_was_multiline))
6148 last_was_multiline =
6149 (strchr(targetbuf.
data + leading_nl_pos + 1,
'\n') != NULL);
6162 TupleDesc resultDesc,
bool colNamesVisible)
6177 Assert(subquery != NULL);
6180 need_paren = (subquery->
cteList ||
6278 context->indentLevel -= subindent;
6284 elog(
ERROR,
"unrecognized node type: %d",
6321 else if (!expr ||
IsA(expr,
Var))
6357 bool omit_child_parens =
true;
6394 omit_child_parens =
false;
6420 foreach(l, orderList)
6481 if (wc->name == NULL)
6506 bool needspace =
false;
6612 bool colNamesVisible)
6620 List *strippedexprs;
6629 foreach(l, query->
rtable)
6636 elog(
ERROR,
"too many subquery RTEs in INSERT");
6643 elog(
ERROR,
"too many values RTEs in INSERT");
6647 if (select_rte && values_rte)
6648 elog(
ERROR,
"both subquery and values RTEs in INSERT");
6674 strippedexprs =
NIL;
6705 strippedexprs =
lappend(strippedexprs,
6712 if (query->override)
6728 else if (values_rte)
6733 else if (strippedexprs)
6764 bool save_varprefix;
6771 save_varprefix =
context->varprefix;
6778 context->varprefix = save_varprefix;
6786 elog(
ERROR,
"cache lookup failed for constraint %u",
6829 bool colNamesVisible)
6891 int remaining_ma_columns;
6902 if (query->hasSubLinks)
6904 foreach(l, targetList)
6914 ma_sublinks =
lappend(ma_sublinks, sl);
6921 cur_ma_sublink = NULL;
6922 remaining_ma_columns = 0;
6926 foreach(l, targetList)
6942 if (next_ma_cell != NULL && cur_ma_sublink == NULL)
6988 next_ma_cell =
lnext(ma_sublinks, next_ma_cell);
6991 ((cur_ma_sublink->
subLinkId << 16) | 1));
7016 if (cur_ma_sublink != NULL)
7018 if (--remaining_ma_columns > 0)
7021 expr = (
Node *) cur_ma_sublink;
7022 cur_ma_sublink = NULL;
7038 bool colNamesVisible)
7090 bool colNamesVisible)
7095 bool haveNotMatchedBySource;
7130 haveNotMatchedBySource =
false;
7137 haveNotMatchedBySource =
true;
7149 switch (
action->matchKind)
7158 if (haveNotMatchedBySource)
7164 elog(
ERROR,
"unrecognized matchKind: %d",
7165 (
int)
action->matchKind);
7181 const char *sep =
"";
7188 foreach(lc2,
action->targetList)
7201 strippedexprs =
lappend(strippedexprs,
7274 elog(
ERROR,
"unexpected utility statement type");
7314 elog(
ERROR,
"bogus varlevelsup: %d offset %d",
7327 if (var->varnosyn > 0 && dpns->
plan == NULL)
7329 varno = var->varnosyn;
7330 varattno = var->varattnosyn;
7366 pvarattno = appinfo->parent_colnos[pvarattno - 1];
7386 varattno = pvarattno;
7422 elog(
ERROR,
"invalid attnum %d for relation \"%s\"",
7423 attnum, rte->eref->aliasname);
7425 Assert(netlevelsup == 0);
7456 if (rte->joinaliasvars ==
NIL)
7457 elog(
ERROR,
"cannot decompile join alias var in plan tree");
7464 if (aliasvar &&
IsA(aliasvar,
Var))
7485 elog(
ERROR,
"invalid attnum %d for relation \"%s\"",
7486 attnum, rte->eref->aliasname);
7565 (*callback) (node,
context, callback_arg);
7593 save_appendparents =
context->appendparents;
7606 context->appendparents = save_appendparents;
7640 (*callback) (node,
context, callback_arg);
7682 if (fieldno > 0 && fieldno <=
list_length(r->colnames))
7714 var->vartype != RECORDOID)
7718 Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
7725 elog(
ERROR,
"bogus varlevelsup: %d offset %d",
7735 if (var->varnosyn > 0 && dpns->
plan == NULL)
7737 varno = var->varnosyn;
7738 varattno = var->varattnosyn;
7768 elog(
ERROR,
"bogus varattno for OUTER_VAR var: %d", varattno);
7770 Assert(netlevelsup == 0);
7787 elog(
ERROR,
"bogus varattno for INNER_VAR var: %d", varattno);
7789 Assert(netlevelsup == 0);
7805 elog(
ERROR,
"bogus varattno for INDEX_VAR var: %d", varattno);
7807 Assert(netlevelsup == 0);
7833 expr = (
Node *) var;
7856 if (ste == NULL || ste->resjunk)
7857 elog(
ERROR,
"subquery %s does not have attribute %d",
7858 rte->eref->aliasname,
attnum);
7872 List *parent_namespaces;
7882 context->namespaces =
lcons(&mydpns, parent_namespaces);
7887 context->namespaces = save_nslist;
7907 elog(
ERROR,
"failed to find plan for subquery %s",
7908 rte->eref->aliasname);
7911 elog(
ERROR,
"bogus varattno for subquery var: %d",
7913 Assert(netlevelsup == 0);
7926 if (rte->joinaliasvars ==
NIL)
7927 elog(
ERROR,
"cannot decompile join alias var in plan tree");
7965 foreach(lc, ctedpns->
ctes)
7978 if (ste == NULL || ste->resjunk)
7979 elog(
ERROR,
"CTE %s does not have attribute %d",
7980 rte->eref->aliasname,
attnum);
7981 expr = (
Node *) ste->expr;
7992 List *parent_namespaces;
8002 context->namespaces =
lcons(&mydpns, parent_namespaces);
8007 context->namespaces = save_nslist;
8029 elog(
ERROR,
"failed to find plan for CTE %s",
8030 rte->eref->aliasname);
8033 elog(
ERROR,
"bogus varattno for subquery var: %d",
8035 Assert(netlevelsup == 0);
8054 Assert(fieldno >= 1 && fieldno <= tupleDesc->natts);
8072 *ancestor_cell_p = NULL;
8086 child_plan = dpns->
plan;
8109 *ancestor_cell_p = lc;
8129 if (paramid == param->
paramid)
8147 *ancestor_cell_p = rest;
8151 elog(
ERROR,
"SubPlan cannot be outermost ancestor");
8165 child_plan = (
Plan *) ancestor;
8221 if (paramid == param->
paramid)
8246 if (paramid == param->
paramid)
8284 if (paramid == param->
paramid)
8317 bool save_varprefix;
8327 save_varprefix =
context->varprefix;
8335 need_paren = !(
IsA(expr,
Var) ||
8347 context->varprefix = save_varprefix;
8387 bool should_qualify =
false;
8396 foreach(lc,
context->namespaces)
8402 should_qualify =
true;
8448 if (strlen(op) == 1)
8472 case T_CoerceToDomainValue:
8473 case T_SetToDefault:
8474 case T_CurrentOfExpr:
8478 case T_SubscriptingRef:
8481 case T_CoalesceExpr:
8483 case T_SQLValueFunction:
8485 case T_NextValueExpr:
8488 case T_GroupingFunc:
8490 case T_MergeSupportFunc:
8492 case T_JsonConstructorExpr:
8516 case T_CoerceToDomain:
8526 case T_ArrayCoerceExpr:
8529 case T_ConvertRowtypeExpr:
8539 const char *parentOp;
8542 bool is_lopriparent;
8543 bool is_hipriparent;
8550 is_lopriop = (strchr(
"+-", *op) != NULL);
8551 is_hipriop = (strchr(
"*/%", *op) != NULL);
8552 if (!(is_lopriop || is_hipriop))
8559 is_lopriparent = (strchr(
"+-", *parentOp) != NULL);
8560 is_hipriparent = (strchr(
"*/%", *parentOp) != NULL);
8561 if (!(is_lopriparent || is_hipriparent))
8564 if (is_hipriop && is_lopriparent)
8567 if (is_lopriop && is_hipriparent)
8586 case T_DistinctExpr:
8587 case T_JsonIsPredicate:
8602 case T_SubscriptingRef:
8605 case T_CoalesceExpr:
8610 case T_GroupingFunc:
8628 parentType = ((
BoolExpr *) parentNode)->boolop;
8654 case T_SubscriptingRef:
8657 case T_CoalesceExpr:
8662 case T_GroupingFunc:
8671 case T_JsonValueExpr:
8692 int indentBefore,
int indentAfter,
int indentPlus)
8700 context->indentLevel += indentBefore;
8708 indentAmount =
Max(
context->indentLevel, 0) + indentPlus;
8725 indentAmount += indentPlus;
8731 context->indentLevel += indentAfter;
8747 while (
str->len > 0 &&
str->data[
str->len - 1] ==
' ')
8748 str->data[--(
str->len)] =
'\0';
8765 bool showimplicit,
Node *parentNode)
8789 const char *behavior_names[] =
8898 case T_GroupingFunc:
8912 case T_MergeSupportFunc:
8916 case T_SubscriptingRef:
8986 case T_NamedArgExpr:
8999 case T_DistinctExpr:
9026 case T_ScalarArrayOpExpr:
9040 expr->
useOr ?
"ANY" :
"ALL");
9209 case T_AlternativeSubPlan:
9225 if (
splan->useHashTable)
9241 const char *fieldname;
9315 relabel->resulttypmod,
9342 case T_ArrayCoerceExpr:
9357 acoerce->resulttypmod,
9363 case T_ConvertRowtypeExpr:
9410 foreach(temp, caseexpr->
args)
9460 case T_CaseTestExpr:
9505 if (rowexpr->row_typeid != RECORDOID)
9522 if (tupdesc == NULL ||
9532 if (tupdesc != NULL)
9534 while (i < tupdesc->natts)
9554 case T_RowCompareExpr:
9583 case T_CoalesceExpr:
9597 switch (minmaxexpr->
op)
9611 case T_SQLValueFunction:
9675 bool needcomma =
false;
9764 Assert(!con->constisnull);
9767 " PRESERVE WHITESPACE");
9770 " STRIP WHITESPACE");
9787 if (con->constisnull)
9795 ", STANDALONE YES");
9803 ", STANDALONE NO VALUE");
9840 if (ntest->argisrow ||
9852 elog(
ERROR,
"unrecognized nulltesttype: %d",
9867 elog(
ERROR,
"unrecognized nulltesttype: %d",
9904 elog(
ERROR,
"unrecognized booltesttype: %d",
9912 case T_CoerceToDomain:
9927 ctest->resulttypmod,
9933 case T_CoerceToDomainValue:
9937 case T_SetToDefault:
9941 case T_CurrentOfExpr:
9954 case T_NextValueExpr:
9970 case T_InferenceElem:
9973 bool save_varprefix;
9980 save_varprefix =
context->varprefix;
9991 need_parens =
false;
10000 context->varprefix = save_varprefix;
10017 case T_PartitionBoundSpec:
10069 elog(
ERROR,
"unrecognized partition strategy: %d",
10076 case T_JsonValueExpr:
10085 case T_JsonConstructorExpr:
10089 case T_JsonIsPredicate:
10141 elog(
ERROR,
"unrecognized JsonExpr op: %d",
10155 bool needcomma =
false;
10192 foreach(l, (
List *) node)
10226 if (node &&
IsA(node,
Var))
10305 case T_CoalesceExpr:
10307 case T_SQLValueFunction:
10381 false, (
Node *) expr);
10393 Oid rettype = expr->funcresulttype;
10394 int32 coercedTypmod;
10400 rettype, coercedTypmod,
10423 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
10424 errmsg(
"too many arguments")));
10427 foreach(l, expr->
args)
10439 argnames, argtypes,
10440 expr->funcvariadic,
10444 foreach(l, expr->
args)
10448 if (use_variadic &&
lnext(expr->
args, l) == NULL)
10460 Aggref *original_aggref)
10473 const char *
options,
bool is_json_objectagg)
10478 bool use_variadic =
false;
10510 argtypes, aggref->aggvariadic,
10518 if (AGGKIND_IS_ORDERED_SET(aggref->aggkind))
10525 Assert(!aggref->aggvariadic);
10534 if (aggref->aggstar)
10542 foreach(l, aggref->
args)
10552 if (is_json_objectagg)
10566 if (use_variadic &&
i == nargs)
10600 Aggref *original_aggref = callback_arg;
10603 elog(
ERROR,
"combining Aggref does not point to an Aggref");
10605 aggref = (
Aggref *) node;
10626 bool is_json_objectagg)
10636 (
errcode(ERRCODE_TOO_MANY_ARGUMENTS),
10637 errmsg(
"too many arguments")));
10640 foreach(l, wfunc->
args)
10652 argtypes,
false, NULL,
10658 if (wfunc->winstar)
10662 if (is_json_objectagg)
10683 foreach(l,
context->windowClause)
10699 elog(
ERROR,
"could not find window clause for winref %u",
10724 case F_TIMEZONE_INTERVAL_TIMESTAMP:
10725 case F_TIMEZONE_INTERVAL_TIMESTAMPTZ:
10726 case F_TIMEZONE_INTERVAL_TIMETZ:
10727 case F_TIMEZONE_TEXT_TIMESTAMP:
10728 case F_TIMEZONE_TEXT_TIMESTAMPTZ:
10729 case F_TIMEZONE_TEXT_TIMETZ:
10740 case F_TIMEZONE_TIMESTAMP:
10741 case F_TIMEZONE_TIMESTAMPTZ:
10742 case F_TIMEZONE_TIMETZ:
10750 case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_INTERVAL:
10751 case F_OVERLAPS_TIMESTAMPTZ_INTERVAL_TIMESTAMPTZ_TIMESTAMPTZ:
10752 case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_INTERVAL:
10753 case F_OVERLAPS_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ_TIMESTAMPTZ:
10754 case F_OVERLAPS_TIMESTAMP_INTERVAL_TIMESTAMP_INTERVAL:
10755 case F_OVERLAPS_TIMESTAMP_INTERVAL_TIMESTAMP_TIMESTAMP:
10756 case F_OVERLAPS_TIMESTAMP_TIMESTAMP_TIMESTAMP_INTERVAL:
10757 case F_OVERLAPS_TIMESTAMP_TIMESTAMP_TIMESTAMP_TIMESTAMP:
10758 case F_OVERLAPS_TIMETZ_TIMETZ_TIMETZ_TIMETZ:
10759 case F_OVERLAPS_TIME_INTERVAL_TIME_INTERVAL:
10760 case F_OVERLAPS_TIME_INTERVAL_TIME_TIME:
10761 case F_OVERLAPS_TIME_TIME_TIME_INTERVAL:
10762 case F_OVERLAPS_TIME_TIME_TIME_TIME:
10775 case F_EXTRACT_TEXT_DATE:
10776 case F_EXTRACT_TEXT_TIME:
10777 case F_EXTRACT_TEXT_TIMETZ:
10778 case F_EXTRACT_TEXT_TIMESTAMP:
10779 case F_EXTRACT_TEXT_TIMESTAMPTZ:
10780 case F_EXTRACT_TEXT_INTERVAL:
10788 !con->constisnull);
10796 case F_IS_NORMALIZED:
10808 !con->constisnull);
10815 case F_PG_COLLATION_FOR:
10832 !con->constisnull);
10839 case F_OVERLAY_BIT_BIT_INT4:
10840 case F_OVERLAY_BIT_BIT_INT4_INT4:
10841 case F_OVERLAY_BYTEA_BYTEA_INT4:
10842 case F_OVERLAY_BYTEA_BYTEA_INT4_INT4:
10843 case F_OVERLAY_TEXT_TEXT_INT4:
10844 case F_OVERLAY_TEXT_TEXT_INT4_INT4:
10860 case F_POSITION_BIT_BIT:
10861 case F_POSITION_BYTEA_BYTEA:
10862 case F_POSITION_TEXT_TEXT:
10871 case F_SUBSTRING_BIT_INT4:
10872 case F_SUBSTRING_BIT_INT4_INT4:
10873 case F_SUBSTRING_BYTEA_INT4:
10874 case F_SUBSTRING_BYTEA_INT4_INT4:
10875 case F_SUBSTRING_TEXT_INT4:
10876 case F_SUBSTRING_TEXT_INT4_INT4:
10890 case F_SUBSTRING_TEXT_TEXT_TEXT:
10901 case F_BTRIM_BYTEA_BYTEA:
10903 case F_BTRIM_TEXT_TEXT:
10916 case F_LTRIM_BYTEA_BYTEA:
10918 case F_LTRIM_TEXT_TEXT:
10931 case F_RTRIM_BYTEA_BYTEA:
10933 case F_RTRIM_TEXT_TEXT:
10946 case F_SYSTEM_USER:
10970 Oid resulttype,
int32 resulttypmod,
10991 ((
Const *)
arg)->consttype == resulttype &&
10992 ((
Const *)
arg)->consttypmod == -1)
11039 bool needlabel =
false;
11041 if (constval->constisnull)
11052 constval->consttypmod));
11059 &typoutput, &typIsVarlena);
11076 if (extval[0] !=
'-')
11092 if (isdigit((
unsigned char) extval[0]) &&
11093 strcspn(extval,
"eE.") != strlen(extval))
11105 if (strcmp(extval,
"t") == 0)
11145 needlabel |= (constval->consttypmod >= 0);
11151 if (needlabel || showtype > 0)
11154 constval->consttypmod));
11171 if (constval->constcollid != typcollation)
11202 " FORMAT JSONB" :
" FORMAT JSON");
11221 bool json_format_by_default)
11230 if (!json_format_by_default ||
11245 bool is_json_object;
11260 switch (ctor->
type)
11284 foreach(lc, ctor->
args)
11291 sep = (is_json_object && (curridx % 2) != 0) ?
" : " :
", ";
11337 const char *
funcname,
bool is_json_objectagg)
11351 is_json_objectagg);
11353 elog(
ERROR,
"invalid JsonConstructorExpr underlying node type: %d",
11363 const char *valptr;
11371 for (valptr =
val; *valptr; valptr++)
11392 char *opname = NULL;
11454 elog(
ERROR,
"unrecognized testexpr type: %d",
11467 if (strcmp(opname,
"=") == 0)
11484 need_paren =
false;
11489 elog(
ERROR,
"unrecognized sublink type: %d",
11519 if (tf->ns_uris !=
NIL)
11526 forboth(lc1, tf->ns_uris, lc2, tf->ns_names)
11536 if (ns_node != NULL)
11566 forfive(l1, tf->colnames, l2, tf->coltypes, l3, tf->coltypmods,
11567 l4, tf->
colexprs, l5, tf->coldefexprs)
11574 bool ordinality = (tf->ordinalitycol == colnum);
11582 ordinality ?
"FOR ORDINALITY" :
11587 if (coldefexpr != NULL)
11593 if (colexpr != NULL)
11661 forfour(lc_colname, tf->colnames,
11662 lc_coltype, tf->coltypes,
11663 lc_coltypmod, tf->coltypmods,
11664 lc_colvalexpr, tf->colvalexprs)
11678 if (scan->
colMin < 0 || colnum < scan->colMin)
11683 if (colnum > scan->
colMax)
11686 if (colnum > scan->
colMin)
11691 ordinality = !colexpr;
11696 ordinality ?
"FOR ORDINALITY" :
11711 bool typispreferred;
11715 if (typcategory == TYPCATEGORY_STRING)
11718 " FORMAT JSONB" :
" FORMAT JSON");
11774 bool needcomma =
false;
11859 if (!rte->inFromCl)
11893 if (itembuf.
len > 0 && itembuf.
data[0] ==
'\n')
11904 trailing_nl = strrchr(
buf->data,
'\n');
11905 if (trailing_nl == NULL)
11906 trailing_nl =
buf->data;
11914 if (strlen(trailing_nl) + itembuf.
len >
context->wrapColumn)
12007 rtfunc->funccolnames !=
NIL)
12009 all_unnest =
false;
12042 if (rtfunc->funccolnames !=
NIL)
12081 if (rtfunc1 && rtfunc1->funccolnames !=
NIL)
12100 bool need_paren_on_right;
12111 switch (
j->jointype)
12144 elog(
ERROR,
"unrecognized join type: %d",
12145 (
int)
j->jointype);
12148 if (need_paren_on_right)
12151 if (need_paren_on_right)
12154 if (
j->usingClause)
12163 char *colname = (
char *)
lfirst(lc);
12173 if (
j->join_using_alias)
12196 if (
j->alias != NULL)
12212 elog(
ERROR,
"unrecognized node type: %d",
12228 bool printalias =
false;
12230 if (rte->alias != NULL)
12277 if (strcmp(refname, rte->
ctename) != 0)
12283 use_as ?
" AS " :
" ",
12347 forfour(l1, rtfunc->funccoltypes,
12348 l2, rtfunc->funccoltypmods,
12349 l3, rtfunc->funccolcollations,
12350 l4, rtfunc->funccolnames)
12395 argtypes[0] = INTERNALOID;
12402 foreach(l, tablesample->
args)
12438 elog(
ERROR,
"cache lookup failed for opclass %u", opclass);
12445 opcname =
NameStr(opcrec->opcname);
12473 return &
buf.data[1];
12506 elog(
ERROR,
"argument type %s of FieldStore is not a tuple type",
12547 node = (
Node *) cdomain->
arg;
12559 if (cdomain && node == (
Node *) cdomain->
arg)
12560 node = (
Node *) cdomain;
12615 for (ptr =
ident; *ptr; ptr++)
12619 if ((ch >=
'a' && ch <=
'z') ||
12620 (ch >=
'0' && ch <=
'9') ||
12655 result = (
char *)
palloc(strlen(
ident) + nquotes + 2 + 1);
12659 for (ptr =
ident; *ptr; ptr++)
12705 elog(
ERROR,
"cache lookup failed for relation %u", relid);
12732 elog(
ERROR,
"cache lookup failed for relation %u", relid);
12738 foreach(nslist, namespaces)
12743 foreach(ctlist, dpns->
ctes)
12790 elog(
ERROR,
"cache lookup failed for relation %u", relid);
12796 elog(
ERROR,
"cache lookup failed for namespace %u",
12797 reltup->relnamespace);
12823 bool has_variadic,
bool *use_variadic_p,
12838 Oid *p_true_typeids;
12839 bool force_qualify =
false;
12843 elog(
ERROR,
"cache lookup failed for function %u", funcid);
12853 if (strcmp(
proname,
"cube") == 0 || strcmp(
proname,
"rollup") == 0)
12854 force_qualify =
true;
12867 if (use_variadic_p)
12871 use_variadic = has_variadic;
12872 *use_variadic_p = use_variadic;
12877 use_variadic =
false;
12887 if (!force_qualify)
12889 NIL, argnames, nargs, argtypes,
12890 !use_variadic,
true,
false,
12891 &p_funcid, &p_rettype,
12892 &p_retset, &p_nvargs, &p_vatype,
12893 &p_true_typeids, NULL);
12903 p_funcid == funcid)
12940 elog(
ERROR,
"cache lookup failed for operator %u", operid);
12942 oprname =
NameStr(operform->oprname);
12949 switch (operform->oprkind)
12960 elog(
ERROR,
"unrecognized oprkind: %d", operform->oprkind);
12965 if (p_result != NULL &&
oprid(p_result) == operid)
12978 if (p_result != NULL)
13005 const char *leftop,
Oid leftoptype,
13007 const char *rightop,
Oid rightoptype)
13016 elog(
ERROR,
"cache lookup failed for operator %u", opoid);
13018 Assert(operform->oprkind ==
'b');
13019 oprname =
NameStr(operform->oprname);
13024 if (leftoptype != operform->oprleft)
13029 if (rightoptype != operform->oprright)
13053 elog(
ERROR,
"cache lookup failed for type %u", typid);
13085 elog(
ERROR,
"cache lookup failed for type %u", typid);
13091 elog(
ERROR,
"cache lookup failed for namespace %u",
13092 typtup->typnamespace);
13120 collname =
NameStr(colltup->collname);
13210 char *result = NULL;
13217 elog(
ERROR,
"cache lookup failed for relation %u", relid);
13220 Anum_pg_class_reloptions, &isnull);
13253 foreach(cell, bound_datums)
IndexAmRoutine * GetIndexAmRoutine(Oid amhandler)
#define DatumGetArrayTypeP(X)
ArrayBuildState * accumArrayResult(ArrayBuildState *astate, Datum dvalue, bool disnull, Oid element_type, MemoryContext rcontext)
Datum array_ref(ArrayType *array, int nSubscripts, int *indx, int arraytyplen, int elmlen, bool elmbyval, char elmalign, bool *isNull)
void deconstruct_array_builtin(ArrayType *array, Oid elmtype, Datum **elemsp, bool **nullsp, int *nelemsp)
Datum makeArrayResult(ArrayBuildState *astate, MemoryContext rcontext)
#define InvalidAttrNumber
char * get_tablespace_name(Oid spc_oid)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_make_singleton(int x)
Bitmapset * bms_add_member(Bitmapset *a, int x)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
#define TextDatumGetCString(d)
#define Assert(condition)
#define SQL_STR_DOUBLE(ch, escape_backslash)
#define OidIsValid(objectId)
const uint8 ScanKeywordCategories[SCANKEYWORDS_NUM_KEYWORDS]
static void PGresult * res
void hash_destroy(HTAB *hashp)
void * hash_search(HTAB *hashp, const void *keyPtr, HASHACTION action, bool *foundPtr)
HTAB * hash_create(const char *tabname, long nelem, const HASHCTL *info, int flags)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define palloc0_array(type, count)
char * OidOutputFunctionCall(Oid functionId, Datum val)
#define PG_GETARG_TEXT_PP(n)
#define DatumGetByteaPP(X)
#define DirectFunctionCall1(func, arg1)
#define PG_RETURN_TEXT_P(x)
#define PG_RETURN_NAME(x)
#define PG_GETARG_INT32(n)
#define PG_GETARG_BOOL(n)
#define PG_RETURN_DATUM(x)
int get_func_trftypes(HeapTuple procTup, Oid **p_trftypes)
int get_func_arg_info(HeapTuple procTup, Oid **p_argtypes, char ***p_argnames, char **p_argmodes)
TupleDesc get_expr_result_tupdesc(Node *expr, bool noError)
void systable_endscan(SysScanDesc sysscan)
HeapTuple systable_getnext(SysScanDesc sysscan)
SysScanDesc systable_beginscan(Relation heapRelation, Oid indexId, bool indexOK, Snapshot snapshot, int nkeys, ScanKey key)
int GetConfigOptionFlags(const char *name, bool missing_ok)
bool heap_attisnull(HeapTuple tup, int attnum, TupleDesc tupleDesc)
#define HeapTupleIsValid(tuple)
static Datum fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)
Oid GetDefaultOpClass(Oid type_id, Oid am_id)
if(TABLE==NULL||TABLE_index==NULL)
PGDLLIMPORT const ScanKeywordList ScanKeywords
#define UNRESERVED_KEYWORD
int ScanKeywordLookup(const char *str, const ScanKeywordList *keywords)
List * lappend(List *list, void *datum)
List * list_copy(const List *oldlist)
List * list_delete_first(List *list)
void list_free(List *list)
List * list_copy_tail(const List *oldlist, int nskip)
List * list_concat(List *list1, const List *list2)
List * lcons(void *datum, List *list)
char * get_language_name(Oid langoid, bool missing_ok)
AttrNumber get_attnum(Oid relid, const char *attname)
Oid get_opclass_input_type(Oid opclass)
char * get_namespace_name_or_temp(Oid nspid)
bool type_is_rowtype(Oid typid)
char * get_namespace_name(Oid nspid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Datum get_attoptions(Oid relid, int16 attnum)
char get_rel_relkind(Oid relid)
Oid get_typcollation(Oid typid)
char * get_rel_name(Oid relid)
char * get_constraint_name(Oid conoid)
Oid get_rel_tablespace(Oid relid)
Oid get_typ_typrelid(Oid typid)
Oid get_base_element_type(Oid typid)
void get_type_category_preferred(Oid typid, char *typcategory, bool *typispreferred)
char * get_attname(Oid relid, AttrNumber attnum, bool missing_ok)
void get_atttypetypmodcoll(Oid relid, AttrNumber attnum, Oid *typid, int32 *typmod, Oid *collid)
Alias * makeAlias(const char *aliasname, List *colnames)
int pg_mbcliplen(const char *mbstr, int len, int limit)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#define CHECK_FOR_INTERRUPTS()
Datum namein(PG_FUNCTION_ARGS)
bool CollationIsVisible(Oid collid)
bool RelationIsVisible(Oid relid)
bool OpclassIsVisible(Oid opcid)
RangeVar * makeRangeVarFromNameList(const List *names)
#define RangeVarGetRelid(relation, lockmode, missing_ok)
Oid exprType(const Node *expr)
bool exprIsLengthCoercion(const Node *expr, int32 *coercedTypmod)
int32 exprTypmod(const Node *expr)
Oid exprCollation(const Node *expr)
Node * strip_implicit_coercions(Node *node)
#define DO_AGGSPLIT_SKIPFINAL(as)
#define IsA(nodeptr, _type_)
#define DO_AGGSPLIT_COMBINE(as)
#define castNode(_type_, nodeptr)
#define repalloc0_array(pointer, type, oldcount, count)
int get_aggregate_argtypes(Aggref *aggref, Oid *inputTypes)
FuncDetailCode func_get_detail(List *funcname, List *fargs, List *fargnames, int nargs, Oid *argtypes, bool expand_variadic, bool expand_defaults, bool include_out_arguments, Oid *funcid, Oid *rettype, bool *retset, int *nvargs, Oid *vatype, Oid **true_typeids, List **argdefaults)
Operator left_oper(ParseState *pstate, List *op, Oid arg, bool noError, int location)
Operator oper(ParseState *pstate, List *opname, Oid ltypeId, Oid rtypeId, bool noError, int location)
TargetEntry * get_tle_by_resno(List *tlist, AttrNumber resno)
char * get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, int location, bool include_dropped, List **colnames, List **colvars)
#define FRAMEOPTION_END_CURRENT_ROW
#define FRAMEOPTION_END_OFFSET
#define FRAMEOPTION_EXCLUDE_CURRENT_ROW
#define FKCONSTR_ACTION_RESTRICT
#define FRAMEOPTION_END_OFFSET_PRECEDING
#define FRAMEOPTION_START_UNBOUNDED_PRECEDING
#define GetCTETargetList(cte)
#define FKCONSTR_ACTION_SETDEFAULT
@ PARTITION_STRATEGY_HASH
@ PARTITION_STRATEGY_LIST
@ PARTITION_STRATEGY_RANGE
#define FRAMEOPTION_START_CURRENT_ROW
#define FKCONSTR_MATCH_SIMPLE
#define FRAMEOPTION_START_OFFSET
@ PARTITION_RANGE_DATUM_MAXVALUE
@ PARTITION_RANGE_DATUM_MINVALUE
#define FKCONSTR_MATCH_PARTIAL
#define FRAMEOPTION_END_OFFSET_FOLLOWING
#define FRAMEOPTION_EXCLUDE_TIES
#define FRAMEOPTION_RANGE
#define FRAMEOPTION_EXCLUDE_GROUP
#define FKCONSTR_ACTION_CASCADE
#define FRAMEOPTION_GROUPS
#define FRAMEOPTION_BETWEEN
#define FKCONSTR_ACTION_SETNULL
#define FRAMEOPTION_END_UNBOUNDED_FOLLOWING
#define FRAMEOPTION_START_OFFSET_PRECEDING
#define FRAMEOPTION_START_OFFSET_FOLLOWING
#define FRAMEOPTION_NONDEFAULT
#define FKCONSTR_MATCH_FULL
#define FKCONSTR_ACTION_NOACTION
PGDLLIMPORT bool standard_conforming_strings
#define rt_fetch(rangetable_index, rangetable)
Expr * get_partition_qual_relid(Oid relid)
FormData_pg_aggregate * Form_pg_aggregate
FormData_pg_am * Form_pg_am
FormData_pg_attribute * Form_pg_attribute
FormData_pg_authid * Form_pg_authid
FormData_pg_class * Form_pg_class
FormData_pg_collation * Form_pg_collation
FormData_pg_constraint * Form_pg_constraint
FormData_pg_depend * Form_pg_depend
FormData_pg_index * Form_pg_index
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define linitial_node(type, l)
#define lsecond_node(type, l)
#define forboth(cell1, list1, cell2, list2)
#define foreach_current_index(var_or_cell)
#define for_each_cell(cell, lst, initcell)
static ListCell * list_head(const List *l)
#define for_each_from(cell, lst, N)
#define foreach_node(type, var, lst)
#define forfour(cell1, list1, cell2, list2, cell3, list3, cell4, list4)
static void * list_nth(const List *list, int n)
static ListCell * lnext(const List *l, const ListCell *c)
#define forfive(cell1, list1, cell2, list2, cell3, list3, cell4, list4, cell5, list5)
#define list_make2(x1, x2)
#define foreach_int(var, lst)
static int list_cell_number(const List *l, const ListCell *c)
#define lthird_node(type, l)
FormData_pg_opclass * Form_pg_opclass
FormData_pg_operator * Form_pg_operator
FormData_pg_partitioned_table * Form_pg_partitioned_table
FormData_pg_proc * Form_pg_proc
FormData_pg_statistic_ext * Form_pg_statistic_ext
FormData_pg_trigger * Form_pg_trigger
FormData_pg_type * Form_pg_type
void check_stack_depth(void)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Name DatumGetName(Datum X)
static Oid DatumGetObjectId(Datum X)
static Datum ObjectIdGetDatum(Oid X)
static Pointer DatumGetPointer(Datum X)
static char DatumGetChar(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int16 DatumGetInt16(Datum X)
static int32 DatumGetInt32(Datum X)
@ SVFOP_CURRENT_TIMESTAMP
@ SVFOP_CURRENT_TIMESTAMP_N
@ OVERRIDING_SYSTEM_VALUE
@ MERGE_WHEN_NOT_MATCHED_BY_TARGET
@ MERGE_WHEN_NOT_MATCHED_BY_SOURCE
void * stringToNode(const char *str)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
void AcquireRewriteLocks(Query *parsetree, bool forExecute, bool forUpdatePushedDown)
Query * getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr)
#define ViewSelectRuleName
Datum pg_get_triggerdef_ext(PG_FUNCTION_ARGS)
static void make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, int prettyFlags, int wrapColumn)
static void removeStringInfoSpaces(StringInfo str)
static bool looks_like_function(Node *node)
Datum pg_get_partition_constraintdef(PG_FUNCTION_ARGS)
static char * get_rtable_name(int rtindex, deparse_context *context)
Datum pg_get_viewdef_wrap(PG_FUNCTION_ARGS)
static void set_relation_column_names(deparse_namespace *dpns, RangeTblEntry *rte, deparse_columns *colinfo)
static void appendContextKeyword(deparse_context *context, const char *str, int indentBefore, int indentAfter, int indentPlus)
Datum pg_get_indexdef_ext(PG_FUNCTION_ARGS)
static void set_using_names(deparse_namespace *dpns, Node *jtnode, List *parentUsing)
static Plan * find_recursive_union(deparse_namespace *dpns, WorkTableScan *wtscan)
static text * string_to_text(char *str)
static void get_values_def(List *values_lists, deparse_context *context)
char * deparse_expression(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit)
#define PRETTYINDENT_LIMIT
Datum pg_get_viewdef(PG_FUNCTION_ARGS)
static char * make_colname_unique(char *colname, deparse_namespace *dpns, deparse_columns *colinfo)
static void get_json_behavior(JsonBehavior *behavior, deparse_context *context, const char *on)
static const char * get_simple_binary_op_name(OpExpr *expr)
static void get_json_agg_constructor(JsonConstructorExpr *ctor, deparse_context *context, const char *funcname, bool is_json_objectagg)
Datum pg_get_constraintdef(PG_FUNCTION_ARGS)
static void set_deparse_for_query(deparse_namespace *dpns, Query *query, List *parent_namespaces)
static void print_function_trftypes(StringInfo buf, HeapTuple proctup)
void(* rsv_callback)(Node *node, deparse_context *context, void *callback_arg)
char * pg_get_constraintdef_command(Oid constraintId)
#define PRETTYINDENT_JOIN
static bool is_input_argument(int nth, const char *argmodes)
static void get_query_def(Query *query, StringInfo buf, List *parentnamespace, TupleDesc resultDesc, bool colNamesVisible, int prettyFlags, int wrapColumn, int startIndent)
static void get_tablesample_def(TableSampleClause *tablesample, deparse_context *context)
Datum pg_get_functiondef(PG_FUNCTION_ARGS)
Datum pg_get_function_result(PG_FUNCTION_ARGS)
const char * quote_identifier(const char *ident)
Datum pg_get_indexdef(PG_FUNCTION_ARGS)
static void get_sublink_expr(SubLink *sublink, deparse_context *context)
static void get_rte_alias(RangeTblEntry *rte, int varno, bool use_as, deparse_context *context)
Datum pg_get_function_arg_default(PG_FUNCTION_ARGS)
char * generate_opclass_name(Oid opclass)
static void get_parameter(Param *param, deparse_context *context)
Datum pg_get_statisticsobjdef_expressions(PG_FUNCTION_ARGS)
Datum pg_get_ruledef(PG_FUNCTION_ARGS)
static void get_json_table_columns(TableFunc *tf, JsonTablePathScan *scan, deparse_context *context, bool showimplicit)
#define PRETTYFLAG_INDENT
List * deparse_context_for(const char *aliasname, Oid relid)
static void get_column_alias_list(deparse_columns *colinfo, deparse_context *context)
Datum pg_get_statisticsobjdef_columns(PG_FUNCTION_ARGS)
Datum pg_get_statisticsobjdef(PG_FUNCTION_ARGS)
static void simple_quote_literal(StringInfo buf, const char *val)
static bool colname_is_unique(const char *colname, deparse_namespace *dpns, deparse_columns *colinfo)
static void get_from_clause_coldeflist(RangeTblFunction *rtfunc, deparse_columns *colinfo, deparse_context *context)
static void get_from_clause(Query *query, const char *prefix, deparse_context *context)
static void get_basic_select_query(Query *query, deparse_context *context, TupleDesc resultDesc, bool colNamesVisible)
static bool get_func_sql_syntax(FuncExpr *expr, deparse_context *context)
static void get_target_list(List *targetList, deparse_context *context, TupleDesc resultDesc, bool colNamesVisible)
Datum pg_get_partkeydef(PG_FUNCTION_ARGS)
static char * generate_qualified_relation_name(Oid relid)
static void set_simple_column_names(deparse_namespace *dpns)
static void get_json_expr_options(JsonExpr *jsexpr, deparse_context *context, JsonBehaviorType default_behavior)
#define PRETTY_INDENT(context)
static void get_rule_groupingset(GroupingSet *gset, List *targetlist, bool omit_parens, deparse_context *context)
static char * pg_get_indexdef_worker(Oid indexrelid, int colno, const Oid *excludeOps, bool attrsOnly, bool keysOnly, bool showTblSpc, bool inherits, int prettyFlags, bool missing_ok)
static char * pg_get_constraintdef_worker(Oid constraintId, bool fullCommand, int prettyFlags, bool missing_ok)
static void get_rule_expr_funccall(Node *node, deparse_context *context, bool showimplicit)
static void expand_colnames_array_to(deparse_columns *colinfo, int n)
static SubPlan * find_param_generator(Param *param, deparse_context *context, int *column_p)
static void add_cast_to(StringInfo buf, Oid typid)
static void get_special_variable(Node *node, deparse_context *context, void *callback_arg)
static void get_select_query_def(Query *query, deparse_context *context, TupleDesc resultDesc, bool colNamesVisible)
static void get_windowfunc_expr_helper(WindowFunc *wfunc, deparse_context *context, const char *funcname, const char *options, bool is_json_objectagg)
static void get_rule_list_toplevel(List *lst, deparse_context *context, bool showimplicit)
char * pg_get_statisticsobjdef_string(Oid statextid)
static char * pg_get_statisticsobj_worker(Oid statextid, bool columns_only, bool missing_ok)
#define deparse_columns_fetch(rangetable_index, dpns)
static void get_json_constructor(JsonConstructorExpr *ctor, deparse_context *context, bool showimplicit)
static const char *const query_getrulebyoid
static char * generate_function_name(Oid funcid, int nargs, List *argnames, Oid *argtypes, bool has_variadic, bool *use_variadic_p, ParseExprKind special_exprkind)
static void get_json_path_spec(Node *path_spec, deparse_context *context, bool showimplicit)
static void printSubscripts(SubscriptingRef *sbsref, deparse_context *context)
static SubPlan * find_param_generator_initplan(Param *param, Plan *plan, int *column_p)
static void pop_ancestor_plan(deparse_namespace *dpns, deparse_namespace *save_dpns)
char * generate_collation_name(Oid collid)
static void get_rule_expr_paren(Node *node, deparse_context *context, bool showimplicit, Node *parentNode)
bool quote_all_identifiers
static void get_agg_expr(Aggref *aggref, deparse_context *context, Aggref *original_aggref)
static int decompile_column_index_array(Datum column_index_array, Oid relId, StringInfo buf)
static void get_const_collation(Const *constval, deparse_context *context)
static void get_delete_query_def(Query *query, deparse_context *context, bool colNamesVisible)
static SPIPlanPtr plan_getrulebyoid
static void get_json_table_nested_columns(TableFunc *tf, JsonTablePlan *plan, deparse_context *context, bool showimplicit, bool needcomma)
static char * deparse_expression_pretty(Node *expr, List *dpcontext, bool forceprefix, bool showimplicit, int prettyFlags, int startIndent)
Datum pg_get_ruledef_ext(PG_FUNCTION_ARGS)
static void print_function_sqlbody(StringInfo buf, HeapTuple proctup)
static bool has_dangerous_join_using(deparse_namespace *dpns, Node *jtnode)
static Node * get_rule_sortgroupclause(Index ref, List *tlist, bool force_colno, deparse_context *context)
List * select_rtable_names_for_explain(List *rtable, Bitmapset *rels_used)
char * pg_get_partconstrdef_string(Oid partitionId, char *aliasname)
char * quote_qualified_identifier(const char *qualifier, const char *ident)
static char * pg_get_viewdef_worker(Oid viewoid, int prettyFlags, int wrapColumn)
static void push_ancestor_plan(deparse_namespace *dpns, ListCell *ancestor_cell, deparse_namespace *save_dpns)
static SPIPlanPtr plan_getviewrule
char * pg_get_partkeydef_columns(Oid relid, bool pretty)
#define WRAP_COLUMN_DEFAULT
static char * flatten_reloptions(Oid relid)
static text * pg_get_expr_worker(text *expr, Oid relid, int prettyFlags)
List * set_deparse_context_plan(List *dpcontext, Plan *plan, List *ancestors)
static Node * processIndirection(Node *node, deparse_context *context)
static void get_agg_combine_expr(Node *node, deparse_context *context, void *callback_arg)
#define PRETTY_PAREN(context)
Datum pg_get_triggerdef(PG_FUNCTION_ARGS)
Datum pg_get_function_sqlbody(PG_FUNCTION_ARGS)
Datum pg_get_expr(PG_FUNCTION_ARGS)
static char * generate_qualified_type_name(Oid typid)
static void get_xmltable(TableFunc *tf, deparse_context *context, bool showimplicit)
char * pg_get_indexdef_columns_extended(Oid indexrelid, bits16 flags)
static void get_utility_query_def(Query *query, deparse_context *context)
static char * get_relation_name(Oid relid)
Datum pg_get_expr_ext(PG_FUNCTION_ARGS)
char * get_list_partvalue_string(Const *val)
static void get_rule_windowclause(Query *query, deparse_context *context)
static void get_rule_windowspec(WindowClause *wc, List *targetList, deparse_context *context)
static void get_json_returning(JsonReturning *returning, StringInfo buf, bool json_format_by_default)
Datum pg_get_viewdef_name_ext(PG_FUNCTION_ARGS)
static Node * find_param_referent(Param *param, deparse_context *context, deparse_namespace **dpns_p, ListCell **ancestor_cell_p)
static void get_rule_orderby(List *orderList, List *targetList, bool force_colno, deparse_context *context)
static void pop_child_plan(deparse_namespace *dpns, deparse_namespace *save_dpns)
static const char * get_name_for_var_field(Var *var, int fieldno, int levelsup, deparse_context *context)
static void set_join_column_names(deparse_namespace *dpns, RangeTblEntry *rte, deparse_columns *colinfo)
Datum pg_get_constraintdef_ext(PG_FUNCTION_ARGS)
static void set_rtable_names(deparse_namespace *dpns, List *parent_namespaces, Bitmapset *rels_used)
static void get_update_query_targetlist_def(Query *query, List *targetList, deparse_context *context, RangeTblEntry *rte)
static void get_rule_expr(Node *node, deparse_context *context, bool showimplicit)
Datum pg_get_viewdef_ext(PG_FUNCTION_ARGS)
static char * pg_get_partkeydef_worker(Oid relid, int prettyFlags, bool attrsOnly, bool missing_ok)
static void get_oper_expr(OpExpr *expr, deparse_context *context)
char * pg_get_querydef(Query *query, bool pretty)
Datum pg_get_function_identity_arguments(PG_FUNCTION_ARGS)
static char * pg_get_triggerdef_worker(Oid trigid, bool pretty)
#define GET_PRETTY_FLAGS(pretty)
static void get_reloptions(StringInfo buf, Datum reloptions)
static void get_func_expr(FuncExpr *expr, deparse_context *context, bool showimplicit)
static void get_const_expr(Const *constval, deparse_context *context, int showtype)
void generate_operator_clause(StringInfo buf, const char *leftop, Oid leftoptype, Oid opoid, const char *rightop, Oid rightoptype)
static void get_setop_query(Node *setOp, Query *query, deparse_context *context, TupleDesc resultDesc, bool colNamesVisible)
static void make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc, int prettyFlags)
static const char *const query_getviewrule
static char * pg_get_ruledef_worker(Oid ruleoid, int prettyFlags)
static int print_function_arguments(StringInfo buf, HeapTuple proctup, bool print_table_args, bool print_defaults)
static void identify_join_columns(JoinExpr *j, RangeTblEntry *jrte, deparse_columns *colinfo)
char * pg_get_indexdef_columns(Oid indexrelid, bool pretty)
static void print_function_rettype(StringInfo buf, HeapTuple proctup)
static RangeTblEntry * get_simple_values_rte(Query *query, TupleDesc resultDesc)
static void set_deparse_plan(deparse_namespace *dpns, Plan *plan)
static void resolve_special_varno(Node *node, deparse_context *context, rsv_callback callback, void *callback_arg)
static void get_merge_query_def(Query *query, deparse_context *context, bool colNamesVisible)
static void get_json_format(JsonFormat *format, StringInfo buf)
static void get_insert_query_def(Query *query, deparse_context *context, bool colNamesVisible)
static void get_tablefunc(TableFunc *tf, deparse_context *context, bool showimplicit)
static void get_rule_expr_toplevel(Node *node, deparse_context *context, bool showimplicit)
static void get_coercion_expr(Node *arg, deparse_context *context, Oid resulttype, int32 resulttypmod, Node *parentNode)
static void push_child_plan(deparse_namespace *dpns, Plan *plan, deparse_namespace *save_dpns)
static void get_json_constructor_options(JsonConstructorExpr *ctor, StringInfo buf)
char * get_range_partbound_string(List *bound_datums)
static bool isSimpleNode(Node *node, Node *parentNode, int prettyFlags)
static void get_with_clause(Query *query, deparse_context *context)
char * pg_get_indexdef_string(Oid indexrelid)
List * deparse_context_for_plan_tree(PlannedStmt *pstmt, List *rtable_names)
static void get_update_query_def(Query *query, deparse_context *context, bool colNamesVisible)
static char * generate_relation_name(Oid relid, List *namespaces)
static void get_windowfunc_expr(WindowFunc *wfunc, deparse_context *context)
static char * get_variable(Var *var, int levelsup, bool istoplevel, deparse_context *context)
Datum pg_get_serial_sequence(PG_FUNCTION_ARGS)
static char * generate_operator_name(Oid operid, Oid arg1, Oid arg2)
static void get_from_clause_item(Node *jtnode, Query *query, deparse_context *context)
Datum pg_get_function_arguments(PG_FUNCTION_ARGS)
static void get_json_table(TableFunc *tf, deparse_context *context, bool showimplicit)
#define PRETTYFLAG_SCHEMA
static void get_opclass_name(Oid opclass, Oid actual_datatype, StringInfo buf)
Datum pg_get_viewdef_name(PG_FUNCTION_ARGS)
Datum pg_get_userbyid(PG_FUNCTION_ARGS)
static void get_agg_expr_helper(Aggref *aggref, deparse_context *context, Aggref *original_aggref, const char *funcname, const char *options, bool is_json_objectagg)
#define RULE_INDEXDEF_PRETTY
#define RULE_INDEXDEF_KEYS_ONLY
void ScanKeyInit(ScanKey entry, AttrNumber attributeNumber, StrategyNumber strategy, RegProcedure procedure, Datum argument)
Snapshot GetTransactionSnapshot(void)
void UnregisterSnapshot(Snapshot snapshot)
Snapshot RegisterSnapshot(Snapshot snapshot)
int SPI_fnumber(TupleDesc tupdesc, const char *fname)
SPITupleTable * SPI_tuptable
int SPI_execute_plan(SPIPlanPtr plan, Datum *Values, const char *Nulls, bool read_only, long tcount)
SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes)
int SPI_keepplan(SPIPlanPtr plan)
char * SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber)
Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
void relation_close(Relation relation, LOCKMODE lockmode)
Relation try_relation_open(Oid relationId, LOCKMODE lockmode)
Relation relation_open(Oid relationId, LOCKMODE lockmode)
#define BTEqualStrategyNumber
StringInfo makeStringInfo(void)
void resetStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendBinaryStringInfo(StringInfo str, const void *data, int datalen)
void appendStringInfoSpaces(StringInfo str, int count)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
BoolTestType booltesttype
CTEMaterialize ctematerialized
JsonReturning * returning
JsonReturning * returning
NullTestType nulltesttype
PartitionRangeDatumKind kind
Node * mergeJoinCondition
OnConflictExpr * onConflict
struct TableSampleClause * tablesample
LockClauseStrength strength
LockWaitPolicy waitPolicy
Bitmapset * appendparents
ParseExprKind special_exprkind
AppendRelInfo ** appendrels
int16 values[FLEXIBLE_ARRAY_MEMBER]
Oid values[FLEXIBLE_ARRAY_MEMBER]
void ReleaseSysCache(HeapTuple tuple)
HeapTuple SearchSysCache1(int cacheId, Datum key1)
Datum SysCacheGetAttr(int cacheId, HeapTuple tup, AttrNumber attributeNumber, bool *isNull)
Datum SysCacheGetAttrNotNull(int cacheId, HeapTuple tup, AttrNumber attributeNumber)
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
TargetEntry * get_sortgroupref_tle(Index sortref, List *targetList)
int count_nonjunk_tlist_entries(List *tlist)
#define ReleaseTupleDesc(tupdesc)
#define TupleDescAttr(tupdesc, i)
TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)
TypeCacheEntry * lookup_type_cache(Oid type_id, int flags)
String * makeString(char *str)
Relids pull_varnos(PlannerInfo *root, Node *node)
List * textToQualifiedNameList(text *textval)
bool SplitGUCList(char *rawstring, char separator, List **namelist)
char * text_to_cstring(const text *t)
text * cstring_to_text_with_len(const char *s, int len)
text * cstring_to_text(const char *s)
char * map_xml_name_to_sql_identifier(const char *name)
@ XML_STANDALONE_NO_VALUE
static void convert(const int32 val, char *const buf)