TdsCdc. Capture
(tds_cdc v0.1.0)
Copy Markdown
Handles querying SQL Server CDC tables and parsing the results.
This module is responsible for:
- Checking if CDC is enabled on the database
- Listing available capture instances
- Fetching changes from CDC tables
Summary
Functions
Returns the SQL query to check if a specific capture instance exists.
Returns the SQL query to check if CDC is enabled on the current database.
Fetches all changes from a capture instance since the given LSN.
Gets the next LSN after the given one.
Gets the maximum LSN from the transaction log.
Gets the minimum LSN for a capture instance, which represents the earliest available change data.
Returns the SQL query to list all capture instances in the current database.
Functions
Returns the SQL query to check if a specific capture instance exists.
@spec cdc_enabled_query() :: String.t()
Returns the SQL query to check if CDC is enabled on the current database.
@spec fetch_changes(GenServer.server(), String.t(), binary()) :: {:ok, [TdsCdc.Change.t()]} | {:error, term()}
Fetches all changes from a capture instance since the given LSN.
This function performs three queries:
- Get the current max LSN
- Increment the from_lsn (since CDC functions are inclusive)
- Query the CDC change table function
Returns {:ok, changes} with a list of %Change{} structs, or {:error, reason}.
@spec get_increment_lsn(GenServer.server(), binary()) :: {:ok, binary()} | {:error, term()}
Gets the next LSN after the given one.
@spec get_max_lsn(GenServer.server()) :: {:ok, binary()} | {:error, term()}
Gets the maximum LSN from the transaction log.
@spec get_min_lsn(GenServer.server(), String.t()) :: {:ok, binary()} | {:error, term()}
Gets the minimum LSN for a capture instance, which represents the earliest available change data.
@spec list_capture_instances_query() :: String.t()
Returns the SQL query to list all capture instances in the current database.