Expand description
Useful queries to inspect the state of a SQL Server instance.
StructsΒ§
- DDLEvent
- A DDL event collected from the
cdc.ddl_historytable.
StaticsΒ§
FunctionsΒ§
- check_
system_ πresult - Helper function to parse an expected result from a βsystemβ query.
- cleanup_
change_ table - Cleans up the change table associated with the specified
capture_instanceby deletingmax_deletesentries with astart_lsnless thanlow_water_mark. - deserialize_
table_ πcolumns_ to_ raw_ tables - ensure_
database_ cdc_ enabled - Ensure change data capture (CDC) is enabled for the database the provided
clientis currently connected to. - ensure_
snapshot_ isolation_ enabled - Ensure the
SNAPSHOTtransaction isolation level is enabled for the database the providedclientis currently connected to. - ensure_
sql_ server_ agent_ running - Ensure the SQL Server Agent is running.
- get_
cdc_ table_ columns - Retrieves column metdata from the CDC table maintained by the provided capture instance. The resulting column information collection is similar to the information collected for the upstream table, with the exclusion of nullability and primary key constraints, which contain static values for CDC columns. CDC table schema is automatically generated and does not attempt to enforce the same constraints on the data as the upstream table.
- get_
changes_ asc - Queries the specified capture instance and returns all changes from
[start_lsn, end_lsn), ordered bystart_lsnin an ascending fashion. - get_
ddl_ history - Returns DDL changes made to the source table for the given capture instance. This follows the
same convention as
cdc.fn_cdc_get_all_changes_<capture_instance>, in that the range is inclusive, i.e.[from_lsn, to_lsn]. The events are returned in ascending order of LSN. - get_
latest_ restore_ history_ id - Retrieves the largest
restore_history_idfrom SQL Server for the current database. Therestore_history_idcolumn is of typeIDENTITY(1,1)based onEXEC sp_help restorehistory. We expect it to start at 1 and be incremented by 1, with possible gaps in values. See: - get_
max_ lsn - Returns the maximum log sequence number for the entire database. This implementation relies on CDC, which is asynchronous, so may return an LSN that is less than the maximum LSN of SQL server.
- get_
max_ lsn_ retry - Returns the maximum log sequence number for the entire database, retrying if the log sequence number is not available. This implementation relies on CDC, which is asynchronous, so may return an LSN that is less than the maximum LSN of SQL server.
- get_
min_ lsn - Returns the minimum log sequence number for the specified
capture_instance. - get_
min_ lsn_ retry - Returns the minimum log sequence number for the specified
capture_instance, retrying if the log sequence number is not available. - get_
min_ lsns - Retrieves the minumum
Lsn(start_lsn field) fromcdc.change_tablesfor the specified capture instances. - get_
tables - get_
tables_ for_ capture_ instance - Returns the table metadata for the tables that are tracked by the specified
capture_instances. - get_
value π - increment_
lsn - Increments the log sequence number.
- map_
null_ πlsn_ to_ retry - parse_
lsn π - Parse an
Lsnfrom the first column of the providedtiberius::Row. - parse_
numeric_ πlsn - Parse an
Lsnin Decimal(25,0) format of the providedtiberius::Row. - snapshot
- Return a
Streamthat is the entire snapshot of the specified table. - snapshot_
size - Returns the total number of rows present in the specified table.
- validate_
source_ privileges - Return a Result that is empty if all tables, columns, and capture instances have the necessary permissions to and an error if any table, column, or capture instance does not have the necessary permissions for tracking changes.