MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / parse_lsn

Function parse_lsn

src/sql-server-util/src/inspect.rs:210–231  ·  view source on GitHub ↗

Parse an [`Lsn`] from the first column of the provided [`tiberius::Row`]. Returns an error if the provided slice doesn't have exactly one row.

(result: &[tiberius::Row])

Source from the content-addressed store, hash-verified

208///
209/// Returns an error if the provided slice doesn't have exactly one row.
210fn parse_lsn(result: &[tiberius::Row]) -> Result<Lsn, SqlServerError> {
211 match result {
212 [row] => {
213 let val = row
214 .try_get::<&[u8], _>(0)?
215 .ok_or_else(|| SqlServerError::NullLsn)?;
216 if val.is_empty() {
217 Err(SqlServerError::NullLsn)
218 } else {
219 let lsn = Lsn::try_from(val).map_err(|msg| SqlServerError::InvalidData {
220 column_name: "lsn".to_string(),
221 error: msg,
222 })?;
223 Ok(lsn)
224 }
225 }
226 other => Err(SqlServerError::InvalidData {
227 column_name: "lsn".to_string(),
228 error: format!("expected 1 column, got {other:?}"),
229 }),
230 }
231}
232
233/// Queries the specified capture instance and returns all changes from
234/// `[start_lsn, end_lsn)`, ordered by `start_lsn` in an ascending fashion.

Callers 3

get_min_lsnFunction · 0.85
get_max_lsnFunction · 0.85
increment_lsnFunction · 0.85

Calls 2

is_emptyMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected