pub async fn confirm_changes(conn: &mut Conn) -> Result<()>Expand description
Confirms changes this invocation already sent, so they outlive the process.
§Why this has to exist at all
Every connection opens with SET autocommit = 0, and the reason written
beside that statement is a good one: a read must never persist anything, and
a statement the caller did not mean to commit is discarded when the process
ends. What was missing is the other half. A caller who DID mean it — who
passed the confirmation mark and received affected: 1 — also had the change
discarded, because nothing ever sent this.
Measured against a real server before the fix: query run inserting one row
ended in zero, reported one row changed, and a second process counted none.
The same insert through query tx, which confirms its own block, persisted.
The report was never false about the statement; it was silent about the
transaction the statement was still sitting in.
It survived because no proof read a change back from a SECOND process. A proof that reads the count reported by the process that just wrote it is reading the inside of the open transaction, and everything looks right in there.
§Errors
Returns the driver failure when the server refuses the confirmation, which is the one moment a caller has to be told the change is not there.