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
-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
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
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
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
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
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
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
-8fe317054982969ad539cdbf1b996b97d86ec4f2
\ No newline at end of file
+0b832e218ec12b0eb559e407d80aba6709e2ea85
\ No newline at end of file
** 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
}
/* 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
/* 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;
** 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,
#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
/* 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;
}
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;
}
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;
}
#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 ){
** 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;
}
}
}else{
- rc = allocatePage(pBt, &pRoot, &pgnoRoot, 1, 0);
+ rc = allocateBtreePage(pBt, &pRoot, &pgnoRoot, 1, 0);
if( rc ) return rc;
}
#endif
** 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>
}
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;
** 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]++;
}
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;
** 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>
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() ){
*/
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;
}
*/
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;
}
#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
/*
#ifndef PAGER_SECTOR_SIZE
# define PAGER_SECTOR_SIZE 512
#endif
-
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;
}
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 );
}
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 );
}
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 );
}
zBuf[j] = 0;
if( !sqlite3OsFileExists( zBuf ) ) break;
}
- TRACE2( "TEMP FILENAME: %s\n", zBuf );
+ OSTRACE2( "TEMP FILENAME: %s\n", zBuf );
return SQLITE_OK;
}
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 ){
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;
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;
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;
}
*/
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;
}
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 ){
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
/* 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;
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;
if( res == NO_ERROR ){
newLocktype = EXCLUSIVE_LOCK;
}else{
- TRACE2( "error-code = %d\n", res );
+ OSTRACE2( "error-code = %d\n", res );
}
}
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;
}
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;
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;
}
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;
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;
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;
}
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;
}
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;
}
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
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;
}
}
sqlite3OsLeaveMutex();
- TRACE3("TEST WR-LOCK %d %d\n", pFile->h, r);
+ OSTRACE3("TEST WR-LOCK %d %d\n", pFile->h, r);
return r;
}
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());
** 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;
}
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;
}
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 );
sqlite3OsLeaveMutex();
id->isOpen = 0;
- TRACE2("CLOSE %-3d\n", id->h);
+ OSTRACE2("CLOSE %-3d\n", id->h);
OpenCounter(-1);
sqlite3ThreadSafeFree(id);
*pId = 0;
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 {
_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;
}
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;
}
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;
}
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 );
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;
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;
sqlite3OsLeaveMutex();
id->isOpen = 0;
- TRACE2("CLOSE %-3d\n", id->h);
+ OSTRACE2("CLOSE %-3d\n", id->h);
OpenCounter(-1);
sqlite3ThreadSafeFree(id);
*pId = 0;
sqlite3OsLeaveMutex();
id->isOpen = 0;
- TRACE2("CLOSE %-3d\n", id->h);
+ OSTRACE2("CLOSE %-3d\n", id->h);
OpenCounter(-1);
sqlite3ThreadSafeFree(id);
*pId = 0;
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;
#endif
}
sqliteFree(zConverted);
- TRACE2("DELETE \"%s\"\n", zFilename);
+ OSTRACE2("DELETE \"%s\"\n", zFilename);
return rc!=0 ? SQLITE_OK : SQLITE_IOERR;
}
#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);
}
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);
}
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);
}
zBuf[j] = 0;
if( !sqlite3OsFileExists(zBuf) ) break;
}
- TRACE2("TEMP FILENAME: %s\n", zBuf);
+ OSTRACE2("TEMP FILENAME: %s\n", zBuf);
return SQLITE_OK;
}
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) );
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;
}
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 ){
#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;
}
*/
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{
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);
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
/* 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;
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());
}
}
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;
}
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;
}
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 ){
** 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"
*/
#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
*/
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 ){
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{
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];
if( !pPager->memDb && pPager->nRef==0 ){
pager_reset(pPager);
pPager->pageSize = pageSize;
- sqlite3ReallocOrFree((void **)&pPager->pTmpSpace, pageSize);
+ sqlite3ReallocOrFree(&pPager->pTmpSpace, pageSize);
}
return pPager->pageSize;
}
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 ){
** 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;
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;
*/
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;
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;
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);
}
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 ){
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;
}
}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 ){
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;
}
** 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
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 ){
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 ){
*/
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){
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;
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;
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); */
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){
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
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))
** 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"
*/
int sqlite3Reprepare(Vdbe *p){
int rc;
- Vdbe *pNew;
+ sqlite3_stmt *pNew;
const char *zSql;
sqlite3 *db;
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;
}
*************************************************************************
** 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
/*
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 *);
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*);
** 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"
}
return zName;
}
-#define errorName sqlite3TestErrorName
+#define t1ErrorName sqlite3TestErrorName
/*
** Convert an sqlite3_stmt* into an sqlite3*. This depends on the
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;
}
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;
}
** 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]) ){
}
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);
#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;
}
** 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++;
}
}
}
-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 ){
}
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;
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;
}
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;
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;
}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;
}
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;
}
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;
}
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);
}
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;
}
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;
}
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;
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);
}
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;
}
}
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;
}
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;
** 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"
/*
** 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];
}
return TCL_ERROR;
}
pPage = sqlite3PagerGetData(pDbPage);
- pgno = get4byte((unsigned char*)pPage);
+ pgno = t4Get4byte((unsigned char*)pPage);
sqlite3PagerUnref(pDbPage);
}
Tcl_DStringResult(interp, &str);
/* 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;
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 ){
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));
}
}
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));
}
}
}
*/
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);
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;
}
}
}
- TRACE(("EXISTS: %s = %d\n", z, ret));
+ ASYNC_TRACE(("EXISTS: %s = %d\n", z, ret));
pthread_mutex_unlock(&async.queueMutex);
return ret;
}
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;
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 ){
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);
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;
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 );
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;
}
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;
}
** 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"
}
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;
}
/*
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;
}
** 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"
/* 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];
** 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
** 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' */
}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);
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;
}
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;
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;
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-- ){
** 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];
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;
** 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;
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;
}
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;
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{
** 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"
*/
#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
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 */
}
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);
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;
** 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
** 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.
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;
}
}
}else{
cost += cost*estLog(cost);
- TRACE(("... sorting increases cost to %.9g\n", cost));
+ WHERETRACE(("... sorting increases cost to %.9g\n", cost));
}
}
if( cost<lowestCost ){
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.
&& 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
*/
flags |= WHERE_BTM_LIMIT;
cost /= 3;
}
- TRACE(("...... range reduces cost to %.9g\n", cost));
+ WHERETRACE(("...... range reduces cost to %.9g\n", cost));
}
}
}
}else{
cost += cost*estLog(cost);
- TRACE(("...... orderby increases cost to %.9g\n", cost));
+ WHERETRACE(("...... orderby increases cost to %.9g\n", cost));
}
}
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));
}
}
/* 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;
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;
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 */
}
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;
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.