]> git.ipfire.org Git - thirdparty/sqlite.git/commitdiff
Simplification to the random rowid picking logic that begins running when
authordrh <drh@noemail.net>
Thu, 25 Sep 2014 12:31:28 +0000 (12:31 +0000)
committerdrh <drh@noemail.net>
Thu, 25 Sep 2014 12:31:28 +0000 (12:31 +0000)
the maximum possible rowid has already been used.

FossilOrigin-Name: 1330c72e172324c68ab49e5bb2ceba985935ae01

manifest
manifest.uuid
src/vdbe.c
test/rowid.test

index fb9c0ed0106304b1f8a71fbd70b40b97b4c70cff..658142eff59ff4fc5deba857bc2d97d311145459 100644 (file)
--- a/manifest
+++ b/manifest
@@ -1,5 +1,5 @@
-C Still\smore\sperformance\senhancements\sto\sthe\sLIKE\sand\sGLOB\soperators.
-D 2014-09-25T11:08:57.081
+C Simplification\sto\sthe\srandom\srowid\spicking\slogic\sthat\sbegins\srunning\swhen\nthe\smaximum\spossible\srowid\shas\salready\sbeen\sused.
+D 2014-09-25T12:31:28.476
 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
 F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -289,7 +289,7 @@ F src/update.c 729f6f18fc27740591d085e1172cebe311144bf0
 F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
 F src/util.c 4006c01772bd8d8ac4306d523bbcee41d3e392d8
 F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a
-F src/vdbe.c 23db9b11f0d0a022c42bf71c2b036d32c82a9abd
+F src/vdbe.c 9fe630d05840aa151a5ba9039901478d9524120b
 F src/vdbe.h 09f5b4e3719fa454f252322b1cdab5cf1f361327
 F src/vdbeInt.h f177bed1ec8d4eb5c7089f012aeb95f374745735
 F src/vdbeapi.c e9e33b59834e3edc8790209765e069874c269d9d
@@ -784,7 +784,7 @@ F test/releasetest.tcl a0df0dfc5e3ee83ade87b9cc96db41b52d590b9e
 F test/resolver01.test 33abf37ff8335e6bf98f2b45a0af3e06996ccd9a
 F test/rollback.test e9504a009a202c3ed711da2e6879ff60c5a4669c
 F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
-F test/rowid.test b78b30afb9537a73788ca1233a23a32190a3bb1f
+F test/rowid.test 9ffee168c4be901820bf5cf5fcbb2105117d0d45
 F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798
 F test/run-wordcount.sh 891e89c4c2d16e629cd45951d4ed899ad12afc09
 F test/savepoint.test 51d3900dc071a7c2ad4248578a5925631b476313
@@ -1200,7 +1200,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
 F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
-P 5ab1023d6cfe31fa8a194804b8216058977ac973
-R 3c45ffccf6b8b9761c0cc8bd190b6e11
+P 6c8924cacc2b875270770fed2cc3b1884f57a655
+R c9d002c28940b83ace850b74161b9f39
 U drh
-Z 88a762d5e9ae73a0ed674e2385a2b544
+Z a6a7b4b719a1f0df211ae0686c0976a9
index 9939e8087e66d7560b1b4b59f1de67297bab235e..5e3b55899b77cc5f7e5434d6a07a3201e34ce44e 100644 (file)
@@ -1 +1 @@
-6c8924cacc2b875270770fed2cc3b1884f57a655
\ No newline at end of file
+1330c72e172324c68ab49e5bb2ceba985935ae01
\ No newline at end of file
index 4c2b75f641529fda454c73d713caa983486e2164..27d7e749011e4d1da28aa5447cf70fe662643e96 100644 (file)
@@ -4020,25 +4020,15 @@ case OP_NewRowid: {           /* out2-prerelease */
       ** it finds one that is not previously used. */
       assert( pOp->p3==0 );  /* We cannot be in random rowid mode if this is
                              ** an AUTOINCREMENT table. */
-      /* on the first attempt, simply do one more than previous */
-      v = lastRowid;
-      v &= (MAX_ROWID>>1); /* ensure doesn't go negative */
-      v++; /* ensure non-zero */
       cnt = 0;
-      while(   ((rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, 0, (u64)v,
+      do{
+        sqlite3_randomness(sizeof(v), &v);
+        v &= (MAX_ROWID>>1);
+        v++;
+      }while(  ((rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, 0, (u64)v,
                                                  0, &res))==SQLITE_OK)
             && (res==0)
-            && (++cnt<100)){
-        /* collision - try another random rowid */
-        sqlite3_randomness(sizeof(v), &v);
-        if( cnt<5 ){
-          /* try "small" random rowids for the initial attempts */
-          v &= 0xffffff;
-        }else{
-          v &= (MAX_ROWID>>1); /* ensure doesn't go negative */
-        }
-        v++; /* ensure non-zero */
-      }
+            && (++cnt<100));
       if( rc==SQLITE_OK && res==0 ){
         rc = SQLITE_FULL;   /* IMP: R-38219-53002 */
         goto abort_due_to_error;
index 6d068d79bb5c946aaf04d99808eb31a431933068..d232139ea09ff913e8cb87e62475acc0791ef419 100644 (file)
@@ -679,9 +679,9 @@ do_test rowid-12.2 {
   save_prng_state
   execsql {
     INSERT INTO t7 VALUES(NULL,'b');
-    SELECT x, y FROM t7;
+    SELECT x, y FROM t7 ORDER BY x;
   }
-} {1 b 9223372036854775807 a}
+} {/\d+ b 9223372036854775807 a/}
 execsql {INSERT INTO t7 VALUES(2,'y');}
 for {set i 1} {$i<100} {incr i} {
   do_test rowid-12.3.$i {