| 4477 | } |
| 4478 | |
| 4479 | pub fn delete_session_fact(conn: &mut Connection, fact_id: i64) -> Result<usize, rusqlite::Error> { |
| 4480 | // Phase A: read the fact's owning session before opening the transaction. |
| 4481 | let session_id = lookup_session_fact_session_id(conn, fact_id)?; |
| 4482 | |
| 4483 | // Phase B: re-check, bump before delete, then delete. |
| 4484 | let tx = conn.transaction_with_behavior(TransactionBehavior::Immediate)?; |
| 4485 | verify_session_fact_session_unchanged(&tx, fact_id, &session_id)?; |
| 4486 | bump_session_facts_version_for_session(&tx, &session_id)?; |
| 4487 | let affected = tx.execute("DELETE FROM session_facts WHERE id = ?1", params![fact_id])?; |
| 4488 | tx.commit()?; |
| 4489 | Ok(affected) |
| 4490 | } |
| 4491 | |
| 4492 | pub fn update_note( |
| 4493 | conn: &Connection, |