internal ReplicationSystemIdentification(string systemId, uint timeline, NpgsqlLogSequenceNumber xLogPos, string dbName) { SystemId = systemId; Timeline = timeline; XLogPos = xLogPos; DbName = dbName; }
internal StreamAbortMessage Populate(NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint transactionXid, uint subtransactionXid) { base.Populate(walStart, walEnd, serverClock, transactionXid); SubtransactionXid = subtransactionXid; return(this); }
internal FullDeleteMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, uint relationId, ReadOnlyMemory <TupleData> oldRow) { base.Populate(walStart, walEnd, serverClock, transactionXid, relationId); OldRow = oldRow; return(this); }
internal StreamStartMessage Populate(NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint transactionXid, byte streamSegmentIndicator) { base.Populate(walStart, walEnd, serverClock, transactionXid); StreamSegmentIndicator = streamSegmentIndicator; return(this); }
/// <summary> /// Instructs the server to start streaming the WAL for physical replication, starting at WAL location /// <paramref name="walLocation"/>. The server can reply with an error, for example if the requested /// section of the WAL has already been recycled. /// </summary> /// <remarks> /// If the client requests a timeline that's not the latest but is part of the history of the server, the server /// will stream all the WAL on that timeline starting from the requested start point up to the point where the /// server switched to another timeline. /// </remarks> /// <param name="slot"> /// The replication slot that will be updated as replication progresses so that the server /// knows which WAL segments are still needed by the standby. /// </param> /// <param name="walLocation">The WAL location to begin streaming at.</param> /// <param name="cancellationToken">The token to be used for stopping the replication.</param> /// <param name="timeline">Streaming starts on timeline tli.</param> /// <returns>A <see cref="Task{T}"/> representing an <see cref="IAsyncEnumerable{NpgsqlXLogDataMessage}"/> that /// can be used to stream WAL entries in form of <see cref="XLogDataMessage"/> instances.</returns> public IAsyncEnumerable <XLogDataMessage> StartReplication(PhysicalReplicationSlot?slot, NpgsqlLogSequenceNumber walLocation, CancellationToken cancellationToken, uint timeline = default) { using (NoSynchronizationContextScope.Enter()) return(StartPhysicalReplication(slot, walLocation, cancellationToken, timeline)); async IAsyncEnumerable <XLogDataMessage> StartPhysicalReplication(PhysicalReplicationSlot?slot, NpgsqlLogSequenceNumber walLocation, [EnumeratorCancellation] CancellationToken cancellationToken, uint timeline) { var builder = new StringBuilder("START_REPLICATION"); if (slot != null) { builder.Append(" SLOT ").Append(slot.Name); } builder.Append(" PHYSICAL ").Append(walLocation); if (timeline != default) { builder.Append(" TIMELINE ").Append(timeline.ToString(CultureInfo.InvariantCulture)); } var enumerator = StartReplicationInternalWrapper(builder.ToString(), bypassingStream: false, cancellationToken); while (await enumerator.MoveNextAsync()) { yield return(enumerator.Current); } } }
private protected DeleteMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, uint relationId) { base.Populate(walStart, walEnd, serverClock, transactionXid); RelationId = relationId; return(this); }
internal IndexUpdateMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, uint relationId, ReadOnlyMemory <TupleData> newRow, ReadOnlyMemory <TupleData> keyRow) { base.Populate(walStart, walEnd, serverClock, transactionXid, relationId, newRow); KeyRow = keyRow; return(this); }
internal BeginMessage Populate(NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, NpgsqlLogSequenceNumber transactionFinalLsn, DateTime transactionCommitTimestamp, uint transactionXid) { base.Populate(walStart, walEnd, serverClock, transactionXid); TransactionFinalLsn = transactionFinalLsn; TransactionCommitTimestamp = transactionCommitTimestamp; return(this); }
internal TestDecodingData Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, string data) { base.Populate(walStart, walEnd, serverClock); Data = data; return(this); }
internal TruncateMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, TruncateOptions options, ReadOnlyArrayBuffer <RelationMessage> relations) { base.Populate(walStart, walEnd, serverClock, transactionXid); Options = options; Relations = relations; return(this); }
internal XLogDataMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, Stream data) { base.Populate(walStart, walEnd, serverClock); Data = data; return(this); }
internal InsertMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, uint relationId, ReadOnlyMemory <TupleData> newRow) { base.Populate(walStart, walEnd, serverClock, transactionXid); RelationId = relationId; NewRow = newRow; return(this); }
internal TypeMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, uint typeId, string ns, string name) { base.Populate(walStart, walEnd, serverClock, transactionXid); TypeId = typeId; Namespace = ns; Name = name; return(this); }
internal LogicalDecodingMessage Populate(NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, byte flags, NpgsqlLogSequenceNumber messageLsn, string prefix, Stream data) { base.Populate(walStart, walEnd, serverClock, transactionXid); Flags = flags; MessageLsn = messageLsn; Prefix = prefix; Data = data; return(this); }
internal UpdateMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, RelationMessage relation) { base.Populate(walStart, walEnd, serverClock, transactionXid); Relation = relation; return(this); }
internal StreamCommitMessage Populate(NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint transactionXid, byte flags, NpgsqlLogSequenceNumber commitLsn, NpgsqlLogSequenceNumber transactionEndLsn, DateTime transactionCommitTimestamp) { base.Populate(walStart, walEnd, serverClock, transactionXid); Flags = flags; CommitLsn = commitLsn; TransactionEndLsn = transactionEndLsn; TransactionCommitTimestamp = transactionCommitTimestamp; return(this); }
internal FullUpdateMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint relationId, ReadOnlyMemory <TupleData> newRow, ReadOnlyMemory <TupleData> oldRow) { base.Populate(walStart, walEnd, serverClock, relationId, newRow); OldRow = oldRow; return(this); }
internal KeyDeleteMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint relationId, ReadOnlyMemory <TupleData> keyRow) { base.Populate(walStart, walEnd, serverClock, relationId); KeyRow = keyRow; return(this); }
internal TruncateMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, TruncateOptions options, uint[] relationIds) { base.Populate(walStart, walEnd, serverClock); Options = options; RelationIds = relationIds; return(this); }
internal OriginMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, NpgsqlLogSequenceNumber originCommitLsn, string originName) { base.Populate(walStart, walEnd, serverClock); OriginCommitLsn = originCommitLsn; OriginName = originName; return(this); }
internal UpdateMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, RelationMessage relation, ushort numColumns) { base.Populate(walStart, walEnd, serverClock, transactionXid, relation); _key.Reset(numColumns, relation.RowDescription); _newRow.Reset(numColumns, relation.RowDescription); return(this); }
internal RelationMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, uint relationId, string ns, string relationName, char relationReplicaIdentitySetting, ReadOnlyArrayBuffer <Column> columns) { base.Populate(walStart, walEnd, serverClock, transactionXid); RelationId = relationId; Namespace = ns; RelationName = relationName; RelationReplicaIdentitySetting = relationReplicaIdentitySetting; Columns = columns; return(this); }
internal RelationMessage Populate( NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint?transactionXid, uint relationId, string ns, string relationName, ReplicaIdentitySetting relationReplicaIdentitySetting) { base.Populate(walStart, walEnd, serverClock, transactionXid); RelationId = relationId; Namespace = ns; RelationName = relationName; ReplicaIdentity = relationReplicaIdentitySetting; return(this); }
/// <summary> /// Instructs the server to start streaming the WAL for physical replication, starting at WAL location /// <paramref name="walLocation"/>. The server can reply with an error, for example if the requested /// section of the WAL has already been recycled. /// </summary> /// <remarks> /// If the client requests a timeline that's not the latest but is part of the history of the server, the server /// will stream all the WAL on that timeline starting from the requested start point up to the point where the /// server switched to another timeline. /// </remarks> /// <param name="slot"> /// The replication slot that will be updated as replication progresses so that the server /// knows which WAL segments are still needed by the standby. /// </param> /// <param name="walLocation">The WAL location to begin streaming at.</param> /// <param name="cancellationToken">The token to be used for stopping the replication.</param> /// <param name="timeline">Streaming starts on timeline tli.</param> /// <returns>A <see cref="Task{T}"/> representing an <see cref="IAsyncEnumerable{NpgsqlXLogDataMessage}"/> that /// can be used to stream WAL entries in form of <see cref="XLogDataMessage"/> instances.</returns> public IAsyncEnumerable <XLogDataMessage> StartReplication(PhysicalReplicationSlot?slot, NpgsqlLogSequenceNumber walLocation, CancellationToken cancellationToken, uint timeline = default) { using var _ = NoSynchronizationContextScope.Enter(); var builder = new StringBuilder("START_REPLICATION"); if (slot != null) { builder.Append(" SLOT ").Append(slot.Name); } builder.Append(" PHYSICAL ").Append(walLocation); if (timeline != default) { builder.Append(" TIMELINE ").Append(timeline.ToString(CultureInfo.InvariantCulture)); } return(StartReplicationInternal(builder.ToString(), bypassingStream: false, cancellationToken)); }
// [Test] public async Task NpgsqlLogSequenceNumber() { var expected1 = new NpgsqlLogSequenceNumber(42949672971ul); Assert.AreEqual(expected1, NpgsqlTypes.NpgsqlLogSequenceNumber.Parse("A/B")); await using var conn = await OpenConnectionAsync(); using var cmd = conn.CreateCommand(); cmd.CommandText = "SELECT 'A/B'::pg_lsn, @p::pg_lsn"; cmd.Parameters.AddWithValue("p", NpgsqlDbType.PgLsn, expected1); await using var reader = await cmd.ExecuteReaderAsync(); reader.Read(); var result1 = reader.GetFieldValue <NpgsqlLogSequenceNumber>(0); var result2 = reader.GetFieldValue <NpgsqlLogSequenceNumber>(1); Assert.AreEqual(expected1, result1); Assert.AreEqual(42949672971ul, (ulong)result1); Assert.AreEqual("A/B", result1.ToString()); Assert.AreEqual(expected1, result2); Assert.AreEqual(42949672971ul, (ulong)result2); Assert.AreEqual("A/B", result2.ToString()); }
/// <summary> /// Instructs the server to start streaming the WAL for logical replication, starting at WAL location /// <paramref name="walLocation"/>. The server can reply with an error, for example if the requested /// section of WAL has already been recycled. /// </summary> /// <remarks> /// If the client requests a timeline that's not the latest but is part of the history of the server, the server /// will stream all the WAL on that timeline starting from the requested start point up to the point where the /// server switched to another timeline. /// </remarks> /// <param name="walLocation">The WAL location to begin streaming at.</param> /// <param name="cancellationToken">The token to be used for stopping the replication.</param> /// <param name="timeline">Streaming starts on timeline tli.</param> /// <returns>A <see cref="Task{T}"/> representing an <see cref="IAsyncEnumerable{NpgsqlXLogDataMessage}"/> that /// can be used to stream WAL entries in form of <see cref="XLogDataMessage"/> instances.</returns> public IAsyncEnumerable <XLogDataMessage> StartReplication( NpgsqlLogSequenceNumber walLocation, CancellationToken cancellationToken, ulong timeline = default) => StartReplication(slot: null, walLocation: walLocation, timeline: timeline, cancellationToken: cancellationToken);
public bool NpgsqlLogSequenceNumber_equals(NpgsqlLogSequenceNumber lsn, object?obj) => lsn.Equals(obj);
internal new StreamStopMessage Populate(NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock) { base.Populate(walStart, walEnd, serverClock); return(this); }
private protected void Populate(NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock, uint transactionXid) { base.Populate(walStart, walEnd, serverClock); TransactionXid = transactionXid; }
private protected void Populate(NpgsqlLogSequenceNumber walStart, NpgsqlLogSequenceNumber walEnd, DateTime serverClock) { WalStart = walStart; WalEnd = walEnd; ServerClock = serverClock; }