1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-07 02:42:48 +03:00

Modify sources to that they can be combined into a single sqlite3.c source

file.  Eliminate all type-pruned pointer warnings. (CVS 3722)

FossilOrigin-Name: 0b832e218ec12b0eb559e407d80aba6709e2ea85
This commit is contained in:
drh
2007-03-26 22:05:01 +00:00
parent 45068f4b5c
commit 4f0c587819
24 changed files with 301 additions and 287 deletions

View File

@@ -248,7 +248,7 @@ objects: $(LIBOBJ_ORIG)
target_source: $(SRC)
rm -rf tsrc
mkdir tsrc
cp $(SRC) tsrc
cp $(SRC) $(TOP)/src/*.h tsrc
rm tsrc/sqlite.h.in tsrc/parse.y
# Rules to build the LEMON compiler generator

View File

@@ -1,5 +1,5 @@
C Set\sthe\ssame\srandom\sseed\sfor\sthe\sspeed\stests.\s(CVS\s3721)
D 2007-03-26T16:30:16
C Modify\ssources\sto\sthat\sthey\scan\sbe\scombined\sinto\sa\ssingle\ssqlite3.c\ssource\nfile.\s\sEliminate\sall\stype-pruned\spointer\swarnings.\s(CVS\s3722)
D 2007-03-26T22:05:01
F Makefile.in 1fe3d0b46e40fd684e1e61f8e8056cefed16de9f
F Makefile.linux-gcc 2d8574d1ba75f129aba2019f0b959db380a90935
F README 9c4e2d6706bdcc3efdd773ce752a8cdab4f90028
@@ -43,7 +43,7 @@ F ext/fts2/fts2_tokenizer.h 4c5ffe31d63622869eb6eec1503df7f6996fd1bd
F ext/fts2/fts2_tokenizer1.c 6067f2f710bc7e91c0688b7b11be1027777553e0
F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895
F ltmain.sh 56abb507100ed2d4261f6dd1653dec3cf4066387
F main.mk 0347b7c277fab2aa579a8d84f3ba975407e8fba4
F main.mk f91734b3f783589fd617e73e00e847ad9f04b636
F mkdll.sh cbc7d92d02f9317a3d24ab55bb727275417260ca
F mkopcodec.awk bd46ad001c98dfbab07b1713cb8e692fa0e5415d
F mkopcodeh.awk cde995d269aa06c94adbf6455bea0acedb913fa5
@@ -58,15 +58,15 @@ F src/alter.c 2c79ec40f65e33deaf90ca493422c74586e481a3
F src/analyze.c 7d2b7ab9a9c2fd6e55700f69064dfdd3e36d7a8a
F src/attach.c 9b5a9c50fb92883e3404353b225674142da826cd
F src/auth.c 902f4722661c796b97f007d9606bd7529c02597f
F src/btree.c 4d94251b59fa33c888efc43881729f7d297899a4
F src/btree.c 0659070eb438bae32cec8afebe6d8d390024d952
F src/btree.h 066444ee25bd6e6accb997bfd2cf5ace14dbcd00
F src/build.c f2edc786b5bf165a7d0949ed3a5872455a610c0e
F src/build.c fe2fcebc9232a7dec77d7602a41c0d3bc2e7fa5d
F src/callback.c 31d22b4919c7645cbcbb1591ce2453e8c677c558
F src/complete.c 7d1a44be8f37de125fcafd3d3a018690b3799675
F src/date.c 393c73fc027597e008dcd81454544659e978b05c
F src/delete.c 151d08386bf9c9e7f92f6b9106c71efec2def184
F src/experimental.c 1b2d1a6cd62ecc39610e97670332ca073c50792b
F src/expr.c b5c65202c7ada4b1ec24f0f010bb73c92ab44e6d
F src/expr.c 971dd206ec0fa82d9fd1abb587a40df226f98966
F src/func.c 94372fe3cf26b81d4dcdc15f98ff240c37c8c708
F src/hash.c 449f3d6620193aa557f5d86cbc5cc6b87702b185
F src/hash.h 1b3f7e2609141fd571f62199fc38687d262e9564
@@ -77,20 +77,20 @@ F src/main.c af8922e0205cf618392de2836c9efad71786d0d6
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/os.c 6df3e9c23eaa982d3e66ef770ad2519de5dd4d97
F src/os.h ec780b3561d0bb887d13f193a1a889872c44a236
F src/os_common.h fdccdbedd7e13ef4cb7f9e33484244a27a6b4c4e
F src/os_os2.c de7e1660c72493e177424dddf5130d70fb711752
F src/os_common.h c86e8cbd6150ca06d46b09ec02ff5fc5d4b05285
F src/os_os2.c cb2c4f6d28810b5cee682d8df92352464d5c9d95
F src/os_os2.h e5f17dd69333632bbc3112881ea407c37d245eb3
F src/os_test.c 49833426101f99aee4bb5f6a44b7c4b2029fda1c
F src/os_test.h 903c93554c23d88f34f667f1979e4a1cee792af3
F src/os_unix.c 4642f23ed0c1ae0f1440db1d2b4231348af69360
F src/os_unix.c 1f32d15449caa02ada876a0e5b7b774d90e1be77
F src/os_unix.h 5768d56d28240d3fe4537fac08cc85e4fb52279e
F src/os_win.c 1d1d0989b0f235751504292c2f28e81044be0d70
F src/os_win.c 13708a58aa24a9960fa45ac4a681e34f881ae77c
F src/os_win.h 41a946bea10f61c158ce8645e7646b29d44f122b
F src/pager.c d5fc7caffe5db2e82296a9f888b3bc8bbd11e25d
F src/pager.c f40ac7af27f3494e5c82807d09a7e23d741aaf75
F src/pager.h 3c16500c25051536e43fb19e246e58fc7cb51d9f
F src/parse.y bcfe366c1fd61cfc40e5344eb69a31997a821af0
F src/pragma.c 9cb8b94e7d38ba35a86037bd517d07ba9870b4b2
F src/prepare.c 4e075fe28591b7d4ffbf818fb88a7e19bbe98065
F src/prepare.c 37207b2b2ccb41d379b01dd62231686bcc48ef1f
F src/printf.c aade23a789d7cc88b397ec0d33a0a01a33a7a9c1
F src/random.c 6119474a6f6917f708c1dee25b9a8e519a620e88
F src/select.c 4d68a0d7f98fb59bcedd0be69750e0445b05899c
@@ -98,18 +98,18 @@ F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c 3ae4654560e91220a95738a73d135d91d937cda1
F src/sqlite.h.in 6b7383baf76070214f6381f603328ca9b22a7fae
F src/sqlite3ext.h 832e13de075d920e2c76584e2b7af1054bb212df
F src/sqliteInt.h 5451308c885e8620e0d4764ae162da2566520073
F src/sqliteInt.h 86ab83dddf32325d8f2afd92575d8e0168ecb8c2
F src/table.c 6d0da66dde26ee75614ed8f584a1996467088d06
F src/tclsqlite.c cd2b3b86ab07c0e0779f6c6e71e72c6c7dc1e704
F src/test1.c b4ff8f82f84d2ccdf07a2db5acae7b47c12f60d7
F src/test1.c 7c8f2786dbd55bab35c7529045a3d72f54c7f98b
F src/test2.c dc48c84ce68b3bc2f2d01871d709f20dc77003b0
F src/test3.c f78f1d83d8c50926fa080abbf8769b9d47ed623e
F src/test3.c b40ca2eb1390a4c5a41bc8c545284a32aca69991
F src/test4.c 8b784cd82de158a2317cb4ac4bc86f91ad315e25
F src/test5.c 7162f8526affb771c4ed256826eee7bb9eca265f
F src/test6.c 5957d249d437e4db74045ce2f1f661648d94bf94
F src/test7.c 03fa8d787f6aebc6d1f72504d52f33013ad2c8e3
F src/test8.c 628ec89f9fbf3bfb9c58a503d845a0719595d0ad
F src/test_async.c aca980c04fcd23544e90fb1026d31b3f85185057
F src/test_async.c 9d326ceda4306bcab252b8f7e8e480ed45d7ccb6
F src/test_autoext.c 855157d97aa28cf84233847548bfacda21807436
F src/test_loadext.c 22065d601a18878e5542191001f0eaa5d77c0ed8
F src/test_md5.c 6c42bc0a3c0b54be34623ff77a0eec32b2fa96e3
@@ -120,17 +120,17 @@ F src/tokenize.c bb1732ef2b6fc2143f93ff28a45d3dcb04c1d396
F src/trigger.c 8c55d31876013ed4e97ee7ce24478fbe00db49bb
F src/update.c 876b3142b8db9ce6ddf8374a2ced65e576acabc7
F src/utf.c 67ecb1032bc0b42c105e88d65ef9d9f626eb0e1f
F src/util.c f6d739fc25026cecb59ac98344a1f12fcbee074f
F src/util.c 729a528fc35e858d33e270676d6a61b3eff525d4
F src/vacuum.c 327c6ffa38935163db7c1e256ff5f788e901b318
F src/vdbe.c 19e244e554e5df3f49d4e15233527753fadbcc4d
F src/vdbe.c df2aa8cf692eeffd4027a2a8ec71aa0248a13e87
F src/vdbe.h 0025259af1939fb264a545816c69e4b5b8d52691
F src/vdbeInt.h 13ba07121cf534d5b80130d2f5eb0a4937a36bba
F src/vdbeapi.c 2d1e6843af8705a1172e54a418d2a3d5febd1dd7
F src/vdbeaux.c 666f0753f7d70b6a092c7f2074ae8cf1f9755cfc
F src/vdbefifo.c 9efb94c8c3f4c979ebd0028219483f88e57584f5
F src/vdbemem.c ff2424bee9eaf7c61d1f28bc0e711bebddebd653
F src/vdbeInt.h b2ca85ca8abfbba86e380b06c7673dc81c6784c3
F src/vdbeapi.c 6cff63a5b3a52af04b2bef0f7e27ed7ea6f85183
F src/vdbeaux.c b196911da933c66df287fd4b1498a2d2ef5daa93
F src/vdbefifo.c 3ca8049c561d5d67cbcb94dc909ae9bb68c0bf8f
F src/vdbemem.c 58a8be2231b0b13e2e77098debe173e79d22f791
F src/vtab.c 7fbda947e28cbe7adb3ba752a76ca9ef29936750
F src/where.c 1242dd545ffa7be8b2f539984d5f458ec731a937
F src/where.c 0825fabc1a185af1567dc82e63683cd9b47d9e22
F tclinstaller.tcl 046e3624671962dc50f0481d7c25b38ef803eb42
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
F test/all.test 7da67663cb5af0c95ecd4805d888459023fb8cfd
@@ -441,7 +441,7 @@ F www/tclsqlite.tcl bb0d1357328a42b1993d78573e587c6dcbc964b9
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl 97e2b5cd296f7d8057e11f44427dea8a4c2db513
P 9ebba469023723652c4dbba3d9982a64a1fb144f
R 4f9a6299d562fcef1dac77609454085b
P 8fe317054982969ad539cdbf1b996b97d86ec4f2
R c60b5a581f8ad645c254d239aa450c65
U drh
Z 20ca486e31ef83b440eceaa1aeb2c1c7
Z d6b37215b7fed9fea082ff01114bbc2c

View File

@@ -1 +1 @@
8fe317054982969ad539cdbf1b996b97d86ec4f2
0b832e218ec12b0eb559e407d80aba6709e2ea85

View File

@@ -9,7 +9,7 @@
** May you share freely, never taking more than you give.
**
*************************************************************************
** $Id: btree.c,v 1.341 2007/03/19 17:44:27 danielk1977 Exp $
** $Id: btree.c,v 1.342 2007/03/26 22:05:01 drh Exp $
**
** This file implements a external (disk-based) database using BTrees.
** For a detailed discussion of BTrees, refer to
@@ -2269,7 +2269,7 @@ static int relocatePage(
}
/* Forward declaration required by autoVacuumCommit(). */
static int allocatePage(BtShared *, MemPage **, Pgno *, Pgno, u8);
static int allocateBtreePage(BtShared *, MemPage **, Pgno *, Pgno, u8);
/*
** This routine is called prior to sqlite3PagerCommit when a transaction
@@ -2359,14 +2359,14 @@ static int autoVacuumCommit(BtShared *pBt, Pgno *nTrunc){
/* Find the next page in the free-list that is not already at the end
** of the file. A page can be pulled off the free list using the
** allocatePage() routine.
** allocateBtreePage() routine.
*/
do{
if( pFreeMemPage ){
releasePage(pFreeMemPage);
pFreeMemPage = 0;
}
rc = allocatePage(pBt, &pFreeMemPage, &iFreePage, 0, 0);
rc = allocateBtreePage(pBt, &pFreeMemPage, &iFreePage, 0, 0);
if( rc!=SQLITE_OK ){
releasePage(pDbMemPage);
goto autovacuum_out;
@@ -3567,7 +3567,7 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){
** anywhere on the free-list, then it is guarenteed to be returned. This
** is only used by auto-vacuum databases when allocating a new table.
*/
static int allocatePage(
static int allocateBtreePage(
BtShared *pBt,
MemPage **ppPage,
Pgno *pPgno,
@@ -3974,7 +3974,7 @@ static int fillInCell(
#ifndef SQLITE_OMIT_AUTOVACUUM
Pgno pgnoPtrmap = pgnoOvfl; /* Overflow page pointer-map entry page */
#endif
rc = allocatePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);
rc = allocateBtreePage(pBt, &pOvfl, &pgnoOvfl, pgnoOvfl, 0);
#ifndef SQLITE_OMIT_AUTOVACUUM
/* If the database supports auto-vacuum, and the second or subsequent
** overflow page is being allocated, add an entry to the pointer-map
@@ -4306,7 +4306,7 @@ static int balance_quick(MemPage *pPage, MemPage *pParent){
/* Allocate a new page. Insert the overflow cell from pPage
** into it. Then remove the overflow cell from pPage.
*/
rc = allocatePage(pBt, &pNew, &pgnoNew, 0, 0);
rc = allocateBtreePage(pBt, &pNew, &pgnoNew, 0, 0);
if( rc!=SQLITE_OK ){
return rc;
}
@@ -4750,7 +4750,7 @@ static int balance_nonroot(MemPage *pPage){
if( rc ) goto balance_cleanup;
}else{
assert( i>0 );
rc = allocatePage(pBt, &pNew, &pgnoNew[i], pgnoNew[i-1], 0);
rc = allocateBtreePage(pBt, &pNew, &pgnoNew[i], pgnoNew[i-1], 0);
if( rc ) goto balance_cleanup;
apNew[i] = pNew;
}
@@ -5071,7 +5071,7 @@ static int balance_deeper(MemPage *pPage){
assert( pPage->pParent==0 );
assert( pPage->nOverflow>0 );
pBt = pPage->pBt;
rc = allocatePage(pBt, &pChild, &pgnoChild, pPage->pgno, 0);
rc = allocateBtreePage(pBt, &pChild, &pgnoChild, pPage->pgno, 0);
if( rc ) return rc;
assert( sqlite3PagerIswriteable(pChild->pDbPage) );
usableSize = pBt->usableSize;
@@ -5407,7 +5407,7 @@ int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
}
#ifdef SQLITE_OMIT_AUTOVACUUM
rc = allocatePage(pBt, &pRoot, &pgnoRoot, 1, 0);
rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);
if( rc ) return rc;
#else
if( pBt->autoVacuum ){
@@ -5435,7 +5435,7 @@ int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
** be moved to the allocated page (unless the allocated page happens
** to reside at pgnoRoot).
*/
rc = allocatePage(pBt, &pPageMove, &pgnoMove, pgnoRoot, 1);
rc = allocateBtreePage(pBt, &pPageMove, &pgnoMove, pgnoRoot, 1);
if( rc!=SQLITE_OK ){
return rc;
}
@@ -5492,7 +5492,7 @@ int sqlite3BtreeCreateTable(Btree *p, int *piTable, int flags){
}
}else{
rc = allocatePage(pBt, &pRoot, &pgnoRoot, 1, 0);
rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);
if( rc ) return rc;
}
#endif

View File

@@ -22,7 +22,7 @@
** COMMIT
** ROLLBACK
**
** $Id: build.c,v 1.415 2007/03/17 10:26:59 danielk1977 Exp $
** $Id: build.c,v 1.416 2007/03/26 22:05:01 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -82,7 +82,7 @@ void sqlite3TableLock(
}
nBytes = sizeof(TableLock) * (pParse->nTableLock+1);
sqliteReallocOrFree((void **)&pParse->aTableLock, nBytes);
sqliteReallocOrFree(&pParse->aTableLock, nBytes);
if( pParse->aTableLock ){
p = &pParse->aTableLock[pParse->nTableLock++];
p->iDb = iDb;
@@ -2804,21 +2804,22 @@ exit_drop_index:
** szEntry is the sizeof of a single array entry. initSize is the
** number of array entries allocated on the initial allocation.
*/
int sqlite3ArrayAllocate(void **ppArray, int szEntry, int initSize){
int sqlite3ArrayAllocate(void *ppArray, int szEntry, int initSize){
char *p;
int *an = (int*)&ppArray[1];
void **pp = (void**)ppArray;
int *an = (int*)&pp[1];
if( an[0]>=an[1] ){
void *pNew;
int newSize;
newSize = an[1]*2 + initSize;
pNew = sqliteRealloc(*ppArray, newSize*szEntry);
pNew = sqliteRealloc(*pp, newSize*szEntry);
if( pNew==0 ){
return -1;
}
an[1] = newSize;
*ppArray = pNew;
*pp = pNew;
}
p = *ppArray;
p = *pp;
memset(&p[an[0]*szEntry], 0, szEntry);
return an[0]++;
}
@@ -2836,7 +2837,7 @@ IdList *sqlite3IdListAppend(IdList *pList, Token *pToken){
if( pList==0 ) return 0;
pList->nAlloc = 0;
}
i = sqlite3ArrayAllocate((void**)&pList->a, sizeof(pList->a[0]), 5);
i = sqlite3ArrayAllocate(&pList->a, sizeof(pList->a[0]), 5);
if( i<0 ){
sqlite3IdListDelete(pList);
return 0;

View File

@@ -12,7 +12,7 @@
** This file contains routines used for analyzing expressions and
** for generating VDBE code that evaluates expressions in SQLite.
**
** $Id: expr.c,v 1.281 2007/03/12 23:48:53 drh Exp $
** $Id: expr.c,v 1.282 2007/03/26 22:05:01 drh Exp $
*/
#include "sqliteInt.h"
#include <ctype.h>
@@ -404,7 +404,7 @@ void sqlite3ExprAssignVarNumber(Parse *pParse, Expr *pExpr){
pExpr->iTable = ++pParse->nVar;
if( pParse->nVarExpr>=pParse->nVarExprAlloc-1 ){
pParse->nVarExprAlloc += pParse->nVarExprAlloc + 10;
sqliteReallocOrFree((void**)&pParse->apVarExpr,
sqliteReallocOrFree(&pParse->apVarExpr,
pParse->nVarExprAlloc*sizeof(pParse->apVarExpr[0]) );
}
if( !sqlite3MallocFailed() ){
@@ -2237,7 +2237,7 @@ int sqlite3ExprCompare(Expr *pA, Expr *pB){
*/
static int addAggInfoColumn(AggInfo *pInfo){
int i;
i = sqlite3ArrayAllocate((void**)&pInfo->aCol, sizeof(pInfo->aCol[0]), 3);
i = sqlite3ArrayAllocate(&pInfo->aCol, sizeof(pInfo->aCol[0]), 3);
if( i<0 ){
return -1;
}
@@ -2250,7 +2250,7 @@ static int addAggInfoColumn(AggInfo *pInfo){
*/
static int addAggInfoFunc(AggInfo *pInfo){
int i;
i = sqlite3ArrayAllocate((void**)&pInfo->aFunc, sizeof(pInfo->aFunc[0]), 2);
i = sqlite3ArrayAllocate(&pInfo->aFunc, sizeof(pInfo->aFunc[0]), 2);
if( i<0 ){
return -1;
}

View File

@@ -40,23 +40,24 @@ int sqlite3_os_trace = 0;
#ifdef SQLITE_DEBUG
static int last_page = 0;
#define SEEK(X) last_page=(X)
#define TRACE1(X) if( sqlite3_os_trace ) sqlite3DebugPrintf(X)
#define TRACE2(X,Y) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y)
#define TRACE3(X,Y,Z) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z)
#define TRACE4(X,Y,Z,A) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A)
#define TRACE5(X,Y,Z,A,B) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A,B)
#define TRACE6(X,Y,Z,A,B,C) if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C)
#define TRACE7(X,Y,Z,A,B,C,D) \
#define OSTRACE1(X) if( sqlite3_os_trace ) sqlite3DebugPrintf(X)
#define OSTRACE2(X,Y) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y)
#define OSTRACE3(X,Y,Z) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z)
#define OSTRACE4(X,Y,Z,A) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A)
#define OSTRACE5(X,Y,Z,A,B) if( sqlite3_os_trace ) sqlite3DebugPrintf(X,Y,Z,A,B)
#define OSTRACE6(X,Y,Z,A,B,C) \
if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C)
#define OSTRACE7(X,Y,Z,A,B,C,D) \
if(sqlite3_os_trace) sqlite3DebugPrintf(X,Y,Z,A,B,C,D)
#else
#define SEEK(X)
#define TRACE1(X)
#define TRACE2(X,Y)
#define TRACE3(X,Y,Z)
#define TRACE4(X,Y,Z,A)
#define TRACE5(X,Y,Z,A,B)
#define TRACE6(X,Y,Z,A,B,C)
#define TRACE7(X,Y,Z,A,B,C,D)
#define OSTRACE1(X)
#define OSTRACE2(X,Y)
#define OSTRACE3(X,Y,Z)
#define OSTRACE4(X,Y,Z,A)
#define OSTRACE5(X,Y,Z,A,B)
#define OSTRACE6(X,Y,Z,A,B,C)
#define OSTRACE7(X,Y,Z,A,B,C,D)
#endif
/*
@@ -197,4 +198,3 @@ int sqlite3GenericAllocationSize(void *p){ return 0; }
#ifndef PAGER_SECTOR_SIZE
# define PAGER_SECTOR_SIZE 512
#endif

View File

@@ -62,7 +62,7 @@ int sqlite3Os2Delete( const char *zFilename ){
APIRET rc = NO_ERROR;
rc = DosDelete( (PSZ)zFilename );
TRACE2( "DELETE \"%s\"\n", zFilename );
OSTRACE2( "DELETE \"%s\"\n", zFilename );
return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR;
}
@@ -127,7 +127,7 @@ int sqlite3Os2OpenReadWrite(
f.delOnClose = 0;
f.pathToDel = NULL;
OpenCounter(+1);
TRACE3( "OPEN R/W %d \"%s\"\n", hf, zFilename );
OSTRACE3( "OPEN R/W %d \"%s\"\n", hf, zFilename );
return allocateOs2File( &f, pld );
}
@@ -167,7 +167,7 @@ int sqlite3Os2OpenExclusive( const char *zFilename, OsFile **pld, int delFlag ){
f.pathToDel = delFlag ? sqlite3OsFullPathname( zFilename ) : NULL;
OpenCounter( +1 );
if( delFlag ) DosForceDelete( sqlite3OsFullPathname( zFilename ) );
TRACE3( "OPEN EX %d \"%s\"\n", hf, sqlite3OsFullPathname ( zFilename ) );
OSTRACE3( "OPEN EX %d \"%s\"\n", hf, sqlite3OsFullPathname ( zFilename ) );
return allocateOs2File( &f, pld );
}
@@ -197,7 +197,7 @@ int sqlite3Os2OpenReadOnly( const char *zFilename, OsFile **pld ){
f.delOnClose = 0;
f.pathToDel = NULL;
OpenCounter( +1 );
TRACE3( "OPEN RO %d \"%s\"\n", hf, zFilename );
OSTRACE3( "OPEN RO %d \"%s\"\n", hf, zFilename );
return allocateOs2File( &f, pld );
}
@@ -261,7 +261,7 @@ int sqlite3Os2TempFileName( char *zBuf ){
zBuf[j] = 0;
if( !sqlite3OsFileExists( zBuf ) ) break;
}
TRACE2( "TEMP FILENAME: %s\n", zBuf );
OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
return SQLITE_OK;
}
@@ -272,7 +272,7 @@ int os2Close( OsFile **pld ){
os2File *pFile;
APIRET rc = NO_ERROR;
if( pld && (pFile = (os2File*)*pld) != 0 ){
TRACE2( "CLOSE %d\n", pFile->h );
OSTRACE2( "CLOSE %d\n", pFile->h );
rc = DosClose( pFile->h );
pFile->locktype = NO_LOCK;
if( pFile->delOnClose != 0 ){
@@ -294,7 +294,7 @@ int os2Read( OsFile *id, void *pBuf, int amt ){
ULONG got;
assert( id!=0 );
SimulateIOError( return SQLITE_IOERR );
TRACE3( "READ %d lock=%d\n", ((os2File*)id)->h, ((os2File*)id)->locktype );
OSTRACE3( "READ %d lock=%d\n", ((os2File*)id)->h, ((os2File*)id)->locktype );
DosRead( ((os2File*)id)->h, pBuf, amt, &got );
if (got == (ULONG)amt)
return SQLITE_OK;
@@ -316,7 +316,7 @@ int os2Write( OsFile *id, const void *pBuf, int amt ){
assert( id!=0 );
SimulateIOError( return SQLITE_IOERR );
SimulateDiskfullError( return SQLITE_FULL );
TRACE3( "WRITE %d lock=%d\n", ((os2File*)id)->h, ((os2File*)id)->locktype );
OSTRACE3( "WRITE %d lock=%d\n", ((os2File*)id)->h, ((os2File*)id)->locktype );
while( amt > 0 &&
(rc = DosWrite( ((os2File*)id)->h, (PVOID)pBuf, amt, &wrote )) && wrote > 0 ){
amt -= wrote;
@@ -334,7 +334,7 @@ int os2Seek( OsFile *id, i64 offset ){
ULONG filePointer = 0L;
assert( id!=0 );
rc = DosSetFilePtr( ((os2File*)id)->h, offset, FILE_BEGIN, &filePointer );
TRACE3( "SEEK %d %lld\n", ((os2File*)id)->h, offset );
OSTRACE3( "SEEK %d %lld\n", ((os2File*)id)->h, offset );
return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR;
}
@@ -343,7 +343,7 @@ int os2Seek( OsFile *id, i64 offset ){
*/
int os2Sync( OsFile *id, int dataOnly ){
assert( id!=0 );
TRACE3( "SYNC %d lock=%d\n", ((os2File*)id)->h, ((os2File*)id)->locktype );
OSTRACE3( "SYNC %d lock=%d\n", ((os2File*)id)->h, ((os2File*)id)->locktype );
return DosResetBuffer( ((os2File*)id)->h ) == NO_ERROR ? SQLITE_OK : SQLITE_IOERR;
}
@@ -363,7 +363,7 @@ int os2Truncate( OsFile *id, i64 nByte ){
APIRET rc = NO_ERROR;
ULONG upperBits = nByte>>32;
assert( id!=0 );
TRACE3( "TRUNCATE %d %lld\n", ((os2File*)id)->h, nByte );
OSTRACE3( "TRUNCATE %d %lld\n", ((os2File*)id)->h, nByte );
SimulateIOError( return SQLITE_IOERR );
rc = DosSetFilePtr( ((os2File*)id)->h, nByte, FILE_BEGIN, &upperBits );
if( rc != NO_ERROR ){
@@ -478,7 +478,7 @@ int os2Lock( OsFile *id, int locktype ){
memset(&LockArea, 0, sizeof(LockArea));
memset(&UnlockArea, 0, sizeof(UnlockArea));
assert( pFile!=0 );
TRACE4( "LOCK %d %d was %d\n", pFile->h, locktype, pFile->locktype );
OSTRACE4( "LOCK %d %d was %d\n", pFile->h, locktype, pFile->locktype );
/* If there is already a lock of this type or more restrictive on the
** OsFile, do nothing. Don't use the end_lock: exit path, as
@@ -513,7 +513,7 @@ int os2Lock( OsFile *id, int locktype ){
/* Try 3 times to get the pending lock. The pending lock might be
** held by another reader process who will release it momentarily.
*/
TRACE2( "could not get a PENDING lock. cnt=%d\n", cnt );
OSTRACE2( "could not get a PENDING lock. cnt=%d\n", cnt );
DosSleep(1);
}
gotPendingLock = res;
@@ -555,7 +555,7 @@ int os2Lock( OsFile *id, int locktype ){
if( locktype==EXCLUSIVE_LOCK && res ){
assert( pFile->locktype>=SHARED_LOCK );
res = unlockReadLock(pFile);
TRACE2( "unreadlock = %d\n", res );
OSTRACE2( "unreadlock = %d\n", res );
LockArea.lOffset = SHARED_FIRST;
LockArea.lRange = SHARED_SIZE;
UnlockArea.lOffset = 0L;
@@ -564,7 +564,7 @@ int os2Lock( OsFile *id, int locktype ){
if( res == NO_ERROR ){
newLocktype = EXCLUSIVE_LOCK;
}else{
TRACE2( "error-code = %d\n", res );
OSTRACE2( "error-code = %d\n", res );
}
}
@@ -585,7 +585,7 @@ int os2Lock( OsFile *id, int locktype ){
if( res == NO_ERROR ){
rc = SQLITE_OK;
}else{
TRACE4( "LOCK FAILED %d trying for %d but got %d\n", pFile->h,
OSTRACE4( "LOCK FAILED %d trying for %d but got %d\n", pFile->h,
locktype, newLocktype );
rc = SQLITE_BUSY;
}
@@ -604,7 +604,7 @@ int os2CheckReservedLock( OsFile *id ){
assert( pFile!=0 );
if( pFile->locktype>=RESERVED_LOCK ){
rc = 1;
TRACE3( "TEST WR-LOCK %d %d (local)\n", pFile->h, rc );
OSTRACE3( "TEST WR-LOCK %d %d (local)\n", pFile->h, rc );
}else{
FILELOCK LockArea,
UnlockArea;
@@ -622,7 +622,7 @@ int os2CheckReservedLock( OsFile *id ){
UnlockArea.lRange = 1L;
rc = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, 2000L, 1L );
}
TRACE3( "TEST WR-LOCK %d %d (remote)\n", pFile->h, rc );
OSTRACE3( "TEST WR-LOCK %d %d (remote)\n", pFile->h, rc );
}
return rc;
}
@@ -648,7 +648,7 @@ int os2Unlock( OsFile *id, int locktype ){
memset(&UnlockArea, 0, sizeof(UnlockArea));
assert( pFile!=0 );
assert( locktype<=SHARED_LOCK );
TRACE4( "UNLOCK %d to %d was %d\n", pFile->h, locktype, pFile->locktype );
OSTRACE4( "UNLOCK %d to %d was %d\n", pFile->h, locktype, pFile->locktype );
type = pFile->locktype;
if( type>=EXCLUSIVE_LOCK ){
LockArea.lOffset = 0L;

View File

@@ -753,19 +753,20 @@ static int transferOwnership(unixFile *pFile){
hSelf = pthread_self();
if( pthread_equal(pFile->tid, hSelf) ){
/* We are still in the same thread */
TRACE1("No-transfer, same thread\n");
OSTRACE1("No-transfer, same thread\n");
return SQLITE_OK;
}
if( pFile->locktype!=NO_LOCK ){
/* We cannot change ownership while we are holding a lock! */
return SQLITE_MISUSE;
}
TRACE4("Transfer ownership of %d from %d to %d\n", pFile->h,pFile->tid,hSelf);
OSTRACE4("Transfer ownership of %d from %d to %d\n",
pFile->h, pFile->tid, hSelf);
pFile->tid = hSelf;
if (pFile->pLock != NULL) {
releaseLockInfo(pFile->pLock);
rc = findLockInfo(pFile->h, &pFile->pLock, 0);
TRACE5("LOCK %d is now %s(%s,%d)\n", pFile->h,
OSTRACE5("LOCK %d is now %s(%s,%d)\n", pFile->h,
locktypeName(pFile->locktype),
locktypeName(pFile->pLock->locktype), pFile->pLock->cnt);
return rc;
@@ -925,7 +926,7 @@ static int unixOpenDirectory(
if( pFile->dirfd<0 ){
return SQLITE_CANTOPEN;
}
TRACE3("OPENDIR %-3d %s\n", pFile->dirfd, zDirname);
OSTRACE3("OPENDIR %-3d %s\n", pFile->dirfd, zDirname);
return SQLITE_OK;
}
@@ -1014,7 +1015,7 @@ static int seekAndRead(unixFile *id, void *pBuf, int cnt){
got = read(id->h, pBuf, cnt);
#endif
TIMER_END;
TRACE5("READ %-3d %5d %7lld %d\n", id->h, got, id->offset, TIMER_ELAPSED);
OSTRACE5("READ %-3d %5d %7lld %d\n", id->h, got, id->offset, TIMER_ELAPSED);
if( got>0 ){
id->offset += got;
}
@@ -1061,7 +1062,7 @@ static int seekAndWrite(unixFile *id, const void *pBuf, int cnt){
got = write(id->h, pBuf, cnt);
#endif
TIMER_END;
TRACE5("WRITE %-3d %5d %7lld %d\n", id->h, got, id->offset, TIMER_ELAPSED);
OSTRACE5("WRITE %-3d %5d %7lld %d\n", id->h, got, id->offset, TIMER_ELAPSED);
if( got>0 ){
id->offset += got;
}
@@ -1211,14 +1212,14 @@ static int unixSync(OsFile *id, int dataOnly){
int rc;
unixFile *pFile = (unixFile*)id;
assert( pFile );
TRACE2("SYNC %-3d\n", pFile->h);
OSTRACE2("SYNC %-3d\n", pFile->h);
rc = full_fsync(pFile->h, pFile->fullSync, dataOnly);
SimulateIOError( rc=1 );
if( rc ){
return SQLITE_IOERR_FSYNC;
}
if( pFile->dirfd>=0 ){
TRACE4("DIRSYNC %-3d (have_fullfsync=%d fullsync=%d)\n", pFile->dirfd,
OSTRACE4("DIRSYNC %-3d (have_fullfsync=%d fullsync=%d)\n", pFile->dirfd,
HAVE_FULLFSYNC, pFile->fullSync);
#ifndef SQLITE_DISABLE_DIRSYNC
/* The directory sync is only attempted if full_fsync is
@@ -1256,7 +1257,7 @@ int sqlite3UnixSyncDirectory(const char *zDirname){
int fd;
int r;
fd = open(zDirname, O_RDONLY|O_BINARY, 0);
TRACE3("DIRSYNC %-3d (%s)\n", fd, zDirname);
OSTRACE3("DIRSYNC %-3d (%s)\n", fd, zDirname);
if( fd<0 ){
return SQLITE_CANTOPEN;
}
@@ -1335,7 +1336,7 @@ static int unixCheckReservedLock(OsFile *id){
}
sqlite3OsLeaveMutex();
TRACE3("TEST WR-LOCK %d %d\n", pFile->h, r);
OSTRACE3("TEST WR-LOCK %d %d\n", pFile->h, r);
return r;
}
@@ -1410,7 +1411,7 @@ static int unixLock(OsFile *id, int locktype){
int s;
assert( pFile );
TRACE7("LOCK %d %s was %s(%s,%d) pid=%d\n", pFile->h,
OSTRACE7("LOCK %d %s was %s(%s,%d) pid=%d\n", pFile->h,
locktypeName(locktype), locktypeName(pFile->locktype),
locktypeName(pLock->locktype), pLock->cnt , getpid());
@@ -1419,7 +1420,7 @@ static int unixLock(OsFile *id, int locktype){
** sqlite3OsEnterMutex() hasn't been called yet.
*/
if( pFile->locktype>=locktype ){
TRACE3("LOCK %d %s ok (already held)\n", pFile->h,
OSTRACE3("LOCK %d %s ok (already held)\n", pFile->h,
locktypeName(locktype));
return SQLITE_OK;
}
@@ -1554,7 +1555,7 @@ static int unixLock(OsFile *id, int locktype){
end_lock:
sqlite3OsLeaveMutex();
TRACE4("LOCK %d %s %s\n", pFile->h, locktypeName(locktype),
OSTRACE4("LOCK %d %s %s\n", pFile->h, locktypeName(locktype),
rc==SQLITE_OK ? "ok" : "failed");
return rc;
}
@@ -1573,7 +1574,7 @@ static int unixUnlock(OsFile *id, int locktype){
unixFile *pFile = (unixFile*)id;
assert( pFile );
TRACE7("UNLOCK %d %d was %d(%d,%d) pid=%d\n", pFile->h, locktype,
OSTRACE7("UNLOCK %d %d was %d(%d,%d) pid=%d\n", pFile->h, locktype,
pFile->locktype, pFile->pLock->locktype, pFile->pLock->cnt, getpid());
assert( locktype<=SHARED_LOCK );
@@ -1686,7 +1687,7 @@ static int unixClose(OsFile **pId){
sqlite3OsLeaveMutex();
id->isOpen = 0;
TRACE2("CLOSE %-3d\n", id->h);
OSTRACE2("CLOSE %-3d\n", id->h);
OpenCounter(-1);
sqlite3ThreadSafeFree(id);
*pId = 0;
@@ -1733,11 +1734,11 @@ static int _AFPFSSetLock(const char *path, int fd, unsigned long long offset,
pb.offset = offset;
pb.length = length;
pb.fd = fd;
TRACE5("AFPLOCK setting lock %s for %d in range %llx:%llx\n",
OSTRACE5("AFPLOCK setting lock %s for %d in range %llx:%llx\n",
(setLockFlag?"ON":"OFF"), fd, offset, length);
err = fsctl(path, afpfsByteRangeLock2FSCTL, &pb, 0);
if ( err==-1 ) {
TRACE4("AFPLOCK failed to fsctl() '%s' %d %s\n", path, errno,
OSTRACE4("AFPLOCK failed to fsctl() '%s' %d %s\n", path, errno,
strerror(errno));
return 1; // error
} else {
@@ -1777,7 +1778,7 @@ static int afpUnixCheckReservedLock(OsFile *id){
_AFPFSSetLock(context->filePath, pFile->h, RESERVED_BYTE, 1, 0);
}
}
TRACE3("TEST WR-LOCK %d %d\n", pFile->h, r);
OSTRACE3("TEST WR-LOCK %d %d\n", pFile->h, r);
return r;
}
@@ -1792,14 +1793,14 @@ static int afpUnixLock(OsFile *id, int locktype)
int gotPendingLock = 0;
assert( pFile );
TRACE5("LOCK %d %s was %s pid=%d\n", pFile->h,
OSTRACE5("LOCK %d %s was %s pid=%d\n", pFile->h,
locktypeName(locktype), locktypeName(pFile->locktype), getpid());
/* If there is already a lock of this type or more restrictive on the
** OsFile, do nothing. Don't use the afp_end_lock: exit path, as
** sqlite3OsEnterMutex() hasn't been called yet.
*/
if( pFile->locktype>=locktype ){
TRACE3("LOCK %d %s ok (already held)\n", pFile->h,
OSTRACE3("LOCK %d %s ok (already held)\n", pFile->h,
locktypeName(locktype));
return SQLITE_OK;
}
@@ -1906,7 +1907,7 @@ static int afpUnixLock(OsFile *id, int locktype)
afp_end_lock:
sqlite3OsLeaveMutex();
TRACE4("LOCK %d %s %s\n", pFile->h, locktypeName(locktype),
OSTRACE4("LOCK %d %s %s\n", pFile->h, locktypeName(locktype),
rc==SQLITE_OK ? "ok" : "failed");
return rc;
}
@@ -1925,7 +1926,7 @@ static int afpUnixUnlock(OsFile *id, int locktype) {
afpLockingContext *context = (afpLockingContext *) pFile->lockingContext;
assert( pFile );
TRACE5("UNLOCK %d %d was %d pid=%d\n", pFile->h, locktype,
OSTRACE5("UNLOCK %d %d was %d pid=%d\n", pFile->h, locktype,
pFile->locktype, getpid());
assert( locktype<=SHARED_LOCK );
@@ -2002,7 +2003,7 @@ static int afpUnixClose(OsFile **pId) {
id->dirfd = -1;
close(id->h);
id->isOpen = 0;
TRACE2("CLOSE %-3d\n", id->h);
OSTRACE2("CLOSE %-3d\n", id->h);
OpenCounter(-1);
sqlite3ThreadSafeFree(id);
*pId = 0;
@@ -2098,7 +2099,7 @@ static int flockUnixClose(OsFile **pId) {
close(id->h);
sqlite3OsLeaveMutex();
id->isOpen = 0;
TRACE2("CLOSE %-3d\n", id->h);
OSTRACE2("CLOSE %-3d\n", id->h);
OpenCounter(-1);
sqlite3ThreadSafeFree(id);
*pId = 0;
@@ -2217,7 +2218,7 @@ static int dotlockUnixClose(OsFile **pId) {
sqlite3OsLeaveMutex();
id->isOpen = 0;
TRACE2("CLOSE %-3d\n", id->h);
OSTRACE2("CLOSE %-3d\n", id->h);
OpenCounter(-1);
sqlite3ThreadSafeFree(id);
*pId = 0;
@@ -2259,7 +2260,7 @@ static int nolockUnixClose(OsFile **pId) {
sqlite3OsLeaveMutex();
id->isOpen = 0;
TRACE2("CLOSE %-3d\n", id->h);
OSTRACE2("CLOSE %-3d\n", id->h);
OpenCounter(-1);
sqlite3ThreadSafeFree(id);
*pId = 0;
@@ -2588,7 +2589,7 @@ static int allocateUnixFile(
close(h);
return SQLITE_NOMEM;
}
TRACE3("OPEN %-3d %s\n", h, zFilename);
OSTRACE3("OPEN %-3d %s\n", h, zFilename);
f.dirfd = -1;
f.fullSync = 0;
f.locktype = 0;

View File

@@ -612,7 +612,7 @@ int sqlite3WinDelete(const char *zFilename){
#endif
}
sqliteFree(zConverted);
TRACE2("DELETE \"%s\"\n", zFilename);
OSTRACE2("DELETE \"%s\"\n", zFilename);
return rc!=0 ? SQLITE_OK : SQLITE_IOERR;
}
@@ -738,7 +738,7 @@ int sqlite3WinOpenReadWrite(
#if OS_WINCE
f.zDeleteOnClose = 0;
#endif
TRACE3("OPEN R/W %d \"%s\"\n", h, zFilename);
OSTRACE3("OPEN R/W %d \"%s\"\n", h, zFilename);
return allocateWinFile(&f, pId);
}
@@ -819,7 +819,7 @@ int sqlite3WinOpenExclusive(const char *zFilename, OsFile **pId, int delFlag){
return SQLITE_CANTOPEN;
}
f.h = h;
TRACE3("OPEN EX %d \"%s\"\n", h, zFilename);
OSTRACE3("OPEN EX %d \"%s\"\n", h, zFilename);
return allocateWinFile(&f, pId);
}
@@ -870,7 +870,7 @@ int sqlite3WinOpenReadOnly(const char *zFilename, OsFile **pId){
f.zDeleteOnClose = 0;
f.hMutex = NULL;
#endif
TRACE3("OPEN RO %d \"%s\"\n", h, zFilename);
OSTRACE3("OPEN RO %d \"%s\"\n", h, zFilename);
return allocateWinFile(&f, pId);
}
@@ -955,7 +955,7 @@ int sqlite3WinTempFileName(char *zBuf){
zBuf[j] = 0;
if( !sqlite3OsFileExists(zBuf) ) break;
}
TRACE2("TEMP FILENAME: %s\n", zBuf);
OSTRACE2("TEMP FILENAME: %s\n", zBuf);
return SQLITE_OK;
}
@@ -975,7 +975,7 @@ static int winClose(OsFile **pId){
int rc = 1;
if( pId && (pFile = (winFile*)*pId)!=0 ){
int rc, cnt = 0;
TRACE2("CLOSE %d\n", pFile->h);
OSTRACE2("CLOSE %d\n", pFile->h);
do{
rc = CloseHandle(pFile->h);
}while( rc==0 && cnt++ < MX_CLOSE_ATTEMPT && (Sleep(100), 1) );
@@ -1002,7 +1002,7 @@ static int winRead(OsFile *id, void *pBuf, int amt){
DWORD got;
assert( id!=0 );
SimulateIOError(return SQLITE_IOERR_READ);
TRACE3("READ %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
OSTRACE3("READ %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
if( !ReadFile(((winFile*)id)->h, pBuf, amt, &got, 0) ){
return SQLITE_IOERR_READ;
}
@@ -1024,7 +1024,7 @@ static int winWrite(OsFile *id, const void *pBuf, int amt){
assert( id!=0 );
SimulateIOError(return SQLITE_IOERR_READ);
SimulateDiskfullError(return SQLITE_FULL);
TRACE3("WRITE %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
OSTRACE3("WRITE %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
assert( amt>0 );
while( amt>0 && (rc = WriteFile(((winFile*)id)->h, pBuf, amt, &wrote, 0))!=0
&& wrote>0 ){
@@ -1057,7 +1057,7 @@ static int winSeek(OsFile *id, i64 offset){
#endif
SEEK(offset/1024 + 1);
rc = SetFilePointer(((winFile*)id)->h, lowerBits, &upperBits, FILE_BEGIN);
TRACE3("SEEK %d %lld\n", ((winFile*)id)->h, offset);
OSTRACE3("SEEK %d %lld\n", ((winFile*)id)->h, offset);
if( rc==INVALID_SET_FILE_POINTER && GetLastError()!=NO_ERROR ){
return SQLITE_FULL;
}
@@ -1069,7 +1069,7 @@ static int winSeek(OsFile *id, i64 offset){
*/
static int winSync(OsFile *id, int dataOnly){
assert( id!=0 );
TRACE3("SYNC %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
OSTRACE3("SYNC %d lock=%d\n", ((winFile*)id)->h, ((winFile*)id)->locktype);
if( FlushFileBuffers(((winFile*)id)->h) ){
return SQLITE_OK;
}else{
@@ -1092,7 +1092,7 @@ int sqlite3WinSyncDirectory(const char *zDirname){
static int winTruncate(OsFile *id, i64 nByte){
LONG upperBits = nByte>>32;
assert( id!=0 );
TRACE3("TRUNCATE %d %lld\n", ((winFile*)id)->h, nByte);
OSTRACE3("TRUNCATE %d %lld\n", ((winFile*)id)->h, nByte);
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
SetFilePointer(((winFile*)id)->h, nByte, &upperBits, FILE_BEGIN);
SetEndOfFile(((winFile*)id)->h);
@@ -1220,7 +1220,7 @@ static int winLock(OsFile *id, int locktype){
winFile *pFile = (winFile*)id;
assert( pFile!=0 );
TRACE5("LOCK %d %d was %d(%d)\n",
OSTRACE5("LOCK %d %d was %d(%d)\n",
pFile->h, locktype, pFile->locktype, pFile->sharedLockByte);
/* If there is already a lock of this type or more restrictive on the
@@ -1250,7 +1250,7 @@ static int winLock(OsFile *id, int locktype){
/* Try 3 times to get the pending lock. The pending lock might be
** held by another reader process who will release it momentarily.
*/
TRACE2("could not get a PENDING lock. cnt=%d\n", cnt);
OSTRACE2("could not get a PENDING lock. cnt=%d\n", cnt);
Sleep(1);
}
gotPendingLock = res;
@@ -1288,12 +1288,12 @@ static int winLock(OsFile *id, int locktype){
if( locktype==EXCLUSIVE_LOCK && res ){
assert( pFile->locktype>=SHARED_LOCK );
res = unlockReadLock(pFile);
TRACE2("unreadlock = %d\n", res);
OSTRACE2("unreadlock = %d\n", res);
res = LockFile(pFile->h, SHARED_FIRST, 0, SHARED_SIZE, 0);
if( res ){
newLocktype = EXCLUSIVE_LOCK;
}else{
TRACE2("error-code = %d\n", GetLastError());
OSTRACE2("error-code = %d\n", GetLastError());
}
}
@@ -1310,7 +1310,7 @@ static int winLock(OsFile *id, int locktype){
if( res ){
rc = SQLITE_OK;
}else{
TRACE4("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
OSTRACE4("LOCK FAILED %d trying for %d but got %d\n", pFile->h,
locktype, newLocktype);
rc = SQLITE_BUSY;
}
@@ -1329,14 +1329,14 @@ static int winCheckReservedLock(OsFile *id){
assert( pFile!=0 );
if( pFile->locktype>=RESERVED_LOCK ){
rc = 1;
TRACE3("TEST WR-LOCK %d %d (local)\n", pFile->h, rc);
OSTRACE3("TEST WR-LOCK %d %d (local)\n", pFile->h, rc);
}else{
rc = LockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
if( rc ){
UnlockFile(pFile->h, RESERVED_BYTE, 0, 1, 0);
}
rc = !rc;
TRACE3("TEST WR-LOCK %d %d (remote)\n", pFile->h, rc);
OSTRACE3("TEST WR-LOCK %d %d (remote)\n", pFile->h, rc);
}
return rc;
}
@@ -1358,7 +1358,7 @@ static int winUnlock(OsFile *id, int locktype){
winFile *pFile = (winFile*)id;
assert( pFile!=0 );
assert( locktype<=SHARED_LOCK );
TRACE5("UNLOCK %d to %d was %d(%d)\n", pFile->h, locktype,
OSTRACE5("UNLOCK %d to %d was %d(%d)\n", pFile->h, locktype,
pFile->locktype, pFile->sharedLockByte);
type = pFile->locktype;
if( type>=EXCLUSIVE_LOCK ){

View File

@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while
** another is writing.
**
** @(#) $Id: pager.c,v 1.299 2007/03/26 15:46:01 danielk1977 Exp $
** @(#) $Id: pager.c,v 1.300 2007/03/26 22:05:02 drh Exp $
*/
#ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h"
@@ -32,21 +32,21 @@
*/
#if 0
#define sqlite3DebugPrintf printf
#define TRACE1(X) sqlite3DebugPrintf(X)
#define TRACE2(X,Y) sqlite3DebugPrintf(X,Y)
#define TRACE3(X,Y,Z) sqlite3DebugPrintf(X,Y,Z)
#define TRACE4(X,Y,Z,W) sqlite3DebugPrintf(X,Y,Z,W)
#define TRACE5(X,Y,Z,W,V) sqlite3DebugPrintf(X,Y,Z,W,V)
#define PAGERTRACE1(X) sqlite3DebugPrintf(X)
#define PAGERTRACE2(X,Y) sqlite3DebugPrintf(X,Y)
#define PAGERTRACE3(X,Y,Z) sqlite3DebugPrintf(X,Y,Z)
#define PAGERTRACE4(X,Y,Z,W) sqlite3DebugPrintf(X,Y,Z,W)
#define PAGERTRACE5(X,Y,Z,W,V) sqlite3DebugPrintf(X,Y,Z,W,V)
#else
#define TRACE1(X)
#define TRACE2(X,Y)
#define TRACE3(X,Y,Z)
#define TRACE4(X,Y,Z,W)
#define TRACE5(X,Y,Z,W,V)
#define PAGERTRACE1(X)
#define PAGERTRACE2(X,Y)
#define PAGERTRACE3(X,Y,Z)
#define PAGERTRACE4(X,Y,Z,W)
#define PAGERTRACE5(X,Y,Z,W,V)
#endif
/*
** The following two macros are used within the TRACEX() macros above
** The following two macros are used within the PAGERTRACEX() macros above
** to print out file-descriptors.
**
** PAGERID() takes a pointer to a Pager struct as it's argument. The
@@ -1082,7 +1082,7 @@ static int pager_playback_one_page(Pager *pPager, OsFile *jfd, int useCksum){
*/
pPg = pager_lookup(pPager, pgno);
assert( pPager->state>=PAGER_EXCLUSIVE || pPg!=0 );
TRACE3("PLAYBACK %d page %d\n", PAGERID(pPager), pgno);
PAGERTRACE3("PLAYBACK %d page %d\n", PAGERID(pPager), pgno);
if( pPager->state>=PAGER_EXCLUSIVE && (pPg==0 || pPg->needSync==0) ){
rc = sqlite3OsSeek(pPager->fd, (pgno-1)*(i64)pPager->pageSize);
if( rc==SQLITE_OK ){
@@ -1226,7 +1226,7 @@ static int pager_reload_cache(Pager *pPager){
if( rc==SQLITE_OK ){
rc = sqlite3OsRead(pPager->fd, zBuf, pPager->pageSize);
}
TRACE3("REFETCH %d page %d\n", PAGERID(pPager), pPg->pgno);
PAGERTRACE3("REFETCH %d page %d\n", PAGERID(pPager), pPg->pgno);
if( rc ) break;
CODEC1(pPager, zBuf, pPg->pgno, 2);
}else{
@@ -1734,7 +1734,7 @@ int sqlite3PagerOpen(
return ((rc==SQLITE_OK)?SQLITE_NOMEM:rc);
}
TRACE3("OPEN %d %s\n", FILEHANDLEID(fd), zFullPathname);
PAGERTRACE3("OPEN %d %s\n", FILEHANDLEID(fd), zFullPathname);
IOTRACE(("OPEN %p %s\n", pPager, zFullPathname))
pPager->zFilename = (char*)&pPager[1];
pPager->zDirectory = &pPager->zFilename[nameLen+1];
@@ -1828,7 +1828,7 @@ int sqlite3PagerSetPagesize(Pager *pPager, int pageSize){
if( !pPager->memDb && pPager->nRef==0 ){
pager_reset(pPager);
pPager->pageSize = pageSize;
sqlite3ReallocOrFree((void **)&pPager->pTmpSpace, pageSize);
sqlite3ReallocOrFree(&pPager->pTmpSpace, pageSize);
}
return pPager->pageSize;
}
@@ -2139,7 +2139,7 @@ int sqlite3PagerClose(Pager *pPager){
pager_reset(pPager);
pagerUnlockAndRollback(pPager);
enable_simulated_io_errors();
TRACE2("CLOSE %d\n", PAGERID(pPager));
PAGERTRACE2("CLOSE %d\n", PAGERID(pPager));
IOTRACE(("CLOSE %p\n", pPager))
assert( pPager->errCode || (pPager->journalOpen==0 && pPager->stmtOpen==0) );
if( pPager->journalOpen ){
@@ -2285,7 +2285,7 @@ static int syncJournal(Pager *pPager){
** it as a candidate for rollback.
*/
if( pPager->fullSync ){
TRACE2("SYNC journal of %d\n", PAGERID(pPager));
PAGERTRACE2("SYNC journal of %d\n", PAGERID(pPager));
IOTRACE(("JSYNC %p\n", pPager))
rc = sqlite3OsSync(pPager->jfd, 0);
if( rc!=0 ) return rc;
@@ -2301,7 +2301,7 @@ static int syncJournal(Pager *pPager){
rc = sqlite3OsSeek(pPager->jfd, pPager->journalOff);
if( rc ) return rc;
}
TRACE2("SYNC journal of %d\n", PAGERID(pPager));
PAGERTRACE2("SYNC journal of %d\n", PAGERID(pPager));
IOTRACE(("JSYNC %d\n", pPager))
rc = sqlite3OsSync(pPager->jfd, pPager->full_fsync);
if( rc!=0 ) return rc;
@@ -2440,14 +2440,14 @@ static int pager_write_pagelist(PgHdr *pList){
*/
if( pList->pgno<=pPager->dbSize ){
char *pData = CODEC2(pPager, PGHDR_TO_DATA(pList), pList->pgno, 6);
TRACE3("STORE %d page %d\n", PAGERID(pPager), pList->pgno);
PAGERTRACE3("STORE %d page %d\n", PAGERID(pPager), pList->pgno);
IOTRACE(("PGOUT %p %d\n", pPager, pList->pgno))
rc = sqlite3OsWrite(pPager->fd, pData, pPager->pageSize);
TEST_INCR(pPager->nWrite);
}
#ifndef NDEBUG
else{
TRACE3("NOSTORE %d page %d\n", PAGERID(pPager), pList->pgno);
PAGERTRACE3("NOSTORE %d page %d\n", PAGERID(pPager), pList->pgno);
}
#endif
if( rc ) return rc;
@@ -2907,7 +2907,7 @@ int sqlite3PagerAcquire(Pager *pPager, Pgno pgno, DbPage **ppPage, int clrFlag){
pPager->pageSize);
}
IOTRACE(("PGIN %p %d\n", pPager, pgno))
TRACE3("FETCH %d page %d\n", PAGERID(pPager), pPg->pgno);
PAGERTRACE3("FETCH %d page %d\n", PAGERID(pPager), pPg->pgno);
CODEC1(pPager, PGHDR_TO_DATA(pPg), pPg->pgno, 3);
if( rc!=SQLITE_OK && rc!=SQLITE_IOERR_SHORT_READ ){
pPg->pgno = 0;
@@ -3142,7 +3142,7 @@ int sqlite3PagerBegin(DbPage *pPg, int exFlag){
return rc;
}
pPager->dirtyCache = 0;
TRACE2("TRANSACTION %d\n", PAGERID(pPager));
PAGERTRACE2("TRANSACTION %d\n", PAGERID(pPager));
if( pPager->useJournal && !pPager->tempFile ){
rc = pager_open_journal(pPager);
}
@@ -3276,7 +3276,7 @@ static int pager_write(PgHdr *pPg){
int szPg;
if( MEMDB ){
PgHistory *pHist = PGHDR_TO_HIST(pPg, pPager);
TRACE3("JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
PAGERTRACE3("JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
assert( pHist->pOrig==0 );
pHist->pOrig = sqliteMallocRaw( pPager->pageSize );
if( pHist->pOrig ){
@@ -3301,7 +3301,7 @@ static int pager_write(PgHdr *pPg){
IOTRACE(("JOUT %p %d %lld %d\n", pPager, pPg->pgno,
pPager->journalOff, szPg))
pPager->journalOff += szPg;
TRACE4("JOURNAL %d page %d needSync=%d\n",
PAGERTRACE4("JOURNAL %d page %d needSync=%d\n",
PAGERID(pPager), pPg->pgno, pPg->needSync);
*(u32*)pEnd = saved;
@@ -3323,7 +3323,7 @@ static int pager_write(PgHdr *pPg){
}
}else{
pPg->needSync = !pPager->journalStarted && !pPager->noSync;
TRACE4("APPEND %d page %d needSync=%d\n",
PAGERTRACE4("APPEND %d page %d needSync=%d\n",
PAGERID(pPager), pPg->pgno, pPg->needSync);
}
if( pPg->needSync ){
@@ -3346,12 +3346,12 @@ static int pager_write(PgHdr *pPg){
if( pHist->pStmt ){
memcpy(pHist->pStmt, PGHDR_TO_DATA(pPg), pPager->pageSize);
}
TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
PAGERTRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
}else{
char *pData2 = CODEC2(pPager, pData, pPg->pgno, 7)-4;
put32bits(pData2, pPg->pgno);
rc = sqlite3OsWrite(pPager->stfd, pData2, pPager->pageSize+4);
TRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
PAGERTRACE3("STMT-JOURNAL %d page %d\n", PAGERID(pPager), pPg->pgno);
if( rc!=SQLITE_OK ){
return rc;
}
@@ -3522,7 +3522,7 @@ void sqlite3PagerDontWrite(Pager *pPager, Pgno pgno){
** corruption during the next transaction.
*/
}else{
TRACE3("DONT_WRITE page %d of %d\n", pgno, PAGERID(pPager));
PAGERTRACE3("DONT_WRITE page %d of %d\n", pgno, PAGERID(pPager));
IOTRACE(("CLEAN %p %d\n", pPager, pgno))
makeClean(pPg);
#ifdef SQLITE_CHECK_PAGES
@@ -3552,7 +3552,7 @@ void sqlite3PagerDontRollback(DbPage *pPg){
pPager->aInStmt[pPg->pgno/8] |= 1<<(pPg->pgno&7);
page_add_to_stmt_list(pPg);
}
TRACE3("DONT_ROLLBACK page %d of %d\n", pPg->pgno, PAGERID(pPager));
PAGERTRACE3("DONT_ROLLBACK page %d of %d\n", pPg->pgno, PAGERID(pPager));
IOTRACE(("GARBAGE %p %d\n", pPager, pPg->pgno))
}
if( pPager->stmtInUse && !pPg->inStmt && (int)pPg->pgno<=pPager->stmtSize ){
@@ -3581,7 +3581,7 @@ int sqlite3PagerCommit(Pager *pPager){
if( pPager->state<PAGER_RESERVED ){
return SQLITE_ERROR;
}
TRACE2("COMMIT %d\n", PAGERID(pPager));
PAGERTRACE2("COMMIT %d\n", PAGERID(pPager));
if( MEMDB ){
pPg = pager_get_all_dirty_pages(pPager);
while( pPg ){
@@ -3635,7 +3635,7 @@ int sqlite3PagerCommit(Pager *pPager){
*/
int sqlite3PagerRollback(Pager *pPager){
int rc;
TRACE2("ROLLBACK %d\n", PAGERID(pPager));
PAGERTRACE2("ROLLBACK %d\n", PAGERID(pPager));
if( MEMDB ){
PgHdr *p;
for(p=pPager->pAll; p; p=p->pNextAll){
@@ -3650,9 +3650,9 @@ int sqlite3PagerRollback(Pager *pPager){
pHist = PGHDR_TO_HIST(p, pPager);
if( pHist->pOrig ){
memcpy(PGHDR_TO_DATA(p), pHist->pOrig, pPager->pageSize);
TRACE3("ROLLBACK-PAGE %d of %d\n", p->pgno, PAGERID(pPager));
PAGERTRACE3("ROLLBACK-PAGE %d of %d\n", p->pgno, PAGERID(pPager));
}else{
TRACE3("PAGE %d is clean on %d\n", p->pgno, PAGERID(pPager));
PAGERTRACE3("PAGE %d is clean on %d\n", p->pgno, PAGERID(pPager));
}
clearHistory(pHist);
p->dirty = 0;
@@ -3750,7 +3750,7 @@ int sqlite3PagerStmtBegin(Pager *pPager){
assert( !pPager->stmtInUse );
assert( pPager->state>=PAGER_SHARED );
assert( pPager->dbSize>=0 );
TRACE2("STMT-BEGIN %d\n", PAGERID(pPager));
PAGERTRACE2("STMT-BEGIN %d\n", PAGERID(pPager));
if( MEMDB ){
pPager->stmtInUse = 1;
pPager->stmtSize = pPager->dbSize;
@@ -3798,7 +3798,7 @@ stmt_begin_failed:
int sqlite3PagerStmtCommit(Pager *pPager){
if( pPager->stmtInUse ){
PgHdr *pPg, *pNext;
TRACE2("STMT-COMMIT %d\n", PAGERID(pPager));
PAGERTRACE2("STMT-COMMIT %d\n", PAGERID(pPager));
if( !MEMDB ){
sqlite3OsSeek(pPager->stfd, 0);
/* sqlite3OsTruncate(pPager->stfd, 0); */
@@ -3830,7 +3830,7 @@ int sqlite3PagerStmtCommit(Pager *pPager){
int sqlite3PagerStmtRollback(Pager *pPager){
int rc;
if( pPager->stmtInUse ){
TRACE2("STMT-ROLLBACK %d\n", PAGERID(pPager));
PAGERTRACE2("STMT-ROLLBACK %d\n", PAGERID(pPager));
if( MEMDB ){
PgHdr *pPg;
for(pPg=pPager->pStmt; pPg; pPg=pPg->pNextStmt){
@@ -3947,7 +3947,7 @@ static int pager_incr_changecounter(Pager *pPager){
int sqlite3PagerSync(Pager *pPager, const char *zMaster, Pgno nTrunc){
int rc = SQLITE_OK;
TRACE4("DATABASE SYNC: File=%s zMaster=%s nTrunc=%d\n",
PAGERTRACE4("DATABASE SYNC: File=%s zMaster=%s nTrunc=%d\n",
pPager->zFilename, zMaster, nTrunc);
/* If this is an in-memory db, or no pages have been written to, or this
@@ -4043,7 +4043,7 @@ int sqlite3PagerMovepage(Pager *pPager, DbPage *pPg, Pgno pgno){
assert( pPg->nRef>0 );
TRACE5("MOVE %d page %d (needSync=%d) moves to %d\n",
PAGERTRACE5("MOVE %d page %d (needSync=%d) moves to %d\n",
PAGERID(pPager), pPg->pgno, pPg->needSync, pgno);
IOTRACE(("MOVE %p %d %d\n", pPager, pPg->pgno, pgno))

View File

@@ -13,7 +13,7 @@
** interface, and routines that contribute to loading the database schema
** from disk.
**
** $Id: prepare.c,v 1.44 2007/03/14 15:37:04 danielk1977 Exp $
** $Id: prepare.c,v 1.45 2007/03/26 22:05:02 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -566,7 +566,7 @@ int sqlite3Prepare(
*/
int sqlite3Reprepare(Vdbe *p){
int rc;
Vdbe *pNew;
sqlite3_stmt *pNew;
const char *zSql;
sqlite3 *db;
@@ -575,17 +575,17 @@ int sqlite3Reprepare(Vdbe *p){
return 0;
}
db = sqlite3VdbeDb(p);
rc = sqlite3Prepare(db, zSql, -1, 0, (sqlite3_stmt**)&pNew, 0);
rc = sqlite3Prepare(db, zSql, -1, 0, &pNew, 0);
if( rc ){
assert( pNew==0 );
return 0;
}else{
assert( pNew!=0 );
}
sqlite3VdbeSwap(pNew, p);
sqlite3_transfer_bindings((sqlite3_stmt*)pNew, (sqlite3_stmt*)p);
sqlite3VdbeResetStepResult(pNew);
sqlite3VdbeFinalize(pNew);
sqlite3VdbeSwap((Vdbe*)pNew, p);
sqlite3_transfer_bindings(pNew, (sqlite3_stmt*)p);
sqlite3VdbeResetStepResult((Vdbe*)pNew);
sqlite3VdbeFinalize((Vdbe*)pNew);
return 1;
}

View File

@@ -11,16 +11,13 @@
*************************************************************************
** Internal interface definitions for SQLite.
**
** @(#) $Id: sqliteInt.h,v 1.543 2007/03/24 16:45:05 danielk1977 Exp $
** @(#) $Id: sqliteInt.h,v 1.544 2007/03/26 22:05:02 drh Exp $
*/
#ifndef _SQLITEINT_H_
#define _SQLITEINT_H_
/*
** Extra interface definitions for those who need them
*/
#ifdef SQLITE_EXTRA
# include "sqliteExtra.h"
#if defined(SQLITE_TCL) || defined(TCLSH)
# include <tcl.h>
#endif
/*
@@ -1570,7 +1567,7 @@ void *sqlite3Realloc(void*,int);
char *sqlite3StrDup(const char*);
char *sqlite3StrNDup(const char*, int);
# define sqlite3CheckMemory(a,b)
void sqlite3ReallocOrFree(void**,int);
void sqlite3ReallocOrFree(void*,int);
void sqlite3FreeX(void*);
void *sqlite3MallocX(int);
int sqlite3AllocSize(void *);
@@ -1627,7 +1624,7 @@ void sqlite3CreateView(Parse*,Token*,Token*,Token*,Select*,int,int);
void sqlite3DropTable(Parse*, SrcList*, int, int);
void sqlite3DeleteTable(sqlite3*, Table*);
void sqlite3Insert(Parse*, SrcList*, ExprList*, Select*, IdList*, int);
int sqlite3ArrayAllocate(void**,int,int);
int sqlite3ArrayAllocate(void*,int,int);
IdList *sqlite3IdListAppend(IdList*, Token*);
int sqlite3IdListIndex(IdList*,const char*);
SrcList *sqlite3SrcListAppend(SrcList*, Token*, Token*);

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test1.c,v 1.229 2007/02/24 13:53:05 drh Exp $
** $Id: test1.c,v 1.230 2007/03/26 22:05:02 drh Exp $
*/
#include "sqliteInt.h"
#include "tcl.h"
@@ -112,7 +112,7 @@ const char *sqlite3TestErrorName(int rc){
}
return zName;
}
#define errorName sqlite3TestErrorName
#define t1ErrorName sqlite3TestErrorName
/*
** Convert an sqlite3_stmt* into an sqlite3*. This depends on the
@@ -129,7 +129,7 @@ int sqlite3TestErrCode(Tcl_Interp *interp, sqlite3 *db, int rc){
char zBuf[200];
int r2 = sqlite3_errcode(db);
sprintf(zBuf, "error code %s (%d) does not match sqlite3_errcode %s (%d)",
errorName(rc), rc, errorName(r2), r2);
t1ErrorName(rc), rc, t1ErrorName(r2), r2);
Tcl_ResetResult(interp);
Tcl_AppendResult(interp, zBuf, 0);
return 1;
@@ -490,7 +490,7 @@ static int sqlite_test_close(
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
rc = sqlite3_close(db);
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
return TCL_OK;
}
@@ -498,7 +498,11 @@ static int sqlite_test_close(
** Implementation of the x_coalesce() function.
** Return the first argument non-NULL argument.
*/
static void ifnullFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
static void t1_ifnullFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
int i;
for(i=0; i<argc; i++){
if( SQLITE_NULL!=sqlite3_value_type(argv[i]) ){
@@ -682,7 +686,7 @@ static int test_create_function(
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
rc = sqlite3_create_function(db, "x_coalesce", -1, SQLITE_ANY, 0,
ifnullFunc, 0, 0);
t1_ifnullFunc, 0, 0);
if( rc==SQLITE_OK ){
rc = sqlite3_create_function(db, "hex8", 1, SQLITE_ANY, 0,
hex8Func, 0, 0);
@@ -716,7 +720,7 @@ static int test_create_function(
#endif
if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;
Tcl_SetResult(interp, (char *)errorName(rc), 0);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);
return TCL_OK;
}
@@ -731,12 +735,16 @@ static int test_create_function(
** is reported on the step function. If the total count is 42, then
** a UTF-8 error is reported on the finalize function.
*/
typedef struct CountCtx CountCtx;
struct CountCtx {
typedef struct t1CountCtx t1CountCtx;
struct t1CountCtx {
int n;
};
static void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){
CountCtx *p;
static void t1CountStep(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
t1CountCtx *p;
p = sqlite3_aggregate_context(context, sizeof(*p));
if( (argc==0 || SQLITE_NULL!=sqlite3_value_type(argv[0]) ) && p ){
p->n++;
@@ -753,8 +761,8 @@ static void countStep(sqlite3_context *context, int argc, sqlite3_value **argv){
}
}
}
static void countFinalize(sqlite3_context *context){
CountCtx *p;
static void t1CountFinalize(sqlite3_context *context){
t1CountCtx *p;
p = sqlite3_aggregate_context(context, sizeof(*p));
if( p ){
if( p->n==42 ){
@@ -794,10 +802,10 @@ static int test_create_aggregate(
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
rc = sqlite3_create_function(db, "x_count", 0, SQLITE_UTF8, 0, 0,
countStep,countFinalize);
t1CountStep,t1CountFinalize);
if( rc==SQLITE_OK ){
sqlite3_create_function(db, "x_count", 1, SQLITE_UTF8, 0, 0,
countStep,countFinalize);
t1CountStep,t1CountFinalize);
}
if( sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;
return TCL_OK;
@@ -1497,7 +1505,7 @@ static int test_finalize(
db = StmtToDb(pStmt);
}
rc = sqlite3_finalize(pStmt);
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
if( db && sqlite3TestErrCode(interp, db, rc) ) return TCL_ERROR;
return TCL_OK;
}
@@ -1528,7 +1536,7 @@ static int test_reset(
if( pStmt && sqlite3TestErrCode(interp, StmtToDb(pStmt), rc) ){
return TCL_ERROR;
}
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
/*
if( rc ){
return TCL_ERROR;
@@ -2052,7 +2060,7 @@ static int test_errstr(
zCode = Tcl_GetString(objv[1]);
for(i=0; i<200; i++){
if( 0==strcmp(errorName(i), zCode) ) break;
if( 0==strcmp(t1ErrorName(i), zCode) ) break;
}
Tcl_SetResult(interp, (char *)sqlite3ErrStr(i), 0);
return TCL_OK;
@@ -2504,7 +2512,7 @@ static int test_errcode(
}else{
sprintf(zBuf,"+%d", rc>>8);
}
Tcl_AppendResult(interp, (char *)errorName(rc), zBuf, 0);
Tcl_AppendResult(interp, (char *)t1ErrorName(rc), zBuf, 0);
return TCL_OK;
}
@@ -2900,7 +2908,7 @@ static int test_step(
rc = sqlite3_step(pStmt);
/* if( rc!=SQLITE_DONE && rc!=SQLITE_ROW ) return TCL_ERROR; */
Tcl_SetResult(interp, (char *)errorName(rc), 0);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), 0);
return TCL_OK;
}
@@ -3137,7 +3145,7 @@ static int test_global_recover(
return TCL_ERROR;
}
rc = sqlite3_global_recover();
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
#endif
return TCL_OK;
}
@@ -3235,7 +3243,7 @@ static int test_sqlite3OsOpenReadWrite(
rc = sqlite3OsOpenReadWrite(Tcl_GetString(objv[1]), &pFile, &dummy);
if( rc!=SQLITE_OK ){
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
return TCL_ERROR;
}
sqlite3TestMakePointerStr(interp, zBuf, pFile);
@@ -3266,7 +3274,7 @@ static int test_sqlite3OsClose(
}
rc = sqlite3OsClose(&pFile);
if( rc!=SQLITE_OK ){
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
@@ -3314,7 +3322,7 @@ static int test_sqlite3OsLock(
}
if( rc!=SQLITE_OK ){
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
@@ -3343,7 +3351,7 @@ static int test_sqlite3OsUnlock(
}
rc = sqlite3OsUnlock(pFile, NO_LOCK);
if( rc!=SQLITE_OK ){
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
return TCL_ERROR;
}
return TCL_OK;
@@ -3363,7 +3371,7 @@ static int test_sqlite3OsTempFileName(
rc = sqlite3OsTempFileName(zFile);
if( rc!=SQLITE_OK ){
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
return TCL_ERROR;
}
Tcl_AppendResult(interp, zFile, 0);
@@ -3492,7 +3500,7 @@ static int delete_function(
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
rc = sqlite3_create_function(db, argv[2], -1, SQLITE_UTF8, 0, 0, 0, 0);
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
return TCL_OK;
}
@@ -3518,7 +3526,7 @@ static int delete_collation(
}
if( getDbPointer(interp, argv[1], &db) ) return TCL_ERROR;
rc = sqlite3_create_collation(db, argv[2], SQLITE_UTF8, 0, 0);
Tcl_SetResult(interp, (char *)errorName(rc), TCL_STATIC);
Tcl_SetResult(interp, (char *)t1ErrorName(rc), TCL_STATIC);
return TCL_OK;
}
@@ -4220,7 +4228,7 @@ int Sqlitetest1_Init(Tcl_Interp *interp){
extern int sqlite3_sync_count, sqlite3_fullsync_count;
extern int sqlite3_opentemp_count;
extern int sqlite3_memUsed;
extern int sqlite3_malloc_id;
extern char *sqlite3_malloc_id;
extern int sqlite3_memMax;
extern int sqlite3_like_count;
extern int sqlite3_tsd_count;

View File

@@ -13,7 +13,7 @@
** is not included in the SQLite library. It is used for automated
** testing of the SQLite library.
**
** $Id: test3.c,v 1.71 2007/03/19 17:44:28 danielk1977 Exp $
** $Id: test3.c,v 1.72 2007/03/26 22:05:02 drh Exp $
*/
#include "sqliteInt.h"
#include "pager.h"
@@ -1229,7 +1229,7 @@ static int btree_cursor_info(
/*
** Copied from btree.c:
*/
static u32 get4byte(unsigned char *p){
static u32 t4Get4byte(unsigned char *p){
return (p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3];
}
@@ -1291,7 +1291,7 @@ static int btree_ovfl_info(
return TCL_ERROR;
}
pPage = sqlite3PagerGetData(pDbPage);
pgno = get4byte((unsigned char*)pPage);
pgno = t4Get4byte((unsigned char*)pPage);
sqlite3PagerUnref(pDbPage);
}
Tcl_DStringResult(interp, &str);

View File

@@ -106,7 +106,7 @@ typedef struct AsyncFile AsyncFile;
/* Enable for debugging */
static int sqlite3async_trace = 0;
# define TRACE(X) if( sqlite3async_trace ) asyncTrace X
# define ASYNC_TRACE(X) if( sqlite3async_trace ) asyncTrace X
static void asyncTrace(const char *zFormat, ...){
char *z;
va_list ap;
@@ -364,7 +364,7 @@ static void addAsyncWrite(AsyncWrite *pWrite){
async.pQueueFirst = pWrite;
}
async.pQueueLast = pWrite;
TRACE(("PUSH %p (%s %s %d)\n", pWrite, azOpcodeName[pWrite->op],
ASYNC_TRACE(("PUSH %p (%s %s %d)\n", pWrite, azOpcodeName[pWrite->op],
pWrite->pFile ? pWrite->pFile->zName : "-", pWrite->iOffset));
if( pWrite->op==ASYNC_CLOSE ){
@@ -520,7 +520,7 @@ static int asyncRead(OsFile *id, void *obuf, int amt){
nRead = MIN(filesize - pFile->iOffset, amt);
if( nRead>0 ){
rc = sqlite3OsRead(pBase, obuf, nRead);
TRACE(("READ %s %d bytes at %d\n", pFile->zName, nRead, pFile->iOffset));
ASYNC_TRACE(("READ %s %d bytes at %d\n", pFile->zName, nRead, pFile->iOffset));
}
}
@@ -540,7 +540,7 @@ static int asyncRead(OsFile *id, void *obuf, int amt){
if( nCopy>0 ){
memcpy(&((char *)obuf)[iBeginOut], &p->zBuf[iBeginIn], nCopy);
TRACE(("OVERREAD %d bytes at %d\n", nCopy, iBeginOut+iOffset));
ASYNC_TRACE(("OVERREAD %d bytes at %d\n", nCopy, iBeginOut+iOffset));
}
}
}
@@ -626,7 +626,7 @@ static int asyncFileHandle(OsFile *id){
*/
static int asyncLock(OsFile *id, int lockType){
AsyncFile *pFile = (AsyncFile*)id;
TRACE(("LOCK %d (%s)\n", lockType, pFile->zName));
ASYNC_TRACE(("LOCK %d (%s)\n", lockType, pFile->zName));
pthread_mutex_lock(&async.lockMutex);
sqlite3HashInsert(&async.aLock, pFile->zName, pFile->nName, (void*)lockType);
pthread_mutex_unlock(&async.lockMutex);
@@ -646,7 +646,7 @@ static int asyncCheckReservedLock(OsFile *id){
pthread_mutex_lock(&async.lockMutex);
rc = (int)sqlite3HashFind(&async.aLock, pFile->zName, pFile->nName);
pthread_mutex_unlock(&async.lockMutex);
TRACE(("CHECK-LOCK %d (%s)\n", rc, pFile->zName));
ASYNC_TRACE(("CHECK-LOCK %d (%s)\n", rc, pFile->zName));
return rc>SHARED_LOCK;
}
@@ -826,7 +826,7 @@ static int asyncFileExists(const char *z){
}
}
TRACE(("EXISTS: %s = %d\n", z, ret));
ASYNC_TRACE(("EXISTS: %s = %d\n", z, ret));
pthread_mutex_unlock(&async.queueMutex);
return ret;
}
@@ -916,9 +916,9 @@ static void *asyncWriterThread(void *NotUsed){
pthread_mutex_unlock(&async.queueMutex);
break;
}else{
TRACE(("IDLE\n"));
ASYNC_TRACE(("IDLE\n"));
pthread_cond_wait(&async.queueSignal, &async.queueMutex);
TRACE(("WAKEUP\n"));
ASYNC_TRACE(("WAKEUP\n"));
}
}
if( p==0 ) break;
@@ -967,7 +967,7 @@ static void *asyncWriterThread(void *NotUsed){
case ASYNC_WRITE:
assert( pBase );
TRACE(("WRITE %s %d bytes at %d\n",
ASYNC_TRACE(("WRITE %s %d bytes at %d\n",
p->pFile->zName, p->nByte, p->iOffset));
rc = sqlite3OsSeek(pBase, p->iOffset);
if( rc==SQLITE_OK ){
@@ -977,18 +977,18 @@ static void *asyncWriterThread(void *NotUsed){
case ASYNC_SYNC:
assert( pBase );
TRACE(("SYNC %s\n", p->pFile->zName));
ASYNC_TRACE(("SYNC %s\n", p->pFile->zName));
rc = sqlite3OsSync(pBase, p->nByte);
break;
case ASYNC_TRUNCATE:
assert( pBase );
TRACE(("TRUNCATE %s to %d bytes\n", p->pFile->zName, p->iOffset));
ASYNC_TRACE(("TRUNCATE %s to %d bytes\n", p->pFile->zName, p->iOffset));
rc = sqlite3OsTruncate(pBase, p->iOffset);
break;
case ASYNC_CLOSE:
TRACE(("CLOSE %s\n", p->pFile->zName));
ASYNC_TRACE(("CLOSE %s\n", p->pFile->zName));
sqlite3OsClose(&p->pFile->pBaseWrite);
sqlite3OsClose(&p->pFile->pBaseRead);
sqlite3OsFree(p->pFile);
@@ -996,23 +996,23 @@ static void *asyncWriterThread(void *NotUsed){
case ASYNC_OPENDIRECTORY:
assert( pBase );
TRACE(("OPENDIR %s\n", p->zBuf));
ASYNC_TRACE(("OPENDIR %s\n", p->zBuf));
sqlite3OsOpenDirectory(pBase, p->zBuf);
break;
case ASYNC_SETFULLSYNC:
assert( pBase );
TRACE(("SETFULLSYNC %s %d\n", p->pFile->zName, p->nByte));
ASYNC_TRACE(("SETFULLSYNC %s %d\n", p->pFile->zName, p->nByte));
sqlite3OsSetFullSync(pBase, p->nByte);
break;
case ASYNC_DELETE:
TRACE(("DELETE %s\n", p->zBuf));
ASYNC_TRACE(("DELETE %s\n", p->zBuf));
rc = xOrigDelete(p->zBuf);
break;
case ASYNC_SYNCDIRECTORY:
TRACE(("SYNCDIR %s\n", p->zBuf));
ASYNC_TRACE(("SYNCDIR %s\n", p->zBuf));
rc = xOrigSyncDirectory(p->zBuf);
break;
@@ -1020,7 +1020,7 @@ static void *asyncWriterThread(void *NotUsed){
AsyncFile *pFile = p->pFile;
int delFlag = ((p->iOffset)?1:0);
OsFile *pBase = 0;
TRACE(("OPEN %s delFlag=%d\n", p->zBuf, delFlag));
ASYNC_TRACE(("OPEN %s delFlag=%d\n", p->zBuf, delFlag));
assert(pFile->pBaseRead==0 && pFile->pBaseWrite==0);
rc = xOrigOpenExclusive(p->zBuf, &pBase, delFlag);
assert( holdingMutex==0 );
@@ -1043,7 +1043,7 @@ static void *asyncWriterThread(void *NotUsed){
pthread_mutex_lock(&async.queueMutex);
holdingMutex = 1;
}
/* TRACE(("UNLINK %p\n", p)); */
/* ASYNC_TRACE(("UNLINK %p\n", p)); */
if( p==async.pQueueLast ){
async.pQueueLast = 0;
}
@@ -1236,14 +1236,14 @@ static int testAsyncWait(
sched_yield();
}
if( cnt>=0 ){
TRACE(("WAIT\n"));
ASYNC_TRACE(("WAIT\n"));
pthread_mutex_lock(&async.queueMutex);
pthread_cond_broadcast(&async.queueSignal);
pthread_mutex_unlock(&async.queueMutex);
pthread_mutex_lock(&async.writerMutex);
pthread_mutex_unlock(&async.writerMutex);
}else{
TRACE(("NO-WAIT\n"));
ASYNC_TRACE(("NO-WAIT\n"));
}
return TCL_OK;
}

View File

@@ -14,7 +14,7 @@
** This file contains functions for allocating memory, comparing
** strings, and stuff like that.
**
** $Id: util.c,v 1.195 2007/03/19 17:44:28 danielk1977 Exp $
** $Id: util.c,v 1.196 2007/03/26 22:05:02 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -661,12 +661,13 @@ void *sqlite3Malloc(int n, int doMemManage){
}
return p;
}
void sqlite3ReallocOrFree(void **pp, int n){
void *p = sqlite3Realloc(*pp, n);
void sqlite3ReallocOrFree(void *pp, int n){
char **x = (char**)pp;
void *p = sqlite3Realloc(*x, n);
if( !p ){
sqlite3FreeX(*pp);
sqlite3FreeX(*x);
}
*pp = p;
*x = p;
}
/*
@@ -1384,11 +1385,11 @@ void *sqlite3TextToPtr(const char *z){
z++;
}
if( sizeof(p)==sizeof(v) ){
p = *(void**)&v;
memcpy(&p, &v, sizeof(p));
}else{
assert( sizeof(p)==sizeof(v2) );
v2 = (u32)v;
p = *(void**)&v2;
memcpy(&p, &v2, sizeof(p));
}
return p;
}

View File

@@ -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.591 2007/03/15 12:05:36 danielk1977 Exp $
** $Id: vdbe.c,v 1.592 2007/03/26 22:05:02 drh Exp $
*/
#include "sqliteInt.h"
#include "os.h"
@@ -4236,7 +4236,7 @@ case OP_ContextPush: { /* no-push */
/* FIX ME: This should be allocated as part of the vdbe at compile-time */
if( i>=p->contextStackDepth ){
p->contextStackDepth = i+1;
sqliteReallocOrFree((void**)&p->contextStack, sizeof(Context)*(i+1));
sqliteReallocOrFree(&p->contextStack, sizeof(Context)*(i+1));
if( p->contextStack==0 ) goto no_mem;
}
pContext = &p->contextStack[i];

View File

@@ -31,7 +31,7 @@
** array is defined in a separate source code file named opcode.c which is
** automatically generated by the makefile.
*/
extern char *sqlite3OpcodeNames[];
extern const char *const sqlite3OpcodeNames[];
/*
** SQL is translated into a sequence of instructions to be
@@ -125,7 +125,10 @@ typedef struct Cursor Cursor;
** SQLITE_BLOB.
*/
struct Mem {
i64 i; /* Integer value. Or FuncDef* when flags==MEM_Agg */
union {
i64 i; /* Integer value. Or FuncDef* when flags==MEM_Agg */
FuncDef *pDef;
};
double r; /* Real value */
char *z; /* String or BLOB value */
int n; /* Number of characters in string value, including '\0' */

View File

@@ -341,7 +341,7 @@ void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
}else{
pMem->flags = MEM_Agg;
pMem->xDel = sqlite3FreeX;
*(FuncDef**)&pMem->i = p->pFunc;
pMem->pDef = p->pFunc;
if( nByte<=NBFS ){
pMem->z = pMem->zShort;
memset(pMem->z, 0, nByte);
@@ -443,7 +443,7 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){
Vdbe *pVm = (Vdbe *)pStmt;
int vals = sqlite3_data_count(pStmt);
if( i>=vals || i<0 ){
static const Mem nullMem = {0, 0.0, "", 0, MEM_Null, MEM_Null };
static const Mem nullMem = {{0,}, 0.0, "", 0, MEM_Null, MEM_Null };
sqlite3Error(pVm->db, SQLITE_RANGE, 0);
return (Mem*)&nullMem;
}

View File

@@ -195,8 +195,7 @@ int sqlite3VdbeMakeLabel(Vdbe *p){
assert( p->magic==VDBE_MAGIC_INIT );
if( i>=p->nLabelAlloc ){
p->nLabelAlloc = p->nLabelAlloc*2 + 10;
sqliteReallocOrFree((void**)&p->aLabel,
p->nLabelAlloc*sizeof(p->aLabel[0]));
sqliteReallocOrFree(&p->aLabel, p->nLabelAlloc*sizeof(p->aLabel[0]));
}
if( p->aLabel ){
p->aLabel[i] = -1;
@@ -723,7 +722,7 @@ int sqlite3VdbeList(
pMem++;
pMem->flags = MEM_Static|MEM_Str|MEM_Term;
pMem->z = sqlite3OpcodeNames[pOp->opcode]; /* Opcode */
pMem->z = (char*)sqlite3OpcodeNames[pOp->opcode]; /* Opcode */
assert( pMem->z!=0 );
pMem->n = strlen(pMem->z);
pMem->type = SQLITE_TEXT;
@@ -1785,9 +1784,10 @@ int sqlite3VdbeSerialPut(unsigned char *buf, Mem *pMem, int file_format){
u64 v;
int i;
if( serial_type==7 ){
v = *(u64*)&pMem->r;
assert( sizeof(v)==sizeof(pMem->r) );
memcpy(&v, &pMem->r, sizeof(v));
}else{
v = *(u64*)&pMem->i;
v = pMem->i;
}
len = i = sqlite3VdbeSerialTypeLen(serial_type);
while( i-- ){
@@ -1861,7 +1861,8 @@ int sqlite3VdbeSerialGet(
** byte order. The byte order differs on some (broken) architectures.
*/
static const u64 t1 = ((u64)0x3ff00000)<<32;
assert( 1.0==*(double*)&t1 );
static const double r1 = 1.0;
assert( sizeof(r1)==sizeof(t1) && memcmp(&r1, &t1, sizeof(r1))==0 );
#endif
x = (buf[0]<<24) | (buf[1]<<16) | (buf[2]<<8) | buf[3];
@@ -1871,7 +1872,9 @@ int sqlite3VdbeSerialGet(
pMem->i = *(i64*)&x;
pMem->flags = MEM_Int;
}else{
pMem->r = *(double*)&x;
assert( sizeof(x)==8 && sizeof(pMem->r)==8 );
memcpy(&pMem->r, &x, sizeof(x));
/* pMem->r = *(double*)&x; */
pMem->flags = MEM_Real;
}
return 8;

View File

@@ -19,7 +19,7 @@
** Allocate a new FifoPage and return a pointer to it. Return NULL if
** we run out of memory. Leave space on the page for nEntry entries.
*/
static FifoPage *allocatePage(int nEntry){
static FifoPage *allocateFifoPage(int nEntry){
FifoPage *pPage;
if( nEntry>32767 ){
nEntry = 32767;
@@ -50,12 +50,12 @@ int sqlite3VdbeFifoPush(Fifo *pFifo, i64 val){
FifoPage *pPage;
pPage = pFifo->pLast;
if( pPage==0 ){
pPage = pFifo->pLast = pFifo->pFirst = allocatePage(20);
pPage = pFifo->pLast = pFifo->pFirst = allocateFifoPage(20);
if( pPage==0 ){
return SQLITE_NOMEM;
}
}else if( pPage->iWrite>=pPage->nSlot ){
pPage->pNext = allocatePage(pFifo->nEntry);
pPage->pNext = allocateFifoPage(pFifo->nEntry);
if( pPage->pNext==0 ){
return SQLITE_NOMEM;
}

View File

@@ -195,7 +195,7 @@ int sqlite3VdbeMemFinalize(Mem *pMem, FuncDef *pFunc){
int rc = SQLITE_OK;
if( pFunc && pFunc->xFinalize ){
sqlite3_context ctx;
assert( (pMem->flags & MEM_Null)!=0 || pFunc==*(FuncDef**)&pMem->i );
assert( (pMem->flags & MEM_Null)!=0 || pFunc==pMem->pDef );
ctx.s.flags = MEM_Null;
ctx.s.z = pMem->zShort;
ctx.pMem = pMem;
@@ -225,7 +225,7 @@ void sqlite3VdbeMemRelease(Mem *p){
if( p->flags & (MEM_Dyn|MEM_Agg) ){
if( p->xDel ){
if( p->flags & MEM_Agg ){
sqlite3VdbeMemFinalize(p, *(FuncDef**)&p->i);
sqlite3VdbeMemFinalize(p, p->pDef);
assert( (p->flags & MEM_Agg)==0 );
sqlite3VdbeMemRelease(p);
}else{

View File

@@ -16,7 +16,7 @@
** so is applicable. Because this module is responsible for selecting
** indices, you might also think of this module as the "query optimizer".
**
** $Id: where.c,v 1.239 2007/03/02 08:12:22 danielk1977 Exp $
** $Id: where.c,v 1.240 2007/03/26 22:05:02 drh Exp $
*/
#include "sqliteInt.h"
@@ -35,9 +35,9 @@
*/
#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
int sqlite3_where_trace = 0;
# define TRACE(X) if(sqlite3_where_trace) sqlite3DebugPrintf X
# define WHERETRACE(X) if(sqlite3_where_trace) sqlite3DebugPrintf X
#else
# define TRACE(X)
# define WHERETRACE(X)
#endif
/* Forward reference
@@ -1209,7 +1209,7 @@ static double bestVirtualIndex(
if( pIdxInfo==0 ){
WhereTerm *pTerm;
int nTerm;
TRACE(("Recomputing index info for %s...\n", pTab->zName));
WHERETRACE(("Recomputing index info for %s...\n", pTab->zName));
/* Count the number of possible WHERE clause constraints referring
** to this virtual table */
@@ -1342,7 +1342,7 @@ static double bestVirtualIndex(
}
sqlite3SafetyOff(pParse->db);
TRACE(("xBestIndex for %s\n", pTab->zName));
WHERETRACE(("xBestIndex for %s\n", pTab->zName));
TRACE_IDX_INPUTS(pIdxInfo);
rc = pTab->pVtab->pModule->xBestIndex(pTab->pVtab, pIdxInfo);
TRACE_IDX_OUTPUTS(pIdxInfo);
@@ -1403,7 +1403,7 @@ static double bestIndex(
int eqTermMask; /* Mask of valid equality operators */
double cost; /* Cost of using pProbe */
TRACE(("bestIndex: tbl=%s notReady=%x\n", pSrc->pTab->zName, notReady));
WHERETRACE(("bestIndex: tbl=%s notReady=%x\n", pSrc->pTab->zName, notReady));
lowestCost = SQLITE_BIG_DBL;
pProbe = pSrc->pTab->pIndex;
@@ -1434,7 +1434,7 @@ static double bestIndex(
** a single row is generated, output is always in sorted order */
*pFlags = WHERE_ROWID_EQ | WHERE_UNIQUE;
*pnEq = 1;
TRACE(("... best is rowid\n"));
WHERETRACE(("... best is rowid\n"));
return 0.0;
}else if( (pExpr = pTerm->pExpr)->pList!=0 ){
/* Rowid IN (LIST): cost is NlogN where N is the number of list
@@ -1447,14 +1447,14 @@ static double bestIndex(
** that value so make a wild guess. */
lowestCost = 200;
}
TRACE(("... rowid IN cost: %.9g\n", lowestCost));
WHERETRACE(("... rowid IN cost: %.9g\n", lowestCost));
}
/* Estimate the cost of a table scan. If we do not know how many
** entries are in the table, use 1 million as a guess.
*/
cost = pProbe ? pProbe->aiRowEst[0] : 1000000;
TRACE(("... table scan base cost: %.9g\n", cost));
WHERETRACE(("... table scan base cost: %.9g\n", cost));
flags = WHERE_ROWID_RANGE;
/* Check for constraints on a range of rowids in a table scan.
@@ -1469,7 +1469,7 @@ static double bestIndex(
flags |= WHERE_BTM_LIMIT;
cost /= 3; /* Guess that rowid>EXPR eliminates two-thirds of rows */
}
TRACE(("... rowid range reduces cost to %.9g\n", cost));
WHERETRACE(("... rowid range reduces cost to %.9g\n", cost));
}else{
flags = 0;
}
@@ -1484,7 +1484,7 @@ static double bestIndex(
}
}else{
cost += cost*estLog(cost);
TRACE(("... sorting increases cost to %.9g\n", cost));
WHERETRACE(("... sorting increases cost to %.9g\n", cost));
}
}
if( cost<lowestCost ){
@@ -1509,7 +1509,7 @@ static double bestIndex(
int i; /* Loop counter */
double inMultiplier = 1;
TRACE(("... index %s:\n", pProbe->zName));
WHERETRACE(("... index %s:\n", pProbe->zName));
/* Count the number of columns in the index that are satisfied
** by x=EXPR constraints or x IN (...) constraints.
@@ -1536,7 +1536,7 @@ static double bestIndex(
&& nEq==pProbe->nColumn ){
flags |= WHERE_UNIQUE;
}
TRACE(("...... nEq=%d inMult=%.9g cost=%.9g\n", nEq, inMultiplier, cost));
WHERETRACE(("...... nEq=%d inMult=%.9g cost=%.9g\n", nEq, inMultiplier, cost));
/* Look for range constraints
*/
@@ -1553,7 +1553,7 @@ static double bestIndex(
flags |= WHERE_BTM_LIMIT;
cost /= 3;
}
TRACE(("...... range reduces cost to %.9g\n", cost));
WHERETRACE(("...... range reduces cost to %.9g\n", cost));
}
}
@@ -1571,7 +1571,7 @@ static double bestIndex(
}
}else{
cost += cost*estLog(cost);
TRACE(("...... orderby increases cost to %.9g\n", cost));
WHERETRACE(("...... orderby increases cost to %.9g\n", cost));
}
}
@@ -1591,7 +1591,7 @@ static double bestIndex(
if( m==0 ){
flags |= WHERE_IDX_ONLY;
cost /= 2;
TRACE(("...... idx-only reduces cost to %.9g\n", cost));
WHERETRACE(("...... idx-only reduces cost to %.9g\n", cost));
}
}
@@ -1609,7 +1609,7 @@ static double bestIndex(
/* Report the best result
*/
*ppIndex = bestIdx;
TRACE(("best index is %s, cost=%.9g, flags=%x, nEq=%d\n",
WHERETRACE(("best index is %s, cost=%.9g, flags=%x, nEq=%d\n",
bestIdx ? bestIdx->zName : "(none)", lowestCost, bestFlags, bestNEq));
*pFlags = bestFlags | eqTermMask;
*pnEq = bestNEq;
@@ -1707,8 +1707,8 @@ static void codeEqualityTerm(
sqlite3VdbeAddOp(v, OP_Rewind, iTab, 0);
VdbeComment((v, "# %.*s", pX->span.n, pX->span.z));
pLevel->nIn++;
sqliteReallocOrFree((void**)&pLevel->aInLoop,
sizeof(pLevel->aInLoop[0])*2*pLevel->nIn);
sqliteReallocOrFree(&pLevel->aInLoop,
sizeof(pLevel->aInLoop[0])*2*pLevel->nIn);
aIn = pLevel->aInLoop;
if( aIn ){
aIn += pLevel->nIn*2 - 2;
@@ -2003,7 +2003,7 @@ WhereInfo *sqlite3WhereBegin(
pTabItem = pTabList->a;
pLevel = pWInfo->a;
andFlags = ~0;
TRACE(("*** Optimizer Start ***\n"));
WHERETRACE(("*** Optimizer Start ***\n"));
for(i=iFrom=0, pLevel=pWInfo->a; i<pTabList->nSrc; i++, pLevel++){
Index *pIdx; /* Index for FROM table at pTabItem */
int flags; /* Flags asssociated with pIdx */
@@ -2071,7 +2071,7 @@ WhereInfo *sqlite3WhereBegin(
}
if( doNotReorder ) break;
}
TRACE(("*** Optimizer choose table %d for loop %d\n", bestJ,
WHERETRACE(("*** Optimizer choose table %d for loop %d\n", bestJ,
pLevel-pWInfo->a));
if( (bestFlags & WHERE_ORDERBY)!=0 ){
*ppOrderBy = 0;
@@ -2090,7 +2090,7 @@ WhereInfo *sqlite3WhereBegin(
notReady &= ~getMask(&maskSet, pTabList->a[bestJ].iCursor);
pLevel->iFrom = bestJ;
}
TRACE(("*** Optimizer Finished ***\n"));
WHERETRACE(("*** Optimizer Finished ***\n"));
/* If the total query only selects a single row, then the ORDER BY
** clause is irrelevant.