]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Add the --verify option to speedtest1. Add verification test cases to
authordrh <drh@noemail.net>
Fri, 11 Apr 2014 17:41:08 +0000 (17:41 +0000)
committerdrh <drh@noemail.net>
Fri, 11 Apr 2014 17:41:08 +0000 (17:41 +0000)
the "rtree" testset and a case that uses a custom geometry callback.

FossilOrigin-Name: 9d485c4207a81f32334857d4a608c5c511dd2b83

manifest
manifest.uuid
test/speedtest1.c

index 1a7e491bc34b559f89f4f61e12352cc420158bab..12cad8c970d17c5df7abb1c5440739f44fcced58 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Update\scomments\sin\sthe\sR-Tree\smodule\sin\spreparation\sfor\ssome\sbig\schanges.\nAdd\san\s"rtree"\sperformance\stest\sto\sspeedtest1.
-D 2014-04-11T16:14:54.092
+C Add\sthe\s--verify\soption\sto\sspeedtest1.\s\sAdd\sverification\stest\scases\sto\nthe\s"rtree"\stestset\sand\sa\scase\sthat\suses\sa\scustom\sgeometry\scallback.
+D 2014-04-11T17:41:08.614
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in e4ee6d36cdf6136aee0158675a3b24dd3bf31a5a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -840,7 +840,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523
 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715
 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa
 F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b
-F test/speedtest1.c 3e06b48e8c578eaa61a01e8c7c4d8734c9dd3776
+F test/speedtest1.c 017473605f9df5f4770dd60ddb4038e6d6829916
 F test/spellfix.test 61309f5efbec53603b3f86457d34a504f80abafe
 F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298
 F test/stat.test 76fd746b85459e812a0193410fb599f0531f22de
@@ -1174,10 +1174,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01
 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff
-P 9515c8344a6743bbb0c6a6e49fb79fb3139090df
-R 57f2249bba89c44cd5839664eafe6658
-T *branch * rtree-enhancements
-T *sym-rtree-enhancements *
-T -sym-sessions *
+P 20a73ec0b2f56609a4504052e198e32803d30207
+R 47999e8bbddb67bbaef79a4f5741e58b
 U drh
-Z bdd5cbefa0a4dcc9a9cc6ed610b85f71
+Z 73dffdddfd99e7f86f5cf9f646a8ff0c
index d8135897dd1029a63ad8b27483533ec2dea68748..0d054cdd301865c810b1934ca5bfb75a510c1663 100644 (file)
@@ -1 +1 @@
-20a73ec0b2f56609a4504052e198e32803d30207
\ No newline at end of file
+9d485c4207a81f32334857d4a608c5c511dd2b83
\ No newline at end of file
index a32f12f92349ba5d4c509e632b13c9b46ad3bae6..0680e9599f55d24ca04bfa64b7a5a4e5fa19ad2a 100644 (file)
@@ -29,6 +29,7 @@ static const char zHelp[] =
   "  --trace             Turn on SQL tracing\n"
   "  --utf16be           Set text encoding to UTF-16BE\n"
   "  --utf16le           Set text encoding to UTF-16LE\n"
+  "  --verify            Run additional verification steps.\n"
   "  --without-rowid     Use WITHOUT ROWID where appropriate\n"
 ;
 
