#include "postgres.h"
#include <poll.h>
#include "access/htup_details.h"
#include "access/xact.h"
#include "catalog/pg_user_mapping.h"
#include "commands/defrem.h"
#include "common/base64.h"
#include "funcapi.h"
#include "libpq/libpq-be.h"
#include "libpq/libpq-be-fe-helpers.h"
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "postgres_fdw.h"
#include "storage/latch.h"
#include "utils/builtins.h"
#include "utils/hsearch.h"
#include "utils/inval.h"
#include "utils/syscache.h"
Go to the source code of this file.
Definition at line 98 of file connection.c.
Definition at line 108 of file connection.c.
Definition at line 2139 of file connection.c.
Definition at line 2137 of file connection.c.
Definition at line 2138 of file connection.c.
Definition at line 105 of file connection.c.
Definition at line 53 of file connection.c.
Enumerator | |
---|---|
PGFDW_V1_1 | |
PGFDW_V1_2 |
Definition at line 122 of file connection.c.
Definition at line 854 of file connection.c.
References ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, DEBUG3, do_sql_command(), elog, GetCurrentTransactionNestLevel(), IsolationIsSerializable, snprintf, and ConnCacheEntry::xact_depth.
Referenced by GetConnection().
Definition at line 721 of file connection.c.
References be_gssapi_get_delegation(), ereport, errcode(), errdetail(), errmsg(), ERROR, Port::has_scram_keys, i, keywords, MyProcPort, pgfdw_has_required_scram_options(), superuser_arg(), user, UserMappingPasswordRequired(), and values.
Referenced by connect_pg_server().
Definition at line 773 of file connection.c.
References conn, do_sql_command(), and PQserverVersion().
Referenced by connect_pg_server().
Definition at line 482 of file connection.c.
References check_conn_params(), configure_remote_session(), conn, CONNECTION_OK, elog, ereport, errcode(), errdetail_internal(), errmsg(), ERROR, ExtractConnectionOptions(), GetDatabaseEncodingName(), Port::has_scram_keys, i, keywords, len, libpqsrv_connect_params(), libpqsrv_disconnect(), libpqsrv_notice_receiver(), list_length(), MyProcPort, ForeignServer::options, palloc(), palloc0(), pchomp(), pfree(), pg_b64_enc_len(), pg_b64_encode(), PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pgfdw_application_name, pgfdw_security_check(), pgfdw_we_connect, PQerrorMessage(), PQsetNoticeReceiver(), PQstatus(), process_pgfdw_appname(), Port::scram_ClientKey, Port::scram_ServerKey, ForeignServer::servername, user, UseScramPassthrough(), values, and WaitEventExtensionNew().
Referenced by make_new_connection().
Definition at line 2397 of file connection.c.
References Assert(), ConnCacheEntry::conn, ConnectionHash, DEBUG3, disconnect_pg_server(), elog, ereport, errmsg(), FSV_MISSING_OK, GetForeignServerExtended(), hash_seq_init(), hash_seq_search(), ConnCacheEntry::invalidated, OidIsValid, ConnCacheEntry::serverid, ForeignServer::servername, WARNING, and ConnCacheEntry::xact_depth.
Referenced by postgres_fdw_disconnect(), and postgres_fdw_disconnect_all().
Definition at line 659 of file connection.c.
References ConnCacheEntry::conn, and libpqsrv_disconnect().
Referenced by disconnect_cached_connections(), GetConnection(), pgfdw_inval_callback(), pgfdw_reject_incomplete_xact_state_change(), and pgfdw_reset_xact_state().
Definition at line 811 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().
Definition at line 818 of file connection.c.
References conn, pgfdw_report_error(), and PQsendQuery().
Referenced by do_sql_command(), pgfdw_subxact_callback(), and pgfdw_xact_callback().
Definition at line 825 of file connection.c.
References conn, pgfdw_get_result(), pgfdw_report_error(), PGRES_COMMAND_OK, PQclear, PQconsumeInput(), and PQresultStatus.
Referenced by do_sql_command(), pgfdw_finish_pre_commit_cleanup(), and pgfdw_finish_pre_subcommit_cleanup().
Definition at line 206 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().
Definition at line 918 of file connection.c.
References cursor_number.
Referenced by postgresAcquireSampleRowsFunc(), and postgresBeginForeignScan().
Definition at line 932 of file connection.c.
References prep_stmt_number.
Referenced by prepare_foreign_modify().
Definition at line 369 of file connection.c.
References Assert(), ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, connect_pg_server(), DEBUG3, defGetBoolean(), DefElem::defname, elog, GetForeignServer(), GetSysCacheHashValue1, ConnCacheEntry::have_error, ConnCacheEntry::have_prep_stmt, ConnCacheEntry::invalidated, ConnCacheEntry::keep_connections, lfirst, ConnCacheEntry::mapping_hashvalue, ObjectIdGetDatum(), ForeignServer::options, ConnCacheEntry::parallel_abort, ConnCacheEntry::parallel_commit, ConnCacheEntry::server_hashvalue, ConnCacheEntry::serverid, ForeignServer::serverid, ForeignServer::servername, ConnCacheEntry::state, user, and ConnCacheEntry::xact_depth.
Referenced by GetConnection().
Definition at line 1734 of file connection.c.
References ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, CONSTRUCT_ABORT_COMMAND, ConnCacheEntry::have_error, ConnCacheEntry::have_prep_stmt, in_error_recursion_trouble(), PgFdwConnState::pendingAreq, pgfdw_cancel_query(), pgfdw_exec_cleanup_query(), PQTRANS_ACTIVE, PQtransactionStatus(), and ConnCacheEntry::state.
Referenced by pgfdw_subxact_callback(), and pgfdw_xact_callback().
Definition at line 1808 of file connection.c.
References ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, CONNECTION_CLEANUP_TIMEOUT, CONSTRUCT_ABORT_COMMAND, GetCurrentTimestamp(), ConnCacheEntry::have_error, in_error_recursion_trouble(), lappend(), pgfdw_cancel_query_begin(), pgfdw_exec_cleanup_query_begin(), PQTRANS_ACTIVE, PQtransactionStatus(), and TimestampTzPlusMilliseconds.
Referenced by pgfdw_subxact_callback(), and pgfdw_xact_callback().
Definition at line 1431 of file connection.c.
References conn, CONNECTION_CLEANUP_TIMEOUT, GetCurrentTimestamp(), now(), pgfdw_cancel_query_begin(), pgfdw_cancel_query_end(), RETRY_CANCEL_TIMEOUT, and TimestampTzPlusMilliseconds.
Referenced by pgfdw_abort_cleanup().
Definition at line 1464 of file connection.c.
References conn, ereport, errcode(), errmsg(), libpqsrv_cancel(), and WARNING.
Referenced by pgfdw_abort_cleanup_begin(), and pgfdw_cancel_query().
Definition at line 1477 of file connection.c.
References conn, ereport, errcode(), errmsg(), pchomp(), pgfdw_get_cleanup_result(), PQclear, PQconsumeInput(), PQerrorMessage(), and WARNING.
Referenced by pgfdw_cancel_query(), and pgfdw_finish_abort_cleanup().
Definition at line 2469 of file connection.c.
References conn, CONNECTION_OK, EINTR, PQsocket(), and PQstatus().
Referenced by postgres_fdw_get_connections_internal().
Definition at line 2506 of file connection.c.
Referenced by postgres_fdw_get_connections_internal().
Definition at line 1531 of file connection.c.
References conn, CONNECTION_CLEANUP_TIMEOUT, GetCurrentTimestamp(), pgfdw_exec_cleanup_query_begin(), pgfdw_exec_cleanup_query_end(), and TimestampTzPlusMilliseconds.
Referenced by pgfdw_abort_cleanup().
Definition at line 1551 of file connection.c.
References Assert(), conn, pgfdw_report(), PQsendQuery(), and WARNING.
Referenced by pgfdw_abort_cleanup_begin(), pgfdw_exec_cleanup_query(), and pgfdw_finish_abort_cleanup().
Definition at line 1569 of file connection.c.
References Assert(), conn, ereport, errcontext, errmsg(), pgfdw_get_cleanup_result(), pgfdw_report(), PGRES_COMMAND_OK, PQclear, PQconsumeInput(), PQresultStatus, and WARNING.
Referenced by pgfdw_exec_cleanup_query(), and pgfdw_finish_abort_cleanup().
Definition at line 947 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 1974 of file connection.c.
References Assert(), ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, CONNECTION_CLEANUP_TIMEOUT, CONSTRUCT_ABORT_COMMAND, GetCurrentTimestamp(), ConnCacheEntry::have_error, ConnCacheEntry::have_prep_stmt, lappend(), lfirst, NIL, now(), PgFdwConnState::pendingAreq, pgfdw_cancel_query_end(), pgfdw_exec_cleanup_query_begin(), pgfdw_exec_cleanup_query_end(), pgfdw_reset_xact_state(), RETRY_CANCEL_TIMEOUT, ConnCacheEntry::state, and TimestampTzPlusMilliseconds.
Referenced by pgfdw_subxact_callback(), and pgfdw_xact_callback().
Definition at line 1866 of file connection.c.
References Assert(), ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, CONNECTION_BAD, do_sql_command_end(), ConnCacheEntry::have_error, ConnCacheEntry::have_prep_stmt, lappend(), lfirst, NIL, pgfdw_reset_xact_state(), PQclear, PQgetResult, PQsendQuery(), and PQstatus().
Referenced by pgfdw_xact_callback().
Definition at line 1940 of file connection.c.
References Assert(), ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, do_sql_command_end(), lfirst, pgfdw_reset_xact_state(), and snprintf.
Referenced by pgfdw_subxact_callback().
Definition at line 1629 of file connection.c.
References CHECK_FOR_INTERRUPTS, conn, GetCurrentTimestamp(), libpqsrv_cancel(), Min, MyLatch, now(), pgfdw_we_cleanup_result, PQclear, PQconsumeInput(), PQgetResult, PQisBusy(), PQsocket(), ResetLatch(), RETRY_CANCEL_TIMEOUT, TimestampDifferenceMilliseconds(), TimestampTzPlusMilliseconds, WaitEventExtensionNew(), WaitLatchOrSocket(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_SOCKET_READABLE, and WL_TIMEOUT.
Referenced by pgfdw_cancel_query_end(), and pgfdw_exec_cleanup_query_end().
Definition at line 964 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 2524 of file connection.c.
References Port::has_scram_keys, i, keywords, MyProcPort, and values.
Referenced by check_conn_params(), and pgfdw_security_check().
Definition at line 1312 of file connection.c.
References Assert(), ConnCacheEntry::conn, ConnectionHash, DEBUG3, disconnect_pg_server(), elog, hash_seq_init(), hash_seq_search(), ConnCacheEntry::invalidated, ConnCacheEntry::mapping_hashvalue, ConnCacheEntry::server_hashvalue, and ConnCacheEntry::xact_depth.
Referenced by GetConnection().
Definition at line 1362 of file connection.c.
References ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, disconnect_pg_server(), ereport, errcode(), errmsg(), ERROR, GetForeignServer(), ConnCacheEntry::serverid, and ForeignServer::servername.
Referenced by GetConnection(), pgfdw_subxact_callback(), and pgfdw_xact_callback().
Definition at line 995 of file connection.c.
References Assert(), conn, ERROR, and pgfdw_report_internal().
Referenced by pgfdw_exec_cleanup_query_begin(), and pgfdw_exec_cleanup_query_end().
Definition at line 988 of file connection.c.
References conn, ERROR, pg_unreachable, and pgfdw_report_internal().
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(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresForeignAsyncNotify(), postgresGetAnalyzeInfoForForeignTable(), postgresImportForeignSchema(), postgresReScanForeignScan(), and prepare_foreign_modify().
Definition at line 1002 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, PQclear, PQerrorMessage(), and PQresultErrorField.
Referenced by pgfdw_report(), and pgfdw_report_error().
Definition at line 1386 of file connection.c.
References ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, CONNECTION_OK, DEBUG3, disconnect_pg_server(), elog, ConnCacheEntry::invalidated, ConnCacheEntry::keep_connections, PQstatus(), PQTRANS_IDLE, PQtransactionStatus(), and ConnCacheEntry::xact_depth.
Referenced by pgfdw_finish_abort_cleanup(), pgfdw_finish_pre_commit_cleanup(), pgfdw_finish_pre_subcommit_cleanup(), pgfdw_subxact_callback(), and pgfdw_xact_callback().
Definition at line 435 of file connection.c.
References be_gssapi_get_delegation(), conn, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, Port::has_scram_keys, i, keywords, MyProcPort, pgfdw_has_required_scram_options(), PQconnectionUsedGSSAPI(), PQconnectionUsedPassword(), superuser_arg(), user, UserMappingPasswordRequired(), and values.
Referenced by connect_pg_server().
Definition at line 1199 of file connection.c.
References Assert(), ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, ConnectionHash, do_sql_command(), do_sql_command_begin(), elog, ERROR, GetCurrentTransactionNestLevel(), hash_seq_init(), hash_seq_search(), lappend(), NIL, ConnCacheEntry::parallel_abort, ConnCacheEntry::parallel_commit, pgfdw_abort_cleanup(), pgfdw_abort_cleanup_begin(), pgfdw_finish_abort_cleanup(), pgfdw_finish_pre_subcommit_cleanup(), pgfdw_reject_incomplete_xact_state_change(), pgfdw_reset_xact_state(), snprintf, SUBXACT_EVENT_ABORT_SUB, SUBXACT_EVENT_PRE_COMMIT_SUB, ConnCacheEntry::xact_depth, and xact_got_connection.
Referenced by GetConnection().
Definition at line 1049 of file connection.c.
References Assert(), ConnCacheEntry::changing_xact_state, ConnCacheEntry::conn, ConnectionHash, cursor_number, DEBUG3, do_sql_command(), do_sql_command_begin(), elog, ereport, errcode(), errmsg(), ERROR, hash_seq_init(), hash_seq_search(), ConnCacheEntry::have_error, ConnCacheEntry::have_prep_stmt, lappend(), NIL, ConnCacheEntry::parallel_abort, ConnCacheEntry::parallel_commit, pgfdw_abort_cleanup(), pgfdw_abort_cleanup_begin(), pgfdw_exec_query(), pgfdw_finish_abort_cleanup(), pgfdw_finish_pre_commit_cleanup(), pgfdw_reject_incomplete_xact_state_change(), pgfdw_reset_xact_state(), PQclear, ConnCacheEntry::xact_depth, XACT_EVENT_ABORT, XACT_EVENT_COMMIT, XACT_EVENT_PARALLEL_ABORT, XACT_EVENT_PARALLEL_COMMIT, XACT_EVENT_PARALLEL_PRE_COMMIT, XACT_EVENT_PRE_COMMIT, XACT_EVENT_PRE_PREPARE, XACT_EVENT_PREPARE, and xact_got_connection.
Referenced by GetConnection().
Definition at line 2348 of file connection.c.
References disconnect_cached_connections(), GetForeignServerByName(), PG_GETARG_TEXT_PP, PG_RETURN_BOOL, ForeignServer::serverid, and text_to_cstring().
Definition at line 2369 of file connection.c.
References disconnect_cached_connections(), InvalidOid, and PG_RETURN_BOOL.
Definition at line 2328 of file connection.c.
References PG_RETURN_VOID, PGFDW_V1_1, and postgres_fdw_get_connections_internal().
Definition at line 2320 of file connection.c.
References PG_RETURN_VOID, PGFDW_V1_2, and postgres_fdw_get_connections_internal().
Definition at line 2168 of file connection.c.
References Assert(), BoolGetDatum(), ConnectionHash, CStringGetTextDatum, elog, ERROR, FSV_MISSING_OK, GetForeignServerExtended(), GETSTRUCT(), hash_seq_init(), hash_seq_search(), HeapTupleIsValid, i, InitMaterializedSRF(), Int32GetDatum(), MappingUserName, TupleDescData::natts, ObjectIdGetDatum(), PG_GETARG_BOOL, pgfdw_conn_check(), pgfdw_conn_checkable(), PGFDW_V1_1, PGFDW_V1_2, POSTGRES_FDW_GET_CONNECTIONS_COLS, POSTGRES_FDW_GET_CONNECTIONS_COLS_V1_1, POSTGRES_FDW_GET_CONNECTIONS_COLS_V1_2, PQbackendPID(), ReleaseSysCache(), FunctionCallInfoBaseData::resultinfo, SearchSysCache1(), ForeignServer::servername, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, tuplestore_putvalues(), and values.
Referenced by postgres_fdw_get_connections(), and postgres_fdw_get_connections_1_2().
Definition at line 897 of file connection.c.
Referenced by estimate_path_cost_size(), finish_foreign_modify(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresEndDirectModify(), postgresEndForeignScan(), postgresGetAnalyzeInfoForForeignTable(), and postgresImportForeignSchema().
Definition at line 673 of file connection.c.
References defGetBoolean(), DefElem::defname, lfirst, and user.
Referenced by check_conn_params(), and pgfdw_security_check().
Definition at line 689 of file connection.c.
References defGetBoolean(), DefElem::defname, lfirst, ForeignServer::options, and user.
Referenced by connect_pg_server().
Definition at line 79 of file connection.c.
Referenced by disconnect_cached_connections(), GetConnection(), pgfdw_inval_callback(), pgfdw_subxact_callback(), pgfdw_xact_callback(), and postgres_fdw_get_connections_internal().
Definition at line 82 of file connection.c.
Referenced by close_cursor(), GetCursorNumber(), pgfdw_xact_callback(), and postgresAcquireSampleRowsFunc().
Definition at line 89 of file connection.c.
Referenced by pgfdw_get_cleanup_result().
Definition at line 90 of file connection.c.
Referenced by connect_pg_server().
Definition at line 91 of file connection.c.
Referenced by GetConnection(), and pgfdw_get_result().
Definition at line 83 of file connection.c.
Referenced by GetPrepStmtNumber().
Definition at line 86 of file connection.c.
Referenced by GetConnection(), pgfdw_subxact_callback(), and pgfdw_xact_callback().