]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add further tests for sqlite3rbu_bp_progress(). Fix a problem in handling WITHOUT...
authordan <dan@noemail.net>
Fri, 18 Mar 2016 20:12:28 +0000 (20:12 +0000)
committerdan <dan@noemail.net>
Fri, 18 Mar 2016 20:12:28 +0000 (20:12 +0000)
FossilOrigin-Name: 65e02368e2b6cec349ea71af5a456d6783b0d15e

ext/rbu/rbuprogress.test
ext/rbu/sqlite3rbu.c
manifest
manifest.uuid

index 8459bc09e03d6c87605af029787a0e8da5a4954c..6e6c7faf618c1de8b0c76c5c29124dfff2da8392 100644 (file)
@@ -70,12 +70,13 @@ proc do_sp_test {tn bReopen target rbu reslist} {
     while 1 {
       if {$bReopen} { sqlite3rbu rbu $target $rbu }
       set rc [rbu step]
-      if {[set rc] != "SQLITE_OK"} { error "error 1" }
+      if {[set rc] != "SQLITE_OK"} { rbu close ; error "error 1" }
       lappend res [lindex [rbu bp_progress] 0]
       if {[lindex [set res] end]==10000} break
       if {$bReopen} { rbu close }
     }
     if {[set res] != [list $reslist]} {
+      rbu close
       error "1. reslist incorrect (expect=$reslist got=[set res])"
     }
 
@@ -88,6 +89,7 @@ proc do_sp_test {tn bReopen target rbu reslist} {
       rbu step
       set res [rbu bp_progress]
       if {[set res] != [list 10000 0]} {
+        rbu close
         error "2. reslist incorrect (expect=10000 0 got=[set res])"
       }
     }
@@ -95,6 +97,7 @@ proc do_sp_test {tn bReopen target rbu reslist} {
     rbu step
     set res [rbu bp_progress]
     if {[set res] != [list 10000 0]} {
+      rbu close
       error "3. reslist incorrect (expect=10000 0 got=[set res])"
     }
 
@@ -102,12 +105,14 @@ proc do_sp_test {tn bReopen target rbu reslist} {
     while {[rbu step]=="SQLITE_OK"} { 
       foreach {a b} [rbu bp_progress] {}
       if {[set a]!=10000 || [set b]<=0 || [set b]>10000} {
+        rbu close
         error "4. reslist incorrect (expect=10000 1..10000 got=[set a] [set b])"
       }
     }
 
     set res [rbu bp_progress]
     if {[set res] != [list 10000 10000]} {
+      rbu close
       error "5. reslist is incorrect (expect=10000 10000 got=[set res])"
     }
 
@@ -116,7 +121,6 @@ proc do_sp_test {tn bReopen target rbu reslist} {
 }
 
 foreach {bReopen} { 0 1 } {
-
   reset_db
   do_test 2.$bReopen.1.0 {
     execsql {
@@ -288,5 +292,114 @@ foreach bReopen {0 1} {
 }
 
 
+foreach {bReopen} { 0 1 } {
+  foreach {tn tbl} {
+    ipk { CREATE TABLE t1(a INTEGER PRIMARY KEY, b, c) }
+    wr  { CREATE TABLE t1(a INT PRIMARY KEY, b, c) WITHOUT ROWID }
+    pk  { CREATE TABLE t1(a INT PRIMARY KEY, b, c) }
+  } {
+
+    foreach {tn2 rbusql r1 r3} {
+      1 {
+        CREATE TABLE data0_t1(a, b, c, rbu_control);
+        INSERT INTO data0_t1 VALUES(15, 15, 15, 0);
+        INSERT INTO data0_t1 VALUES(20, 20, 20, 0);
+        CREATE TABLE rbu_count(tbl, cnt);
+        INSERT INTO rbu_count VALUES('data0_t1', 2); 
+      } 
+      {2500 5000 7500 10000}
+      {1666 3333 5000 6666 8333 10000}
+
+      2 {
+        CREATE TABLE data0_t1(a, b, c, rbu_control);
+        INSERT INTO data0_t1 VALUES(10, 10, 10, 2);
+        CREATE TABLE rbu_count(tbl, cnt);
+        INSERT INTO rbu_count VALUES('data0_t1', 1); 
+      } 
+      {3333 6666 10000}
+      {2000 4000 6000 8000 10000}
+
+      3 {
+        CREATE TABLE data0_t1(a, b, c, rbu_control);
+        INSERT INTO data0_t1 VALUES(7, 7, 7, 2);
+        INSERT INTO data0_t1 VALUES(10, 10, 10, 2);
+        CREATE TABLE rbu_count(tbl, cnt);
+        INSERT INTO rbu_count VALUES('data0_t1', 2); 
+      } 
+      {2500 4000 6000 8000 10000}
+      {1666 2500 3750 5000 6250 7500 8750 10000}
+
+    } {
+
+      reset_db ; execsql $tbl
+      do_test 4.$tn.$bReopen.$tn2.0 {
+        execsql {
+          CREATE INDEX t1c ON t1(c);
+          INSERT INTO t1 VALUES(1, 1, 1);
+          INSERT INTO t1 VALUES(5, 5, 5);
+          INSERT INTO t1 VALUES(10, 10, 10);
+        }
+        create_db_file rbu.db $rbusql
+      } {}
+
+      set R(ipk) $r1
+      set R(wr) $r1
+      set R(pk) $r3
+      do_sp_test 4.$tn.$bReopen.$tn2.1 $bReopen test.db rbu.db $R($tn)
+    }
+  }
+}
+
+foreach {bReopen} { 0 1 } {
+  foreach {tn tbl} {
+    nopk { 
+      CREATE TABLE t1(a, b, c);
+      CREATE INDEX t1c ON t1(c);
+    }
+    vtab { 
+      CREATE VIRTUAL TABLE t1 USING fts5(a, b, c);
+    }
+  } {
+
+    foreach {tn2 rbusql r1 r2} {
+      1 {
+        CREATE TABLE data0_t1(a, b, c, rbu_rowid, rbu_control);
+        INSERT INTO data0_t1 VALUES(15, 15, 15, 4, 0);
+        INSERT INTO data0_t1 VALUES(20, 20, 20, 5, 0);
+        CREATE TABLE rbu_count(tbl, cnt);
+        INSERT INTO rbu_count VALUES('data0_t1', 2); 
+      } 
+      {2500 5000 7500 10000}
+      {5000 10000}
+
+      2 {
+        CREATE TABLE data0_t1(rbu_rowid, a, b, c, rbu_control);
+        INSERT INTO data0_t1 VALUES(0, 7, 7, 7, 2);
+        INSERT INTO data0_t1 VALUES(2, 10, 10, 10, 2);
+        CREATE TABLE rbu_count(tbl, cnt);
+        INSERT INTO rbu_count VALUES('data0_t1', 2); 
+      } 
+      {2500 4000 6000 8000 10000}
+      {5000 10000}
+    } {
+
+      reset_db ; execsql $tbl
+      do_test 5.$tn.$bReopen.$tn2.0 {
+        execsql {
+          INSERT INTO t1 VALUES(1, 1, 1);
+          INSERT INTO t1 VALUES(5, 5, 5);
+          INSERT INTO t1 VALUES(10, 10, 10);
+        }
+        create_db_file rbu.db $rbusql
+      } {}
+
+      set R(nopk) $r1
+      set R(vtab) $r2
+      do_sp_test 5.$tn.$bReopen.$tn2.1 $bReopen test.db rbu.db $R($tn)
+    }
+  }
+}
+
+
 finish_test
 
index ab7b983eadd1c5f84a6aa836bb354c270ca08daa..b587d2bb203b3fd2dcac9b4d65c9f6dcdfe1279f 100644 (file)
@@ -1202,6 +1202,11 @@ static void rbuObjIterCacheIndexedCols(sqlite3rbu *p, RbuObjIter *pIter){
     pIter->nIndex++;
   }
 
+  if( pIter->eType==RBU_PK_WITHOUT_ROWID ){
+    /* "PRAGMA index_list" includes the main PK b-tree */
+    pIter->nIndex--;
+  }
+
   rbuFinalize(p, pList);
   if( bIndex==0 ) pIter->abIndexed = 0;
 }
@@ -1313,6 +1318,7 @@ static int rbuObjIterCacheTableInfo(sqlite3rbu *p, RbuObjIter *pIter){
     rbuFinalize(p, pStmt);
     rbuObjIterCacheIndexedCols(p, pIter);
     assert( pIter->eType!=RBU_PK_VTAB || pIter->abIndexed==0 );
+    assert( pIter->eType!=RBU_PK_VTAB || pIter->nIndex==0 );
   }
 
   return p->rc;
@@ -3122,14 +3128,15 @@ static void rbuIndexCntFunc(
   assert( nVal==1 );
   
   rc = prepareFreeAndCollectError(p->dbMain, &pStmt, &zErrmsg, 
-      sqlite3_mprintf("PRAGMA index_list = %Q", sqlite3_value_text(apVal[0]))
+      sqlite3_mprintf("SELECT count(*) FROM sqlite_master "
+        "WHERE type='index' AND tbl_name = %Q", sqlite3_value_text(apVal[0]))
   );
   if( rc!=SQLITE_OK ){
     sqlite3_result_error(pCtx, zErrmsg, -1);
   }else{
     int nIndex = 0;
-    while( SQLITE_ROW==sqlite3_step(pStmt) ){
-      nIndex++;
+    if( SQLITE_ROW==sqlite3_step(pStmt) ){
+      nIndex = sqlite3_column_int(pStmt, 0);
     }
     rc = sqlite3_finalize(pStmt);
     if( rc==SQLITE_OK ){
index 106d447afa226960dc9c1fdbe38e8473d0fcee09..ec9f64957f5971fbe684c837ac7a17aeb840b3cf 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Change\sthe\sname\sof\sthe\snew\sAPI\son\sthis\sbranch\sto\s"sqlite3_bp_progress".\sAdd\stests\sand\sdocumentation\sfor\sthe\ssame.
-D 2016-03-18T18:56:45.343
+C Add\sfurther\stests\sfor\ssqlite3rbu_bp_progress().\sFix\sa\sproblem\sin\shandling\sWITHOUT\sROWID\stables\sin\sthe\ssame.
+D 2016-03-18T20:12:28.661
 F Makefile.in f53429fb2f313c099283659d0df6f20f932c861f
 F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
 F Makefile.msc df0bf9ff7f8b3f4dd9fb4cc43f92fe58f6ec5c66
@@ -242,9 +242,9 @@ F ext/rbu/rbudiff.test 6cc806dc36389292f2a8f5842d0103721df4a07d
 F ext/rbu/rbufault.test cc0be8d5d392d98b0c2d6a51be377ea989250a89
 F ext/rbu/rbufault2.test 9a7f19edd6ea35c4c9f807d8a3db0a03a5670c06
 F ext/rbu/rbufts.test 828cd689da825f0a7b7c53ffc1f6f7fdb6fa5bda
-F ext/rbu/rbuprogress.test 77fe3cd10d3c408bef364bc2e529310495ddd07e
+F ext/rbu/rbuprogress.test 9d2dfd82fc001f26997e36db256df31f2e19e133
 F ext/rbu/rbusave.test 0f43b6686084f426ddd040b878426452fd2c2f48
-F ext/rbu/sqlite3rbu.c 6b7dc899b3980d4236bffa5048218f8dba85ac0a
+F ext/rbu/sqlite3rbu.c edeb8f90a1bccc567438036e083123cec1403091
 F ext/rbu/sqlite3rbu.h d7cc99350c10134f358fe1a8997d9225b3f712b2
 F ext/rbu/test_rbu.c 3505641a78b723589b8780d5f9b2faeeb73e037d
 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761
@@ -1457,7 +1457,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
 F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
 F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
-P bf82321724d3b0feb51e26d9b76090e03cc3964a
-R 14faa32cca0db38c921d7bc3da7dea4c
+P 1a1b69e87eb7d18f76f5b733e44da75136a686b6
+R 4f2c92bc8e3f772f06e8b5d5663259fa
 U dan
-Z 40a2b2dbafc34d98f3493240ec44ac36
+Z bf41c4bf32ca5beb18733d3a05925431
index d6c18684be5315618a1e79d9e06470e910ae256f..5b3c08d36326fa7f076ea6105066a7a240a3eeae 100644 (file)
@@ -1 +1 @@
-1a1b69e87eb7d18f76f5b733e44da75136a686b6
\ No newline at end of file
+65e02368e2b6cec349ea71af5a456d6783b0d15e
\ No newline at end of file