1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-08 14:02:16 +03:00

Simplification to the random rowid picking logic that begins running when

the maximum possible rowid has already been used.

FossilOrigin-Name: 1330c72e172324c68ab49e5bb2ceba985935ae01
This commit is contained in:
drh
2014-09-25 12:31:28 +00:00
parent 9fdfdc893b
commit 2c4dc635a1
4 changed files with 16 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
C Still\smore\sperformance\senhancements\sto\sthe\sLIKE\sand\sGLOB\soperators. C Simplification\sto\sthe\srandom\srowid\spicking\slogic\sthat\sbegins\srunning\swhen\nthe\smaximum\spossible\srowid\shas\salready\sbeen\sused.
D 2014-09-25T11:08:57.081 D 2014-09-25T12:31:28.476
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a F Makefile.in cf57f673d77606ab0f2d9627ca52a9ba1464146a
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@@ -289,7 +289,7 @@ F src/update.c 729f6f18fc27740591d085e1172cebe311144bf0
F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c F src/utf.c fc6b889ba0779b7722634cdeaa25f1930d93820c
F src/util.c 4006c01772bd8d8ac4306d523bbcee41d3e392d8 F src/util.c 4006c01772bd8d8ac4306d523bbcee41d3e392d8
F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a F src/vacuum.c 59f03f92bcff57faa6a8ca256eb29ccddfb0614a
F src/vdbe.c 23db9b11f0d0a022c42bf71c2b036d32c82a9abd F src/vdbe.c 9fe630d05840aa151a5ba9039901478d9524120b
F src/vdbe.h 09f5b4e3719fa454f252322b1cdab5cf1f361327 F src/vdbe.h 09f5b4e3719fa454f252322b1cdab5cf1f361327
F src/vdbeInt.h f177bed1ec8d4eb5c7089f012aeb95f374745735 F src/vdbeInt.h f177bed1ec8d4eb5c7089f012aeb95f374745735
F src/vdbeapi.c e9e33b59834e3edc8790209765e069874c269d9d F src/vdbeapi.c e9e33b59834e3edc8790209765e069874c269d9d
@@ -784,7 +784,7 @@ F test/releasetest.tcl a0df0dfc5e3ee83ade87b9cc96db41b52d590b9e
F test/resolver01.test 33abf37ff8335e6bf98f2b45a0af3e06996ccd9a F test/resolver01.test 33abf37ff8335e6bf98f2b45a0af3e06996ccd9a
F test/rollback.test e9504a009a202c3ed711da2e6879ff60c5a4669c F test/rollback.test e9504a009a202c3ed711da2e6879ff60c5a4669c
F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81
F test/rowid.test b78b30afb9537a73788ca1233a23a32190a3bb1f F test/rowid.test 9ffee168c4be901820bf5cf5fcbb2105117d0d45
F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798 F test/rtree.test 0c8d9dd458d6824e59683c19ab2ffa9ef946f798
F test/run-wordcount.sh 891e89c4c2d16e629cd45951d4ed899ad12afc09 F test/run-wordcount.sh 891e89c4c2d16e629cd45951d4ed899ad12afc09
F test/savepoint.test 51d3900dc071a7c2ad4248578a5925631b476313 F test/savepoint.test 51d3900dc071a7c2ad4248578a5925631b476313
@@ -1200,7 +1200,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1
F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4
F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32 F tool/warnings.sh 0abfd78ceb09b7f7c27c688c8e3fe93268a13b32
F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f F tool/win/sqlite.vsix deb315d026cc8400325c5863eef847784a219a2f
P 5ab1023d6cfe31fa8a194804b8216058977ac973 P 6c8924cacc2b875270770fed2cc3b1884f57a655
R 3c45ffccf6b8b9761c0cc8bd190b6e11 R c9d002c28940b83ace850b74161b9f39
U drh U drh
Z 88a762d5e9ae73a0ed674e2385a2b544 Z a6a7b4b719a1f0df211ae0686c0976a9

View File

@@ -1 +1 @@
6c8924cacc2b875270770fed2cc3b1884f57a655 1330c72e172324c68ab49e5bb2ceba985935ae01

View File

@@ -4020,25 +4020,15 @@ case OP_NewRowid: { /* out2-prerelease */
** it finds one that is not previously used. */ ** it finds one that is not previously used. */
assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is assert( pOp->p3==0 ); /* We cannot be in random rowid mode if this is
** an AUTOINCREMENT table. */ ** 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; 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) 0, &res))==SQLITE_OK)
&& (res==0) && (res==0)
&& (++cnt<100)){ && (++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 */
}
if( rc==SQLITE_OK && res==0 ){ if( rc==SQLITE_OK && res==0 ){
rc = SQLITE_FULL; /* IMP: R-38219-53002 */ rc = SQLITE_FULL; /* IMP: R-38219-53002 */
goto abort_due_to_error; goto abort_due_to_error;

View File

@@ -679,9 +679,9 @@ do_test rowid-12.2 {
save_prng_state save_prng_state
execsql { execsql {
INSERT INTO t7 VALUES(NULL,'b'); 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');} execsql {INSERT INTO t7 VALUES(2,'y');}
for {set i 1} {$i<100} {incr i} { for {set i 1} {$i<100} {incr i} {
do_test rowid-12.3.$i { do_test rowid-12.3.$i {