PostgreSQL Source Code
git master
|
#include "foreign/foreign.h"
#include "lib/stringinfo.h"
#include "libpq-fe.h"
#include "nodes/execnodes.h"
#include "nodes/pathnodes.h"
#include "utils/relcache.h"
Go to the source code of this file.
Data Structures | |
struct | PgFdwRelationInfo |
struct | PgFdwConnState |
Typedefs | |
typedef struct PgFdwRelationInfo | PgFdwRelationInfo |
typedef struct PgFdwConnState | PgFdwConnState |
typedef enum PgFdwSamplingMethod | PgFdwSamplingMethod |
Enumerations | |
enum | PgFdwSamplingMethod { ANALYZE_SAMPLE_OFF , ANALYZE_SAMPLE_AUTO , ANALYZE_SAMPLE_RANDOM , ANALYZE_SAMPLE_SYSTEM , ANALYZE_SAMPLE_BERNOULLI } |
Variables | |
char * | pgfdw_application_name |
typedef struct PgFdwConnState PgFdwConnState |
typedef struct PgFdwRelationInfo PgFdwRelationInfo |
typedef enum PgFdwSamplingMethod PgFdwSamplingMethod |
enum PgFdwSamplingMethod |
Enumerator | |
---|---|
ANALYZE_SAMPLE_OFF | |
ANALYZE_SAMPLE_AUTO | |
ANALYZE_SAMPLE_RANDOM | |
ANALYZE_SAMPLE_SYSTEM | |
ANALYZE_SAMPLE_BERNOULLI |
Definition at line 145 of file postgres_fdw.h.
List* build_tlist_to_deparse | ( | RelOptInfo * | foreignrel | ) |
Definition at line 1176 of file deparse.c.
References add_to_flat_tlist(), RestrictInfo::clause, PathTarget::exprs, PgFdwRelationInfo::grouped_tlist, if(), IS_UPPER_REL, lfirst_node, PgFdwRelationInfo::local_conds, NIL, pull_var_clause(), PVC_RECURSE_PLACEHOLDERS, and RelOptInfo::reltarget.
Referenced by estimate_path_cost_size(), and postgresGetForeignPlan().
void classifyConditions | ( | PlannerInfo * | root, |
RelOptInfo * | baserel, | ||
List * | input_conds, | ||
List ** | remote_conds, | ||
List ** | local_conds | ||
) |
Definition at line 218 of file deparse.c.
References RestrictInfo::clause, is_foreign_expr(), lappend(), lfirst_node, NIL, and root.
Referenced by estimate_path_cost_size(), and postgresGetForeignRelSize().
void deparseAnalyzeInfoSql | ( | StringInfo | buf, |
Relation | rel | ||
) |
Definition at line 2521 of file deparse.c.
References appendStringInfoString(), buf, nameData::data, deparseRelation(), deparseStringLiteral(), initStringInfo(), and relname.
Referenced by postgresGetAnalyzeInfoForForeignTable().
void deparseAnalyzeSizeSql | ( | StringInfo | buf, |
Relation | rel | ||
) |
Definition at line 2499 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), buf, nameData::data, deparseRelation(), deparseStringLiteral(), initStringInfo(), and relname.
Referenced by postgresAnalyzeForeignTable().
void deparseAnalyzeSql | ( | StringInfo | buf, |
Relation | rel, | ||
PgFdwSamplingMethod | sample_method, | ||
double | sample_frac, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 2561 of file deparse.c.
References ANALYZE_SAMPLE_AUTO, ANALYZE_SAMPLE_BERNOULLI, ANALYZE_SAMPLE_OFF, ANALYZE_SAMPLE_RANDOM, ANALYZE_SAMPLE_SYSTEM, appendStringInfo(), appendStringInfoString(), attname, buf, defGetString(), DefElem::defname, deparseRelation(), elog, ERROR, GetForeignColumnOptions(), i, lappend_int(), lfirst, NameStr, TupleDescData::natts, NIL, options, quote_identifier(), RelationGetDescr, RelationGetRelid, and TupleDescAttr.
Referenced by postgresAcquireSampleRowsFunc().
void deparseDeleteSql | ( | StringInfo | buf, |
RangeTblEntry * | rte, | ||
Index | rtindex, | ||
Relation | rel, | ||
List * | returningList, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 2362 of file deparse.c.
References appendStringInfoString(), buf, deparseRelation(), deparseReturningList(), NIL, TriggerDesc::trig_delete_after_row, and RelationData::trigdesc.
Referenced by postgresPlanForeignModify().
void deparseDirectDeleteSql | ( | StringInfo | buf, |
PlannerInfo * | root, | ||
Index | rtindex, | ||
Relation | rel, | ||
RelOptInfo * | foreignrel, | ||
List * | remote_conds, | ||
List ** | params_list, | ||
List * | returningList, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 2391 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), appendWhereClause(), buf, context, deparseExplicitTargetList(), deparseFromExprForRel(), deparseRelation(), deparseReturningList(), list_concat(), list_free_deep(), NIL, planner_rt_fetch, REL_ALIAS_PREFIX, RELOPT_JOINREL, RelOptInfo::reloptkind, and root.
Referenced by postgresPlanDirectModify().
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 | ||
) |
Definition at line 2276 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), appendWhereClause(), Assert, attnum, buf, context, deparseColumnRef(), deparseExplicitTargetList(), deparseExpr(), deparseFromExprForRel(), deparseRelation(), deparseReturningList(), TargetEntry::expr, forboth, lfirst_int, lfirst_node, list_concat(), list_free_deep(), NIL, planner_rt_fetch, REL_ALIAS_PREFIX, RELOPT_JOINREL, RelOptInfo::reloptkind, reset_transmission_modes(), root, and set_transmission_modes().
Referenced by postgresPlanDirectModify().
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 | ||
) |
Definition at line 2083 of file deparse.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), attnum, buf, deparseColumnRef(), deparseRelation(), deparseReturningList(), lfirst_int, RelationGetDescr, TriggerDesc::trig_insert_after_row, RelationData::trigdesc, and TupleDescAttr.
Referenced by postgresBeginForeignInsert(), and postgresPlanForeignModify().
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 | ||
) |
Definition at line 1233 of file deparse.c.
References appendConditions(), appendGroupByClause(), appendLimitClause(), appendOrderByClause(), appendStringInfoString(), Assert, buf, context, deparseFromExpr(), deparseLockingClause(), deparseSelectSql(), IS_JOIN_REL, IS_SIMPLE_REL, IS_UPPER_REL, PgFdwRelationInfo::outerrel, PgFdwRelationInfo::remote_conds, and root.
Referenced by deparseRangeTblRef(), estimate_path_cost_size(), and postgresGetForeignPlan().
void deparseStringLiteral | ( | StringInfo | buf, |
const char * | val | ||
) |
Definition at line 2849 of file deparse.c.
References appendStringInfoChar(), buf, ESCAPE_STRING_SYNTAX, SQL_STR_DOUBLE, and val.
Referenced by deparseAnalyzeInfoSql(), deparseAnalyzeSizeSql(), deparseConst(), and postgresImportForeignSchema().
void deparseTruncateSql | ( | StringInfo | buf, |
List * | rels, | ||
DropBehavior | behavior, | ||
bool | restart_seqs | ||
) |
Definition at line 2646 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), buf, deparseRelation(), DROP_CASCADE, DROP_RESTRICT, lfirst, and list_head().
Referenced by postgresExecForeignTruncate().
void deparseUpdateSql | ( | StringInfo | buf, |
RangeTblEntry * | rte, | ||
Index | rtindex, | ||
Relation | rel, | ||
List * | targetAttrs, | ||
List * | withCheckOptionList, | ||
List * | returningList, | ||
List ** | retrieved_attrs | ||
) |
Definition at line 2216 of file deparse.c.
References appendStringInfo(), appendStringInfoString(), attnum, buf, deparseColumnRef(), deparseRelation(), deparseReturningList(), lfirst_int, RelationGetDescr, TriggerDesc::trig_update_after_row, RelationData::trigdesc, and TupleDescAttr.
Referenced by postgresPlanForeignModify().
void do_sql_command | ( | PGconn * | conn, |
const char * | sql | ||
) |
Definition at line 717 of file connection.c.
References conn, do_sql_command_begin(), and do_sql_command_end().
Referenced by begin_remote_xact(), configure_remote_session(), pgfdw_subxact_callback(), pgfdw_xact_callback(), and postgresExecForeignTruncate().
int ExtractConnectionOptions | ( | List * | defelems, |
const char ** | keywords, | ||
const char ** | values | ||
) |
Definition at line 414 of file option.c.
References defGetString(), DefElem::defname, i, InitPgFdwOptions(), is_libpq_option(), lfirst, and values.
Referenced by connect_pg_server().
Definition at line 445 of file option.c.
References ereport, errcode(), errmsg(), ERROR, get_extension_oid(), lappend_oid(), lfirst, list_free(), NIL, OidIsValid, pstrdup(), SplitIdentifierString(), and WARNING.
Referenced by apply_server_options(), and postgres_fdw_validator().
EquivalenceMember* find_em_for_rel | ( | PlannerInfo * | root, |
EquivalenceClass * | ec, | ||
RelOptInfo * | rel | ||
) |
Definition at line 7832 of file postgres_fdw.c.
References bms_intersect(), bms_is_empty, bms_is_subset(), EquivalenceClass::ec_members, EquivalenceMember::em_expr, EquivalenceMember::em_relids, PgFdwRelationInfo::hidden_subquery_rels, is_foreign_expr(), lfirst, RelOptInfo::relids, and root.
Referenced by appendOrderByClause(), get_useful_pathkeys_for_relation(), and is_foreign_pathkey().
EquivalenceMember* find_em_for_rel_target | ( | PlannerInfo * | root, |
EquivalenceClass * | ec, | ||
RelOptInfo * | rel | ||
) |
Definition at line 7868 of file postgres_fdw.c.
References arg, EquivalenceClass::ec_members, EquivalenceMember::em_expr, EquivalenceMember::em_is_child, EquivalenceMember::em_is_const, equal(), PathTarget::exprs, get_pathtarget_sortgroupref, get_sortgroupref_clause_noerr(), i, is_foreign_expr(), IsA, lfirst, RelOptInfo::reltarget, and root.
Referenced by add_foreign_ordered_paths(), and appendOrderByClause().
const char* get_jointype_name | ( | JoinType | jointype | ) |
Definition at line 1641 of file deparse.c.
References elog, ERROR, JOIN_FULL, JOIN_INNER, JOIN_LEFT, JOIN_RIGHT, and JOIN_SEMI.
Referenced by deparseFromExprForRel(), and foreign_join_ok().
PGconn* GetConnection | ( | UserMapping * | user, |
bool | will_prep_stmt, | ||
PgFdwConnState ** | state | ||
) |
Definition at line 195 of file connection.c.
References Assert, begin_remote_xact(), CacheRegisterSyscacheCallback(), ConnCacheEntry::conn, CONNECTION_BAD, ConnectionHash, CopyErrorData(), ctl, CurrentMemoryContext, DEBUG3, disconnect_pg_server(), elog, ereport, errdetail_internal(), errmsg_internal(), FlushErrorState(), FreeErrorData(), HASH_BLOBS, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), ConnCacheEntry::have_prep_stmt, ConnCacheEntry::invalidated, sort-test::key, make_new_connection(), MemoryContextSwitchTo(), pchomp(), PgFdwConnState::pendingAreq, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pgfdw_inval_callback(), pgfdw_reject_incomplete_xact_state_change(), pgfdw_subxact_callback(), pgfdw_we_get_result, pgfdw_xact_callback(), PQerrorMessage(), PQstatus(), process_pending_request(), RegisterSubXactCallback(), RegisterXactCallback(), ErrorData::sqlerrcode, ConnCacheEntry::state, user, WaitEventExtensionNew(), ConnCacheEntry::xact_depth, and xact_got_connection.
Referenced by create_foreign_modify(), dumpDatabase(), dumpDatabaseConfig(), dumpLOs(), dumpTableData_copy(), estimate_path_cost_size(), expand_extension_name_patterns(), expand_foreign_server_name_patterns(), expand_schema_name_patterns(), expand_table_name_patterns(), getTables(), main(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresBeginDirectModify(), postgresBeginForeignScan(), postgresExecForeignTruncate(), postgresGetAnalyzeInfoForForeignTable(), postgresImportForeignSchema(), setup_connection(), StartLogStreamer(), StreamLog(), and StreamLogicalLog().
unsigned int GetCursorNumber | ( | PGconn * | conn | ) |
Definition at line 824 of file connection.c.
References cursor_number.
Referenced by postgresAcquireSampleRowsFunc(), and postgresBeginForeignScan().
unsigned int GetPrepStmtNumber | ( | PGconn * | conn | ) |
Definition at line 838 of file connection.c.
References prep_stmt_number.
Referenced by prepare_foreign_modify().
Definition at line 152 of file shippable.c.
References FirstGenbkiObjectId.
Referenced by deparse_type_name(), and is_shippable().
bool is_foreign_expr | ( | PlannerInfo * | root, |
RelOptInfo * | baserel, | ||
Expr * | expr | ||
) |
Definition at line 244 of file deparse.c.
References foreign_loc_cxt::collation, contain_mutable_functions(), FDW_COLLATE_NONE, FDW_COLLATE_UNSAFE, foreign_expr_walker(), foreign_glob_cxt::foreignrel, if(), InvalidOid, IS_UPPER_REL, PgFdwRelationInfo::outerrel, foreign_glob_cxt::relids, RelOptInfo::relids, foreign_glob_cxt::root, root, and foreign_loc_cxt::state.
Referenced by add_foreign_final_paths(), classifyConditions(), find_em_for_rel(), find_em_for_rel_target(), foreign_grouping_ok(), foreign_join_ok(), postgresGetForeignPaths(), postgresGetForeignPlan(), and postgresPlanDirectModify().
bool is_foreign_param | ( | PlannerInfo * | root, |
RelOptInfo * | baserel, | ||
Expr * | expr | ||
) |
Definition at line 1082 of file deparse.c.
References bms_is_member(), if(), IS_UPPER_REL, nodeTag, PgFdwRelationInfo::outerrel, RelOptInfo::relids, Var::varlevelsup, and Var::varno.
Referenced by foreign_grouping_ok().
bool is_foreign_pathkey | ( | PlannerInfo * | root, |
RelOptInfo * | baserel, | ||
PathKey * | pathkey | ||
) |
Definition at line 1123 of file deparse.c.
References EquivalenceClass::ec_has_volatile, find_em_for_rel(), if(), is_shippable(), PathKey::pk_opfamily, and root.
Referenced by get_useful_pathkeys_for_relation().
bool is_shippable | ( | Oid | objectId, |
Oid | classId, | ||
PgFdwRelationInfo * | fpinfo | ||
) |
Definition at line 162 of file shippable.c.
References HASH_ENTER, HASH_FIND, hash_search(), InitializeShippableCache(), is_builtin(), sort-test::key, lookup_shippable(), NIL, PgFdwRelationInfo::server, ForeignServer::serverid, ShippableCacheEntry::shippable, PgFdwRelationInfo::shippable_extensions, and ShippableCacheHash.
Referenced by add_foreign_ordered_paths(), foreign_expr_walker(), get_useful_pathkeys_for_relation(), and is_foreign_pathkey().
PGresult* pgfdw_exec_query | ( | PGconn * | conn, |
const char * | query, | ||
PgFdwConnState * | state | ||
) |
Definition at line 853 of file connection.c.
References conn, pgfdw_get_result(), PQsendQuery(), and process_pending_request().
Referenced by close_cursor(), deallocate_query(), fetch_more_data(), get_remote_estimate(), pgfdw_xact_callback(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresGetAnalyzeInfoForForeignTable(), postgresImportForeignSchema(), and postgresReScanForeignScan().
Definition at line 870 of file connection.c.
References conn, libpqsrv_get_result_last(), and pgfdw_we_get_result.
Referenced by create_cursor(), do_sql_command_end(), execute_dml_stmt(), execute_foreign_modify(), fetch_more_data(), pgfdw_exec_query(), and prepare_foreign_modify().
Definition at line 889 of file connection.c.
References conn, ereport, errcode(), errcontext, errdetail_internal(), errhint(), errmsg(), errmsg_internal(), MAKE_SQLSTATE, pchomp(), PG_DIAG_CONTEXT, PG_DIAG_MESSAGE_DETAIL, PG_DIAG_MESSAGE_HINT, PG_DIAG_MESSAGE_PRIMARY, PG_DIAG_SQLSTATE, PG_END_TRY, PG_FINALLY, PG_TRY, PQclear(), PQerrorMessage(), PQresultErrorField(), and res.
Referenced by close_cursor(), create_cursor(), deallocate_query(), do_sql_command_begin(), do_sql_command_end(), execute_dml_stmt(), execute_foreign_modify(), fetch_more_data(), fetch_more_data_begin(), get_remote_estimate(), pgfdw_exec_cleanup_query_begin(), pgfdw_exec_cleanup_query_end(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresForeignAsyncNotify(), postgresGetAnalyzeInfoForForeignTable(), postgresImportForeignSchema(), postgresReScanForeignScan(), and prepare_foreign_modify().
void process_pending_request | ( | AsyncRequest * | areq | ) |
Definition at line 7505 of file postgres_fdw.c.
References Assert, AsyncRequest::callback_pending, ExecAsyncRequestDone(), ExecAsyncResponse(), ForeignScanState::fdw_state, fetch_more_data(), and AsyncRequest::requestee.
Referenced by create_cursor(), execute_dml_stmt(), execute_foreign_modify(), GetConnection(), pgfdw_exec_query(), and postgresForeignAsyncConfigureWait().
char* process_pgfdw_appname | ( | const char * | appname | ) |
Definition at line 491 of file option.c.
References appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), application_name, buf, cluster_name, Port::database_name, dbname, initStringInfo(), MyProcPid, MyProcPort, MyStartTime, Port::user_name, and username.
Referenced by connect_pg_server().
void rebuildInsertSql | ( | StringInfo | buf, |
Relation | rel, | ||
char * | orig_query, | ||
List * | target_attrs, | ||
int | values_end_len, | ||
int | num_params, | ||
int | num_rows | ||
) |
Definition at line 2156 of file deparse.c.
References appendBinaryStringInfo(), appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert, attnum, buf, i, lfirst_int, RelationGetDescr, and TupleDescAttr.
Referenced by execute_foreign_modify().
void ReleaseConnection | ( | PGconn * | conn | ) |
Definition at line 803 of file connection.c.
Referenced by estimate_path_cost_size(), finish_foreign_modify(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresEndDirectModify(), postgresEndForeignScan(), postgresGetAnalyzeInfoForForeignTable(), and postgresImportForeignSchema().
void reset_transmission_modes | ( | int | nestlevel | ) |
Definition at line 3946 of file postgres_fdw.c.
References AtEOXact_GUC().
Referenced by appendConditions(), appendLimitClause(), appendOrderByClause(), convert_prep_stmt_params(), deparseDirectUpdateSql(), and process_query_params().
int set_transmission_modes | ( | void | ) |
Definition at line 3910 of file postgres_fdw.c.
References DateStyle, extra_float_digits, GUC_ACTION_SAVE, IntervalStyle, INTSTYLE_POSTGRES, NewGUCNestLevel(), PGC_S_SESSION, PGC_USERSET, set_config_option(), and USE_ISO_DATES.
Referenced by appendConditions(), appendLimitClause(), appendOrderByClause(), convert_prep_stmt_params(), deparseDirectUpdateSql(), and process_query_params().
|
extern |
Definition at line 52 of file option.c.
Referenced by _PG_init(), and connect_pg_server().