|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/table.h"#include "catalog/pg_sequence.h"#include "catalog/pg_subscription_rel.h"#include "commands/sequence.h"#include "pgstat.h"#include "postmaster/interrupt.h"#include "replication/logicalworker.h"#include "replication/worker_internal.h"#include "utils/acl.h"#include "utils/builtins.h"#include "utils/fmgroids.h"#include "utils/guc.h"#include "utils/inval.h"#include "utils/lsyscache.h"#include "utils/memutils.h"#include "utils/pg_lsn.h"#include "utils/syscache.h"#include "utils/usercontext.h"
Go to the source code of this file.
Macros | |
| #define | REMOTE_SEQ_COL_COUNT 10 |
| #define | MAX_SEQUENCES_SYNC_PER_BATCH 100 |
Typedefs | |
| typedef enum CopySeqResult | CopySeqResult |
Enumerations | |
| enum | CopySeqResult { COPYSEQ_SUCCESS , COPYSEQ_MISMATCH , COPYSEQ_INSUFFICIENT_PERM , COPYSEQ_SKIPPED } |
Functions | |
| void | ProcessSequencesForSync (void) |
| static void | get_sequences_string (List *seqindexes, StringInfo buf) |
| static void | report_sequence_errors (List *mismatched_seqs_idx, List *insuffperm_seqs_idx, List *missing_seqs_idx) |
| static CopySeqResult | get_and_validate_seq_info (TupleTableSlot *slot, Relation *sequence_rel, LogicalRepSequenceInfo **seqinfo, int *seqidx) |
| static CopySeqResult | copy_sequence (LogicalRepSequenceInfo *seqinfo, Oid seqowner) |
| static void | copy_sequences (WalReceiverConn *conn) |
| static void | LogicalRepSyncSequences (void) |
| static void | start_sequence_sync (void) |
| void | SequenceSyncWorkerMain (Datum main_arg) |
Variables | |
| static List * | seqinfos = NIL |
| #define MAX_SEQUENCES_SYNC_PER_BATCH 100 |
| #define REMOTE_SEQ_COL_COUNT 10 |
Definition at line 73 of file sequencesync.c.
| typedef enum CopySeqResult CopySeqResult |
| enum CopySeqResult |
| Enumerator | |
|---|---|
| COPYSEQ_SUCCESS | |
| COPYSEQ_MISMATCH | |
| COPYSEQ_INSUFFICIENT_PERM | |
| COPYSEQ_SKIPPED | |
Definition at line 75 of file sequencesync.c.
|
static |
Definition at line 324 of file sequencesync.c.
References ACL_UPDATE, ACLCHECK_OK, COPYSEQ_INSUFFICIENT_PERM, COPYSEQ_SUCCESS, GetUserId(), LogicalRepSequenceInfo::is_called, LogicalRepSequenceInfo::last_value, LogicalRepSequenceInfo::localrelid, MySubscription, Subscription::oid, LogicalRepSequenceInfo::page_lsn, pg_class_aclcheck(), RestoreUserContext(), Subscription::runasowner, SetSequence(), SwitchToUntrustedUser(), and UpdateSubscriptionRelState().
Referenced by copy_sequences().
|
static |
Definition at line 375 of file sequencesync.c.
References appendStringInfo(), appendStringInfoString(), ApplyContext, CHECK_FOR_INTERRUPTS, CommitTransactionCommand(), ConfigReloadPending, conn, copy_sequence(), COPYSEQ_INSUFFICIENT_PERM, COPYSEQ_MISMATCH, COPYSEQ_SKIPPED, COPYSEQ_SUCCESS, StringInfoData::data, DEBUG1, elog, ereport, WalRcvExecResult::err, errcode(), errmsg(), ERROR, ExecDropSingleTupleTableSlot(), LogicalRepSequenceInfo::found_on_pub, get_and_validate_seq_info(), idx(), lappend_int(), StringInfoData::len, lengthof, list_length(), list_nth(), LOG, MakeSingleTupleTableSlot(), makeStringInfo(), MAX_SEQUENCES_SYNC_PER_BATCH, MemoryContextSwitchTo(), MySubscription, Subscription::name, NIL, NoLock, LogicalRepSequenceInfo::nspname, PGC_SIGHUP, ProcessConfigFile(), quote_literal_cstr(), RelationData::rd_rel, REMOTE_SEQ_COL_COUNT, report_sequence_errors(), resetStringInfo(), seqinfos, LogicalRepSequenceInfo::seqname, StartTransactionCommand(), WalRcvExecResult::status, table_close(), TTSOpsMinimalTuple, WalRcvExecResult::tupledesc, WalRcvExecResult::tuplestore, tuplestore_gettupleslot(), walrcv_clear_result(), walrcv_exec, and WALRCV_OK_TUPLES.
Referenced by LogicalRepSyncSequences().
|
static |
Definition at line 230 of file sequencesync.c.
References Assert(), COPYSEQ_MISMATCH, COPYSEQ_SKIPPED, COPYSEQ_SUCCESS, DatumGetBool(), DatumGetInt32(), DatumGetInt64(), DatumGetLSN(), DatumGetObjectId(), elog, ERROR, LogicalRepSequenceInfo::found_on_pub, get_namespace_name(), GETSTRUCT(), HeapTupleIsValid, LogicalRepSequenceInfo::is_called, LogicalRepSequenceInfo::last_value, list_nth(), LogicalRepSequenceInfo::localrelid, LogicalRepSequenceInfo::nspname, ObjectIdGetDatum(), LogicalRepSequenceInfo::page_lsn, RelationGetNamespace, RelationGetRelationName, ReleaseSysCache(), REMOTE_SEQ_COL_COUNT, RowExclusiveLock, SearchSysCache1(), seqinfos, LogicalRepSequenceInfo::seqname, slot_getattr(), and try_table_open().
Referenced by copy_sequences().
|
static |
Definition at line 146 of file sequencesync.c.
References appendStringInfo(), appendStringInfoString(), buf, foreach_int, list_nth(), LogicalRepSequenceInfo::nspname, resetStringInfo(), seqinfos, and LogicalRepSequenceInfo::seqname.
Referenced by report_sequence_errors().
|
static |
Definition at line 600 of file sequencesync.c.
References AccessShareLock, appendStringInfo(), ApplyContext, BTEqualStrategyNumber, CharGetDatum(), CHECK_FOR_INTERRUPTS, CommitTransactionCommand(), Subscription::conninfo, copy_sequences(), StringInfoData::data, ereport, err(), errcode(), errmsg(), ERROR, get_namespace_name(), GETSTRUCT(), GetSystemIdentifier(), HeapTupleIsValid, initStringInfo(), InvalidOid, lappend(), LogicalRepSequenceInfo::localrelid, LogRepWorkerWalRcvConn, MemoryContextSwitchTo(), MyLogicalRepWorker, MySubscription, Subscription::name, NoLock, LogicalRepSequenceInfo::nspname, ObjectIdGetDatum(), Subscription::oid, Subscription::ownersuperuser, palloc0_object, Subscription::passwordrequired, pfree(), pstrdup(), RelationData::rd_rel, RelationGetNamespace, RelationGetRelationName, RowExclusiveLock, ScanKeyInit(), seqinfos, LogicalRepSequenceInfo::seqname, StartTransactionCommand(), LogicalRepWorker::subid, systable_beginscan(), systable_endscan(), systable_getnext(), table_close(), table_open(), try_table_open(), UINT64_FORMAT, and walrcv_connect.
Referenced by start_sequence_sync().
| void ProcessSequencesForSync | ( | void | ) |
Definition at line 94 of file sequencesync.c.
References CommitTransactionCommand(), FetchRelationStates(), InvalidOid, LogicalRepWorker::last_seqsync_start_time, launch_sync_worker(), logicalrep_sync_worker_count(), logicalrep_worker_find(), LW_SHARED, LWLockAcquire(), LWLockRelease(), MyLogicalRepWorker, pgstat_report_stat(), LogicalRepWorker::subid, and WORKERTYPE_SEQUENCESYNC.
Referenced by ProcessSyncingRelations().
|
static |
Definition at line 172 of file sequencesync.c.
References StringInfoData::data, ereport, errcode(), errmsg(), errmsg_plural(), ERROR, get_sequences_string(), list_length(), makeStringInfo(), MySubscription, Subscription::name, and WARNING.
Referenced by copy_sequences().
| void SequenceSyncWorkerMain | ( | Datum | main_arg | ) |
Definition at line 746 of file sequencesync.c.
References DatumGetInt32(), FinishSyncWorker(), SetupApplyOrSyncWorker(), and start_sequence_sync().
|
static |
Definition at line 714 of file sequencesync.c.
References AbortOutOfAnyTransaction(), am_sequencesync_worker(), Assert(), Subscription::disableonerr, DisableSubscriptionAndExit(), LogicalRepSyncSequences(), MySubscription, Subscription::oid, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pgstat_report_subscription_error(), and WORKERTYPE_SEQUENCESYNC.
Referenced by SequenceSyncWorkerMain().
Definition at line 83 of file sequencesync.c.
Referenced by copy_sequences(), get_and_validate_seq_info(), get_sequences_string(), and LogicalRepSyncSequences().