#include "postgres_fe.h"
#include <sys/time.h>
#include <unistd.h>
#include "access/xlog_internal.h"
#include "common/connect.h"
#include "common/file_perm.h"
#include "common/logging.h"
#include "common/string.h"
#include "datatype/timestamp.h"
#include "port/pg_bswap.h"
#include "pqexpbuffer.h"
#include "streamutil.h"
Go to the source code of this file.
Definition at line 30 of file streamutil.c.
Definition at line 42 of file streamutil.c.
Definition at line 37 of file streamutil.c.
Definition at line 790 of file streamutil.c.
References AppendPlainCommandOption(), appendPQExpBuffer(), and buf.
Referenced by BaseBackup().
Definition at line 746 of file streamutil.c.
References appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), and buf.
Referenced by AppendIntegerCommandOption(), AppendStringCommandOption(), BaseBackup(), and CreateReplicationSlot().
Definition at line 767 of file streamutil.c.
References AppendPlainCommandOption(), appendPQExpBuffer(), buf, conn, palloc(), pfree(), and PQescapeStringConn().
Referenced by BaseBackup(), and CreateReplicationSlot().
Definition at line 584 of file streamutil.c.
References AppendPlainCommandOption(), appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), AppendStringCommandOption(), Assert(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), ERRCODE_DUPLICATE_OBJECT, failover, PQExpBufferData::len, PG_DIAG_SQLSTATE, pg_log_error, PGRES_TUPLES_OK, plugin, PQclear, PQerrorMessage(), PQexec(), PQnfields, PQntuples, PQresultErrorField, PQresultStatus, PQserverVersion(), slot_exists_ok, and two_phase.
Definition at line 697 of file streamutil.c.
References appendPQExpBuffer(), Assert(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), pg_log_error, PGRES_COMMAND_OK, PQclear, PQerrorMessage(), PQexec(), PQnfields, PQntuples, and PQresultStatus.
Definition at line 868 of file streamutil.c.
References buf, and pg_ntoh64.
Referenced by ProcessWALDataMsg(), and StreamLogicalLog().
Definition at line 857 of file streamutil.c.
References buf, i, and pg_hton64.
Referenced by sendFeedback().
Definition at line 803 of file streamutil.c.
References gettimeofday(), POSTGRES_EPOCH_JDATE, SECS_PER_DAY, UNIX_EPOCH_JDATE, and USECS_PER_SEC.
Referenced by flushAndSendFeedback(), HandleCopyStream(), ProcessKeepaliveMsg(), and StreamLogicalLog().
Definition at line 822 of file streamutil.c.
References start_time, and USECS_PER_SEC.
Referenced by CalculateCopyStreamSleeptime(), and StreamLogicalLog().
Definition at line 844 of file streamutil.c.
References INT64CONST, and start_time.
Referenced by HandleCopyStream(), and StreamLogicalLog().
Definition at line 60 of file streamutil.c.
References ALWAYS_SECURE_SEARCH_PATH_SQL, Assert(), CONNECTION_BAD, CONNECTION_OK, connection_string, dbgetpassword, dbhost, dbname, dbport, dbuser, free, i, _PQconninfoOption::keyword, keywords, password, pg_fatal, pg_log_error, pg_malloc0(), PGRES_TUPLES_OK, PQclear, PQconnectdbParams(), PQconnectionNeedsPassword(), PQconninfoFree(), PQconninfoParse(), PQerrorMessage(), PQexec(), PQfinish(), PQparameterStatus(), PQresultStatus, PQserverVersion(), PQstatus(), progname, RetrieveDataDirCreatePerm(), simple_prompt(), _PQconninfoOption::val, and values.
Definition at line 490 of file streamutil.c.
References appendPQExpBuffer(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), InvalidXLogRecPtr, pg_log_error, PGRES_TUPLES_OK, PQclear, PQerrorMessage(), PQexec(), PQgetisnull, PQgetvalue, PQnfields, PQntuples, and PQresultStatus.
Referenced by StreamLog().
Definition at line 355 of file streamutil.c.
References Assert(), conn, data_directory_mode, MINIMUM_VERSION_FOR_GROUP_ACCESS, pg_log_error, PGRES_TUPLES_OK, PQclear, PQerrorMessage(), PQexec(), PQgetvalue, PQnfields, PQntuples, PQresultStatus, PQserverVersion(), and SetDataDirectoryCreatePerm().
Referenced by GetConnection().
Definition at line 276 of file streamutil.c.
References Assert(), conn, DEFAULT_XLOG_SEG_SIZE, IsValidWalSegSize, MINIMUM_VERSION_FOR_SHOW_CMD, ngettext, pg_log_error, pg_log_error_detail, PGRES_TUPLES_OK, PQclear, PQerrorMessage(), PQexec(), PQgetvalue, PQnfields, PQntuples, PQresultStatus, PQserverVersion(), and WalSegSz.
Referenced by main().
Definition at line 409 of file streamutil.c.
References Assert(), conn, pg_log_error, pg_strdup(), PGRES_TUPLES_OK, PQclear, PQerrorMessage(), PQexec(), PQgetisnull, PQgetvalue, PQnfields, PQntuples, PQresultStatus, PQserverVersion(), and startpos.
Referenced by BaseBackup(), main(), ReceiveXlogStream(), and StreamLog().
Definition at line 52 of file streamutil.c.
Referenced by add_client_identification(), append_db_pattern_cte(), append_rel_pattern_filtered_cte(), append_rel_pattern_raw_cte(), appendQualifiedRelation(), AppendStringCommandOption(), appendStringLiteralConn(), applyRemoteGucs(), BaseBackup(), build_client_final_message(), build_client_first_message(), build_startup_packet(), buildShSecLabels(), canChangeResultMode(), check_and_drop_existing_subscriptions(), check_and_drop_publications(), check_expected_areq(), check_for_pg_role_prefix(), check_for_prepared_transactions(), check_is_install_user(), check_issuer(), check_loadable_libraries(), check_new_cluster_replication_slots(), check_new_cluster_subscription_configuration(), check_old_cluster_subscription_state(), check_prepare_conn(), check_publisher(), check_subscriber(), CheckCopyStreamStop(), CheckServerVersionForStreaming(), cleanup_objects_atexit(), cleanup_user_oauth_flow(), clear_allowed_sasl_mechs(), client_initial_response(), close_cursor(), cluster_all_databases(), cluster_one_database(), compile_database_list(), compile_relation_list_one_db(), configure_remote_session(), confirm_result_status_impl(), connect_database(), connect_pg_server(), ConnectDatabase(), connectDatabase(), connectFailureMessage(), connection_failed(), connectMaintenanceDatabase(), connectNoDelay(), connectOptions1(), connectToServer(), consume_null_result_impl(), consume_query_cancel_impl(), consume_result_status_impl(), copy_connection(), CopyStreamPoll(), CopyStreamReceive(), create_cursor(), create_logical_replication_slot(), create_logical_replication_slots(), create_publication(), create_subscription(), CreateReplicationSlot(), dblink_cancel_query(), dblink_close(), dblink_connect(), dblink_disconnect(), dblink_error_message(), dblink_exec(), dblink_fetch(), dblink_get_conn(), dblink_get_notify(), dblink_is_busy(), dblink_open(), dblink_record_internal(), dblink_res_error(), dblink_res_internalerror(), dblink_security_check(), dblink_send_query(), disconnect_atexit(), disconnect_database(), disconnectDatabase(), do_sql_command(), do_sql_command_begin(), do_sql_command_end(), doConnect(), drop_existing_subscriptions(), drop_failover_replication_slots(), drop_primary_replication_slot(), drop_publication(), drop_replication_slot(), dropDBs(), DropReplicationSlot(), dropRoles(), dropTablespaces(), dumpDatabase(), dumpDatabaseConfig(), dumpDatabases(), dumpLOs(), dumpRoleGUCPrivs(), dumpRoleMembership(), dumpRoles(), dumpTableData_copy(), dumpTablespaces(), dumpUserConfig(), ecpg_raise_backend(), emitHostIdentityInfo(), emitShSecLabels(), enable_subscription(), escape_append_literal(), escape_fmt_id(), escape_identifier(), escape_literal(), escape_string_conn(), estimate_path_cost_size(), executeCommand(), executeMaintenanceCommand(), executeQuery(), executeQueryOrDie(), ExecuteSqlCommand(), exit_nicely(), expand_dbname_patterns(), exportFile(), fetch_more_data(), fill_allowed_sasl_mechs(), fillPGconn(), flushAndSendFeedback(), free_async_ctx(), freePGconn(), gen_reindex_command(), generate_object_name(), get_db_conn(), get_db_infos(), get_parallel_tabidx_list(), get_parallel_tables_list(), get_primary_sysid(), get_publisher_databases(), get_remote_estimate(), get_subscription_info(), get_tablespace_paths(), get_template0_info(), getAnotherTuple(), getBackendKeyData(), getCopyDataMessage(), getCopyResult(), getCopyStart(), getHostaddr(), getNotify(), getParamDescriptions(), getParameterStatus(), getReadyForQuery(), getRowDescriptions(), GetSlotInformation(), gss_read(), handle_oauth_sasl_error(), handleCopyIn(), handleCopyOut(), HandleCopyStream(), HandleEndOfCopyStream(), handleFatalError(), handleSyncLoss(), importFile(), index_of_allowed_sasl_mech(), init_allowed_encryption_methods(), init_libpq_conn(), init_libpq_source(), initialize_curl(), initialize_SSL(), internal_ping(), issuer_from_well_known_uri(), libpq_append_conn_error(), libpq_fetch_file(), libpq_get_current_wal_insert_lsn(), libpq_prng_init(), libpq_traverse_files(), libpqrcv_alter_slot(), libpqrcv_connect(), libpqrcv_create_slot(), libpqrcv_disconnect(), libpqrcv_endstreaming(), libpqrcv_exec(), libpqrcv_get_backend_pid(), libpqrcv_get_conninfo(), libpqrcv_get_senderinfo(), libpqrcv_identify_system(), libpqrcv_readtimelinehistoryfile(), libpqrcv_receive(), libpqrcv_send(), libpqrcv_server_version(), libpqrcv_startstreaming(), libpqsrv_cancel(), libpqsrv_connect(), libpqsrv_connect_internal(), libpqsrv_connect_params(), libpqsrv_disconnect(), libpqsrv_exec(), libpqsrv_exec_params(), libpqsrv_get_result(), libpqsrv_get_result_last(), libpqsrv_PQgetResult(), lo_close(), lo_creat(), lo_create(), lo_export(), lo_import(), lo_import_internal(), lo_import_with_oid(), lo_initialize(), lo_lseek(), lo_lseek64(), lo_open(), lo_read(), lo_tell(), lo_tell64(), lo_truncate(), lo_truncate64(), lo_unlink(), lo_write(), main(), makeAlterConfigCommand(), materializeQueryResult(), materializeResult(), my_truncate(), oauth_exchange(), oauth_init(), old_9_6_invalidate_hash_indexes(), open_client_SSL(), openssl_verify_peer_name_matches_certificate_ip(), openssl_verify_peer_name_matches_certificate_name(), overwrite(), ParallelSlotsAdoptConn(), ParallelSlotsTerminate(), parseInput(), pg_fe_cleanup_oauth_flow(), pg_fe_run_oauth_flow(), pg_fe_run_oauth_flow_impl(), pg_fe_sendauth(), pg_GSS_error(), pg_GSS_load_servicename(), pg_GSS_read(), pg_GSS_write(), pg_password_sendauth(), pg_SASL_continue(), pg_SASL_init(), pgconn_bio_ctrl(), pgconn_bio_read(), pgfdw_cancel_query(), pgfdw_cancel_query_begin(), pgfdw_cancel_query_end(), pgfdw_conn_check(), pgfdw_exec_cleanup_query(), pgfdw_exec_cleanup_query_begin(), pgfdw_exec_cleanup_query_end(), pgfdw_exec_query(), pgfdw_get_cleanup_result(), pgfdw_get_result(), pgfdw_report(), pgfdw_report_error(), pgfdw_report_internal(), pgfdw_security_check(), pgpassfileWarning(), pgtls_close(), pgtls_get_peer_certificate_hash(), pgtls_open_client(), pgtls_read(), pgtls_read_pending(), pgtls_verify_peer_name_matches_certificate_guts(), pgtls_write(), pickout(), postgresAcquireSampleRowsFunc(), postgresAnalyzeForeignTable(), postgresExecForeignTruncate(), postgresGetAnalyzeInfoForForeignTable(), postgresImportForeignSchema(), pq_verify_peer_name_matches_certificate(), pq_verify_peer_name_matches_certificate_ip(), pq_verify_peer_name_matches_certificate_name(), pqAllocCmdQueueEntry(), pqAppendCmdQueueEntry(), PQbackendPID(), pqBuildStartupPacket3(), PQcancelCreate(), PQcancelPoll(), PQchangePassword(), pqCheckInBufferSpace(), pqCheckOutBufferSpace(), pqClearAsyncResult(), pqClearOAuthToken(), PQclientEncoding(), pqClosePGconn(), PQclosePortal(), PQclosePrepared(), pqCommandQueueAdvance(), PQconnectdb(), pqConnectDBComplete(), PQconnectdbParams(), pqConnectDBStart(), PQconnectionNeedsPassword(), PQconnectionUsedGSSAPI(), PQconnectionUsedPassword(), pqConnectOptions2(), PQconnectPoll(), PQconnectStart(), PQconnectStartParams(), PQconninfo(), PQconsumeInput(), PQdb(), PQdefaultSSLKeyPassHook_OpenSSL(), PQdescribePortal(), PQdescribePrepared(), pqDropConnection(), pqDropServerData(), PQencryptPasswordConn(), PQendcopy(), pqEndcopy3(), PQenterPipelineMode(), PQerrorMessage(), PQescapeByteaConn(), PQescapeByteaInternal(), PQescapeIdentifier(), PQescapeInternal(), PQescapeLiteral(), PQescapeStringConn(), PQescapeStringInternal(), PQexec(), PQexecFinish(), PQexecParams(), PQexecPrepared(), PQexecStart(), PQexitPipelineMode(), PQfinish(), PQfireResultCreateEvents(), PQflush(), pqFlush(), PQfn(), PQfullProtocolVersion(), pqFunctionCall3(), pqGetc(), PQgetCancel(), PQgetCopyData(), pqGetCopyData3(), pqGetErrorNotice3(), PQgetgssctx(), pqGetInt(), PQgetline(), pqGetline3(), PQgetlineAsync(), pqGetlineAsync3(), pqGetnchar(), pqGetNegotiateProtocolVersion3(), PQgetResult(), pqGets(), pqGets_append(), pqGets_internal(), PQgetssl(), PQgssEncInUse(), PQhost(), PQhostaddr(), PQinstanceData(), PQisBusy(), PQisnonblocking(), pqMakeEmptyPGconn(), PQmakeEmptyPGresult(), PQnotifies(), PQoptions(), pqPacketSend(), PQparameterStatus(), pqParseDone(), pqParseInput3(), pqParseIntParam(), pqParseProtocolVersion(), PQpass(), PQping(), PQpingParams(), pqPipelineFlush(), pqPipelineProcessQueue(), PQpipelineStatus(), PQpipelineSync(), pqPipelineSyncInternal(), PQport(), PQprepare(), pqPrepareAsyncResult(), PQprotocolVersion(), pqPutc(), PQputCopyData(), PQputCopyEnd(), pqPutInt(), PQputline(), pqPutMsgBytes(), pqPutMsgEnd(), pqPutMsgStart(), PQputnbytes(), pqPutnchar(), pqPuts(), pqReadData(), pqReadReady(), pqRecycleCmdQueueEntry(), PQregisterEventProc(), pqReleaseConnHosts(), PQrequestCancel(), PQreset(), PQresetPoll(), PQresetStart(), pqRowProcessor(), pqSaveErrorResult(), pqSaveParameterStatus(), pqSaveWriteError(), pqsecure_close(), pqsecure_open_client(), pqsecure_open_gss(), pqsecure_raw_read(), pqsecure_raw_write(), pqsecure_read(), pqsecure_write(), PQsendClosePortal(), PQsendClosePrepared(), PQsendDescribePortal(), PQsendDescribePrepared(), PQsendFlushRequest(), PQsendPipelineSync(), PQsendPrepare(), PQsendQuery(), PQsendQueryContinue(), PQsendQueryGuts(), PQsendQueryInternal(), PQsendQueryParams(), PQsendQueryPrepared(), PQsendQueryStart(), pqSendSome(), PQsendTypedCommand(), PQserverVersion(), PQsetChunkedRowsMode(), PQsetClientEncoding(), PQsetdbLogin(), PQsetErrorContextVisibility(), PQsetErrorVerbosity(), PQsetInstanceData(), PQsetnonblocking(), PQsetNoticeProcessor(), PQsetNoticeReceiver(), PQsetSingleRowMode(), PQsetTraceFlags(), pqSkipnchar(), PQsocket(), pqSocketCheck(), PQssl_passwd_cb(), PQsslAttribute(), PQsslAttributeNames(), PQsslInUse(), PQsslStruct(), PQstatus(), PQtrace(), pqTraceOutputCharResponse(), pqTraceOutputMessage(), pqTraceOutputNoTypeByteMessage(), PQtransactionStatus(), PQtty(), PQuntrace(), PQuser(), pqWait(), pqWaitTimed(), pqWriteReady(), prepare_vacuum_command(), prepareToTerminate(), process_result(), ProcessKeepaliveMsg(), processSQLNamePattern(), ProcessWALDataMsg(), prohibit_crossdb_refs(), prompt_user(), read_server_final_message(), read_server_first_message(), ReceiveArchiveStream(), ReceiveBackupManifest(), ReceiveBackupManifestInMemory(), ReceiveCopyData(), ReceiveTarFile(), ReceiveXlogStream(), reindex_all_databases(), reindex_one_database(), release_conn_addrinfo(), retrieve_objects(), RetrieveDataDirCreatePerm(), RetrieveWalSegSize(), run_permutation(), run_reindex_command(), run_simple_command(), run_simple_query(), run_user_oauth_flow(), run_vacuum_command(), RunIdentifySystem(), scram_exchange(), scram_init(), select_next_encryption_method(), send_cancellable_query_impl(), sendFeedback(), sendTerminateConn(), server_is_in_recovery(), set_archive_cancel_info(), set_frozenxids(), set_replication_progress(), SetCancelConn(), setKeepalivesCount(), setKeepalivesIdle(), setKeepalivesInterval(), setTCPUserTimeout(), setup_connection(), setup_oauth_parameters(), setup_publisher(), setup_recovery(), setup_subscriber(), setup_token_request(), sql_conn(), sql_exec(), sql_exec_dumpalldbs(), sql_exec_dumpalltables(), sql_exec_dumpalltbspc(), sql_exec_searchtables(), ssl_set_pgconn_bio(), start_device_authz(), start_postmaster(), start_token_request(), StartLogStreamer(), store_conn_addrinfo(), storeQueryResult(), StreamLog(), StreamLogicalLog(), stringlist_to_identifierstr(), TableCommandResultHandler(), test_cancel(), test_disallowed_in_pipeline(), test_multi_pipelines(), test_nosync(), test_pipeline_abort(), test_pipeline_idle(), test_pipelined_insert(), test_prepared(), test_protocol_version(), test_simple_pipeline(), test_singlerowmode(), test_transaction(), test_uniqviol(), try_complete_step(), useKeepalives(), vacuum_all_databases(), vacuum_one_database(), vacuumlo(), verify_btree_slot_handler(), verify_heap_slot_handler(), wait_for_end_recovery(), wait_on_slots(), and wait_until_connected().
Definition at line 45 of file streamutil.c.
Referenced by BaseBackup(), ConnectDatabase(), GetConnection(), and main().
Definition at line 50 of file streamutil.c.
Referenced by GetConnection(), and main().
Definition at line 46 of file streamutil.c.
Referenced by GetConnection(), and main().
Definition at line 49 of file streamutil.c.
Referenced by _reconnectToDB(), AlterDatabaseOwner(), appendPsqlMetaConnect(), AutoVacWorkerMain(), BackgroundWorkerInitializeConnection(), check_and_drop_existing_subscriptions(), check_db(), CheckAndGetDbnameFromConninfo(), cluster_all_databases(), concat_conninfo_dbname(), connect_slot(), ConnectDatabase(), conninfo_uri_parse_options(), convert_database_name(), create_database(), createdb(), do_connect(), drop_database_if_exists(), drop_existing_subscriptions(), drop_publication(), dropdb(), dropDBs(), dumpDatabaseConfig(), dumpDatabases(), ECPGconnect(), find_matching_idle_slot(), GenerateRecoveryConfig(), get_base_conninfo(), get_database_oid(), get_publisher_databases(), GetConnection(), GetDatabaseTuple(), GetDbnameFromConnectionOptions(), IdentifySystem(), InitPostgres(), libpqrcv_get_dbname_from_conninfo(), log_status_format(), main(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), movedb(), ParallelSlotsGetIdle(), passwordFromFile(), PostgresMain(), PostgresSingleUserMain(), process_pgfdw_appname(), process_postgres_switches(), prohibit_crossdb_refs(), ReconnectToServer(), reindex_all_databases(), ReplSlotSyncWorkerMain(), runPgDump(), set_replication_progress(), and vacuuming_main().
Definition at line 48 of file streamutil.c.
Referenced by GetConnection(), and main().
Definition at line 47 of file streamutil.c.
Referenced by GetConnection(), and main().
Definition at line 51 of file streamutil.c.
Referenced by add_client_identification(), AlterRole(), check_password(), ConnectDatabase(), connectDatabase(), ConnectDatabaseAhx(), conninfo_uri_parse_options(), CreateRole(), do_connect(), doConnect(), encrypt_password(), GetConnection(), main(), pg_be_scram_build_secret(), pg_fe_scram_build_secret(), pg_fe_sendauth(), pg_password_sendauth(), pg_SASL_init(), PQconnectionNeedsPassword(), PQpass(), scram_build_secret(), scram_init(), scram_SaltedPassword(), scram_verify_plain_password(), sql_conn(), and vacuumlo().
Definition at line 44 of file streamutil.c.
Referenced by GetConnection().
Definition at line 32 of file streamutil.c.
Referenced by close_walfile(), extractPageMap(), findLastCheckpoint(), FindStreamingStart(), main(), open_walfile(), ProcessWALDataMsg(), readOneRecord(), ReceiveXlogStream(), RetrieveWalSegSize(), SimpleXLogPageRead(), StartLogStreamer(), and StreamLog().