mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-11 01:42:22 +03:00
Performance improvements (CVS 1379)
FossilOrigin-Name: cad47917267d32ab00c8b949151c8bc3c6638479
This commit is contained in:
15
src/btree.c
15
src/btree.c
@@ -9,7 +9,7 @@
|
||||
** May you share freely, never taking more than you give.
|
||||
**
|
||||
*************************************************************************
|
||||
** $Id: btree.c,v 1.135 2004/05/14 12:17:46 drh Exp $
|
||||
** $Id: btree.c,v 1.136 2004/05/14 15:27:28 drh Exp $
|
||||
**
|
||||
** This file implements a external (disk-based) database using BTrees.
|
||||
** For a detailed discussion of BTrees, refer to
|
||||
@@ -741,18 +741,20 @@ static int initPage(
|
||||
int c, pc, i, hdr;
|
||||
unsigned char *data;
|
||||
int usableSize;
|
||||
int sumCell = 0; /* Total size of all cells */
|
||||
/* int sumCell = 0; // Total size of all cells */
|
||||
|
||||
|
||||
assert( pPage->pBt!=0 );
|
||||
assert( pParent==0 || pParent->pBt==pPage->pBt );
|
||||
assert( pPage->pgno==sqlite3pager_pagenumber(pPage->aData) );
|
||||
assert( pPage->aData == &((unsigned char*)pPage)[-pPage->pBt->pageSize] );
|
||||
assert( pPage->pParent==0 || pPage->pParent==pParent );
|
||||
assert( pPage->pParent==pParent || !pPage->isInit );
|
||||
if( pPage->isInit ) return SQLITE_OK;
|
||||
if( pPage->pParent==0 && pParent!=0 ){
|
||||
pPage->pParent = pParent;
|
||||
sqlite3pager_ref(pParent->aData);
|
||||
}
|
||||
if( pPage->isInit ) return SQLITE_OK;
|
||||
pPage->nCell = pPage->nCellAlloc = 0;
|
||||
assert( pPage->hdrOffset==(pPage->pgno==1 ? 100 : 0) );
|
||||
hdr = pPage->hdrOffset;
|
||||
@@ -782,7 +784,7 @@ static int initPage(
|
||||
pc = get2byte(&data[hdr+3]);
|
||||
for(i=0; pc>0; i++){
|
||||
pPage->aCell[i] = &data[pc];
|
||||
sumCell += cellSize(pPage, &data[pc]);
|
||||
/* sumCell += cellSize(pPage, &data[pc]); */
|
||||
pc = get2byte(&data[pc]);
|
||||
}
|
||||
|
||||
@@ -801,10 +803,11 @@ static int initPage(
|
||||
if( pPage->nFree>=usableSize ) return SQLITE_CORRUPT;
|
||||
|
||||
/* Sanity check: Cells and freespace and header must sum to the size
|
||||
** a page. */
|
||||
** a page.
|
||||
if( sumCell+pPage->nFree+hdr+10-pPage->leaf*4 != usableSize ){
|
||||
return SQLITE_CORRUPT;
|
||||
}
|
||||
*/
|
||||
|
||||
pPage->isInit = 1;
|
||||
pageIntegrity(pPage);
|
||||
@@ -879,7 +882,7 @@ static int getAndInitPage(
|
||||
){
|
||||
int rc;
|
||||
rc = getPage(pBt, pgno, ppPage);
|
||||
if( rc==SQLITE_OK ){
|
||||
if( rc==SQLITE_OK && (*ppPage)->isInit==0 ){
|
||||
rc = initPage(*ppPage, pParent);
|
||||
}
|
||||
return rc;
|
||||
|
||||
12
src/vdbe.c
12
src/vdbe.c
@@ -43,7 +43,7 @@
|
||||
** in this file for details. If in doubt, do not deviate from existing
|
||||
** commenting and indentation practices when changing or adding code.
|
||||
**
|
||||
** $Id: vdbe.c,v 1.290 2004/05/14 12:16:11 danielk1977 Exp $
|
||||
** $Id: vdbe.c,v 1.291 2004/05/14 15:27:29 drh Exp $
|
||||
*/
|
||||
#include "sqliteInt.h"
|
||||
#include "os.h"
|
||||
@@ -2001,7 +2001,7 @@ case OP_Column: {
|
||||
/* This code will run very infrequently (e.g. tables with several
|
||||
** hundred columns).
|
||||
*/
|
||||
zData = (char *)sqliteMalloc(offset+max_space);
|
||||
zData = (char *)sqliteMallocRaw(offset+max_space);
|
||||
if( !zData ){
|
||||
rc = SQLITE_NOMEM;
|
||||
goto abort_due_to_error;
|
||||
@@ -2023,7 +2023,7 @@ case OP_Column: {
|
||||
** the serial types for the record. At the end of this block variable
|
||||
** offset is set to the offset to the start of Data0 in the record.
|
||||
*/
|
||||
aTypes = (u64 *)sqliteMalloc(sizeof(u64)*nFields);
|
||||
aTypes = (u64 *)sqliteMallocRaw(sizeof(u64)*nFields);
|
||||
if( !aTypes ){
|
||||
if( freeZdata ){
|
||||
sqliteFree(zData);
|
||||
@@ -2058,7 +2058,7 @@ case OP_Column: {
|
||||
zData = (char *)sqlite3BtreeDataFetch(pCrsr, offset+len);
|
||||
}
|
||||
if( !zData && len>0 ){
|
||||
zData = (char *)sqliteMalloc(len);
|
||||
zData = (char *)sqliteMallocRaw(len);
|
||||
if( !zData ){
|
||||
sqliteFree(aTypes);
|
||||
rc = SQLITE_NOMEM;
|
||||
@@ -2164,7 +2164,7 @@ case OP_MakeRecord: {
|
||||
}
|
||||
|
||||
/* Allocate space for the new record. */
|
||||
zNewRecord = sqliteMalloc(nBytes);
|
||||
zNewRecord = sqliteMallocRaw(nBytes);
|
||||
if( !zNewRecord ){
|
||||
rc = SQLITE_NOMEM;
|
||||
goto abort_due_to_error;
|
||||
@@ -2304,7 +2304,7 @@ case OP_MakeIdxKey: {
|
||||
}
|
||||
|
||||
/* Allocate space for the new key */
|
||||
zKey = (char *)sqliteMalloc(nByte);
|
||||
zKey = (char *)sqliteMallocRaw(nByte);
|
||||
if( !zKey ){
|
||||
rc = SQLITE_NOMEM;
|
||||
goto abort_due_to_error;
|
||||
|
||||
@@ -1521,7 +1521,7 @@ int sqlite3VdbeIdxKeyCompare(
|
||||
|
||||
pCellKey = (unsigned char *)sqlite3BtreeKeyFetch(pCur, nCellKey);
|
||||
if( !pCellKey ){
|
||||
pCellKey = (unsigned char *)sqliteMalloc(nCellKey);
|
||||
pCellKey = (unsigned char *)sqliteMallocRaw(nCellKey);
|
||||
if( !pCellKey ){
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
@@ -1547,6 +1547,3 @@ int sqlite3VdbeIdxKeyCompare(
|
||||
}
|
||||
return SQLITE_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user