Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Unified Diff: third_party/sqlite/src/ext/rbu/rbudiff.test

Issue 2751253002: [sql] Import SQLite 3.17.0. (Closed)
Patch Set: also clang on Linux i386 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/sqlite/src/ext/rbu/rbu_common.tcl ('k') | third_party/sqlite/src/ext/rbu/rbudor.test » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/sqlite/src/ext/rbu/rbudiff.test
diff --git a/third_party/sqlite/src/ext/rbu/rbudiff.test b/third_party/sqlite/src/ext/rbu/rbudiff.test
index 10be9e0d5328461a2828d16531b6a98720509305..6f6af828047ec3415274e018a72ca5188fec2a76 100644
--- a/third_party/sqlite/src/ext/rbu/rbudiff.test
+++ b/third_party/sqlite/src/ext/rbu/rbudiff.test
@@ -18,22 +18,17 @@ if {![info exists testdir]} {
source $testdir/tester.tcl
set testprefix rbudiff
-if {$tcl_platform(platform)=="windows"} {
- set PROG "sqldiff.exe"
-} else {
- set PROG "./sqldiff"
-}
-if {![file exe $PROG]} {
- puts "rbudiff.test cannot run because $PROG is not available"
- finish_test
- return
-}
+set PROG [test_find_sqldiff]
db close
proc get_rbudiff_sql {db1 db2} {
exec $::PROG --rbu $db1 $db2
}
+proc get_vtab_rbudiff_sql {db1 db2} {
+ exec $::PROG --vtab --rbu $db1 $db2
+}
+
proc step_rbu {target rbu} {
while 1 {
sqlite3rbu rbu $target $rbu
@@ -45,6 +40,7 @@ proc step_rbu {target rbu} {
}
proc apply_rbudiff {sql target} {
+ test_rbucount $sql
forcedelete rbu.db
sqlite3 rbudb rbu.db
rbudb eval $sql
@@ -52,15 +48,43 @@ proc apply_rbudiff {sql target} {
step_rbu $target rbu.db
}
+proc sqlesc {id} {
+ set ret "'[string map {' ''} $id]'"
+ set ret
+}
+
+# The only argument is the output of an [sqldiff -rbu] run. This command
+# tests that the contents of the rbu_count table is correct. An exception
+# is thrown if it is not.
+#
+proc test_rbucount {sql} {
+ sqlite3 tmpdb ""
+ tmpdb eval $sql
+ tmpdb eval {
+ SELECT name FROM sqlite_master WHERE name LIKE 'data%' AND type='table'
+ } {
+ set a [tmpdb eval "SELECT count(*) FROM [sqlesc $name]"]
+ set b [tmpdb eval {SELECT cnt FROM rbu_count WHERE tbl = $name}]
+ if {$a != $b} {
+ tmpdb close
+ error "rbu_count error - tbl = $name"
+ }
+ }
+ tmpdb close
+ return ""
+}
+
proc rbudiff_cksum {db1} {
set txt ""
sqlite3 dbtmp $db1
foreach tbl [dbtmp eval {SELECT name FROM sqlite_master WHERE type='table'}] {
set cols [list]
- dbtmp eval "PRAGMA table_info = $tbl" { lappend cols "quote( $name )" }
+ dbtmp eval "PRAGMA table_info = [sqlesc $tbl]" {
+ lappend cols "quote( $name )"
+ }
append txt [dbtmp eval \
- "SELECT [join $cols {||'.'||}] FROM $tbl ORDER BY 1"
+ "SELECT [join $cols {||'.'||}] FROM [sqlesc $tbl] ORDER BY 1"
]
}
dbtmp close
@@ -116,6 +140,24 @@ foreach {tn init mod} {
);
}
+ 4 {
+ CREATE TABLE x1(a, b, c, PRIMARY KEY(a, b, c));
+ INSERT INTO x1 VALUES('u', 'v', NULL);
+ INSERT INTO x1 VALUES('x', 'y', 'z');
+ INSERT INTO x1 VALUES('a', NULL, 'b');
+ } {
+ INSERT INTO x1 VALUES('a', 'b', 'c');
+ }
+
+ 5 {
+ CREATE TABLE t1(a PRIMARY KEY, b);
+ INSERT INTO t1 VALUES(1, NULL);
+ INSERT INTO t1 VALUES(2, X'');
+ } {
+ UPDATE t1 SET b = X'' WHERE a=1;
+ UPDATE t1 SET b = NULL WHERE a=2;
+ }
+
} {
catch { db close }
@@ -146,5 +188,116 @@ foreach {tn init mod} {
do_test 1.$tn.5 { rbudiff_cksum test.db } [rbudiff_cksum test.db2]
}
+#-------------------------------------------------------------------------
+# Test that if the --vtab switch is present, [sqldiff] handles virtual
+# table types fts[345] and rtree correctly.
+#
+ifcapable fts3&&fts5&&rtree {
+
+foreach {tn init mod} {
+ 1 {
+ CREATE VIRTUAL TABLE t1 USING fts5(c);
+ INSERT INTO t1 VALUES('a b c');
+ INSERT INTO t1 VALUES('a b c');
+ } {
+ DELETE FROM t1 WHERE rowid = 1;
+ INSERT INTO t1 VALUES('a b c');
+ }
+
+ 2 {
+ CREATE VIRTUAL TABLE "x y" USING 'rtree'(id, x1, x2);
+ INSERT INTO "x y" VALUES(1, 2, 3);
+ INSERT INTO "x y" VALUES(2, 4, 6);
+ } {
+ DELETE FROM "x y" WHERE rowid = 1;
+ INSERT INTO "x y" VALUES(3, 6, 9);
+ }
+
+ 3 {
+ CREATE VIRTUAL TABLE 'x''y' USING fts3;
+ INSERT INTO 'x''y' VALUES('one two three');
+ INSERT INTO 'x''y' VALUES('four five six');
+ } {
+ DELETE FROM 'x''y' WHERE rowid = 1;
+ INSERT INTO 'x''y' VALUES('one two three');
+ }
+} {
+
+ forcedelete test.db test.db2
+ sqlite3 db test.db
+ db eval "$init"
+ sqlite3 db test.db2
+ db eval "$init ; $mod"
+ db close
+
+ do_test 2.$tn.1 {
+ set sql [get_vtab_rbudiff_sql test.db test.db2]
+ apply_rbudiff $sql test.db
+ } {SQLITE_DONE}
+ do_test 2.$tn.2 { rbudiff_cksum test.db } [rbudiff_cksum test.db2]
+}
+
+}
+
+ifcapable fts5 {
+ foreach {tn init mod} {
+ 1 {
+ CREATE VIRTUAL TABLE t1 USING fts5(c);
+ INSERT INTO t1 VALUES('a b c');
+ INSERT INTO t1 VALUES('a b c');
+ } {
+ DELETE FROM t1 WHERE rowid = 1;
+ INSERT INTO t1 VALUES('a b c');
+ }
+
+ 2 {
+ CREATE VIRTUAL TABLE t1 USING FTs5(c);
+ INSERT INTO t1 VALUES('a b c');
+ INSERT INTO t1 VALUES('a b c');
+ } {
+ DELETE FROM t1 WHERE rowid = 1;
+ INSERT INTO t1 VALUES('a b c');
+ }
+
+ 3 {
+ creAte virTUal
+tablE t1 USING FTs5(c);
+ INSERT INTO t1 VALUES('a b c');
+ INSERT INTO t1 VALUES('a b c');
+ } {
+ DELETE FROM t1 WHERE rowid = 1;
+ INSERT INTO t1 VALUES('a b c');
+ }
+
+ } {
+ forcedelete test.db test.db2
+ sqlite3 db test.db
+ db eval "$init"
+ sqlite3 db test.db2
+ db eval "$init ; $mod"
+ db eval { INSERT INTO t1(t1) VALUES('optimize') }
+ db close
+
+ do_test 3.$tn.1 {
+ set sql [get_vtab_rbudiff_sql test.db test.db2]
+ apply_rbudiff $sql test.db
+ } {SQLITE_DONE}
+
+ sqlite3 db test.db
+ sqlite3 db2 test.db2
+ do_test 3.$tn.2 {
+ db2 eval { SELECT * FROM t1 ORDER BY rowid }
+ } [db eval { SELECT * FROM t1 ORDER BY rowid }]
+
+ do_test 3.$tn.3 {
+ db2 eval { INSERT INTO t1(t1) VALUES('integrity-check') }
+ } {}
+
+ db close
+ db2 close
+ }
+}
+
+
finish_test
« no previous file with comments | « third_party/sqlite/src/ext/rbu/rbu_common.tcl ('k') | third_party/sqlite/src/ext/rbu/rbudor.test » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698