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

Fix harmless compiler warnings. (CVS 5073)

FossilOrigin-Name: 227a6f67c21c87a7cf98f84b9d57a6dc9da93ebb
This commit is contained in:
drh
2008-05-01 17:03:49 +00:00
parent 356574e97a
commit e265b08458
11 changed files with 368 additions and 371 deletions

View File

@@ -1,5 +1,5 @@
C Test\sversions\sof\sgetVarint\sfunctions.\sThe\supdates\sessentially\sutilize\sloop\sunrolling\sand\ssome\sshifting/anding\stricks\sto\sminimize\sthe\snumber\sof\slogical\soperations\srequired.\s(CVS\s5072) C Fix\sharmless\scompiler\swarnings.\s(CVS\s5073)
D 2008-05-01T02:47:04 D 2008-05-01T17:03:49
F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7 F Makefile.arm-wince-mingw32ce-gcc ac5f7b2cef0cd850d6f755ba6ee4ab961b1fadf7
F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952 F Makefile.in 25b3282a4ac39388632c2fb0e044ff494d490952
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
@@ -102,8 +102,8 @@ F src/hash.h 031cd9f915aff27e12262cb9eb570ac1b8326b53
F src/insert.c 77f0829b3e2edd19e9238195c56b0d56ab000f17 F src/insert.c 77f0829b3e2edd19e9238195c56b0d56ab000f17
F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2 F src/journal.c 807bed7a158979ac8d63953e1774e8d85bff65e2
F src/legacy.c 8267890e6a0a71f13b680794520999c642299081 F src/legacy.c 8267890e6a0a71f13b680794520999c642299081
F src/loadext.c 5c20a5afeb154e68d62ed6d9c634add1b21387fd F src/loadext.c 48455156d6044141d7e332c1b0b4647b3b8b8e66
F src/main.c 94c8bf6ad592aec60dae1c34d30c089fc9be1137 F src/main.c d40ed2bf7b63002726b19951cae14d0bcf7debd9
F src/malloc.c 12c1ae98ef1eff34b13c9eb526e0b7b479e1e820 F src/malloc.c 12c1ae98ef1eff34b13c9eb526e0b7b479e1e820
F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217 F src/md5.c c5fdfa5c2593eaee2e32a5ce6c6927c986eaf217
F src/mem1.c fc716ff521b6dd3e43eaa211967383308800e70a F src/mem1.c fc716ff521b6dd3e43eaa211967383308800e70a
@@ -122,19 +122,19 @@ F src/os_common.h e8b748b2f2ecc8a498e50bfe5d8721f189c19d2a
F src/os_os2.c 41015b3fa91568761eb10cbf6ca27a0624ba0bda F src/os_os2.c 41015b3fa91568761eb10cbf6ca27a0624ba0bda
F src/os_unix.c 8cf512c4321c3114f053dc9eaae394db2dc03ebe F src/os_unix.c 8cf512c4321c3114f053dc9eaae394db2dc03ebe
F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403 F src/os_win.c 3a60bddd07ea6f8adb2314dd5996ac97b988f403
F src/pager.c 268be1208002fab9202b3f29b490ba35615a697d F src/pager.c fd4e176cbd9dbf09d59406b8346e2c00eeda2999
F src/pager.h 45ec2188593afd48a25c743529646771d75e83e4 F src/pager.h 4f051fd856de6fd3c19aef5f82eace54122b9173
F src/parse.y fc4bd35c6088901f7c8daead26c6fb11c87d22e7 F src/parse.y fc4bd35c6088901f7c8daead26c6fb11c87d22e7
F src/pragma.c 2e4bb2e76e48a32750529fdc4bfe86ac5f54e01b F src/pragma.c 2e4bb2e76e48a32750529fdc4bfe86ac5f54e01b
F src/prepare.c adc7e1fc08dfbab63cd213d4c0aff8f3fa70d477 F src/prepare.c adc7e1fc08dfbab63cd213d4c0aff8f3fa70d477
F src/printf.c 77c192ccc81117d68b21b449cd33396357aa266d F src/printf.c 77c192ccc81117d68b21b449cd33396357aa266d
F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a F src/random.c 2b2db2de4ab491f5a14d3480466f8f4b5a5db74a
F src/select.c b02ee16591f0194739e7deb12099d3e98e60b7f3 F src/select.c da43ce3080112aa77863e9c570c1df19a892acb8
F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96 F src/server.c 087b92a39d883e3fa113cae259d64e4c7438bc96
F src/shell.c be22ec05c8c4a43a95a6ad3b8068542200451e07 F src/shell.c be22ec05c8c4a43a95a6ad3b8068542200451e07
F src/sqlite.h.in abb785d2afcf45bb9344fe6edc1c7b428e1b719f F src/sqlite.h.in abb785d2afcf45bb9344fe6edc1c7b428e1b719f
F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3 F src/sqlite3ext.h faacd0e6a81aabee0861c6d7883c9172e74ef5b3
F src/sqliteInt.h d629773dd5d00a2dc2cf8dd84f59b75075c3f8f5 F src/sqliteInt.h 6dbffa746c569b992e76051565d3531a07a54669
F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8 F src/sqliteLimit.h f435e728c6b620ef7312814d660a81f9356eb5c8
F src/table.c 46ccf9b7892a86f57420ae7bac69ecd5e72d26b5 F src/table.c 46ccf9b7892a86f57420ae7bac69ecd5e72d26b5
F src/tclsqlite.c 2877726bf32f7d72ff057b37ed6c93485b667ea1 F src/tclsqlite.c 2877726bf32f7d72ff057b37ed6c93485b667ea1
@@ -170,8 +170,8 @@ F src/utf.c 8c94fa10efc78c2568d08d436acc59df4df7191b
F src/util.c 43a77ab79275991b819428ded8ac8dc868604ac7 F src/util.c 43a77ab79275991b819428ded8ac8dc868604ac7
F src/vacuum.c c3b2b70677f874102b8753bf494c232e777f3998 F src/vacuum.c c3b2b70677f874102b8753bf494c232e777f3998
F src/vdbe.c 26964ba7ed76d2a1c52747d601aaf2dc5b09b651 F src/vdbe.c 26964ba7ed76d2a1c52747d601aaf2dc5b09b651
F src/vdbe.h bfd84bda447f39cb599302c7ec85067dae20453c F src/vdbe.h f4bb70962d9c13e0f65b215c90e8acea1ae6e8ee
F src/vdbeInt.h 05316345da487b0cf540482576f9ae3337d133cd F src/vdbeInt.h 18aebaa7857de4507d92ced62d8fe0844671a681
F src/vdbeapi.c 0e1b5a808bb0e556f2a975eb7d11fd3153e922bf F src/vdbeapi.c 0e1b5a808bb0e556f2a975eb7d11fd3153e922bf
F src/vdbeaux.c aae523de91fb72a32a256253880739fe103ea76e F src/vdbeaux.c aae523de91fb72a32a256253880739fe103ea76e
F src/vdbeblob.c 554736781ee273a8089c776e96bdb53e66f57ce6 F src/vdbeblob.c 554736781ee273a8089c776e96bdb53e66f57ce6
@@ -573,7 +573,7 @@ F tool/spaceanal.tcl b87db46ae29e3116411b1686e136b9b994d7de39
F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355 F tool/speedtest.tcl 06c76698485ccf597b9e7dbb1ac70706eb873355
F tool/speedtest16.c 6f5bc019dcf8b6537f379bbac0408a9e1a86f0b6 F tool/speedtest16.c 6f5bc019dcf8b6537f379bbac0408a9e1a86f0b6
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
F tool/speedtest8.c a7cd2b2dbb8f97b0c51c0e01f49116a9162071be F tool/speedtest8.c e74126bc12178fa29904f711bb100212a5448041
F tool/speedtest8inst1.c 025879132979a5fdec11218472cba6cf8f6ec854 F tool/speedtest8inst1.c 025879132979a5fdec11218472cba6cf8f6ec854
F www/34to35.tcl 942e479aa7740b55d714dce0f0b2cb6ca91c3f20 F www/34to35.tcl 942e479aa7740b55d714dce0f0b2cb6ca91c3f20
F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf F www/arch.fig d5f9752a4dbf242e9cfffffd3f5762b6c63b3bcf
@@ -633,7 +633,7 @@ F www/tclsqlite.tcl 8be95ee6dba05eabcd27a9d91331c803f2ce2130
F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0 F www/vdbe.tcl 87a31ace769f20d3627a64fa1fade7fed47b90d0
F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b F www/version3.tcl 890248cf7b70e60c383b0e84d77d5132b3ead42b
F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5 F www/whentouse.tcl fc46eae081251c3c181bd79c5faef8195d7991a5
P 9c8b4babb2222a5e0c2ecf7a116b7df90084c81d P 682dc24dbe82d0326377e27c5ff97db3499873b0
R 329903c79b08ceeef301067fa9d79cfe R 2a1e4afac9472a5800a38d1bea7bd744
U shane U drh
Z 34ccf6f71b1f112c4e41d623ea9e6a2c Z a7fa05d78dd2cc528c84b78b850c9e17

