为什么我的修改没有使用 SAVEPOINT 写入磁盘?

Why arent my modifications being written to the disk using SAVEPOINT?

我有三个操作,一个读取,一个写入,另一个读取,每个操作都在使用 SAVEPOINT 启动的事务中。我读取了一个值,中止了我用来读取它的事务,我设置了这个值,提交了我用来设置它的事务,然后我在一个我后来中止的事务中再次读取它。当我再次打开数据库时,设置已撤消。

我在以下 shell 脚本中找出了我的问题:

$ sqlite3 oi.sqlite3 <<<"CREATE TABLE test (value TEXT);"
$ sqlite3 oi.sqlite3 <<<"INSERT INTO test VALUES (1);"
$ sqlite3 oi.sqlite3 <<<"
 SAVEPOINT '1';
 RELEASE '1';
 SAVEPOINT '2';
 SELECT * FROM test;
 ROLLBACK TO '2';
 SAVEPOINT '3';
 UPDATE test SET value=0;
 RELEASE '3';
 SAVEPOINT '4';
 SELECT * FROM test;
 ROLLBACK TO '4';"
$ sqlite3 oi.sqlite3 <<<"SELECT * FROM test;"

我的输出是

1 # Read before set
0 # Read after set
1 # Read after reopening the database

我错过了什么?

来自文档:

Note that unlike that plain ROLLBACK command (without the TO keyword) the ROLLBACK TO command does not cancel the transaction.

所以,我需要在每个 ROLLBACK TO 之后 运行 RELEASE