@@ -51,6 +52,7 @@ static struct Global {
   int bReprepare;            /* True to reprepare the SQL on each rerun */
   int bSqlOnly;              /* True to print the SQL once only */
   int bExplain;              /* Print SQL with EXPLAIN prefix */
+  int bVerify;               /* Try to verify that results are correct */
   int szTest;                /* Scale factor for test iterations */
   const char *zWR;           /* Might be WITHOUT ROWID */
   const char *zNN;           /* Might be NOT NULL */
@@ -951,6 +953,26 @@ static void twoCoords(
   *pX1 = x1;
 }
 
+/* The following routine is an R-Tree geometry callback.  It returns
+** true if the object overlaps a slice on the Y coordinate between the
+** two values given as arguments.  In other words
+**
+**     SELECT count(*) FROM rt1 WHERE id MATCH xslice(10,20);
+**
+** Is the same as saying:
+**
+**     SELECT count(*) FROM rt1 WHERE y1>=10 AND y0<=20;
+*/
+static int xsliceGeometryCallback(
+  sqlite3_rtree_geometry *p,
+  int nCoord,
+  double *aCoord,
+  int *pRes
+){
+  *pRes = aCoord[3]>=p->aParam[0] && aCoord[2]<=p->aParam[1];
+  return SQLITE_OK;
+}
+
 /*
 ** A testset for the R-Tree virtual table
 */
@@ -958,6 +980,8 @@ void testset_rtree(void){
   unsigned i, n;
   unsigned mxCoord;
   unsigned x0, x1, y0, y1, z0, z1;
+  unsigned iStep;
+  int *aCheck = sqlite3_malloc( sizeof(int)*g.szTest*100 );
 
   mxCoord = g.szTest*600;
   n = g.szTest*100;
@@ -982,23 +1006,83 @@ void testset_rtree(void){
   speedtest1_exec("COMMIT");
   speedtest1_end_test();
 
+  speedtest1_begin_test(101, "Copy from rtree to a regular table");
+  speedtest1_exec("CREATE TABLE t1(id INTEGER PRIMARY KEY,x0,x1,y0,y1,z0,z1)");
+  speedtest1_exec("INSERT INTO t1 SELECT * FROM rt1");
+  speedtest1_end_test();
+
   n = g.szTest*20;
   speedtest1_begin_test(110, "%d one-dimensional intersect slice queries", n);
   speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x0>=?1 AND x1<=?2");
-  for(i=0; i<mxCoord; i+=(mxCoord/n)){
-    sqlite3_bind_int(g.pStmt, 1, i);
-    sqlite3_bind_int(g.pStmt, 2, i+mxCoord/n);
+  iStep = mxCoord/n;
+  for(i=0; i<n; i++){
+    sqlite3_bind_int(g.pStmt, 1, i*iStep);
+    sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
     speedtest1_run();
+    aCheck[i] = atoi(g.zResult);
   }
   speedtest1_end_test();
 
+  if( g.bVerify ){
+    n = g.szTest*20;
+    speedtest1_begin_test(111, "Verify result from 1-D intersect slice queries");
+    speedtest1_prepare("SELECT count(*) FROM t1 WHERE x0>=?1 AND x1<=?2");
+    iStep = mxCoord/n;
+    for(i=0; i<n; i++){
+      sqlite3_bind_int(g.pStmt, 1, i*iStep);
+      sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+      speedtest1_run();
+      if( aCheck[i]!=atoi(g.zResult) ){
+        fatal_error("Count disagree step %d: %d..%d.  %d vs %d",
+                    i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));
+      }
+    }
+    speedtest1_end_test();
+  }
+  
   n = g.szTest*20;
   speedtest1_begin_test(120, "%d one-dimensional overlap slice queries", n);
   speedtest1_prepare("SELECT count(*) FROM rt1 WHERE y1>=?1 AND y0<=?2");
-  for(i=0; i<mxCoord; i+=(mxCoord/n)){
-    sqlite3_bind_int(g.pStmt, 1, i);
-    sqlite3_bind_int(g.pStmt, 2, i+mxCoord/n);
+  iStep = mxCoord/n;
+  for(i=0; i<n; i++){
+    sqlite3_bind_int(g.pStmt, 1, i*iStep);
+    sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
     speedtest1_run();
+    aCheck[i] = atoi(g.zResult);
+  }
+  speedtest1_end_test();
+
+  if( g.bVerify ){
+    n = g.szTest*20;
+    speedtest1_begin_test(121, "Verify result from 1-D overlap slice queries");
+    speedtest1_prepare("SELECT count(*) FROM t1 WHERE y1>=?1 AND y0<=?2");
+    iStep = mxCoord/n;
+    for(i=0; i<n; i++){
+      sqlite3_bind_int(g.pStmt, 1, i*iStep);
+      sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+      speedtest1_run();
+      if( aCheck[i]!=atoi(g.zResult) ){
+        fatal_error("Count disagree step %d: %d..%d.  %d vs %d",
+                    i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));
+      }
+    }
+    speedtest1_end_test();
+  }
+  
+
+  n = g.szTest*20;
+  speedtest1_begin_test(125, "%d custom geometry callback queries", n);
+  sqlite3_rtree_geometry_callback(g.db, "xslice", xsliceGeometryCallback, 0);
+  speedtest1_prepare("SELECT count(*) FROM rt1 WHERE id MATCH xslice(?1,?2)");
+  iStep = mxCoord/n;
+  for(i=0; i<n; i++){
+    sqlite3_bind_int(g.pStmt, 1, i*iStep);
+    sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
+    speedtest1_run();
+    if( aCheck[i]!=atoi(g.zResult) ){
+      fatal_error("Count disagree step %d: %d..%d.  %d vs %d",
+                  i, i*iStep, (i+1)*iStep, aCheck[i], atoi(g.zResult));
+    }
   }
   speedtest1_end_test();
 
@@ -1006,10 +1090,12 @@ void testset_rtree(void){
   speedtest1_begin_test(130, "%d three-dimensional intersect box queries", n);
   speedtest1_prepare("SELECT count(*) FROM rt1 WHERE x1>=?1 AND x0<=?2"
                      " AND y1>=?1 AND y0<=?2 AND z1>=?1 AND z0<=?2");
-  for(i=0; i<mxCoord; i+=(mxCoord/n)){
-    sqlite3_bind_int(g.pStmt, 1, i);
-    sqlite3_bind_int(g.pStmt, 2, i+mxCoord/n);
+  iStep = mxCoord/n;
+  for(i=0; i<n; i++){
+    sqlite3_bind_int(g.pStmt, 1, i*iStep);
+    sqlite3_bind_int(g.pStmt, 2, (i+1)*iStep);
     speedtest1_run();
+    aCheck[i] = atoi(g.zResult);
   }
   speedtest1_end_test();
 
@@ -1142,6 +1228,8 @@ int main(int argc, char **argv){
         zEncoding = "utf16le";
       }else if( strcmp(z,"utf16be")==0 ){
         zEncoding = "utf16be";
+      }else if( strcmp(z,"verify")==0 ){
+        g.bVerify = 1;
       }else if( strcmp(z,"without-rowid")==0 ){
         g.zWR = "WITHOUT ROWID";
         g.zPK = "PRIMARY KEY";