View File

@@ -1 +1 @@
682dc24dbe82d0326377e27c5ff97db3499873b0 227a6f67c21c87a7cf98f84b9d57a6dc9da93ebb

View File

@@ -469,7 +469,9 @@ static struct {
int sqlite3_auto_extension(void *xInit){ int sqlite3_auto_extension(void *xInit){
int i; int i;
int rc = SQLITE_OK; int rc = SQLITE_OK;
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_mutex_enter(mutex); sqlite3_mutex_enter(mutex);
for(i=0; i<autoext.nExt; i++){ for(i=0; i<autoext.nExt; i++){
if( autoext.aExt[i]==xInit ) break; if( autoext.aExt[i]==xInit ) break;
@@ -495,7 +497,9 @@ int sqlite3_auto_extension(void *xInit){
** Reset the automatic extension loading mechanism. ** Reset the automatic extension loading mechanism.
*/ */
void sqlite3_reset_auto_extension(void){ void sqlite3_reset_auto_extension(void){
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_mutex_enter(mutex); sqlite3_mutex_enter(mutex);
sqlite3_free(autoext.aExt); sqlite3_free(autoext.aExt);
autoext.aExt = 0; autoext.aExt = 0;
@@ -518,7 +522,9 @@ int sqlite3AutoLoadExtensions(sqlite3 *db){
} }
for(i=0; go; i++){ for(i=0; go; i++){
char *zErrmsg = 0; char *zErrmsg = 0;
#ifndef SQLITE_MUTEX_NOOP
sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex *mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER);
#endif
sqlite3_mutex_enter(mutex); sqlite3_mutex_enter(mutex);
if( i>=autoext.nExt ){ if( i>=autoext.nExt ){
xInit = 0; xInit = 0;

View File

@@ -14,7 +14,7 @@
** other files are for internal use by SQLite and should not be ** other files are for internal use by SQLite and should not be
** accessed by users of the library. ** accessed by users of the library.
** **
** $Id: main.c,v 1.436 2008/04/28 20:35:49 drh Exp $ ** $Id: main.c,v 1.437 2008/05/01 17:03:49 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
#include <ctype.h> #include <ctype.h>
@@ -30,6 +30,7 @@ const char *sqlite3_libversion(void){ return sqlite3_version; }
int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; } int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; } int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
/* /*
** If the following function pointer is not NULL and if ** If the following function pointer is not NULL and if
** SQLITE_ENABLE_IOTRACE is enabled, then messages describing ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
@@ -37,6 +38,7 @@ int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
** are intended for debugging activity only. ** are intended for debugging activity only.
*/ */
void (*sqlite3IoTrace)(const char*, ...) = 0; void (*sqlite3IoTrace)(const char*, ...) = 0;
#endif
/* /*
** If the following global variable points to a string which is the ** If the following global variable points to a string which is the

View File

@@ -18,7 +18,7 @@
** file simultaneously, or one process from reading the database while ** file simultaneously, or one process from reading the database while
** another is writing. ** another is writing.
** **
** @(#) $Id: pager.c,v 1.436 2008/04/29 15:38:59 drh Exp $ ** @(#) $Id: pager.c,v 1.437 2008/05/01 17:03:49 drh Exp $
*/ */
#ifndef SQLITE_OMIT_DISKIO #ifndef SQLITE_OMIT_DISKIO
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -4368,29 +4368,6 @@ int sqlite3PagerIswriteable(DbPage *pPg){
} }
#endif #endif
#ifndef SQLITE_OMIT_VACUUM
/*
** Replace the content of a single page with the information in the third
** argument.
*/
int sqlite3PagerOverwrite(Pager *pPager, Pgno pgno, void *pData){
PgHdr *pPg;
int rc;
pagerEnter(pPager);
rc = sqlite3PagerGet(pPager, pgno, &pPg);
if( rc==SQLITE_OK ){
rc = sqlite3PagerWrite(pPg);
if( rc==SQLITE_OK ){
memcpy(sqlite3PagerGetData(pPg), pData, pPager->pageSize);
}
sqlite3PagerUnref(pPg);
}
pagerLeave(pPager);
return rc;
}
#endif
/* /*
** A call to this routine tells the pager that it is not necessary to ** A call to this routine tells the pager that it is not necessary to
** write the information on page pPg back to the disk, even though ** write the information on page pPg back to the disk, even though

View File

@@ -13,7 +13,7 @@
** subsystem. The page cache subsystem reads and writes a file a page ** subsystem. The page cache subsystem reads and writes a file a page
** at a time and provides a journal for rollback. ** at a time and provides a journal for rollback.
** **
** @(#) $Id: pager.h,v 1.71 2008/04/17 17:02:01 drh Exp $ ** @(#) $Id: pager.h,v 1.72 2008/05/01 17:03:49 drh Exp $
*/ */
#ifndef _PAGER_H_ #ifndef _PAGER_H_
@@ -77,7 +77,6 @@ DbPage *sqlite3PagerLookup(Pager *pPager, Pgno pgno);
int sqlite3PagerRef(DbPage*); int sqlite3PagerRef(DbPage*);
int sqlite3PagerUnref(DbPage*); int sqlite3PagerUnref(DbPage*);
int sqlite3PagerWrite(DbPage*); int sqlite3PagerWrite(DbPage*);
int sqlite3PagerOverwrite(Pager *pPager, Pgno pgno, void*);
int sqlite3PagerPagecount(Pager*); int sqlite3PagerPagecount(Pager*);
int sqlite3PagerTruncate(Pager*,Pgno); int sqlite3PagerTruncate(Pager*,Pgno);
int sqlite3PagerBegin(DbPage*, int exFlag); int sqlite3PagerBegin(DbPage*, int exFlag);

View File

@@ -12,7 +12,7 @@
** This file contains C code routines that are called by the parser ** This file contains C code routines that are called by the parser
** to handle SELECT statements in SQLite. ** to handle SELECT statements in SQLite.
** **
** $Id: select.c,v 1.428 2008/04/17 19:14:02 drh Exp $ ** $Id: select.c,v 1.429 2008/05/01 17:03:49 drh Exp $
*/ */
#include "sqliteInt.h" #include "sqliteInt.h"
@@ -2938,7 +2938,7 @@ static void updateAccumulator(Parse *pParse, AggInfo *pAggInfo){
pAggInfo->directMode = 0; pAggInfo->directMode = 0;
} }
#ifndef SQLITE_OMIT_TRIGGER #if 0
/* /*
** This function is used when a SELECT statement is used to create a ** This function is used when a SELECT statement is used to create a
** temporary table for iterating through when running an INSTEAD OF ** temporary table for iterating through when running an INSTEAD OF

View File

@@ -11,7 +11,7 @@
************************************************************************* *************************************************************************
** Internal interface definitions for SQLite. ** Internal interface definitions for SQLite.
** **
** @(#) $Id: sqliteInt.h,v 1.700 2008/04/28 18:46:43 drh Exp $ ** @(#) $Id: sqliteInt.h,v 1.701 2008/05/01 17:03:49 drh Exp $
*/ */
#ifndef _SQLITEINT_H_ #ifndef _SQLITEINT_H_
#define _SQLITEINT_H_ #define _SQLITEINT_H_
@@ -2211,10 +2211,10 @@ void sqlite3Put4byte(u8*, u32);
#ifdef SQLITE_ENABLE_IOTRACE #ifdef SQLITE_ENABLE_IOTRACE
# define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; } # define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
void sqlite3VdbeIOTraceSql(Vdbe*); void sqlite3VdbeIOTraceSql(Vdbe*);
SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...);
#else #else
# define IOTRACE(A) # define IOTRACE(A)
# define sqlite3VdbeIOTraceSql(X) # define sqlite3VdbeIOTraceSql(X)
#endif #endif
SQLITE_EXTERN void (*sqlite3IoTrace)(const char*,...);
#endif #endif

View File

@@ -15,7 +15,7 @@
** or VDBE. The VDBE implements an abstract machine that runs a ** or VDBE. The VDBE implements an abstract machine that runs a
** simple program to access and modify the underlying database. ** simple program to access and modify the underlying database.
** **
** $Id: vdbe.h,v 1.130 2008/04/11 14:56:53 drh Exp $ ** $Id: vdbe.h,v 1.131 2008/05/01 17:03:49 drh Exp $
*/ */
#ifndef _SQLITE_VDBE_H_ #ifndef _SQLITE_VDBE_H_
#define _SQLITE_VDBE_H_ #define _SQLITE_VDBE_H_
@@ -182,7 +182,9 @@ sqlite3 *sqlite3VdbeDb(Vdbe*);
void sqlite3VdbeSetSql(Vdbe*, const char *z, int n); void sqlite3VdbeSetSql(Vdbe*, const char *z, int n);
void sqlite3VdbeSwap(Vdbe*,Vdbe*); void sqlite3VdbeSwap(Vdbe*,Vdbe*);
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
int sqlite3VdbeReleaseMemory(int); int sqlite3VdbeReleaseMemory(int);
#endif
UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,void*,int); UnpackedRecord *sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,void*,int);
void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*); void sqlite3VdbeDeleteUnpackedRecord(UnpackedRecord*);
int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*); int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);

