Ensure that compatible malloc and free functions are used with stat3 data if SQLITE_ENABLE_STAT3 is defined.

FossilOrigin-Name: 32bb1ecee4e43a4683512dbca047abf735afd313
This commit is contained in:
dan 2012-03-19 10:21:37 +00:00
parent db0ad5f204
commit 0d1614c731
3 changed files with 13 additions and 9 deletions

View File

@ -1,5 +1,5 @@
C In\spager1.test,\suse\s"file\sattr\stest.db\s-readonly\s0"\sbefore\s"file\sattr\stest.db\s-perm\srw-rw-rw-",\snot\safter.
D 2012-03-17T15:12:16.594
C Ensure\sthat\scompatible\smalloc\sand\sfree\sfunctions\sare\sused\swith\sstat3\sdata\sif\sSQLITE_ENABLE_STAT3\sis\sdefined.
D 2012-03-19T10:21:37.927
F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f
F Makefile.in 2f37e468503dbe79d35c9f6dffcf3fae1ae9ec20
F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23
@ -119,7 +119,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b
F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc
F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad
F src/alter.c 149cc80d9257971b0bff34e58fb2263e01998289
F src/analyze.c f32ff304da413851eefa562b04e61ff6cb88248b
F src/analyze.c 70c46504c0d2543ea5cdca01140b2cd3e1d886e7
F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f
F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34
F src/backup.c 6be23a344d3301ae38e92fddb3a33b91c309fce4
@ -992,7 +992,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06
F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f
F tool/warnings-clang.sh 9f406d66e750e8ac031c63a9ef3248aaa347ef2a
F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381
P affaebde109e8dd851474ffe7b7d48b1aae8c7ed
R c4a04a92e8486010645a44f1a08a5af3
P 4f5283f18f570a09b95c26e5aa14885ada518dd2
R 86b82af92d1239c76d6157fdd039db02
U dan
Z 7e2f94cd0ef8dfee62915c8ab2714a0c
Z fc0fdf7e77db24e47eb9fd009ed1d240

View File

@ -1 +1 @@
4f5283f18f570a09b95c26e5aa14885ada518dd2
32bb1ecee4e43a4683512dbca047abf735afd313

View File

@ -932,6 +932,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){
int eType; /* Datatype of a sample */
IndexSample *pSample; /* A slot in pIdx->aSample[] */
assert( db->lookaside.bEnabled==0 );
if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){
return SQLITE_OK;
}
@ -958,7 +959,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){
if( pIdx==0 ) continue;
assert( pIdx->nSample==0 );
pIdx->nSample = nSample;
pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) );
pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample));
pIdx->avgEq = pIdx->aiRowEst[1];
if( pIdx->aSample==0 ){
db->mallocFailed = 1;
@ -1031,7 +1032,7 @@ static int loadStat3(sqlite3 *db, const char *zDb){
if( n < 1){
pSample->u.z = 0;
}else{
pSample->u.z = sqlite3Malloc(n);
pSample->u.z = sqlite3DbMallocRaw(db, n);
if( pSample->u.z==0 ){
db->mallocFailed = 1;
sqlite3_finalize(pStmt);
@ -1107,7 +1108,10 @@ int sqlite3AnalysisLoad(sqlite3 *db, int iDb){
/* Load the statistics from the sqlite_stat3 table. */
#ifdef SQLITE_ENABLE_STAT3
if( rc==SQLITE_OK ){
int lookasideEnabled = db->lookaside.bEnabled;
db->lookaside.bEnabled = 0;
rc = loadStat3(db, sInfo.zDatabase);
db->lookaside.bEnabled = lookasideEnabled;
}
#endif