From 781e34cde3908108e2cadf2c727e8fe0e8743961 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 20 Mar 2014 08:59:47 +0000 Subject: [PATCH 1/7] Add an experimental fix to avoid attempting to mmap memory from an offset that is not a multiple of the system page size on systems with page sizes larger than 32KB. FossilOrigin-Name: 6f3a5c24d254fc6faf607b505bdef4a7aafc21af --- manifest | 15 ++++++----- manifest.uuid | 2 +- src/os_unix.c | 71 ++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 60 insertions(+), 28 deletions(-) diff --git a/manifest b/manifest index 8ad063c938..0276975e81 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\ssome\sunnecessary\scalls\sto\ssqlite3VdbeRecordUnpack()\sthat\swere\sbeing\smade\swhen\smerging\sdata\sfrom\stwo\sor\smore\stemp\sfiles\stogether\sin\svdbesort.c -D 2014-03-19T20:01:25.712 +C Add\san\sexperimental\sfix\sto\savoid\sattempting\sto\smmap\smemory\sfrom\san\soffset\sthat\sis\snot\sa\smultiple\sof\sthe\ssystem\spage\ssize\son\ssystems\swith\spage\ssizes\slarger\sthan\s32KB. +D 2014-03-20T08:59:47.455 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -203,7 +203,7 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_unix.c 18f7f95dc6bcb9cf4d4a238d8e2de96611bc2ae5 +F src/os_unix.c 7e2f6348e99bd215d36cb5d40161b06456089e21 F src/os_win.c e71678ac927d0a0fb11d993db20a9748eabf808e F src/pager.c 97a8908bf4e6e7c3adea09d3597cfa48ae33ab4e F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 @@ -1156,7 +1156,10 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P ecd9d3f9453be0bb8e312d8027fd1a9e55882f36 -R 597feeb3c9b32d5be1e5c696f1b077da +P 707ea170b3e26965b7e3982f7554d122d130b9a6 +R df2b4ee35d794d54be353b7886f4773f +T *branch * shm-mapping-fix +T *sym-shm-mapping-fix * +T -sym-trunk * U dan -Z 03e3772c0627172d43f05f231b29ede3 +Z 8f1167a615e2deebf3a41d21381f8bfc diff --git a/manifest.uuid b/manifest.uuid index 5d0bb22e62..b57a947167 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -707ea170b3e26965b7e3982f7554d122d130b9a6 \ No newline at end of file +6f3a5c24d254fc6faf607b505bdef4a7aafc21af \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index deb9e51d07..151ed890ae 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -4105,6 +4105,33 @@ static int unixShmSystemLock( return rc; } +/* +** Return the system page size. +*/ +static int unixGetPagesize(void){ +#if defined(_BSD_SOURCE) + return getpagesize(); +#else + return (int)sysconf(_SC_PAGESIZE); +#endif +} + +/* +** Return the minimum number of 32KB shm regions that should be mapped at +** a time, assuming that each mapping must be an integer multiple of the +** current system page-size. +** +** Usually, this is 1. The exception seems to be systems that are configured +** to use 64KB pages - in this case each mapping must cover at least two +** shm regions. +*/ +static int unixShmRegionPerMap(void){ + int shmsz = 32*1024; /* SHM region size */ + int pgsz = unixGetPagesize(); /* System page size */ + assert( ((pgsz-1)&pgsz)==0 ); /* Page size must be a power of 2 */ + if( pgszpInode->pShmNode; assert( unixMutexHeld() ); if( p && p->nRef==0 ){ + int nShmPerMap = unixShmRegionPerMap(); int i; assert( p->pInode==pFd->pInode ); sqlite3_mutex_free(p->mutex); - for(i=0; inRegion; i++){ + for(i=0; inRegion; i+=nShmPerMap){ if( p->h>=0 ){ osMunmap(p->apRegion[i], p->szRegion); }else{ @@ -4326,6 +4354,8 @@ static int unixShmMap( unixShm *p; unixShmNode *pShmNode; int rc = SQLITE_OK; + int nShmPerMap = unixShmRegionPerMap(); + int nReqRegion; /* If the shared-memory file has not yet been opened, open it now. */ if( pDbFd->pShm==0 ){ @@ -4341,9 +4371,12 @@ static int unixShmMap( assert( pShmNode->h>=0 || pDbFd->pInode->bProcessLock==1 ); assert( pShmNode->h<0 || pDbFd->pInode->bProcessLock==0 ); - if( pShmNode->nRegion<=iRegion ){ + /* Minimum number of regions required to be mapped. */ + nReqRegion = ((iRegion+nShmPerMap) / nShmPerMap) * nShmPerMap; + + if( pShmNode->nRegionszRegion = szRegion; @@ -4392,17 +4425,19 @@ static int unixShmMap( /* Map the requested memory region into this processes address space. */ apNew = (char **)sqlite3_realloc( - pShmNode->apRegion, (iRegion+1)*sizeof(char *) + pShmNode->apRegion, nReqRegion*sizeof(char *) ); if( !apNew ){ rc = SQLITE_IOERR_NOMEM; goto shmpage_out; } pShmNode->apRegion = apNew; - while(pShmNode->nRegion<=iRegion){ + while( pShmNode->nRegionh>=0 ){ - pMem = osMmap(0, szRegion, + pMem = osMmap(0, nMap, pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE, MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion ); @@ -4418,8 +4453,11 @@ static int unixShmMap( } memset(pMem, 0, szRegion); } - pShmNode->apRegion[pShmNode->nRegion] = pMem; - pShmNode->nRegion++; + + for(i=0; iapRegion[pShmNode->nRegion+i] = &((char*)pMem)[szRegion*i]; + } + pShmNode->nRegion += nShmPerMap; } } @@ -4633,19 +4671,6 @@ static void unixUnmapfile(unixFile *pFd){ } } -/* -** Return the system page size. -*/ -static int unixGetPagesize(void){ -#if HAVE_MREMAP - return 512; -#elif defined(_BSD_SOURCE) - return getpagesize(); -#else - return (int)sysconf(_SC_PAGESIZE); -#endif -} - /* ** Attempt to set the size of the memory mapping maintained by file ** descriptor pFd to nNew bytes. Any existing mapping is discarded. @@ -4682,8 +4707,12 @@ static void unixRemapfile( if( (pFd->ctrlFlags & UNIXFILE_RDONLY)==0 ) flags |= PROT_WRITE; if( pOrig ){ +#if HAVE_MREMAP + i64 nReuse = pFd->mmapSize; +#else const int szSyspage = unixGetPagesize(); i64 nReuse = (pFd->mmapSize & ~(szSyspage-1)); +#endif u8 *pReq = &pOrig[nReuse]; /* Unmap any pages of the existing mapping that cannot be reused. */ From bc76063cd2d0c7bdf59965af73a67a2ed1181641 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 20 Mar 2014 09:42:09 +0000 Subject: [PATCH 2/7] Add a test to ensure os_unix.c works with 64KiB OS pages. FossilOrigin-Name: e3d2be3ba47cdaafd26347620ae3bc2813203f16 --- manifest | 20 +++++++++---------- manifest.uuid | 2 +- src/os_unix.c | 15 ++++++++++---- src/test_syscall.c | 49 +++++++++++++++++++++++++++++++++++++++++++++- test/syscall.test | 1 + test/wal64k.test | 47 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 117 insertions(+), 17 deletions(-) create mode 100644 test/wal64k.test diff --git a/manifest b/manifest index 0276975e81..5dfca569cc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sexperimental\sfix\sto\savoid\sattempting\sto\smmap\smemory\sfrom\san\soffset\sthat\sis\snot\sa\smultiple\sof\sthe\ssystem\spage\ssize\son\ssystems\swith\spage\ssizes\slarger\sthan\s32KB. -D 2014-03-20T08:59:47.455 +C Add\sa\stest\sto\sensure\sos_unix.c\sworks\swith\s64KiB\sOS\spages. +D 2014-03-20T09:42:09.744 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -203,7 +203,7 @@ F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c 1b147e4cf7cc39e618115c14a086aed44bc91ace F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_unix.c 7e2f6348e99bd215d36cb5d40161b06456089e21 +F src/os_unix.c ae4b5240af4619d711301d7992396e182585269f F src/os_win.c e71678ac927d0a0fb11d993db20a9748eabf808e F src/pager.c 97a8908bf4e6e7c3adea09d3597cfa48ae33ab4e F src/pager.h ffd5607f7b3e4590b415b007a4382f693334d428 @@ -266,7 +266,7 @@ F src/test_server.c a2615049954cbb9cfb4a62e18e2f0616e4dc38fe F src/test_sqllog.c c1c1bbedbcaf82b93d83e4f9dd990e62476a680e F src/test_stat.c 9898687a6c2beca733b0dd6fe19163d987826d31 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd -F src/test_syscall.c 16dbe79fb320fadb5acd7a0a59f49e52ab2d2091 +F src/test_syscall.c 2e21ca7f7dc54a028f1967b63f1e76155c356f9b F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c 1e133a40b50e9c035b00174035b846e7eef481cb F src/test_vfs.c e72f555ef7a59080f898fcf1a233deb9eb704ea9 @@ -835,7 +835,7 @@ F test/subselect.test d24fd8757daf97dafd2e889c73ea4c4272dcf4e4 F test/substr.test 18f57c4ca8a598805c4d64e304c418734d843c1a F test/superlock.test 1cde669f68d2dd37d6c9bd35eee1d95491ae3fc2 F test/sync.test a34cd43e98b7fb84eabbf38f7ed8f7349b3f3d85 -F test/syscall.test a653783d985108c4912cc64d341ffbbb55ad2806 +F test/syscall.test d2fdaad713f103ac611fe7ef9b724c7b69f8149c F test/sysfault.test fa776e60bf46bdd3ae69f0b73e46ee3977a58ae6 F test/table.test 580d23530187026d4502fae74a490f0408cf2cc7 F test/tableapi.test 2674633fa95d80da917571ebdd759a14d9819126 @@ -1054,6 +1054,7 @@ F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c F test/wal5.test 8f888b50f66b78821e61ed0e233ded5de378224b F test/wal6.test 527581f5527bf9c24394991e2be83000aace5f9e +F test/wal64k.test 63828c2161ad76ddd4109dee0a096b6ef6895698 F test/wal7.test 2ae8f427d240099cc4b2dfef63cff44e2a68a1bd F test/wal8.test 75c42e1bc4545c277fed212f8fc9b7723cd02216 F test/wal9.test 378e76a9ad09cd9bee06c172ad3547b0129a6750 @@ -1156,10 +1157,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 707ea170b3e26965b7e3982f7554d122d130b9a6 -R df2b4ee35d794d54be353b7886f4773f -T *branch * shm-mapping-fix -T *sym-shm-mapping-fix * -T -sym-trunk * +P 6f3a5c24d254fc6faf607b505bdef4a7aafc21af +R 20782a7f4b1e1e0590156d829fb7cb71 U dan -Z 8f1167a615e2deebf3a41d21381f8bfc +Z 523769a43e90bd1d8c3037ea221853f3 diff --git a/manifest.uuid b/manifest.uuid index b57a947167..40e6d382ef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f3a5c24d254fc6faf607b505bdef4a7aafc21af \ No newline at end of file +e3d2be3ba47cdaafd26347620ae3bc2813203f16 \ No newline at end of file diff --git a/src/os_unix.c b/src/os_unix.c index 151ed890ae..fc320a4926 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -323,6 +323,7 @@ static int posixFchown(int fd, uid_t uid, gid_t gid){ /* Forward reference */ static int openDirectory(const char*, int*); +static int unixGetpagesize(void); /* ** Many system calls are accessed through pointer-to-functions so that @@ -446,6 +447,9 @@ static struct unix_syscall { #define osMremap ((void*(*)(void*,size_t,size_t,int,...))aSyscall[23].pCurrent) #endif + { "getpagesize", (sqlite3_syscall_ptr)unixGetpagesize, 0 }, +#define osGetpagesize ((int(*)(void))aSyscall[24].pCurrent) + }; /* End of the overrideable system calls */ /* @@ -4107,8 +4111,11 @@ static int unixShmSystemLock( /* ** Return the system page size. +** +** This function should not be called directly by other code in this file. +** Instead, it should be called via macro osGetpagesize(). */ -static int unixGetPagesize(void){ +static int unixGetpagesize(void){ #if defined(_BSD_SOURCE) return getpagesize(); #else @@ -4127,7 +4134,7 @@ static int unixGetPagesize(void){ */ static int unixShmRegionPerMap(void){ int shmsz = 32*1024; /* SHM region size */ - int pgsz = unixGetPagesize(); /* System page size */ + int pgsz = osGetpagesize(); /* System page size */ assert( ((pgsz-1)&pgsz)==0 ); /* Page size must be a power of 2 */ if( pgszmmapSize; #else - const int szSyspage = unixGetPagesize(); + const int szSyspage = osGetpagesize(); i64 nReuse = (pFd->mmapSize & ~(szSyspage-1)); #endif u8 *pReq = &pOrig[nReuse]; @@ -7458,7 +7465,7 @@ int sqlite3_os_init(void){ /* Double-check that the aSyscall[] array has been constructed ** correctly. See ticket [bb3a86e890c8e96ab] */ - assert( ArraySize(aSyscall)==24 ); + assert( ArraySize(aSyscall)==25 ); /* Register all VFSes defined in the aVfs[] array */ for(i=0; i<(sizeof(aVfs)/sizeof(sqlite3_vfs)); i++){ diff --git a/src/test_syscall.c b/src/test_syscall.c index 7c0873c16d..0dac2e897e 100644 --- a/src/test_syscall.c +++ b/src/test_syscall.c @@ -67,6 +67,11 @@ ** test_syscall list ** Return a list of all system calls. The list is constructed using ** the xNextSystemCall() VFS method. +** +** test_syscall pagesize PGSZ +** If PGSZ is a power of two greater than 256, install a wrapper around +** OS function getpagesize() that reports the system page size as PGSZ. +** Or, if PGSZ is less than zero, remove any wrapper already installed. */ #include "sqliteInt.h" @@ -89,7 +94,9 @@ static struct TestSyscallGlobal { int bPersist; /* 1 for persistent errors, 0 for transient */ int nCount; /* Fail after this many more calls */ int nFail; /* Number of failures that have occurred */ -} gSyscall = { 0, 0 }; + int pgsz; + sqlite3_syscall_ptr orig_getpagesize; +} gSyscall = { 0, 0, 0, 0, 0 }; static int ts_open(const char *, int, int); static int ts_close(int fd); @@ -650,6 +657,45 @@ static int test_syscall_defaultvfs( return TCL_OK; } +static int ts_getpagesize(void){ + return gSyscall.pgsz; +} + +static int test_syscall_pagesize( + void * clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + sqlite3_vfs *pVfs = sqlite3_vfs_find(0); + int pgsz; + if( objc!=3 ){ + Tcl_WrongNumArgs(interp, 2, objv, "PGSZ"); + return TCL_ERROR; + } + if( Tcl_GetIntFromObj(interp, objv[2], &pgsz) ){ + return TCL_ERROR; + } + + if( pgsz<0 ){ + if( gSyscall.orig_getpagesize ){ + pVfs->xSetSystemCall(pVfs, "getpagesize", gSyscall.orig_getpagesize); + } + }else{ + if( pgsz<512 || (pgsz & (pgsz-1)) ){ + Tcl_AppendResult(interp, "pgsz out of range", 0); + return TCL_ERROR; + } + gSyscall.orig_getpagesize = pVfs->xGetSystemCall(pVfs, "getpagesize"); + gSyscall.pgsz = pgsz; + pVfs->xSetSystemCall( + pVfs, "getpagesize", (sqlite3_syscall_ptr)ts_getpagesize + ); + } + + return TCL_OK; +} + static int test_syscall( void * clientData, Tcl_Interp *interp, @@ -668,6 +714,7 @@ static int test_syscall( { "exists", test_syscall_exists }, { "list", test_syscall_list }, { "defaultvfs", test_syscall_defaultvfs }, + { "pagesize", test_syscall_pagesize }, { 0, 0 } }; int iCmd; diff --git a/test/syscall.test b/test/syscall.test index 5bf1225867..c2d9979031 100644 --- a/test/syscall.test +++ b/test/syscall.test @@ -61,6 +61,7 @@ foreach s { fcntl read pread write pwrite fchmod fallocate pread64 pwrite64 unlink openDirectory mkdir rmdir statvfs fchown umask mmap munmap mremap + getpagesize } { if {[test_syscall exists $s]} {lappend syscall_list $s} } diff --git a/test/wal64k.test b/test/wal64k.test new file mode 100644 index 0000000000..afd820778e --- /dev/null +++ b/test/wal64k.test @@ -0,0 +1,47 @@ +# 2010 April 13 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the operation of the library in +# "PRAGMA journal_mode=WAL" mode. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix wal64k + +ifcapable !wal {finish_test ; return } + +db close +test_syscall pagesize 65536 +sqlite3 db test.db + +do_execsql_test 1.0 { + PRAGMA journal_mode = WAL; + CREATE TABLE t1(x); + CREATE INDEX i1 ON t1(x); +} {wal} +do_test 1.1 { file size test.db-shm } {65536} + +do_test 1.2 { + execsql BEGIN + while {[file size test.db-shm]==65536} { + execsql { INSERT INTO t1 VALUES( randstr(900,1100) ) } + } + execsql COMMIT + file size test.db-shm +} {131072} + +integrity_check 1.3 + +db close +test_syscall pagesize -1 +finish_test + From 3d1d90a13da2d8a617f86756b79d9289b03ed566 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 24 Mar 2014 15:00:15 +0000 Subject: [PATCH 3/7] Fix arithmetic operators so that they do not change the affinity of their input operands. Ticket [a8a0d2996a]. FossilOrigin-Name: 221f8f944703108e47d789fa8ce6c00fe2abcbb6 --- manifest | 15 ++++--- manifest.uuid | 2 +- src/vdbe.c | 35 ++++++++++++--- test/tkt-a8a0d2996a.test | 93 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 132 insertions(+), 13 deletions(-) create mode 100644 test/tkt-a8a0d2996a.test diff --git a/manifest b/manifest index 3c6309f95b..9e30ebbe2c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\sattempting\sto\smmap\smemory\sfrom\san\soffset\sthat\sis\snot\sa\smultiple\sof\sthe\ssystem\spage\ssize\son\ssystems\swith\spage\ssizes\slarger\sthan\s32KB. -D 2014-03-24T11:23:17.736 +C Fix\sarithmetic\soperators\sso\sthat\sthey\sdo\snot\schange\sthe\saffinity\sof\stheir\ninput\soperands.\s\sTicket\s[a8a0d2996a]. +D 2014-03-24T15:00:15.271 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -278,7 +278,7 @@ F src/update.c 5b3e74a03b3811e586b4f2b4cbd7c49f01c93115 F src/utf.c 6dc9ec9f1b3db43ae8ba0365377f11df1ee4c01c F src/util.c c46c90459ef9bdc0c6c73803cf4c55425b4771cf F src/vacuum.c 3728d74919d4fb1356f9e9a13e27773db60b7179 -F src/vdbe.c 5c0feeb6c9e6a0e0cc2a9715aa6045830643809d +F src/vdbe.c 74c7386e83eee56f921a17bb4a0396c9551f5bc7 F src/vdbe.h fb2c48c198300a7c632f09fc940011d2ad2fc2ae F src/vdbeInt.h 2b9a6849166d0014c843ae3fd83a062be4efa325 F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 @@ -892,6 +892,7 @@ F test/tkt-94c04eaadb.test f738c57c7f68ab8be1c054415af7774617cb6223 F test/tkt-9d68c883.test 458f7d82a523d7644b54b497c986378a7d8c8b67 F test/tkt-9f2eb3abac.test 85bc63e749f050e6a61c8f9207f1eee65c9d3395 F test/tkt-a7b7803e.test 159ef554234fa1f9fb318c751b284bd1cf858da4 +F test/tkt-a8a0d2996a.test eb597379dbcefa24765763d7f682c00cb5924fa9 F test/tkt-b1d3a2e531.test 8f7576e41ca179289ee1a8fee28386fd8e4b0550 F test/tkt-b351d95f9.test d14a503c414c5c58fdde3e80f9a3cfef986498c0 F test/tkt-b72787b1.test a95e8cdad0b98af1853ac7f0afd4ab27b77bf5f3 @@ -1158,7 +1159,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 641408a1395bfc911ca619ef9e5f073b913d856b e3d2be3ba47cdaafd26347620ae3bc2813203f16 -R aadeef09c98319ee1e1acbdf39605080 -U dan -Z a7c50b19ab534dd04ee960894cca4791 +P db7d62c8d58eb1e8654a762c9b199ae4e2759038 +R c2ec5fb627231252d937ea015ddf100a +U drh +Z 7360db1b973f463e9c0480db05633068 diff --git a/manifest.uuid b/manifest.uuid index 3a41778163..9344d79651 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -db7d62c8d58eb1e8654a762c9b199ae4e2759038 \ No newline at end of file +221f8f944703108e47d789fa8ce6c00fe2abcbb6 \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index b70c5e1c9d..84f720b526 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -310,6 +310,29 @@ void sqlite3ValueApplyAffinity( applyAffinity((Mem *)pVal, affinity, enc); } +/* +** Return the numeric type for pMem, either MEM_Int or MEM_Real or both or +** none. +** +** Unlike applyNumericAffinity(), this routine does not modify pMem->flags. +** But it does set pMem->r and pMem->u.i appropriately. +*/ +static u16 numericType(Mem *pMem){ + if( pMem->flags & (MEM_Int|MEM_Real) ){ + return pMem->flags & (MEM_Int|MEM_Real); + } + if( pMem->flags & (MEM_Str|MEM_Blob) ){ + if( sqlite3AtoF(pMem->z, &pMem->r, pMem->n, pMem->enc)==0 ){ + return 0; + } + if( sqlite3Atoi64(pMem->z, &pMem->u.i, pMem->n, pMem->enc)==SQLITE_OK ){ + return MEM_Int; + } + return MEM_Real; + } + return 0; +} + #ifdef SQLITE_DEBUG /* ** Write a nice string representation of the contents of cell pMem @@ -1351,20 +1374,22 @@ case OP_Multiply: /* same as TK_STAR, in1, in2, out3 */ case OP_Divide: /* same as TK_SLASH, in1, in2, out3 */ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */ char bIntint; /* Started out as two integer operands */ - int flags; /* Combined MEM_* flags from both inputs */ + u16 flags; /* Combined MEM_* flags from both inputs */ + u16 type1; /* Numeric type of left operand */ + u16 type2; /* Numeric type of right operand */ i64 iA; /* Integer value of left operand */ i64 iB; /* Integer value of right operand */ double rA; /* Real value of left operand */ double rB; /* Real value of right operand */ pIn1 = &aMem[pOp->p1]; - applyNumericAffinity(pIn1); + type1 = numericType(pIn1); pIn2 = &aMem[pOp->p2]; - applyNumericAffinity(pIn2); + type2 = numericType(pIn2); pOut = &aMem[pOp->p3]; flags = pIn1->flags | pIn2->flags; if( (flags & MEM_Null)!=0 ) goto arithmetic_result_is_null; - if( (pIn1->flags & pIn2->flags & MEM_Int)==MEM_Int ){ + if( (type1 & type2 & MEM_Int)!=0 ){ iA = pIn1->u.i; iB = pIn2->u.i; bIntint = 1; @@ -1420,7 +1445,7 @@ fp_math: } pOut->r = rB; MemSetTypeFlag(pOut, MEM_Real); - if( (flags & MEM_Real)==0 && !bIntint ){ + if( ((type1|type2)&MEM_Real)==0 && !bIntint ){ sqlite3VdbeIntegerAffinity(pOut); } #endif diff --git a/test/tkt-a8a0d2996a.test b/test/tkt-a8a0d2996a.test new file mode 100644 index 0000000000..6b15e410e7 --- /dev/null +++ b/test/tkt-a8a0d2996a.test @@ -0,0 +1,93 @@ +# 2014-03-24 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# +# Tests to verify that arithmetic operators do not change the type of +# input operands. Ticket [a8a0d2996a] +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix tkt-a8a0d2996a + +do_execsql_test 1.0 { + CREATE TABLE t(x,y); + INSERT INTO t VALUES('1','1'); + SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1'; +} {text text} +do_execsql_test 1.1 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1'; +} {text text} +do_execsql_test 1.2 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1'; +} {text text} +do_execsql_test 1.3 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1'; +} {text text} +do_execsql_test 1.4 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1'; +} {text text} + +do_execsql_test 2.0 { + UPDATE t SET x='1xyzzy'; + SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1'; +} {text text} +do_execsql_test 2.1 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1'; +} {text text} +do_execsql_test 2.2 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1'; +} {text text} +do_execsql_test 2.3 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1'; +} {text text} +do_execsql_test 2.4 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1'; +} {text text} + + +do_execsql_test 3.0 { + UPDATE t SET x='1.0'; + SELECT typeof(x), typeof(y) FROM t WHERE 1=x+0 AND y=='1'; +} {text text} +do_execsql_test 3.1 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x-0 AND y=='1'; +} {text text} +do_execsql_test 3.2 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x*1 AND y=='1'; +} {text text} +do_execsql_test 3.3 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x/1 AND y=='1'; +} {text text} +do_execsql_test 3.4 { + SELECT typeof(x), typeof(y) FROM t WHERE 1=x%4 AND y=='1'; +} {text text} + +do_execsql_test 4.0 { + SELECT 1+1.; +} {2.0} +do_execsql_test 4.1 { + SELECT '1.23e64'/'1.0000e+62'; +} {123.0} +do_execsql_test 4.2 { + SELECT '100x'+'-2y'; +} {98} +do_execsql_test 4.3 { + SELECT '100x'+'4.5y'; +} {104.5} +do_execsql_test 4.4 { + SELECT '-9223372036854775807x'-'1x'; +} {-9.22337203685478e+18} +do_execsql_test 4.5 { + SELECT '9223372036854775806x'+'1x'; +} {9.22337203685478e+18} +do_execsql_test 4.6 { + SELECT '1234x'/'10y'; +} {123.4} From b22f38a7791fed647b172dff6b2b1cf308b6e66c Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 24 Mar 2014 16:30:06 +0000 Subject: [PATCH 4/7] Remove unused variables Parse.nColCache and Parse.iColCache. FossilOrigin-Name: 4d7551ce464c8038147e81667368924f2a7485a6 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 2 -- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 9e30ebbe2c..58b47e5f6f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sarithmetic\soperators\sso\sthat\sthey\sdo\snot\schange\sthe\saffinity\sof\stheir\ninput\soperands.\s\sTicket\s[a8a0d2996a]. -D 2014-03-24T15:00:15.271 +C Remove\sunused\svariables\sParse.nColCache\sand\sParse.iColCache. +D 2014-03-24T16:30:06.093 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -222,7 +222,7 @@ F src/shell.c cee9f46f2688a261601b1fd3d7f4b3cddf9b5cdf F src/sqlite.h.in a2ef671f92747a5a1c8a47bad5c585a8dd9eca80 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 1e16bac177ce6396e59af867afb90c92949895de +F src/sqliteInt.h afbf39e96736ceb85e1d896b281ba2406dd70aa0 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1159,7 +1159,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P db7d62c8d58eb1e8654a762c9b199ae4e2759038 -R c2ec5fb627231252d937ea015ddf100a -U drh -Z 7360db1b973f463e9c0480db05633068 +P 221f8f944703108e47d789fa8ce6c00fe2abcbb6 +R dc20bd716d0015e30edc93a05e72ad4b +U dan +Z 0a61715f43b39f80ef65df2d7add7843 diff --git a/manifest.uuid b/manifest.uuid index 9344d79651..de90fd9eab 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -221f8f944703108e47d789fa8ce6c00fe2abcbb6 \ No newline at end of file +4d7551ce464c8038147e81667368924f2a7485a6 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 27dfc08e0f..5e0dd91ec9 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2393,8 +2393,6 @@ struct Parse { u8 checkSchema; /* Causes schema cookie check after an error */ u8 nested; /* Number of nested calls to the parser/code generator */ u8 nTempReg; /* Number of temporary registers in aTempReg[] */ - u8 nColCache; /* Number of entries in aColCache[] */ - u8 iColCache; /* Next entry in aColCache[] to replace */ u8 isMultiWrite; /* True if statement may modify/insert multiple rows */ u8 mayAbort; /* True if statement may throw an ABORT exception */ u8 hasCompound; /* Need to invoke convertCompoundSelectToSubquery() */ From 86dd3716b998bbc2ca2f1aad2a5c01eeb0d7ece8 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 25 Mar 2014 11:00:21 +0000 Subject: [PATCH 5/7] Detect when a VdbeCursor is still pointing at a valid row but that row has moved, and invalidated the return from prior sqlite3BtreeDataFetch() or sqlite3BtreeKeyFetch() calls. FossilOrigin-Name: e6798871ce94961135762669af418cd78540c121 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 23 +++++++++++++++++++---- src/vdbeaux.c | 2 +- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 58b47e5f6f..e6372d6699 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\sunused\svariables\sParse.nColCache\sand\sParse.iColCache. -D 2014-03-24T16:30:06.093 +C Detect\swhen\sa\sVdbeCursor\sis\sstill\spointing\sat\sa\svalid\srow\sbut\sthat\srow\shas\nmoved,\sand\sinvalidated\sthe\sreturn\sfrom\sprior\ssqlite3BtreeDataFetch()\sor\nsqlite3BtreeKeyFetch()\scalls. +D 2014-03-25T11:00:21.320 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -164,7 +164,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c a729e63cf5cd1829507cb7b8e89f99b95141bb53 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 029cec7b98fe0a985922c03f101630391044c4ad +F src/btree.c 8d7e432bdd27d63182865c708ea0e7606489b6d1 F src/btree.h 232836cb51753f2e96aa8ce0f052c6df850f76ba F src/btreeInt.h 0be66063468a520e4d66b80c7a1dc26d04ee6ea4 F src/build.c 0d50ef95aad63f4c4fc47f3fa2670d4557c45db0 @@ -282,7 +282,7 @@ F src/vdbe.c 74c7386e83eee56f921a17bb4a0396c9551f5bc7 F src/vdbe.h fb2c48c198300a7c632f09fc940011d2ad2fc2ae F src/vdbeInt.h 2b9a6849166d0014c843ae3fd83a062be4efa325 F src/vdbeapi.c 0ed6053f947edd0b30f64ce5aeb811872a3450a4 -F src/vdbeaux.c 5078ca7de4fd5ba4535bd17fe44d5b56c2d3294c +F src/vdbeaux.c 68dbdc77cdc008eeabc088b8b8a60aa743ba8d2a F src/vdbeblob.c 15377abfb59251bccedd5a9c7d014a895f0c04aa F src/vdbemem.c 6fc77594c60f6155404f3f8d71bf36d1fdeb4447 F src/vdbesort.c 4abb7c0f8f19b7d7d82f4558d5da1a30fdf9ea38 @@ -1159,7 +1159,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 221f8f944703108e47d789fa8ce6c00fe2abcbb6 -R dc20bd716d0015e30edc93a05e72ad4b -U dan -Z 0a61715f43b39f80ef65df2d7add7843 +P 4d7551ce464c8038147e81667368924f2a7485a6 +R 8613a90c52863cb0b93f254b2d121d4b +U drh +Z f61d5d3cf5132dbd8d9ed764bc0739f9 diff --git a/manifest.uuid b/manifest.uuid index de90fd9eab..b106017e83 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4d7551ce464c8038147e81667368924f2a7485a6 \ No newline at end of file +e6798871ce94961135762669af418cd78540c121 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 486cf8e6d5..43d41d67e9 100644 --- a/src/btree.c +++ b/src/btree.c @@ -746,20 +746,32 @@ static int btreeRestoreCursorPosition(BtCursor *pCur){ ** at is deleted out from under them. ** ** This routine returns an error code if something goes wrong. The -** integer *pHasMoved is set to one if the cursor has moved and 0 if not. +** integer *pHasMoved is set as follows: +** +** 0: The cursor is unchanged +** 1: The cursor is still pointing at the same row, but the pointers +** returned by sqlite3BtreeKeyFetch() or sqlite3BtreeDataFetch() +** might now be invalid because of a balance() or other change to the +** b-tree. +** 2: The cursor is no longer pointing to the row. The row might have +** been deleted out from under the cursor. */ int sqlite3BtreeCursorHasMoved(BtCursor *pCur, int *pHasMoved){ int rc; + if( pCur->eState==CURSOR_VALID ){ + *pHasMoved = 0; + return SQLITE_OK; + } rc = restoreCursorPosition(pCur); if( rc ){ - *pHasMoved = 1; + *pHasMoved = 2; return rc; } if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){ - *pHasMoved = 1; + *pHasMoved = 2; }else{ - *pHasMoved = 0; + *pHasMoved = 1; } return SQLITE_OK; } @@ -4188,10 +4200,13 @@ static const void *fetchPayload( assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) ); assert( cursorHoldsMutex(pCur) ); assert( pCur->aiIdx[pCur->iPage]apPage[pCur->iPage]->nCell ); + assert( pCur->info.nSize>0 ); +#if 0 if( pCur->info.nSize==0 ){ btreeParseCell(pCur->apPage[pCur->iPage], pCur->aiIdx[pCur->iPage], &pCur->info); } +#endif *pAmt = pCur->info.nLocal; return (void*)(pCur->info.pCell + pCur->info.nHeader); } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index 6f1fa2670b..0d2299bab1 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2735,7 +2735,7 @@ int sqlite3VdbeCursorMoveto(VdbeCursor *p){ if( rc ) return rc; if( hasMoved ){ p->cacheStatus = CACHE_STALE; - p->nullRow = 1; + if( hasMoved==2 ) p->nullRow = 1; } } return SQLITE_OK; From 0c60c1fe6674d50ea394ffd9ec08201414c5251b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 25 Mar 2014 14:54:36 +0000 Subject: [PATCH 6/7] Add an ORDER BY test case to speedtest1.c FossilOrigin-Name: 588122641e57e957813d329ea071e13ccbde5acd --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index e6372d6699..5a5497d41f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Detect\swhen\sa\sVdbeCursor\sis\sstill\spointing\sat\sa\svalid\srow\sbut\sthat\srow\shas\nmoved,\sand\sinvalidated\sthe\sreturn\sfrom\sprior\ssqlite3BtreeDataFetch()\sor\nsqlite3BtreeKeyFetch()\scalls. -D 2014-03-25T11:00:21.320 +C Add\san\sORDER\sBY\stest\scase\sto\sspeedtest1.c +D 2014-03-25T14:54:36.731 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -825,7 +825,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/speedtest1.c 1603da7b4897716f9df15bd71b0310f56ec3181e +F test/speedtest1.c bbf90952e0464e464467c72785602cca82a4d842 F test/spellfix.test 61309f5efbec53603b3f86457d34a504f80abafe F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test 76fd746b85459e812a0193410fb599f0531f22de @@ -1159,7 +1159,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 4d7551ce464c8038147e81667368924f2a7485a6 -R 8613a90c52863cb0b93f254b2d121d4b +P e6798871ce94961135762669af418cd78540c121 +R 63e64c2147fb938edf250ea589ed8a9b U drh -Z f61d5d3cf5132dbd8d9ed764bc0739f9 +Z 815d7c70c40cd78a37bdf42f1d8f6b2e diff --git a/manifest.uuid b/manifest.uuid index b106017e83..f5a99b9470 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e6798871ce94961135762669af418cd78540c121 \ No newline at end of file +588122641e57e957813d329ea071e13ccbde5acd \ No newline at end of file diff --git a/test/speedtest1.c b/test/speedtest1.c index 05160e0eeb..e525f9cb18 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -512,6 +512,26 @@ void testset_main(void){ speedtest1_end_test(); + n = g.szTest/5; + speedtest1_begin_test(145, "%d SELECTS w/ORDER BY, unindexed", n); + speedtest1_exec("BEGIN"); + speedtest1_prepare( + "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n" + " ORDER BY a LIMIT 10; -- %d times", n + ); + for(i=1; i<=n; i++){ + x1 = speedtest1_random()%maxb; + zNum[0] = '%'; + len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2); + zNum[len] = '%'; + zNum[len+1] = 0; + sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC); + speedtest1_run(); + } + speedtest1_exec("COMMIT"); + speedtest1_end_test(); + + speedtest1_begin_test(150, "CREATE INDEX five times"); speedtest1_exec("BEGIN;"); speedtest1_exec("CREATE UNIQUE INDEX t1b ON t1(b);"); From c872966ef483aee010e327af97e7e66b065236bb Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 25 Mar 2014 17:45:49 +0000 Subject: [PATCH 7/7] Add another performance test case to speedtest1. This case is another ORDER BY test but this time without LIMIT. FossilOrigin-Name: 9ab7ffd59209aef0ffbf384b3902a93fd3b86a6d --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/speedtest1.c | 21 ++++++++++++++++++++- 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 5a5497d41f..d9f3760dc0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sORDER\sBY\stest\scase\sto\sspeedtest1.c -D 2014-03-25T14:54:36.731 +C Add\sanother\sperformance\stest\scase\sto\sspeedtest1.\s\sThis\scase\sis\sanother\nORDER\sBY\stest\sbut\sthis\stime\swithout\sLIMIT. +D 2014-03-25T17:45:49.623 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 2ef13430cd359f7b361bb863504e227b25cc7f81 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -825,7 +825,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/speedtest1.c bbf90952e0464e464467c72785602cca82a4d842 +F test/speedtest1.c 2bec93920c6d26adfa781b509b1c9ca0a4d8f39d F test/spellfix.test 61309f5efbec53603b3f86457d34a504f80abafe F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test 76fd746b85459e812a0193410fb599f0531f22de @@ -1159,7 +1159,7 @@ F tool/vdbe_profile.tcl 67746953071a9f8f2f668b73fe899074e2c6d8c1 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P e6798871ce94961135762669af418cd78540c121 -R 63e64c2147fb938edf250ea589ed8a9b +P 588122641e57e957813d329ea071e13ccbde5acd +R 6b6fe86503bb240eaed31036f5ef1e04 U drh -Z 815d7c70c40cd78a37bdf42f1d8f6b2e +Z 513f3088d16b4a60fe04e39489233db6 diff --git a/manifest.uuid b/manifest.uuid index f5a99b9470..0289c1d2a0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -588122641e57e957813d329ea071e13ccbde5acd \ No newline at end of file +9ab7ffd59209aef0ffbf384b3902a93fd3b86a6d \ No newline at end of file diff --git a/test/speedtest1.c b/test/speedtest1.c index e525f9cb18..b39493354d 100644 --- a/test/speedtest1.c +++ b/test/speedtest1.c @@ -513,7 +513,26 @@ void testset_main(void){ n = g.szTest/5; - speedtest1_begin_test(145, "%d SELECTS w/ORDER BY, unindexed", n); + speedtest1_begin_test(142, "%d SELECTS w/ORDER BY, unindexed", n); + speedtest1_exec("BEGIN"); + speedtest1_prepare( + "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n" + " ORDER BY a; -- %d times", n + ); + for(i=1; i<=n; i++){ + x1 = speedtest1_random()%maxb; + zNum[0] = '%'; + len = speedtest1_numbername(i, zNum+1, sizeof(zNum)-2); + zNum[len] = '%'; + zNum[len+1] = 0; + sqlite3_bind_text(g.pStmt, 1, zNum, len, SQLITE_STATIC); + speedtest1_run(); + } + speedtest1_exec("COMMIT"); + speedtest1_end_test(); + + n = g.szTest/5; + speedtest1_begin_test(145, "%d SELECTS w/ORDER BY and LIMIT, unindexed", n); speedtest1_exec("BEGIN"); speedtest1_prepare( "SELECT a, b, c FROM t1 WHERE c LIKE ?1\n"