summaryrefslogtreecommitdiff
path: root/chromium/third_party/sqlite/src/ext/rbu
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/sqlite/src/ext/rbu')
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu1.test3
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu10.test7
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu11.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu12.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu13.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu14.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu3.test9
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu5.test1
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu6.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu7.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu8.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu9.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuA.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuB.test3
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuC.test1
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl10
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbucollate.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbucrash.test12
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbucrash2.test12
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbudiff.test7
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbudor.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuexpr.test7
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbufault.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbufault2.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbufault3.test1
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbufault4.test9
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbufts.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbumisc.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbumulti.test5
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbupartial.test3
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuprogress.test1
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rburesume.test9
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbusave.test6
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbusplit.test3
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbutemplimit.test4
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuvacuum.test1
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test10
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test1
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/rbuvacuum4.test2
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c126
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h114
-rw-r--r--chromium/third_party/sqlite/src/ext/rbu/test_rbu.c57
42 files changed, 302 insertions, 212 deletions
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu1.test b/chromium/third_party/sqlite/src/ext/rbu/rbu1.test
index 9237dbcea72..418857d8b14 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu1.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu1.test
@@ -11,11 +11,10 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu1
db close
-sqlite3_shutdown
-sqlite3_config_uri 1
# Create a simple RBU database. That expects to write to a table:
#
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu10.test b/chromium/third_party/sqlite/src/ext/rbu/rbu10.test
index aa4db8a29f4..8705c7b2e5d 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu10.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu10.test
@@ -10,13 +10,10 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu10
-
#--------------------------------------------------------------------
# Test that UPDATE commands work even if the input columns are in a
# different order to the output columns.
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu11.test b/chromium/third_party/sqlite/src/ext/rbu/rbu11.test
index 5a4219b0015..a42163cce6a 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu11.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu11.test
@@ -10,10 +10,8 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu11
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu12.test b/chromium/third_party/sqlite/src/ext/rbu/rbu12.test
index 7816bfe89f9..a753ef2494f 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu12.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu12.test
@@ -10,10 +10,8 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
source $testdir/lock_common.tcl
set ::testprefix rbu12
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu13.test b/chromium/third_party/sqlite/src/ext/rbu/rbu13.test
index 624c587cc3a..9bf2adc6fab 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu13.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu13.test
@@ -13,10 +13,8 @@
# for UPDATE statements. This tests RBU's internal UPDATE statement cache.
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
source $testdir/lock_common.tcl
set ::testprefix rbu13
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu14.test b/chromium/third_party/sqlite/src/ext/rbu/rbu14.test
index 07f6784094d..ac5b92c6c78 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu14.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu14.test
@@ -13,10 +13,8 @@
# table.
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
source $testdir/lock_common.tcl
set ::testprefix rbu14
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu3.test b/chromium/third_party/sqlite/src/ext/rbu/rbu3.test
index da87561fbb7..4ea6adbcdaa 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu3.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu3.test
@@ -10,10 +10,8 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu3
@@ -26,9 +24,6 @@ proc run_rbu {target rbu} {
}
forcedelete test.db-oal rbu.db
-db close
-sqlite3_shutdown
-sqlite3_config_uri 1
reset_db
#--------------------------------------------------------------------
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu5.test b/chromium/third_party/sqlite/src/ext/rbu/rbu5.test
index 3696dfb874d..2ae69e96526 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu5.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu5.test
@@ -13,6 +13,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu5
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu6.test b/chromium/third_party/sqlite/src/ext/rbu/rbu6.test
index bb5b17f4257..29d4c5e1a2f 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu6.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu6.test
@@ -13,10 +13,8 @@
# outcome of some other client writing to the database while an RBU update
# is being applied.
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu6
proc setup_test {} {
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu7.test b/chromium/third_party/sqlite/src/ext/rbu/rbu7.test
index 1e3bc174dd6..ffe6ebe1b64 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu7.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu7.test
@@ -13,10 +13,8 @@
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu7
# Test index:
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu8.test b/chromium/third_party/sqlite/src/ext/rbu/rbu8.test
index c0ccd8c5eb8..b73bde274ca 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu8.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu8.test
@@ -12,10 +12,8 @@
# Test the rbu_delta() feature.
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu8
do_execsql_test 1.0 {
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu9.test b/chromium/third_party/sqlite/src/ext/rbu/rbu9.test
index 0efdc1dde55..499ff09459e 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu9.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu9.test
@@ -12,10 +12,8 @@
# Test RBU with virtual tables. And tables with no PRIMARY KEY declarations.
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbu9
ifcapable !fts3 {
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuA.test b/chromium/third_party/sqlite/src/ext/rbu/rbuA.test
index 642caca1960..b43d30d4f6d 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuA.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuA.test
@@ -14,10 +14,8 @@
# a wal mode database via RBU.
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbuA
set db_sql {
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuB.test b/chromium/third_party/sqlite/src/ext/rbu/rbuB.test
index ece51c39b2a..3e777631d59 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuB.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuB.test
@@ -12,6 +12,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbuB
db close
@@ -48,7 +49,7 @@ do_test 1.2 {
do_test 1.3 {
set ::errlog
-} {SQLITE_NOTICE_RECOVER_WAL SQLITE_INTERNAL}
+} {SQLITE_NOTICE_RECOVER_WAL SQLITE_NOTICE_RBU}
do_execsql_test 1.4 {
SELECT * FROM t1
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuC.test b/chromium/third_party/sqlite/src/ext/rbu/rbuC.test
index ff3d4d50758..a38a6918a9d 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuC.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuC.test
@@ -13,6 +13,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbuC
#-------------------------------------------------------------------------
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl b/chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl
index c4e98784a48..57db5a561fa 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbu_common.tcl
@@ -15,6 +15,16 @@ if {![info exists testdir]} {
}
source $testdir/tester.tcl
+proc if_no_rbu_support {tcl} {
+ set bOk 1
+ ifcapable !rbu { set bOk 0 }
+ if {[permutation]=="journaltest"} { set bOk 0 }
+ if {$bOk==0} {
+ set c [catch {uplevel 1 $tcl} r]
+ return -code $c $r
+ }
+}
+
proc check_prestep_state {target state} {
set oal_exists [file exists $target-oal]
set wal_exists [file exists $target-wal]
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbucollate.test b/chromium/third_party/sqlite/src/ext/rbu/rbucollate.test
index ccc09762470..beb54aa54e2 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbucollate.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbucollate.test
@@ -11,6 +11,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbucollate
ifcapable !icu_collations {
@@ -18,11 +19,6 @@ ifcapable !icu_collations {
return
}
-db close
-sqlite3_shutdown
-sqlite3_config_uri 1
-reset_db
-
# Create a simple RBU database. That expects to write to a table:
#
# CREATE TABLE t1(a PRIMARY KEY, b, c);
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbucrash.test b/chromium/third_party/sqlite/src/ext/rbu/rbucrash.test
index 34ac2c86fe1..e187e8db380 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbucrash.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbucrash.test
@@ -10,18 +10,10 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbucrash
-db close
-forcedelete test.db-oal rbu.db
-sqlite3_shutdown
-sqlite3_config_uri 1
-reset_db
-
# Set up a target database and an rbu update database. The target
# db is the usual "test.db", the rbu db is "test.db2".
#
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbucrash2.test b/chromium/third_party/sqlite/src/ext/rbu/rbucrash2.test
index 9ff6eba4f22..10721df7093 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbucrash2.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbucrash2.test
@@ -10,18 +10,10 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbucrash2
-db close
-forcedelete test.db-oal rbu.db
-sqlite3_shutdown
-sqlite3_config_uri 1
-reset_db
-
# Set up a target database and an rbu update database. The target
# db is the usual "test.db", the rbu db is "test.db2".
#
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbudiff.test b/chromium/third_party/sqlite/src/ext/rbu/rbudiff.test
index 5c2bf9bee7b..e5e3df12f26 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbudiff.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbudiff.test
@@ -12,10 +12,9 @@
# Tests for the [sqldiff --rbu] command.
#
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set testprefix rbudiff
set PROG [test_find_sqldiff]
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbudor.test b/chromium/third_party/sqlite/src/ext/rbu/rbudor.test
index df4d934de79..c456d6ab71e 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbudor.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbudor.test
@@ -13,10 +13,8 @@
# enabled by SQLITE_DIRECT_OVERFLOW_READ - Direct Overflow Read.
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbudor
set bigA [string repeat a 5000]
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuexpr.test b/chromium/third_party/sqlite/src/ext/rbu/rbuexpr.test
index a392c4ed8c8..4635d9fef26 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuexpr.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuexpr.test
@@ -11,14 +11,9 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbuexpr
-db close
-sqlite3_shutdown
-sqlite3_config_uri 1
-
-sqlite3 db test.db
-
do_execsql_test 1.0 {
CREATE TABLE t1(a, b, c PRIMARY KEY);
CREATE INDEX i1 ON t1(a, null, b+1);
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbufault.test b/chromium/third_party/sqlite/src/ext/rbu/rbufault.test
index 247a991899e..d35c389d7be 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbufault.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbufault.test
@@ -10,10 +10,8 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
source $testdir/malloc_common.tcl
set ::testprefix rbufault
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbufault2.test b/chromium/third_party/sqlite/src/ext/rbu/rbufault2.test
index 36f2b6b6f23..fafe0ede7d2 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbufault2.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbufault2.test
@@ -10,10 +10,8 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
source $testdir/malloc_common.tcl
set ::testprefix rbufault2
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbufault3.test b/chromium/third_party/sqlite/src/ext/rbu/rbufault3.test
index 4f690284a27..543e2376262 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbufault3.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbufault3.test
@@ -13,6 +13,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
source $testdir/malloc_common.tcl
set ::testprefix rbufault3
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbufault4.test b/chromium/third_party/sqlite/src/ext/rbu/rbufault4.test
index 551b8b2b6f3..b95612449f2 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbufault4.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbufault4.test
@@ -10,10 +10,8 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
source $testdir/malloc_common.tcl
set ::testprefix rbufault4
@@ -26,6 +24,7 @@ for {set tn 1} {1} {incr tn} {
INSERT INTO t1 VALUES(1, 2, 3);
INSERT INTO t1 VALUES(4, 5, 6);
}
+ db close
forcedelete test.db2
sqlite3rbu_vacuum rbu test.db test.db2
@@ -55,8 +54,10 @@ for {set tn 1} {1} {incr tn} {
set trc [rbu close]
if {$trc!="SQLITE_DONE"} { error "Got $trc instead of SQLITE_DONE!" }
+ sqlite3 db test.db
set rc [db one {PRAGMA integrity_check}]
if {$rc!="ok"} { error "Got $rc instead of ok!" }
+ db close
}
}
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbufts.test b/chromium/third_party/sqlite/src/ext/rbu/rbufts.test
index 95d4e75c52a..b46c32fdc21 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbufts.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbufts.test
@@ -13,10 +13,8 @@
# contains tests to ensure that RBU works with FTS tables.
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbufts
ifcapable !fts3 {
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbumisc.test b/chromium/third_party/sqlite/src/ext/rbu/rbumisc.test
index c2a3906c09f..16293141be9 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbumisc.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbumisc.test
@@ -11,13 +11,9 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbumisc
-db close
-sqlite3_shutdown
-sqlite3_config_uri 1
-reset_db
-
proc populate_rbu_db {} {
forcedelete rbu.db
sqlite3 rbu rbu.db
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbumulti.test b/chromium/third_party/sqlite/src/ext/rbu/rbumulti.test
index 5579a5f5bf1..c24da3518dd 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbumulti.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbumulti.test
@@ -9,16 +9,17 @@
#
#***********************************************************************
#
+# TESTRUNNER: slow
+#
# This file contains tests of multiple RBU operations running
# concurrently within the same process.
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbumulti
db close
-sqlite3_shutdown
-sqlite3_config_uri 1
autoinstall_test_functions
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbupartial.test b/chromium/third_party/sqlite/src/ext/rbu/rbupartial.test
index d6cd7330fe0..0c8191d2b6d 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbupartial.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbupartial.test
@@ -11,11 +11,10 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbupartial
db close
-sqlite3_shutdown
-sqlite3_config_uri 1
foreach {tn without_rowid a b c d} {
1 "" a b c d
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuprogress.test b/chromium/third_party/sqlite/src/ext/rbu/rbuprogress.test
index bf37b4e5056..07268374247 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuprogress.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuprogress.test
@@ -11,6 +11,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbuprogress
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rburesume.test b/chromium/third_party/sqlite/src/ext/rbu/rburesume.test
index a2cf9bc4ab0..cdd8908435c 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rburesume.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rburesume.test
@@ -9,11 +9,14 @@
#
#***********************************************************************
#
+# TESTRUNNER: slow
+#
# This file contains tests for resumption of RBU operations in the
# case where the previous RBU process crashed.
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rburesume
forcedelete test.db-shm test.db-oal
@@ -97,7 +100,7 @@ for {set n 1} {$n < 5000} {incr n} {
break
}
- foreach f {test.db test.db-oal test.db-wal test.db-shm test.db-vacuum} {
+ foreach f {test.db test.db-oal test.db-wal test.db-vacuum} {
set f2 [string map [list test.db test.db2] $f]
if {[file exists $f]} {
forcecopy $f $f2
@@ -156,7 +159,7 @@ for {set n 1} {$n < 5000} {incr n} {
break
}
- foreach f {test.db test.db-oal test.db-wal test.db-shm test.db-vacuum} {
+ foreach f {test.db test.db-oal test.db-wal test.db-vacuum} {
set f2 [string map [list test.db test.db2] $f]
if {[file exists $f]} {
forcecopy $f $f2
@@ -223,7 +226,7 @@ for {set n 1} {$n < 5000} {incr n} {
break
}
- foreach f {test.db test.db-oal test.db-wal test.db-shm test.db-vacuum} {
+ foreach f {test.db test.db-oal test.db-wal test.db-vacuum} {
set f2 [string map [list test.db test.db2] $f]
if {[file exists $f]} {
forcecopy $f $f2
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbusave.test b/chromium/third_party/sqlite/src/ext/rbu/rbusave.test
index 210d7b545a8..8e9708980be 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbusave.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbusave.test
@@ -10,10 +10,8 @@
#***********************************************************************
#
-if {![info exists testdir]} {
- set testdir [file join [file dirname [info script]] .. .. test]
-}
-source $testdir/tester.tcl
+source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbusave
do_execsql_test 1.0 {
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbusplit.test b/chromium/third_party/sqlite/src/ext/rbu/rbusplit.test
index 34fef38677a..fb1d7238d4b 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbusplit.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbusplit.test
@@ -12,11 +12,10 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbusplit
db close
-sqlite3_shutdown
-sqlite3_config_uri 1
autoinstall_test_functions
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbutemplimit.test b/chromium/third_party/sqlite/src/ext/rbu/rbutemplimit.test
index 958b2bfcbc6..88b5f4152de 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbutemplimit.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbutemplimit.test
@@ -9,13 +9,13 @@
#
#***********************************************************************
#
+# TESTRUNNER: slow
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbutemplimit
db close
-sqlite3_shutdown
-sqlite3_config_uri 1
proc setup_databases {} {
forcedelete test.db2
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum.test b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum.test
index 1785f529b14..ad377a4bebf 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum.test
@@ -15,6 +15,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set ::testprefix rbuvacuum
foreach step {0 1} {
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test
index c8fba6a22d5..34ec26188ac 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum2.test
@@ -15,6 +15,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
foreach {step} {0 1} {
foreach {ttt state} {
@@ -227,10 +228,11 @@ do_test 6.1 {
rbu close
} {SQLITE_OK}
-do_execsql_test 6.2 {
- SELECT 1 FROM sqlite_master LIMIT 1;
- PRAGMA wal_checkpoint;
-} {1 0 4 4}
+do_test 6.2 {
+ execsql { SELECT 1 FROM sqlite_master LIMIT 1 }
+ execsql { PRAGMA wal_checkpoint }
+ execsql { SELECT 1 FROM sqlite_master LIMIT 1 }
+} {1}
do_test 6.3 {
sqlite3rbu_vacuum rbu test.db test.db2
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test
index 7e1e337f3cb..d70c094f2ff 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum3.test
@@ -15,6 +15,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set testprefix rbuvacuum3
do_execsql_test 1.0 {
diff --git a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum4.test b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum4.test
index 5cf33d67653..7b0db974d3f 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum4.test
+++ b/chromium/third_party/sqlite/src/ext/rbu/rbuvacuum4.test
@@ -15,6 +15,7 @@
#
source [file join [file dirname [info script]] rbu_common.tcl]
+if_no_rbu_support { finish_test ; return }
set testprefix rbuvacuum4
set step 1
@@ -87,6 +88,7 @@ do_execsql_test 4.2 {
SELECT count(*) fROM x1
} 6
+db cache flush
do_rbu_vacuum_test 4.1.2 0
#-------------------------------------------------------------------------
diff --git a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
index 27a3720daa0..2db66f67acb 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
+++ b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.c
@@ -393,6 +393,8 @@ struct sqlite3rbu {
int nPagePerSector; /* Pages per sector for pTargetFd */
i64 iOalSz;
i64 nPhaseOneStep;
+ void *pRenameArg;
+ int (*xRename)(void*, const char*, const char*);
/* The following state variables are used as part of the incremental
** checkpoint stage (eStage==RBU_STAGE_CKPT). See comments surrounding
@@ -2781,7 +2783,7 @@ static void rbuOpenDatabase(sqlite3rbu *p, sqlite3 *dbMain, int *pbRetry){
sqlite3_file_control(p->dbRbu, "main", SQLITE_FCNTL_RBUCNT, (void*)p);
if( p->zState==0 ){
const char *zFile = sqlite3_db_filename(p->dbRbu, "main");
- p->zState = rbuMPrintf(p, "file://%s-vacuum?modeof=%s", zFile, zFile);
+ p->zState = rbuMPrintf(p, "file:///%s-vacuum?modeof=%s", zFile, zFile);
}
}
@@ -3029,11 +3031,11 @@ static void rbuSetupCheckpoint(sqlite3rbu *p, RbuState *pState){
** no-ops. These locks will not be released until the connection
** is closed.
**
- ** * Attempting to xSync() the database file causes an SQLITE_INTERNAL
+ ** * Attempting to xSync() the database file causes an SQLITE_NOTICE
** error.
**
** As a result, unless an error (i.e. OOM or SQLITE_BUSY) occurs, the
- ** checkpoint below fails with SQLITE_INTERNAL, and leaves the aFrame[]
+ ** checkpoint below fails with SQLITE_NOTICE, and leaves the aFrame[]
** array populated with a set of (frame -> page) mappings. Because the
** WRITER, CHECKPOINT and READ0 locks are still held, it is safe to copy
** data from the wal file into the database file according to the
@@ -3043,7 +3045,7 @@ static void rbuSetupCheckpoint(sqlite3rbu *p, RbuState *pState){
int rc2;
p->eStage = RBU_STAGE_CAPTURE;
rc2 = sqlite3_exec(p->dbMain, "PRAGMA main.wal_checkpoint=restart", 0, 0,0);
- if( rc2!=SQLITE_INTERNAL ) p->rc = rc2;
+ if( rc2!=SQLITE_NOTICE ) p->rc = rc2;
}
if( p->rc==SQLITE_OK && p->nFrame>0 ){
@@ -3089,7 +3091,7 @@ static int rbuCaptureWalRead(sqlite3rbu *pRbu, i64 iOff, int iAmt){
if( pRbu->mLock!=mReq ){
pRbu->rc = SQLITE_BUSY;
- return SQLITE_INTERNAL;
+ return SQLITE_NOTICE_RBU;
}
pRbu->pgsz = iAmt;
@@ -3241,32 +3243,7 @@ static void rbuMoveOalFile(sqlite3rbu *p){
}
if( p->rc==SQLITE_OK ){
-#if defined(_WIN32_WCE)
- {
- LPWSTR zWideOal;
- LPWSTR zWideWal;
-
- zWideOal = rbuWinUtf8ToUnicode(zOal);
- if( zWideOal ){
- zWideWal = rbuWinUtf8ToUnicode(zWal);
- if( zWideWal ){
- if( MoveFileW(zWideOal, zWideWal) ){
- p->rc = SQLITE_OK;
- }else{
- p->rc = SQLITE_IOERR;
- }
- sqlite3_free(zWideWal);
- }else{
- p->rc = SQLITE_IOERR_NOMEM;
- }
- sqlite3_free(zWideOal);
- }else{
- p->rc = SQLITE_IOERR_NOMEM;
- }
- }
-#else
- p->rc = rename(zOal, zWal) ? SQLITE_IOERR : SQLITE_OK;
-#endif
+ p->rc = p->xRename(p->pRenameArg, zOal, zWal);
}
if( p->rc!=SQLITE_OK
@@ -3853,7 +3830,8 @@ static void rbuSetupOal(sqlite3rbu *p, RbuState *pState){
static void rbuDeleteOalFile(sqlite3rbu *p){
char *zOal = rbuMPrintf(p, "%s-oal", p->zTarget);
if( zOal ){
- sqlite3_vfs *pVfs = sqlite3_vfs_find(0);
+ sqlite3_vfs *pVfs = 0;
+ sqlite3_file_control(p->dbMain, "main", SQLITE_FCNTL_VFS_POINTER, &pVfs);
assert( pVfs && p->rc==SQLITE_OK && p->zErrmsg==0 );
pVfs->xDelete(pVfs, zOal, 0);
sqlite3_free(zOal);
@@ -4005,6 +3983,7 @@ static sqlite3rbu *openRbuHandle(
/* Create the custom VFS. */
memset(p, 0, sizeof(sqlite3rbu));
+ sqlite3rbu_rename_handler(p, 0, 0);
rbuCreateVfs(p);
/* Open the target, RBU and state databases */
@@ -4396,6 +4375,54 @@ int sqlite3rbu_savestate(sqlite3rbu *p){
return rc;
}
+/*
+** Default xRename callback for RBU.
+*/
+static int xDefaultRename(void *pArg, const char *zOld, const char *zNew){
+ int rc = SQLITE_OK;
+#if defined(_WIN32_WCE)
+ {
+ LPWSTR zWideOld;
+ LPWSTR zWideNew;
+
+ zWideOld = rbuWinUtf8ToUnicode(zOld);
+ if( zWideOld ){
+ zWideNew = rbuWinUtf8ToUnicode(zNew);
+ if( zWideNew ){
+ if( MoveFileW(zWideOld, zWideNew) ){
+ rc = SQLITE_OK;
+ }else{
+ rc = SQLITE_IOERR;
+ }
+ sqlite3_free(zWideNew);
+ }else{
+ rc = SQLITE_IOERR_NOMEM;
+ }
+ sqlite3_free(zWideOld);
+ }else{
+ rc = SQLITE_IOERR_NOMEM;
+ }
+ }
+#else
+ rc = rename(zOld, zNew) ? SQLITE_IOERR : SQLITE_OK;
+#endif
+ return rc;
+}
+
+void sqlite3rbu_rename_handler(
+ sqlite3rbu *pRbu,
+ void *pArg,
+ int (*xRename)(void *pArg, const char *zOld, const char *zNew)
+){
+ if( xRename ){
+ pRbu->xRename = xRename;
+ pRbu->pRenameArg = pArg;
+ }else{
+ pRbu->xRename = xDefaultRename;
+ pRbu->pRenameArg = 0;
+ }
+}
+
/**************************************************************************
** Beginning of RBU VFS shim methods. The VFS shim modifies the behaviour
** of a standard VFS in the following ways:
@@ -4452,7 +4479,7 @@ int sqlite3rbu_savestate(sqlite3rbu *p){
** database file are recorded. xShmLock() calls to unlock the same
** locks are no-ops (so that once obtained, these locks are never
** relinquished). Finally, calls to xSync() on the target database
-** file fail with SQLITE_INTERNAL errors.
+** file fail with SQLITE_NOTICE errors.
*/
static void rbuUnlockShm(rbu_file *p){
@@ -4561,9 +4588,12 @@ static int rbuVfsClose(sqlite3_file *pFile){
sqlite3_free(p->zDel);
if( p->openFlags & SQLITE_OPEN_MAIN_DB ){
+ const sqlite3_io_methods *pMeth = p->pReal->pMethods;
rbuMainlistRemove(p);
rbuUnlockShm(p);
- p->pReal->pMethods->xShmUnmap(p->pReal, 0);
+ if( pMeth->iVersion>1 && pMeth->xShmUnmap ){
+ pMeth->xShmUnmap(p->pReal, 0);
+ }
}
else if( (p->openFlags & SQLITE_OPEN_DELETEONCLOSE) && p->pRbu ){
rbuUpdateTempSize(p, 0);
@@ -4731,7 +4761,7 @@ static int rbuVfsSync(sqlite3_file *pFile, int flags){
rbu_file *p = (rbu_file *)pFile;
if( p->pRbu && p->pRbu->eStage==RBU_STAGE_CAPTURE ){
if( p->openFlags & SQLITE_OPEN_MAIN_DB ){
- return SQLITE_INTERNAL;
+ return SQLITE_NOTICE_RBU;
}
return SQLITE_OK;
}
@@ -5022,6 +5052,25 @@ static int rbuVfsOpen(
rbuVfsShmUnmap, /* xShmUnmap */
0, 0 /* xFetch, xUnfetch */
};
+ static sqlite3_io_methods rbuvfs_io_methods1 = {
+ 1, /* iVersion */
+ rbuVfsClose, /* xClose */
+ rbuVfsRead, /* xRead */
+ rbuVfsWrite, /* xWrite */
+ rbuVfsTruncate, /* xTruncate */
+ rbuVfsSync, /* xSync */
+ rbuVfsFileSize, /* xFileSize */
+ rbuVfsLock, /* xLock */
+ rbuVfsUnlock, /* xUnlock */
+ rbuVfsCheckReservedLock, /* xCheckReservedLock */
+ rbuVfsFileControl, /* xFileControl */
+ rbuVfsSectorSize, /* xSectorSize */
+ rbuVfsDeviceCharacteristics, /* xDeviceCharacteristics */
+ 0, 0, 0, 0, 0, 0
+ };
+
+
+
rbu_vfs *pRbuVfs = (rbu_vfs*)pVfs;
sqlite3_vfs *pRealVfs = pRbuVfs->pRealVfs;
rbu_file *pFd = (rbu_file *)pFile;
@@ -5076,10 +5125,15 @@ static int rbuVfsOpen(
rc = pRealVfs->xOpen(pRealVfs, zOpen, pFd->pReal, oflags, pOutFlags);
}
if( pFd->pReal->pMethods ){
+ const sqlite3_io_methods *pMeth = pFd->pReal->pMethods;
/* The xOpen() operation has succeeded. Set the sqlite3_file.pMethods
** pointer and, if the file is a main database file, link it into the
** mutex protected linked list of all such files. */
- pFile->pMethods = &rbuvfs_io_methods;
+ if( pMeth->iVersion<2 || pMeth->xShmLock==0 ){
+ pFile->pMethods = &rbuvfs_io_methods1;
+ }else{
+ pFile->pMethods = &rbuvfs_io_methods;
+ }
if( flags & SQLITE_OPEN_MAIN_DB ){
rbuMainlistAdd(pFd);
}
diff --git a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h
index 69d89500a02..d156b3178a1 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h
+++ b/chromium/third_party/sqlite/src/ext/rbu/sqlite3rbu.h
@@ -10,42 +10,42 @@
**
*************************************************************************
**
-** This file contains the public interface for the RBU extension.
+** This file contains the public interface for the RBU extension.
*/
/*
** SUMMARY
**
-** Writing a transaction containing a large number of operations on
+** Writing a transaction containing a large number of operations on
** b-tree indexes that are collectively larger than the available cache
-** memory can be very inefficient.
+** memory can be very inefficient.
**
** The problem is that in order to update a b-tree, the leaf page (at least)
** containing the entry being inserted or deleted must be modified. If the
-** working set of leaves is larger than the available cache memory, then a
-** single leaf that is modified more than once as part of the transaction
+** working set of leaves is larger than the available cache memory, then a
+** single leaf that is modified more than once as part of the transaction
** may be loaded from or written to the persistent media multiple times.
** Additionally, because the index updates are likely to be applied in
-** random order, access to pages within the database is also likely to be in
+** random order, access to pages within the database is also likely to be in
** random order, which is itself quite inefficient.
**
** One way to improve the situation is to sort the operations on each index
** by index key before applying them to the b-tree. This leads to an IO
** pattern that resembles a single linear scan through the index b-tree,
-** and all but guarantees each modified leaf page is loaded and stored
+** and all but guarantees each modified leaf page is loaded and stored
** exactly once. SQLite uses this trick to improve the performance of
** CREATE INDEX commands. This extension allows it to be used to improve
** the performance of large transactions on existing databases.
**
-** Additionally, this extension allows the work involved in writing the
-** large transaction to be broken down into sub-transactions performed
-** sequentially by separate processes. This is useful if the system cannot
-** guarantee that a single update process will run for long enough to apply
-** the entire update, for example because the update is being applied on a
-** mobile device that is frequently rebooted. Even after the writer process
+** Additionally, this extension allows the work involved in writing the
+** large transaction to be broken down into sub-transactions performed
+** sequentially by separate processes. This is useful if the system cannot
+** guarantee that a single update process will run for long enough to apply
+** the entire update, for example because the update is being applied on a
+** mobile device that is frequently rebooted. Even after the writer process
** has committed one or more sub-transactions, other database clients continue
-** to read from the original database snapshot. In other words, partially
-** applied transactions are not visible to other clients.
+** to read from the original database snapshot. In other words, partially
+** applied transactions are not visible to other clients.
**
** "RBU" stands for "Resumable Bulk Update". As in a large database update
** transmitted via a wireless network to a mobile device. A transaction
@@ -61,9 +61,9 @@
**
** * INSERT statements may not use any default values.
**
-** * UPDATE and DELETE statements must identify their target rows by
+** * UPDATE and DELETE statements must identify their target rows by
** non-NULL PRIMARY KEY values. Rows with NULL values stored in PRIMARY
-** KEY fields may not be updated or deleted. If the table being written
+** KEY fields may not be updated or deleted. If the table being written
** has no PRIMARY KEY, affected rows must be identified by rowid.
**
** * UPDATE statements may not modify PRIMARY KEY columns.
@@ -80,10 +80,10 @@
** PREPARATION
**
** An "RBU update" is stored as a separate SQLite database. A database
-** containing an RBU update is an "RBU database". For each table in the
+** containing an RBU update is an "RBU database". For each table in the
** target database to be updated, the RBU database should contain a table
** named "data_<target name>" containing the same set of columns as the
-** target table, and one more - "rbu_control". The data_% table should
+** target table, and one more - "rbu_control". The data_% table should
** have no PRIMARY KEY or UNIQUE constraints, but each column should have
** the same type as the corresponding column in the target database.
** The "rbu_control" column should have no type at all. For example, if
@@ -98,22 +98,22 @@
** The order of the columns in the data_% table does not matter.
**
** Instead of a regular table, the RBU database may also contain virtual
-** tables or view named using the data_<target> naming scheme.
+** tables or views named using the data_<target> naming scheme.
**
-** Instead of the plain data_<target> naming scheme, RBU database tables
+** Instead of the plain data_<target> naming scheme, RBU database tables
** may also be named data<integer>_<target>, where <integer> is any sequence
** of zero or more numeric characters (0-9). This can be significant because
-** tables within the RBU database are always processed in order sorted by
+** tables within the RBU database are always processed in order sorted by
** name. By judicious selection of the <integer> portion of the names
** of the RBU tables the user can therefore control the order in which they
** are processed. This can be useful, for example, to ensure that "external
** content" FTS4 tables are updated before their underlying content tables.
**
** If the target database table is a virtual table or a table that has no
-** PRIMARY KEY declaration, the data_% table must also contain a column
-** named "rbu_rowid". This column is mapped to the tables implicit primary
-** key column - "rowid". Virtual tables for which the "rowid" column does
-** not function like a primary key value cannot be updated using RBU. For
+** PRIMARY KEY declaration, the data_% table must also contain a column
+** named "rbu_rowid". This column is mapped to the table's implicit primary
+** key column - "rowid". Virtual tables for which the "rowid" column does
+** not function like a primary key value cannot be updated using RBU. For
** example, if the target db contains either of the following:
**
** CREATE VIRTUAL TABLE x1 USING fts3(a, b);
@@ -136,35 +136,35 @@
** CREATE TABLE data_ft1(a, b, langid, rbu_rowid, rbu_control);
** CREATE TABLE data_ft1(a, b, rbu_rowid, rbu_control);
**
-** For each row to INSERT into the target database as part of the RBU
+** For each row to INSERT into the target database as part of the RBU
** update, the corresponding data_% table should contain a single record
** with the "rbu_control" column set to contain integer value 0. The
-** other columns should be set to the values that make up the new record
-** to insert.
+** other columns should be set to the values that make up the new record
+** to insert.
**
-** If the target database table has an INTEGER PRIMARY KEY, it is not
-** possible to insert a NULL value into the IPK column. Attempting to
+** If the target database table has an INTEGER PRIMARY KEY, it is not
+** possible to insert a NULL value into the IPK column. Attempting to
** do so results in an SQLITE_MISMATCH error.
**
-** For each row to DELETE from the target database as part of the RBU
+** For each row to DELETE from the target database as part of the RBU
** update, the corresponding data_% table should contain a single record
** with the "rbu_control" column set to contain integer value 1. The
** real primary key values of the row to delete should be stored in the
** corresponding columns of the data_% table. The values stored in the
** other columns are not used.
**
-** For each row to UPDATE from the target database as part of the RBU
+** For each row to UPDATE from the target database as part of the RBU
** update, the corresponding data_% table should contain a single record
** with the "rbu_control" column set to contain a value of type text.
-** The real primary key values identifying the row to update should be
+** The real primary key values identifying the row to update should be
** stored in the corresponding columns of the data_% table row, as should
-** the new values of all columns being update. The text value in the
+** the new values of all columns being update. The text value in the
** "rbu_control" column must contain the same number of characters as
** there are columns in the target database table, and must consist entirely
-** of 'x' and '.' characters (or in some special cases 'd' - see below). For
+** of 'x' and '.' characters (or in some special cases 'd' - see below). For
** each column that is being updated, the corresponding character is set to
** 'x'. For those that remain as they are, the corresponding character of the
-** rbu_control value should be set to '.'. For example, given the tables
+** rbu_control value should be set to '.'. For example, given the tables
** above, the update statement:
**
** UPDATE t1 SET c = 'usa' WHERE a = 4;
@@ -178,30 +178,30 @@
** target table with the value stored in the corresponding data_% column, the
** user-defined SQL function "rbu_delta()" is invoked and the result stored in
** the target table column. rbu_delta() is invoked with two arguments - the
-** original value currently stored in the target table column and the
+** original value currently stored in the target table column and the
** value specified in the data_xxx table.
**
** For example, this row:
**
** INSERT INTO data_t1(a, b, c, rbu_control) VALUES(4, NULL, 'usa', '..d');
**
-** is similar to an UPDATE statement such as:
+** is similar to an UPDATE statement such as:
**
** UPDATE t1 SET c = rbu_delta(c, 'usa') WHERE a = 4;
**
-** Finally, if an 'f' character appears in place of a 'd' or 's' in an
+** Finally, if an 'f' character appears in place of a 'd' or 's' in an
** ota_control string, the contents of the data_xxx table column is assumed
** to be a "fossil delta" - a patch to be applied to a blob value in the
** format used by the fossil source-code management system. In this case
-** the existing value within the target database table must be of type BLOB.
+** the existing value within the target database table must be of type BLOB.
** It is replaced by the result of applying the specified fossil delta to
** itself.
**
** If the target database table is a virtual table or a table with no PRIMARY
-** KEY, the rbu_control value should not include a character corresponding
+** KEY, the rbu_control value should not include a character corresponding
** to the rbu_rowid value. For example, this:
**
-** INSERT INTO data_ft1(a, b, rbu_rowid, rbu_control)
+** INSERT INTO data_ft1(a, b, rbu_rowid, rbu_control)
** VALUES(NULL, 'usa', 12, '.x');
**
** causes a result similar to:
@@ -545,6 +545,34 @@ SQLITE_API void sqlite3rbu_bp_progress(sqlite3rbu *pRbu, int *pnOne, int*pnTwo);
SQLITE_API int sqlite3rbu_state(sqlite3rbu *pRbu);
/*
+** As part of applying an RBU update or performing an RBU vacuum operation,
+** the system must at one point move the *-oal file to the equivalent *-wal
+** path. Normally, it does this by invoking POSIX function rename(2) directly.
+** Except on WINCE platforms, where it uses win32 API MoveFileW(). This
+** function may be used to register a callback that the RBU module will invoke
+** instead of one of these APIs.
+**
+** If a callback is registered with an RBU handle, it invokes it instead
+** of rename(2) when it needs to move a file within the file-system. The
+** first argument passed to the xRename() callback is a copy of the second
+** argument (pArg) passed to this function. The second is the full path
+** to the file to move and the third the full path to which it should be
+** moved. The callback function should return SQLITE_OK to indicate
+** success. If an error occurs, it should return an SQLite error code.
+** In this case the RBU operation will be abandoned and the error returned
+** to the RBU user.
+**
+** Passing a NULL pointer in place of the xRename argument to this function
+** restores the default behaviour.
+*/
+SQLITE_API void sqlite3rbu_rename_handler(
+ sqlite3rbu *pRbu,
+ void *pArg,
+ int (*xRename)(void *pArg, const char *zOld, const char *zNew)
+);
+
+
+/*
** Create an RBU VFS named zName that accesses the underlying file-system
** via existing VFS zParent. Or, if the zParent parameter is passed NULL,
** then the new RBU VFS uses the default system VFS to access the file-system.
diff --git a/chromium/third_party/sqlite/src/ext/rbu/test_rbu.c b/chromium/third_party/sqlite/src/ext/rbu/test_rbu.c
index 6d04bfe8ccf..af794d80f8a 100644
--- a/chromium/third_party/sqlite/src/ext/rbu/test_rbu.c
+++ b/chromium/third_party/sqlite/src/ext/rbu/test_rbu.c
@@ -26,6 +26,14 @@
# endif
#endif
#include <assert.h>
+#include <string.h>
+
+typedef struct TestRbu TestRbu;
+struct TestRbu {
+ sqlite3rbu *pRbu;
+ Tcl_Interp *interp;
+ Tcl_Obj *xRename;
+};
/* From main.c */
extern const char *sqlite3ErrName(int);
@@ -55,6 +63,20 @@ void test_rbu_delta(sqlite3_context *pCtx, int nArg, sqlite3_value **apVal){
Tcl_DecrRefCount(pScript);
}
+static int xRenameCallback(void *pArg, const char *zOld, const char *zNew){
+ int rc = SQLITE_OK;
+ TestRbu *pTest = (TestRbu*)pArg;
+ Tcl_Obj *pEval = Tcl_DuplicateObj(pTest->xRename);
+
+ Tcl_IncrRefCount(pEval);
+ Tcl_ListObjAppendElement(pTest->interp, pEval, Tcl_NewStringObj(zOld, -1));
+ Tcl_ListObjAppendElement(pTest->interp, pEval, Tcl_NewStringObj(zNew, -1));
+
+ rc = Tcl_EvalObjEx(pTest->interp, pEval, TCL_GLOBAL_ONLY);
+ Tcl_DecrRefCount(pEval);
+
+ return rc ? SQLITE_IOERR : SQLITE_OK;
+}
static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
ClientData clientData,
@@ -63,7 +85,8 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
Tcl_Obj *CONST objv[]
){
int ret = TCL_OK;
- sqlite3rbu *pRbu = (sqlite3rbu*)clientData;
+ TestRbu *pTest = (TestRbu*)clientData;
+ sqlite3rbu *pRbu = pTest->pRbu;
struct RbuCmd {
const char *zName;
int nArg;
@@ -82,6 +105,7 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
{"temp_size_limit", 3, "LIMIT"}, /* 10 */
{"temp_size", 2, ""}, /* 11 */
{"dbRbu_eval", 3, "SQL"}, /* 12 */
+ {"rename_handler", 3, "SCRIPT"},/* 13 */
{0,0,0}
};
int iCmd;
@@ -127,6 +151,8 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
}
ret = TCL_ERROR;
}
+ if( pTest->xRename ) Tcl_DecrRefCount(pTest->xRename);
+ ckfree(pTest);
break;
}
@@ -214,6 +240,19 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
break;
}
+ case 13: /* rename_handler */ {
+ Tcl_Obj *pScript = objv[2];
+ assert( !sqlite3_stricmp(aCmd[13].zName, "rename_handler") );
+ if( Tcl_GetCharLength(pScript)==0 ){
+ sqlite3rbu_rename_handler(pRbu, 0, 0);
+ }else{
+ pTest->xRename = Tcl_DuplicateObj(pScript);
+ Tcl_IncrRefCount(pTest->xRename);
+ sqlite3rbu_rename_handler(pRbu, pTest, xRenameCallback);
+ }
+ break;
+ }
+
default: /* seems unlikely */
assert( !"cannot happen" );
break;
@@ -222,6 +261,18 @@ static int SQLITE_TCLAPI test_sqlite3rbu_cmd(
return ret;
}
+static void createRbuWrapper(
+ Tcl_Interp *interp,
+ const char *zCmd,
+ sqlite3rbu *pRbu
+){
+ TestRbu *pTest = (TestRbu*)ckalloc(sizeof(TestRbu));
+ memset(pTest, 0, sizeof(TestRbu));
+ pTest->pRbu = pRbu;
+ pTest->interp = interp;
+ Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pTest, 0);
+}
+
/*
** Tclcmd: sqlite3rbu CMD <target-db> <rbu-db> ?<state-db>?
*/
@@ -247,7 +298,7 @@ static int SQLITE_TCLAPI test_sqlite3rbu(
if( objc==5 ) zStateDb = Tcl_GetString(objv[4]);
pRbu = sqlite3rbu_open(zTarget, zRbu, zStateDb);
- Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0);
+ createRbuWrapper(interp, zCmd, pRbu);
Tcl_SetObjResult(interp, objv[1]);
return TCL_OK;
}
@@ -276,7 +327,7 @@ static int SQLITE_TCLAPI test_sqlite3rbu_vacuum(
if( zStateDb && zStateDb[0]=='\0' ) zStateDb = 0;
pRbu = sqlite3rbu_vacuum(zTarget, zStateDb);
- Tcl_CreateObjCommand(interp, zCmd, test_sqlite3rbu_cmd, (ClientData)pRbu, 0);
+ createRbuWrapper(interp, zCmd, pRbu);
Tcl_SetObjResult(interp, objv[1]);
return TCL_OK;
}