pub struct JournalSql {
pub quote: fn(&str) -> String,
pub placeholder: fn(usize) -> String,
pub before_type: &'static str,
pub insert_prefix: &'static str,
pub insert_suffix: &'static str,
pub now: &'static str,
pub key_column: &'static str,
pub primary_key: &'static str,
}Expand description
Dialect-neutral SQL for the before-image journal and the run-scoped delete.
Each builder takes the dialect’s identifier quoting and placeholder style
as function pointers (plain fn, so a sink can hold one across an await
in a Send future), so the SQL sinks share one tested generator instead of three
hand-written copies. before_type is the dialect’s JSON-or-text column type
(JSONB, TEXT, JSON); insert_ignore is its “skip an existing key”
spelling (INSERT … ON CONFLICT DO NOTHING, INSERT OR IGNORE,
INSERT IGNORE).
Fields§
§quote: fn(&str) -> String§placeholder: fn(usize) -> String§before_type: &'static str§insert_prefix: &'static str§insert_suffix: &'static str§now: &'static str§key_column: &'static strThe key_json column definition (plus any helper column). A dialect
with a byte-limited index (MySQL: 3072 bytes) keys on a stored hash of
the JSON instead of the text itself.
primary_key: &'static strThe primary-key clause.
Implementations§
Source§impl JournalSql
impl JournalSql
Sourcepub fn insert(&self, rows: usize) -> String
pub fn insert(&self, rows: usize) -> String
Insert rows journal rows of (run_id, table_name, key_json, before_json), skipping keys already journaled for the run — the first
page to touch a key holds its true pre-run image.
Sourcepub fn delete_table(&self) -> String
pub fn delete_table(&self) -> String
Drop one run’s journal rows for one table (after a restore).
Sourcepub fn keys_in(
&self,
key: &[String],
tuples: usize,
start: usize,
) -> (String, usize)
pub fn keys_in( &self, key: &[String], tuples: usize, start: usize, ) -> (String, usize)
(k1, k2) IN ((p, p), (p, p), …) over tuples key tuples, placeholders
numbered from start + 1. Returns the predicate and the next free
placeholder index.
Sourcepub fn delete_by_run(&self, table_ref: &str, run_id_col: &str) -> String
pub fn delete_by_run(&self, table_ref: &str, run_id_col: &str) -> String
DELETE FROM <table> WHERE <run_id_col> = p1 — the append undo.
Sourcepub fn count_by_run(&self, table_ref: &str, run_id_col: &str) -> String
pub fn count_by_run(&self, table_ref: &str, run_id_col: &str) -> String
SELECT count(*) FROM <table> WHERE <run_id_col> = p1.
Trait Implementations§
Source§impl Clone for JournalSql
impl Clone for JournalSql
impl Copy for JournalSql
Auto Trait Implementations§
impl Freeze for JournalSql
impl RefUnwindSafe for JournalSql
impl Send for JournalSql
impl Sync for JournalSql
impl Unpin for JournalSql
impl UnsafeUnpin for JournalSql
impl UnwindSafe for JournalSql
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request