Omit the maximum loop count on the random name chooser in the VACUUM command.
Add a comment to explain why this is safe and does not result in an infinite loop. Ticket #1009. (CVS 2122) FossilOrigin-Name: 1241086f23a2ef7aef85139817f0c1b90140481d
This commit is contained in:
parent
4693423b09
commit
6c90fecc96
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Rig\sthe\ssqliteMalloc()\sroutine\sso\sthat\swe\scan\smake\sit\sfail\smultiple\stimes\nin\sa\srow.\s\sModify\sthe\smalloc.test\sprocedure\sto\smake\smalloc\sfail\sin\sthis\nway\sand\sverify\sthat\sthe\sfailures\sare\sstill\shandled\scorrectly.\s(CVS\s2121)
|
||||
D 2004-11-20T19:18:01
|
||||
C Omit\sthe\smaximum\sloop\scount\son\sthe\srandom\sname\schooser\sin\sthe\sVACUUM\scommand.\nAdd\sa\scomment\sto\sexplain\swhy\sthis\sis\ssafe\sand\sdoes\snot\sresult\sin\san\ninfinite\sloop.\s\sTicket\s#1009.\s(CVS\s2122)
|
||||
D 2004-11-20T19:18:56
|
||||
F Makefile.in e747bb5ba34ccbdd81f79dcf1b2b33c02817c21d
|
||||
F Makefile.linux-gcc a9e5a0d309fa7c38e7c14d3ecf7690879d3a5457
|
||||
F README a01693e454a00cc117967e3f9fdab2d4d52e9bc1
|
||||
@ -74,7 +74,7 @@ F src/trigger.c 0c91b56182560263733e4b035acdb939bd1cf0e2
|
||||
F src/update.c 395a2b270dfcbc96c20e40c9cb42b0533768ce30
|
||||
F src/utf.c e45ce11be6922408cd381561721f6cca7d3b992a
|
||||
F src/util.c 4a8db4e97a3cfda12ad8dda3e77dd2d00ad1de5e
|
||||
F src/vacuum.c ecb4a2c6f1ac5cc9b394dc64d3bb14ca650c4f60
|
||||
F src/vacuum.c d061dd908a9e809c54e40e24a551b1d64abd3d16
|
||||
F src/vdbe.c ba3a920731d43bcf2497d558238400369008531a
|
||||
F src/vdbe.h 067ca8d6750ba4f69a50284765e5883dee860181
|
||||
F src/vdbeInt.h 6017100adff362b8dfa37a69e3f1431f084bfa5b
|
||||
@ -260,7 +260,7 @@ F www/tclsqlite.tcl 560ecd6a916b320e59f2917317398f3d59b7cc25
|
||||
F www/vdbe.tcl 095f106d93875c94b47367384ebc870517431618
|
||||
F www/version3.tcl 092a01f5ef430d2c4acc0ae558d74c4bb89638a0
|
||||
F www/whentouse.tcl fdacb0ba2d39831e8a6240d05a490026ad4c4e4c
|
||||
P 368774487e7a0266465f5a1c2701c9b14573d26c
|
||||
R 2d696b4b112d3e16cd5eeec0f1da51b4
|
||||
P 519bc9d9975bbdb4ba056799534d5c465e0cd042
|
||||
R 91deb97845899511a506d4ec5150a23d
|
||||
U drh
|
||||
Z f7c4d9f04ce181b804404f872e7ac015
|
||||
Z a06d6e8301753205b533356bff385276
|
||||
|
@ -1 +1 @@
|
||||
519bc9d9975bbdb4ba056799534d5c465e0cd042
|
||||
1241086f23a2ef7aef85139817f0c1b90140481d
|
15
src/vacuum.c
15
src/vacuum.c
@ -14,7 +14,7 @@
|
||||
** Most of the code in this file may be omitted by defining the
|
||||
** SQLITE_OMIT_VACUUM macro.
|
||||
**
|
||||
** $Id: vacuum.c,v 1.33 2004/10/30 20:23:09 drh Exp $
|
||||
** $Id: vacuum.c,v 1.34 2004/11/20 19:18:56 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@ -97,7 +97,6 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
|
||||
const char *zFilename; /* full pathname of the database file */
|
||||
int nFilename; /* number of characters in zFilename[] */
|
||||
char *zTemp = 0; /* a temporary file in same directory as zFilename */
|
||||
int i; /* Loop counter */
|
||||
Btree *pMain; /* The database being vacuumed */
|
||||
Btree *pTemp;
|
||||
char *zSql = 0;
|
||||
@ -129,11 +128,19 @@ int sqlite3RunVacuum(char **pzErrMsg, sqlite3 *db){
|
||||
goto end_of_vacuum;
|
||||
}
|
||||
strcpy(zTemp, zFilename);
|
||||
i = 0;
|
||||
|
||||
/* The randomName() procedure in the following loop uses an excellent
|
||||
** source of randomness to generate a name from a space of 1.3e+31
|
||||
** possibilities. So unless the directory already contains on the order
|
||||
** of 1.3e+31 files, the probability that the following loop will
|
||||
** run more than once or twice is vanishingly small. We are certain
|
||||
** enough that this loop will always terminate (and terminate quickly)
|
||||
** that we don't even bother to set a maximum loop count.
|
||||
*/
|
||||
do {
|
||||
zTemp[nFilename] = '-';
|
||||
randomName((unsigned char*)&zTemp[nFilename+1]);
|
||||
} while( i<10 && sqlite3OsFileExists(zTemp) );
|
||||
} while( sqlite3OsFileExists(zTemp) );
|
||||
|
||||
/* Attach the temporary database as 'vacuum_db'. The synchronous pragma
|
||||
** can be set to 'off' for this file, as it is not recovered if a crash
|
||||
|
Loading…
Reference in New Issue
Block a user