fn merge_attached(
conn: &mut Connection,
secret_filter: Option<&RegexSet>,
watermark: Option<i64>,
) -> Result<MergeStats>Expand description
Merge other.command_history (already ATTACHed) into main.
Structured to minimize write-lock hold time so concurrent shell hooks
(insert/seal, which only retry for ~1s) don’t hit “database is locked”
during a sync: all reads and regex filtering happen outside any write
transaction (WAL readers never block writers), and inserts run in
id-ordered chunks, each a short BEGIN IMMEDIATE transaction via
with_write_retry. The merge is therefore not atomic, but INSERT OR
IGNORE is idempotent and the caller only advances the watermark after
full success, so an interrupted merge simply re-considers rows next sync.