Skip to content

Comments

Enhance replication slot functionality with customizable options and snapshot support#23

Merged
isdaniel merged 2 commits intomainfrom
feat/customization-created-replication-slot
Feb 20, 2026
Merged

Enhance replication slot functionality with customizable options and snapshot support#23
isdaniel merged 2 commits intomainfrom
feat/customization-created-replication-slot

Conversation

@isdaniel
Copy link
Owner

for #22

@gemini-code-assist
Copy link

Summary of Changes

Hello @isdaniel, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly expands the functionality for creating and managing PostgreSQL replication slots within the pg-walstream library. It introduces granular control over slot properties such as temporariness, snapshot behavior, two-phase commit support, and failover synchronization. These enhancements provide greater flexibility for users to tailor replication streams to specific use cases, particularly for initial data synchronization and high-availability setups.

Highlights

  • Configurable Replication Slot Options: Introduced comprehensive customization for PostgreSQL replication slot creation, including temporary slots, snapshot export, two-phase commit, and failover options.
  • Dynamic SQL Generation: Implemented automatic SQL syntax selection for CREATE_REPLICATION_SLOT based on the connected PostgreSQL server version (PG14 vs. PG15+), ensuring compatibility.
  • Snapshot Export Support: Added the ability to retrieve the exported snapshot name, enabling users to read a consistent initial state of the database from a separate connection.
  • Enhanced Stream Configuration: Enhanced ReplicationStreamConfig with new builder methods (with_slot_options and with_slot_type) for easily configuring replication slot properties.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • README.md
    • Updated the feature list to include 'Configurable Slot Options'.
    • Modified example code to demonstrate the new with_slot_options builder method.
    • Added a note about the validity of exported snapshots.
    • Rewrote the 'Replication Slot Options' section to detail the new configurable options and their PostgreSQL version compatibility, including a table for clarity.
  • src/connection.rs
    • Removed the deprecated create_replication_slot function.
    • Refactored slot creation logic into a new build_create_slot_sql private method to dynamically generate SQL based on provided options and PostgreSQL version.
    • Updated create_replication_slot_with_options to use the new SQL builder.
    • Added extensive unit tests for various CREATE_REPLICATION_SLOT SQL generation scenarios, covering logical and physical slots with different options.
  • src/lib.rs
    • Updated an example in the crate-level documentation to use StreamingMode::On instead of a boolean.
  • src/stream.rs
    • Introduced ReplicationSlotOptions and SlotType into the module.
    • Added exported_snapshot_name field to LogicalReplicationStream to store the snapshot identifier.
    • Extended ReplicationStreamConfig with slot_options and slot_type fields, initialized with sensible defaults.
    • Added with_slot_options and with_slot_type builder methods to ReplicationStreamConfig for fluent configuration.
    • Modified ensure_replication_slot to use the new create_replication_slot_with_options and to capture the exported_snapshot_name if available.
    • Implemented logic to automatically recreate temporary slots upon reconnection.
    • Exposed exported_snapshot_name() and is_temporary_slot() public methods on LogicalReplicationStream.
    • Updated test cases for ReplicationStreamConfig to include slot_type assertions.
Activity
  • No specific activity (comments, reviews, progress updates) was provided in the context for this pull request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 92.34234% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.03%. Comparing base (228c88b) to head (027bd7f).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/stream.rs 88.94% 22 Missing ⚠️
src/connection.rs 95.10% 12 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
+ Coverage   88.12%   89.03%   +0.90%     
==========================================
  Files           8        8              
  Lines        7056     7448     +392     
==========================================
+ Hits         6218     6631     +413     
+ Misses        838      817      -21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly enhances replication slot functionality by introducing a rich set of configuration options, including support for temporary slots, snapshot export, two-phase commit, and failover, with improved documentation. However, it introduces SQL injection vulnerabilities in the CREATE_REPLICATION_SLOT command construction, as identifiers like the slot name and output plugin name are not properly escaped, potentially allowing arbitrary SQL execution. Additionally, there are suggestions to align src/connection.rs with PostgreSQL version-specific SQL syntax and to make SQL string construction more robust.

@isdaniel
Copy link
Owner Author

/gemini review

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request significantly enhances the replication slot functionality by adding support for customizable options like temporary slots and snapshot export. While the changes generally improve security through proper SQL identifier quoting, a potential SQL injection vulnerability was identified in the start_replication method due to incomplete manual escaping of string values, which could be exploited if the PostgreSQL server has standard_conforming_strings disabled. Additionally, there are a couple of suggestions to improve the documentation for clarity.

@isdaniel isdaniel merged commit 386b67d into main Feb 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant