57 .
name =
"postgres_fdw",
62#define DEFAULT_FDW_STARTUP_COST 100.0
65#define DEFAULT_FDW_TUPLE_COST 0.2
68#define DEFAULT_FDW_SORT_MULTIPLIER 1.2
372"SELECT pg_catalog.pg_restore_relation_stats(\n"
374"\t'schemaname', $2,\n"
376"\t'relpages', $4::integer,\n"
377"\t'reltuples', $5::real)";
399"SELECT pg_catalog.pg_restore_attribute_stats(\n"
401"\t'schemaname', $2,\n"
404"\t'inherited', false::boolean,\n"
405"\t'null_frac', $5::real,\n"
406"\t'avg_width', $6::integer,\n"
407"\t'n_distinct', $7::real,\n"
408"\t'most_common_vals', $8,\n"
409"\t'most_common_freqs', $9::real[],\n"
410"\t'histogram_bounds', $10,\n"
411"\t'correlation', $11::real,\n"
412"\t'most_common_elems', $12,\n"
413"\t'most_common_elem_freqs', $13::real[],\n"
414"\t'elem_count_histogram', $14::real[],\n"
415"\t'range_length_histogram', $15,\n"
416"\t'range_empty_frac', $16::real,\n"
417"\t'range_bounds_histogram', $17)";
462#define NUM_MAPPED_ATTIMPORT_ARGS 13
483"SELECT pg_catalog.pg_clear_attribute_stats($1, $2, $3, false)";
531 Index resultRelation,
565 Index resultRelation,
627 double retrieved_rows,
649 List *retrieved_attrs);
666 List *returningList);
671 List *fdw_scan_tlist,
682 const char ***param_values);
686 const char **param_values);
731 List *retrieved_attrs,
855 fpinfo->pushdown_safe =
true;
866 fpinfo->use_remote_estimate =
false;
871 fpinfo->async_capable =
false;
882 if (
fpinfo->use_remote_estimate)
936 fpinfo->retrieved_rows = -1;
937 fpinfo->rel_startup_cost = -1;
938 fpinfo->rel_total_cost = -1;
947 if (
fpinfo->use_remote_estimate)
999 fpinfo->make_outerrel_subquery =
false;
1000 fpinfo->make_innerrel_subquery =
false;
1040 foreach(
lc,
root->eq_classes)
1136 fpinfo->qp_is_pushdown_safe =
false;
1137 if (
root->query_pathkeys)
1141 foreach(
lc,
root->query_pathkeys)
1162 fpinfo->qp_is_pushdown_safe =
true;
1175 if (!
fpinfo->use_remote_estimate)
1271 if (!
fpinfo->use_remote_estimate)
1333 if (
baserel->has_eclass_joins)
1355 baserel->lateral_referencers);
1365 foreach(
lc, clauses)
1415 &rows, &width, &disabled_nodes,
1416 &startup_cost, &total_cost);
1460 List *fdw_recheck_quals =
NIL;
1461 List *retrieved_attrs;
1463 bool has_final_sort =
false;
1464 bool has_limit =
false;
1509 if (rinfo->pseudoconstant)
1624 has_final_sort, has_limit,
false,
1625 &retrieved_attrs, ¶ms_list);
1638 fdw_private =
lappend(fdw_private,
1678 for (
int i = 0;
i < tupdesc->
natts;
i++)
1686 if (att->atttypid !=
RECORDOID || att->atttypmod >= 0)
1703 att->atttypid = reltype;
1743 if (
fsplan->scan.scanrelid > 0)
1744 rtindex =
fsplan->scan.scanrelid;
1773 "postgres_fdw tuple data",
1776 "postgres_fdw temporary data",
1783 if (
fsplan->scan.scanrelid > 0)
1898 snprintf(sql,
sizeof(sql),
"CLOSE c%u",
1904 snprintf(sql,
sizeof(sql),
"MOVE BACKWARD ALL IN c%u",
1909 snprintf(sql,
sizeof(sql),
"CLOSE c%u",
1943 if (fsstate ==
NULL)
1993 Index resultRelation,
2055 elog(
ERROR,
"system-column update is not supported");
2063 if (
plan->withCheckOptionLists)
2070 if (
plan->returningLists)
2082 elog(
ERROR,
"unexpected ON CONFLICT specification: %d",
2083 (
int)
plan->onConflictAction);
2141 List *retrieved_attrs;
2270 batch_size =
fmstate->batch_size;
2378 Index resultRelation;
2401 errmsg(
"cannot route tuples into foreign table to be updated \"%s\"",
2424 elog(
ERROR,
"unexpected ON CONFLICT specification: %d",
2425 (
int) onConflictAction);
2480 retrieved_attrs !=
NIL,
2665 Index resultRelation,
2707 if (
fscan->scan.scanrelid == 0)
2714 foreignrel =
root->simple_rel_array[resultRelation];
2715 rte =
root->simple_rte_array[resultRelation];
2742 elog(
ERROR,
"system-column update is not supported");
2770 if (
plan->returningLists)
2783 if (
fscan->scan.scanrelid == 0)
2799 returningList, &retrieved_attrs);
2805 returningList, &retrieved_attrs);
2816 fscan->resultRelation = resultRelation;
2821 fscan->fdw_exprs = params_list;
2835 if (
fscan->scan.scanrelid == 0)
2849 if (
fscan->scan.plan.async_capable)
2850 fscan->scan.plan.async_capable =
false;
2892 if (
fsplan->scan.scanrelid == 0)
2906 if (
fsplan->scan.scanrelid == 0)
2935 "postgres_fdw temporary data",
2943 if (
fsplan->scan.scanrelid == 0)
2955 if (
fsplan->scan.scanrelid == 0)
2963 dmstate->numParams = numParams;
2987 if (
dmstate->num_tuples == -1)
3048 List *fdw_private =
plan->fdw_private;
3080 if (
isdigit((
unsigned char) *ptr))
3082 int rti =
strtol(ptr, &ptr, 10);
3097 if (
isdigit((
unsigned char) *ptr))
3099 int rti =
strtol(ptr, &ptr, 10);
3123 if (refname ==
NULL)
3124 refname =
rte->eref->aliasname;
3230 serverid =
table->serverid;
3233 foreach(cell, server->
options)
3253 foreach(cell,
table->options)
3267 errmsg(
"foreign table \"%s\" does not allow truncates",
3315 double retrieved_rows;
3317 int disabled_nodes = 0;
3331 if (
fpinfo->use_remote_estimate)
3343 List *retrieved_attrs;
3356 fdw_scan_tlist =
NIL;
3374 remote_conds, pathkeys,
3377 false, &retrieved_attrs,
NULL);
3382 &startup_cost, &total_cost);
3385 retrieved_rows = rows;
3398 startup_cost +=
fpinfo->local_conds_cost.startup;
3399 total_cost +=
fpinfo->local_conds_cost.per_tuple * retrieved_rows;
3402 total_cost +=
local_cost.per_tuple * retrieved_rows;
3439 if (
fpinfo->rel_startup_cost >= 0 &&
fpinfo->rel_total_cost >= 0)
3444 retrieved_rows =
fpinfo->retrieved_rows;
3446 startup_cost =
fpinfo->rel_startup_cost;
3447 run_cost =
fpinfo->rel_total_cost -
fpinfo->rel_startup_cost;
3476 rows = foreignrel->
rows;
3493 retrieved_rows =
Min(retrieved_rows, nrows);
3518 startup_cost +=
fpinfo->local_conds_cost.startup;
3537 run_cost += nrows *
join_cost.per_tuple;
3540 run_cost +=
fpinfo->local_conds_cost.per_tuple * retrieved_rows;
3553 double numGroups = 1;
3574 if (
root->parse->hasAggs)
3590 if (
root->hasHavingQual)
3605 rows = retrieved_rows = numGroups;
3618 startup_cost =
ofpinfo->rel_startup_cost;
3620 startup_cost +=
aggcosts.transCost.startup;
3622 startup_cost +=
aggcosts.finalCost.startup;
3634 run_cost +=
aggcosts.finalCost.per_tuple * numGroups;
3638 if (
root->hasHavingQual)
3647 startup_cost +=
fpinfo->local_conds_cost.startup;
3648 run_cost +=
fpinfo->local_conds_cost.per_tuple * retrieved_rows;
3660 rows = foreignrel->
rows;
3668 retrieved_rows =
Min(retrieved_rows, foreignrel->
tuples);
3697 if (pathkeys !=
NIL)
3711 retrieved_rows, width,
3714 &startup_cost, &run_cost);
3723 total_cost = startup_cost + run_cost;
3730 retrieved_rows = rows;
3765 fpinfo->retrieved_rows = retrieved_rows;
3766 fpinfo->rel_startup_cost = startup_cost;
3767 fpinfo->rel_total_cost = total_cost;
3776 startup_cost +=
fpinfo->fdw_startup_cost;
3777 total_cost +=
fpinfo->fdw_startup_cost;
3778 total_cost +=
fpinfo->fdw_tuple_cost * retrieved_rows;
3795 if (!
fpinfo->use_remote_estimate &&
3801 total_cost -= (total_cost - startup_cost) * 0.05 *
3819 double *rows,
int *width,
3820 Cost *startup_cost,
Cost *total_cost)
3842 elog(
ERROR,
"could not interpret EXPLAIN output: \"%s\"", line);
3843 n =
sscanf(p,
"(cost=%lf..%lf rows=%lf width=%d)",
3844 startup_cost, total_cost, rows, width);
3846 elog(
ERROR,
"could not interpret EXPLAIN output: \"%s\"", line);
3857 double retrieved_rows,
3859 double limit_tuples,
3916 Expr *expr =
em->em_expr;
3932 state->current = expr;
4051 snprintf(sql,
sizeof(sql),
"FETCH %d FROM c%u",
4066 for (
i = 0;
i < numrows;
i++)
4181 List *retrieved_attrs)
4216 fmstate->target_attrs = target_attrs;
4217 fmstate->values_end = values_end;
4218 fmstate->has_returning = has_returning;
4219 fmstate->retrieved_attrs = retrieved_attrs;
4223 "postgres_fdw temporary data",
4243 elog(
ERROR,
"could not find junk ctid column");
4259 Assert(!attr->attisdropped);
4262 if (attr->attgenerated)
4312 if (
fmstate->conn_state->pendingAreq)
4623 var->
varno == rtindex &&
4636 for (
i = 1;
i <= tupdesc->
natts;
i++)
4642 if (attr->attisdropped)
4671 var->
varno == rtindex &&
4734 int numParams =
dmstate->numParams;
4738 if (
dmstate->conn_state->pendingAreq)
4848 List *fdw_scan_tlist,
4873 dmstate->hasSystemCols =
false;
4874 foreach(
lc, fdw_scan_tlist)
4885 if (var->
varno == rtindex &&
4899 dmstate->hasSystemCols =
true;
5024 const char ***param_values)
5035 foreach(
lc, fdw_exprs)
5057 *param_values = (
const char **)
palloc0(numParams *
sizeof(
char *));
5067 const char **param_values)
5076 foreach(
lc, param_exprs)
5090 param_values[
i] =
NULL;
5144 elog(
ERROR,
"unexpected result from deparseAnalyzeSizeSql query");
5193 elog(
ERROR,
"unexpected result from deparseAnalyzeInfoSql query");
5237 double reltuples = -1.0;
5246 astate.
rel = relation;
5259 "postgres_fdw temporary data",
5332 errmsg(
"remote server does not support TABLESAMPLE feature")));
5358 if ((reltuples <= 0) || (targrows >= reltuples))
5477 for (
i = 0;
i < numrows;
i++)
5509 (
errmsg(
"\"%s\": table contains %.0f rows, %d rows in sample",
5535 if (astate->
numrows < targrows)
5554 Assert(pos >= 0 && pos < targrows);
5592 const char *schemaname =
NULL;
5646 errmsg(
"cannot import statistics for foreign table \"%s.%s\" --- this foreign table has extended statistics objects",
5655 (
errmsg(
"importing statistics for foreign table \"%s.%s\"",
5668 (
errmsg(
"finished importing statistics for foreign table \"%s.%s\"",
5751 errmsg(
"could not import statistics for foreign table \"%s.%s\" --- remote table \"%s.%s\" is of relkind \"%c\" which cannot have statistics",
5777 errmsg(
"could not import statistics for foreign table \"%s.%s\" --- remote table \"%s.%s\" has no relation statistics to import",
5834 elog(
ERROR,
"unexpected result from deparseAnalyzeInfoSql query");
5852 "SELECT DISTINCT ON (attname COLLATE \"C\") attname,"
5856 " most_common_vals,"
5857 " most_common_freqs,"
5858 " histogram_bounds,"
5864 " most_common_elems,"
5865 " most_common_elem_freqs,"
5866 " elem_count_histogram,");
5869 " NULL, NULL, NULL,");
5874 " range_length_histogram,"
5875 " range_empty_frac,"
5876 " range_bounds_histogram");
5879 " NULL, NULL, NULL,");
5882 " FROM pg_catalog.pg_stats"
5883 " WHERE schemaname = ");
5886 " AND tablename = ");
5889 " AND attname = ANY('%s'::text[])",
5895 " ORDER BY attname COLLATE \"C\", inherited DESC");
5898 " ORDER BY attname COLLATE \"C\"");
5905 elog(
ERROR,
"unexpected result from fetch_attstats query");
5925 for (
int i = 0;
i < tupdesc->
natts;
i++)
5930 char *remote_attname;
5988 foreach(
lc, va_cols)
6036 errmsg(
"could not import statistics for foreign table \"%s.%s\" --- remote table \"%s.%s\" has no attribute statistics to import",
6061 if (row >= numrows - 1)
6064 errmsg(
"could not import statistics for foreign table \"%s.%s\" --- no attribute statistics found for column \"%s\" of remote table \"%s.%s\"",
6082 errmsg(
"could not import statistics for foreign table \"%s.%s\" --- no attribute statistics found for column \"%s\" of remote table \"%s.%s\"",
6092 elog(
ERROR,
"unexpected result from fetch_attstats query");
6101 if (row < numrows - 1)
6102 elog(
ERROR,
"unexpected result from fetch_attstats query");
6149 elog(
ERROR,
"failed to prepare attimport_sql query");
6154 elog(
ERROR,
"failed to prepare attclear_sql query");
6162 char *
nulls2 = nulls + 1;
6184 elog(
ERROR,
"failed to execute attclear_sql query for column \"%s\" of foreign table \"%s.%s\"",
6199 elog(
ERROR,
"failed to execute attimport_sql query for column \"%s\" of foreign table \"%s.%s\"",
6205 errmsg(
"could not import statistics for foreign table \"%s.%s\" --- attribute statistics import failed for column \"%s\" of this foreign table",
6231 values, nulls,
false, 1);
6233 elog(
ERROR,
"failed to execute relimport_sql query for foreign table \"%s.%s\"",
6239 errmsg(
"could not import statistics for foreign table \"%s.%s\" --- relation statistics import failed for this foreign table",
6319 foreach(
lc,
stmt->options)
6363 errmsg(
"schema \"%s\" is not present on foreign server \"%s\"",
6389 " format_type(atttypid, atttypmod), "
6391 " pg_get_expr(adbin, adrelid), ");
6404 " collnsp.nspname ");
6411 " JOIN pg_namespace n ON "
6412 " relnamespace = n.oid "
6413 " LEFT JOIN pg_attribute a ON "
6414 " attrelid = c.oid AND attnum > 0 "
6415 " AND NOT attisdropped "
6416 " LEFT JOIN pg_attrdef ad ON "
6417 " adrelid = c.oid AND adnum = attnum ");
6421 " LEFT JOIN pg_collation coll ON "
6422 " coll.oid = attcollation "
6423 " LEFT JOIN pg_namespace collnsp ON "
6424 " collnsp.oid = collnamespace ");
6427 "WHERE c.relkind IN ("
6433 " AND n.nspname = ");
6445 bool first_item =
true;
6453 foreach(
lc,
stmt->table_list)
6477 for (
i = 0;
i < numrows;)
6480 bool first_item =
true;
6539 (!attgenerated || !attgenerated[0]))
6548 " GENERATED ALWAYS AS (%s) STORED",
6556 while (++
i < numrows &&
6709 joinclauses =
lappend(joinclauses, rinfo);
6730 foreach(
lc,
root->placeholder_list)
6745 fpinfo->joinclauses = joinclauses;
6747 fpinfo->outerrel = outerrel;
6748 fpinfo->innerrel = innerrel;
6749 fpinfo->jointype = jointype;
6757 fpinfo->make_outerrel_subquery =
false;
6758 fpinfo->make_innerrel_subquery =
false;
6852 fpinfo->make_outerrel_subquery =
true;
6853 fpinfo->lower_subquery_rels =
6859 fpinfo->make_innerrel_subquery =
true;
6860 fpinfo->lower_subquery_rels =
6868 elog(
ERROR,
"unsupported join type %d", jointype);
6890 fpinfo->make_outerrel_subquery =
true;
6896 fpinfo->make_innerrel_subquery =
true;
6902 fpinfo->pushdown_safe =
true;
6905 if (
fpinfo->use_remote_estimate)
6920 fpinfo->retrieved_rows = -1;
6921 fpinfo->rel_startup_cost = -1;
6922 fpinfo->rel_total_cost = -1;
7018 &rows, &width, &disabled_nodes,
7019 &startup_cost, &total_cost);
7076 foreach(
lc,
fpinfo->server->options)
7089 fpinfo->shippable_extensions =
7108 foreach(
lc,
fpinfo->table->options)
7212 if (joinrel->fdw_private)
7230 fpinfo->pushdown_safe =
false;
7231 joinrel->fdw_private =
fpinfo;
7252 elog(
DEBUG3,
"could not push down foreign join because a local path suitable for EPQ checks was not found");
7286 if (!
fpinfo->use_remote_estimate)
7293 &rows, &width, &disabled_nodes,
7294 &startup_cost, &total_cost);
7296 joinrel->
rows = rows;
7300 fpinfo->disabled_nodes = disabled_nodes;
7301 fpinfo->startup_cost = startup_cost;
7302 fpinfo->total_cost = total_cost;
7479 foreach(
lc, (
List *) havingQual)
7495 root->qual_security_level,
7545 fpinfo->grouped_tlist = tlist;
7548 fpinfo->pushdown_safe =
true;
7555 fpinfo->retrieved_rows = -1;
7556 fpinfo->rel_startup_cost = -1;
7557 fpinfo->rel_total_cost = -1;
7599 fpinfo->pushdown_safe =
false;
7617 elog(
ERROR,
"unexpected upper relation: %d", (
int) stage);
7646 !
root->hasHavingQual)
7691 &rows, &width, &disabled_nodes,
7692 &startup_cost, &total_cost);
7697 fpinfo->disabled_nodes = disabled_nodes;
7698 fpinfo->startup_cost = startup_cost;
7699 fpinfo->total_cost = total_cost;
7746 if (
parse->hasTargetSRFs)
7790 foreach(
lc,
root->sort_pathkeys)
7820 fpinfo->pushdown_safe =
true;
7825 fpextra->has_final_sort =
true;
7829 &rows, &width, &disabled_nodes,
7830 &startup_cost, &total_cost);
7846 root->sort_pathkeys,
7871 bool has_final_sort =
false;
7897 if (
parse->hasTargetSRFs)
7975 fpinfo->pushdown_safe =
true;
8000 has_final_sort =
true;
8001 pathkeys =
root->sort_pathkeys;
8054 fpinfo->pushdown_safe =
true;
8059 fpextra->has_final_sort = has_final_sort;
8077 ifpinfo->use_remote_estimate =
false;
8080 &rows, &width, &disabled_nodes,
8081 &startup_cost, &total_cost);
8122 return fpinfo->async_capable;
8159 if (
areq->request_complete)
8274 if (fetch && !pendingAreq)
8305 if (fetch && !pendingAreq)
8339 snprintf(sql,
sizeof(sql),
"FETCH %d FROM c%u",
8374 areq->callback_pending =
false;
8392 areq->callback_pending =
false;
8401 if (
areq->requestee->instrument)
8424 List *retrieved_attrs,
8461 nulls = (
bool *)
palloc(tupdesc->
natts *
sizeof(
bool));
8463 memset(nulls,
true, tupdesc->
natts *
sizeof(
bool));
8470 errpos.fsstate = fsstate;
8480 foreach(
lc, retrieved_attrs)
8532 elog(
ERROR,
"remote query result does not match the foreign table");
8598 if (
fsplan->scan.scanrelid > 0)
8601 varno =
fsplan->scan.scanrelid;
8602 colno =
errpos->cur_attno;
8663 errcontext(
"processing expression at position %d in select list",
8752 if (
em->em_is_const)
8759 em_expr =
em->em_expr;
8763 if (!
equal(em_expr, expr))
void get_translated_update_targetlist(PlannerInfo *root, Index relid, List **processed_tlist, List **update_colnos)
void add_row_identity_var(PlannerInfo *root, Var *orig_var, Index rtindex, const char *rowid_name)
#define AttributeNumberIsValid(attributeNumber)
#define InvalidAttrNumber
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
int bms_next_member(const Bitmapset *a, int prevbit)
Bitmapset * bms_del_member(Bitmapset *a, int x)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
static Datum values[MAXATTR]
#define CStringGetTextDatum(s)
#define Assert(condition)
#define OidIsValid(objectId)
Selectivity clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
bool attribute_is_analyzable(Relation onerel, int attnum, Form_pg_attribute attr, int *p_attstattarget)
unsigned int GetCursorNumber(PGconn *conn)
void do_sql_command(PGconn *conn, const char *sql)
PGresult * pgfdw_exec_query(PGconn *conn, const char *query, PgFdwConnState *state)
void ReleaseConnection(PGconn *conn)
PGresult * pgfdw_get_result(PGconn *conn)
void pgfdw_report_error(PGresult *res, PGconn *conn, const char *sql)
static unsigned int cursor_number
unsigned int GetPrepStmtNumber(PGconn *conn)
List * ExtractExtensionList(const char *extensionsString, bool warnOnMissing)
void set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void cost_sort(Path *path, PlannerInfo *root, List *pathkeys, int input_disabled_nodes, Cost input_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root)
double clamp_row_est(double nrows)
bool is_projection_capable_path(Path *path)
ForeignScan * make_foreignscan(List *qptlist, List *qpqual, Index scanrelid, List *fdw_exprs, List *fdw_private, List *fdw_scan_tlist, List *fdw_recheck_quals, Plan *outer_plan)
Plan * change_plan_targetlist(Plan *subplan, List *tlist, bool tlist_parallel_safe)
static DataChecksumsWorkerOperation operation
char * defGetString(DefElem *def)
bool defGetBoolean(DefElem *def)
void deparseAnalyzeSizeSql(StringInfo buf, Relation rel)
const char * get_jointype_name(JoinType jointype)
void deparseAnalyzeInfoSql(StringInfo buf, Relation rel)
void deparseDirectDeleteSql(StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, RelOptInfo *foreignrel, List *remote_conds, List **params_list, List *returningList, List **retrieved_attrs)
void deparseDirectUpdateSql(StringInfo buf, PlannerInfo *root, Index rtindex, Relation rel, RelOptInfo *foreignrel, List *targetlist, List *targetAttrs, List *remote_conds, List **params_list, List *returningList, List **retrieved_attrs)
bool is_foreign_param(PlannerInfo *root, RelOptInfo *baserel, Expr *expr)
void deparseSelectStmtForRel(StringInfo buf, PlannerInfo *root, RelOptInfo *rel, List *tlist, List *remote_conds, List *pathkeys, bool has_final_sort, bool has_limit, bool is_subquery, List **retrieved_attrs, List **params_list)
void deparseStringLiteral(StringInfo buf, const char *val)
void rebuildInsertSql(StringInfo buf, Relation rel, char *orig_query, List *target_attrs, int values_end_len, int num_params, int num_rows)
void deparseInsertSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs, bool doNothing, List *withCheckOptionList, List *returningList, List **retrieved_attrs, int *values_end_len)
void deparseUpdateSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *targetAttrs, List *withCheckOptionList, List *returningList, List **retrieved_attrs)
void deparseDeleteSql(StringInfo buf, RangeTblEntry *rte, Index rtindex, Relation rel, List *returningList, List **retrieved_attrs)
void deparseAnalyzeSql(StringInfo buf, Relation rel, PgFdwSamplingMethod sample_method, double sample_frac, List **retrieved_attrs)
bool is_foreign_expr(PlannerInfo *root, RelOptInfo *baserel, Expr *expr)
void classifyConditions(PlannerInfo *root, RelOptInfo *baserel, List *input_conds, List **remote_conds, List **local_conds)
void deparseTruncateSql(StringInfo buf, List *rels, DropBehavior behavior, bool restart_seqs)
bool is_foreign_pathkey(PlannerInfo *root, RelOptInfo *baserel, PathKey *pathkey)
List * build_tlist_to_deparse(RelOptInfo *foreignrel)
ErrorContextCallback * error_context_stack
int errcode(int sqlerrcode)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
void setup_eclass_member_iterator(EquivalenceMemberIterator *it, EquivalenceClass *ec, Relids child_relids)
List * generate_implied_equalities_for_column(PlannerInfo *root, RelOptInfo *rel, ec_matches_callback_type callback, void *callback_arg, Relids prohibited_rels)
EquivalenceMember * eclass_member_iterator_next(EquivalenceMemberIterator *it)
bool eclass_useful_for_merging(PlannerInfo *root, EquivalenceClass *eclass, RelOptInfo *rel)
void ExecAsyncResponse(AsyncRequest *areq)
void ExecAsyncRequestPending(AsyncRequest *areq)
void ExecAsyncRequestDone(AsyncRequest *areq, TupleTableSlot *result)
List * ExecInitExprList(List *nodes, PlanState *parent)
AttrNumber ExecFindJunkAttributeInTlist(List *targetlist, const char *attrName)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
TupleTableSlot * ExecStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
void ExecForceStoreHeapTuple(HeapTuple tuple, TupleTableSlot *slot, bool shouldFree)
TupleTableSlot * ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo)
Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)
Oid ExecGetResultRelCheckAsUser(ResultRelInfo *relInfo, EState *estate)
#define outerPlanState(node)
static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)
static TupleTableSlot * ExecProcNode(PlanState *node)
static Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
#define EXEC_FLAG_EXPLAIN_ONLY
static Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
bool HasRelationExtStatistics(Relation onerel)
int(* AcquireSampleRowsFunc)(Relation relation, int elevel, HeapTuple *rows, int targrows, double *totalrows, double *totaldeadrows)
int PQserverVersion(const PGconn *conn)
int PQsocket(const PGconn *conn)
int PQsendQueryParams(PGconn *conn, const char *command, int nParams, const Oid *paramTypes, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
int PQconsumeInput(PGconn *conn)
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
int PQsendQuery(PGconn *conn, const char *query)
int PQsendQueryPrepared(PGconn *conn, const char *stmtName, int nParams, const char *const *paramValues, const int *paramLengths, const int *paramFormats, int resultFormat)
#define palloc_array(type, count)
#define palloc0_array(type, count)
#define palloc0_object(type)
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
char * OutputFunctionCall(FmgrInfo *flinfo, Datum val)
#define PG_MODULE_MAGIC_EXT(...)
#define DirectFunctionCall1(func, arg1)
#define PG_FUNCTION_INFO_V1(funcname)
#define PG_RETURN_POINTER(x)
ForeignTable * GetForeignTable(Oid relid)
Path * GetExistingLocalJoinPath(RelOptInfo *joinrel)
UserMapping * GetUserMapping(Oid userid, Oid serverid)
ForeignServer * GetForeignServer(Oid serverid)
List * GetForeignColumnOptions(Oid relid, AttrNumber attnum)
bool parse_int(const char *value, int *result, int flags, const char **hintmsg)
int NewGUCNestLevel(void)
bool parse_real(const char *value, double *result, int flags, const char **hintmsg)
void AtEOXact_GUC(bool isCommit, int nestLevel)
int set_config_option(const char *name, const char *value, GucContext context, GucSource source, GucAction action, bool changeVal, int elevel, bool is_reload)
static int server_version_num
HeapTuple heap_form_tuple(TupleDesc tupleDescriptor, const Datum *values, const bool *isnull)
void heap_freetuple(HeapTuple htup)
#define SizeofHeapTupleHeader
static void HeapTupleHeaderSetCmin(HeapTupleHeaderData *tup, CommandId cid)
static void HeapTupleHeaderSetXmin(HeapTupleHeaderData *tup, TransactionId xid)
static void HeapTupleHeaderSetXmax(HeapTupleHeaderData *tup, TransactionId xid)
Bitmapset * get_rel_all_updated_cols(PlannerInfo *root, RelOptInfo *rel)
void InstrUpdateTupleCount(NodeInstrumentation *instr, double nTuples)
ItemPointerData * ItemPointer
static libpqsrv_PGresult * libpqsrv_PGresultSetParent(libpqsrv_PGresult *bres, MemoryContext ctx)
#define PQ_QUERY_PARAM_MAX_LIMIT
List * lappend(List *list, void *datum)
List * list_delete(List *list, void *datum)
List * list_concat(List *list1, const List *list2)
List * list_copy(const List *oldlist)
List * lappend_int(List *list, int datum)
bool list_member_ptr(const List *list, const void *datum)
void list_free(List *list)
bool list_member_int(const List *list, int datum)
bool list_member(const List *list, const void *datum)
List * list_append_unique_ptr(List *list, void *datum)
char * get_rel_name(Oid relid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Oid get_rel_namespace(Oid relid)
Oid get_rel_type_id(Oid relid)
char * get_namespace_name_or_temp(Oid nspid)
char * get_namespace_name(Oid nspid)
Datum subpath(PG_FUNCTION_ARGS)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
void MemoryContextReset(MemoryContext context)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
MemoryContext GetMemoryChunkContext(void *pointer)
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
#define ALLOCSET_SMALL_SIZES
#define CHECK_FOR_INTERRUPTS()
#define INTSTYLE_POSTGRES
Oid exprType(const Node *expr)
#define IsA(nodeptr, _type_)
#define IS_OUTER_JOIN(jointype)
#define castNode(_type_, nodeptr)
#define PVC_RECURSE_PLACEHOLDERS
#define PVC_INCLUDE_PLACEHOLDERS
#define PVC_INCLUDE_AGGREGATES
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
@ FDW_IMPORT_SCHEMA_LIMIT_TO
@ FDW_IMPORT_SCHEMA_EXCEPT
#define rt_fetch(rangetable_index, rangetable)
PathKey * make_canonical_pathkey(PlannerInfo *root, EquivalenceClass *eclass, Oid opfamily, CompareType cmptype, bool nulls_first)
void update_mergeclause_eclasses(PlannerInfo *root, RestrictInfo *restrictinfo)
bool pathkeys_contained_in(List *keys1, List *keys2)
ForeignPath * create_foreign_upper_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, int disabled_nodes, Cost startup_cost, Cost total_cost, List *pathkeys, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
ProjectionPath * create_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
SortPath * create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, double limit_tuples)
ForeignPath * create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, int disabled_nodes, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
ForeignPath * create_foreign_join_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, int disabled_nodes, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
void add_path(RelOptInfo *parent_rel, Path *new_path)
void adjust_limit_rows_costs(double *rows, Cost *startup_cost, Cost *total_cost, int64 offset_est, int64 count_est)
#define RINFO_IS_PUSHED_DOWN(rinfo, joinrelids)
@ PARTITIONWISE_AGGREGATE_FULL
@ PARTITIONWISE_AGGREGATE_NONE
#define IS_SIMPLE_REL(rel)
#define get_pathtarget_sortgroupref(target, colno)
#define planner_rt_fetch(rti, root)
#define IS_OTHER_REL(rel)
#define IS_UPPER_REL(rel)
FormData_pg_attribute * Form_pg_attribute
#define lfirst_node(type, lc)
static int list_length(const List *l)
#define forboth(cell1, list1, cell2, list2)
#define list_make5(x1, x2, x3, x4, x5)
static void * list_nth(const List *list, int n)
#define list_make3(x1, x2, x3)
#define list_nth_node(type, list, n)
#define list_make2(x1, x2)
#define list_make4(x1, x2, x3, x4)
static const struct lconv_member_info table[]
static char buf[DEFAULT_XLOG_SEG_SIZE]
#define qsort(a, b, c, d)
static bool DatumGetBool(Datum X)
static Datum PointerGetDatum(const void *X)
static Datum Int16GetDatum(int16 X)
static Pointer DatumGetPointer(Datum X)
static Datum CStringGetDatum(const char *X)
static Datum Int32GetDatum(int32 X)
static int postgresGetForeignModifyBatchSize(ResultRelInfo *resultRelInfo)
#define DEFAULT_FDW_SORT_MULTIPLIER
static const char ** convert_prep_stmt_params(PgFdwModifyState *fmstate, ItemPointer tupleid, TupleTableSlot **slots, int numSlots)
static TupleTableSlot * apply_returning_filter(PgFdwDirectModifyState *dmstate, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
static bool postgresImportForeignStatistics(Relation relation, List *va_cols, int elevel)
static bool foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinPathExtraData *extra)
static const char * attimport_sql
static void postgresBeginForeignScan(ForeignScanState *node, int eflags)
static bool postgresIsForeignPathAsyncCapable(ForeignPath *path)
static void store_returning_result(PgFdwModifyState *fmstate, TupleTableSlot *slot, PGresult *res)
static void create_cursor(ForeignScanState *node)
static void postgresExecForeignTruncate(List *rels, DropBehavior behavior, bool restart_seqs)
static void postgresExplainForeignModify(ModifyTableState *mtstate, ResultRelInfo *rinfo, List *fdw_private, int subplan_index, ExplainState *es)
static void analyze_row_processor(PGresult *res, int row, PgFdwAnalyzeState *astate)
static TupleTableSlot ** postgresExecForeignBatchInsert(EState *estate, ResultRelInfo *resultRelInfo, TupleTableSlot **slots, TupleTableSlot **planSlots, int *numSlots)
static void deallocate_query(PgFdwModifyState *fmstate)
static void postgresGetForeignJoinPaths(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinType jointype, JoinPathExtraData *extra)
static void postgresExplainForeignScan(ForeignScanState *node, ExplainState *es)
static TupleDesc get_tupdesc_for_join_scan_tuples(ForeignScanState *node)
static TupleTableSlot * postgresExecForeignUpdate(EState *estate, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, TupleTableSlot *planSlot)
@ ATTCLEAR_SQL_SCHEMANAME
@ ATTCLEAR_SQL_NUM_FIELDS
static bool postgresPlanDirectModify(PlannerInfo *root, ModifyTable *plan, Index resultRelation, int subplan_index)
static void conversion_error_callback(void *arg)
static const Oid relimport_argtypes[RELIMPORT_SQL_NUM_FIELDS]
static bool import_spi_query_ok(void)
static void postgresReScanForeignScan(ForeignScanState *node)
static void prepare_foreign_modify(PgFdwModifyState *fmstate)
static void postgresForeignAsyncRequest(AsyncRequest *areq)
static int postgresIsForeignRelUpdatable(Relation rel)
void reset_transmission_modes(int nestlevel)
int set_transmission_modes(void)
static double postgresGetAnalyzeInfoForForeignTable(Relation relation, bool *can_tablesample)
static RemoteAttributeMapping * build_remattrmap(Relation relation, List *va_cols, int *p_attrcnt, StringInfo column_list)
FdwDirectModifyPrivateIndex
@ FdwDirectModifyPrivateSetProcessed
@ FdwDirectModifyPrivateHasReturning
@ FdwDirectModifyPrivateRetrievedAttrs
@ FdwDirectModifyPrivateUpdateSql
static void rebuild_fdw_scan_tlist(ForeignScan *fscan, List *tlist)
static ForeignScan * postgresGetForeignPlan(PlannerInfo *root, RelOptInfo *foreignrel, Oid foreigntableid, ForeignPath *best_path, List *tlist, List *scan_clauses, Plan *outer_plan)
static void postgresEndForeignScan(ForeignScanState *node)
static void postgresGetForeignPaths(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid)
static void add_foreign_grouping_paths(PlannerInfo *root, RelOptInfo *input_rel, RelOptInfo *grouped_rel, GroupPathExtraData *extra)
static List * postgresPlanForeignModify(PlannerInfo *root, ModifyTable *plan, Index resultRelation, int subplan_index)
static const AttrResultArgMap attr_result_arg_map[NUM_MAPPED_ATTIMPORT_ARGS]
static void estimate_path_cost_size(PlannerInfo *root, RelOptInfo *foreignrel, List *param_join_conds, List *pathkeys, PgFdwPathExtraData *fpextra, double *p_rows, int *p_width, int *p_disabled_nodes, Cost *p_startup_cost, Cost *p_total_cost)
static void fetch_more_data(ForeignScanState *node)
static void prepare_query_params(PlanState *node, List *fdw_exprs, int numParams, FmgrInfo **param_flinfo, List **param_exprs, const char ***param_values)
static void postgresEndForeignModify(EState *estate, ResultRelInfo *resultRelInfo)
static void produce_tuple_asynchronously(AsyncRequest *areq, bool fetch)
static ForeignScan * find_modifytable_subplan(PlannerInfo *root, ModifyTable *plan, Index rtindex, int subplan_index)
static void add_foreign_ordered_paths(PlannerInfo *root, RelOptInfo *input_rel, RelOptInfo *ordered_rel)
static bool semijoin_target_ok(PlannerInfo *root, RelOptInfo *joinrel, RelOptInfo *outerrel, RelOptInfo *innerrel)
static bool attname_in_list(const char *attname, List *va_cols)
static void merge_fdw_options(PgFdwRelationInfo *fpinfo, const PgFdwRelationInfo *fpinfo_o, const PgFdwRelationInfo *fpinfo_i)
static void map_field_to_arg(PGresult *res, int row, int field, int arg, Datum *values, char *nulls)
static void postgresAddForeignUpdateTargets(PlannerInfo *root, Index rtindex, RangeTblEntry *target_rte, Relation target_relation)
static void postgresGetForeignRelSize(PlannerInfo *root, RelOptInfo *baserel, Oid foreigntableid)
static HeapTuple make_tuple_from_result_row(PGresult *res, int row, Relation rel, AttInMetadata *attinmeta, List *retrieved_attrs, ForeignScanState *fsstate, MemoryContext temp_context)
static void postgresEndDirectModify(ForeignScanState *node)
static void get_remote_estimate(const char *sql, PGconn *conn, double *rows, int *width, Cost *startup_cost, Cost *total_cost)
static void postgresForeignAsyncConfigureWait(AsyncRequest *areq)
static const Oid attimport_argtypes[ATTIMPORT_SQL_NUM_FIELDS]
static PGresult * fetch_attstats(PGconn *conn, int server_version_num, const char *remote_schemaname, const char *remote_relname, const char *column_list)
EquivalenceMember * find_em_for_rel_target(PlannerInfo *root, EquivalenceClass *ec, RelOptInfo *rel)
static void postgresGetForeignUpperPaths(PlannerInfo *root, UpperRelationKind stage, RelOptInfo *input_rel, RelOptInfo *output_rel, void *extra)
static void apply_server_options(PgFdwRelationInfo *fpinfo)
static void close_cursor(PGconn *conn, unsigned int cursor_number, PgFdwConnState *conn_state)
@ FdwPathPrivateHasFinalSort
static int get_batch_size_option(Relation rel)
static void postgresForeignAsyncNotify(AsyncRequest *areq)
static void adjust_foreign_grouping_path_cost(PlannerInfo *root, List *pathkeys, double retrieved_rows, double width, double limit_tuples, int *p_disabled_nodes, Cost *p_startup_cost, Cost *p_run_cost)
static void add_foreign_final_paths(PlannerInfo *root, RelOptInfo *input_rel, RelOptInfo *final_rel, FinalPathExtraData *extra)
static void fetch_more_data_begin(AsyncRequest *areq)
static void execute_dml_stmt(ForeignScanState *node)
static TupleTableSlot * postgresIterateForeignScan(ForeignScanState *node)
static TupleTableSlot * postgresExecForeignDelete(EState *estate, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, TupleTableSlot *planSlot)
#define NUM_MAPPED_ATTIMPORT_ARGS
static int remattrmap_cmp(const void *v1, const void *v2)
static bool foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel, Node *havingQual)
static const char * relimport_sql
@ FdwScanPrivateRetrievedAttrs
@ FdwScanPrivateSelectSql
@ FdwScanPrivateFetchSize
@ FdwScanPrivateRelations
static bool ec_member_matches_foreign(PlannerInfo *root, RelOptInfo *rel, EquivalenceClass *ec, EquivalenceMember *em, void *arg)
@ FdwModifyPrivateUpdateSql
@ FdwModifyPrivateTargetAttnums
@ FdwModifyPrivateRetrievedAttrs
@ FdwModifyPrivateHasReturning
static TupleTableSlot ** execute_foreign_modify(EState *estate, ResultRelInfo *resultRelInfo, CmdType operation, TupleTableSlot **slots, TupleTableSlot **planSlots, int *numSlots)
static PgFdwModifyState * create_foreign_modify(EState *estate, RangeTblEntry *rte, ResultRelInfo *resultRelInfo, CmdType operation, Plan *subplan, char *query, List *target_attrs, int values_end, bool has_returning, List *retrieved_attrs)
static void add_paths_with_pathkeys_for_rel(PlannerInfo *root, RelOptInfo *rel, Path *epq_path, List *restrictlist)
static bool postgresRecheckForeignScan(ForeignScanState *node, TupleTableSlot *slot)
static List * postgresImportForeignSchema(ImportForeignSchemaStmt *stmt, Oid serverOid)
static void complete_pending_request(AsyncRequest *areq)
static const char * attclear_sql
static PGresult * fetch_relstats(PGconn *conn, Relation relation)
static bool postgresAnalyzeForeignTable(Relation relation, AcquireSampleRowsFunc *func, BlockNumber *totalpages)
static List * build_remote_returning(Index rtindex, Relation rel, List *returningList)
static TupleTableSlot * get_returning_data(ForeignScanState *node)
@ ATTSTATS_HISTOGRAM_BOUNDS
@ ATTSTATS_MOST_COMMON_ELEM_FREQS
@ ATTSTATS_MOST_COMMON_VALS
@ ATTSTATS_MOST_COMMON_ELEMS
@ ATTSTATS_ELEM_COUNT_HISTOGRAM
@ ATTSTATS_RANGE_LENGTH_HISTOGRAM
@ ATTSTATS_MOST_COMMON_FREQS
@ ATTSTATS_RANGE_BOUNDS_HISTOGRAM
@ ATTSTATS_RANGE_EMPTY_FRAC
void process_pending_request(AsyncRequest *areq)
#define DEFAULT_FDW_TUPLE_COST
static bool match_attrmap(PGresult *res, const char *local_schemaname, const char *local_relname, const char *remote_schemaname, const char *remote_relname, int attrcnt, RemoteAttributeMapping *remattrmap)
static void postgresBeginForeignModify(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo, List *fdw_private, int subplan_index, int eflags)
@ ATTIMPORT_SQL_MOST_COMMON_VALS
@ ATTIMPORT_SQL_RANGE_BOUNDS_HISTOGRAM
@ ATTIMPORT_SQL_MOST_COMMON_ELEM_FREQS
@ ATTIMPORT_SQL_SCHEMANAME
@ ATTIMPORT_SQL_ELEM_COUNT_HISTOGRAM
@ ATTIMPORT_SQL_MOST_COMMON_ELEMS
@ ATTIMPORT_SQL_N_DISTINCT
@ ATTIMPORT_SQL_HISTOGRAM_BOUNDS
@ ATTIMPORT_SQL_RANGE_EMPTY_FRAC
@ ATTIMPORT_SQL_RANGE_LENGTH_HISTOGRAM
@ ATTIMPORT_SQL_NULL_FRAC
@ ATTIMPORT_SQL_AVG_WIDTH
@ ATTIMPORT_SQL_NUM_FIELDS
@ ATTIMPORT_SQL_MOST_COMMON_FREQS
@ ATTIMPORT_SQL_CORRELATION
static void process_query_params(ExprContext *econtext, FmgrInfo *param_flinfo, List *param_exprs, const char **param_values)
static bool import_fetched_statistics(const char *schemaname, const char *relname, int attrcnt, const RemoteAttributeMapping *remattrmap, RemoteStatsResults *remstats)
static void postgresBeginForeignInsert(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo)
static const Oid attclear_argtypes[ATTCLEAR_SQL_NUM_FIELDS]
@ RELIMPORT_SQL_SCHEMANAME
@ RELIMPORT_SQL_RELTUPLES
@ RELIMPORT_SQL_NUM_FIELDS
static void init_returning_filter(PgFdwDirectModifyState *dmstate, List *fdw_scan_tlist, Index rtindex)
static TupleTableSlot * postgresIterateDirectModify(ForeignScanState *node)
static void postgresBeginDirectModify(ForeignScanState *node, int eflags)
static List * get_useful_pathkeys_for_relation(PlannerInfo *root, RelOptInfo *rel)
Datum postgres_fdw_handler(PG_FUNCTION_ARGS)
static TupleTableSlot * postgresExecForeignInsert(EState *estate, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, TupleTableSlot *planSlot)
static void apply_table_options(PgFdwRelationInfo *fpinfo)
static int postgresAcquireSampleRowsFunc(Relation relation, int elevel, HeapTuple *rows, int targrows, double *totalrows, double *totaldeadrows)
static void postgresEndForeignInsert(EState *estate, ResultRelInfo *resultRelInfo)
static bool fetch_remote_statistics(Relation relation, List *va_cols, ForeignTable *table, const char *local_schemaname, const char *local_relname, int *p_attrcnt, RemoteAttributeMapping **p_remattrmap, RemoteStatsResults *remstats)
EquivalenceMember * find_em_for_rel(PlannerInfo *root, EquivalenceClass *ec, RelOptInfo *rel)
static void postgresExplainDirectModify(ForeignScanState *node, ExplainState *es)
#define DEFAULT_FDW_STARTUP_COST
static List * get_useful_ecs_for_relation(PlannerInfo *root, RelOptInfo *rel)
static void finish_foreign_modify(PgFdwModifyState *fmstate)
bool is_shippable(Oid objectId, Oid classId, PgFdwRelationInfo *fpinfo)
@ ANALYZE_SAMPLE_BERNOULLI
void get_agg_clause_costs(PlannerInfo *root, AggSplit aggsplit, AggClauseCosts *costs)
char * psprintf(const char *fmt,...)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
#define RelationGetNamespace(relation)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
ParamPathInfo * get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, Relids required_outer)
List * extract_actual_clauses(List *restrictinfo_list, bool pseudoconstant)
bool join_clause_is_movable_to(RestrictInfo *rinfo, RelOptInfo *baserel)
RestrictInfo * make_restrictinfo(PlannerInfo *root, Expr *clause, bool is_pushed_down, bool has_clone, bool is_clone, bool pseudoconstant, Index security_level, Relids required_relids, Relids incompatible_relids, Relids outer_relids)
const char * quote_identifier(const char *ident)
void reservoir_init_selection_state(ReservoirState rs, int n)
double sampler_random_fract(pg_prng_state *randstate)
double reservoir_get_next_S(ReservoirState rs, double t, int n)
double estimate_num_groups(PlannerInfo *root, List *groupExprs, double input_rows, List **pgset, EstimationInfo *estinfo)
int SPI_freeplan(SPIPlanPtr plan)
SPITupleTable * SPI_tuptable
int SPI_execute_plan(SPIPlanPtr plan, const Datum *Values, const char *Nulls, bool read_only, long tcount)
int SPI_execute_with_args(const char *src, int nargs, Oid *argtypes, const Datum *Values, const char *Nulls, bool read_only, long tcount)
SPIPlanPtr SPI_prepare(const char *src, int nargs, Oid *argtypes)
Datum SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool *isnull)
PGconn * GetConnection(void)
void resetStringInfo(StringInfo str)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void appendStringInfoChar(StringInfo str, char ch)
void initStringInfo(StringInfo str)
Bitmapset * as_needrequest
struct WaitEventSet * as_eventset
enum AttImportSqlArgs arg_num
enum AttStatsColumns res_field
ForeignScanState * fsstate
MemoryContext es_query_cxt
struct ErrorContextCallback * previous
void(* callback)(void *arg)
MemoryContext ecxt_per_tuple_memory
TupleTableSlot * ecxt_scantuple
EndForeignInsert_function EndForeignInsert
ReScanForeignScan_function ReScanForeignScan
BeginForeignInsert_function BeginForeignInsert
RecheckForeignScan_function RecheckForeignScan
AddForeignUpdateTargets_function AddForeignUpdateTargets
BeginForeignModify_function BeginForeignModify
EndForeignModify_function EndForeignModify
BeginDirectModify_function BeginDirectModify
PlanForeignModify_function PlanForeignModify
PlanDirectModify_function PlanDirectModify
ExecForeignInsert_function ExecForeignInsert
BeginForeignScan_function BeginForeignScan
ForeignAsyncRequest_function ForeignAsyncRequest
IterateDirectModify_function IterateDirectModify
ExecForeignUpdate_function ExecForeignUpdate
GetForeignJoinPaths_function GetForeignJoinPaths
ImportForeignStatistics_function ImportForeignStatistics
ExecForeignBatchInsert_function ExecForeignBatchInsert
GetForeignPaths_function GetForeignPaths
GetForeignModifyBatchSize_function GetForeignModifyBatchSize
GetForeignRelSize_function GetForeignRelSize
ExplainForeignScan_function ExplainForeignScan
EndForeignScan_function EndForeignScan
AnalyzeForeignTable_function AnalyzeForeignTable
EndDirectModify_function EndDirectModify
ExplainForeignModify_function ExplainForeignModify
IsForeignPathAsyncCapable_function IsForeignPathAsyncCapable
IterateForeignScan_function IterateForeignScan
ForeignAsyncNotify_function ForeignAsyncNotify
ImportForeignSchema_function ImportForeignSchema
GetForeignPlan_function GetForeignPlan
ExecForeignDelete_function ExecForeignDelete
ExecForeignTruncate_function ExecForeignTruncate
ExplainDirectModify_function ExplainDirectModify
IsForeignRelUpdatable_function IsForeignRelUpdatable
GetForeignUpperPaths_function GetForeignUpperPaths
ForeignAsyncConfigureWait_function ForeignAsyncConfigureWait
ResultRelInfo * resultRelInfo
ResultRelInfo * resultRelInfo
ReservoirStateData rstate
AttInMetadata * attinmeta
AsyncRequest * pendingAreq
PgFdwConnState * conn_state
const char ** param_values
AttInMetadata * attinmeta
AttInMetadata * attinmeta
PgFdwConnState * conn_state
struct PgFdwModifyState * aux_fmstate
const char ** param_values
AttInMetadata * attinmeta
unsigned int cursor_number
PgFdwConnState * conn_state
NodeInstrumentation * instrument
ExprContext * ps_ExprContext
ExprContext * pi_exprContext
struct PathTarget * reltarget
QualCost baserestrictcost
struct ResultRelInfo * ri_RootResultRelInfo
List * ri_WithCheckOptions
TriggerDesc * ri_TrigDesc
ProjectionInfo * ri_projectReturning
bool ri_usesFdwDirectModify
Relation ss_currentRelation
TupleTableSlot * ss_ScanTupleSlot
bool trig_insert_after_row
bool trig_update_before_row
bool trig_insert_before_row
TupleDesc tts_tupleDescriptor
#define FirstLowInvalidHeapAttributeNumber
#define SelfItemPointerAttributeNumber
void table_close(Relation relation, LOCKMODE lockmode)
Relation table_open(Oid relationId, LOCKMODE lockmode)
Datum tidin(PG_FUNCTION_ARGS)
TargetEntry * tlist_member(Expr *node, List *targetlist)
SortGroupClause * get_sortgroupref_clause_noerr(Index sortref, List *clauses)
bool grouping_is_sortable(List *groupClause)
PathTarget * copy_pathtarget(PathTarget *src)
void add_new_columns_to_pathtarget(PathTarget *target, List *exprs)
List * get_sortgrouplist_exprs(List *sgClauses, List *targetList)
List * add_to_flat_tlist(List *tlist, List *exprs)
#define InvalidTransactionId
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)
static CompactAttribute * TupleDescCompactAttr(TupleDesc tupdesc, int i)
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static void slot_getallattrs(TupleTableSlot *slot)
static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
Integer * makeInteger(int i)
String * makeString(char *str)
Boolean * makeBoolean(bool val)
List * pull_var_clause(Node *node, int flags)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)
int GetNumRegisteredWaitEvents(WaitEventSet *set)
int AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd, Latch *latch, void *user_data)
#define WL_SOCKET_READABLE