mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-08 14:02:16 +03:00
Code optimizations to help the library run faster. (CVS 808)
FossilOrigin-Name: db745e87dc26cf1a35cdcec18f4b659742e14120
This commit is contained in:
24
manifest
24
manifest
@@ -1,5 +1,5 @@
|
|||||||
C If\scompiled\swith\sthe\s-DVDBE_PROFILE=1\soption,\sspecial\scode\sis\sinserted\sthat\nuses\sthe\spentium\sRDTSC\sinstruction\sto\scompute\svery\sprecise\sruntimes\son\sall\nVDBE\sopcodes.\s\s(This\sonly\sworks\son\si586\sprocessors,\sof\scourse.)\s\sThe\sresults\nare\swritten\sinto\sthe\svdbe_profile.out\sfile\sfor\sanalysis.\sHopefully,\sthis\nnew\sfeature\swill\sreveal\shot\sspots\sthat\scan\sbe\soptimized\sto\smake\sthe\sVDBE\srun\nfaster.\s(CVS\s807)
|
C Code\soptimizations\sto\shelp\sthe\slibrary\srun\sfaster.\s(CVS\s808)
|
||||||
D 2003-01-01T23:06:21
|
D 2003-01-02T14:43:56
|
||||||
F Makefile.in 868c17a1ae1c07603d491274cc8f86c04acf2a1e
|
F Makefile.in 868c17a1ae1c07603d491274cc8f86c04acf2a1e
|
||||||
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
F Makefile.linux-gcc b86a99c493a5bfb402d1d9178dcdc4bd4b32f906
|
||||||
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
F README f1de682fbbd94899d50aca13d387d1b3fd3be2dd
|
||||||
@@ -18,21 +18,21 @@ F main.mk 9d13839b9697af332d788fe6e801e68da027cc5c
|
|||||||
F publish.sh e5b83867d14708ed58cec8cba0a4f201e969474d
|
F publish.sh e5b83867d14708ed58cec8cba0a4f201e969474d
|
||||||
F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
|
F spec.template 238f7db425a78dc1bb7682e56e3834c7270a3f5e
|
||||||
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
|
F sqlite.1 83f4a9d37bdf2b7ef079a82d54eaf2e3509ee6ea
|
||||||
F src/btree.c 215d4b322c98fbff795095fa253d9ea108d4b9de
|
F src/btree.c 6a2a9bb701a60df4abe2fb7047b25787c90e1ffd
|
||||||
F src/btree.h 17710339f7a8f46e3c7d6d0d4648ef19c584ffda
|
F src/btree.h 17710339f7a8f46e3c7d6d0d4648ef19c584ffda
|
||||||
F src/build.c 415dce8886aabb6d45851caed7014707056d668b
|
F src/build.c 8569ac014609add4b796260d3567a5090b90056d
|
||||||
F src/delete.c aad9d4051ab46e6f6391ea5f7b8994a7c05bdd15
|
F src/delete.c aad9d4051ab46e6f6391ea5f7b8994a7c05bdd15
|
||||||
F src/encode.c 6c9c87d5b7b2c0101d011ebc283a80abf672a4d1
|
F src/encode.c 6c9c87d5b7b2c0101d011ebc283a80abf672a4d1
|
||||||
F src/expr.c 9427b4d1d04ede1095994b8e042abe2e6fea7443
|
F src/expr.c 9427b4d1d04ede1095994b8e042abe2e6fea7443
|
||||||
F src/func.c 90c583f0b91220f7cd411a2407deaf9327245d63
|
F src/func.c 90c583f0b91220f7cd411a2407deaf9327245d63
|
||||||
F src/hash.c 6a6236b89c8c060c65dabd300a1c8ce7c10edb72
|
F src/hash.c 4fc39feb7b7711f6495ee9f2159559bedb043e1f
|
||||||
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
|
F src/hash.h cd0433998bc1a3759d244e1637fe5a3c13b53bf8
|
||||||
F src/insert.c 764300a0bd8074a2174946c0bf8a550bd833397a
|
F src/insert.c 764300a0bd8074a2174946c0bf8a550bd833397a
|
||||||
F src/main.c cee05c2ba23b5e78f9671f319dbd68e2130e0f68
|
F src/main.c cee05c2ba23b5e78f9671f319dbd68e2130e0f68
|
||||||
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
|
F src/md5.c fe4f9c9c6f71dfc26af8da63e4d04489b1430565
|
||||||
F src/os.c 740022806209e44cab0abddfb1fee65c77702e21
|
F src/os.c 740022806209e44cab0abddfb1fee65c77702e21
|
||||||
F src/os.h 09fd96b4d733aae2f3b98b2ae9ceea40b8fd780d
|
F src/os.h 09fd96b4d733aae2f3b98b2ae9ceea40b8fd780d
|
||||||
F src/pager.c ebc73e7c314e7d8ff6c5728bb96831aaa9efb2e4
|
F src/pager.c 255c5d14ff489071021bf1374654836f2516abb3
|
||||||
F src/pager.h 540833e8cb826b80ce2e39aa917deee5e12db626
|
F src/pager.h 540833e8cb826b80ce2e39aa917deee5e12db626
|
||||||
F src/parse.y 469c9636ff713e63c00234662209f11668671ae9
|
F src/parse.y 469c9636ff713e63c00234662209f11668671ae9
|
||||||
F src/printf.c 5c50fc1da75c8f5bf432b1ad17d91d6653acd167
|
F src/printf.c 5c50fc1da75c8f5bf432b1ad17d91d6653acd167
|
||||||
@@ -41,7 +41,7 @@ F src/select.c cc8640e5d4e3ec1a8de58fde6b2fdd6f846b7263
|
|||||||
F src/shell.c 53185af128613a2bac79d50128f4c17794f0f992
|
F src/shell.c 53185af128613a2bac79d50128f4c17794f0f992
|
||||||
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
|
F src/shell.tcl 27ecbd63dd88396ad16d81ab44f73e6c0ea9d20e
|
||||||
F src/sqlite.h.in 98b1574b2362abe02c4a4c73b9dbf99bcd713ab3
|
F src/sqlite.h.in 98b1574b2362abe02c4a4c73b9dbf99bcd713ab3
|
||||||
F src/sqliteInt.h 4eb6290304c9225752ca9cc4fdda5bc480d14176
|
F src/sqliteInt.h 65dfa06bc49ebff83361bfb259ee4c675534808a
|
||||||
F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
|
F src/table.c eed2098c9b577aa17f8abe89313a9c4413f57d63
|
||||||
F src/tclsqlite.c 9f2c00a92338c51171ded8943bd42d77f7e69e64
|
F src/tclsqlite.c 9f2c00a92338c51171ded8943bd42d77f7e69e64
|
||||||
F src/test1.c a46e9f61915b32787c5d5a05a4b92e4dacc437d9
|
F src/test1.c a46e9f61915b32787c5d5a05a4b92e4dacc437d9
|
||||||
@@ -51,8 +51,8 @@ F src/threadtest.c d641a5219e718e18a1a80a50eb9bb549f451f42e
|
|||||||
F src/tokenize.c 75e3bb37305b64e118e709752066f494c4f93c30
|
F src/tokenize.c 75e3bb37305b64e118e709752066f494c4f93c30
|
||||||
F src/trigger.c 5ba917fc226b96065108da28186c2efaec53e481
|
F src/trigger.c 5ba917fc226b96065108da28186c2efaec53e481
|
||||||
F src/update.c 881e4c8e7c786545da4fd2d95da19252b2e31137
|
F src/update.c 881e4c8e7c786545da4fd2d95da19252b2e31137
|
||||||
F src/util.c 8f19c71e45d1a5a3ff2e9a3eef8f36296d87ea43
|
F src/util.c e2d108842e02810d3d3242cac0e024b09cdb3c4a
|
||||||
F src/vdbe.c 0baebb3f0c624e59bf6710cd9fc15db01c7fc31e
|
F src/vdbe.c 572ee028e01d2811dee1ad4d5161ce82e31e88d4
|
||||||
F src/vdbe.h 754eba497cfe0c3e352b9c101ab2f811f10d0a55
|
F src/vdbe.h 754eba497cfe0c3e352b9c101ab2f811f10d0a55
|
||||||
F src/where.c af235636b7bc7f7f42ee1c7162d1958ad0102cab
|
F src/where.c af235636b7bc7f7f42ee1c7162d1958ad0102cab
|
||||||
F test/all.test 873d30e25a41b3aa48fec5633a7ec1816e107029
|
F test/all.test 873d30e25a41b3aa48fec5633a7ec1816e107029
|
||||||
@@ -152,7 +152,7 @@ F www/speed.tcl a20a792738475b68756ea7a19321600f23d1d803
|
|||||||
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
|
F www/sqlite.tcl ae3dcfb077e53833b59d4fcc94d8a12c50a44098
|
||||||
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
F www/tclsqlite.tcl 1db15abeb446aad0caf0b95b8b9579720e4ea331
|
||||||
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
F www/vdbe.tcl 2013852c27a02a091d39a766bc87cff329f21218
|
||||||
P ee95eefe12c48f28412461125c231122e0d4277a
|
P a1c071ea18766932c90275c704e078134c67be68
|
||||||
R c487959d68c24b3808f56b254c4d4b49
|
R 007ca29b327fd24b8c788dde75e1f089
|
||||||
U drh
|
U drh
|
||||||
Z 2e2dd169d3dae32e223fb4d52d6a727e
|
Z 65610790d7e7e89a7d7be7a3a45c0c23
|
||||||
|
@@ -1 +1 @@
|
|||||||
a1c071ea18766932c90275c704e078134c67be68
|
db745e87dc26cf1a35cdcec18f4b659742e14120
|
90
src/btree.c
90
src/btree.c
@@ -9,7 +9,7 @@
|
|||||||
** May you share freely, never taking more than you give.
|
** May you share freely, never taking more than you give.
|
||||||
**
|
**
|
||||||
*************************************************************************
|
*************************************************************************
|
||||||
** $Id: btree.c,v 1.75 2002/12/04 22:29:28 drh Exp $
|
** $Id: btree.c,v 1.76 2003/01/02 14:43:56 drh Exp $
|
||||||
**
|
**
|
||||||
** This file implements a external (disk-based) database using BTrees.
|
** This file implements a external (disk-based) database using BTrees.
|
||||||
** For a detailed discussion of BTrees, refer to
|
** For a detailed discussion of BTrees, refer to
|
||||||
@@ -1106,7 +1106,8 @@ int sqliteBtreeKeySize(BtCursor *pCur, int *pSize){
|
|||||||
MemPage *pPage;
|
MemPage *pPage;
|
||||||
|
|
||||||
pPage = pCur->pPage;
|
pPage = pCur->pPage;
|
||||||
if( pPage==0 || pCur->idx >= pPage->nCell ){
|
assert( pPage!=0 );
|
||||||
|
if( pCur->idx >= pPage->nCell ){
|
||||||
*pSize = 0;
|
*pSize = 0;
|
||||||
}else{
|
}else{
|
||||||
pCell = pPage->apCell[pCur->idx];
|
pCell = pPage->apCell[pCur->idx];
|
||||||
@@ -1180,29 +1181,26 @@ static int getPayload(BtCursor *pCur, int offset, int amt, char *zBuf){
|
|||||||
** Read part of the key associated with cursor pCur. A maximum
|
** Read part of the key associated with cursor pCur. A maximum
|
||||||
** of "amt" bytes will be transfered into zBuf[]. The transfer
|
** of "amt" bytes will be transfered into zBuf[]. The transfer
|
||||||
** begins at "offset". The number of bytes actually read is
|
** begins at "offset". The number of bytes actually read is
|
||||||
** returned. The amount returned will be smaller than the
|
** returned.
|
||||||
** amount requested if there are not enough bytes in the key
|
**
|
||||||
** to satisfy the request.
|
** Change: It used to be that the amount returned will be smaller
|
||||||
|
** than the amount requested if there are not enough bytes in the key
|
||||||
|
** to satisfy the request. But now, it must be the case that there
|
||||||
|
** is enough data available to satisfy the request. If not, an exception
|
||||||
|
** is raised. The change was made in an effort to boost performance
|
||||||
|
** by eliminating unneeded tests.
|
||||||
*/
|
*/
|
||||||
int sqliteBtreeKey(BtCursor *pCur, int offset, int amt, char *zBuf){
|
int sqliteBtreeKey(BtCursor *pCur, int offset, int amt, char *zBuf){
|
||||||
Cell *pCell;
|
|
||||||
MemPage *pPage;
|
MemPage *pPage;
|
||||||
|
|
||||||
if( amt<0 ) return 0;
|
assert( amt>=0 );
|
||||||
if( offset<0 ) return 0;
|
assert( offset>=0 );
|
||||||
if( amt==0 ) return 0;
|
assert( pCur->pPage!=0 );
|
||||||
pPage = pCur->pPage;
|
pPage = pCur->pPage;
|
||||||
if( pPage==0 ) return 0;
|
|
||||||
if( pCur->idx >= pPage->nCell ){
|
if( pCur->idx >= pPage->nCell ){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pCell = pPage->apCell[pCur->idx];
|
assert( amt+offset <= NKEY(pCur->pBt, pPage->apCell[pCur->idx]->h) );
|
||||||
if( amt+offset > NKEY(pCur->pBt, pCell->h) ){
|
|
||||||
amt = NKEY(pCur->pBt, pCell->h) - offset;
|
|
||||||
if( amt<=0 ){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getPayload(pCur, offset, amt, zBuf);
|
getPayload(pCur, offset, amt, zBuf);
|
||||||
return amt;
|
return amt;
|
||||||
}
|
}
|
||||||
@@ -1219,7 +1217,8 @@ int sqliteBtreeDataSize(BtCursor *pCur, int *pSize){
|
|||||||
MemPage *pPage;
|
MemPage *pPage;
|
||||||
|
|
||||||
pPage = pCur->pPage;
|
pPage = pCur->pPage;
|
||||||
if( pPage==0 || pCur->idx >= pPage->nCell ){
|
assert( pPage!=0 );
|
||||||
|
if( pCur->idx >= pPage->nCell ){
|
||||||
*pSize = 0;
|
*pSize = 0;
|
||||||
}else{
|
}else{
|
||||||
pCell = pPage->apCell[pCur->idx];
|
pCell = pPage->apCell[pCur->idx];
|
||||||
@@ -1239,23 +1238,16 @@ int sqliteBtreeDataSize(BtCursor *pCur, int *pSize){
|
|||||||
int sqliteBtreeData(BtCursor *pCur, int offset, int amt, char *zBuf){
|
int sqliteBtreeData(BtCursor *pCur, int offset, int amt, char *zBuf){
|
||||||
Cell *pCell;
|
Cell *pCell;
|
||||||
MemPage *pPage;
|
MemPage *pPage;
|
||||||
int nData;
|
|
||||||
|
|
||||||
if( amt<0 ) return 0;
|
assert( amt>=0 );
|
||||||
if( offset<0 ) return 0;
|
assert( offset>=0 );
|
||||||
if( amt==0 ) return 0;
|
assert( pCur->pPage!=0 );
|
||||||
pPage = pCur->pPage;
|
pPage = pCur->pPage;
|
||||||
if( pPage==0 || pCur->idx >= pPage->nCell ){
|
if( pCur->idx >= pPage->nCell ){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
pCell = pPage->apCell[pCur->idx];
|
pCell = pPage->apCell[pCur->idx];
|
||||||
nData = NDATA(pCur->pBt, pCell->h);
|
assert( amt+offset <= NDATA(pCur->pBt, pCell->h) );
|
||||||
if( amt+offset > nData ){
|
|
||||||
amt = nData - offset;
|
|
||||||
if( amt<=0 ){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
getPayload(pCur, offset + NKEY(pCur->pBt, pCell->h), amt, zBuf);
|
getPayload(pCur, offset + NKEY(pCur->pBt, pCell->h), amt, zBuf);
|
||||||
return amt;
|
return amt;
|
||||||
}
|
}
|
||||||
@@ -1552,26 +1544,28 @@ int sqliteBtreeMoveto(BtCursor *pCur, const void *pKey, int nKey, int *pRes){
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Advance the cursor to the next entry in the database. If
|
** Advance the cursor to the next entry in the database. If
|
||||||
** successful and pRes!=NULL then set *pRes=0. If the cursor
|
** successful then set *pRes=0. If the cursor
|
||||||
** was already pointing to the last entry in the database before
|
** was already pointing to the last entry in the database before
|
||||||
** this routine was called, then set *pRes=1 if pRes!=NULL.
|
** this routine was called, then set *pRes=1.
|
||||||
*/
|
*/
|
||||||
int sqliteBtreeNext(BtCursor *pCur, int *pRes){
|
int sqliteBtreeNext(BtCursor *pCur, int *pRes){
|
||||||
int rc;
|
int rc;
|
||||||
|
assert( pRes!=0 );
|
||||||
|
/* assert( pCur->pPage!=0 ); */
|
||||||
if( pCur->pPage==0 ){
|
if( pCur->pPage==0 ){
|
||||||
if( pRes ) *pRes = 1;
|
*pRes = 1;
|
||||||
return SQLITE_ABORT;
|
return SQLITE_ABORT;
|
||||||
}
|
}
|
||||||
assert( pCur->pPage->isInit );
|
assert( pCur->pPage->isInit );
|
||||||
assert( pCur->eSkip!=SKIP_INVALID );
|
assert( pCur->eSkip!=SKIP_INVALID );
|
||||||
if( pCur->pPage->nCell==0 ){
|
if( pCur->pPage->nCell==0 ){
|
||||||
if( pRes ) *pRes = 1;
|
*pRes = 1;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
assert( pCur->idx<pCur->pPage->nCell );
|
assert( pCur->idx<pCur->pPage->nCell );
|
||||||
if( pCur->eSkip==SKIP_NEXT ){
|
if( pCur->eSkip==SKIP_NEXT ){
|
||||||
pCur->eSkip = SKIP_NONE;
|
pCur->eSkip = SKIP_NONE;
|
||||||
if( pRes ) *pRes = 0;
|
*pRes = 0;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
pCur->eSkip = SKIP_NONE;
|
pCur->eSkip = SKIP_NONE;
|
||||||
@@ -1581,25 +1575,22 @@ int sqliteBtreeNext(BtCursor *pCur, int *pRes){
|
|||||||
rc = moveToChild(pCur, SWAB32(pCur->pBt, pCur->pPage->u.hdr.rightChild));
|
rc = moveToChild(pCur, SWAB32(pCur->pBt, pCur->pPage->u.hdr.rightChild));
|
||||||
if( rc ) return rc;
|
if( rc ) return rc;
|
||||||
rc = moveToLeftmost(pCur);
|
rc = moveToLeftmost(pCur);
|
||||||
if( rc ) return rc;
|
*pRes = 0;
|
||||||
if( pRes ) *pRes = 0;
|
return rc;
|
||||||
return SQLITE_OK;
|
|
||||||
}
|
}
|
||||||
do{
|
do{
|
||||||
if( pCur->pPage->pParent==0 ){
|
if( pCur->pPage->pParent==0 ){
|
||||||
if( pRes ) *pRes = 1;
|
*pRes = 1;
|
||||||
return SQLITE_OK;
|
return SQLITE_OK;
|
||||||
}
|
}
|
||||||
rc = moveToParent(pCur);
|
rc = moveToParent(pCur);
|
||||||
if( rc ) return rc;
|
}while( rc==SQLITE_OK && pCur->idx>=pCur->pPage->nCell );
|
||||||
}while( pCur->idx>=pCur->pPage->nCell );
|
*pRes = 0;
|
||||||
if( pRes ) *pRes = 0;
|
return rc;
|
||||||
return SQLITE_OK;
|
|
||||||
}
|
}
|
||||||
rc = moveToLeftmost(pCur);
|
rc = moveToLeftmost(pCur);
|
||||||
if( rc ) return rc;
|
*pRes = 0;
|
||||||
if( pRes ) *pRes = 0;
|
return rc;
|
||||||
return SQLITE_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2621,8 +2612,9 @@ int sqliteBtreeDelete(BtCursor *pCur){
|
|||||||
BtCursor leafCur;
|
BtCursor leafCur;
|
||||||
Cell *pNext;
|
Cell *pNext;
|
||||||
int szNext;
|
int szNext;
|
||||||
|
int notUsed;
|
||||||
getTempCursor(pCur, &leafCur);
|
getTempCursor(pCur, &leafCur);
|
||||||
rc = sqliteBtreeNext(&leafCur, 0);
|
rc = sqliteBtreeNext(&leafCur, ¬Used);
|
||||||
if( rc!=SQLITE_OK ){
|
if( rc!=SQLITE_OK ){
|
||||||
return SQLITE_CORRUPT;
|
return SQLITE_CORRUPT;
|
||||||
}
|
}
|
||||||
@@ -3157,7 +3149,7 @@ static int checkTreePage(
|
|||||||
/* Check that keys are in the right order
|
/* Check that keys are in the right order
|
||||||
*/
|
*/
|
||||||
cur.idx = i;
|
cur.idx = i;
|
||||||
zKey2 = sqliteMalloc( nKey2+1 );
|
zKey2 = sqliteMallocRaw( nKey2+1 );
|
||||||
getPayload(&cur, 0, nKey2, zKey2);
|
getPayload(&cur, 0, nKey2, zKey2);
|
||||||
if( zKey1 && keyCompare(zKey1, nKey1, zKey2, nKey2)>=0 ){
|
if( zKey1 && keyCompare(zKey1, nKey1, zKey2, nKey2)>=0 ){
|
||||||
checkAppendMsg(pCheck, zContext, "Key is out of order");
|
checkAppendMsg(pCheck, zContext, "Key is out of order");
|
||||||
@@ -3253,7 +3245,7 @@ char *sqliteBtreeIntegrityCheck(Btree *pBt, int *aRoot, int nRoot){
|
|||||||
unlockBtreeIfUnused(pBt);
|
unlockBtreeIfUnused(pBt);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
sCheck.anRef = sqliteMalloc( (sCheck.nPage+1)*sizeof(sCheck.anRef[0]) );
|
sCheck.anRef = sqliteMallocRaw( (sCheck.nPage+1)*sizeof(sCheck.anRef[0]) );
|
||||||
sCheck.anRef[1] = 1;
|
sCheck.anRef[1] = 1;
|
||||||
for(i=2; i<=sCheck.nPage; i++){ sCheck.anRef[i] = 0; }
|
for(i=2; i<=sCheck.nPage; i++){ sCheck.anRef[i] = 0; }
|
||||||
sCheck.zErrMsg = 0;
|
sCheck.zErrMsg = 0;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
** ROLLBACK
|
** ROLLBACK
|
||||||
** PRAGMA
|
** PRAGMA
|
||||||
**
|
**
|
||||||
** $Id: build.c,v 1.117 2002/12/03 02:22:52 drh Exp $
|
** $Id: build.c,v 1.118 2003/01/02 14:43:56 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -727,7 +727,7 @@ static char *createTableStmt(Table *p){
|
|||||||
zEnd = "\n)";
|
zEnd = "\n)";
|
||||||
}
|
}
|
||||||
n += 35 + 6*p->nCol;
|
n += 35 + 6*p->nCol;
|
||||||
zStmt = sqliteMalloc( n );
|
zStmt = sqliteMallocRaw( n );
|
||||||
if( zStmt==0 ) return 0;
|
if( zStmt==0 ) return 0;
|
||||||
strcpy(zStmt, p->isTemp ? "CREATE TEMP TABLE " : "CREATE TABLE ");
|
strcpy(zStmt, p->isTemp ? "CREATE TEMP TABLE " : "CREATE TABLE ");
|
||||||
k = strlen(zStmt);
|
k = strlen(zStmt);
|
||||||
@@ -1164,7 +1164,7 @@ void sqliteAddIdxKeyType(Vdbe *v, Index *pIdx){
|
|||||||
assert( pIdx!=0 && pIdx->pTable!=0 );
|
assert( pIdx!=0 && pIdx->pTable!=0 );
|
||||||
pTab = pIdx->pTable;
|
pTab = pIdx->pTable;
|
||||||
n = pIdx->nColumn;
|
n = pIdx->nColumn;
|
||||||
zType = sqliteMalloc( n+1 );
|
zType = sqliteMallocRaw( n+1 );
|
||||||
if( zType==0 ) return;
|
if( zType==0 ) return;
|
||||||
for(i=0; i<n; i++){
|
for(i=0; i<n; i++){
|
||||||
int iCol = pIdx->aiColumn[i];
|
int iCol = pIdx->aiColumn[i];
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
** This is the implementation of generic hash-tables
|
** This is the implementation of generic hash-tables
|
||||||
** used in SQLite.
|
** used in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: hash.c,v 1.8 2002/05/21 23:44:30 drh Exp $
|
** $Id: hash.c,v 1.9 2003/01/02 14:43:57 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
@@ -313,7 +313,7 @@ void *sqliteHashInsert(Hash *pH, const void *pKey, int nKey, void *data){
|
|||||||
new_elem = (HashElem*)sqliteMalloc( sizeof(HashElem) );
|
new_elem = (HashElem*)sqliteMalloc( sizeof(HashElem) );
|
||||||
if( new_elem==0 ) return data;
|
if( new_elem==0 ) return data;
|
||||||
if( pH->copyKey && pKey!=0 ){
|
if( pH->copyKey && pKey!=0 ){
|
||||||
new_elem->pKey = sqliteMalloc( nKey );
|
new_elem->pKey = sqliteMallocRaw( nKey );
|
||||||
if( new_elem->pKey==0 ){
|
if( new_elem->pKey==0 ){
|
||||||
sqliteFree(new_elem);
|
sqliteFree(new_elem);
|
||||||
return data;
|
return data;
|
||||||
|
@@ -18,7 +18,7 @@
|
|||||||
** file simultaneously, or one process from reading the database while
|
** file simultaneously, or one process from reading the database while
|
||||||
** another is writing.
|
** another is writing.
|
||||||
**
|
**
|
||||||
** @(#) $Id: pager.c,v 1.62 2002/12/28 01:06:30 drh Exp $
|
** @(#) $Id: pager.c,v 1.63 2003/01/02 14:43:57 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "os.h" /* Must be first to enable large file support */
|
#include "os.h" /* Must be first to enable large file support */
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
@@ -962,13 +962,14 @@ int sqlitepager_get(Pager *pPager, Pgno pgno, void **ppPage){
|
|||||||
pPager->nMiss++;
|
pPager->nMiss++;
|
||||||
if( pPager->nPage<pPager->mxPage || pPager->pFirst==0 ){
|
if( pPager->nPage<pPager->mxPage || pPager->pFirst==0 ){
|
||||||
/* Create a new page */
|
/* Create a new page */
|
||||||
pPg = sqliteMalloc( sizeof(*pPg) + SQLITE_PAGE_SIZE + pPager->nExtra );
|
pPg = sqliteMallocRaw( sizeof(*pPg) + SQLITE_PAGE_SIZE + pPager->nExtra );
|
||||||
if( pPg==0 ){
|
if( pPg==0 ){
|
||||||
*ppPage = 0;
|
*ppPage = 0;
|
||||||
pager_unwritelock(pPager);
|
pager_unwritelock(pPager);
|
||||||
pPager->errMask |= PAGER_ERR_MEM;
|
pPager->errMask |= PAGER_ERR_MEM;
|
||||||
return SQLITE_NOMEM;
|
return SQLITE_NOMEM;
|
||||||
}
|
}
|
||||||
|
memset(pPg, 0, sizeof(*pPg));
|
||||||
pPg->pPager = pPager;
|
pPg->pPager = pPager;
|
||||||
pPg->pNextAll = pPager->pAll;
|
pPg->pNextAll = pPager->pAll;
|
||||||
if( pPager->pAll ){
|
if( pPager->pAll ){
|
||||||
|
@@ -11,7 +11,7 @@
|
|||||||
*************************************************************************
|
*************************************************************************
|
||||||
** Internal interface definitions for SQLite.
|
** Internal interface definitions for SQLite.
|
||||||
**
|
**
|
||||||
** @(#) $Id: sqliteInt.h,v 1.150 2002/12/04 20:01:06 drh Exp $
|
** @(#) $Id: sqliteInt.h,v 1.151 2003/01/02 14:43:57 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "sqlite.h"
|
#include "sqlite.h"
|
||||||
@@ -119,7 +119,8 @@ typedef unsigned INTPTR_TYPE uptr; /* Big enough to hold a pointer */
|
|||||||
** by an AWK script to determine if there are any leaks.
|
** by an AWK script to determine if there are any leaks.
|
||||||
*/
|
*/
|
||||||
#ifdef MEMORY_DEBUG
|
#ifdef MEMORY_DEBUG
|
||||||
# define sqliteMalloc(X) sqliteMalloc_(X,__FILE__,__LINE__)
|
# define sqliteMalloc(X) sqliteMalloc_(X,1,__FILE__,__LINE__)
|
||||||
|
# define sqliteMallocRaw(X) sqliteMalloc_(X,0,__FILE__,__LINE__)
|
||||||
# define sqliteFree(X) sqliteFree_(X,__FILE__,__LINE__)
|
# define sqliteFree(X) sqliteFree_(X,__FILE__,__LINE__)
|
||||||
# define sqliteRealloc(X,Y) sqliteRealloc_(X,Y,__FILE__,__LINE__)
|
# define sqliteRealloc(X,Y) sqliteRealloc_(X,Y,__FILE__,__LINE__)
|
||||||
# define sqliteStrDup(X) sqliteStrDup_(X,__FILE__,__LINE__)
|
# define sqliteStrDup(X) sqliteStrDup_(X,__FILE__,__LINE__)
|
||||||
@@ -893,13 +894,14 @@ int sqliteCompare(const char *, const char *);
|
|||||||
int sqliteSortCompare(const char *, const char *);
|
int sqliteSortCompare(const char *, const char *);
|
||||||
void sqliteRealToSortable(double r, char *);
|
void sqliteRealToSortable(double r, char *);
|
||||||
#ifdef MEMORY_DEBUG
|
#ifdef MEMORY_DEBUG
|
||||||
void *sqliteMalloc_(int,char*,int);
|
void *sqliteMalloc_(int,int,char*,int);
|
||||||
void sqliteFree_(void*,char*,int);
|
void sqliteFree_(void*,char*,int);
|
||||||
void *sqliteRealloc_(void*,int,char*,int);
|
void *sqliteRealloc_(void*,int,char*,int);
|
||||||
char *sqliteStrDup_(const char*,char*,int);
|
char *sqliteStrDup_(const char*,char*,int);
|
||||||
char *sqliteStrNDup_(const char*, int,char*,int);
|
char *sqliteStrNDup_(const char*, int,char*,int);
|
||||||
#else
|
#else
|
||||||
void *sqliteMalloc(int);
|
void *sqliteMalloc(int);
|
||||||
|
void *sqliteMallocRaw(int);
|
||||||
void sqliteFree(void*);
|
void sqliteFree(void*);
|
||||||
void *sqliteRealloc(void*,int);
|
void *sqliteRealloc(void*,int);
|
||||||
char *sqliteStrDup(const char*);
|
char *sqliteStrDup(const char*);
|
||||||
|
39
src/util.c
39
src/util.c
@@ -14,7 +14,7 @@
|
|||||||
** This file contains functions for allocating memory, comparing
|
** This file contains functions for allocating memory, comparing
|
||||||
** strings, and stuff like that.
|
** strings, and stuff like that.
|
||||||
**
|
**
|
||||||
** $Id: util.c,v 1.53 2002/12/17 13:05:26 drh Exp $
|
** $Id: util.c,v 1.54 2003/01/02 14:43:57 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
@@ -48,7 +48,7 @@ static int memcnt = 0;
|
|||||||
** Allocate new memory and set it to zero. Return NULL if
|
** Allocate new memory and set it to zero. Return NULL if
|
||||||
** no memory is available.
|
** no memory is available.
|
||||||
*/
|
*/
|
||||||
void *sqliteMalloc_(int n, char *zFile, int line){
|
void *sqliteMalloc_(int n, int bZero, char *zFile, int line){
|
||||||
void *p;
|
void *p;
|
||||||
int *pi;
|
int *pi;
|
||||||
int k;
|
int k;
|
||||||
@@ -76,7 +76,7 @@ void *sqliteMalloc_(int n, char *zFile, int line){
|
|||||||
pi[1] = n;
|
pi[1] = n;
|
||||||
pi[k+2] = 0xdead3344;
|
pi[k+2] = 0xdead3344;
|
||||||
p = &pi[2];
|
p = &pi[2];
|
||||||
memset(p, 0, n);
|
memset(p, bZero==0, n);
|
||||||
#if MEMORY_DEBUG>1
|
#if MEMORY_DEBUG>1
|
||||||
fprintf(stderr,"%06d malloc %d bytes at 0x%x from %s:%d\n",
|
fprintf(stderr,"%06d malloc %d bytes at 0x%x from %s:%d\n",
|
||||||
++memcnt, n, (int)p, zFile,line);
|
++memcnt, n, (int)p, zFile,line);
|
||||||
@@ -121,7 +121,7 @@ void *sqliteRealloc_(void *oldP, int n, char *zFile, int line){
|
|||||||
int *oldPi, *pi, k, oldN, oldK;
|
int *oldPi, *pi, k, oldN, oldK;
|
||||||
void *p;
|
void *p;
|
||||||
if( oldP==0 ){
|
if( oldP==0 ){
|
||||||
return sqliteMalloc_(n,zFile,line);
|
return sqliteMalloc_(n,1,zFile,line);
|
||||||
}
|
}
|
||||||
if( n==0 ){
|
if( n==0 ){
|
||||||
sqliteFree_(oldP,zFile,line);
|
sqliteFree_(oldP,zFile,line);
|
||||||
@@ -153,7 +153,7 @@ void *sqliteRealloc_(void *oldP, int n, char *zFile, int line){
|
|||||||
if( n>oldN ){
|
if( n>oldN ){
|
||||||
memset(&((char*)p)[oldN], 0, n-oldN);
|
memset(&((char*)p)[oldN], 0, n-oldN);
|
||||||
}
|
}
|
||||||
memset(oldPi, 0, (oldK+3)*sizeof(int));
|
memset(oldPi, 0xab, (oldK+3)*sizeof(int));
|
||||||
free(oldPi);
|
free(oldPi);
|
||||||
#if MEMORY_DEBUG>1
|
#if MEMORY_DEBUG>1
|
||||||
fprintf(stderr,"%06d realloc %d to %d bytes at 0x%x to 0x%x at %s:%d\n",
|
fprintf(stderr,"%06d realloc %d to %d bytes at 0x%x to 0x%x at %s:%d\n",
|
||||||
@@ -190,14 +190,14 @@ void sqliteStrRealloc(char **pz){
|
|||||||
char *sqliteStrDup_(const char *z, char *zFile, int line){
|
char *sqliteStrDup_(const char *z, char *zFile, int line){
|
||||||
char *zNew;
|
char *zNew;
|
||||||
if( z==0 ) return 0;
|
if( z==0 ) return 0;
|
||||||
zNew = sqliteMalloc_(strlen(z)+1, zFile, line);
|
zNew = sqliteMalloc_(strlen(z)+1, 0, zFile, line);
|
||||||
if( zNew ) strcpy(zNew, z);
|
if( zNew ) strcpy(zNew, z);
|
||||||
return zNew;
|
return zNew;
|
||||||
}
|
}
|
||||||
char *sqliteStrNDup_(const char *z, int n, char *zFile, int line){
|
char *sqliteStrNDup_(const char *z, int n, char *zFile, int line){
|
||||||
char *zNew;
|
char *zNew;
|
||||||
if( z==0 ) return 0;
|
if( z==0 ) return 0;
|
||||||
zNew = sqliteMalloc_(n+1, zFile, line);
|
zNew = sqliteMalloc_(n+1, 0, zFile, line);
|
||||||
if( zNew ){
|
if( zNew ){
|
||||||
memcpy(zNew, z, n);
|
memcpy(zNew, z, n);
|
||||||
zNew[n] = 0;
|
zNew[n] = 0;
|
||||||
@@ -214,7 +214,7 @@ char *sqliteStrNDup_(const char *z, int n, char *zFile, int line){
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
** Allocate new memory and set it to zero. Return NULL if
|
** Allocate new memory and set it to zero. Return NULL if
|
||||||
** no memory is available.
|
** no memory is available. See also sqliteMallocRaw().
|
||||||
*/
|
*/
|
||||||
void *sqliteMalloc(int n){
|
void *sqliteMalloc(int n){
|
||||||
void *p;
|
void *p;
|
||||||
@@ -228,6 +228,21 @@ void *sqliteMalloc(int n){
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** Allocate new memory but do not set it to zero. Return NULL if
|
||||||
|
** no memory is available. See also sqliteMalloc().
|
||||||
|
*/
|
||||||
|
void *sqliteMallocRaw(int n){
|
||||||
|
void *p;
|
||||||
|
if( n==0 ) return 0;
|
||||||
|
p = malloc(n);
|
||||||
|
if( p==0 ){
|
||||||
|
sqlite_malloc_failed++;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Free memory previously obtained from sqliteMalloc()
|
** Free memory previously obtained from sqliteMalloc()
|
||||||
*/
|
*/
|
||||||
@@ -264,14 +279,14 @@ void *sqliteRealloc(void *p, int n){
|
|||||||
char *sqliteStrDup(const char *z){
|
char *sqliteStrDup(const char *z){
|
||||||
char *zNew;
|
char *zNew;
|
||||||
if( z==0 ) return 0;
|
if( z==0 ) return 0;
|
||||||
zNew = sqliteMalloc(strlen(z)+1);
|
zNew = sqliteMallocRaw(strlen(z)+1);
|
||||||
if( zNew ) strcpy(zNew, z);
|
if( zNew ) strcpy(zNew, z);
|
||||||
return zNew;
|
return zNew;
|
||||||
}
|
}
|
||||||
char *sqliteStrNDup(const char *z, int n){
|
char *sqliteStrNDup(const char *z, int n){
|
||||||
char *zNew;
|
char *zNew;
|
||||||
if( z==0 ) return 0;
|
if( z==0 ) return 0;
|
||||||
zNew = sqliteMalloc(n+1);
|
zNew = sqliteMallocRaw(n+1);
|
||||||
if( zNew ){
|
if( zNew ){
|
||||||
memcpy(zNew, z, n);
|
memcpy(zNew, z, n);
|
||||||
zNew[n] = 0;
|
zNew[n] = 0;
|
||||||
@@ -300,7 +315,7 @@ void sqliteSetString(char **pz, const char *zFirst, ...){
|
|||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
sqliteFree(*pz);
|
sqliteFree(*pz);
|
||||||
*pz = zResult = sqliteMalloc( nByte );
|
*pz = zResult = sqliteMallocRaw( nByte );
|
||||||
if( zResult==0 ){
|
if( zResult==0 ){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -341,7 +356,7 @@ void sqliteSetNString(char **pz, ...){
|
|||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
sqliteFree(*pz);
|
sqliteFree(*pz);
|
||||||
*pz = zResult = sqliteMalloc( nByte + 1 );
|
*pz = zResult = sqliteMallocRaw( nByte + 1 );
|
||||||
if( zResult==0 ) return;
|
if( zResult==0 ) return;
|
||||||
va_start(ap, pz);
|
va_start(ap, pz);
|
||||||
while( (z = va_arg(ap, const char*))!=0 ){
|
while( (z = va_arg(ap, const char*))!=0 ){
|
||||||
|
33
src/vdbe.c
33
src/vdbe.c
@@ -36,7 +36,7 @@
|
|||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.188 2003/01/01 23:06:21 drh Exp $
|
** $Id: vdbe.c,v 1.189 2003/01/02 14:43:57 drh Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -609,7 +609,7 @@ char *sqlite_set_result_string(sqlite_func *p, const char *zResult, int n){
|
|||||||
p->s.flags = STK_Str;
|
p->s.flags = STK_Str;
|
||||||
p->z = p->s.z;
|
p->z = p->s.z;
|
||||||
}else{
|
}else{
|
||||||
p->z = sqliteMalloc( n+1 );
|
p->z = sqliteMallocRaw( n+1 );
|
||||||
if( p->z ){
|
if( p->z ){
|
||||||
memcpy(p->z, zResult, n);
|
memcpy(p->z, zResult, n);
|
||||||
p->z[n] = 0;
|
p->z[n] = 0;
|
||||||
@@ -817,7 +817,7 @@ static int hardDeephem(Vdbe *p, int i){
|
|||||||
char **pzStack = &p->zStack[i];
|
char **pzStack = &p->zStack[i];
|
||||||
char *z;
|
char *z;
|
||||||
assert( (pStack->flags & STK_Ephem)!=0 );
|
assert( (pStack->flags & STK_Ephem)!=0 );
|
||||||
z = sqliteMalloc( pStack->n );
|
z = sqliteMallocRaw( pStack->n );
|
||||||
if( z==0 ) return 1;
|
if( z==0 ) return 1;
|
||||||
memcpy(z, *pzStack, pStack->n);
|
memcpy(z, *pzStack, pStack->n);
|
||||||
*pzStack = z;
|
*pzStack = z;
|
||||||
@@ -1662,7 +1662,7 @@ case OP_Dup: {
|
|||||||
zStack[j] = aStack[j].z;
|
zStack[j] = aStack[j].z;
|
||||||
aStack[j].flags &= ~(STK_Static|STK_Dyn|STK_Ephem);
|
aStack[j].flags &= ~(STK_Static|STK_Dyn|STK_Ephem);
|
||||||
}else{
|
}else{
|
||||||
zStack[j] = sqliteMalloc( aStack[j].n );
|
zStack[j] = sqliteMallocRaw( aStack[j].n );
|
||||||
if( zStack[j]==0 ) goto no_mem;
|
if( zStack[j]==0 ) goto no_mem;
|
||||||
memcpy(zStack[j], zStack[i], aStack[j].n);
|
memcpy(zStack[j], zStack[i], aStack[j].n);
|
||||||
aStack[j].flags &= ~(STK_Static|STK_Ephem);
|
aStack[j].flags &= ~(STK_Static|STK_Ephem);
|
||||||
@@ -1871,7 +1871,7 @@ case OP_Concat: {
|
|||||||
zStack[p->tos] = 0;
|
zStack[p->tos] = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
zNew = sqliteMalloc( nByte );
|
zNew = sqliteMallocRaw( nByte );
|
||||||
if( zNew==0 ) goto no_mem;
|
if( zNew==0 ) goto no_mem;
|
||||||
j = 0;
|
j = 0;
|
||||||
for(i=p->tos-nField+1; i<=p->tos; i++){
|
for(i=p->tos-nField+1; i<=p->tos; i++){
|
||||||
@@ -2782,7 +2782,7 @@ case OP_MakeRecord: {
|
|||||||
rc = SQLITE_TOOBIG;
|
rc = SQLITE_TOOBIG;
|
||||||
goto abort_due_to_error;
|
goto abort_due_to_error;
|
||||||
}
|
}
|
||||||
zNewRecord = sqliteMalloc( nByte );
|
zNewRecord = sqliteMallocRaw( nByte );
|
||||||
if( zNewRecord==0 ) goto no_mem;
|
if( zNewRecord==0 ) goto no_mem;
|
||||||
j = 0;
|
j = 0;
|
||||||
addr = idxWidth*(nField+1) + addUnique*sizeof(uniqueCnt);
|
addr = idxWidth*(nField+1) + addUnique*sizeof(uniqueCnt);
|
||||||
@@ -2936,7 +2936,7 @@ case OP_MakeKey: {
|
|||||||
goto abort_due_to_error;
|
goto abort_due_to_error;
|
||||||
}
|
}
|
||||||
if( addRowid ) nByte += sizeof(u32);
|
if( addRowid ) nByte += sizeof(u32);
|
||||||
zNewKey = sqliteMalloc( nByte );
|
zNewKey = sqliteMallocRaw( nByte );
|
||||||
if( zNewKey==0 ) goto no_mem;
|
if( zNewKey==0 ) goto no_mem;
|
||||||
j = 0;
|
j = 0;
|
||||||
for(i=p->tos-nField+1; i<=p->tos; i++){
|
for(i=p->tos-nField+1; i<=p->tos; i++){
|
||||||
@@ -3929,7 +3929,7 @@ case OP_Column: {
|
|||||||
zStack[tos] = aStack[tos].z;
|
zStack[tos] = aStack[tos].z;
|
||||||
aStack[tos].n = amt;
|
aStack[tos].n = amt;
|
||||||
}else{
|
}else{
|
||||||
char *z = sqliteMalloc( amt );
|
char *z = sqliteMallocRaw( amt );
|
||||||
if( z==0 ) goto no_mem;
|
if( z==0 ) goto no_mem;
|
||||||
aStack[tos].flags = STK_Str | STK_Dyn;
|
aStack[tos].flags = STK_Str | STK_Dyn;
|
||||||
zStack[tos] = z;
|
zStack[tos] = z;
|
||||||
@@ -4001,7 +4001,7 @@ case OP_FullKey: {
|
|||||||
goto abort_due_to_error;
|
goto abort_due_to_error;
|
||||||
}
|
}
|
||||||
if( amt>NBFS ){
|
if( amt>NBFS ){
|
||||||
z = sqliteMalloc( amt );
|
z = sqliteMallocRaw( amt );
|
||||||
aStack[tos].flags = STK_Str | STK_Dyn;
|
aStack[tos].flags = STK_Str | STK_Dyn;
|
||||||
}else{
|
}else{
|
||||||
z = aStack[tos].z;
|
z = aStack[tos].z;
|
||||||
@@ -4095,12 +4095,11 @@ case OP_Rewind: {
|
|||||||
*/
|
*/
|
||||||
case OP_Prev:
|
case OP_Prev:
|
||||||
case OP_Next: {
|
case OP_Next: {
|
||||||
int i = pOp->p1;
|
|
||||||
Cursor *pC;
|
Cursor *pC;
|
||||||
BtCursor *pCrsr;
|
BtCursor *pCrsr;
|
||||||
|
|
||||||
if( VERIFY( i>=0 && i<p->nCursor && )
|
if( VERIFY( pOp->p1>=0 && pOp->p1<p->nCursor && )
|
||||||
(pCrsr = (pC = &p->aCsr[i])->pCursor)!=0 ){
|
(pCrsr = (pC = &p->aCsr[pOp->p1])->pCursor)!=0 ){
|
||||||
int res;
|
int res;
|
||||||
if( pC->nullRow ){
|
if( pC->nullRow ){
|
||||||
res = 1;
|
res = 1;
|
||||||
@@ -4406,7 +4405,7 @@ case OP_ListWrite: {
|
|||||||
VERIFY( if( p->tos<0 ) goto not_enough_stack; )
|
VERIFY( if( p->tos<0 ) goto not_enough_stack; )
|
||||||
pKeylist = p->pList;
|
pKeylist = p->pList;
|
||||||
if( pKeylist==0 || pKeylist->nUsed>=pKeylist->nKey ){
|
if( pKeylist==0 || pKeylist->nUsed>=pKeylist->nKey ){
|
||||||
pKeylist = sqliteMalloc( sizeof(Keylist)+999*sizeof(pKeylist->aKey[0]) );
|
pKeylist = sqliteMallocRaw( sizeof(Keylist)+999*sizeof(pKeylist->aKey[0]) );
|
||||||
if( pKeylist==0 ) goto no_mem;
|
if( pKeylist==0 ) goto no_mem;
|
||||||
pKeylist->nKey = 1000;
|
pKeylist->nKey = 1000;
|
||||||
pKeylist->nRead = 0;
|
pKeylist->nRead = 0;
|
||||||
@@ -4516,7 +4515,7 @@ case OP_SortPut: {
|
|||||||
Sorter *pSorter;
|
Sorter *pSorter;
|
||||||
VERIFY( if( tos<1 ) goto not_enough_stack; )
|
VERIFY( if( tos<1 ) goto not_enough_stack; )
|
||||||
if( Stringify(p, tos) || Stringify(p, nos) ) goto no_mem;
|
if( Stringify(p, tos) || Stringify(p, nos) ) goto no_mem;
|
||||||
pSorter = sqliteMalloc( sizeof(Sorter) );
|
pSorter = sqliteMallocRaw( sizeof(Sorter) );
|
||||||
if( pSorter==0 ) goto no_mem;
|
if( pSorter==0 ) goto no_mem;
|
||||||
pSorter->pNext = p->pSort;
|
pSorter->pNext = p->pSort;
|
||||||
p->pSort = pSorter;
|
p->pSort = pSorter;
|
||||||
@@ -4560,7 +4559,7 @@ case OP_SortMakeRec: {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nByte += sizeof(char*)*(nField+1);
|
nByte += sizeof(char*)*(nField+1);
|
||||||
azArg = sqliteMalloc( nByte );
|
azArg = sqliteMallocRaw( nByte );
|
||||||
if( azArg==0 ) goto no_mem;
|
if( azArg==0 ) goto no_mem;
|
||||||
z = (char*)&azArg[nField+1];
|
z = (char*)&azArg[nField+1];
|
||||||
for(j=0, i=p->tos-nField+1; i<=p->tos; i++, j++){
|
for(j=0, i=p->tos-nField+1; i<=p->tos; i++, j++){
|
||||||
@@ -4613,7 +4612,7 @@ case OP_SortMakeKey: {
|
|||||||
nByte += aStack[i].n+2;
|
nByte += aStack[i].n+2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
zNewKey = sqliteMalloc( nByte );
|
zNewKey = sqliteMallocRaw( nByte );
|
||||||
if( zNewKey==0 ) goto no_mem;
|
if( zNewKey==0 ) goto no_mem;
|
||||||
j = 0;
|
j = 0;
|
||||||
k = 0;
|
k = 0;
|
||||||
@@ -4942,7 +4941,7 @@ case OP_MemStore: {
|
|||||||
if( (flags & STK_Static)!=0 || (pOp->p2 && (flags & STK_Dyn)!=0) ){
|
if( (flags & STK_Static)!=0 || (pOp->p2 && (flags & STK_Dyn)!=0) ){
|
||||||
pMem->z = zStack[tos];
|
pMem->z = zStack[tos];
|
||||||
}else if( flags & STK_Str ){
|
}else if( flags & STK_Str ){
|
||||||
pMem->z = sqliteMalloc( pMem->s.n );
|
pMem->z = sqliteMallocRaw( pMem->s.n );
|
||||||
if( pMem->z==0 ) goto no_mem;
|
if( pMem->z==0 ) goto no_mem;
|
||||||
memcpy(pMem->z, zStack[tos], pMem->s.n);
|
memcpy(pMem->z, zStack[tos], pMem->s.n);
|
||||||
pMem->s.flags |= STK_Dyn;
|
pMem->s.flags |= STK_Dyn;
|
||||||
|
Reference in New Issue
Block a user