diff options
author | drh <drh@noemail.net> | 2016-03-16 01:16:30 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2016-03-16 01:16:30 +0000 |
commit | 47e1842e5bd5c5f467b0290f3fde9df69fa42a25 (patch) | |
tree | 69786029a35258e2ee2a76f5d023764e19a074f0 /src/pragma.c | |
parent | c5c67abb9ab2c58d41f75a41a1693e4b30e00bd5 (diff) | |
parent | 32f57d4c373c8f49b59f4a40149c136ef8a5632b (diff) | |
download | sqlite-47e1842e5bd5c5f467b0290f3fde9df69fa42a25.tar.gz sqlite-47e1842e5bd5c5f467b0290f3fde9df69fa42a25.zip |
Merge all recent enhancements from trunk.
FossilOrigin-Name: 6a7ee04b0ddac36a87d5ed2ac89a53e537f4d5a3
Diffstat (limited to 'src/pragma.c')
-rw-r--r-- | src/pragma.c | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/src/pragma.c b/src/pragma.c index 1d6291431..70c2950c8 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -993,6 +993,7 @@ void sqlite3Pragma( int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK; if( iLevel==0 ) iLevel = 1; pDb->safety_level = iLevel; + pDb->bSyncSet = 1; setAllPagerFlags(db); } } @@ -1438,6 +1439,7 @@ void sqlite3Pragma( for(i=0; i<db->nDb; i++){ HashElem *x; Hash *pTbls; + int *aRoot; int cnt = 0; if( OMIT_TEMPDB && i==1 ) continue; @@ -1451,31 +1453,34 @@ void sqlite3Pragma( /* Do an integrity check of the B-Tree ** - ** Begin by filling registers 2, 3, ... with the root pages numbers + ** Begin by finding the root pages numbers ** for all tables and indices in the database. */ assert( sqlite3SchemaMutexHeld(db, i, 0) ); pTbls = &db->aDb[i].pSchema->tblHash; - for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ + for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ Table *pTab = sqliteHashData(x); Index *pIdx; - if( HasRowid(pTab) ){ - sqlite3VdbeAddOp2(v, OP_Integer, pTab->tnum, 2+cnt); - VdbeComment((v, "%s", pTab->zName)); - cnt++; - } + if( HasRowid(pTab) ) cnt++; + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ cnt++; } + } + aRoot = sqlite3DbMallocRawNN(db, sizeof(int)*(cnt+1)); + if( aRoot==0 ) break; + for(cnt=0, x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ + Table *pTab = sqliteHashData(x); + Index *pIdx; + if( HasRowid(pTab) ) aRoot[cnt++] = pTab->tnum; for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ - sqlite3VdbeAddOp2(v, OP_Integer, pIdx->tnum, 2+cnt); - VdbeComment((v, "%s", pIdx->zName)); - cnt++; + aRoot[cnt++] = pIdx->tnum; } } + aRoot[cnt] = 0; /* Make sure sufficient number of registers have been allocated */ - pParse->nMem = MAX( pParse->nMem, cnt+8 ); + pParse->nMem = MAX( pParse->nMem, 14 ); /* Do the b-tree integrity checks */ - sqlite3VdbeAddOp3(v, OP_IntegrityCk, 2, cnt, 1); + sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY); sqlite3VdbeChangeP5(v, (u8)i); addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v); sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0, |