Add NpgsqlDataSource constructor to ReplicationConnection#6527
Draft
Add NpgsqlDataSource constructor to ReplicationConnection#6527
Conversation
Add new constructors to LogicalReplicationConnection, PhysicalReplicationConnection, and the base ReplicationConnection class that accept an NpgsqlDataSource parameter. This allows using data source features like UsePeriodicPasswordProvider with replication connections. When created from a data source, an internal UnpooledDataSource is created with the data source's configuration but with replication-specific settings (Pooling=false, Enlist=false, KeepAlive=0, and the appropriate ReplicationMode). The ConnectionString setter throws InvalidOperationException when the connection was created with a data source, consistent with NpgsqlConnection behavior. Fixes #4392 Agent-Logs-Url: https://github.com/npgsql/npgsql/sessions/2cf5ecb4-b7ee-446f-9ff1-b083c127e961 Co-authored-by: roji <1862641+roji@users.noreply.github.com>
Agent-Logs-Url: https://github.com/npgsql/npgsql/sessions/2cf5ecb4-b7ee-446f-9ff1-b083c127e961 Co-authored-by: roji <1862641+roji@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Integrate ReplicationConnection with NpgsqlDataSource
Add NpgsqlDataSource constructor to ReplicationConnection
Apr 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ReplicationConnectiondirectly constructs anNpgsqlConnection, bypassingNpgsqlDataSourceentirely. This prevents using data source features likeUsePeriodicPasswordProviderwith replication connections.Changes
ReplicationConnection: Newprivate protectedconstructor acceptingNpgsqlDataSource. Clones the data source's settings, overrides replication-specific values (Pooling=false,Enlist=false,KeepAlive=0,ReplicationMode), and creates an internalUnpooledDataSourcethat carries forward the original data source's configuration (password providers, logging, etc.). The internal data source is disposed with the connection.ConnectionStringsetter throws if constructed from a data source.LogicalReplicationConnection/PhysicalReplicationConnection: Public constructors forwardingNpgsqlDataSourceto base.Open_with_data_sourceandConnectionString_cannot_be_set_when_created_with_data_sourceinCommonReplicationTests.Usage