PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <sys/time.h>
#include <unistd.h>
#include "access/xlog_internal.h"
#include "common/connect.h"
#include "common/fe_memutils.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 "receivelog.h"
#include "streamutil.h"
Go to the source code of this file.
Macros | |
#define | ERRCODE_DUPLICATE_OBJECT "42710" |
#define | MINIMUM_VERSION_FOR_SHOW_CMD 100000 |
#define | MINIMUM_VERSION_FOR_GROUP_ACCESS 110000 |
Variables | |
int | WalSegSz |
const char * | progname |
char * | connection_string = NULL |
char * | dbhost = NULL |
char * | dbuser = NULL |
char * | dbport = NULL |
char * | dbname = NULL |
int | dbgetpassword = 0 |
static char * | password = NULL |
PGconn * | conn = NULL |
#define ERRCODE_DUPLICATE_OBJECT "42710" |
Definition at line 32 of file streamutil.c.
#define MINIMUM_VERSION_FOR_GROUP_ACCESS 110000 |
Definition at line 44 of file streamutil.c.
#define MINIMUM_VERSION_FOR_SHOW_CMD 100000 |
Definition at line 39 of file streamutil.c.
void AppendIntegerCommandOption | ( | PQExpBuffer | buf, |
bool | use_new_option_syntax, | ||
char * | option_name, | ||
int32 | option_value | ||
) |
Definition at line 784 of file streamutil.c.
References AppendPlainCommandOption(), appendPQExpBuffer(), and buf.
Referenced by BaseBackup().
void AppendPlainCommandOption | ( | PQExpBuffer | buf, |
bool | use_new_option_syntax, | ||
char * | option_name | ||
) |
Definition at line 740 of file streamutil.c.
References appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), and buf.
Referenced by AppendIntegerCommandOption(), AppendStringCommandOption(), BaseBackup(), and CreateReplicationSlot().
void AppendStringCommandOption | ( | PQExpBuffer | buf, |
bool | use_new_option_syntax, | ||
char * | option_name, | ||
char * | option_value | ||
) |
Definition at line 761 of file streamutil.c.
References AppendPlainCommandOption(), appendPQExpBuffer(), buf, conn, palloc(), pfree(), and PQescapeStringConn().
Referenced by BaseBackup(), and CreateReplicationSlot().
bool CreateReplicationSlot | ( | PGconn * | conn, |
const char * | slot_name, | ||
const char * | plugin, | ||
bool | is_temporary, | ||
bool | is_physical, | ||
bool | reserve_wal, | ||
bool | slot_exists_ok, | ||
bool | two_phase | ||
) |
Definition at line 583 of file streamutil.c.
References AppendPlainCommandOption(), appendPQExpBuffer(), appendPQExpBufferChar(), appendPQExpBufferStr(), AppendStringCommandOption(), Assert(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), ERRCODE_DUPLICATE_OBJECT, PQExpBufferData::len, PG_DIAG_SQLSTATE, pg_log_error, PGRES_TUPLES_OK, plugin, PQclear(), PQerrorMessage(), PQexec(), PQnfields(), PQntuples(), PQresultErrorField(), PQresultStatus(), PQserverVersion(), res, slot_exists_ok, and two_phase.
Definition at line 691 of file streamutil.c.
References appendPQExpBuffer(), Assert(), conn, createPQExpBuffer(), PQExpBufferData::data, destroyPQExpBuffer(), pg_log_error, PGRES_COMMAND_OK, PQclear(), PQerrorMessage(), PQexec(), PQnfields(), PQntuples(), PQresultStatus(), and res.
int64 fe_recvint64 | ( | char * | buf | ) |
Definition at line 862 of file streamutil.c.
References buf, and pg_ntoh64.
Referenced by ProcessXLogDataMsg(), and StreamLogicalLog().
void fe_sendint64 | ( | int64 | i, |
char * | buf | ||
) |
Definition at line 851 of file streamutil.c.
References buf, i, and pg_hton64.
Referenced by sendFeedback().
TimestampTz feGetCurrentTimestamp | ( | void | ) |
Definition at line 797 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().
void feTimestampDifference | ( | TimestampTz | start_time, |
TimestampTz | stop_time, | ||
long * | secs, | ||
int * | microsecs | ||
) |
Definition at line 816 of file streamutil.c.
References start_time, and USECS_PER_SEC.
Referenced by CalculateCopyStreamSleeptime(), and StreamLogicalLog().
bool feTimestampDifferenceExceeds | ( | TimestampTz | start_time, |
TimestampTz | stop_time, | ||
int | msec | ||
) |
Definition at line 838 of file streamutil.c.
References start_time.
Referenced by HandleCopyStream(), and StreamLogicalLog().
PGconn* GetConnection | ( | void | ) |
Definition at line 62 of file streamutil.c.
References ALWAYS_SECURE_SEARCH_PATH_SQL, Assert(), CONNECTION_BAD, CONNECTION_OK, connection_string, dbgetpassword, dbhost, dbname, dbport, dbuser, exit(), free, i, _PQconninfoOption::keyword, password, pg_fatal, pg_log_error, pg_malloc0(), PGRES_TUPLES_OK, PQclear(), PQconnectdbParams(), PQconnectionNeedsPassword(), PQconninfoFree(), PQconninfoParse(), PQerrorMessage(), PQexec(), PQfinish(), PQparameterStatus(), PQresultStatus(), PQserverVersion(), PQstatus(), progname, res, RetrieveDataDirCreatePerm(), simple_prompt(), _PQconninfoOption::val, and values.
bool GetSlotInformation | ( | PGconn * | conn, |
const char * | slot_name, | ||
XLogRecPtr * | restart_lsn, | ||
TimeLineID * | restart_tli | ||
) |
Definition at line 489 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(), PQresultStatus(), and res.
Referenced by StreamLog().
Definition at line 354 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(), res, and SetDataDirectoryCreatePerm().
Referenced by GetConnection().
Definition at line 275 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(), res, and WalSegSz.
Referenced by main().
bool RunIdentifySystem | ( | PGconn * | conn, |
char ** | sysid, | ||
TimeLineID * | starttli, | ||
XLogRecPtr * | startpos, | ||
char ** | db_name | ||
) |
Definition at line 408 of file streamutil.c.
References Assert(), conn, pg_log_error, pg_strdup(), PGRES_TUPLES_OK, PQclear(), PQerrorMessage(), PQexec(), PQgetisnull(), PQgetvalue(), PQnfields(), PQntuples(), PQresultStatus(), PQserverVersion(), res, and startpos.
Referenced by BaseBackup(), main(), ReceiveXlogStream(), and StreamLog().
PGconn* conn = NULL |
Definition at line 54 of file streamutil.c.
Referenced by 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(), check_expected_areq(), check_for_data_types_usage(), check_for_incompatible_polymorphics(), check_for_isn_and_int8_passing_mismatch(), check_for_pg_role_prefix(), check_for_prepared_transactions(), check_for_tables_with_oids(), check_for_user_defined_encoding_conversions(), check_for_user_defined_postfix_ops(), check_is_install_user(), check_loadable_libraries(), check_new_cluster_logical_replication_slots(), check_prepare_conn(), CheckCopyStreamStop(), CheckServerVersionForStreaming(), close_cursor(), closePGconn(), cluster_all_databases(), cluster_one_database(), compile_database_list(), compile_relation_list_one_db(), configure_remote_session(), connect_pg_server(), connectDatabase(), connectDBComplete(), connectDBStart(), connectFailureMessage(), connectMaintenanceDatabase(), connectNoDelay(), connectOptions1(), connectOptions2(), connectToServer(), CopyStreamPoll(), CopyStreamReceive(), create_cursor(), create_logical_replication_slots(), 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_security_check(), dblink_send_query(), disconnect_atexit(), disconnectDatabase(), do_sql_command(), do_sql_command_begin(), do_sql_command_end(), doConnect(), dropDBs(), DropReplicationSlot(), dropRoles(), dropTablespaces(), dumpDatabase(), dumpDatabaseConfig(), dumpDatabases(), dumpLOs(), dumpRoleGUCPrivs(), dumpRoleMembership(), dumpRoles(), dumpTableData_copy(), dumpTablespaces(), dumpUserConfig(), ecpg_raise_backend(), emitHostIdentityInfo(), emitShSecLabels(), estimate_path_cost_size(), executeCommand(), executeMaintenanceCommand(), executeQuery(), executeQueryOrDie(), ExecuteSqlCommand(), exit_nicely(), expand_dbname_patterns(), exportFile(), fetch_more_data(), fillPGconn(), flushAndSendFeedback(), freePGconn(), get_db_conn(), get_db_infos(), get_loadable_libraries(), get_old_cluster_logical_slot_infos(), get_parallel_object_list(), get_rel_infos(), get_remote_estimate(), get_tablespace_paths(), get_template0_info(), getAnotherTuple(), getCopyDataMessage(), getCopyResult(), getCopyStart(), getHostaddr(), getNotify(), getParamDescriptions(), getParameterStatus(), getReadyForQuery(), getRowDescriptions(), GetSlotInformation(), gss_read(), handleCopyIn(), handleCopyOut(), HandleCopyStream(), HandleEndOfCopyStream(), handleSyncLoss(), importFile(), init_libpq_conn(), init_libpq_source(), initialize_SSL(), internal_ping(), libpq_append_conn_error(), libpq_fetch_file(), libpq_get_current_wal_insert_lsn(), libpq_prng_init(), libpq_traverse_files(), 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_connect(), libpqsrv_connect_internal(), libpqsrv_connect_params(), libpqsrv_disconnect(), 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(), makeEmptyPGconn(), materializeResult(), my_SSL_set_fd(), my_truncate(), 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(), parse_int_param(), parseInput(), 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(), pgfdw_cancel_query(), pgfdw_cancel_query_begin(), pgfdw_cancel_query_end(), 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_error(), pgfdw_security_check(), pgpassfileWarning(), pgtls_close(), pgtls_get_peer_certificate_hash(), pgtls_init(), 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(), pqCheckInBufferSpace(), pqCheckOutBufferSpace(), pqClearAsyncResult(), PQclientEncoding(), PQclosePortal(), PQclosePrepared(), pqCommandQueueAdvance(), PQconnectdb(), PQconnectdbParams(), PQconnectionNeedsPassword(), PQconnectionUsedGSSAPI(), PQconnectionUsedPassword(), 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(), 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(), PQmakeEmptyPGresult(), PQnotifies(), PQoptions(), pqPacketSend(), PQparameterStatus(), pqParseInput3(), PQpass(), PQping(), PQpingParams(), pqPipelineFlush(), pqPipelineProcessQueue(), PQpipelineStatus(), PQpipelineSync(), PQport(), PQprepare(), pqPrepareAsyncResult(), PQprotocolVersion(), pqPutc(), PQputCopyData(), PQputCopyEnd(), pqPutInt(), PQputline(), pqPutMsgBytes(), pqPutMsgEnd(), pqPutMsgStart(), PQputnbytes(), pqPutnchar(), pqPuts(), pqReadData(), pqReadReady(), pqRecycleCmdQueueEntry(), PQregisterEventProc(), PQrequestCancel(), PQreset(), PQresetPoll(), PQresetStart(), pqRowProcessor(), pqSaveErrorResult(), pqSaveParameterStatus(), pqSaveWriteError(), pqsecure_close(), pqsecure_initialize(), pqsecure_open_client(), pqsecure_open_gss(), pqsecure_raw_read(), pqsecure_raw_write(), pqsecure_read(), pqsecure_write(), PQsendClosePortal(), PQsendClosePrepared(), PQsendDescribePortal(), PQsendDescribePrepared(), PQsendFlushRequest(), PQsendPrepare(), PQsendQuery(), PQsendQueryContinue(), PQsendQueryGuts(), PQsendQueryInternal(), PQsendQueryParams(), PQsendQueryPrepared(), PQsendQueryStart(), pqSendSome(), PQsendTypedCommand(), PQserverVersion(), PQsetClientEncoding(), PQsetdbLogin(), PQsetErrorContextVisibility(), PQsetErrorVerbosity(), PQsetInstanceData(), PQsetnonblocking(), PQsetNoticeProcessor(), PQsetNoticeReceiver(), PQsetSingleRowMode(), PQsetTraceFlags(), pqSkipnchar(), PQsocket(), pqSocketCheck(), PQssl_passwd_cb(), PQsslAttribute(), PQsslAttributeNames(), PQsslInUse(), PQsslStruct(), PQstatus(), PQtrace(), pqTraceOutputMessage(), pqTraceOutputNoTypeByteMessage(), PQtransactionStatus(), PQtty(), PQuntrace(), PQuser(), pqWait(), pqWaitTimed(), pqWriteReady(), prepareToTerminate(), process_result(), ProcessKeepaliveMsg(), processSQLNamePattern(), ProcessXLogDataMsg(), prohibit_crossdb_refs(), read_server_final_message(), read_server_first_message(), ReceiveArchiveStream(), ReceiveBackupManifest(), ReceiveBackupManifestInMemory(), ReceiveCopyData(), ReceiveTarFile(), ReceiveXlogStream(), reindex_all_databases(), reindex_one_database(), release_conn_addrinfo(), report_extension_updates(), RetrieveDataDirCreatePerm(), RetrieveWalSegSize(), run_permutation(), run_reindex_command(), run_simple_command(), run_simple_query(), run_vacuum_command(), RunIdentifySystem(), scram_exchange(), scram_init(), sendFeedback(), sendTerminateConn(), set_archive_cancel_info(), set_frozenxids(), SetCancelConn(), setKeepalivesCount(), setKeepalivesIdle(), setKeepalivesInterval(), setTCPUserTimeout(), setup_connection(), sql_conn(), sql_exec(), sql_exec_dumpalldbs(), sql_exec_dumpalltables(), sql_exec_dumpalltbspc(), sql_exec_searchtables(), start_postmaster(), StartLogStreamer(), store_conn_addrinfo(), storeQueryResult(), StreamLog(), StreamLogicalLog(), stringlist_to_identifierstr(), TableCommandResultHandler(), test_disallowed_in_pipeline(), test_multi_pipelines(), test_nosync(), test_pipeline_abort(), test_pipeline_idle(), test_pipelined_insert(), test_prepared(), test_simple_pipeline(), test_singlerowmode(), test_transaction(), test_uniqviol(), try_complete_step(), useKeepalives(), vacuum_all_databases(), vacuum_one_database(), vacuumlo(), verify_btree_slot_handler(), and verify_heap_slot_handler().
char* connection_string = NULL |
Definition at line 47 of file streamutil.c.
Referenced by connectDatabase(), GetConnection(), and main().
int dbgetpassword = 0 |
Definition at line 52 of file streamutil.c.
Referenced by GetConnection(), and main().
char* dbhost = NULL |
Definition at line 48 of file streamutil.c.
Referenced by GetConnection(), and main().
char* dbname = NULL |
Definition at line 51 of file streamutil.c.
Referenced by _reconnectToDB(), AlterDatabaseOwner(), appendPsqlMetaConnect(), AutoVacWorkerMain(), BackgroundWorkerInitializeConnection(), check_db(), cluster_all_databases(), connect_slot(), connectDatabase(), conninfo_uri_parse_options(), convert_database_name(), create_database(), createdb(), do_connect(), drop_database_if_exists(), dropdb(), dropDBs(), dumpDatabaseConfig(), dumpDatabases(), ECPGconnect(), find_matching_idle_slot(), get_database_oid(), GetConnection(), GetDatabaseTuple(), IdentifySystem(), InitPostgres(), log_status_format(), main(), map_sql_catalog_to_xmlschema_types(), map_sql_schema_to_xmlschema_types(), movedb(), objectNamesToOids(), ParallelSlotsGetIdle(), passwordFromFile(), PostgresMain(), PostgresSingleUserMain(), process_pgfdw_appname(), process_postgres_switches(), prohibit_crossdb_refs(), ReconnectToServer(), reindex_all_databases(), and runPgDump().
char* dbport = NULL |
Definition at line 50 of file streamutil.c.
Referenced by GetConnection(), and main().
char* dbuser = NULL |
Definition at line 49 of file streamutil.c.
Referenced by GetConnection(), and main().
|
static |
Definition at line 53 of file streamutil.c.
Referenced by AlterRole(), check_password(), ConnectDatabase(), connectDatabase(), 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().
const char* progname |
Definition at line 46 of file streamutil.c.
Referenced by GetConnection().
int WalSegSz |
Definition at line 34 of file streamutil.c.
Referenced by close_walfile(), extractPageMap(), findLastCheckpoint(), FindStreamingStart(), main(), open_walfile(), ProcessXLogDataMsg(), readOneRecord(), ReceiveXlogStream(), RetrieveWalSegSize(), SimpleXLogPageRead(), StartLogStreamer(), and StreamLog().