57 #define DEFAULT_FDW_STARTUP_COST 100.0
60 #define DEFAULT_FDW_TUPLE_COST 0.2
63 #define DEFAULT_FDW_SORT_MULTIPLIER 1.2
350 Index resultRelation,
384 Index resultRelation,
429 List *param_join_conds,
432 double *p_rows,
int *p_width,
433 Cost *p_startup_cost,
Cost *p_total_cost);
442 double retrieved_rows,
445 Cost *p_startup_cost,
463 List *retrieved_attrs);
480 List *returningList);
485 List *fdw_scan_tlist,
496 const char ***param_values);
500 const char **param_values);
504 double *totaldeadrows);
514 List *retrieved_attrs,
527 Path *epq_path,
List *restrictlist);
634 baserel->fdw_private = (
void *) fpinfo;
810 List *useful_eclass_list =
NIL;
820 foreach(lc,
root->eq_classes)
825 useful_eclass_list =
lappend(useful_eclass_list, cur_ec);
835 return useful_eclass_list;
852 if (restrictinfo->mergeopfamilies ==
NIL)
883 if (
bms_overlap(relids, restrictinfo->right_ec->ec_relids))
885 restrictinfo->right_ec);
886 else if (
bms_overlap(relids, restrictinfo->left_ec->ec_relids))
888 restrictinfo->left_ec);
891 return useful_eclass_list;
906 List *useful_pathkeys_list =
NIL;
907 List *useful_eclass_list;
919 bool query_pathkeys_ok =
true;
921 foreach(lc,
root->query_pathkeys)
934 query_pathkeys_ok =
false;
939 if (query_pathkeys_ok)
956 return useful_pathkeys_list;
966 query_ec = query_pathkey->pk_eclass;
976 foreach(lc, useful_eclass_list)
982 if (cur_ec == query_ec)
987 OperatorFamilyRelationId, fpinfo))
999 useful_pathkeys_list =
lappend(useful_pathkeys_list,
1003 return useful_pathkeys_list;
1083 required_outer =
bms_union(rinfo->clause_relids,
1098 Assert(param_info != NULL);
1137 if (
arg.current == NULL)
1144 foreach(lc, clauses)
1159 required_outer =
bms_union(rinfo->clause_relids,
1168 Assert(param_info != NULL);
1182 foreach(lc, ppi_list)
1194 &startup_cost, &total_cost);
1237 List *fdw_recheck_quals =
NIL;
1238 List *retrieved_attrs;
1240 bool has_final_sort =
false;
1241 bool has_limit =
false;
1260 scan_relid = foreignrel->
relid;
1281 foreach(lc, scan_clauses)
1286 if (rinfo->pseudoconstant)
1303 fdw_recheck_quals = remote_exprs;
1361 foreach(lc, local_exprs)
1377 Join *join_plan = (
Join *) outer_plan;
1401 has_final_sort, has_limit,
false,
1402 &retrieved_attrs, ¶ms_list);
1415 fdw_private =
lappend(fdw_private,
1455 for (
int i = 0;
i < tupdesc->natts;
i++)
1463 if (att->atttypid != RECORDOID || att->atttypmod >= 0)
1480 att->atttypid = reltype;
1538 fsstate->cursor_exists =
false;
1550 "postgres_fdw tuple data",
1553 "postgres_fdw temporary data",
1567 fsstate->rel = NULL;
1577 fsstate->numParams = numParams;
1582 &fsstate->param_flinfo,
1583 &fsstate->param_exprs,
1584 &fsstate->param_values);
1675 snprintf(sql,
sizeof(sql),
"CLOSE c%u",
1681 snprintf(sql,
sizeof(sql),
"MOVE BACKWARD ALL IN c%u",
1686 snprintf(sql,
sizeof(sql),
"CLOSE c%u",
1724 if (fsstate == NULL)
1734 fsstate->
conn = NULL;
1774 Index resultRelation,
1782 List *withCheckOptionList =
NIL;
1785 bool doNothing =
false;
1786 int values_end_len = -1;
1819 if (!attr->attisdropped)
1836 elog(
ERROR,
"system-column update is not supported");
1844 if (
plan->withCheckOptionLists)
1851 if (
plan->returningLists)
1863 elog(
ERROR,
"unexpected ON CONFLICT specification: %d",
1864 (
int)
plan->onConflictAction);
1873 targetAttrs, doNothing,
1874 withCheckOptionList, returningList,
1875 &retrieved_attrs, &values_end_len);
1880 withCheckOptionList, returningList,
1889 elog(
ERROR,
"unexpected operation: %d", (
int) operation);
1922 List *retrieved_attrs;
1984 &slot, &planSlot, &numSlots);
1989 return rslot ? *rslot : NULL;
2013 slots, planSlots, numSlots);
2086 if (fmstate && fmstate->
p_nums > 0)
2106 &slot, &planSlot, &numSlots);
2108 return rslot ? rslot[0] : NULL;
2125 &slot, &planSlot, &numSlots);
2127 return rslot ? rslot[0] : NULL;
2141 if (fmstate == NULL)
2159 Index resultRelation;
2168 bool doNothing =
false;
2181 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
2182 errmsg(
"cannot route tuples into foreign table to be updated \"%s\"",
2192 if (!attr->attisdropped)
2205 elog(
ERROR,
"unexpected ON CONFLICT specification: %d",
2206 (
int) onConflictAction);
2226 rte->relkind = RELKIND_FOREIGN_TABLE;
2250 &retrieved_attrs, &values_end_len);
2261 retrieved_attrs !=
NIL,
2329 if (strcmp(def->
defname,
"updatable") == 0)
2336 if (strcmp(def->
defname,
"updatable") == 0)
2446 Index resultRelation,
2484 if (fscan->
scan.plan.qual !=
NIL)
2495 foreignrel =
root->simple_rel_array[resultRelation];
2496 rte =
root->simple_rte_array[resultRelation];
2513 &processed_tlist, &targetAttrs);
2514 forboth(lc, processed_tlist, lc2, targetAttrs)
2523 elog(
ERROR,
"system-column update is not supported");
2551 if (
plan->returningLists)
2579 remote_exprs, ¶ms_list,
2580 returningList, &retrieved_attrs);
2585 remote_exprs, ¶ms_list,
2586 returningList, &retrieved_attrs);
2589 elog(
ERROR,
"unexpected operation: %d", (
int) operation);
2619 fscan->
scan.plan.lefttree = NULL;
2630 if (fscan->
scan.plan.async_capable)
2631 fscan->
scan.plan.async_capable =
false;
2690 dmstate->resultRel = dmstate->rel;
2698 dmstate->rel = NULL;
2702 dmstate->num_tuples = -1;
2716 "postgres_fdw temporary data",
2720 if (dmstate->has_returning)
2744 dmstate->numParams = numParams;
2749 &dmstate->param_flinfo,
2750 &dmstate->param_exprs,
2751 &dmstate->param_values);
2774 if (!resultRelInfo->ri_projectReturning)
2808 if (dmstate == NULL)
2816 dmstate->
conn = NULL;
2829 List *fdw_private =
plan->fdw_private;
2861 if (isdigit((
unsigned char) *ptr))
2863 int rti = strtol(ptr, &ptr, 10);
2878 if (isdigit((
unsigned char) *ptr))
2880 int rti = strtol(ptr, &ptr, 10);
2904 if (refname == NULL)
2905 refname = rte->eref->aliasname;
2906 if (strcmp(refname,
relname) != 0)
2988 bool server_truncatable =
true;
3014 foreach(cell, server->
options)
3018 if (strcmp(defel->
defname,
"truncatable") == 0)
3033 truncatable = server_truncatable;
3038 if (strcmp(defel->
defname,
"truncatable") == 0)
3047 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3048 errmsg(
"foreign table \"%s\" does not allow truncates",
3087 List *param_join_conds,
3090 double *p_rows,
int *p_width,
3091 Cost *p_startup_cost,
Cost *p_total_cost)
3095 double retrieved_rows;
3112 List *remote_param_join_conds;
3113 List *local_param_join_conds;
3122 List *retrieved_attrs;
3129 &remote_param_join_conds, &local_param_join_conds);
3135 fdw_scan_tlist =
NIL;
3142 remote_conds =
list_concat(remote_param_join_conds,
3153 remote_conds, pathkeys,
3156 false, &retrieved_attrs, NULL);
3161 &startup_cost, &total_cost);
3164 retrieved_rows = rows;
3168 local_param_join_conds,
3180 startup_cost += local_cost.
startup;
3181 total_cost += local_cost.
per_tuple * retrieved_rows;
3196 startup_cost -= tlist_cost.
startup;
3197 total_cost -= tlist_cost.
startup;
3198 total_cost -= tlist_cost.
per_tuple * rows;
3222 rows = fpinfo->
rows;
3224 width = fpinfo->
width;
3255 rows = foreignrel->
rows;
3265 nrows = fpinfo_i->
rows * fpinfo_o->
rows;
3272 retrieved_rows =
Min(retrieved_rows, nrows);
3295 startup_cost += join_cost.
startup;
3296 startup_cost += remote_conds_cost.
startup;
3316 run_cost += nrows * join_cost.
per_tuple;
3318 run_cost += nrows * remote_conds_cost.
per_tuple;
3332 double numGroups = 1;
3350 input_rows = ofpinfo->
rows;
3354 if (
root->parse->hasAggs)
3364 input_rows, NULL, NULL);
3370 if (
root->hasHavingQual)
3385 rows = retrieved_rows = numGroups;
3418 if (
root->hasHavingQual)
3424 startup_cost += remote_cost.
startup;
3425 run_cost += remote_cost.
per_tuple * numGroups;
3440 rows = foreignrel->
rows;
3448 retrieved_rows =
Min(retrieved_rows, foreignrel->
tuples);
3461 run_cost += cpu_per_tuple * foreignrel->
tuples;
3477 if (pathkeys !=
NIL)
3484 retrieved_rows, width,
3486 &startup_cost, &run_cost);
3495 total_cost = startup_cost + run_cost;
3502 retrieved_rows = rows;
3535 if (pathkeys ==
NIL && param_join_conds ==
NIL && fpextra == NULL)
3573 total_cost -= (total_cost - startup_cost) * 0.05 *
3580 *p_startup_cost = startup_cost;
3581 *p_total_cost = total_cost;
3590 double *rows,
int *width,
3591 Cost *startup_cost,
Cost *total_cost)
3615 p = strrchr(line,
'(');
3617 elog(
ERROR,
"could not interpret EXPLAIN output: \"%s\"", line);
3618 n = sscanf(p,
"(cost=%lf..%lf rows=%lf width=%d)",
3619 startup_cost, total_cost, rows, width);
3621 elog(
ERROR,
"could not interpret EXPLAIN output: \"%s\"", line);
3637 double retrieved_rows,
3639 double limit_tuples,
3640 Cost *p_startup_cost,
3659 *p_startup_cost + *p_run_cost,
3678 *p_startup_cost *= sort_multiplier;
3679 *p_run_cost *= sort_multiplier;
3700 if (
state->current != NULL)
3710 state->current = expr;
3764 NULL,
values, NULL, NULL, 0))
3836 snprintf(sql,
sizeof(sql),
"FETCH %d FROM c%u",
3851 for (
i = 0;
i < numrows;
i++)
3975 List *retrieved_attrs)
4004 fmstate->
query = query;
4017 "postgres_fdw temporary data",
4037 elog(
ERROR,
"could not find junk ctid column");
4053 Assert(!attr->attisdropped);
4056 if (attr->attgenerated)
4095 const char **p_values;
4126 fmstate->
query = sql.data;
4159 fmstate->
p_nums * (*numSlots),
4198 return (n_rows > 0) ? slots : NULL;
4218 snprintf(prep_name,
sizeof(prep_name),
"pgsql_fdw_prep_%u",
4248 fmstate->
p_name = p_name;
4260 static const char **
4266 const char **p_values;
4274 p_values = (
const char **)
palloc(
sizeof(
char *) * fmstate->
p_nums * numSlots);
4277 Assert(!(tupleid != NULL && numSlots > 1));
4280 if (tupleid != NULL)
4298 for (
i = 0;
i < numSlots;
i++)
4300 j = (tupleid != NULL) ? 1 : 0;
4309 if (attr->attgenerated)
4313 p_values[pindex] = NULL;
4382 fmstate->
conn = NULL;
4422 bool have_wholerow =
false;
4440 var->
varno == rtindex &&
4443 have_wholerow =
true;
4453 for (
i = 1;
i <= tupdesc->
natts;
i++)
4459 if (attr->attisdropped)
4488 var->
varno == rtindex &&
4523 List *new_tlist = tlist;
4527 foreach(lc, old_tlist)
4534 new_tlist =
lappend(new_tlist,
4575 NULL,
values, NULL, NULL, 0))
4609 Assert(resultRelInfo->ri_projectReturning);
4617 estate->es_processed += 1;
4664 resultRelInfo->ri_projectReturning->pi_exprContext->ecxt_scantuple =
4675 List *fdw_scan_tlist,
4701 foreach(lc, fdw_scan_tlist)
4712 if (var->
varno == rtindex &&
4782 for (
i = 0;
i < resultTupType->
natts;
i++)
4794 isnull[
i] = old_isnull[
j - 1];
4818 resultTup->
t_self = *ctid;
4851 const char ***param_values)
4862 foreach(lc, fdw_exprs)
4884 *param_values = (
const char **)
palloc0(numParams *
sizeof(
char *));
4894 const char **param_values)
4903 foreach(lc, param_exprs)
4910 expr_value =
ExecEvalExpr(expr_state, econtext, &isNull);
4917 param_values[
i] = NULL;
4974 elog(
ERROR,
"unexpected result from deparseAnalyzeSizeSql query");
5003 volatile double reltuples = -1;
5004 volatile char relkind = 0;
5007 *can_tablesample =
false;
5031 elog(
ERROR,
"unexpected result from deparseAnalyzeInfoSql query");
5045 *can_tablesample = (relkind == RELKIND_RELATION ||
5046 relkind == RELKIND_MATVIEW ||
5047 relkind == RELKIND_PARTITIONED_TABLE);
5070 double *totaldeadrows)
5079 double sample_frac = -1.0;
5087 astate.
rel = relation;
5100 "postgres_fdw temporary data",
5122 if (strcmp(def->
defname,
"analyze_sampling") == 0)
5126 if (strcmp(
value,
"off") == 0)
5128 else if (strcmp(
value,
"auto") == 0)
5130 else if (strcmp(
value,
"random") == 0)
5132 else if (strcmp(
value,
"system") == 0)
5134 else if (strcmp(
value,
"bernoulli") == 0)
5145 if (strcmp(def->
defname,
"analyze_sampling") == 0)
5149 if (strcmp(
value,
"off") == 0)
5151 else if (strcmp(
value,
"auto") == 0)
5153 else if (strcmp(
value,
"random") == 0)
5155 else if (strcmp(
value,
"system") == 0)
5157 else if (strcmp(
value,
"bernoulli") == 0)
5172 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
5173 errmsg(
"remote server does not support TABLESAMPLE feature")));
5182 bool can_tablesample;
5199 if ((reltuples <= 0) || (targrows >= reltuples))
5227 sample_frac = targrows / reltuples;
5234 Assert(sample_frac >= 0.0 && sample_frac <= 1.0);
5281 if (strcmp(def->
defname,
"fetch_size") == 0)
5291 if (strcmp(def->
defname,
"fetch_size") == 0)
5299 snprintf(fetch_sql,
sizeof(fetch_sql),
"FETCH %d FROM c%u",
5325 for (
i = 0;
i < numrows;
i++)
5349 *totaldeadrows = 0.0;
5359 *totalrows = reltuples;
5365 (
errmsg(
"\"%s\": table contains %.0f rows, %d rows in sample",
5367 *totalrows, astate.
numrows)));
5391 if (astate->
numrows < targrows)
5410 Assert(pos >= 0 && pos < targrows);
5448 bool import_collate =
true;
5449 bool import_default =
false;
5450 bool import_generated =
true;
5451 bool import_not_null =
true;
5462 foreach(lc,
stmt->options)
5466 if (strcmp(def->
defname,
"import_collate") == 0)
5468 else if (strcmp(def->
defname,
"import_default") == 0)
5470 else if (strcmp(def->
defname,
"import_generated") == 0)
5472 else if (strcmp(def->
defname,
"import_not_null") == 0)
5476 (
errcode(ERRCODE_FDW_INVALID_OPTION_NAME),
5490 import_collate =
false;
5508 (
errcode(ERRCODE_FDW_SCHEMA_NOT_FOUND),
5509 errmsg(
"schema \"%s\" is not present on foreign server \"%s\"",
5538 " format_type(atttypid, atttypmod), "
5540 " pg_get_expr(adbin, adrelid), ");
5553 " collnsp.nspname ");
5560 " JOIN pg_namespace n ON "
5561 " relnamespace = n.oid "
5562 " LEFT JOIN pg_attribute a ON "
5563 " attrelid = c.oid AND attnum > 0 "
5564 " AND NOT attisdropped "
5565 " LEFT JOIN pg_attrdef ad ON "
5566 " adrelid = c.oid AND adnum = attnum ");
5570 " LEFT JOIN pg_collation coll ON "
5571 " coll.oid = attcollation "
5572 " LEFT JOIN pg_namespace collnsp ON "
5573 " collnsp.oid = collnamespace ");
5576 "WHERE c.relkind IN ("
5582 " AND n.nspname = ");
5594 bool first_item =
true;
5602 foreach(lc,
stmt->table_list)
5626 for (
i = 0;
i < numrows;)
5629 bool first_item =
true;
5644 char *collnamespace;
5682 if (import_collate && collname != NULL && collnamespace != NULL)
5688 if (import_default && attdefault != NULL &&
5689 (!attgenerated || !attgenerated[0]))
5693 if (import_generated && attgenerated != NULL &&
5694 attgenerated[0] == ATTRIBUTE_GENERATED_STORED)
5696 Assert(attdefault != NULL);
5698 " GENERATED ALWAYS AS (%s) STORED",
5706 while (++
i < numrows &&
5862 if (!is_remote_clause)
5864 joinclauses =
lappend(joinclauses, rinfo);
5868 if (is_remote_clause)
5885 foreach(lc,
root->placeholder_list)
6007 elog(
ERROR,
"unsupported join type %d", jointype);
6052 fpinfo->
user = NULL;
6089 Path *epq_path,
List *restrictlist)
6091 List *useful_pathkeys_list =
NIL;
6101 if (epq_path != NULL && useful_pathkeys_list !=
NIL)
6146 foreach(lc, useful_pathkeys_list)
6153 Path *sorted_epq_path;
6156 &rows, &width, &startup_cost, &total_cost);
6162 sorted_epq_path = epq_path;
6163 if (sorted_epq_path != NULL &&
6166 sorted_epq_path = (
Path *)
6215 if (strcmp(def->
defname,
"use_remote_estimate") == 0)
6217 else if (strcmp(def->
defname,
"fdw_startup_cost") == 0)
6220 else if (strcmp(def->
defname,
"fdw_tuple_cost") == 0)
6223 else if (strcmp(def->
defname,
"extensions") == 0)
6226 else if (strcmp(def->
defname,
"fetch_size") == 0)
6228 else if (strcmp(def->
defname,
"async_capable") == 0)
6247 if (strcmp(def->
defname,
"use_remote_estimate") == 0)
6249 else if (strcmp(def->
defname,
"fetch_size") == 0)
6251 else if (strcmp(def->
defname,
"async_capable") == 0)
6346 if (joinrel->fdw_private)
6365 joinrel->fdw_private = fpinfo;
6386 elog(
DEBUG3,
"could not push down foreign join because a local path suitable for EPQ checks was not found");
6427 &rows, &width, &startup_cost, &total_cost);
6429 joinrel->
rows = rows;
6431 fpinfo->
rows = rows;
6432 fpinfo->
width = width;
6491 if (ofpinfo->local_conds)
6511 foreach(lc, grouping_target->exprs)
6610 foreach(lc, (
List *) havingQual)
6626 root->qual_security_level,
6654 foreach(lc, aggvars)
6697 ofpinfo->relation_name);
6718 if (!input_rel->fdw_private ||
6726 output_rel->fdw_private)
6731 fpinfo->
stage = stage;
6732 output_rel->fdw_private = fpinfo;
6748 elog(
ERROR,
"unexpected upper relation: %d", (
int) stage);
6776 !
root->hasHavingQual)
6821 &rows, &width, &startup_cost, &total_cost);
6824 fpinfo->
rows = rows;
6825 fpinfo->
width = width;
6872 if (
parse->hasTargetSRFs)
6916 foreach(lc,
root->sort_pathkeys)
6955 &rows, &width, &startup_cost, &total_cost);
6970 root->sort_pathkeys,
6995 bool has_final_sort =
false;
6998 bool save_use_remote_estimate =
false;
7020 if (
parse->hasTargetSRFs)
7024 fpinfo->outerrel = input_rel;
7030 fpinfo->table = ifpinfo->
table;
7031 fpinfo->server = ifpinfo->
server;
7032 fpinfo->user = ifpinfo->
user;
7097 fpinfo->pushdown_safe =
true;
7122 has_final_sort =
true;
7123 pathkeys =
root->sort_pathkeys;
7176 fpinfo->pushdown_safe =
true;
7202 &rows, &width, &startup_cost, &total_cost);
7264 AsyncRequest *pendingAreq = fsstate->conn_state->pendingAreq;
7276 if (fsstate->next_tuple < fsstate->num_tuples)
7285 Assert(fsstate->next_tuple >= fsstate->num_tuples);
7325 Assert(pendingAreq == areq);
7350 if (fsstate->next_tuple < fsstate->num_tuples)
7357 Assert(fsstate->next_tuple >= fsstate->num_tuples);
7360 Assert(fsstate->conn_state->pendingAreq == areq);
7379 AsyncRequest *pendingAreq = fsstate->conn_state->pendingAreq;
7383 Assert(areq != pendingAreq);
7386 if (fsstate->next_tuple >= fsstate->num_tuples)
7389 if (!fsstate->eof_reached)
7394 if (fetch && !pendingAreq)
7417 Assert(fsstate->next_tuple >= fsstate->num_tuples);
7420 if (!fsstate->eof_reached)
7425 if (fetch && !pendingAreq)
7452 Assert(!fsstate->conn_state->pendingAreq);
7455 if (!fsstate->cursor_exists)
7459 snprintf(sql,
sizeof(sql),
"FETCH %d FROM c%u",
7460 fsstate->fetch_size, fsstate->cursor_number);
7466 fsstate->conn_state->pendingAreq = areq;
7482 Assert(fsstate->conn_state->pendingAreq == areq);
7491 if (fsstate->next_tuple >= fsstate->num_tuples)
7544 List *retrieved_attrs,
7581 nulls = (
bool *)
palloc(tupdesc->
natts *
sizeof(
bool));
7583 memset(nulls,
true, tupdesc->
natts *
sizeof(
bool));
7592 errcallback.
arg = (
void *) &errpos;
7600 foreach(lc, retrieved_attrs)
7620 Assert(i <= tupdesc->natts);
7621 nulls[
i - 1] = (valstr == NULL);
7652 elog(
ERROR,
"remote query result does not match the foreign table");
7704 bool is_wholerow =
false;
7751 relname = rte->eref->aliasname;
7755 else if (colno > 0 && colno <=
list_length(rte->eref->colnames))
7783 errcontext(
"processing expression at position %d in select list",
7844 foreach(lc1, target->
exprs)
7853 root->parse->sortClause) == NULL)
7882 if (!
equal(em_expr, expr))
7928 if (strcmp(def->
defname,
"batch_size") == 0)
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
int bms_next_member(const Bitmapset *a, int prevbit)
bool bms_is_subset(const Bitmapset *a, const Bitmapset *b)
bool bms_is_member(int x, const Bitmapset *a)
Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_add_members(Bitmapset *a, const Bitmapset *b)
Bitmapset * bms_del_member(Bitmapset *a, int x)
bool bms_overlap(const Bitmapset *a, const Bitmapset *b)
bool bms_nonempty_difference(const Bitmapset *a, const Bitmapset *b)
static Datum values[MAXATTR]
#define Assert(condition)
#define MemSet(start, val, len)
#define OidIsValid(objectId)
Selectivity clauselist_selectivity(PlannerInfo *root, List *clauses, int varRelid, JoinType jointype, SpecialJoinInfo *sjinfo)
unsigned int GetCursorNumber(PGconn *conn)
void do_sql_command(PGconn *conn, const char *sql)
void ReleaseConnection(PGconn *conn)
void pgfdw_report_error(int elevel, PGresult *res, PGconn *conn, bool clear, const char *sql)
PGresult * pgfdw_exec_query(PGconn *conn, const char *query, PgFdwConnState *state)
static unsigned int cursor_number
PGconn * GetConnection(UserMapping *user, bool will_prep_stmt, PgFdwConnState **state)
unsigned int GetPrepStmtNumber(PGconn *conn)
PGresult * pgfdw_get_result(PGconn *conn)
List * ExtractExtensionList(const char *extensionsString, bool warnOnMissing)
void set_baserel_size_estimates(PlannerInfo *root, RelOptInfo *rel)
void cost_qual_eval(QualCost *cost, List *quals, PlannerInfo *root)
double clamp_row_est(double nrows)
void cost_sort(Path *path, PlannerInfo *root, List *pathkeys, Cost input_cost, double tuples, int width, Cost comparison_cost, int sort_mem, double limit_tuples)
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 void PGresult * res
bool defGetBoolean(DefElem *def)
char * defGetString(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)
List * build_tlist_to_deparse(RelOptInfo *foreignrel)
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)
ErrorContextCallback * error_context_stack
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
bool equal(const void *a, const void *b)
List * generate_implied_equalities_for_column(PlannerInfo *root, RelOptInfo *rel, ec_matches_callback_type callback, void *callback_arg, Relids prohibited_rels)
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)
AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc)
TupleTableSlot * ExecStoreVirtualTuple(TupleTableSlot *slot)
TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)
HeapTuple ExecFetchSlotHeapTuple(TupleTableSlot *slot, bool materialize, bool *shouldFree)
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 Datum ExecEvalExpr(ExprState *state, ExprContext *econtext, bool *isNull)
#define EXEC_FLAG_EXPLAIN_ONLY
static Datum ExecGetJunkAttribute(TupleTableSlot *slot, AttrNumber attno, bool *isNull)
static TupleTableSlot * ExecProcNode(PlanState *node)
void ExplainPropertyText(const char *qlabel, const char *value, ExplainState *es)
void ExplainPropertyInteger(const char *qlabel, const char *unit, int64 value, ExplainState *es)
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)
ExecStatusType PQresultStatus(const PGresult *res)
char * PQcmdTuples(PGresult *res)
int PQntuples(const PGresult *res)
int PQconsumeInput(PGconn *conn)
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
int PQsendPrepare(PGconn *conn, const char *stmtName, const char *query, int nParams, const Oid *paramTypes)
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
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)
int PQnfields(const PGresult *res)
Datum InputFunctionCall(FmgrInfo *flinfo, char *str, Oid typioparam, int32 typmod)
void fmgr_info(Oid functionId, FmgrInfo *finfo)
char * OutputFunctionCall(FmgrInfo *flinfo, Datum val)
#define DirectFunctionCall1(func, arg1)
#define PG_RETURN_POINTER(x)
ForeignTable * GetForeignTable(Oid relid)
Path * GetExistingLocalJoinPath(RelOptInfo *joinrel)
UserMapping * GetUserMapping(Oid userid, Oid serverid)
ForeignServer * GetForeignServer(Oid serverid)
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
#define HeapTupleHeaderSetXmin(tup, xid)
#define HeapTupleHeaderSetXmax(tup, xid)
#define HeapTupleHeaderSetCmin(tup, cid)
Bitmapset * get_rel_all_updated_cols(PlannerInfo *root, RelOptInfo *rel)
void InstrUpdateTupleCount(Instrumentation *instr, double nTuples)
if(TABLE==NULL||TABLE_index==NULL)
ItemPointerData * ItemPointer
int GetNumRegisteredWaitEvents(WaitEventSet *set)
int AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd, Latch *latch, void *user_data)
#define WL_SOCKET_READABLE
#define PQ_QUERY_PARAM_MAX_LIMIT
List * lappend(List *list, void *datum)
List * lappend_int(List *list, int datum)
List * list_copy(const List *oldlist)
List * list_delete(List *list, void *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)
List * list_concat(List *list1, const List *list2)
bool list_member(const List *list, const void *datum)
List * list_append_unique_ptr(List *list, void *datum)
char * get_namespace_name_or_temp(Oid nspid)
void getTypeOutputInfo(Oid type, Oid *typOutput, bool *typIsVarlena)
Oid get_rel_namespace(Oid relid)
Oid get_rel_type_id(Oid relid)
char * get_rel_name(Oid relid)
Datum subpath(PG_FUNCTION_ARGS)
TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)
Var * makeVar(int varno, AttrNumber varattno, Oid vartype, int32 vartypmod, Oid varcollid, Index varlevelsup)
void MemoryContextReset(MemoryContext context)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
MemoryContext CurrentMemoryContext
#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
@ FDW_IMPORT_SCHEMA_LIMIT_TO
@ FDW_IMPORT_SCHEMA_EXCEPT
#define rt_fetch(rangetable_index, rangetable)
void update_mergeclause_eclasses(PlannerInfo *root, RestrictInfo *restrictinfo)
PathKey * make_canonical_pathkey(PlannerInfo *root, EquivalenceClass *eclass, Oid opfamily, int strategy, bool nulls_first)
bool pathkeys_contained_in(List *keys1, List *keys2)
SortPath * create_sort_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, List *pathkeys, double limit_tuples)
ProjectionPath * create_projection_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath, PathTarget *target)
ForeignPath * create_foreignscan_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
ForeignPath * create_foreign_upper_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, 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)
ForeignPath * create_foreign_join_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, double rows, Cost startup_cost, Cost total_cost, List *pathkeys, Relids required_outer, Path *fdw_outerpath, List *fdw_restrictinfo, List *fdw_private)
#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)
#define list_make3(x1, x2, x3)
static void * list_nth(const List *list, int n)
#define list_nth_node(type, list, n)
#define list_make2(x1, x2)
#define list_make4(x1, x2, x3, x4)
static Datum PointerGetDatum(const void *X)
static Pointer DatumGetPointer(Datum X)
static Datum CStringGetDatum(const char *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 ForeignScan * find_modifytable_subplan(PlannerInfo *root, ModifyTable *plan, Index rtindex, int subplan_index)
static TupleTableSlot * apply_returning_filter(PgFdwDirectModifyState *dmstate, ResultRelInfo *resultRelInfo, TupleTableSlot *slot, EState *estate)
static bool foreign_join_ok(PlannerInfo *root, RelOptInfo *joinrel, JoinType jointype, RelOptInfo *outerrel, RelOptInfo *innerrel, JoinPathExtraData *extra)
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)
static bool postgresPlanDirectModify(PlannerInfo *root, ModifyTable *plan, Index resultRelation, int subplan_index)
static void conversion_error_callback(void *arg)
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)
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 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 void estimate_path_cost_size(PlannerInfo *root, RelOptInfo *foreignrel, List *param_join_conds, List *pathkeys, PgFdwPathExtraData *fpextra, double *p_rows, int *p_width, Cost *p_startup_cost, Cost *p_total_cost)
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)
struct PgFdwModifyState PgFdwModifyState
static void merge_fdw_options(PgFdwRelationInfo *fpinfo, const PgFdwRelationInfo *fpinfo_o, const PgFdwRelationInfo *fpinfo_i)
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 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)
EquivalenceMember * find_em_for_rel(PlannerInfo *root, EquivalenceClass *ec, RelOptInfo *rel)
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)
static bool foreign_grouping_ok(PlannerInfo *root, RelOptInfo *grouped_rel, Node *havingQual)
@ 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 void adjust_foreign_grouping_path_cost(PlannerInfo *root, List *pathkeys, double retrieved_rows, double width, double limit_tuples, Cost *p_startup_cost, Cost *p_run_cost)
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)
struct ConversionLocation ConversionLocation
struct PgFdwScanState PgFdwScanState
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)
void process_pending_request(AsyncRequest *areq)
#define DEFAULT_FDW_TUPLE_COST
struct PgFdwDirectModifyState PgFdwDirectModifyState
static void postgresBeginForeignModify(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo, List *fdw_private, int subplan_index, int eflags)
static void process_query_params(ExprContext *econtext, FmgrInfo *param_flinfo, List *param_exprs, const char **param_values)
static void postgresBeginForeignInsert(ModifyTableState *mtstate, ResultRelInfo *resultRelInfo)
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)
struct PgFdwAnalyzeState PgFdwAnalyzeState
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)
PG_FUNCTION_INFO_V1(postgres_fdw_handler)
static void postgresEndForeignInsert(EState *estate, ResultRelInfo *resultRelInfo)
EquivalenceMember * find_em_for_rel_target(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,...)
MemoryContextSwitchTo(old_ctx)
static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)
#define RelationGetRelid(relation)
#define RelationGetDescr(relation)
#define RelationGetRelationName(relation)
ParamPathInfo * get_baserel_parampathinfo(PlannerInfo *root, RelOptInfo *baserel, Relids required_outer)
RelOptInfo * find_base_rel(PlannerInfo *root, int relid)
RelOptInfo * find_join_rel(PlannerInfo *root, Relids relids)
List * extract_actual_clauses(List *restrictinfo_list, bool pseudoconstant)
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)
bool join_clause_is_movable_to(RestrictInfo *rinfo, RelOptInfo *baserel)
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)
#define BTLessStrategyNumber
StringInfo makeStringInfo(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
struct PlanState * requestor
struct PlanState * requestee
ForeignScanState * fsstate
MemoryContext es_query_cxt
struct ErrorContextCallback * previous
void(* callback)(void *arg)
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
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
Bitmapset * fs_base_relids
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
List * shippable_extensions
bool make_outerrel_subquery
Relids lower_subquery_rels
Selectivity joinclause_sel
List * final_remote_exprs
Relids hidden_subquery_rels
Selectivity local_conds_sel
bool make_innerrel_subquery
QualCost local_conds_cost
const char ** param_values
AttInMetadata * attinmeta
unsigned int cursor_number
PgFdwConnState * conn_state
Instrumentation * instrument
ExecProcNodeMtd ExecProcNodeReal
ExprContext * ps_ExprContext
struct PathTarget * reltarget
Relids lateral_referencers
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)
List * get_sortgrouplist_exprs(List *sgClauses, List *targetList)
PathTarget * copy_pathtarget(PathTarget *src)
SortGroupClause * get_sortgroupref_clause_noerr(Index sortref, List *clauses)
bool grouping_is_sortable(List *groupClause)
List * add_to_flat_tlist(List *tlist, List *exprs)
void add_new_columns_to_pathtarget(PathTarget *target, List *exprs)
TargetEntry * tlist_member(Expr *node, List *targetlist)
#define InvalidTransactionId
TupleDesc CreateTupleDescCopy(TupleDesc tupdesc)
#define TupleDescAttr(tupdesc, i)
static TupleTableSlot * ExecClearTuple(TupleTableSlot *slot)
static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)
static Datum slot_getattr(TupleTableSlot *slot, int attnum, bool *isnull)
static void slot_getallattrs(TupleTableSlot *slot)
Boolean * makeBoolean(bool val)
String * makeString(char *str)
Integer * makeInteger(int i)
List * pull_var_clause(Node *node, int flags)
void pull_varattnos(Node *node, Index varno, Bitmapset **varattnos)