]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Allow the RBU module to read data from appropriately named SQL views created within...
authordan <dan@noemail.net>
Fri, 24 Jul 2015 18:58:59 +0000 (18:58 +0000)
committerdan <dan@noemail.net>
Fri, 24 Jul 2015 18:58:59 +0000 (18:58 +0000)
FossilOrigin-Name: 45c6a760ca63d19a7ccc352c7e35d8391025b515

ext/rbu/rbu14.test [new file with mode: 0644]
ext/rbu/sqlite3rbu.c
manifest
manifest.uuid

diff --git a/ext/rbu/rbu14.test b/ext/rbu/rbu14.test
new file mode 100644 (file)
index 0000000..d4f97ac
--- /dev/null
@@ -0,0 +1,95 @@
+# 2015 July 25
+#
+# The author disclaims copyright to this source code.  In place of
+# a legal notice, here is a blessing:
+#
+#    May you do good and not evil.
+#    May you find forgiveness for yourself and forgive others.
+#    May you share freely, never taking more than you give.
+#
+#***********************************************************************
+#
+# Test that an RBU data_xxx table may be a view instead of a regular
+# table.
+#
+
+if {![info exists testdir]} {
+  set testdir [file join [file dirname [info script]] .. .. test]
+}
+source $testdir/tester.tcl
+source $testdir/lock_common.tcl
+set ::testprefix rbu14
+
+
+foreach {tn schema} {
+  1 {
+    CREATE TABLE t1(a PRIMARY KEY, b, c);
+    CREATE TABLE t2(a PRIMARY KEY, b, c);
+  }
+  2 {
+    CREATE TABLE t1(a PRIMARY KEY, b, c);
+    CREATE TABLE t2(a PRIMARY KEY, b, c);
+    CREATE INDEX i1 ON t1(b, c);
+    CREATE INDEX i2 ON t2(b, c);
+  }
+  3 {
+    CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
+    CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;
+  }
+  4 {
+    CREATE TABLE t1(a PRIMARY KEY, b, c) WITHOUT ROWID;
+    CREATE TABLE t2(a PRIMARY KEY, b, c) WITHOUT ROWID;
+    CREATE INDEX i1 ON t1(b, c);
+    CREATE INDEX i2 ON t2(b, c);
+  }
+} {
+  reset_db
+
+  execsql $schema
+  execsql {
+    INSERT INTO t1 VALUES(50, 50, 50);
+    INSERT INTO t1 VALUES(51, 51, 51);
+    INSERT INTO t2 VALUES(50, 50, 50);
+    INSERT INTO t2 VALUES(51, 51, 51);
+  }
+
+  forcedelete rbu.db
+  do_execsql_test $tn.1 {
+    ATTACH 'rbu.db' AS rbu;
+    CREATE TABLE rbu.stuff(tbl, a, b, c, rbu_control);
+    INSERT INTO stuff VALUES
+      ('t1', 1, 2, 3, 0),                   -- insert into t1
+      ('t2', 4, 5, 6, 0),                   -- insert into t2
+      ('t1', 50, NULL, NULL, 1),            -- delete from t1
+      ('t2', 51, NULL, NULL, 1);            -- delete from t2
+
+    CREATE VIEW rbu.data_t1 AS 
+    SELECT a, b, c, rbu_control FROM stuff WHERE tbl='t1';
+    CREATE VIEW rbu.data_t2 AS 
+    SELECT a, b, c, rbu_control FROM stuff WHERE tbl='t2';
+  }
+
+  do_test $tn.2 {
+    while 1 {
+      sqlite3rbu rbu test.db rbu.db
+      set rc [rbu step]
+      rbu close
+      if {$rc != "SQLITE_OK"} break
+    }
+    set rc
+  } {SQLITE_DONE}
+
+  do_execsql_test $tn.3.1 {
+    SELECT * FROM t1 ORDER BY a;
+  } {1 2 3 51 51 51}
+
+  do_execsql_test $tn.3.2 {
+    SELECT * FROM t2 ORDER BY a;
+  } {4 5 6 50 50 50}
+
+  integrity_check $tn.4
+}
+
+
+finish_test
+
index 11090d082119974317e5a38becc105fc694ccd2e..93197e13def036bb88ee90ab473fc7e8c0deb098 100644 (file)
@@ -568,7 +568,7 @@ static int rbuObjIterFirst(sqlite3rbu *p, RbuObjIter *pIter){
 
   rc = prepareAndCollectError(p->dbRbu, &pIter->pTblIter, &p->zErrmsg, 
       "SELECT substr(name, 6) FROM sqlite_master "
-      "WHERE type='table' AND name LIKE 'data_%'"
+      "WHERE type IN ('table', 'view') AND name LIKE 'data_%'"
   );
 
   if( rc==SQLITE_OK ){
index a8a2be5eb9257d42fdf743a73e37817fbc0c1708..94afeff7d368b1d66c035b613f9b0b427ada5aac 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Fix\sa\stest\sscript\sbug\sintroduced\sby\s[562687d9].
-D 2015-07-24T18:22:29.438
+C Allow\sthe\sRBU\smodule\sto\sread\sdata\sfrom\sappropriately\snamed\sSQL\sviews\screated\swithin\sthe\sRBU\sdatabase.
+D 2015-07-24T18:58:59.288
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in 4de3ef40c8b3b75c0c55ff4242a43c8ce1ad90ee
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -206,6 +206,7 @@ F ext/rbu/rbu10.test 046b0980041d30700464a800bbf6733ed2df515d
 F ext/rbu/rbu11.test 9bc68c2d3dbeb1720153626e3bd0466dcc017702
 F ext/rbu/rbu12.test bde22ed0004dd5d1888c72a84ae407e574aeae16
 F ext/rbu/rbu13.test 462ff799c4afedc3ef8a47ff818c0ffbf14ae4f2
+F ext/rbu/rbu14.test 01f5dcba904aecadbaea69d4ccdc2ea43dd30560
 F ext/rbu/rbu3.test 8bd4c6b87367c358981b6a47dc3d654fa60bff90
 F ext/rbu/rbu5.test 2e24fee3e615aecd99bbdd46967935a641e866f7
 F ext/rbu/rbu6.test 32e8ed60631b6facdb6366bd2b5f5f25245e7edb
@@ -216,7 +217,7 @@ F ext/rbu/rbuA.test c1a7b3e2d926b8f8448bb3b4ae787e314ee4b2b3
 F ext/rbu/rbucrash.test 8d2ed5d4b05fef6c00c2a6b5f7ead71fa172a695
 F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89
 F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06
-F ext/rbu/sqlite3rbu.c d37e1ca2d13e439cb3df7cd9d98db90458f21433
+F ext/rbu/sqlite3rbu.c 7a0ca8fca2d0c9a72f0b7b96618c2ea9f7b4bc1d
 F ext/rbu/sqlite3rbu.h 6a280298e9eeb8ef59841a620f07f4f844651545
 F ext/rbu/test_rbu.c f99698956cc9158d6bf865e461e2d15876538ac1
 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
@@ -1365,7 +1366,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 48bd54594752d5be3337f12c72f28d2080cb630b
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 1997ee548b2e569a39e73319b661c1a78dfe5dae
-R f8b9545e94c6fbffbe67ad49b98674a7
+P a343745d99cf4bccb2f5582735cc2f88b03e847d
+R 7ce8a63d79686096fb6b7851b4b14217
 U dan
-Z 7d7fc23acf815710c2dab9adf78529b1
+Z 6032c3754b57e07594e126d07ba72107
index 281e88295cfda70f78abcfebf0808fe3b9fced52..d26a45bf907add893c13f33edd12af2f3dd6ec3d 100644 (file)
@@ -1 +1 @@
-a343745d99cf4bccb2f5582735cc2f88b03e847d
\ No newline at end of file
+45c6a760ca63d19a7ccc352c7e35d8391025b515
\ No newline at end of file