View File

@@ -421,7 +421,9 @@ int sqlite3VdbeMemFinalize(Mem*, FuncDef*);
const char *sqlite3OpcodeName(int); const char *sqlite3OpcodeName(int);
int sqlite3VdbeOpcodeHasProperty(int, int); int sqlite3VdbeOpcodeHasProperty(int, int);
int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve); int sqlite3VdbeMemGrow(Mem *pMem, int n, int preserve);
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
int sqlite3VdbeReleaseBuffers(Vdbe *p); int sqlite3VdbeReleaseBuffers(Vdbe *p);
#endif
#ifndef NDEBUG #ifndef NDEBUG
void sqlite3VdbeMemSanity(Mem*); void sqlite3VdbeMemSanity(Mem*);

View File

@@ -1,323 +1,332 @@
/* /*
** Performance test for SQLite. ** Performance test for SQLite.
** **
** This program reads ASCII text from a file named on the command-line ** This program reads ASCII text from a file named on the command-line
** and submits that text to SQLite for evaluation. A new database ** and submits that text to SQLite for evaluation. A new database
** is created at the beginning of the program. All statements are ** is created at the beginning of the program. All statements are
** timed using the high-resolution timer built into Intel-class processors. ** timed using the high-resolution timer built into Intel-class processors.
** **
** To compile this program, first compile the SQLite library separately ** To compile this program, first compile the SQLite library separately
** will full optimizations. For example: ** will full optimizations. For example:
** **
** gcc -c -O6 -DSQLITE_THREADSAFE=0 sqlite3.c ** gcc -c -O6 -DSQLITE_THREADSAFE=0 sqlite3.c
** **
** Then link against this program. But to do optimize this program ** Then link against this program. But to do optimize this program
** because that defeats the hi-res timer. ** because that defeats the hi-res timer.
** **
** gcc speedtest8.c sqlite3.o -ldl ** gcc speedtest8.c sqlite3.o -ldl
** **
** Then run this program with a single argument which is the name of ** Then run this program with a single argument which is the name of
** a file containing SQL script that you want to test: ** a file containing SQL script that you want to test:
** **
** ./a.out test.db test.sql ** ./a.out test.db test.sql
*/ */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <sys/times.h> #include <sys/times.h>
#include <time.h> #include <time.h>
#include <sched.h> #include <sched.h>
#include "sqlite3.h" #include "sqlite3.h"
/* /*
** The following routine only works on pentium-class processors. ** The following routine only works on pentium-class processors.
** It uses the RDTSC opcode to read the cycle count value out of the ** It uses the RDTSC opcode to read the cycle count value out of the
** processor and returns that value. This can be used for high-res ** processor and returns that value. This can be used for high-res
** profiling. ** profiling.
*/ */
__inline__ unsigned long long int hwtime(void){ __inline__ unsigned long long int hwtime(void){
unsigned int lo, hi; unsigned int lo, hi;
/* We cannot use "=A", since this would use %rax on x86_64 */ /* We cannot use "=A", since this would use %rax on x86_64 */
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
return (unsigned long long int)hi << 32 | lo; return (unsigned long long int)hi << 32 | lo;
} }
/* /*
** Timers ** Timers
*/ */
static unsigned long long int prepTime = 0; static unsigned long long int prepTime = 0;
static unsigned long long int runTime = 0; static unsigned long long int runTime = 0;
static unsigned long long int finalizeTime = 0; static unsigned long long int finalizeTime = 0;
/* /*
** Prepare and run a single statement of SQL. ** Prepare and run a single statement of SQL.
*/ */
static void prepareAndRun(sqlite3 *db, const char *zSql, int bQuiet){ static void prepareAndRun(sqlite3 *db, const char *zSql, int bQuiet){
sqlite3_stmt *pStmt; sqlite3_stmt *pStmt;
const char *stmtTail; const char *stmtTail;
unsigned long long int iStart, iElapse; unsigned long long int iStart, iElapse;
int rc; int rc;
if (!bQuiet) printf("****************************************************************\n"); if (!bQuiet){
if (!bQuiet) printf("SQL statement: [%s]\n", zSql); printf("***************************************************************\n");
iStart = hwtime(); }
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &stmtTail); if (!bQuiet) printf("SQL statement: [%s]\n", zSql);
iElapse = hwtime() - iStart; iStart = hwtime();
prepTime += iElapse; rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &stmtTail);
if (!bQuiet) printf("sqlite3_prepare_v2() returns %d in %llu cycles\n", rc, iElapse); iElapse = hwtime() - iStart;
if( rc==SQLITE_OK ){ prepTime += iElapse;
int nRow = 0; if (!bQuiet){
iStart = hwtime(); printf("sqlite3_prepare_v2() returns %d in %llu cycles\n", rc, iElapse);
while( (rc=sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; } }
iElapse = hwtime() - iStart; if( rc==SQLITE_OK ){
runTime += iElapse; int nRow = 0;
if (!bQuiet) printf("sqlite3_step() returns %d after %d rows in %llu cycles\n", iStart = hwtime();
rc, nRow, iElapse); while( (rc=sqlite3_step(pStmt))==SQLITE_ROW ){ nRow++; }
iStart = hwtime(); iElapse = hwtime() - iStart;
rc = sqlite3_finalize(pStmt); runTime += iElapse;
iElapse = hwtime() - iStart; if (!bQuiet){
finalizeTime += iElapse; printf("sqlite3_step() returns %d after %d rows in %llu cycles\n",
if (!bQuiet) printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse); rc, nRow, iElapse);
} }
} iStart = hwtime();
rc = sqlite3_finalize(pStmt);
/*************************************************************************** iElapse = hwtime() - iStart;
** The "overwrite" VFS is an overlay over the default VFS. It modifies finalizeTime += iElapse;
** the xTruncate operation on journal files so that xTruncate merely if (!bQuiet){
** writes zeros into the first 50 bytes of the file rather than truely printf("sqlite3_finalize() returns %d in %llu cycles\n", rc, iElapse);
** truncating the file. }
** }
** The following variables are initialized to be the virtual function }
** tables for the overwrite VFS.
*/ /***************************************************************************
static sqlite3_vfs overwrite_vfs; ** The "overwrite" VFS is an overlay over the default VFS. It modifies
static sqlite3_io_methods overwrite_methods; ** the xTruncate operation on journal files so that xTruncate merely
** writes zeros into the first 50 bytes of the file rather than truely
/* ** truncating the file.
** The truncate method for journal files in the overwrite VFS. **
*/ ** The following variables are initialized to be the virtual function
static int overwriteTruncate(sqlite3_file *pFile, sqlite_int64 size){ ** tables for the overwrite VFS.
int rc; */
static const char buf[50]; static sqlite3_vfs overwrite_vfs;
if( size ){ static sqlite3_io_methods overwrite_methods;
return SQLITE_IOERR;
} /*
rc = pFile->pMethods->xWrite(pFile, buf, sizeof(buf), 0); ** The truncate method for journal files in the overwrite VFS.
if( rc==SQLITE_OK ){ */
rc = pFile->pMethods->xSync(pFile, SQLITE_SYNC_NORMAL); static int overwriteTruncate(sqlite3_file *pFile, sqlite_int64 size){
} int rc;
return rc; static const char buf[50];
} if( size ){
return SQLITE_IOERR;
/* }
** The delete method for journal files in the overwrite VFS. rc = pFile->pMethods->xWrite(pFile, buf, sizeof(buf), 0);
*/ if( rc==SQLITE_OK ){
static int overwriteDelete(sqlite3_file *pFile){ rc = pFile->pMethods->xSync(pFile, SQLITE_SYNC_NORMAL);
return overwriteTruncate(pFile, 0); }
} return rc;
}
/*
** The open method for overwrite VFS. If the file being opened is /*
** a journal file then substitute the alternative xTruncate method. ** The delete method for journal files in the overwrite VFS.
*/ */
static int overwriteOpen( static int overwriteDelete(sqlite3_file *pFile){
sqlite3_vfs *pVfs, return overwriteTruncate(pFile, 0);
const char *zName, }
sqlite3_file *pFile,
int flags, /*
int *pOutFlags ** The open method for overwrite VFS. If the file being opened is
){ ** a journal file then substitute the alternative xTruncate method.
int rc; */
sqlite3_vfs *pRealVfs; static int overwriteOpen(
int isJournal; sqlite3_vfs *pVfs,
const char *zName,
isJournal = (flags & (SQLITE_OPEN_MAIN_JOURNAL|SQLITE_OPEN_TEMP_JOURNAL))!=0; sqlite3_file *pFile,
pRealVfs = (sqlite3_vfs*)pVfs->pAppData; int flags,
rc = pRealVfs->xOpen(pRealVfs, zName, pFile, flags, pOutFlags); int *pOutFlags
if( rc==SQLITE_OK && isJournal ){ ){
if( overwrite_methods.xTruncate==0 ){ int rc;
sqlite3_io_methods temp; sqlite3_vfs *pRealVfs;
memcpy(&temp, pFile->pMethods, sizeof(temp)); int isJournal;
temp.xTruncate = overwriteTruncate;
memcpy(&overwrite_methods, &temp, sizeof(temp)); isJournal = (flags & (SQLITE_OPEN_MAIN_JOURNAL|SQLITE_OPEN_TEMP_JOURNAL))!=0;
} pRealVfs = (sqlite3_vfs*)pVfs->pAppData;
pFile->pMethods = &overwrite_methods; rc = pRealVfs->xOpen(pRealVfs, zName, pFile, flags, pOutFlags);
} if( rc==SQLITE_OK && isJournal ){
return rc; if( overwrite_methods.xTruncate==0 ){
} sqlite3_io_methods temp;
memcpy(&temp, pFile->pMethods, sizeof(temp));
/* temp.xTruncate = overwriteTruncate;
** Overlay the overwrite VFS over top of the current default VFS memcpy(&overwrite_methods, &temp, sizeof(temp));
** and make the overlay VFS the new default. }
** pFile->pMethods = &overwrite_methods;
** This routine can only be evaluated once. On second and subsequent }
** executions it becomes a no-op. return rc;
*/ }
static void registerOverwriteVfs(void){
sqlite3_vfs *pBase; /*
if( overwrite_vfs.iVersion ) return; ** Overlay the overwrite VFS over top of the current default VFS
pBase = sqlite3_vfs_find(0); ** and make the overlay VFS the new default.
memcpy(&overwrite_vfs, pBase, sizeof(overwrite_vfs)); **
overwrite_vfs.pAppData = pBase; ** This routine can only be evaluated once. On second and subsequent
overwrite_vfs.xOpen = overwriteOpen; ** executions it becomes a no-op.
overwrite_vfs.zName = "overwriteVfs"; */
sqlite3_vfs_register(&overwrite_vfs, 1); static void registerOverwriteVfs(void){
} sqlite3_vfs *pBase;
if( overwrite_vfs.iVersion ) return;
int main(int argc, char **argv){ pBase = sqlite3_vfs_find(0);
sqlite3 *db; memcpy(&overwrite_vfs, pBase, sizeof(overwrite_vfs));
int rc; overwrite_vfs.pAppData = pBase;
int nSql; overwrite_vfs.xOpen = overwriteOpen;
char *zSql; overwrite_vfs.zName = "overwriteVfs";
int i, j; sqlite3_vfs_register(&overwrite_vfs, 1);
FILE *in; }
unsigned long long int iStart, iElapse;
unsigned long long int iSetup = 0; int main(int argc, char **argv){
int nStmt = 0; sqlite3 *db;
int nByte = 0; int rc;
const char *zArgv0 = argv[0]; int nSql;
int bQuiet = 0; char *zSql;
struct tms tmsStart, tmsEnd; int i, j;
clock_t clkStart, clkEnd; FILE *in;
unsigned long long int iStart, iElapse;
#ifdef HAVE_OSINST unsigned long long int iSetup = 0;
extern sqlite3_vfs *sqlite3_instvfs_binarylog(char *, char *, char *); int nStmt = 0;
extern void sqlite3_instvfs_destroy(sqlite3_vfs *); int nByte = 0;
sqlite3_vfs *pVfs = 0; const char *zArgv0 = argv[0];
#endif int bQuiet = 0;
struct tms tmsStart, tmsEnd;
while (argc>3) clock_t clkStart, clkEnd;
{
if( argc>3 && strcmp(argv[1], "-overwrite")==0 ){ #ifdef HAVE_OSINST
registerOverwriteVfs(); extern sqlite3_vfs *sqlite3_instvfs_binarylog(char *, char *, char *);
argv++; extern void sqlite3_instvfs_destroy(sqlite3_vfs *);
argc--; sqlite3_vfs *pVfs = 0;
continue; #endif
}
while (argc>3)
#ifdef HAVE_OSINST {
if( argc>4 && (strcmp(argv[1], "-log")==0) ){ if( argc>3 && strcmp(argv[1], "-overwrite")==0 ){
pVfs = sqlite3_instvfs_binarylog("oslog", 0, argv[2]); registerOverwriteVfs();
sqlite3_vfs_register(pVfs, 1); argv++;
argv += 2; argc--;
argc -= 2; continue;
continue; }
}
#endif #ifdef HAVE_OSINST
if( argc>4 && (strcmp(argv[1], "-log")==0) ){
/* pVfs = sqlite3_instvfs_binarylog("oslog", 0, argv[2]);
** Increasing the priority slightly above normal can help with repeatability sqlite3_vfs_register(pVfs, 1);
** of testing. Note that with Cygwin, -5 equates to "High", +5 equates to "Low", argv += 2;
** and anything in between equates to "Normal". argc -= 2;
*/ continue;
if( argc>4 && (strcmp(argv[1], "-priority")==0) ){ }
struct sched_param myParam; #endif
sched_getparam(0, &myParam);
printf ("Current process priority is %d.\n", (int)myParam.sched_priority); /*
myParam.sched_priority = atoi(argv[2]); ** Increasing the priority slightly above normal can help with
printf ("Setting process priority to %d.\n", (int)myParam.sched_priority); ** repeatability of testing. Note that with Cygwin, -5 equates
if (sched_setparam (0, &myParam) != 0){ ** to "High", +5 equates to "Low", and anything in between
printf ("error setting priority\n"); ** equates to "Normal".
exit(2); */
} if( argc>4 && (strcmp(argv[1], "-priority")==0) ){
argv += 2; struct sched_param myParam;
argc -= 2; sched_getparam(0, &myParam);
continue; printf ("Current process priority is %d.\n", (int)myParam.sched_priority);
} myParam.sched_priority = atoi(argv[2]);
printf ("Setting process priority to %d.\n", (int)myParam.sched_priority);
if( argc>3 && strcmp(argv[1], "-quiet")==0 ){ if (sched_setparam (0, &myParam) != 0){
bQuiet = -1; printf ("error setting priority\n");
argv++; exit(2);
argc--; }
continue; argv += 2;
} argc -= 2;
continue;
break; }
}
if( argc>3 && strcmp(argv[1], "-quiet")==0 ){
if( argc!=3 ){ bQuiet = -1;
fprintf(stderr, "Usage: %s [options] FILENAME SQL-SCRIPT\n" argv++;
"Runs SQL-SCRIPT against a UTF8 database\n" argc--;
"\toptions:\n" continue;
"\t-overwrite\n" }
#ifdef HAVE_OSINST
"\t-log <log>\n" break;
#endif }
"\t-priority <value> : set priority of task\n"
"\t-quiet : only display summary results\n", if( argc!=3 ){
zArgv0); fprintf(stderr, "Usage: %s [options] FILENAME SQL-SCRIPT\n"
exit(1); "Runs SQL-SCRIPT against a UTF8 database\n"
} "\toptions:\n"
"\t-overwrite\n"
in = fopen(argv[2], "r"); #ifdef HAVE_OSINST
fseek(in, 0L, SEEK_END); "\t-log <log>\n"
nSql = ftell(in); #endif
zSql = malloc( nSql+1 ); "\t-priority <value> : set priority of task\n"
fseek(in, 0L, SEEK_SET); "\t-quiet : only display summary results\n",
nSql = fread(zSql, 1, nSql, in); zArgv0);
zSql[nSql] = 0; exit(1);
}
printf("SQLite version: %d\n", sqlite3_libversion_number());
unlink(argv[1]); in = fopen(argv[2], "r");
clkStart = times(&tmsStart); fseek(in, 0L, SEEK_END);
iStart = hwtime(); nSql = ftell(in);
rc = sqlite3_open(argv[1], &db); zSql = malloc( nSql+1 );
iElapse = hwtime() - iStart; fseek(in, 0L, SEEK_SET);
iSetup = iElapse; nSql = fread(zSql, 1, nSql, in);
if (!bQuiet) printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse); zSql[nSql] = 0;
for(i=j=0; j<nSql; j++){
if( zSql[j]==';' ){ printf("SQLite version: %d\n", sqlite3_libversion_number());
int isComplete; unlink(argv[1]);
char c = zSql[j+1]; clkStart = times(&tmsStart);
zSql[j+1] = 0; iStart = hwtime();
isComplete = sqlite3_complete(&zSql[i]); rc = sqlite3_open(argv[1], &db);
zSql[j+1] = c; iElapse = hwtime() - iStart;
if( isComplete ){ iSetup = iElapse;
zSql[j] = 0; if (!bQuiet) printf("sqlite3_open() returns %d in %llu cycles\n", rc, iElapse);
while( i<j && isspace(zSql[i]) ){ i++; } for(i=j=0; j<nSql; j++){
if( i<j ){ if( zSql[j]==';' ){
int n = j - i; int isComplete;
if( n>=6 && memcmp(&zSql[i], ".crash",6)==0 ) exit(1); char c = zSql[j+1];
nStmt++; zSql[j+1] = 0;
nByte += n; isComplete = sqlite3_complete(&zSql[i]);
prepareAndRun(db, &zSql[i], bQuiet); zSql[j+1] = c;
} if( isComplete ){
zSql[j] = ';'; zSql[j] = 0;
i = j+1; while( i<j && isspace(zSql[i]) ){ i++; }
} if( i<j ){
} int n = j - i;
} if( n>=6 && memcmp(&zSql[i], ".crash",6)==0 ) exit(1);
iStart = hwtime(); nStmt++;
sqlite3_close(db); nByte += n;
iElapse = hwtime() - iStart; prepareAndRun(db, &zSql[i], bQuiet);
clkEnd = times(&tmsEnd); }
iSetup += iElapse; zSql[j] = ';';
if (!bQuiet) printf("sqlite3_close() returns in %llu cycles\n", iElapse); i = j+1;
}
printf("\n"); }
printf("Statements run: %15d stmts\n", nStmt); }
printf("Bytes of SQL text: %15d bytes\n", nByte); iStart = hwtime();
printf("Total prepare time: %15llu cycles\n", prepTime); sqlite3_close(db);
printf("Total run time: %15llu cycles\n", runTime); iElapse = hwtime() - iStart;
printf("Total finalize time: %15llu cycles\n", finalizeTime); clkEnd = times(&tmsEnd);
printf("Open/Close time: %15llu cycles\n", iSetup); iSetup += iElapse;
printf("Total time: %15llu cycles\n", if (!bQuiet) printf("sqlite3_close() returns in %llu cycles\n", iElapse);
prepTime + runTime + finalizeTime + iSetup);
printf("\n");
printf("\n"); printf("Statements run: %15d stmts\n", nStmt);
printf("Total user CPU time: %15.3g secs\n", (tmsEnd.tms_utime - tmsStart.tms_utime)/(double)CLOCKS_PER_SEC ); printf("Bytes of SQL text: %15d bytes\n", nByte);
printf("Total system CPU time: %15.3g secs\n", (tmsEnd.tms_stime - tmsStart.tms_stime)/(double)CLOCKS_PER_SEC ); printf("Total prepare time: %15llu cycles\n", prepTime);
printf("Total real time: %15.3g secs\n", (clkEnd -clkStart)/(double)CLOCKS_PER_SEC ); printf("Total run time: %15llu cycles\n", runTime);
printf("Total finalize time: %15llu cycles\n", finalizeTime);
#ifdef HAVE_OSINST printf("Open/Close time: %15llu cycles\n", iSetup);
if( pVfs ){ printf("Total time: %15llu cycles\n",
sqlite3_instvfs_destroy(pVfs); prepTime + runTime + finalizeTime + iSetup);
printf("vfs log written to %s\n", argv[0]);
} printf("\n");
#endif printf("Total user CPU time: %15.3g secs\n", (tmsEnd.tms_utime - tmsStart.tms_utime)/(double)CLOCKS_PER_SEC );
printf("Total system CPU time: %15.3g secs\n", (tmsEnd.tms_stime - tmsStart.tms_stime)/(double)CLOCKS_PER_SEC );
return 0; printf("Total real time: %15.3g secs\n", (clkEnd -clkStart)/(double)CLOCKS_PER_SEC );
}
#ifdef HAVE_OSINST
if( pVfs ){
sqlite3_instvfs_destroy(pVfs);
printf("vfs log written to %s\n", argv[0]);
}
#endif
return 0;
}