From 4245c405ea9ef9115dd2dd6b81afc10a6edf67d1 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Jun 2012 14:32:21 +0000 Subject: [PATCH 01/69] The sqlite3_close() interface returns SQLITE_OK even if there are outstanding sqlite3_stmt and sqlite3_backup objects. The connection becomes a zombie. Resource deallocation is deferred until the last sqlite3_stmt or sqlite3_backup object closes. This is intended to help SQLite play nicer with garbage collectors. FossilOrigin-Name: e276a02b7f54e804caa553dca99023416a415e1c --- manifest | 33 ++++++++++++++++-------------- manifest.uuid | 2 +- src/backup.c | 7 +++---- src/main.c | 53 ++++++++++++++++++++++++++++++++++-------------- src/sqlite.h.in | 13 +++++++----- src/sqliteInt.h | 2 ++ src/vdbeapi.c | 11 +++------- src/vdbeaux.c | 1 + test/backup.test | 9 +++----- test/capi3.test | 10 ++------- test/capi3c.test | 16 ++++----------- test/misuse.test | 2 +- 12 files changed, 84 insertions(+), 75 deletions(-) diff --git a/manifest b/manifest index b001b92c56..bed498a322 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Avoid\scalling\sfchown()\sif\sthe\sprocess\sis\snot\srunning\sas\sroot. -D 2012-05-31T13:10:49.376 +C The\ssqlite3_close()\sinterface\sreturns\sSQLITE_OK\seven\sif\sthere\sare\soutstanding\nsqlite3_stmt\sand\ssqlite3_backup\sobjects.\s\sThe\sconnection\sbecomes\sa\szombie.\nResource\sdeallocation\sis\sdeferred\suntil\sthe\slast\ssqlite3_stmt\sor\s\nsqlite3_backup\sobject\scloses.\s\sThis\sis\sintended\sto\shelp\sSQLite\splay\snicer\nwith\sgarbage\scollectors. +D 2012-06-02T14:32:21.619 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -120,7 +120,7 @@ F src/alter.c 149cc80d9257971b0bff34e58fb2263e01998289 F src/analyze.c 70c46504c0d2543ea5cdca01140b2cd3e1d886e7 F src/attach.c 12c6957996908edc31c96d7c68d4942c2474405f F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 6be23a344d3301ae38e92fddb3a33b91c309fce4 +F src/backup.c 641eab30db6c70c3393719c4c874ecf534eafb27 F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c f0b71054103cb77eb5e782088c16998ec4f06624 @@ -145,7 +145,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c fdd95737fe28db3ad2b740c8a134b40592c6b20a +F src/main.c 7ccc7d2dbd06b8eb9226e3f4f46150299dc69da3 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -180,9 +180,9 @@ F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b -F src/sqlite.h.in 922d2907cc2b0177b2c4a3b462f04937750d6edd +F src/sqlite.h.in f8f4b07ecf9516403ecb0b88c2c4e6fe939bd495 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 64cffc7ff43725ade0cdfdbab0ef6a56ef3b682f +F src/sqliteInt.h d3b7409a510f7aeb0f9e6a2c74a18db3c659435c F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -242,8 +242,8 @@ F src/vacuum.c bfd53f9bd20a8fdb70b0fa8e77182b866875c0d8 F src/vdbe.c b6cb2ac43263843a5612892c0ad2309609b32c26 F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb F src/vdbeInt.h 6ff4180a05683566a8835d12f7ec504b22932c82 -F src/vdbeapi.c 3662b6a468a2a4605a15dfab313baa6dff81ad91 -F src/vdbeaux.c d52c8a424fdd4b1d5cf1ac93cc7cd20da023ec5c +F src/vdbeapi.c f8ba09132fe654ffd068058cef490426aca9fca6 +F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 @@ -288,7 +288,7 @@ F test/autovacuum.test fcaf4616ae5bb18098db1cb36262565e5c841c3c F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 F test/backcompat.test bccbc64769d9c755ad65ee7c2f7336b86e3cc0c8 -F test/backup.test 717346db953e9e435c2a94916e4af177330d60d3 +F test/backup.test d7c3e3d522631c3e44fddeac1e5f2f8cb5498a2c F test/backup2.test 34986ef926ea522911a51dfdb2f8e99b7b75ebcf F test/backup_ioerr.test 40d208bc9224b666ee3ed423f49bc9062a36a9d0 F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450 @@ -314,9 +314,9 @@ F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0 F test/cache.test f64136b0893c293d0b910ed057b3b711249099a7 F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360 -F test/capi3.test 8dedb0050610e9ff95cd9d487beb0ce5f33a31ee +F test/capi3.test d527782c154b1dc8a96d16c140226dcf3cff0834 F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 -F test/capi3c.test 01f197d73f4d4d66316483662f475cab7ab5bd60 +F test/capi3c.test 51b51d053549c9a022cf3c04f334e697f44fbd45 F test/capi3d.test 17b57ca28be3e37e14c2ba8f787d292d84b724a1 F test/capi3e.test f7408dda65c92b9056199fdc180f893015f83dde F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3 @@ -618,7 +618,7 @@ F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test 4337d84e441f36cee62656f9f7ba8bc22a7ca721 -F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054 +F test/misuse.test 1564457e771fa0d1066b9a29b1c3149837f8c561 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101 @@ -1004,7 +1004,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 07935d10d341fe6265cfd3b09e2c4ef4005c4826 -R db0f48be730e02610af744a3fe432e51 +P 70c419a434be77b042a23174483d6a411899eb5d +R 117d6304ef757a98fccc6a61da6ef5e1 +T *branch * deferred-close +T *sym-deferred-close * +T -sym-trunk * U drh -Z a3e118b76a7afa02078e1c319e3927b5 +Z e1d9ca4a10dedd659e87ebf966dd6be6 diff --git a/manifest.uuid b/manifest.uuid index b74e97b330..d79db39f4e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -70c419a434be77b042a23174483d6a411899eb5d \ No newline at end of file +e276a02b7f54e804caa553dca99023416a415e1c \ No newline at end of file diff --git a/src/backup.c b/src/backup.c index 7a4047f34c..6655ee3916 100644 --- a/src/backup.c +++ b/src/backup.c @@ -543,14 +543,13 @@ int sqlite3_backup_step(sqlite3_backup *p, int nPage){ */ int sqlite3_backup_finish(sqlite3_backup *p){ sqlite3_backup **pp; /* Ptr to head of pagers backup list */ - MUTEX_LOGIC( sqlite3_mutex *mutex; ) /* Mutex to protect source database */ + sqlite3 *pSrcDb = p->pSrcDb; /* Source database connection */ int rc; /* Value to return */ /* Enter the mutexes */ if( p==0 ) return SQLITE_OK; sqlite3_mutex_enter(p->pSrcDb->mutex); sqlite3BtreeEnter(p->pSrc); - MUTEX_LOGIC( mutex = p->pSrcDb->mutex; ) if( p->pDestDb ){ sqlite3_mutex_enter(p->pDestDb->mutex); } @@ -576,7 +575,7 @@ int sqlite3_backup_finish(sqlite3_backup *p){ /* Exit the mutexes and free the backup context structure. */ if( p->pDestDb ){ - sqlite3_mutex_leave(p->pDestDb->mutex); + sqlite3LeaveMutexAndCloseZombie(p->pDestDb); } sqlite3BtreeLeave(p->pSrc); if( p->pDestDb ){ @@ -585,7 +584,7 @@ int sqlite3_backup_finish(sqlite3_backup *p){ ** sqlite3_backup_finish(). */ sqlite3_free(p); } - sqlite3_mutex_leave(mutex); + sqlite3LeaveMutexAndCloseZombie(pSrcDb); return rc; } diff --git a/src/main.c b/src/main.c index 4e9a605f40..d0aebd5eee 100644 --- a/src/main.c +++ b/src/main.c @@ -703,6 +703,7 @@ void sqlite3CloseSavepoints(sqlite3 *db){ db->isTransactionSavepoint = 0; } + /* ** Invoke the destructor function associated with FuncDef p, if any. Except, ** if this is not the last copy of the function, do not invoke it. Multiple @@ -724,9 +725,6 @@ static void functionDestroy(sqlite3 *db, FuncDef *p){ ** Close an existing SQLite database */ int sqlite3_close(sqlite3 *db){ - HashElem *i; /* Hash table iterator */ - int j; - if( !db ){ return SQLITE_OK; } @@ -747,25 +745,51 @@ int sqlite3_close(sqlite3 *db){ */ sqlite3VtabRollback(db); - /* If there are any outstanding VMs, return SQLITE_BUSY. */ - if( db->pVdbe ){ - sqlite3Error(db, SQLITE_BUSY, - "unable to close due to unfinalised statements"); - sqlite3_mutex_leave(db->mutex); - return SQLITE_BUSY; - } - assert( sqlite3SafetyCheckSickOrOk(db) ); + /* + ** Mark this database connection as a zombie. Then try to close it. + */ + db->magic = SQLITE_MAGIC_ZOMBIE; + sqlite3LeaveMutexAndCloseZombie(db); + return SQLITE_OK; +} + +/* +** Close the mutex on database connection db. +** +** Furthermore, if database connection db is a zombie (meaning that there +** has been a prior call to sqlite3_close(db)) and every sqlite3_stmt +** has now been finalized and every sqlite3_backup has finished, then +** free all resources. +*/ +void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){ + HashElem *i; /* Hash table iterator */ + int j; + + assert( sqlite3_mutex_held(db->mutex) ); + + /* If there are outstanding sqlite3_stmt or sqlite3_backup objects + ** or if the connection has not yet been closed by sqlite3_close, then + ** just leave the mutex and return. + */ + if( db->pVdbe || db->magic!=SQLITE_MAGIC_ZOMBIE ){ + sqlite3_mutex_leave(db->mutex); + return; + } for(j=0; jnDb; j++){ Btree *pBt = db->aDb[j].pBt; if( pBt && sqlite3BtreeIsInBackup(pBt) ){ - sqlite3Error(db, SQLITE_BUSY, - "unable to close due to unfinished backup operation"); sqlite3_mutex_leave(db->mutex); - return SQLITE_BUSY; + return; } } + /* If we reach this point, it means that the database connection has + ** closed all sqlite3_stmt and sqlite3_backup objects and has been + ** pased to sqlite3_close (meaning that it is a zombie). Therefore, + ** go ahead and free all resources. + */ + /* Free any outstanding Savepoint structures. */ sqlite3CloseSavepoints(db); @@ -845,7 +869,6 @@ int sqlite3_close(sqlite3 *db){ sqlite3_free(db->lookaside.pStart); } sqlite3_free(db); - return SQLITE_OK; } /* diff --git a/src/sqlite.h.in b/src/sqlite.h.in index e96c196802..ce07c386f6 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -265,12 +265,15 @@ typedef sqlite_uint64 sqlite3_uint64; ** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is ** successfully destroyed and all associated resources are deallocated. ** -** Applications must [sqlite3_finalize | finalize] all [prepared statements] -** and [sqlite3_blob_close | close] all [BLOB handles] associated with -** the [sqlite3] object prior to attempting to close the object. ^If +** Applications should [sqlite3_finalize | finalize] all [prepared statements], +** [sqlite3_blob_close | close] all [BLOB handles], and +** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated +** with the [sqlite3] object prior to attempting to close the object. ^If ** sqlite3_close() is called on a [database connection] that still has -** outstanding [prepared statements] or [BLOB handles], then it returns -** SQLITE_BUSY. +** outstanding [prepared statements], [BLOB handles], and/or +** [sqlite3_backup] objects then it returns SQLITE_OK but the deallocation +** of resources is deferred until all [prepared statements], [BLOB handles], +** and [sqlite3_backup] objects are also destroyed. ** ** ^If [sqlite3_close()] is invoked while a transaction is open, ** the transaction is automatically rolled back. diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 85dabb0b39..9732c8f226 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -974,6 +974,7 @@ struct sqlite3 { #define SQLITE_MAGIC_SICK 0x4b771290 /* Error and awaiting close */ #define SQLITE_MAGIC_BUSY 0xf03b7906 /* Database currently in use */ #define SQLITE_MAGIC_ERROR 0xb5357930 /* An SQLITE_MISUSE error occurred */ +#define SQLITE_MAGIC_ZOMBIE 0x64cffc7f /* Close with last statement close */ /* ** Each SQL function is defined by an instance of the following @@ -2833,6 +2834,7 @@ void sqlite3CommitTransaction(Parse*); void sqlite3RollbackTransaction(Parse*); void sqlite3Savepoint(Parse*, int, Token*); void sqlite3CloseSavepoints(sqlite3 *); +void sqlite3LeaveMutexAndCloseZombie(sqlite3*); int sqlite3ExprIsConstant(Expr*); int sqlite3ExprIsConstantNotJoin(Expr*); int sqlite3ExprIsConstantOrFunction(Expr*); diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 94db205e1f..e25acd9449 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -71,17 +71,12 @@ int sqlite3_finalize(sqlite3_stmt *pStmt){ }else{ Vdbe *v = (Vdbe*)pStmt; sqlite3 *db = v->db; -#if SQLITE_THREADSAFE - sqlite3_mutex *mutex; -#endif if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT; -#if SQLITE_THREADSAFE - mutex = v->db->mutex; -#endif - sqlite3_mutex_enter(mutex); + sqlite3_mutex_enter(db->mutex); rc = sqlite3VdbeFinalize(v); + if( (rc&0xff)==SQLITE_MISUSE ) rc = SQLITE_OK; rc = sqlite3ApiExit(db, rc); - sqlite3_mutex_leave(mutex); + sqlite3LeaveMutexAndCloseZombie(db); } return rc; } diff --git a/src/vdbeaux.c b/src/vdbeaux.c index caa2bf6700..3ccf711619 100644 --- a/src/vdbeaux.c +++ b/src/vdbeaux.c @@ -2469,6 +2469,7 @@ void sqlite3VdbeDelete(Vdbe *p){ if( NEVER(p==0) ) return; db = p->db; + assert( sqlite3_mutex_held(db->mutex) ); if( p->pPrev ){ p->pPrev->pNext = p->pNext; }else{ diff --git a/test/backup.test b/test/backup.test index 4d7213c15c..bb517727a2 100644 --- a/test/backup.test +++ b/test/backup.test @@ -419,11 +419,8 @@ do_test backup-4.3.1 { } {B} do_test backup-4.3.2 { db2 cache flush - sqlite3_close db2 -} {SQLITE_BUSY} -do_test backup-4.3.3 { - sqlite3_errmsg db2 -} {unable to close due to unfinished backup operation} + db2 close ;# close will be deferred until the backup finishes +} {} do_test backup-4.3.4 { B step 50 } {SQLITE_DONE} @@ -436,7 +433,7 @@ do_test backup-4.4.1 { list $rc [sqlite3_errcode db] [sqlite3_errmsg db] } {1 SQLITE_ERROR {source and destination must be distinct}} db close -db2 close + do_test backup-4.5.1 { catch { forcedelete test.db } diff --git a/test/capi3.test b/test/capi3.test index d9106267c5..81cf41db0a 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -647,20 +647,14 @@ do_test capi3-6.0 { } {0} do_test capi3-6.1 { db cache flush - sqlite3_close $DB -} {SQLITE_BUSY} + db close +} {} do_test capi3-6.2 { sqlite3_step $STMT } {SQLITE_ERROR} -#check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1} do_test capi3-6.3 { sqlite3_finalize $STMT } {SQLITE_SCHEMA} -do_test capi3-6.4-misuse { - db cache flush - sqlite3_close $DB -} {SQLITE_OK} -db close # This procedure sets the value of the file-format in file 'test.db' # to $newval. Also, the schema cookie is incremented. diff --git a/test/capi3c.test b/test/capi3c.test index 4092091894..3074ce09fc 100644 --- a/test/capi3c.test +++ b/test/capi3c.test @@ -618,22 +618,14 @@ do_test capi3c-6.0 { } {0} do_test capi3c-6.1 { db cache flush - sqlite3_close $DB -} {SQLITE_BUSY} -do_test capi3c-6.2 { + db close; # close deferred +} {} +do_test capi3c-6.2-misuse { sqlite3_step $STMT -} {SQLITE_ROW} -check_data $STMT capi3c-6.3 {INTEGER} {1} {1.0} {1} +} {SQLITE_MISUSE} do_test capi3c-6.3 { sqlite3_finalize $STMT } {SQLITE_OK} -do_test capi3c-6.4 { - db cache flush - sqlite3_close $DB -} {SQLITE_OK} -do_test capi3c-6.99-misuse { - db close -} {} # This procedure sets the value of the file-format in file 'test.db' # to $newval. Also, the schema cookie is incremented. diff --git a/test/misuse.test b/test/misuse.test index 71ee0118c8..62d387e3c6 100644 --- a/test/misuse.test +++ b/test/misuse.test @@ -170,7 +170,7 @@ do_test misuse-4.3 { } } msg] lappend v $msg $r -} {0 {} SQLITE_BUSY} +} {0 {} SQLITE_OK} do_test misuse-4.4 { # Flush the TCL statement cache here, otherwise the sqlite3_close() will # fail because there are still un-finalized() VDBEs. From 167cd6ab78284a153a0f6c50817d8a9e4eca76ef Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 2 Jun 2012 17:09:46 +0000 Subject: [PATCH 02/69] Revert sqlite3_close() to legacy behavior. Create a new sqlite3_close_v2() interface that exhibits the deferred-close behavior. This minimizes the chance of breakage in legacy apps. FossilOrigin-Name: c4b8621125ce77308b06692d92f70586b10055a9 --- manifest | 25 ++++++++----------- manifest.uuid | 2 +- src/main.c | 65 ++++++++++++++++++++++++++++++++++-------------- src/sqlite.h.in | 34 ++++++++++++++++++------- test/backup.test | 9 ++++--- test/capi3.test | 10 ++++++-- test/capi3c.test | 16 +++++++++--- test/misuse.test | 2 +- 8 files changed, 110 insertions(+), 53 deletions(-) diff --git a/manifest b/manifest index bed498a322..4e60618575 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssqlite3_close()\sinterface\sreturns\sSQLITE_OK\seven\sif\sthere\sare\soutstanding\nsqlite3_stmt\sand\ssqlite3_backup\sobjects.\s\sThe\sconnection\sbecomes\sa\szombie.\nResource\sdeallocation\sis\sdeferred\suntil\sthe\slast\ssqlite3_stmt\sor\s\nsqlite3_backup\sobject\scloses.\s\sThis\sis\sintended\sto\shelp\sSQLite\splay\snicer\nwith\sgarbage\scollectors. -D 2012-06-02T14:32:21.619 +C Revert\ssqlite3_close()\sto\slegacy\sbehavior.\s\sCreate\sa\snew\ssqlite3_close_v2()\ninterface\sthat\sexhibits\sthe\sdeferred-close\sbehavior.\s\sThis\sminimizes\sthe\nchance\sof\sbreakage\sin\slegacy\sapps. +D 2012-06-02T17:09:46.071 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -145,7 +145,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 7ccc7d2dbd06b8eb9226e3f4f46150299dc69da3 +F src/main.c 4f47dad00c32092a28cac06d2e7cdcde024af432 F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -180,7 +180,7 @@ F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b -F src/sqlite.h.in f8f4b07ecf9516403ecb0b88c2c4e6fe939bd495 +F src/sqlite.h.in 238059420ea5e60deb6dacc3c46a44f47739060d F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h d3b7409a510f7aeb0f9e6a2c74a18db3c659435c F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -288,7 +288,7 @@ F test/autovacuum.test fcaf4616ae5bb18098db1cb36262565e5c841c3c F test/autovacuum_ioerr2.test 8a367b224183ad801e0e24dcb7d1501f45f244b4 F test/avtrans.test 0252654f4295ddda3b2cce0e894812259e655a85 F test/backcompat.test bccbc64769d9c755ad65ee7c2f7336b86e3cc0c8 -F test/backup.test d7c3e3d522631c3e44fddeac1e5f2f8cb5498a2c +F test/backup.test c9cdd23a495864b9edf75a9fa66f5cb7e10fcf62 F test/backup2.test 34986ef926ea522911a51dfdb2f8e99b7b75ebcf F test/backup_ioerr.test 40d208bc9224b666ee3ed423f49bc9062a36a9d0 F test/backup_malloc.test 7162d604ec2b4683c4b3799a48657fb8b5e2d450 @@ -314,9 +314,9 @@ F test/boundary4.test 89e02fa66397b8a325d5eb102b5806f961f8ec4b F test/busy.test 76b4887f8b9160ba903c1ac22e8ff406ad6ae2f0 F test/cache.test f64136b0893c293d0b910ed057b3b711249099a7 F test/capi2.test 835d4cee9f542ea50fa8d01f3fe6de80b0627360 -F test/capi3.test d527782c154b1dc8a96d16c140226dcf3cff0834 +F test/capi3.test 8dedb0050610e9ff95cd9d487beb0ce5f33a31ee F test/capi3b.test efb2b9cfd127efa84433cd7a2d72ce0454ae0dc4 -F test/capi3c.test 51b51d053549c9a022cf3c04f334e697f44fbd45 +F test/capi3c.test 01f197d73f4d4d66316483662f475cab7ab5bd60 F test/capi3d.test 17b57ca28be3e37e14c2ba8f787d292d84b724a1 F test/capi3e.test f7408dda65c92b9056199fdc180f893015f83dde F test/cast.test 4c275cbdc8202d6f9c54a3596701719868ac7dc3 @@ -618,7 +618,7 @@ F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 F test/misc7.test 4337d84e441f36cee62656f9f7ba8bc22a7ca721 -F test/misuse.test 1564457e771fa0d1066b9a29b1c3149837f8c561 +F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a F test/multiplex3.test d228f59eac91839a977eac19f21d053f03e4d101 @@ -1004,10 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 70c419a434be77b042a23174483d6a411899eb5d -R 117d6304ef757a98fccc6a61da6ef5e1 -T *branch * deferred-close -T *sym-deferred-close * -T -sym-trunk * +P e276a02b7f54e804caa553dca99023416a415e1c +R 8a810a07bd449d4ae1bace844f29b96d U drh -Z e1d9ca4a10dedd659e87ebf966dd6be6 +Z 06fa4191b1c8c7f470cba6494d9b6a75 diff --git a/manifest.uuid b/manifest.uuid index d79db39f4e..5efdc927b0 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e276a02b7f54e804caa553dca99023416a415e1c \ No newline at end of file +c4b8621125ce77308b06692d92f70586b10055a9 \ No newline at end of file diff --git a/src/main.c b/src/main.c index d0aebd5eee..f91d6a0092 100644 --- a/src/main.c +++ b/src/main.c @@ -703,7 +703,6 @@ void sqlite3CloseSavepoints(sqlite3 *db){ db->isTransactionSavepoint = 0; } - /* ** Invoke the destructor function associated with FuncDef p, if any. Except, ** if this is not the last copy of the function, do not invoke it. Multiple @@ -721,10 +720,25 @@ static void functionDestroy(sqlite3 *db, FuncDef *p){ } } +/* +** Return TRUE if database connection db has unfinalized prepared +** statements or unfinished sqlite3_backup objects. +*/ +static int connectionIsBusy(sqlite3 *db){ + int j; + assert( sqlite3_mutex_held(db->mutex) ); + if( db->pVdbe ) return 1; + for(j=0; jnDb; j++){ + Btree *pBt = db->aDb[j].pBt; + if( pBt && sqlite3BtreeIsInBackup(pBt) ) return 1; + } + return 0; +} + /* ** Close an existing SQLite database */ -int sqlite3_close(sqlite3 *db){ +static int sqlite3Close(sqlite3 *db, int forceZombie){ if( !db ){ return SQLITE_OK; } @@ -745,44 +759,56 @@ int sqlite3_close(sqlite3 *db){ */ sqlite3VtabRollback(db); - /* - ** Mark this database connection as a zombie. Then try to close it. + /* Legacy behavior (sqlite3_close() behavior) is to return + ** SQLITE_BUSY if the connection can not be closed immediately. + */ + if( !forceZombie && connectionIsBusy(db) ){ + sqlite3Error(db, SQLITE_BUSY, "unable to close due to unfinalized " + "statements or unfinished backups"); + sqlite3_mutex_leave(db->mutex); + return SQLITE_BUSY; + } + + /* Convert the connection into a zombie and then close it. */ db->magic = SQLITE_MAGIC_ZOMBIE; sqlite3LeaveMutexAndCloseZombie(db); return SQLITE_OK; } +/* +** Two variations on the public interface for closing a database +** connection. The sqlite3_close() version returns SQLITE_BUSY and +** leaves the connection option if there are unfinalized prepared +** statements or unfinished sqlite3_backups. The sqlite3_close_v2() +** version forces the connection to become a zombie if there are +** unclosed resources, and arranges for deallocation when the last +** prepare statement or sqlite3_backup closes. +*/ +int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); } +int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); } + /* ** Close the mutex on database connection db. ** ** Furthermore, if database connection db is a zombie (meaning that there -** has been a prior call to sqlite3_close(db)) and every sqlite3_stmt -** has now been finalized and every sqlite3_backup has finished, then -** free all resources. +** has been a prior call to sqlite3_close(db) or sqlite3_close_v2(db)) and +** every sqlite3_stmt has now been finalized and every sqlite3_backup has +** finished, then free all resources. */ void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){ HashElem *i; /* Hash table iterator */ int j; - assert( sqlite3_mutex_held(db->mutex) ); - /* If there are outstanding sqlite3_stmt or sqlite3_backup objects - ** or if the connection has not yet been closed by sqlite3_close, then - ** just leave the mutex and return. + ** or if the connection has not yet been closed by sqlite3_close_v2(), + ** then just leave the mutex and return. */ - if( db->pVdbe || db->magic!=SQLITE_MAGIC_ZOMBIE ){ + if( db->magic!=SQLITE_MAGIC_ZOMBIE || connectionIsBusy(db) ){ sqlite3_mutex_leave(db->mutex); return; } - for(j=0; jnDb; j++){ - Btree *pBt = db->aDb[j].pBt; - if( pBt && sqlite3BtreeIsInBackup(pBt) ){ - sqlite3_mutex_leave(db->mutex); - return; - } - } /* If we reach this point, it means that the database connection has ** closed all sqlite3_stmt and sqlite3_backup objects and has been @@ -869,6 +895,7 @@ void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){ sqlite3_free(db->lookaside.pStart); } sqlite3_free(db); + return SQLITE_OK; } /* diff --git a/src/sqlite.h.in b/src/sqlite.h.in index ce07c386f6..0eb6b7940f 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -214,7 +214,8 @@ int sqlite3_threadsafe(void); ** the opaque structure named "sqlite3". It is useful to think of an sqlite3 ** pointer as an object. The [sqlite3_open()], [sqlite3_open16()], and ** [sqlite3_open_v2()] interfaces are its constructors, and [sqlite3_close()] -** is its destructor. There are many other interfaces (such as +** and [sqlite3_close_v2()] are its destructors. There are many other +** interfaces (such as ** [sqlite3_prepare_v2()], [sqlite3_create_function()], and ** [sqlite3_busy_timeout()] to name but three) that are methods on an ** sqlite3 object. @@ -261,9 +262,22 @@ typedef sqlite_uint64 sqlite3_uint64; /* ** CAPI3REF: Closing A Database Connection ** -** ^The sqlite3_close() routine is the destructor for the [sqlite3] object. -** ^Calls to sqlite3_close() return SQLITE_OK if the [sqlite3] object is -** successfully destroyed and all associated resources are deallocated. +** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors +** for the [sqlite3] object. +** ^Calls to sqlite3_close() and sqlite3_close_v2() return SQLITE_OK if +** the [sqlite3] object is successfully destroyed and all associated +** resources are deallocated. +** +** ^If the database connection is associated with unfinalized prepared +** statements or unfinished sqlite3_backup objects then sqlite3_close() +** will leave the database connection open and return [SQLITE_BUSY]. +** ^If sqlite3_close_v2() is called with unfinalized prepared statements +** and unfinished sqlite3_backups, then the database connection becomes +** an unusable "zombie" which will automatically be deallocated when the +** last prepared statement is finalized or the last sqlite3_backup is +** finished. The sqlite3_close_v2() interface is intended for use with +** host languages that are garbage collected, and where the order in which +** destructors are called is arbitrary. ** ** Applications should [sqlite3_finalize | finalize] all [prepared statements], ** [sqlite3_blob_close | close] all [BLOB handles], and @@ -275,17 +289,19 @@ typedef sqlite_uint64 sqlite3_uint64; ** of resources is deferred until all [prepared statements], [BLOB handles], ** and [sqlite3_backup] objects are also destroyed. ** -** ^If [sqlite3_close()] is invoked while a transaction is open, +** ^If an [sqlite3] object is destroyed while a transaction is open, ** the transaction is automatically rolled back. ** -** The C parameter to [sqlite3_close(C)] must be either a NULL +** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)] +** must be either a NULL ** pointer or an [sqlite3] object pointer obtained ** from [sqlite3_open()], [sqlite3_open16()], or ** [sqlite3_open_v2()], and not previously closed. -** ^Calling sqlite3_close() with a NULL pointer argument is a -** harmless no-op. +** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer +** argument is a harmless no-op. */ -int sqlite3_close(sqlite3 *); +int sqlite3_close(sqlite3*); +int sqlite3_close_v2(sqlite3*); /* ** The type for a callback function. diff --git a/test/backup.test b/test/backup.test index bb517727a2..444619c68c 100644 --- a/test/backup.test +++ b/test/backup.test @@ -419,8 +419,11 @@ do_test backup-4.3.1 { } {B} do_test backup-4.3.2 { db2 cache flush - db2 close ;# close will be deferred until the backup finishes -} {} + sqlite3_close db2 +} {SQLITE_BUSY} +do_test backup-4.3.3 { + sqlite3_errmsg db2 +} {unable to close due to unfinalized statements or unfinished backups} do_test backup-4.3.4 { B step 50 } {SQLITE_DONE} @@ -433,7 +436,7 @@ do_test backup-4.4.1 { list $rc [sqlite3_errcode db] [sqlite3_errmsg db] } {1 SQLITE_ERROR {source and destination must be distinct}} db close - +db2 close do_test backup-4.5.1 { catch { forcedelete test.db } diff --git a/test/capi3.test b/test/capi3.test index 81cf41db0a..d9106267c5 100644 --- a/test/capi3.test +++ b/test/capi3.test @@ -647,14 +647,20 @@ do_test capi3-6.0 { } {0} do_test capi3-6.1 { db cache flush - db close -} {} + sqlite3_close $DB +} {SQLITE_BUSY} do_test capi3-6.2 { sqlite3_step $STMT } {SQLITE_ERROR} +#check_data $STMT capi3-6.3 {INTEGER} {1} {1.0} {1} do_test capi3-6.3 { sqlite3_finalize $STMT } {SQLITE_SCHEMA} +do_test capi3-6.4-misuse { + db cache flush + sqlite3_close $DB +} {SQLITE_OK} +db close # This procedure sets the value of the file-format in file 'test.db' # to $newval. Also, the schema cookie is incremented. diff --git a/test/capi3c.test b/test/capi3c.test index 3074ce09fc..4092091894 100644 --- a/test/capi3c.test +++ b/test/capi3c.test @@ -618,14 +618,22 @@ do_test capi3c-6.0 { } {0} do_test capi3c-6.1 { db cache flush - db close; # close deferred -} {} -do_test capi3c-6.2-misuse { + sqlite3_close $DB +} {SQLITE_BUSY} +do_test capi3c-6.2 { sqlite3_step $STMT -} {SQLITE_MISUSE} +} {SQLITE_ROW} +check_data $STMT capi3c-6.3 {INTEGER} {1} {1.0} {1} do_test capi3c-6.3 { sqlite3_finalize $STMT } {SQLITE_OK} +do_test capi3c-6.4 { + db cache flush + sqlite3_close $DB +} {SQLITE_OK} +do_test capi3c-6.99-misuse { + db close +} {} # This procedure sets the value of the file-format in file 'test.db' # to $newval. Also, the schema cookie is incremented. diff --git a/test/misuse.test b/test/misuse.test index 62d387e3c6..71ee0118c8 100644 --- a/test/misuse.test +++ b/test/misuse.test @@ -170,7 +170,7 @@ do_test misuse-4.3 { } } msg] lappend v $msg $r -} {0 {} SQLITE_OK} +} {0 {} SQLITE_BUSY} do_test misuse-4.4 { # Flush the TCL statement cache here, otherwise the sqlite3_close() will # fail because there are still un-finalized() VDBEs. From 46daba87d323b71fa8692f463bd84195233ad340 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 11 Jun 2012 02:05:22 +0000 Subject: [PATCH 03/69] Version 3.7.13 FossilOrigin-Name: f5b5a13f7394dc143aa136f1d4faba6839eaa6dc --- manifest | 13 ++++++++----- manifest.uuid | 2 +- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/manifest b/manifest index 8bced82de4..8e0fdc7786 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smissing\stargets\sfor\sfts3_unicode.lo\sand\sfts3_unicode2.lo\sto\sMakefile.in. -D 2012-06-09T18:52:29.837 +C Version\s3.7.13 +D 2012-06-11T02:05:22.539 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1005,7 +1005,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 025227be5495f950c466dfabac140cba69e498be +P 0ae0ce630a2e11f81dca50a9cfb04c4a41c03b2d R 45dae5fdb66a9a88c8595b45bd7db627 -U dan -Z b0a689d65a4b2d791e77df9966396ebf +T +bgcolor * #d0c0ff +T +sym-release * +T +sym-version-3.7.13 * +U drh +Z c0babe9c1caac24f66a10b2544a508b6 diff --git a/manifest.uuid b/manifest.uuid index 1a6654ac9a..168458e2bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0ae0ce630a2e11f81dca50a9cfb04c4a41c03b2d \ No newline at end of file +f5b5a13f7394dc143aa136f1d4faba6839eaa6dc \ No newline at end of file From 4104337270d3183eaa8c88038a8a83602b28e60d Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 15 Jun 2012 20:42:43 +0000 Subject: [PATCH 04/69] Fix compiler warning. FossilOrigin-Name: 37d9bc061d5ecfe37ccbd6f559986d7ae0449179 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/main.c | 1 - 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4e60618575..6be83175c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Revert\ssqlite3_close()\sto\slegacy\sbehavior.\s\sCreate\sa\snew\ssqlite3_close_v2()\ninterface\sthat\sexhibits\sthe\sdeferred-close\sbehavior.\s\sThis\sminimizes\sthe\nchance\sof\sbreakage\sin\slegacy\sapps. -D 2012-06-02T17:09:46.071 +C Fix\scompiler\swarning. +D 2012-06-15T20:42:43.595 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 4f37eb61be9d38643cdd839a74b8e3bad724cfcf F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -145,7 +145,7 @@ F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 F src/loadext.c f20382fbaeec832438a1ba7797bee3d3c8a6d51d -F src/main.c 4f47dad00c32092a28cac06d2e7cdcde024af432 +F src/main.c aacb100c6bae0141b8afbc846b5e0cfc3c28236e F src/malloc.c fe085aa851b666b7c375c1ff957643dc20a04bf6 F src/mem0.c 6a55ebe57c46ca1a7d98da93aaa07f99f1059645 F src/mem1.c b3677415e69603d6a0e7c5410a1b3731d55beda1 @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh a8a0a3babda96dfb1ff51adda3cbbf3dfb7266c2 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P e276a02b7f54e804caa553dca99023416a415e1c -R 8a810a07bd449d4ae1bace844f29b96d -U drh -Z 06fa4191b1c8c7f470cba6494d9b6a75 +P c4b8621125ce77308b06692d92f70586b10055a9 +R 57c11cdb4c652e2e66fa754b88986502 +U mistachkin +Z bfc433cff95e9f96663878f602826ba1 diff --git a/manifest.uuid b/manifest.uuid index 5efdc927b0..15f9187211 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -c4b8621125ce77308b06692d92f70586b10055a9 \ No newline at end of file +37d9bc061d5ecfe37ccbd6f559986d7ae0449179 \ No newline at end of file diff --git a/src/main.c b/src/main.c index f91d6a0092..c9872f7bc0 100644 --- a/src/main.c +++ b/src/main.c @@ -895,7 +895,6 @@ void sqlite3LeaveMutexAndCloseZombie(sqlite3 *db){ sqlite3_free(db->lookaside.pStart); } sqlite3_free(db); - return SQLITE_OK; } /* From 8ba0d1cbca6ffd8f0fb93de1d5b51451591b0500 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 16 Jun 2012 15:26:31 +0000 Subject: [PATCH 05/69] In Lemon, when comparing the output to the *.h file to see if it has changed, make sure that the proposed new output and the preexisting output are the same size before deciding that they are the same. FossilOrigin-Name: 0c2fb18d25217ada7e75dcab8b342bbc632875d8 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- tool/lemon.c | 4 +++- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 8e0fdc7786..1043803b95 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Version\s3.7.13 -D 2012-06-11T02:05:22.539 +C In\sLemon,\swhen\scomparing\sthe\soutput\sto\sthe\s*.h\sfile\sto\ssee\sif\sit\shas\schanged,\nmake\ssure\sthat\sthe\sproposed\snew\soutput\sand\sthe\spreexisting\soutput\sare\sthe\nsame\ssize\sbefore\sdeciding\sthat\sthey\sare\sthe\ssame. +D 2012-06-16T15:26:31.082 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -973,7 +973,7 @@ F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 90f46af31c92b940fec25b491f39409fd95dcdfa +F tool/lemon.c 8b7afc12a6671e3a932a5209a9e64abbfbd0f025 F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e @@ -1005,10 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 0ae0ce630a2e11f81dca50a9cfb04c4a41c03b2d -R 45dae5fdb66a9a88c8595b45bd7db627 -T +bgcolor * #d0c0ff -T +sym-release * -T +sym-version-3.7.13 * +P f5b5a13f7394dc143aa136f1d4faba6839eaa6dc +R 1f8bdd1a411e91223aef9522ba34a3e6 U drh -Z c0babe9c1caac24f66a10b2544a508b6 +Z 53f96406b6eec20edfa4ee33fc7d7346 diff --git a/manifest.uuid b/manifest.uuid index 168458e2bb..0425283c18 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f5b5a13f7394dc143aa136f1d4faba6839eaa6dc \ No newline at end of file +0c2fb18d25217ada7e75dcab8b342bbc632875d8 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index 5d96995335..2786e01dcd 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -4021,12 +4021,14 @@ void ReportHeader(struct lemon *lemp) else prefix = ""; in = file_open(lemp,".h","rb"); if( in ){ + int nextChar; for(i=1; interminal && fgets(line,LINESIZE,in); i++){ sprintf(pattern,"#define %s%-30s %2d\n",prefix,lemp->symbols[i]->name,i); if( strcmp(line,pattern) ) break; } + nextChar = fgetc(in); fclose(in); - if( i==lemp->nterminal ){ + if( i==lemp->nterminal && nextChar==EOF ){ /* No change in the file. Don't rewrite it. */ return; } From c8bde37d199230099ea1521313c08b156378417b Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 18 Jun 2012 08:00:56 +0000 Subject: [PATCH 06/69] Fix a few compilation issues that can occur with certain compilers (e.g. GCC 2.95.3, MSVC). FossilOrigin-Name: f970a3de61fe2ebaf1778c4a3383cfdc52299162 --- ext/fts3/fts3_unicode2.c | 2 +- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/mutex_w32.c | 3 +-- src/shell.c | 10 ++++++---- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/ext/fts3/fts3_unicode2.c b/ext/fts3/fts3_unicode2.c index 226d5ee419..3c24569026 100644 --- a/ext/fts3/fts3_unicode2.c +++ b/ext/fts3/fts3_unicode2.c @@ -146,7 +146,7 @@ int sqlite3FtsUnicodeIsalnum(int c){ } assert( aEntry[0]=aEntry[iRes] ); - return (c >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF))); + return (((unsigned int)c) >= ((aEntry[iRes]>>10) + (aEntry[iRes]&0x3FF))); } return 1; } diff --git a/manifest b/manifest index 1043803b95..d36e959c74 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sLemon,\swhen\scomparing\sthe\soutput\sto\sthe\s*.h\sfile\sto\ssee\sif\sit\shas\schanged,\nmake\ssure\sthat\sthe\sproposed\snew\soutput\sand\sthe\spreexisting\soutput\sare\sthe\nsame\ssize\sbefore\sdeciding\sthat\sthey\sare\sthe\ssame. -D 2012-06-16T15:26:31.082 +C Fix\sa\sfew\scompilation\sissues\sthat\scan\soccur\swith\scertain\scompilers\s(e.g.\sGCC\s2.95.3,\sMSVC). +D 2012-06-18T08:00:56.560 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -71,7 +71,7 @@ F ext/fts3/fts3_tokenizer.c e94a8b901066031437ccfe4769fc76370257cede F ext/fts3/fts3_tokenizer.h 66dec98e365854b6cd2d54f1a96bb6d428fc5a68 F ext/fts3/fts3_tokenizer1.c 5c98225a53705e5ee34824087478cf477bdb7004 F ext/fts3/fts3_unicode.c 49e36e6ba59f79e6bd6a8bfe434570fe48d20559 -F ext/fts3/fts3_unicode2.c 2965d217c37079f1dbbdbd2c58f843be285d73f2 +F ext/fts3/fts3_unicode2.c a863f05f758af36777dffc2facc898bc73fec896 F ext/fts3/fts3_write.c 794438f904cdf4516b258e530c0065efadb7b9b5 F ext/fts3/fts3speed.tcl b54caf6a18d38174f1a6e84219950d85e98bb1e9 F ext/fts3/mkfts3amal.tcl 252ecb7fe6467854f2aa237bf2c390b74e71f100 @@ -158,7 +158,7 @@ F src/mutex.h 2a79e0c10c26412546b501ee0f3d92b42decf63e F src/mutex_noop.c 7682796b7d8d39bf1c138248858efcd10c9e1553 F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc -F src/mutex_w32.c db8970270841e2385a43602477e84c4b19aff1db +F src/mutex_w32.c aedeaae3a850f6237ad142206911e3053a393e02 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca @@ -179,7 +179,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d -F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b +F src/shell.c 79cbf565f50c7b9ab0a622e0a7d612ad3b97a685 F src/sqlite.h.in 39f041ce71a0d994e2487014fc9e8721595f5bc0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 29b5348f0056d9b46d0bb94d4853db21568afde9 @@ -1005,7 +1005,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P f5b5a13f7394dc143aa136f1d4faba6839eaa6dc -R 1f8bdd1a411e91223aef9522ba34a3e6 -U drh -Z 53f96406b6eec20edfa4ee33fc7d7346 +P 0c2fb18d25217ada7e75dcab8b342bbc632875d8 +R 1fec034065f8f455e31652ddfa62f1cf +T *branch * compiler-compat +T *sym-compiler-compat * +T -sym-trunk * +U mistachkin +Z 855dea24159ac5797cf9bffe7655aa6d diff --git a/manifest.uuid b/manifest.uuid index 0425283c18..9a664fabef 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c2fb18d25217ada7e75dcab8b342bbc632875d8 \ No newline at end of file +f970a3de61fe2ebaf1778c4a3383cfdc52299162 \ No newline at end of file diff --git a/src/mutex_w32.c b/src/mutex_w32.c index accf9ef8a2..56b4a4d925 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -109,8 +109,6 @@ static int winMutex_isInit = 0; */ static long winMutex_lock = 0; -extern void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ - static int winMutexInit(void){ /* The first to increment to 1 does actual initialization */ if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){ @@ -126,6 +124,7 @@ static int winMutexInit(void){ }else{ /* Someone else is in the process of initing the static mutexes */ while( !winMutex_isInit ){ + extern void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ sqlite3_win32_sleep(1); } } diff --git a/src/shell.c b/src/shell.c index 801ad2ca27..3f28680235 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2697,10 +2697,12 @@ static char *find_home_dir(void){ if( home_dir ) return home_dir; #if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) && !defined(_WIN32_WCE) && !defined(__RTP__) && !defined(_WRS_KERNEL) - struct passwd *pwent; - uid_t uid = getuid(); - if( (pwent=getpwuid(uid)) != NULL) { - home_dir = pwent->pw_dir; + { + struct passwd *pwent; + uid_t uid = getuid(); + if( (pwent=getpwuid(uid)) != NULL) { + home_dir = pwent->pw_dir; + } } #endif From 9721c21c41c9443c804a9d3f2489703f9ae10234 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 18 Jun 2012 17:15:29 +0000 Subject: [PATCH 07/69] Allow the SQLITE_API macro to apply to the sqlite3_win32_sleep function. FossilOrigin-Name: 21266c68afb067ff40062df1e8b383dfd247c17b --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/mutex_w32.c | 3 ++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index d36e959c74..5f05b6d64e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sfew\scompilation\sissues\sthat\scan\soccur\swith\scertain\scompilers\s(e.g.\sGCC\s2.95.3,\sMSVC). -D 2012-06-18T08:00:56.560 +C Allow\sthe\sSQLITE_API\smacro\sto\sapply\sto\sthe\ssqlite3_win32_sleep\sfunction. +D 2012-06-18T17:15:29.347 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -158,7 +158,7 @@ F src/mutex.h 2a79e0c10c26412546b501ee0f3d92b42decf63e F src/mutex_noop.c 7682796b7d8d39bf1c138248858efcd10c9e1553 F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc -F src/mutex_w32.c aedeaae3a850f6237ad142206911e3053a393e02 +F src/mutex_w32.c 32a9b3841e2d757355f0012b860b1bc5e01eafa0 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca @@ -1005,10 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 0c2fb18d25217ada7e75dcab8b342bbc632875d8 -R 1fec034065f8f455e31652ddfa62f1cf -T *branch * compiler-compat -T *sym-compiler-compat * -T -sym-trunk * +P f970a3de61fe2ebaf1778c4a3383cfdc52299162 +R f7c2f2158f3710573c689aa0bb5b67ff U mistachkin -Z 855dea24159ac5797cf9bffe7655aa6d +Z 6375ed0474e573645b8013045823eb03 diff --git a/manifest.uuid b/manifest.uuid index 9a664fabef..94bee6bf1f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f970a3de61fe2ebaf1778c4a3383cfdc52299162 \ No newline at end of file +21266c68afb067ff40062df1e8b383dfd247c17b \ No newline at end of file diff --git a/src/mutex_w32.c b/src/mutex_w32.c index 56b4a4d925..27d10af5bd 100644 --- a/src/mutex_w32.c +++ b/src/mutex_w32.c @@ -109,6 +109,8 @@ static int winMutex_isInit = 0; */ static long winMutex_lock = 0; +void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ + static int winMutexInit(void){ /* The first to increment to 1 does actual initialization */ if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){ @@ -124,7 +126,6 @@ static int winMutexInit(void){ }else{ /* Someone else is in the process of initing the static mutexes */ while( !winMutex_isInit ){ - extern void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */ sqlite3_win32_sleep(1); } } From 2ae26b759d75db1f4270b3225b30f40128e5d31b Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Jun 2012 20:52:32 +0000 Subject: [PATCH 08/69] Fix a problem with identifying white-space characters outside of the ascii range in the ICU tokenizer. FossilOrigin-Name: 892b74116a3b23268895b96433d18ef00c1433d8 --- ext/fts3/fts3_icu.c | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- test/fts3atoken.test | 10 ++++++++++ 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/ext/fts3/fts3_icu.c b/ext/fts3/fts3_icu.c index 5e9c900b09..18b7948c32 100644 --- a/ext/fts3/fts3_icu.c +++ b/ext/fts3/fts3_icu.c @@ -199,7 +199,7 @@ static int icuNext( while( iStartaChar, iWhite, pCsr->nChar, c); + U16_NEXT(pCsr->aChar, iWhite, pCsr->nChar, c); if( u_isspace(c) ){ iStart = iWhite; }else{ diff --git a/manifest b/manifest index 1043803b95..b57416185b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C In\sLemon,\swhen\scomparing\sthe\soutput\sto\sthe\s*.h\sfile\sto\ssee\sif\sit\shas\schanged,\nmake\ssure\sthat\sthe\sproposed\snew\soutput\sand\sthe\spreexisting\soutput\sare\sthe\nsame\ssize\sbefore\sdeciding\sthat\sthey\sare\sthe\ssame. -D 2012-06-16T15:26:31.082 +C Fix\sa\sproblem\swith\sidentifying\swhite-space\scharacters\soutside\sof\sthe\sascii\srange\sin\sthe\sICU\stokenizer. +D 2012-06-18T20:52:32.200 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -62,7 +62,7 @@ F ext/fts3/fts3_aux.c 5205182bd8f372782597888156404766edf5781e F ext/fts3/fts3_expr.c dbc7ba4c3a6061adde0f38ed8e9b349568299551 F ext/fts3/fts3_hash.c 8dd2d06b66c72c628c2732555a32bc0943114914 F ext/fts3/fts3_hash.h 8331fb2206c609f9fc4c4735b9ab5ad6137c88ec -F ext/fts3/fts3_icu.c 62ec177c55f6a5c6e994dd3e5fd3194b4045c347 +F ext/fts3/fts3_icu.c b85eca4a52e5ec11b94392de5167974c11906d4a F ext/fts3/fts3_porter.c a465b49fcb8249a755792f87516eff182efa42b3 F ext/fts3/fts3_snippet.c bf67520ae9d2352a65368ed101729ff701c08808 F ext/fts3/fts3_term.c a521f75132f9a495bdca1bdd45949b3191c52763 @@ -464,7 +464,7 @@ F test/fts3al.test 07d64326e79bbdbab20ee87fc3328fbf01641c9f F test/fts3am.test 218aa6ba0dfc50c7c16b2022aac5c6be593d08d8 F test/fts3an.test a49ccadc07a2f7d646ec1b81bc09da2d85a85b18 F test/fts3ao.test e7b80272efcced57d1d087a9da5c690dd7c21fd9 -F test/fts3atoken.test 402ef2f7c2fb4b3d4fa0587df6441c1447e799b3 +F test/fts3atoken.test fb398ab50aa232489e2a17f9b29d7ad3a3885f36 F test/fts3auto.test b39f3f51227aea145eae6638690355dbdf9abf18 F test/fts3aux1.test 0b02743955d56fc0d4d66236a26177bd1b726de0 F test/fts3b.test e93bbb653e52afde110ad53bbd793f14fe7a8984 @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P f5b5a13f7394dc143aa136f1d4faba6839eaa6dc -R 1f8bdd1a411e91223aef9522ba34a3e6 -U drh -Z 53f96406b6eec20edfa4ee33fc7d7346 +P 0c2fb18d25217ada7e75dcab8b342bbc632875d8 +R de31ab49b2137fc2f97d1253270053d5 +U dan +Z 2c0f1a3c7e342f99735e428af302d9d8 diff --git a/manifest.uuid b/manifest.uuid index 0425283c18..75492d0b49 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0c2fb18d25217ada7e75dcab8b342bbc632875d8 \ No newline at end of file +892b74116a3b23268895b96433d18ef00c1433d8 \ No newline at end of file diff --git a/test/fts3atoken.test b/test/fts3atoken.test index 554259d0a5..9277bfb8e6 100644 --- a/test/fts3atoken.test +++ b/test/fts3atoken.test @@ -174,6 +174,16 @@ ifcapable icu { insert into x1 (name) values (NULL); delete from x1; } + + proc cp_to_str {codepoint_list} { + set fmt [string repeat %c [llength $codepoint_list]] + eval [list format $fmt] $codepoint_list + } + + do_test 5.2 { + set str [cp_to_str {19968 26085 32822 32645 27874 23433 20986}] + execsql { INSERT INTO x1 VALUES($str) } + } {} } From 89f15088f0bc72252fcbda6981a56e80ba7d739c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Jun 2012 00:45:16 +0000 Subject: [PATCH 09/69] Improved rounding accuracy on test-to-float conversions. FossilOrigin-Name: 699b792c6a0e989994549959b11ec1bfad8bbd92 --- manifest | 17 +++++++++-------- manifest.uuid | 2 +- src/test_func.c | 38 ++++++++++++++++++++++++++++++++++++++ src/util.c | 2 +- test/atof1.test | 36 ++++++++++++++++++++++++++++++++++++ 5 files changed, 85 insertions(+), 10 deletions(-) create mode 100644 test/atof1.test diff --git a/manifest b/manifest index b57416185b..9606896e10 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sproblem\swith\sidentifying\swhite-space\scharacters\soutside\sof\sthe\sascii\srange\sin\sthe\sICU\stokenizer. -D 2012-06-18T20:52:32.200 +C Improved\srounding\saccuracy\son\stest-to-float\sconversions. +D 2012-06-19T00:45:16.776 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -203,7 +203,7 @@ F src/test_btree.c 5b89601dcb42a33ba8b820a6b763cc9cb48bac16 F src/test_config.c 4f7b8030287d62fe56a1d99e68b41760feae381a F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc -F src/test_func.c 090f2c3339e85c2c964435f99aed6f3da9d59525 +F src/test_func.c 3a8dd37c08ab43b76d38eea2836e34a3897bf170 F src/test_fuzzer.c 1d26aa965120420bc14807da29d4d4541bfa6148 F src/test_hexio.c abfdecb6fa58c354623978efceb088ca18e379cd F src/test_init.c 3cbad7ce525aec925f8fda2192d576d47f0d478a @@ -237,7 +237,7 @@ F src/tokenize.c 1e86210d3976717a19238ea7b047fac481fe8c12 F src/trigger.c ee7e178fb9188f44b532cebd449a7c1df90fb684 F src/update.c d3076782c887c10e882996550345da9c4c9f9dea F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 -F src/util.c 4f6cfad661b2e3454b0cdd5b1b9d39a54942d0e3 +F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd F src/vdbe.c f5ad3c06dc3fe647097065829c013f3f1b9eadca F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb @@ -274,6 +274,7 @@ F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 0dd8701bd588bf6e70c2557a22ae3f22b2567b4c +F test/atof1.test 1f6dc0f47f6697e32fa51dd154412e1172984928 F test/attach.test 0d112b7713611fdf0340260192749737135fda5f F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966 F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e @@ -1005,7 +1006,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 0c2fb18d25217ada7e75dcab8b342bbc632875d8 -R de31ab49b2137fc2f97d1253270053d5 -U dan -Z 2c0f1a3c7e342f99735e428af302d9d8 +P 892b74116a3b23268895b96433d18ef00c1433d8 +R f92cf3b5f19c2cdf0a1f4043259e76e0 +U drh +Z 37917877b4f7a2aac8f4f47ec8031274 diff --git a/manifest.uuid b/manifest.uuid index 75492d0b49..9a76fd8178 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -892b74116a3b23268895b96433d18ef00c1433d8 \ No newline at end of file +699b792c6a0e989994549959b11ec1bfad8bbd92 \ No newline at end of file diff --git a/src/test_func.c b/src/test_func.c index c4fe351cb9..6f9bb03dc8 100644 --- a/src/test_func.c +++ b/src/test_func.c @@ -422,6 +422,43 @@ static void testHexToUtf16le( } #endif +/* +** SQL function: real2hex(X) +** +** If argument X is a real number, then convert it into a string which is +** the big-endian hexadecimal representation of the ieee754 encoding of +** that number. If X is not a real number, return NULL. +*/ +static void real2hex( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + union { + sqlite3_uint64 i; + double r; + unsigned char x[8]; + } v; + char zOut[20]; + int i; + int bigEndian; + v.i = 1; + bigEndian = v.x[0]==0; + v.r = sqlite3_value_double(argv[0]); + for(i=0; i<8; i++){ + if( bigEndian ){ + zOut[i*2] = "0123456789abcdef"[v.x[i]>>4]; + zOut[i*2+1] = "0123456789abcdef"[v.x[i]&0xf]; + }else{ + zOut[14-i*2] = "0123456789abcdef"[v.x[i]>>4]; + zOut[14-i*2+1] = "0123456789abcdef"[v.x[i]&0xf]; + } + } + zOut[16] = 0; + sqlite3_result_text(context, zOut, -1, SQLITE_TRANSIENT); +} + + static int registerTestFunctions(sqlite3 *db){ static const struct { char *zName; @@ -444,6 +481,7 @@ static int registerTestFunctions(sqlite3 *db){ { "test_eval", 1, SQLITE_UTF8, test_eval}, { "test_isolation", 2, SQLITE_UTF8, test_isolation}, { "test_counter", 1, SQLITE_UTF8, counterFunc}, + { "real2hex", 1, SQLITE_UTF8, real2hex}, }; int i; diff --git a/src/util.c b/src/util.c index dd3b08ae46..5cf8ebacb5 100644 --- a/src/util.c +++ b/src/util.c @@ -371,7 +371,7 @@ do_atof_calc: /* if exponent, scale significand as appropriate ** and store in result. */ if( e ){ - double scale = 1.0; + LONGDOUBLE_TYPE scale = 1.0; /* attempt to handle extremely small/large numbers better */ if( e>307 && e<342 ){ while( e%308 ) { scale *= 1.0e+1; e -= 1; } diff --git a/test/atof1.test b/test/atof1.test new file mode 100644 index 0000000000..dff5e2a3d8 --- /dev/null +++ b/test/atof1.test @@ -0,0 +1,36 @@ +# 2012 June 18 +# +# 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 of the sqlite3AtoF() function. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +expr srand(1) +for {set i 1} {$i<10000} {incr i} { + do_test 1.$i { + set pow [expr {int((rand()-0.5)*100)}] + set x [expr {pow((rand()-0.5)*2*rand(),$pow)}] + set xf [format %.45e $x] + set y [db eval "SELECT $xf=\$x"] + if {!$y} { + puts -nonewline \173[db eval "SELECT real2hex($xf), real2hex(\$x)"]\175 + db eval "SELECT $xf+0.0 AS a, \$x AS b" { + puts [format "\n%.60e\n%.60e\n%.60e" $x $a $b] + } + } + set y + } {1} +} + + +finish_test From 72b3fbc7b5b5bbe783ca6a6b14532770f6eb011d Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Jun 2012 03:11:25 +0000 Subject: [PATCH 10/69] Improved accuracy on text-to-real and real-to-text conversions. Most conversions now round-trip correctly. Still need to fix some corner cases. FossilOrigin-Name: 8ecffca900cd6a8922001fd458a266ce8c83fb66 --- manifest | 21 ++++++++++++--------- manifest.uuid | 2 +- src/func.c | 13 ++++++++++++- src/printf.c | 15 +++++++++------ test/atof1.test | 32 ++++++++++++++++++++++++++++---- test/date.test | 2 +- 6 files changed, 63 insertions(+), 22 deletions(-) diff --git a/manifest b/manifest index 9606896e10..92463ef29e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\srounding\saccuracy\son\stest-to-float\sconversions. -D 2012-06-19T00:45:16.776 +C Improved\saccuracy\son\stext-to-real\sand\sreal-to-text\sconversions.\s\sMost\nconversions\snow\sround-trip\scorrectly.\s\sStill\sneed\sto\sfix\ssome\scorner\ncases. +D 2012-06-19T03:11:25.621 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -135,7 +135,7 @@ F src/delete.c 4c20ea4f6213b3bc1c6a510586864b679946e05e F src/expr.c 06a7733d19dc725dc46ba51afd9feadb4b85d991 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5 -F src/func.c c6b3c94320253a35bda43fb69cc292618e3285d6 +F src/func.c 22a180ac02e725a16aed586c3ae1c1c0f7c79cfd F src/global.c 4cfdca5cb0edd33c4d021baec4ede958cb2c793b F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -174,7 +174,7 @@ F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache1.c 2234d84f9c003d800a57f00f8535c91667fa4f6c F src/pragma.c eee3e3161f82a1e06f632a8d2a82b29ba3c45889 F src/prepare.c 33291b83cca285718048d219c67b8298501fa3a5 -F src/printf.c 7ffb4ebb8b341f67e049695ba031da717b3d2699 +F src/printf.c 263748c3b1e41f9f16a567ef2cbe4cf95b897a1a F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 @@ -274,7 +274,7 @@ F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 0dd8701bd588bf6e70c2557a22ae3f22b2567b4c -F test/atof1.test 1f6dc0f47f6697e32fa51dd154412e1172984928 +F test/atof1.test 6e6d41337133cb98e61262fa385780e04e9de165 F test/attach.test 0d112b7713611fdf0340260192749737135fda5f F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966 F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e @@ -364,7 +364,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 -F test/date.test a18a2ce81add84b17b06559e82ad7bb91bc6ddff +F test/date.test f3228180c87bbe5d39c9397bf001c0095c3821b9 F test/dbstatus.test 207e5b63fcb7b9c3bb8e1fdf38ebd4654ad0e54b F test/dbstatus2.test b1de8250fde1f3474d6b86f0e89de38d84794f56 F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc @@ -1006,7 +1006,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 892b74116a3b23268895b96433d18ef00c1433d8 -R f92cf3b5f19c2cdf0a1f4043259e76e0 +P 699b792c6a0e989994549959b11ec1bfad8bbd92 +R 9adb61fbfc8a4b0255b08c19fe781f44 +T *branch * floating-point-conversions +T *sym-floating-point-conversions * +T -sym-trunk * U drh -Z 37917877b4f7a2aac8f4f47ec8031274 +Z 93861bbc3afe941842927198b8f68ac0 diff --git a/manifest.uuid b/manifest.uuid index 9a76fd8178..630caf4294 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -699b792c6a0e989994549959b11ec1bfad8bbd92 \ No newline at end of file +8ecffca900cd6a8922001fd458a266ce8c83fb66 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 6ffc7184b0..7aaef2b38f 100644 --- a/src/func.c +++ b/src/func.c @@ -863,8 +863,19 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ assert( argc==1 ); UNUSED_PARAMETER(argc); switch( sqlite3_value_type(argv[0]) ){ - case SQLITE_INTEGER: case SQLITE_FLOAT: { + double r1, r2; + r1 = sqlite3_value_double(argv[0]); + char zBuf[50]; + sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1); + sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8); + if( r1!=r2 ){ + sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.20e", r1); + } + sqlite3_result_text(context, zBuf, -1, SQLITE_TRANSIENT); + break; + } + case SQLITE_INTEGER: { sqlite3_result_value(context, argv[0]); break; } diff --git a/src/printf.c b/src/printf.c index 58cfd2bd41..75febb286f 100644 --- a/src/printf.c +++ b/src/printf.c @@ -124,7 +124,8 @@ static const et_info fmtinfo[] = { static char et_getdigit(LONGDOUBLE_TYPE *val, int *cnt){ int digit; LONGDOUBLE_TYPE d; - if( (*cnt)++ >= 16 ) return '0'; + if( (*cnt)<=0 ) return '0'; + (*cnt)--; digit = (int)*val; d = digit; digit += '0'; @@ -428,9 +429,11 @@ void sqlite3VXPrintf( break; } if( realvalue>0.0 ){ - while( realvalue>=1e32 && exp<=350 ){ realvalue *= 1e-32; exp+=32; } - while( realvalue>=1e8 && exp<=350 ){ realvalue *= 1e-8; exp+=8; } - while( realvalue>=10.0 && exp<=350 ){ realvalue *= 0.1; exp++; } + LONGDOUBLE_TYPE scale = 1.0; + while( realvalue>=1e64*scale && exp<=350 ){ scale *= 1e64; exp+=64; } + while( realvalue>=1e8*scale && exp<=350 ){ scale *= 1e8; exp+=8; } + while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; } + realvalue /= scale; while( realvalue<1e-8 ){ realvalue *= 1e8; exp-=8; } while( realvalue<1.0 ){ realvalue *= 10.0; exp--; } if( exp>350 ){ @@ -463,7 +466,7 @@ void sqlite3VXPrintf( xtype = etFLOAT; } }else{ - flag_rtz = 0; + flag_rtz = flag_altform2; } if( xtype==etEXP ){ e2 = 0; @@ -478,7 +481,7 @@ void sqlite3VXPrintf( } } zOut = bufpt; - nsd = 0; + nsd = 16 + flag_altform2*10; flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2; /* The sign in front of the number */ if( prefix ){ diff --git a/test/atof1.test b/test/atof1.test index dff5e2a3d8..f1635789a6 100644 --- a/test/atof1.test +++ b/test/atof1.test @@ -17,10 +17,14 @@ source $testdir/tester.tcl expr srand(1) for {set i 1} {$i<10000} {incr i} { - do_test 1.$i { - set pow [expr {int((rand()-0.5)*100)}] - set x [expr {pow((rand()-0.5)*2*rand(),$pow)}] - set xf [format %.45e $x] + set pow [expr {int((rand()-0.5)*100)}] + set x [expr {pow((rand()-0.5)*2*rand(),$pow)}] + set xf [format %.32e $x] + + # Verify that text->real conversions get exactly same ieee754 floating- + # point value in SQLite as they do in TCL. + # + do_test 1.$i.1 { set y [db eval "SELECT $xf=\$x"] if {!$y} { puts -nonewline \173[db eval "SELECT real2hex($xf), real2hex(\$x)"]\175 @@ -30,6 +34,26 @@ for {set i 1} {$i<10000} {incr i} { } set y } {1} + + # FIX ME. The following tests (real->text->real round-trips) sometimes + # fail for large floating-point values. Skip them for now... + # + if {abs($x)>1e50} continue + + # Verify that round-trip real->text->real conversions using the quote() + # function preserve the bits of the numeric value exactly. + # + do_test 1.$i.2 { + set y [db eval {SELECT $x=CAST(quote($x) AS real)}] + if {!$y} { + db eval {SELECT real2hex($x) a, real2hex(CAST(quote($x) AS real)) b} {} + puts "\nIN: $a $xf" + puts [format {QUOTE: %16s %s} {} [db eval {SELECT quote($x)}]] + db eval {SELECT CAST(quote($x) AS real) c} {} + puts "OUT: $b [format %.32e $c]" + } + set y + } {1} } diff --git a/test/date.test b/test/date.test index 9bfec12626..a30402c0d6 100644 --- a/test/date.test +++ b/test/date.test @@ -151,7 +151,7 @@ datetest 3.2.1 {strftime('pre%fpost','2003-10-31 12:34:56.432')} pre56.432post datetest 3.2.2 {strftime('%f','2003-10-31 12:34:59.9999999')} 59.999 datetest 3.3 {strftime('%H','2003-10-31 12:34:56.432')} 12 datetest 3.4 {strftime('%j','2003-10-31 12:34:56.432')} 304 -datetest 3.5 {strftime('%J','2003-10-31 12:34:56.432')} 2452944.02426426 +datetest 3.5 {strftime('%J','2003-10-31 12:34:56.432')} 2452944.024264259 datetest 3.6 {strftime('%m','2003-10-31 12:34:56.432')} 10 datetest 3.7 {strftime('%M','2003-10-31 12:34:56.432')} 34 datetest 3.8.1 {strftime('%s','2003-10-31 12:34:56.432')} 1067603696 From 4ef941302867706bd6e997b9b46d5e096d93273e Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Jun 2012 03:35:05 +0000 Subject: [PATCH 11/69] Round-trip conversions of real->text->real are now lossless on x64 with GCC. Untested on other platforms so far. Still a corner-case problem with round(). FossilOrigin-Name: fd7bd4a59361be41b10522abc212cf56fb5e35b4 --- manifest | 17 +++++++---------- manifest.uuid | 2 +- src/printf.c | 1 + test/atof1.test | 7 +------ 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index 92463ef29e..f2fa197301 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\saccuracy\son\stext-to-real\sand\sreal-to-text\sconversions.\s\sMost\nconversions\snow\sround-trip\scorrectly.\s\sStill\sneed\sto\sfix\ssome\scorner\ncases. -D 2012-06-19T03:11:25.621 +C Round-trip\sconversions\sof\sreal->text->real\sare\snow\slossless\son\sx64\swith\sGCC.\nUntested\son\sother\splatforms\sso\sfar.\s\sStill\sa\scorner-case\sproblem\swith\sround(). +D 2012-06-19T03:35:05.368 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -174,7 +174,7 @@ F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache1.c 2234d84f9c003d800a57f00f8535c91667fa4f6c F src/pragma.c eee3e3161f82a1e06f632a8d2a82b29ba3c45889 F src/prepare.c 33291b83cca285718048d219c67b8298501fa3a5 -F src/printf.c 263748c3b1e41f9f16a567ef2cbe4cf95b897a1a +F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 @@ -274,7 +274,7 @@ F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 0dd8701bd588bf6e70c2557a22ae3f22b2567b4c -F test/atof1.test 6e6d41337133cb98e61262fa385780e04e9de165 +F test/atof1.test b765ba6bc09aa6a16234d2d66a71a5079f2a6d8a F test/attach.test 0d112b7713611fdf0340260192749737135fda5f F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966 F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e @@ -1006,10 +1006,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 699b792c6a0e989994549959b11ec1bfad8bbd92 -R 9adb61fbfc8a4b0255b08c19fe781f44 -T *branch * floating-point-conversions -T *sym-floating-point-conversions * -T -sym-trunk * +P 8ecffca900cd6a8922001fd458a266ce8c83fb66 +R 4b19672a1a06e137614a87d3123c24fd U drh -Z 93861bbc3afe941842927198b8f68ac0 +Z 1cc55456093d3d8044d88cb7bcd1bdba diff --git a/manifest.uuid b/manifest.uuid index 630caf4294..703abfa72b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ecffca900cd6a8922001fd458a266ce8c83fb66 \ No newline at end of file +fd7bd4a59361be41b10522abc212cf56fb5e35b4 \ No newline at end of file diff --git a/src/printf.c b/src/printf.c index 75febb286f..9f68d204ff 100644 --- a/src/printf.c +++ b/src/printf.c @@ -430,6 +430,7 @@ void sqlite3VXPrintf( } if( realvalue>0.0 ){ LONGDOUBLE_TYPE scale = 1.0; + while( realvalue>=1e100*scale && exp<=350 ){ scale *= 1e100;exp+=100;} while( realvalue>=1e64*scale && exp<=350 ){ scale *= 1e64; exp+=64; } while( realvalue>=1e8*scale && exp<=350 ){ scale *= 1e8; exp+=8; } while( realvalue>=10.0*scale && exp<=350 ){ scale *= 10.0; exp++; } diff --git a/test/atof1.test b/test/atof1.test index f1635789a6..66e1bee518 100644 --- a/test/atof1.test +++ b/test/atof1.test @@ -16,7 +16,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl expr srand(1) -for {set i 1} {$i<10000} {incr i} { +for {set i 1} {$i<20000} {incr i} { set pow [expr {int((rand()-0.5)*100)}] set x [expr {pow((rand()-0.5)*2*rand(),$pow)}] set xf [format %.32e $x] @@ -35,11 +35,6 @@ for {set i 1} {$i<10000} {incr i} { set y } {1} - # FIX ME. The following tests (real->text->real round-trips) sometimes - # fail for large floating-point values. Skip them for now... - # - if {abs($x)>1e50} continue - # Verify that round-trip real->text->real conversions using the quote() # function preserve the bits of the numeric value exactly. # From 4aaf1552be2a1376bdc595077037e09f60adb691 Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 19 Jun 2012 03:59:30 +0000 Subject: [PATCH 12/69] Fix an incorrect testcase for the round() function. All tests are passing now, including new real->text->real round-trip tests. FossilOrigin-Name: 963eb24f737f184d5fcdcd92ebf90466f818cfd8 --- manifest | 12 ++++++------ manifest.uuid | 2 +- test/func.test | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index f2fa197301..476505fb32 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Round-trip\sconversions\sof\sreal->text->real\sare\snow\slossless\son\sx64\swith\sGCC.\nUntested\son\sother\splatforms\sso\sfar.\s\sStill\sa\scorner-case\sproblem\swith\sround(). -D 2012-06-19T03:35:05.368 +C Fix\san\sincorrect\stestcase\sfor\sthe\sround()\sfunction.\s\sAll\stests\sare\spassing\nnow,\sincluding\snew\sreal->text->real\sround-trip\stests. +D 2012-06-19T03:59:30.382 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -503,7 +503,7 @@ F test/fts4merge.test c424309743fdd203f8e56a1f1cd7872cd66cc0ee F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7 F test/fts4unicode.test 247e6c64563b5f930aec0f89a5b01ed6b4b129cd -F test/func.test 9809b7622d721904a8cc33c1ffb87f46d506ed01 +F test/func.test 0d89043dab9a8853358d14c68e028ee0093bf066 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 @@ -1006,7 +1006,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8ecffca900cd6a8922001fd458a266ce8c83fb66 -R 4b19672a1a06e137614a87d3123c24fd +P fd7bd4a59361be41b10522abc212cf56fb5e35b4 +R c0c29fe1d0e93cd15c8e76222be12539 U drh -Z 1cc55456093d3d8044d88cb7bcd1bdba +Z 5bd3e2acf922536517e034479b86dc68 diff --git a/manifest.uuid b/manifest.uuid index 703abfa72b..eb04d6c81f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fd7bd4a59361be41b10522abc212cf56fb5e35b4 \ No newline at end of file +963eb24f737f184d5fcdcd92ebf90466f818cfd8 \ No newline at end of file diff --git a/test/func.test b/test/func.test index ba1ea026d7..e44c44b280 100644 --- a/test/func.test +++ b/test/func.test @@ -312,7 +312,7 @@ ifcapable floatingpoint { execsql {SELECT round(9999999999999.55,1);} } {9999999999999.6} do_test func-4.38 { - execsql {SELECT round(9999999999999.555,2);} + execsql {SELECT round(9999999999999.556,2);} } {9999999999999.56} } From 2b434a7ec0b3bf9a04b581472439be02deb3e4cb Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 19 Jun 2012 04:36:48 +0000 Subject: [PATCH 13/69] Move variable declaration to fix compilation with MSVC. FossilOrigin-Name: d45f7a013f05fe7603d5e6d02df0e6bab2c7ffd8 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/func.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 476505fb32..bd1f483817 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sincorrect\stestcase\sfor\sthe\sround()\sfunction.\s\sAll\stests\sare\spassing\nnow,\sincluding\snew\sreal->text->real\sround-trip\stests. -D 2012-06-19T03:59:30.382 +C Move\svariable\sdeclaration\sto\sfix\scompilation\swith\sMSVC. +D 2012-06-19T04:36:48.907 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -135,7 +135,7 @@ F src/delete.c 4c20ea4f6213b3bc1c6a510586864b679946e05e F src/expr.c 06a7733d19dc725dc46ba51afd9feadb4b85d991 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5 -F src/func.c 22a180ac02e725a16aed586c3ae1c1c0f7c79cfd +F src/func.c 18dfedfb857e100b05755a1b12e88b389f957879 F src/global.c 4cfdca5cb0edd33c4d021baec4ede958cb2c793b F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -1006,7 +1006,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P fd7bd4a59361be41b10522abc212cf56fb5e35b4 -R c0c29fe1d0e93cd15c8e76222be12539 -U drh -Z 5bd3e2acf922536517e034479b86dc68 +P 963eb24f737f184d5fcdcd92ebf90466f818cfd8 +R f969ff33ef926829900ede45cb301833 +U mistachkin +Z 0dc9aadbc42938d9910cf216fa3f6f99 diff --git a/manifest.uuid b/manifest.uuid index eb04d6c81f..b28390f96e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -963eb24f737f184d5fcdcd92ebf90466f818cfd8 \ No newline at end of file +d45f7a013f05fe7603d5e6d02df0e6bab2c7ffd8 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 7aaef2b38f..e56561e4ec 100644 --- a/src/func.c +++ b/src/func.c @@ -865,8 +865,8 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ switch( sqlite3_value_type(argv[0]) ){ case SQLITE_FLOAT: { double r1, r2; - r1 = sqlite3_value_double(argv[0]); char zBuf[50]; + r1 = sqlite3_value_double(argv[0]); sqlite3_snprintf(sizeof(zBuf), zBuf, "%!.15g", r1); sqlite3AtoF(zBuf, &r2, 20, SQLITE_UTF8); if( r1!=r2 ){ From 3aaa4cd9ed06204766f81d111ff8fc804f2f14bb Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 19 Jun 2012 06:35:39 +0000 Subject: [PATCH 14/69] Add tests to check that the "unicode61" and "icu" tokenizers both identify white-space codepoints outside the ASCII range. FossilOrigin-Name: bfb2d4730cbbe18fb940e72f4fde9122d550734e --- manifest | 14 +++++------ manifest.uuid | 2 +- test/fts4unicode.test | 57 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 65 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 9606896e10..cdb67bec0b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improved\srounding\saccuracy\son\stest-to-float\sconversions. -D 2012-06-19T00:45:16.776 +C Add\stests\sto\scheck\sthat\sthe\s"unicode61"\sand\s"icu"\stokenizers\sboth\sidentify\swhite-space\scodepoints\soutside\sthe\sASCII\srange. +D 2012-06-19T06:35:39.290 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -502,7 +502,7 @@ F test/fts4langid.test 24a6e41063b416bbdf371ff6b4476fa41c194aa7 F test/fts4merge.test c424309743fdd203f8e56a1f1cd7872cd66cc0ee F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7 -F test/fts4unicode.test 247e6c64563b5f930aec0f89a5b01ed6b4b129cd +F test/fts4unicode.test aad033abdcfa0f87ce5f56468f59fdf2a0acbcef F test/func.test 9809b7622d721904a8cc33c1ffb87f46d506ed01 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a @@ -1006,7 +1006,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 892b74116a3b23268895b96433d18ef00c1433d8 -R f92cf3b5f19c2cdf0a1f4043259e76e0 -U drh -Z 37917877b4f7a2aac8f4f47ec8031274 +P 699b792c6a0e989994549959b11ec1bfad8bbd92 +R fcc8a5f96c6c9d1a1ba2f2345cbe909b +U dan +Z 04e7a9f69aa11cdd2b90d7abb2bd52a9 diff --git a/manifest.uuid b/manifest.uuid index 9a76fd8178..9412d9826a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -699b792c6a0e989994549959b11ec1bfad8bbd92 \ No newline at end of file +bfb2d4730cbbe18fb940e72f4fde9122d550734e \ No newline at end of file diff --git a/test/fts4unicode.test b/test/fts4unicode.test index 3abceb68b2..0ac60a6f01 100644 --- a/test/fts4unicode.test +++ b/test/fts4unicode.test @@ -326,5 +326,62 @@ do_unicode_token_test3 5.11 "tokenchars=\u0301" \ "0 hello\u0301world hello\u0301world 1 helloworld helloworld" +#------------------------------------------------------------------------- + +proc do_tokenize {tokenizer txt} { + set res [list] + foreach {a b c} [db one {SELECT fts3_tokenizer_test($tokenizer, $txt)}] { + lappend res $b + } + set res +} + +# Argument $lCodepoint must be a list of codepoints (integers) that +# correspond to whitespace characters. This command creates a string +# $W from the codepoints, then tokenizes "${W}hello{$W}world${W}" +# using tokenizer $tokenizer. The test passes if the tokenizer successfully +# extracts the two 5 character tokens. +# +proc do_isspace_test {tn tokenizer lCp} { + set whitespace [format [string repeat %c [llength $lCp]] {*}$lCp] + set txt "${whitespace}hello${whitespace}world${whitespace}" + uplevel [list do_test $tn [list do_tokenize $tokenizer $txt] {hello world}] +} + +set tokenizers [list unicode61] +ifcapable icu { lappend tokenizers icu } + +# Some tests to check that the tokenizers can both identify white-space +# codepoints. All codepoints tested below are of type "Zs" in the +# UnicodeData.txt file. +foreach T $tokenizers { + do_isspace_test 6.$T.1 $T 32 + do_isspace_test 6.$T.2 $T 160 + do_isspace_test 6.$T.3 $T 5760 + do_isspace_test 6.$T.4 $T 6158 + do_isspace_test 6.$T.5 $T 8192 + do_isspace_test 6.$T.6 $T 8193 + do_isspace_test 6.$T.7 $T 8194 + do_isspace_test 6.$T.8 $T 8195 + do_isspace_test 6.$T.9 $T 8196 + do_isspace_test 6.$T.10 $T 8197 + do_isspace_test 6.$T.11 $T 8198 + do_isspace_test 6.$T.12 $T 8199 + do_isspace_test 6.$T.13 $T 8200 + do_isspace_test 6.$T.14 $T 8201 + do_isspace_test 6.$T.15 $T 8202 + do_isspace_test 6.$T.16 $T 8239 + do_isspace_test 6.$T.17 $T 8287 + do_isspace_test 6.$T.18 $T 12288 + + do_isspace_test 6.$T.19 $T {32 160 5760 6158} + do_isspace_test 6.$T.19 $T {8192 8193 8194 8195} + do_isspace_test 6.$T.19 $T {8196 8197 8198 8199} + do_isspace_test 6.$T.19 $T {8200 8201 8202 8239} + do_isspace_test 6.$T.19 $T {8287 12288} +} + + finish_test + From 8d967a90f8fe15d55caed85c280e3d9e68d11095 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 21 Jun 2012 04:21:35 +0000 Subject: [PATCH 15/69] When linking to the MSVC runtime library, use the debug library when necessary. Also, link dynamically to the MSVC runtime library when required (e.g. WinRT) or requested via the USE_CRT_DLL build macro. FossilOrigin-Name: f6be345ad5ff739bd64114489930bab970e7972e --- Makefile.msc | 27 ++++++++++++++++++++++++--- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 32 insertions(+), 11 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index d8f01d650f..a80db8c638 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -15,6 +15,10 @@ USE_AMALGAMATION = 1 # USE_ICU = 0 +# Set this non-0 to dynamically link to the MSVC runtime library. +# +USE_CRT_DLL = 0 + # Set this non-0 to compile binaries suitable for the WinRT environment. # This setting does not apply to any binaries that require Tcl to operate # properly (i.e. the text fixture, etc). @@ -53,11 +57,28 @@ TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise # the following compile-time options must be used as well to # disable use of Win32 APIs that are not available and to enable # use of Win32 APIs that are specific to Windows 8 and/or WinRT. -# Also, we need to dynamically link to the MSVC runtime when -# compiling for WinRT. # !IF $(FOR_WINRT)!=0 -TCC = $(TCC) -DSQLITE_OS_WINRT=1 -MD +TCC = $(TCC) -DSQLITE_OS_WINRT=1 +!ENDIF + +# Also, we need to dynamically link to the correct MSVC runtime +# when compiling for WinRT (e.g. debug or release) OR if the +# USE_CRT_DLL option is set to force dynamically linking to the +# MSVC runtime library. +# +!IF $(FOR_WINRT)!=0 || $(USE_CRT_DLL)!=0 +!IF $(DEBUG)>0 +TCC = $(TCC) -MDd +!ELSE +TCC = $(TCC) -MD +!ENDIF +!ELSE +!IF $(DEBUG)>0 +TCC = $(TCC) -MTd +!ELSE +TCC = $(TCC) -MT +!ENDIF !ENDIF # The mksqlite3c.tcl and mksqlite3h.tcl scripts will pull in diff --git a/manifest b/manifest index cdb67bec0b..63815455d5 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\stests\sto\scheck\sthat\sthe\s"unicode61"\sand\s"icu"\stokenizers\sboth\sidentify\swhite-space\scodepoints\soutside\sthe\sASCII\srange. -D 2012-06-19T06:35:39.290 +C When\slinking\sto\sthe\sMSVC\sruntime\slibrary,\suse\sthe\sdebug\slibrary\swhen\snecessary.\s\sAlso,\slink\sdynamically\sto\sthe\sMSVC\sruntime\slibrary\swhen\srequired\s(e.g.\sWinRT)\sor\srequested\svia\sthe\sUSE_CRT_DLL\sbuild\smacro. +D 2012-06-21T04:21:35.689 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc fd86027849a59a2f621b791b79eabf3f8ffbd684 +F Makefile.msc e893726c32ff402760eea125c7baaf928ed24257 F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION 3e857b9b826e818eec9411eafe2c3fa22c1dbb8a @@ -1006,7 +1006,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 699b792c6a0e989994549959b11ec1bfad8bbd92 -R fcc8a5f96c6c9d1a1ba2f2345cbe909b -U dan -Z 04e7a9f69aa11cdd2b90d7abb2bd52a9 +P bfb2d4730cbbe18fb940e72f4fde9122d550734e +R b751ec9a0e2895a08497a9ce16da8150 +U mistachkin +Z 261d93d15033b394b92302b9665ce94e diff --git a/manifest.uuid b/manifest.uuid index 9412d9826a..3363e200dc 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bfb2d4730cbbe18fb940e72f4fde9122d550734e \ No newline at end of file +f6be345ad5ff739bd64114489930bab970e7972e \ No newline at end of file From 83905c905cc965a4d9342514b1a76a1d0bfc77a6 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 21 Jun 2012 13:00:37 +0000 Subject: [PATCH 16/69] Remove support for OS/2 from the source tree. FossilOrigin-Name: ff828c67e5d3c1afa5bc3a304b9c6fcc7b3ea5fa --- Makefile.in | 13 +- main.mk | 7 +- manifest | 28 +- manifest.uuid | 2 +- src/mutex.h | 4 - src/mutex_os2.c | 274 ------ src/os.h | 26 +- src/os_os2.c | 1924 ------------------------------------------- src/shell.c | 18 +- src/test_quota.c | 12 +- tool/mksqlite3c.tcl | 3 - 11 files changed, 25 insertions(+), 2286 deletions(-) delete mode 100644 src/mutex_os2.c delete mode 100644 src/os_os2.c diff --git a/Makefile.in b/Makefile.in index 9f8235d8ff..df424cb190 100644 --- a/Makefile.in +++ b/Makefile.in @@ -172,8 +172,8 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \ icu.lo insert.lo journal.lo legacy.lo loadext.lo \ main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \ memjournal.lo \ - mutex.lo mutex_noop.lo mutex_os2.lo mutex_unix.lo mutex_w32.lo \ - notify.lo opcodes.lo os.lo os_os2.lo os_unix.lo os_win.lo \ + mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \ + notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \ pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \ random.lo resolve.lo rowset.lo rtree.lo select.lo status.lo \ table.lo tokenize.lo trigger.lo \ @@ -232,14 +232,12 @@ SRC = \ $(TOP)/src/mutex.c \ $(TOP)/src/mutex.h \ $(TOP)/src/mutex_noop.c \ - $(TOP)/src/mutex_os2.c \ $(TOP)/src/mutex_unix.c \ $(TOP)/src/mutex_w32.c \ $(TOP)/src/notify.c \ $(TOP)/src/os.c \ $(TOP)/src/os.h \ $(TOP)/src/os_common.h \ - $(TOP)/src/os_os2.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ @@ -402,7 +400,6 @@ TESTSRC2 = \ $(TOP)/src/wal.c \ $(TOP)/src/mem5.c \ $(TOP)/src/os.c \ - $(TOP)/src/os_os2.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ @@ -657,9 +654,6 @@ mutex.lo: $(TOP)/src/mutex.c $(HDR) mutex_noop.lo: $(TOP)/src/mutex_noop.c $(HDR) $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mutex_noop.c -mutex_os2.lo: $(TOP)/src/mutex_os2.c $(HDR) - $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mutex_os2.c - mutex_unix.lo: $(TOP)/src/mutex_unix.c $(HDR) $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/mutex_unix.c @@ -687,9 +681,6 @@ os_unix.lo: $(TOP)/src/os_unix.c $(HDR) os_win.lo: $(TOP)/src/os_win.c $(HDR) $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/os_win.c -os_os2.lo: $(TOP)/src/os_os2.c $(HDR) - $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/os_os2.c - pragma.lo: $(TOP)/src/pragma.c $(HDR) $(LTCOMPILE) $(TEMP_STORE) -c $(TOP)/src/pragma.c diff --git a/main.mk b/main.mk index b484ad455c..8682961881 100644 --- a/main.mk +++ b/main.mk @@ -60,8 +60,8 @@ LIBOBJ+= alter.o analyze.o attach.o auth.o \ icu.o insert.o journal.o legacy.o loadext.o \ main.o malloc.o mem0.o mem1.o mem2.o mem3.o mem5.o \ memjournal.o \ - mutex.o mutex_noop.o mutex_os2.o mutex_unix.o mutex_w32.o \ - notify.o opcodes.o os.o os_os2.o os_unix.o os_win.o \ + mutex.o mutex_noop.o mutex_unix.o mutex_w32.o \ + notify.o opcodes.o os.o os_unix.o os_win.o \ pager.o parse.o pcache.o pcache1.o pragma.o prepare.o printf.o \ random.o resolve.o rowset.o rtree.o select.o status.o \ table.o tokenize.o trigger.o \ @@ -113,14 +113,12 @@ SRC = \ $(TOP)/src/mutex.c \ $(TOP)/src/mutex.h \ $(TOP)/src/mutex_noop.c \ - $(TOP)/src/mutex_os2.c \ $(TOP)/src/mutex_unix.c \ $(TOP)/src/mutex_w32.c \ $(TOP)/src/notify.c \ $(TOP)/src/os.c \ $(TOP)/src/os.h \ $(TOP)/src/os_common.h \ - $(TOP)/src/os_os2.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ @@ -282,7 +280,6 @@ TESTSRC2 = \ $(TOP)/src/wal.c \ $(TOP)/src/mem5.c \ $(TOP)/src/os.c \ - $(TOP)/src/os_os2.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ diff --git a/manifest b/manifest index 63815455d5..b28db56120 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C When\slinking\sto\sthe\sMSVC\sruntime\slibrary,\suse\sthe\sdebug\slibrary\swhen\snecessary.\s\sAlso,\slink\sdynamically\sto\sthe\sMSVC\sruntime\slibrary\swhen\srequired\s(e.g.\sWinRT)\sor\srequested\svia\sthe\sUSE_CRT_DLL\sbuild\smacro. -D 2012-06-21T04:21:35.689 +C Remove\ssupport\sfor\sOS/2\sfrom\sthe\ssource\stree. +D 2012-06-21T13:00:37.211 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 +F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc e893726c32ff402760eea125c7baaf928ed24257 F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca @@ -103,7 +103,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk 84ed9c324cf0b8f4eb6f276553d1fd092b5ae0f4 +F main.mk d109a9342d1fe135d3900aca9f5563f9480a991d F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -154,16 +154,14 @@ F src/mem3.c 61c9d47b792908c532ca3a62b999cf21795c6534 F src/mem5.c c2c63b7067570b00bf33d751c39af24182316f7f F src/memjournal.c 0ebce851677a7ac035ba1512a7e65851b34530c6 F src/mutex.c d3b66a569368015e0fcb1ac15f81c119f504d3bc -F src/mutex.h 2a79e0c10c26412546b501ee0f3d92b42decf63e +F src/mutex.h 5bc526e19dccc412b7ff04642f6fdad3fdfdabea F src/mutex_noop.c 7682796b7d8d39bf1c138248858efcd10c9e1553 -F src/mutex_os2.c 882d735098c07c8c6a5472b8dd66e19675fe117f F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc F src/mutex_w32.c db8970270841e2385a43602477e84c4b19aff1db F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c -F src/os.h 38aabd5e3ecd4162332076f55bb09cec02165cca +F src/os.h c2ebd26a68a4223fe170b003852b97d9e7211498 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 -F src/os_os2.c 4a75888ba3dfc820ad5e8177025972d74d7f2440 F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757 F src/os_win.c e3d3d3e26b65a35d4293d753137a58510bd3299b F src/pager.c e381c118b77dc22021a1a59d3fec24815e91df78 @@ -179,7 +177,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d -F src/shell.c c16f72e34f611f060546709564c121a67cb2b31b +F src/shell.c d332251457860fa2fe365a4ac623266d2b262319 F src/sqlite.h.in 39f041ce71a0d994e2487014fc9e8721595f5bc0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 29b5348f0056d9b46d0bb94d4853db21568afde9 @@ -218,7 +216,7 @@ F src/test_mutex.c a6bd7b9cf6e19d989e31392b06ac8d189f0d573e F src/test_onefile.c 0396f220561f3b4eedc450cef26d40c593c69a25 F src/test_osinst.c 90a845c8183013d80eccb1f29e8805608516edba F src/test_pcache.c a5cd24730cb43c5b18629043314548c9169abb00 -F src/test_quota.c 0af3e1e9a1f22bc5f431dd3efcc32762f4109f58 +F src/test_quota.c 8ab295092c70903ca6f3209fa4c75f5cb6c1bf8e F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 @@ -980,7 +978,7 @@ F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 105023aa86f696a74b1d6a4929d1e1c3baf9471c -F tool/mksqlite3c.tcl f289ba51f74f45c71a80c13e6c74a6dd92763253 +F tool/mksqlite3c.tcl 589c7f44e990be1b8443cfe4808dce392b0327fa F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8 F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 @@ -1006,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P bfb2d4730cbbe18fb940e72f4fde9122d550734e -R b751ec9a0e2895a08497a9ce16da8150 -U mistachkin -Z 261d93d15033b394b92302b9665ce94e +P f6be345ad5ff739bd64114489930bab970e7972e +R 492386d04a647f2a6a5176511e3c5436 +U drh +Z a98b35ee88892c9758a44c5d42a86c30 diff --git a/manifest.uuid b/manifest.uuid index 3363e200dc..bdacec9c75 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f6be345ad5ff739bd64114489930bab970e7972e \ No newline at end of file +ff828c67e5d3c1afa5bc3a304b9c6fcc7b3ea5fa \ No newline at end of file diff --git a/src/mutex.h b/src/mutex.h index b0e552c7c4..0978812252 100644 --- a/src/mutex.h +++ b/src/mutex.h @@ -36,8 +36,6 @@ ** SQLITE_MUTEX_PTHREADS For multi-threaded applications on Unix. ** ** SQLITE_MUTEX_W32 For multi-threaded applications on Win32. -** -** SQLITE_MUTEX_OS2 For multi-threaded applications on OS/2. */ #if !SQLITE_THREADSAFE # define SQLITE_MUTEX_OMIT @@ -47,8 +45,6 @@ # define SQLITE_MUTEX_PTHREADS # elif SQLITE_OS_WIN # define SQLITE_MUTEX_W32 -# elif SQLITE_OS_OS2 -# define SQLITE_MUTEX_OS2 # else # define SQLITE_MUTEX_NOOP # endif diff --git a/src/mutex_os2.c b/src/mutex_os2.c deleted file mode 100644 index ce650d994e..0000000000 --- a/src/mutex_os2.c +++ /dev/null @@ -1,274 +0,0 @@ -/* -** 2007 August 28 -** -** 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 contains the C functions that implement mutexes for OS/2 -*/ -#include "sqliteInt.h" - -/* -** The code in this file is only used if SQLITE_MUTEX_OS2 is defined. -** See the mutex.h file for details. -*/ -#ifdef SQLITE_MUTEX_OS2 - -/********************** OS/2 Mutex Implementation ********************** -** -** This implementation of mutexes is built using the OS/2 API. -*/ - -/* -** The mutex object -** Each recursive mutex is an instance of the following structure. -*/ -struct sqlite3_mutex { - HMTX mutex; /* Mutex controlling the lock */ - int id; /* Mutex type */ -#ifdef SQLITE_DEBUG - int trace; /* True to trace changes */ -#endif -}; - -#ifdef SQLITE_DEBUG -#define SQLITE3_MUTEX_INITIALIZER { 0, 0, 0 } -#else -#define SQLITE3_MUTEX_INITIALIZER { 0, 0 } -#endif - -/* -** Initialize and deinitialize the mutex subsystem. -*/ -static int os2MutexInit(void){ return SQLITE_OK; } -static int os2MutexEnd(void){ return SQLITE_OK; } - -/* -** The sqlite3_mutex_alloc() routine allocates a new -** mutex and returns a pointer to it. If it returns NULL -** that means that a mutex could not be allocated. -** SQLite will unwind its stack and return an error. The argument -** to sqlite3_mutex_alloc() is one of these integer constants: -** -**
    -**
  • SQLITE_MUTEX_FAST -**
  • SQLITE_MUTEX_RECURSIVE -**
  • SQLITE_MUTEX_STATIC_MASTER -**
  • SQLITE_MUTEX_STATIC_MEM -**
  • SQLITE_MUTEX_STATIC_MEM2 -**
  • SQLITE_MUTEX_STATIC_PRNG -**
  • SQLITE_MUTEX_STATIC_LRU -**
  • SQLITE_MUTEX_STATIC_LRU2 -**
-** -** The first two constants cause sqlite3_mutex_alloc() to create -** a new mutex. The new mutex is recursive when SQLITE_MUTEX_RECURSIVE -** is used but not necessarily so when SQLITE_MUTEX_FAST is used. -** The mutex implementation does not need to make a distinction -** between SQLITE_MUTEX_RECURSIVE and SQLITE_MUTEX_FAST if it does -** not want to. But SQLite will only request a recursive mutex in -** cases where it really needs one. If a faster non-recursive mutex -** implementation is available on the host platform, the mutex subsystem -** might return such a mutex in response to SQLITE_MUTEX_FAST. -** -** The other allowed parameters to sqlite3_mutex_alloc() each return -** a pointer to a static preexisting mutex. Six static mutexes are -** used by the current version of SQLite. Future versions of SQLite -** may add additional static mutexes. Static mutexes are for internal -** use by SQLite only. Applications that use SQLite mutexes should -** use only the dynamic mutexes returned by SQLITE_MUTEX_FAST or -** SQLITE_MUTEX_RECURSIVE. -** -** Note that if one of the dynamic mutex parameters (SQLITE_MUTEX_FAST -** or SQLITE_MUTEX_RECURSIVE) is used then sqlite3_mutex_alloc() -** returns a different mutex on every call. But for the static -** mutex types, the same mutex is returned on every call that has -** the same type number. -*/ -static sqlite3_mutex *os2MutexAlloc(int iType){ - sqlite3_mutex *p = NULL; - switch( iType ){ - case SQLITE_MUTEX_FAST: - case SQLITE_MUTEX_RECURSIVE: { - p = sqlite3MallocZero( sizeof(*p) ); - if( p ){ - p->id = iType; - if( DosCreateMutexSem( 0, &p->mutex, 0, FALSE ) != NO_ERROR ){ - sqlite3_free( p ); - p = NULL; - } - } - break; - } - default: { - static volatile int isInit = 0; - static sqlite3_mutex staticMutexes[6] = { - SQLITE3_MUTEX_INITIALIZER, - SQLITE3_MUTEX_INITIALIZER, - SQLITE3_MUTEX_INITIALIZER, - SQLITE3_MUTEX_INITIALIZER, - SQLITE3_MUTEX_INITIALIZER, - SQLITE3_MUTEX_INITIALIZER, - }; - if ( !isInit ){ - APIRET rc; - PTIB ptib; - PPIB ppib; - HMTX mutex; - char name[32]; - DosGetInfoBlocks( &ptib, &ppib ); - sqlite3_snprintf( sizeof(name), name, "\\SEM32\\SQLITE%04x", - ppib->pib_ulpid ); - while( !isInit ){ - mutex = 0; - rc = DosCreateMutexSem( name, &mutex, 0, FALSE); - if( rc == NO_ERROR ){ - unsigned int i; - if( !isInit ){ - for( i = 0; i < sizeof(staticMutexes)/sizeof(staticMutexes[0]); i++ ){ - DosCreateMutexSem( 0, &staticMutexes[i].mutex, 0, FALSE ); - } - isInit = 1; - } - DosCloseMutexSem( mutex ); - }else if( rc == ERROR_DUPLICATE_NAME ){ - DosSleep( 1 ); - }else{ - return p; - } - } - } - assert( iType-2 >= 0 ); - assert( iType-2 < sizeof(staticMutexes)/sizeof(staticMutexes[0]) ); - p = &staticMutexes[iType-2]; - p->id = iType; - break; - } - } - return p; -} - - -/* -** This routine deallocates a previously allocated mutex. -** SQLite is careful to deallocate every mutex that it allocates. -*/ -static void os2MutexFree(sqlite3_mutex *p){ -#ifdef SQLITE_DEBUG - TID tid; - PID pid; - ULONG ulCount; - DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount); - assert( ulCount==0 ); - assert( p->id==SQLITE_MUTEX_FAST || p->id==SQLITE_MUTEX_RECURSIVE ); -#endif - DosCloseMutexSem( p->mutex ); - sqlite3_free( p ); -} - -#ifdef SQLITE_DEBUG -/* -** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are -** intended for use inside assert() statements. -*/ -static int os2MutexHeld(sqlite3_mutex *p){ - TID tid; - PID pid; - ULONG ulCount; - PTIB ptib; - DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount); - if( ulCount==0 || ( ulCount>1 && p->id!=SQLITE_MUTEX_RECURSIVE ) ) - return 0; - DosGetInfoBlocks(&ptib, NULL); - return tid==ptib->tib_ptib2->tib2_ultid; -} -static int os2MutexNotheld(sqlite3_mutex *p){ - TID tid; - PID pid; - ULONG ulCount; - PTIB ptib; - DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount); - if( ulCount==0 ) - return 1; - DosGetInfoBlocks(&ptib, NULL); - return tid!=ptib->tib_ptib2->tib2_ultid; -} -static void os2MutexTrace(sqlite3_mutex *p, char *pAction){ - TID tid; - PID pid; - ULONG ulCount; - DosQueryMutexSem(p->mutex, &pid, &tid, &ulCount); - printf("%s mutex %p (%d) with nRef=%ld\n", pAction, (void*)p, p->trace, ulCount); -} -#endif - -/* -** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt -** to enter a mutex. If another thread is already within the mutex, -** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return -** SQLITE_BUSY. The sqlite3_mutex_try() interface returns SQLITE_OK -** upon successful entry. Mutexes created using SQLITE_MUTEX_RECURSIVE can -** be entered multiple times by the same thread. In such cases the, -** mutex must be exited an equal number of times before another thread -** can enter. If the same thread tries to enter any other kind of mutex -** more than once, the behavior is undefined. -*/ -static void os2MutexEnter(sqlite3_mutex *p){ - assert( p->id==SQLITE_MUTEX_RECURSIVE || os2MutexNotheld(p) ); - DosRequestMutexSem(p->mutex, SEM_INDEFINITE_WAIT); -#ifdef SQLITE_DEBUG - if( p->trace ) os2MutexTrace(p, "enter"); -#endif -} -static int os2MutexTry(sqlite3_mutex *p){ - int rc = SQLITE_BUSY; - assert( p->id==SQLITE_MUTEX_RECURSIVE || os2MutexNotheld(p) ); - if( DosRequestMutexSem(p->mutex, SEM_IMMEDIATE_RETURN) == NO_ERROR ) { - rc = SQLITE_OK; -#ifdef SQLITE_DEBUG - if( p->trace ) os2MutexTrace(p, "try"); -#endif - } - return rc; -} - -/* -** The sqlite3_mutex_leave() routine exits a mutex that was -** previously entered by the same thread. The behavior -** is undefined if the mutex is not currently entered or -** is not currently allocated. SQLite will never do either. -*/ -static void os2MutexLeave(sqlite3_mutex *p){ - assert( os2MutexHeld(p) ); - DosReleaseMutexSem(p->mutex); -#ifdef SQLITE_DEBUG - if( p->trace ) os2MutexTrace(p, "leave"); -#endif -} - -sqlite3_mutex_methods const *sqlite3DefaultMutex(void){ - static const sqlite3_mutex_methods sMutex = { - os2MutexInit, - os2MutexEnd, - os2MutexAlloc, - os2MutexFree, - os2MutexEnter, - os2MutexTry, - os2MutexLeave, -#ifdef SQLITE_DEBUG - os2MutexHeld, - os2MutexNotheld -#else - 0, - 0 -#endif - }; - - return &sMutex; -} -#endif /* SQLITE_MUTEX_OS2 */ diff --git a/src/os.h b/src/os.h index 2efffff9b6..37d08fc254 100644 --- a/src/os.h +++ b/src/os.h @@ -23,7 +23,7 @@ /* ** Figure out if we are dealing with Unix, Windows, or some other ** operating system. After the following block of preprocess macros, -** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, SQLITE_OS_OS2, and SQLITE_OS_OTHER +** all of SQLITE_OS_UNIX, SQLITE_OS_WIN, and SQLITE_OS_OTHER ** will defined to either 1 or 0. One of the four will be 1. The other ** three will be 0. */ @@ -33,8 +33,6 @@ # define SQLITE_OS_UNIX 0 # undef SQLITE_OS_WIN # define SQLITE_OS_WIN 0 -# undef SQLITE_OS_OS2 -# define SQLITE_OS_OS2 0 # else # undef SQLITE_OS_OTHER # endif @@ -45,19 +43,12 @@ # if defined(_WIN32) || defined(WIN32) || defined(__CYGWIN__) || defined(__MINGW32__) || defined(__BORLANDC__) # define SQLITE_OS_WIN 1 # define SQLITE_OS_UNIX 0 -# define SQLITE_OS_OS2 0 -# elif defined(__EMX__) || defined(_OS2) || defined(OS2) || defined(_OS2_) || defined(__OS2__) -# define SQLITE_OS_WIN 0 -# define SQLITE_OS_UNIX 0 -# define SQLITE_OS_OS2 1 # else # define SQLITE_OS_WIN 0 # define SQLITE_OS_UNIX 1 -# define SQLITE_OS_OS2 0 # endif # else # define SQLITE_OS_UNIX 0 -# define SQLITE_OS_OS2 0 # endif #else # ifndef SQLITE_OS_WIN @@ -69,21 +60,6 @@ # include #endif -#if SQLITE_OS_OS2 -# if (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ >= 3) && defined(OS2_HIGH_MEMORY) -# include /* has to be included before os2.h for linking to work */ -# endif -# define INCL_DOSDATETIME -# define INCL_DOSFILEMGR -# define INCL_DOSERRORS -# define INCL_DOSMISC -# define INCL_DOSPROCESS -# define INCL_DOSMODULEMGR -# define INCL_DOSSEMAPHORES -# include -# include -#endif - /* ** Determine if we are dealing with Windows NT. ** diff --git a/src/os_os2.c b/src/os_os2.c deleted file mode 100644 index 487ac3c3c8..0000000000 --- a/src/os_os2.c +++ /dev/null @@ -1,1924 +0,0 @@ -/* -** 2006 Feb 14 -** -** 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 contains code that is specific to OS/2. -*/ - -#include "sqliteInt.h" - -#if SQLITE_OS_OS2 - -/* -** A Note About Memory Allocation: -** -** This driver uses malloc()/free() directly rather than going through -** the SQLite-wrappers sqlite3_malloc()/sqlite3_free(). Those wrappers -** are designed for use on embedded systems where memory is scarce and -** malloc failures happen frequently. OS/2 does not typically run on -** embedded systems, and when it does the developers normally have bigger -** problems to worry about than running out of memory. So there is not -** a compelling need to use the wrappers. -** -** But there is a good reason to not use the wrappers. If we use the -** wrappers then we will get simulated malloc() failures within this -** driver. And that causes all kinds of problems for our tests. We -** could enhance SQLite to deal with simulated malloc failures within -** the OS driver, but the code to deal with those failure would not -** be exercised on Linux (which does not need to malloc() in the driver) -** and so we would have difficulty writing coverage tests for that -** code. Better to leave the code out, we think. -** -** The point of this discussion is as follows: When creating a new -** OS layer for an embedded system, if you use this file as an example, -** avoid the use of malloc()/free(). Those routines work ok on OS/2 -** desktops but not so well in embedded systems. -*/ - -/* -** Macros used to determine whether or not to use threads. -*/ -#if defined(SQLITE_THREADSAFE) && SQLITE_THREADSAFE -# define SQLITE_OS2_THREADS 1 -#endif - -/* -** Include code that is common to all os_*.c files -*/ -#include "os_common.h" - -/* Forward references */ -typedef struct os2File os2File; /* The file structure */ -typedef struct os2ShmNode os2ShmNode; /* A shared descritive memory node */ -typedef struct os2ShmLink os2ShmLink; /* A connection to shared-memory */ - -/* -** The os2File structure is subclass of sqlite3_file specific for the OS/2 -** protability layer. -*/ -struct os2File { - const sqlite3_io_methods *pMethod; /* Always the first entry */ - HFILE h; /* Handle for accessing the file */ - int flags; /* Flags provided to os2Open() */ - int locktype; /* Type of lock currently held on this file */ - int szChunk; /* Chunk size configured by FCNTL_CHUNK_SIZE */ - char *zFullPathCp; /* Full path name of this file */ - os2ShmLink *pShmLink; /* Instance of shared memory on this file */ -}; - -#define LOCK_TIMEOUT 10L /* the default locking timeout */ - -/* -** Missing from some versions of the OS/2 toolkit - -** used to allocate from high memory if possible -*/ -#ifndef OBJ_ANY -# define OBJ_ANY 0x00000400 -#endif - -/***************************************************************************** -** The next group of routines implement the I/O methods specified -** by the sqlite3_io_methods object. -******************************************************************************/ - -/* -** Close a file. -*/ -static int os2Close( sqlite3_file *id ){ - APIRET rc; - os2File *pFile = (os2File*)id; - - assert( id!=0 ); - OSTRACE(( "CLOSE %d (%s)\n", pFile->h, pFile->zFullPathCp )); - - rc = DosClose( pFile->h ); - - if( pFile->flags & SQLITE_OPEN_DELETEONCLOSE ) - DosForceDelete( (PSZ)pFile->zFullPathCp ); - - free( pFile->zFullPathCp ); - pFile->zFullPathCp = NULL; - pFile->locktype = NO_LOCK; - pFile->h = (HFILE)-1; - pFile->flags = 0; - - OpenCounter( -1 ); - return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR; -} - -/* -** Read data from a file into a buffer. Return SQLITE_OK if all -** bytes were read successfully and SQLITE_IOERR if anything goes -** wrong. -*/ -static int os2Read( - sqlite3_file *id, /* File to read from */ - void *pBuf, /* Write content into this buffer */ - int amt, /* Number of bytes to read */ - sqlite3_int64 offset /* Begin reading at this offset */ -){ - ULONG fileLocation = 0L; - ULONG got; - os2File *pFile = (os2File*)id; - assert( id!=0 ); - SimulateIOError( return SQLITE_IOERR_READ ); - OSTRACE(( "READ %d lock=%d\n", pFile->h, pFile->locktype )); - if( DosSetFilePtr(pFile->h, offset, FILE_BEGIN, &fileLocation) != NO_ERROR ){ - return SQLITE_IOERR; - } - if( DosRead( pFile->h, pBuf, amt, &got ) != NO_ERROR ){ - return SQLITE_IOERR_READ; - } - if( got == (ULONG)amt ) - return SQLITE_OK; - else { - /* Unread portions of the input buffer must be zero-filled */ - memset(&((char*)pBuf)[got], 0, amt-got); - return SQLITE_IOERR_SHORT_READ; - } -} - -/* -** Write data from a buffer into a file. Return SQLITE_OK on success -** or some other error code on failure. -*/ -static int os2Write( - sqlite3_file *id, /* File to write into */ - const void *pBuf, /* The bytes to be written */ - int amt, /* Number of bytes to write */ - sqlite3_int64 offset /* Offset into the file to begin writing at */ -){ - ULONG fileLocation = 0L; - APIRET rc = NO_ERROR; - ULONG wrote; - os2File *pFile = (os2File*)id; - assert( id!=0 ); - SimulateIOError( return SQLITE_IOERR_WRITE ); - SimulateDiskfullError( return SQLITE_FULL ); - OSTRACE(( "WRITE %d lock=%d\n", pFile->h, pFile->locktype )); - if( DosSetFilePtr(pFile->h, offset, FILE_BEGIN, &fileLocation) != NO_ERROR ){ - return SQLITE_IOERR; - } - assert( amt>0 ); - while( amt > 0 && - ( rc = DosWrite( pFile->h, (PVOID)pBuf, amt, &wrote ) ) == NO_ERROR && - wrote > 0 - ){ - amt -= wrote; - pBuf = &((char*)pBuf)[wrote]; - } - - return ( rc != NO_ERROR || amt > (int)wrote ) ? SQLITE_FULL : SQLITE_OK; -} - -/* -** Truncate an open file to a specified size -*/ -static int os2Truncate( sqlite3_file *id, i64 nByte ){ - APIRET rc; - os2File *pFile = (os2File*)id; - assert( id!=0 ); - OSTRACE(( "TRUNCATE %d %lld\n", pFile->h, nByte )); - SimulateIOError( return SQLITE_IOERR_TRUNCATE ); - - /* If the user has configured a chunk-size for this file, truncate the - ** file so that it consists of an integer number of chunks (i.e. the - ** actual file size after the operation may be larger than the requested - ** size). - */ - if( pFile->szChunk ){ - nByte = ((nByte + pFile->szChunk - 1)/pFile->szChunk) * pFile->szChunk; - } - - rc = DosSetFileSize( pFile->h, nByte ); - return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR_TRUNCATE; -} - -#ifdef SQLITE_TEST -/* -** Count the number of fullsyncs and normal syncs. This is used to test -** that syncs and fullsyncs are occuring at the right times. -*/ -int sqlite3_sync_count = 0; -int sqlite3_fullsync_count = 0; -#endif - -/* -** Make sure all writes to a particular file are committed to disk. -*/ -static int os2Sync( sqlite3_file *id, int flags ){ - os2File *pFile = (os2File*)id; - OSTRACE(( "SYNC %d lock=%d\n", pFile->h, pFile->locktype )); -#ifdef SQLITE_TEST - if( flags & SQLITE_SYNC_FULL){ - sqlite3_fullsync_count++; - } - sqlite3_sync_count++; -#endif - /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a - ** no-op - */ -#ifdef SQLITE_NO_SYNC - UNUSED_PARAMETER(pFile); - return SQLITE_OK; -#else - return DosResetBuffer( pFile->h ) == NO_ERROR ? SQLITE_OK : SQLITE_IOERR; -#endif -} - -/* -** Determine the current size of a file in bytes -*/ -static int os2FileSize( sqlite3_file *id, sqlite3_int64 *pSize ){ - APIRET rc = NO_ERROR; - FILESTATUS3 fsts3FileInfo; - memset(&fsts3FileInfo, 0, sizeof(fsts3FileInfo)); - assert( id!=0 ); - SimulateIOError( return SQLITE_IOERR_FSTAT ); - rc = DosQueryFileInfo( ((os2File*)id)->h, FIL_STANDARD, &fsts3FileInfo, sizeof(FILESTATUS3) ); - if( rc == NO_ERROR ){ - *pSize = fsts3FileInfo.cbFile; - return SQLITE_OK; - }else{ - return SQLITE_IOERR_FSTAT; - } -} - -/* -** Acquire a reader lock. -*/ -static int getReadLock( os2File *pFile ){ - FILELOCK LockArea, - UnlockArea; - APIRET res; - memset(&LockArea, 0, sizeof(LockArea)); - memset(&UnlockArea, 0, sizeof(UnlockArea)); - LockArea.lOffset = SHARED_FIRST; - LockArea.lRange = SHARED_SIZE; - UnlockArea.lOffset = 0L; - UnlockArea.lRange = 0L; - res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 1L ); - OSTRACE(( "GETREADLOCK %d res=%d\n", pFile->h, res )); - return res; -} - -/* -** Undo a readlock -*/ -static int unlockReadLock( os2File *id ){ - FILELOCK LockArea, - UnlockArea; - APIRET res; - memset(&LockArea, 0, sizeof(LockArea)); - memset(&UnlockArea, 0, sizeof(UnlockArea)); - LockArea.lOffset = 0L; - LockArea.lRange = 0L; - UnlockArea.lOffset = SHARED_FIRST; - UnlockArea.lRange = SHARED_SIZE; - res = DosSetFileLocks( id->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 1L ); - OSTRACE(( "UNLOCK-READLOCK file handle=%d res=%d?\n", id->h, res )); - return res; -} - -/* -** Lock the file with the lock specified by parameter locktype - one -** of the following: -** -** (1) SHARED_LOCK -** (2) RESERVED_LOCK -** (3) PENDING_LOCK -** (4) EXCLUSIVE_LOCK -** -** Sometimes when requesting one lock state, additional lock states -** are inserted in between. The locking might fail on one of the later -** transitions leaving the lock state different from what it started but -** still short of its goal. The following chart shows the allowed -** transitions and the inserted intermediate states: -** -** UNLOCKED -> SHARED -** SHARED -> RESERVED -** SHARED -> (PENDING) -> EXCLUSIVE -** RESERVED -> (PENDING) -> EXCLUSIVE -** PENDING -> EXCLUSIVE -** -** This routine will only increase a lock. The os2Unlock() routine -** erases all locks at once and returns us immediately to locking level 0. -** It is not possible to lower the locking level one step at a time. You -** must go straight to locking level 0. -*/ -static int os2Lock( sqlite3_file *id, int locktype ){ - int rc = SQLITE_OK; /* Return code from subroutines */ - APIRET res = NO_ERROR; /* Result of an OS/2 lock call */ - int newLocktype; /* Set pFile->locktype to this value before exiting */ - int gotPendingLock = 0;/* True if we acquired a PENDING lock this time */ - FILELOCK LockArea, - UnlockArea; - os2File *pFile = (os2File*)id; - memset(&LockArea, 0, sizeof(LockArea)); - memset(&UnlockArea, 0, sizeof(UnlockArea)); - assert( pFile!=0 ); - OSTRACE(( "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 - ** os2File, do nothing. Don't use the end_lock: exit path, as - ** sqlite3_mutex_enter() hasn't been called yet. - */ - if( pFile->locktype>=locktype ){ - OSTRACE(( "LOCK %d %d ok (already held)\n", pFile->h, locktype )); - return SQLITE_OK; - } - - /* Make sure the locking sequence is correct - */ - assert( pFile->locktype!=NO_LOCK || locktype==SHARED_LOCK ); - assert( locktype!=PENDING_LOCK ); - assert( locktype!=RESERVED_LOCK || pFile->locktype==SHARED_LOCK ); - - /* Lock the PENDING_LOCK byte if we need to acquire a PENDING lock or - ** a SHARED lock. If we are acquiring a SHARED lock, the acquisition of - ** the PENDING_LOCK byte is temporary. - */ - newLocktype = pFile->locktype; - if( pFile->locktype==NO_LOCK - || (locktype==EXCLUSIVE_LOCK && pFile->locktype==RESERVED_LOCK) - ){ - LockArea.lOffset = PENDING_BYTE; - LockArea.lRange = 1L; - UnlockArea.lOffset = 0L; - UnlockArea.lRange = 0L; - - /* wait longer than LOCK_TIMEOUT here not to have to try multiple times */ - res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, 100L, 0L ); - if( res == NO_ERROR ){ - gotPendingLock = 1; - OSTRACE(( "LOCK %d pending lock boolean set. res=%d\n", pFile->h, res )); - } - } - - /* Acquire a shared lock - */ - if( locktype==SHARED_LOCK && res == NO_ERROR ){ - assert( pFile->locktype==NO_LOCK ); - res = getReadLock(pFile); - if( res == NO_ERROR ){ - newLocktype = SHARED_LOCK; - } - OSTRACE(( "LOCK %d acquire shared lock. res=%d\n", pFile->h, res )); - } - - /* Acquire a RESERVED lock - */ - if( locktype==RESERVED_LOCK && res == NO_ERROR ){ - assert( pFile->locktype==SHARED_LOCK ); - LockArea.lOffset = RESERVED_BYTE; - LockArea.lRange = 1L; - UnlockArea.lOffset = 0L; - UnlockArea.lRange = 0L; - res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L ); - if( res == NO_ERROR ){ - newLocktype = RESERVED_LOCK; - } - OSTRACE(( "LOCK %d acquire reserved lock. res=%d\n", pFile->h, res )); - } - - /* Acquire a PENDING lock - */ - if( locktype==EXCLUSIVE_LOCK && res == NO_ERROR ){ - newLocktype = PENDING_LOCK; - gotPendingLock = 0; - OSTRACE(( "LOCK %d acquire pending lock. pending lock boolean unset.\n", - pFile->h )); - } - - /* Acquire an EXCLUSIVE lock - */ - if( locktype==EXCLUSIVE_LOCK && res == NO_ERROR ){ - assert( pFile->locktype>=SHARED_LOCK ); - res = unlockReadLock(pFile); - OSTRACE(( "unreadlock = %d\n", res )); - LockArea.lOffset = SHARED_FIRST; - LockArea.lRange = SHARED_SIZE; - UnlockArea.lOffset = 0L; - UnlockArea.lRange = 0L; - res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L ); - if( res == NO_ERROR ){ - newLocktype = EXCLUSIVE_LOCK; - }else{ - OSTRACE(( "OS/2 error-code = %d\n", res )); - getReadLock(pFile); - } - OSTRACE(( "LOCK %d acquire exclusive lock. res=%d\n", pFile->h, res )); - } - - /* If we are holding a PENDING lock that ought to be released, then - ** release it now. - */ - if( gotPendingLock && locktype==SHARED_LOCK ){ - int r; - LockArea.lOffset = 0L; - LockArea.lRange = 0L; - UnlockArea.lOffset = PENDING_BYTE; - UnlockArea.lRange = 1L; - r = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L ); - OSTRACE(( "LOCK %d unlocking pending/is shared. r=%d\n", pFile->h, r )); - } - - /* Update the state of the lock has held in the file descriptor then - ** return the appropriate result code. - */ - if( res == NO_ERROR ){ - rc = SQLITE_OK; - }else{ - OSTRACE(( "LOCK FAILED %d trying for %d but got %d\n", pFile->h, - locktype, newLocktype )); - rc = SQLITE_BUSY; - } - pFile->locktype = newLocktype; - OSTRACE(( "LOCK %d now %d\n", pFile->h, pFile->locktype )); - return rc; -} - -/* -** This routine checks if there is a RESERVED lock held on the specified -** file by this or any other process. If such a lock is held, return -** non-zero, otherwise zero. -*/ -static int os2CheckReservedLock( sqlite3_file *id, int *pOut ){ - int r = 0; - os2File *pFile = (os2File*)id; - assert( pFile!=0 ); - if( pFile->locktype>=RESERVED_LOCK ){ - r = 1; - OSTRACE(( "TEST WR-LOCK %d %d (local)\n", pFile->h, r )); - }else{ - FILELOCK LockArea, - UnlockArea; - APIRET rc = NO_ERROR; - memset(&LockArea, 0, sizeof(LockArea)); - memset(&UnlockArea, 0, sizeof(UnlockArea)); - LockArea.lOffset = RESERVED_BYTE; - LockArea.lRange = 1L; - UnlockArea.lOffset = 0L; - UnlockArea.lRange = 0L; - rc = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L ); - OSTRACE(( "TEST WR-LOCK %d lock reserved byte rc=%d\n", pFile->h, rc )); - if( rc == NO_ERROR ){ - APIRET rcu = NO_ERROR; /* return code for unlocking */ - LockArea.lOffset = 0L; - LockArea.lRange = 0L; - UnlockArea.lOffset = RESERVED_BYTE; - UnlockArea.lRange = 1L; - rcu = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L ); - OSTRACE(( "TEST WR-LOCK %d unlock reserved byte r=%d\n", pFile->h, rcu )); - } - r = !(rc == NO_ERROR); - OSTRACE(( "TEST WR-LOCK %d %d (remote)\n", pFile->h, r )); - } - *pOut = r; - return SQLITE_OK; -} - -/* -** Lower the locking level on file descriptor id to locktype. locktype -** must be either NO_LOCK or SHARED_LOCK. -** -** If the locking level of the file descriptor is already at or below -** the requested locking level, this routine is a no-op. -** -** It is not possible for this routine to fail if the second argument -** is NO_LOCK. If the second argument is SHARED_LOCK then this routine -** might return SQLITE_IOERR; -*/ -static int os2Unlock( sqlite3_file *id, int locktype ){ - int type; - os2File *pFile = (os2File*)id; - APIRET rc = SQLITE_OK; - APIRET res = NO_ERROR; - FILELOCK LockArea, - UnlockArea; - memset(&LockArea, 0, sizeof(LockArea)); - memset(&UnlockArea, 0, sizeof(UnlockArea)); - assert( pFile!=0 ); - assert( locktype<=SHARED_LOCK ); - OSTRACE(( "UNLOCK %d to %d was %d\n", pFile->h, locktype, pFile->locktype )); - type = pFile->locktype; - if( type>=EXCLUSIVE_LOCK ){ - LockArea.lOffset = 0L; - LockArea.lRange = 0L; - UnlockArea.lOffset = SHARED_FIRST; - UnlockArea.lRange = SHARED_SIZE; - res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L ); - OSTRACE(( "UNLOCK %d exclusive lock res=%d\n", pFile->h, res )); - if( locktype==SHARED_LOCK && getReadLock(pFile) != NO_ERROR ){ - /* This should never happen. We should always be able to - ** reacquire the read lock */ - OSTRACE(( "UNLOCK %d to %d getReadLock() failed\n", pFile->h, locktype )); - rc = SQLITE_IOERR_UNLOCK; - } - } - if( type>=RESERVED_LOCK ){ - LockArea.lOffset = 0L; - LockArea.lRange = 0L; - UnlockArea.lOffset = RESERVED_BYTE; - UnlockArea.lRange = 1L; - res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L ); - OSTRACE(( "UNLOCK %d reserved res=%d\n", pFile->h, res )); - } - if( locktype==NO_LOCK && type>=SHARED_LOCK ){ - res = unlockReadLock(pFile); - OSTRACE(( "UNLOCK %d is %d want %d res=%d\n", - pFile->h, type, locktype, res )); - } - if( type>=PENDING_LOCK ){ - LockArea.lOffset = 0L; - LockArea.lRange = 0L; - UnlockArea.lOffset = PENDING_BYTE; - UnlockArea.lRange = 1L; - res = DosSetFileLocks( pFile->h, &UnlockArea, &LockArea, LOCK_TIMEOUT, 0L ); - OSTRACE(( "UNLOCK %d pending res=%d\n", pFile->h, res )); - } - pFile->locktype = locktype; - OSTRACE(( "UNLOCK %d now %d\n", pFile->h, pFile->locktype )); - return rc; -} - -/* -** Control and query of the open file handle. -*/ -static int os2FileControl(sqlite3_file *id, int op, void *pArg){ - switch( op ){ - case SQLITE_FCNTL_LOCKSTATE: { - *(int*)pArg = ((os2File*)id)->locktype; - OSTRACE(( "FCNTL_LOCKSTATE %d lock=%d\n", - ((os2File*)id)->h, ((os2File*)id)->locktype )); - return SQLITE_OK; - } - case SQLITE_FCNTL_CHUNK_SIZE: { - ((os2File*)id)->szChunk = *(int*)pArg; - return SQLITE_OK; - } - case SQLITE_FCNTL_SIZE_HINT: { - sqlite3_int64 sz = *(sqlite3_int64*)pArg; - SimulateIOErrorBenign(1); - os2Truncate(id, sz); - SimulateIOErrorBenign(0); - return SQLITE_OK; - } - case SQLITE_FCNTL_SYNC_OMITTED: { - return SQLITE_OK; - } - } - return SQLITE_NOTFOUND; -} - -/* -** Return the sector size in bytes of the underlying block device for -** the specified file. This is almost always 512 bytes, but may be -** larger for some devices. -** -** SQLite code assumes this function cannot fail. It also assumes that -** if two files are created in the same file-system directory (i.e. -** a database and its journal file) that the sector size will be the -** same for both. -*/ -static int os2SectorSize(sqlite3_file *id){ - UNUSED_PARAMETER(id); - return SQLITE_DEFAULT_SECTOR_SIZE; -} - -/* -** Return a vector of device characteristics. -*/ -static int os2DeviceCharacteristics(sqlite3_file *id){ - UNUSED_PARAMETER(id); - return SQLITE_IOCAP_UNDELETABLE_WHEN_OPEN; -} - - -/* -** Character set conversion objects used by conversion routines. -*/ -static UconvObject ucUtf8 = NULL; /* convert between UTF-8 and UCS-2 */ -static UconvObject uclCp = NULL; /* convert between local codepage and UCS-2 */ - -/* -** Helper function to initialize the conversion objects from and to UTF-8. -*/ -static void initUconvObjects( void ){ - if( UniCreateUconvObject( UTF_8, &ucUtf8 ) != ULS_SUCCESS ) - ucUtf8 = NULL; - if ( UniCreateUconvObject( (UniChar *)L"@path=yes", &uclCp ) != ULS_SUCCESS ) - uclCp = NULL; -} - -/* -** Helper function to free the conversion objects from and to UTF-8. -*/ -static void freeUconvObjects( void ){ - if ( ucUtf8 ) - UniFreeUconvObject( ucUtf8 ); - if ( uclCp ) - UniFreeUconvObject( uclCp ); - ucUtf8 = NULL; - uclCp = NULL; -} - -/* -** Helper function to convert UTF-8 filenames to local OS/2 codepage. -** The two-step process: first convert the incoming UTF-8 string -** into UCS-2 and then from UCS-2 to the current codepage. -** The returned char pointer has to be freed. -*/ -static char *convertUtf8PathToCp( const char *in ){ - UniChar tempPath[CCHMAXPATH]; - char *out = (char *)calloc( CCHMAXPATH, 1 ); - - if( !out ) - return NULL; - - if( !ucUtf8 || !uclCp ) - initUconvObjects(); - - /* determine string for the conversion of UTF-8 which is CP1208 */ - if( UniStrToUcs( ucUtf8, tempPath, (char *)in, CCHMAXPATH ) != ULS_SUCCESS ) - return out; /* if conversion fails, return the empty string */ - - /* conversion for current codepage which can be used for paths */ - UniStrFromUcs( uclCp, out, tempPath, CCHMAXPATH ); - - return out; -} - -/* -** Helper function to convert filenames from local codepage to UTF-8. -** The two-step process: first convert the incoming codepage-specific -** string into UCS-2 and then from UCS-2 to the codepage of UTF-8. -** The returned char pointer has to be freed. -** -** This function is non-static to be able to use this in shell.c and -** similar applications that take command line arguments. -*/ -char *convertCpPathToUtf8( const char *in ){ - UniChar tempPath[CCHMAXPATH]; - char *out = (char *)calloc( CCHMAXPATH, 1 ); - - if( !out ) - return NULL; - - if( !ucUtf8 || !uclCp ) - initUconvObjects(); - - /* conversion for current codepage which can be used for paths */ - if( UniStrToUcs( uclCp, tempPath, (char *)in, CCHMAXPATH ) != ULS_SUCCESS ) - return out; /* if conversion fails, return the empty string */ - - /* determine string for the conversion of UTF-8 which is CP1208 */ - UniStrFromUcs( ucUtf8, out, tempPath, CCHMAXPATH ); - - return out; -} - - -#ifndef SQLITE_OMIT_WAL - -/* -** Use main database file for interprocess locking. If un-defined -** a separate file is created for this purpose. The file will be -** used only to set file locks. There will be no data written to it. -*/ -#define SQLITE_OS2_NO_WAL_LOCK_FILE - -#if 0 -static void _ERR_TRACE( const char *fmt, ... ) { - va_list ap; - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - fflush(stderr); -} -#define ERR_TRACE(rc, msg) \ - if( (rc) != SQLITE_OK ) _ERR_TRACE msg; -#else -#define ERR_TRACE(rc, msg) -#endif - -/* -** Helper functions to obtain and relinquish the global mutex. The -** global mutex is used to protect os2ShmNodeList. -** -** Function os2ShmMutexHeld() is used to assert() that the global mutex -** is held when required. This function is only used as part of assert() -** statements. e.g. -** -** os2ShmEnterMutex() -** assert( os2ShmMutexHeld() ); -** os2ShmLeaveMutex() -*/ -static void os2ShmEnterMutex(void){ - sqlite3_mutex_enter(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); -} -static void os2ShmLeaveMutex(void){ - sqlite3_mutex_leave(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); -} -#ifdef SQLITE_DEBUG -static int os2ShmMutexHeld(void) { - return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER)); -} -int GetCurrentProcessId(void) { - PPIB pib; - DosGetInfoBlocks(NULL, &pib); - return (int)pib->pib_ulpid; -} -#endif - -/* -** Object used to represent a the shared memory area for a single log file. -** When multiple threads all reference the same log-summary, each thread has -** its own os2File object, but they all point to a single instance of this -** object. In other words, each log-summary is opened only once per process. -** -** os2ShmMutexHeld() must be true when creating or destroying -** this object or while reading or writing the following fields: -** -** nRef -** pNext -** -** The following fields are read-only after the object is created: -** -** szRegion -** hLockFile -** shmBaseName -** -** Either os2ShmNode.mutex must be held or os2ShmNode.nRef==0 and -** os2ShmMutexHeld() is true when reading or writing any other field -** in this structure. -** -*/ -struct os2ShmNode { - sqlite3_mutex *mutex; /* Mutex to access this object */ - os2ShmNode *pNext; /* Next in list of all os2ShmNode objects */ - - int szRegion; /* Size of shared-memory regions */ - - int nRegion; /* Size of array apRegion */ - void **apRegion; /* Array of pointers to shared-memory regions */ - - int nRef; /* Number of os2ShmLink objects pointing to this */ - os2ShmLink *pFirst; /* First os2ShmLink object pointing to this */ - - HFILE hLockFile; /* File used for inter-process memory locking */ - char shmBaseName[1]; /* Name of the memory object !!! must last !!! */ -}; - - -/* -** Structure used internally by this VFS to record the state of an -** open shared memory connection. -** -** The following fields are initialized when this object is created and -** are read-only thereafter: -** -** os2Shm.pShmNode -** os2Shm.id -** -** All other fields are read/write. The os2Shm.pShmNode->mutex must be held -** while accessing any read/write fields. -*/ -struct os2ShmLink { - os2ShmNode *pShmNode; /* The underlying os2ShmNode object */ - os2ShmLink *pNext; /* Next os2Shm with the same os2ShmNode */ - u32 sharedMask; /* Mask of shared locks held */ - u32 exclMask; /* Mask of exclusive locks held */ -#ifdef SQLITE_DEBUG - u8 id; /* Id of this connection with its os2ShmNode */ -#endif -}; - - -/* -** A global list of all os2ShmNode objects. -** -** The os2ShmMutexHeld() must be true while reading or writing this list. -*/ -static os2ShmNode *os2ShmNodeList = NULL; - -/* -** Constants used for locking -*/ -#ifdef SQLITE_OS2_NO_WAL_LOCK_FILE -#define OS2_SHM_BASE (PENDING_BYTE + 0x10000) /* first lock byte */ -#else -#define OS2_SHM_BASE ((22+SQLITE_SHM_NLOCK)*4) /* first lock byte */ -#endif - -#define OS2_SHM_DMS (OS2_SHM_BASE+SQLITE_SHM_NLOCK) /* deadman switch */ - -/* -** Apply advisory locks for all n bytes beginning at ofst. -*/ -#define _SHM_UNLCK 1 /* no lock */ -#define _SHM_RDLCK 2 /* shared lock, no wait */ -#define _SHM_WRLCK 3 /* exlusive lock, no wait */ -#define _SHM_WRLCK_WAIT 4 /* exclusive lock, wait */ -static int os2ShmSystemLock( - os2ShmNode *pNode, /* Apply locks to this open shared-memory segment */ - int lockType, /* _SHM_UNLCK, _SHM_RDLCK, _SHM_WRLCK or _SHM_WRLCK_WAIT */ - int ofst, /* Offset to first byte to be locked/unlocked */ - int nByte /* Number of bytes to lock or unlock */ -){ - APIRET rc; - FILELOCK area; - ULONG mode, timeout; - - /* Access to the os2ShmNode object is serialized by the caller */ - assert( sqlite3_mutex_held(pNode->mutex) || pNode->nRef==0 ); - - mode = 1; /* shared lock */ - timeout = 0; /* no wait */ - area.lOffset = ofst; - area.lRange = nByte; - - switch( lockType ) { - case _SHM_WRLCK_WAIT: - timeout = (ULONG)-1; /* wait forever */ - case _SHM_WRLCK: - mode = 0; /* exclusive lock */ - case _SHM_RDLCK: - rc = DosSetFileLocks(pNode->hLockFile, - NULL, &area, timeout, mode); - break; - /* case _SHM_UNLCK: */ - default: - rc = DosSetFileLocks(pNode->hLockFile, - &area, NULL, 0, 0); - break; - } - - OSTRACE(("SHM-LOCK %d %s %s 0x%08lx\n", - pNode->hLockFile, - rc==SQLITE_OK ? "ok" : "failed", - lockType==_SHM_UNLCK ? "Unlock" : "Lock", - rc)); - - ERR_TRACE(rc, ("os2ShmSystemLock: %d %s\n", rc, pNode->shmBaseName)) - - return ( rc == 0 ) ? SQLITE_OK : SQLITE_BUSY; -} - -/* -** Find an os2ShmNode in global list or allocate a new one, if not found. -** -** This is not a VFS shared-memory method; it is a utility function called -** by VFS shared-memory methods. -*/ -static int os2OpenSharedMemory( os2File *fd, int szRegion ) { - os2ShmLink *pLink; - os2ShmNode *pNode; - int cbShmName, rc = SQLITE_OK; - char shmName[CCHMAXPATH + 30]; -#ifndef SQLITE_OS2_NO_WAL_LOCK_FILE - ULONG action; -#endif - - /* We need some additional space at the end to append the region number */ - cbShmName = sprintf(shmName, "\\SHAREMEM\\%s", fd->zFullPathCp ); - if( cbShmName >= CCHMAXPATH-8 ) - return SQLITE_IOERR_SHMOPEN; - - /* Replace colon in file name to form a valid shared memory name */ - shmName[10+1] = '!'; - - /* Allocate link object (we free it later in case of failure) */ - pLink = sqlite3_malloc( sizeof(*pLink) ); - if( !pLink ) - return SQLITE_NOMEM; - - /* Access node list */ - os2ShmEnterMutex(); - - /* Find node by it's shared memory base name */ - for( pNode = os2ShmNodeList; - pNode && stricmp(shmName, pNode->shmBaseName) != 0; - pNode = pNode->pNext ) ; - - /* Not found: allocate a new node */ - if( !pNode ) { - pNode = sqlite3_malloc( sizeof(*pNode) + cbShmName ); - if( pNode ) { - memset(pNode, 0, sizeof(*pNode) ); - pNode->szRegion = szRegion; - pNode->hLockFile = (HFILE)-1; - strcpy(pNode->shmBaseName, shmName); - -#ifdef SQLITE_OS2_NO_WAL_LOCK_FILE - if( DosDupHandle(fd->h, &pNode->hLockFile) != 0 ) { -#else - sprintf(shmName, "%s-lck", fd->zFullPathCp); - if( DosOpen((PSZ)shmName, &pNode->hLockFile, &action, 0, FILE_NORMAL, - OPEN_ACTION_OPEN_IF_EXISTS | OPEN_ACTION_CREATE_IF_NEW, - OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | - OPEN_FLAGS_NOINHERIT | OPEN_FLAGS_FAIL_ON_ERROR, - NULL) != 0 ) { -#endif - sqlite3_free(pNode); - rc = SQLITE_IOERR; - } else { - pNode->mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_FAST); - if( !pNode->mutex ) { - sqlite3_free(pNode); - rc = SQLITE_NOMEM; - } - } - } else { - rc = SQLITE_NOMEM; - } - - if( rc == SQLITE_OK ) { - pNode->pNext = os2ShmNodeList; - os2ShmNodeList = pNode; - } else { - pNode = NULL; - } - } else if( pNode->szRegion != szRegion ) { - rc = SQLITE_IOERR_SHMSIZE; - pNode = NULL; - } - - if( pNode ) { - sqlite3_mutex_enter(pNode->mutex); - - memset(pLink, 0, sizeof(*pLink)); - - pLink->pShmNode = pNode; - pLink->pNext = pNode->pFirst; - pNode->pFirst = pLink; - pNode->nRef++; - - fd->pShmLink = pLink; - - sqlite3_mutex_leave(pNode->mutex); - - } else { - /* Error occured. Free our link object. */ - sqlite3_free(pLink); - } - - os2ShmLeaveMutex(); - - ERR_TRACE(rc, ("os2OpenSharedMemory: %d %s\n", rc, fd->zFullPathCp)) - - return rc; -} - -/* -** Purge the os2ShmNodeList list of all entries with nRef==0. -** -** This is not a VFS shared-memory method; it is a utility function called -** by VFS shared-memory methods. -*/ -static void os2PurgeShmNodes( int deleteFlag ) { - os2ShmNode *pNode; - os2ShmNode **ppNode; - - os2ShmEnterMutex(); - - ppNode = &os2ShmNodeList; - - while( *ppNode ) { - pNode = *ppNode; - - if( pNode->nRef == 0 ) { - *ppNode = pNode->pNext; - - if( pNode->apRegion ) { - /* Prevent other processes from resizing the shared memory */ - os2ShmSystemLock(pNode, _SHM_WRLCK_WAIT, OS2_SHM_DMS, 1); - - while( pNode->nRegion-- ) { -#ifdef SQLITE_DEBUG - int rc = -#endif - DosFreeMem(pNode->apRegion[pNode->nRegion]); - - OSTRACE(("SHM-PURGE pid-%d unmap region=%d %s\n", - (int)GetCurrentProcessId(), pNode->nRegion, - rc == 0 ? "ok" : "failed")); - } - - /* Allow other processes to resize the shared memory */ - os2ShmSystemLock(pNode, _SHM_UNLCK, OS2_SHM_DMS, 1); - - sqlite3_free(pNode->apRegion); - } - - DosClose(pNode->hLockFile); - -#ifndef SQLITE_OS2_NO_WAL_LOCK_FILE - if( deleteFlag ) { - char fileName[CCHMAXPATH]; - /* Skip "\\SHAREMEM\\" */ - sprintf(fileName, "%s-lck", pNode->shmBaseName + 10); - /* restore colon */ - fileName[1] = ':'; - - DosForceDelete(fileName); - } -#endif - - sqlite3_mutex_free(pNode->mutex); - - sqlite3_free(pNode); - - } else { - ppNode = &pNode->pNext; - } - } - - os2ShmLeaveMutex(); -} - -/* -** This function is called to obtain a pointer to region iRegion of the -** shared-memory associated with the database file id. Shared-memory regions -** are numbered starting from zero. Each shared-memory region is szRegion -** bytes in size. -** -** If an error occurs, an error code is returned and *pp is set to NULL. -** -** Otherwise, if the bExtend parameter is 0 and the requested shared-memory -** region has not been allocated (by any client, including one running in a -** separate process), then *pp is set to NULL and SQLITE_OK returned. If -** bExtend is non-zero and the requested shared-memory region has not yet -** been allocated, it is allocated by this function. -** -** If the shared-memory region has already been allocated or is allocated by -** this call as described above, then it is mapped into this processes -** address space (if it is not already), *pp is set to point to the mapped -** memory and SQLITE_OK returned. -*/ -static int os2ShmMap( - sqlite3_file *id, /* Handle open on database file */ - int iRegion, /* Region to retrieve */ - int szRegion, /* Size of regions */ - int bExtend, /* True to extend block if necessary */ - void volatile **pp /* OUT: Mapped memory */ -){ - PVOID pvTemp; - void **apRegion; - os2ShmNode *pNode; - int n, rc = SQLITE_OK; - char shmName[CCHMAXPATH]; - os2File *pFile = (os2File*)id; - - *pp = NULL; - - if( !pFile->pShmLink ) - rc = os2OpenSharedMemory( pFile, szRegion ); - - if( rc == SQLITE_OK ) { - pNode = pFile->pShmLink->pShmNode ; - - sqlite3_mutex_enter(pNode->mutex); - - assert( szRegion==pNode->szRegion ); - - /* Unmapped region ? */ - if( iRegion >= pNode->nRegion ) { - /* Prevent other processes from resizing the shared memory */ - os2ShmSystemLock(pNode, _SHM_WRLCK_WAIT, OS2_SHM_DMS, 1); - - apRegion = sqlite3_realloc( - pNode->apRegion, (iRegion + 1) * sizeof(apRegion[0])); - - if( apRegion ) { - pNode->apRegion = apRegion; - - while( pNode->nRegion <= iRegion ) { - sprintf(shmName, "%s-%u", - pNode->shmBaseName, pNode->nRegion); - - if( DosGetNamedSharedMem(&pvTemp, (PSZ)shmName, - PAG_READ | PAG_WRITE) != NO_ERROR ) { - if( !bExtend ) - break; - - if( DosAllocSharedMem(&pvTemp, (PSZ)shmName, szRegion, - PAG_READ | PAG_WRITE | PAG_COMMIT | OBJ_ANY) != NO_ERROR && - DosAllocSharedMem(&pvTemp, (PSZ)shmName, szRegion, - PAG_READ | PAG_WRITE | PAG_COMMIT) != NO_ERROR ) { - rc = SQLITE_NOMEM; - break; - } - } - - apRegion[pNode->nRegion++] = pvTemp; - } - - /* zero out remaining entries */ - for( n = pNode->nRegion; n <= iRegion; n++ ) - pNode->apRegion[n] = NULL; - - /* Return this region (maybe zero) */ - *pp = pNode->apRegion[iRegion]; - } else { - rc = SQLITE_NOMEM; - } - - /* Allow other processes to resize the shared memory */ - os2ShmSystemLock(pNode, _SHM_UNLCK, OS2_SHM_DMS, 1); - - } else { - /* Region has been mapped previously */ - *pp = pNode->apRegion[iRegion]; - } - - sqlite3_mutex_leave(pNode->mutex); - } - - ERR_TRACE(rc, ("os2ShmMap: %s iRgn = %d, szRgn = %d, bExt = %d : %d\n", - pFile->zFullPathCp, iRegion, szRegion, bExtend, rc)) - - return rc; -} - -/* -** Close a connection to shared-memory. Delete the underlying -** storage if deleteFlag is true. -** -** If there is no shared memory associated with the connection then this -** routine is a harmless no-op. -*/ -static int os2ShmUnmap( - sqlite3_file *id, /* The underlying database file */ - int deleteFlag /* Delete shared-memory if true */ -){ - os2File *pFile = (os2File*)id; - os2ShmLink *pLink = pFile->pShmLink; - - if( pLink ) { - int nRef = -1; - os2ShmLink **ppLink; - os2ShmNode *pNode = pLink->pShmNode; - - sqlite3_mutex_enter(pNode->mutex); - - for( ppLink = &pNode->pFirst; - *ppLink && *ppLink != pLink; - ppLink = &(*ppLink)->pNext ) ; - - assert(*ppLink); - - if( *ppLink ) { - *ppLink = pLink->pNext; - nRef = --pNode->nRef; - } else { - ERR_TRACE(1, ("os2ShmUnmap: link not found ! %s\n", - pNode->shmBaseName)) - } - - pFile->pShmLink = NULL; - sqlite3_free(pLink); - - sqlite3_mutex_leave(pNode->mutex); - - if( nRef == 0 ) - os2PurgeShmNodes( deleteFlag ); - } - - return SQLITE_OK; -} - -/* -** Change the lock state for a shared-memory segment. -** -** Note that the relationship between SHAREd and EXCLUSIVE locks is a little -** different here than in posix. In xShmLock(), one can go from unlocked -** to shared and back or from unlocked to exclusive and back. But one may -** not go from shared to exclusive or from exclusive to shared. -*/ -static int os2ShmLock( - sqlite3_file *id, /* Database file holding the shared memory */ - int ofst, /* First lock to acquire or release */ - int n, /* Number of locks to acquire or release */ - int flags /* What to do with the lock */ -){ - u32 mask; /* Mask of locks to take or release */ - int rc = SQLITE_OK; /* Result code */ - os2File *pFile = (os2File*)id; - os2ShmLink *p = pFile->pShmLink; /* The shared memory being locked */ - os2ShmLink *pX; /* For looping over all siblings */ - os2ShmNode *pShmNode = p->pShmNode; /* Our node */ - - assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK ); - assert( n>=1 ); - assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED) - || flags==(SQLITE_SHM_LOCK | SQLITE_SHM_EXCLUSIVE) - || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_SHARED) - || flags==(SQLITE_SHM_UNLOCK | SQLITE_SHM_EXCLUSIVE) ); - assert( n==1 || (flags & SQLITE_SHM_EXCLUSIVE)!=0 ); - - mask = (u32)((1U<<(ofst+n)) - (1U<1 || mask==(1<mutex); - - if( flags & SQLITE_SHM_UNLOCK ){ - u32 allMask = 0; /* Mask of locks held by siblings */ - - /* See if any siblings hold this same lock */ - for(pX=pShmNode->pFirst; pX; pX=pX->pNext){ - if( pX==p ) continue; - assert( (pX->exclMask & (p->exclMask|p->sharedMask))==0 ); - allMask |= pX->sharedMask; - } - - /* Unlock the system-level locks */ - if( (mask & allMask)==0 ){ - rc = os2ShmSystemLock(pShmNode, _SHM_UNLCK, ofst+OS2_SHM_BASE, n); - }else{ - rc = SQLITE_OK; - } - - /* Undo the local locks */ - if( rc==SQLITE_OK ){ - p->exclMask &= ~mask; - p->sharedMask &= ~mask; - } - }else if( flags & SQLITE_SHM_SHARED ){ - u32 allShared = 0; /* Union of locks held by connections other than "p" */ - - /* Find out which shared locks are already held by sibling connections. - ** If any sibling already holds an exclusive lock, go ahead and return - ** SQLITE_BUSY. - */ - for(pX=pShmNode->pFirst; pX; pX=pX->pNext){ - if( (pX->exclMask & mask)!=0 ){ - rc = SQLITE_BUSY; - break; - } - allShared |= pX->sharedMask; - } - - /* Get shared locks at the system level, if necessary */ - if( rc==SQLITE_OK ){ - if( (allShared & mask)==0 ){ - rc = os2ShmSystemLock(pShmNode, _SHM_RDLCK, ofst+OS2_SHM_BASE, n); - }else{ - rc = SQLITE_OK; - } - } - - /* Get the local shared locks */ - if( rc==SQLITE_OK ){ - p->sharedMask |= mask; - } - }else{ - /* Make sure no sibling connections hold locks that will block this - ** lock. If any do, return SQLITE_BUSY right away. - */ - for(pX=pShmNode->pFirst; pX; pX=pX->pNext){ - if( (pX->exclMask & mask)!=0 || (pX->sharedMask & mask)!=0 ){ - rc = SQLITE_BUSY; - break; - } - } - - /* Get the exclusive locks at the system level. Then if successful - ** also mark the local connection as being locked. - */ - if( rc==SQLITE_OK ){ - rc = os2ShmSystemLock(pShmNode, _SHM_WRLCK, ofst+OS2_SHM_BASE, n); - if( rc==SQLITE_OK ){ - assert( (p->sharedMask & mask)==0 ); - p->exclMask |= mask; - } - } - } - - sqlite3_mutex_leave(pShmNode->mutex); - - OSTRACE(("SHM-LOCK shmid-%d, pid-%d got %03x,%03x %s\n", - p->id, (int)GetCurrentProcessId(), p->sharedMask, p->exclMask, - rc ? "failed" : "ok")); - - ERR_TRACE(rc, ("os2ShmLock: ofst = %d, n = %d, flags = 0x%x -> %d \n", - ofst, n, flags, rc)) - - return rc; -} - -/* -** Implement a memory barrier or memory fence on shared memory. -** -** All loads and stores begun before the barrier must complete before -** any load or store begun after the barrier. -*/ -static void os2ShmBarrier( - sqlite3_file *id /* Database file holding the shared memory */ -){ - UNUSED_PARAMETER(id); - os2ShmEnterMutex(); - os2ShmLeaveMutex(); -} - -#else -# define os2ShmMap 0 -# define os2ShmLock 0 -# define os2ShmBarrier 0 -# define os2ShmUnmap 0 -#endif /* #ifndef SQLITE_OMIT_WAL */ - - -/* -** This vector defines all the methods that can operate on an -** sqlite3_file for os2. -*/ -static const sqlite3_io_methods os2IoMethod = { - 2, /* iVersion */ - os2Close, /* xClose */ - os2Read, /* xRead */ - os2Write, /* xWrite */ - os2Truncate, /* xTruncate */ - os2Sync, /* xSync */ - os2FileSize, /* xFileSize */ - os2Lock, /* xLock */ - os2Unlock, /* xUnlock */ - os2CheckReservedLock, /* xCheckReservedLock */ - os2FileControl, /* xFileControl */ - os2SectorSize, /* xSectorSize */ - os2DeviceCharacteristics, /* xDeviceCharacteristics */ - os2ShmMap, /* xShmMap */ - os2ShmLock, /* xShmLock */ - os2ShmBarrier, /* xShmBarrier */ - os2ShmUnmap /* xShmUnmap */ -}; - - -/*************************************************************************** -** Here ends the I/O methods that form the sqlite3_io_methods object. -** -** The next block of code implements the VFS methods. -****************************************************************************/ - -/* -** Create a temporary file name in zBuf. zBuf must be big enough to -** hold at pVfs->mxPathname characters. -*/ -static int getTempname(int nBuf, char *zBuf ){ - static const char zChars[] = - "abcdefghijklmnopqrstuvwxyz" - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "0123456789"; - int i, j; - PSZ zTempPathCp; - char zTempPath[CCHMAXPATH]; - ULONG ulDriveNum, ulDriveMap; - - /* It's odd to simulate an io-error here, but really this is just - ** using the io-error infrastructure to test that SQLite handles this - ** function failing. - */ - SimulateIOError( return SQLITE_IOERR ); - - if( sqlite3_temp_directory ) { - sqlite3_snprintf(CCHMAXPATH-30, zTempPath, "%s", sqlite3_temp_directory); - } else if( DosScanEnv( (PSZ)"TEMP", &zTempPathCp ) == NO_ERROR || - DosScanEnv( (PSZ)"TMP", &zTempPathCp ) == NO_ERROR || - DosScanEnv( (PSZ)"TMPDIR", &zTempPathCp ) == NO_ERROR ) { - char *zTempPathUTF = convertCpPathToUtf8( (char *)zTempPathCp ); - sqlite3_snprintf(CCHMAXPATH-30, zTempPath, "%s", zTempPathUTF); - free( zTempPathUTF ); - } else if( DosQueryCurrentDisk( &ulDriveNum, &ulDriveMap ) == NO_ERROR ) { - zTempPath[0] = (char)('A' + ulDriveNum - 1); - zTempPath[1] = ':'; - zTempPath[2] = '\0'; - } else { - zTempPath[0] = '\0'; - } - - /* Strip off a trailing slashes or backslashes, otherwise we would get * - * multiple (back)slashes which causes DosOpen() to fail. * - * Trailing spaces are not allowed, either. */ - j = sqlite3Strlen30(zTempPath); - while( j > 0 && ( zTempPath[j-1] == '\\' || zTempPath[j-1] == '/' || - zTempPath[j-1] == ' ' ) ){ - j--; - } - zTempPath[j] = '\0'; - - /* We use 20 bytes to randomize the name */ - sqlite3_snprintf(nBuf-22, zBuf, - "%s\\"SQLITE_TEMP_FILE_PREFIX, zTempPath); - j = sqlite3Strlen30(zBuf); - sqlite3_randomness( 20, &zBuf[j] ); - for( i = 0; i < 20; i++, j++ ){ - zBuf[j] = zChars[ ((unsigned char)zBuf[j])%(sizeof(zChars)-1) ]; - } - zBuf[j] = 0; - - OSTRACE(( "TEMP FILENAME: %s\n", zBuf )); - return SQLITE_OK; -} - - -/* -** Turn a relative pathname into a full pathname. Write the full -** pathname into zFull[]. zFull[] will be at least pVfs->mxPathname -** bytes in size. -*/ -static int os2FullPathname( - sqlite3_vfs *pVfs, /* Pointer to vfs object */ - const char *zRelative, /* Possibly relative input path */ - int nFull, /* Size of output buffer in bytes */ - char *zFull /* Output buffer */ -){ - char *zRelativeCp = convertUtf8PathToCp( zRelative ); - char zFullCp[CCHMAXPATH] = "\0"; - char *zFullUTF; - APIRET rc = DosQueryPathInfo( (PSZ)zRelativeCp, FIL_QUERYFULLNAME, - zFullCp, CCHMAXPATH ); - free( zRelativeCp ); - zFullUTF = convertCpPathToUtf8( zFullCp ); - sqlite3_snprintf( nFull, zFull, zFullUTF ); - free( zFullUTF ); - return rc == NO_ERROR ? SQLITE_OK : SQLITE_IOERR; -} - - -/* -** Open a file. -*/ -static int os2Open( - sqlite3_vfs *pVfs, /* Not used */ - const char *zName, /* Name of the file (UTF-8) */ - sqlite3_file *id, /* Write the SQLite file handle here */ - int flags, /* Open mode flags */ - int *pOutFlags /* Status return flags */ -){ - HFILE h; - ULONG ulOpenFlags = 0; - ULONG ulOpenMode = 0; - ULONG ulAction = 0; - ULONG rc; - os2File *pFile = (os2File*)id; - const char *zUtf8Name = zName; - char *zNameCp; - char zTmpname[CCHMAXPATH]; - - int isExclusive = (flags & SQLITE_OPEN_EXCLUSIVE); - int isCreate = (flags & SQLITE_OPEN_CREATE); - int isReadWrite = (flags & SQLITE_OPEN_READWRITE); -#ifndef NDEBUG - int isDelete = (flags & SQLITE_OPEN_DELETEONCLOSE); - int isReadonly = (flags & SQLITE_OPEN_READONLY); - int eType = (flags & 0xFFFFFF00); - int isOpenJournal = (isCreate && ( - eType==SQLITE_OPEN_MASTER_JOURNAL - || eType==SQLITE_OPEN_MAIN_JOURNAL - || eType==SQLITE_OPEN_WAL - )); -#endif - - UNUSED_PARAMETER(pVfs); - assert( id!=0 ); - - /* Check the following statements are true: - ** - ** (a) Exactly one of the READWRITE and READONLY flags must be set, and - ** (b) if CREATE is set, then READWRITE must also be set, and - ** (c) if EXCLUSIVE is set, then CREATE must also be set. - ** (d) if DELETEONCLOSE is set, then CREATE must also be set. - */ - assert((isReadonly==0 || isReadWrite==0) && (isReadWrite || isReadonly)); - assert(isCreate==0 || isReadWrite); - assert(isExclusive==0 || isCreate); - assert(isDelete==0 || isCreate); - - /* The main DB, main journal, WAL file and master journal are never - ** automatically deleted. Nor are they ever temporary files. */ - assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_DB ); - assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MAIN_JOURNAL ); - assert( (!isDelete && zName) || eType!=SQLITE_OPEN_MASTER_JOURNAL ); - assert( (!isDelete && zName) || eType!=SQLITE_OPEN_WAL ); - - /* Assert that the upper layer has set one of the "file-type" flags. */ - assert( eType==SQLITE_OPEN_MAIN_DB || eType==SQLITE_OPEN_TEMP_DB - || eType==SQLITE_OPEN_MAIN_JOURNAL || eType==SQLITE_OPEN_TEMP_JOURNAL - || eType==SQLITE_OPEN_SUBJOURNAL || eType==SQLITE_OPEN_MASTER_JOURNAL - || eType==SQLITE_OPEN_TRANSIENT_DB || eType==SQLITE_OPEN_WAL - ); - - memset( pFile, 0, sizeof(*pFile) ); - pFile->h = (HFILE)-1; - - /* If the second argument to this function is NULL, generate a - ** temporary file name to use - */ - if( !zUtf8Name ){ - assert(isDelete && !isOpenJournal); - rc = getTempname(CCHMAXPATH, zTmpname); - if( rc!=SQLITE_OK ){ - return rc; - } - zUtf8Name = zTmpname; - } - - if( isReadWrite ){ - ulOpenMode |= OPEN_ACCESS_READWRITE; - }else{ - ulOpenMode |= OPEN_ACCESS_READONLY; - } - - /* Open in random access mode for possibly better speed. Allow full - ** sharing because file locks will provide exclusive access when needed. - ** The handle should not be inherited by child processes and we don't - ** want popups from the critical error handler. - */ - ulOpenMode |= OPEN_FLAGS_RANDOM | OPEN_SHARE_DENYNONE | - OPEN_FLAGS_NOINHERIT | OPEN_FLAGS_FAIL_ON_ERROR; - - /* SQLITE_OPEN_EXCLUSIVE is used to make sure that a new file is - ** created. SQLite doesn't use it to indicate "exclusive access" - ** as it is usually understood. - */ - if( isExclusive ){ - /* Creates a new file, only if it does not already exist. */ - /* If the file exists, it fails. */ - ulOpenFlags |= OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_FAIL_IF_EXISTS; - }else if( isCreate ){ - /* Open existing file, or create if it doesn't exist */ - ulOpenFlags |= OPEN_ACTION_CREATE_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; - }else{ - /* Opens a file, only if it exists. */ - ulOpenFlags |= OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS; - } - - zNameCp = convertUtf8PathToCp( zUtf8Name ); - rc = DosOpen( (PSZ)zNameCp, - &h, - &ulAction, - 0L, - FILE_NORMAL, - ulOpenFlags, - ulOpenMode, - (PEAOP2)NULL ); - free( zNameCp ); - - if( rc != NO_ERROR ){ - OSTRACE(( "OPEN Invalid handle rc=%d: zName=%s, ulAction=%#lx, ulFlags=%#lx, ulMode=%#lx\n", - rc, zUtf8Name, ulAction, ulOpenFlags, ulOpenMode )); - - if( isReadWrite ){ - return os2Open( pVfs, zName, id, - ((flags|SQLITE_OPEN_READONLY)&~(SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE)), - pOutFlags ); - }else{ - return SQLITE_CANTOPEN; - } - } - - if( pOutFlags ){ - *pOutFlags = isReadWrite ? SQLITE_OPEN_READWRITE : SQLITE_OPEN_READONLY; - } - - os2FullPathname( pVfs, zUtf8Name, sizeof( zTmpname ), zTmpname ); - pFile->zFullPathCp = convertUtf8PathToCp( zTmpname ); - pFile->pMethod = &os2IoMethod; - pFile->flags = flags; - pFile->h = h; - - OpenCounter(+1); - OSTRACE(( "OPEN %d pOutFlags=%d\n", pFile->h, pOutFlags )); - return SQLITE_OK; -} - -/* -** Delete the named file. -*/ -static int os2Delete( - sqlite3_vfs *pVfs, /* Not used on os2 */ - const char *zFilename, /* Name of file to delete */ - int syncDir /* Not used on os2 */ -){ - APIRET rc; - char *zFilenameCp; - SimulateIOError( return SQLITE_IOERR_DELETE ); - zFilenameCp = convertUtf8PathToCp( zFilename ); - rc = DosDelete( (PSZ)zFilenameCp ); - free( zFilenameCp ); - OSTRACE(( "DELETE \"%s\"\n", zFilename )); - return (rc == NO_ERROR || - rc == ERROR_FILE_NOT_FOUND || - rc == ERROR_PATH_NOT_FOUND ) ? SQLITE_OK : SQLITE_IOERR_DELETE; -} - -/* -** Check the existance and status of a file. -*/ -static int os2Access( - sqlite3_vfs *pVfs, /* Not used on os2 */ - const char *zFilename, /* Name of file to check */ - int flags, /* Type of test to make on this file */ - int *pOut /* Write results here */ -){ - APIRET rc; - FILESTATUS3 fsts3ConfigInfo; - char *zFilenameCp; - - UNUSED_PARAMETER(pVfs); - SimulateIOError( return SQLITE_IOERR_ACCESS; ); - - zFilenameCp = convertUtf8PathToCp( zFilename ); - rc = DosQueryPathInfo( (PSZ)zFilenameCp, FIL_STANDARD, - &fsts3ConfigInfo, sizeof(FILESTATUS3) ); - free( zFilenameCp ); - OSTRACE(( "ACCESS fsts3ConfigInfo.attrFile=%d flags=%d rc=%d\n", - fsts3ConfigInfo.attrFile, flags, rc )); - - switch( flags ){ - case SQLITE_ACCESS_EXISTS: - /* For an SQLITE_ACCESS_EXISTS query, treat a zero-length file - ** as if it does not exist. - */ - if( fsts3ConfigInfo.cbFile == 0 ) - rc = ERROR_FILE_NOT_FOUND; - break; - case SQLITE_ACCESS_READ: - break; - case SQLITE_ACCESS_READWRITE: - if( fsts3ConfigInfo.attrFile & FILE_READONLY ) - rc = ERROR_ACCESS_DENIED; - break; - default: - rc = ERROR_FILE_NOT_FOUND; - assert( !"Invalid flags argument" ); - } - - *pOut = (rc == NO_ERROR); - OSTRACE(( "ACCESS %s flags %d: rc=%d\n", zFilename, flags, *pOut )); - - return SQLITE_OK; -} - - -#ifndef SQLITE_OMIT_LOAD_EXTENSION -/* -** Interfaces for opening a shared library, finding entry points -** within the shared library, and closing the shared library. -*/ -/* -** Interfaces for opening a shared library, finding entry points -** within the shared library, and closing the shared library. -*/ -static void *os2DlOpen(sqlite3_vfs *pVfs, const char *zFilename){ - HMODULE hmod; - APIRET rc; - char *zFilenameCp = convertUtf8PathToCp(zFilename); - rc = DosLoadModule(NULL, 0, (PSZ)zFilenameCp, &hmod); - free(zFilenameCp); - return rc != NO_ERROR ? 0 : (void*)hmod; -} -/* -** A no-op since the error code is returned on the DosLoadModule call. -** os2Dlopen returns zero if DosLoadModule is not successful. -*/ -static void os2DlError(sqlite3_vfs *pVfs, int nBuf, char *zBufOut){ -/* no-op */ -} -static void (*os2DlSym(sqlite3_vfs *pVfs, void *pHandle, const char *zSymbol))(void){ - PFN pfn; - APIRET rc; - rc = DosQueryProcAddr((HMODULE)pHandle, 0L, (PSZ)zSymbol, &pfn); - if( rc != NO_ERROR ){ - /* if the symbol itself was not found, search again for the same - * symbol with an extra underscore, that might be needed depending - * on the calling convention */ - char _zSymbol[256] = "_"; - strncat(_zSymbol, zSymbol, 254); - rc = DosQueryProcAddr((HMODULE)pHandle, 0L, (PSZ)_zSymbol, &pfn); - } - return rc != NO_ERROR ? 0 : (void(*)(void))pfn; -} -static void os2DlClose(sqlite3_vfs *pVfs, void *pHandle){ - DosFreeModule((HMODULE)pHandle); -} -#else /* if SQLITE_OMIT_LOAD_EXTENSION is defined: */ - #define os2DlOpen 0 - #define os2DlError 0 - #define os2DlSym 0 - #define os2DlClose 0 -#endif - - -/* -** Write up to nBuf bytes of randomness into zBuf. -*/ -static int os2Randomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf ){ - int n = 0; -#if defined(SQLITE_TEST) - n = nBuf; - memset(zBuf, 0, nBuf); -#else - int i; - PPIB ppib; - PTIB ptib; - DATETIME dt; - static unsigned c = 0; - /* Ordered by variation probability */ - static ULONG svIdx[6] = { QSV_MS_COUNT, QSV_TIME_LOW, - QSV_MAXPRMEM, QSV_MAXSHMEM, - QSV_TOTAVAILMEM, QSV_TOTRESMEM }; - - /* 8 bytes; timezone and weekday don't increase the randomness much */ - if( (int)sizeof(dt)-3 <= nBuf - n ){ - c += 0x0100; - DosGetDateTime(&dt); - dt.year = (USHORT)((dt.year - 1900) | c); - memcpy(&zBuf[n], &dt, sizeof(dt)-3); - n += sizeof(dt)-3; - } - - /* 4 bytes; PIDs and TIDs are 16 bit internally, so combine them */ - if( (int)sizeof(ULONG) <= nBuf - n ){ - DosGetInfoBlocks(&ptib, &ppib); - *(PULONG)&zBuf[n] = MAKELONG(ppib->pib_ulpid, - ptib->tib_ptib2->tib2_ultid); - n += sizeof(ULONG); - } - - /* Up to 6 * 4 bytes; variables depend on the system state */ - for( i = 0; i < 6 && (int)sizeof(ULONG) <= nBuf - n; i++ ){ - DosQuerySysInfo(svIdx[i], svIdx[i], - (PULONG)&zBuf[n], sizeof(ULONG)); - n += sizeof(ULONG); - } -#endif - - return n; -} - -/* -** Sleep for a little while. Return the amount of time slept. -** The argument is the number of microseconds we want to sleep. -** The return value is the number of microseconds of sleep actually -** requested from the underlying operating system, a number which -** might be greater than or equal to the argument, but not less -** than the argument. -*/ -static int os2Sleep( sqlite3_vfs *pVfs, int microsec ){ - DosSleep( (microsec/1000) ); - return microsec; -} - -/* -** The following variable, if set to a non-zero value, becomes the result -** returned from sqlite3OsCurrentTime(). This is used for testing. -*/ -#ifdef SQLITE_TEST -int sqlite3_current_time = 0; -#endif - -/* -** Find the current time (in Universal Coordinated Time). Write into *piNow -** the current time and date as a Julian Day number times 86_400_000. In -** other words, write into *piNow the number of milliseconds since the Julian -** epoch of noon in Greenwich on November 24, 4714 B.C according to the -** proleptic Gregorian calendar. -** -** On success, return 0. Return 1 if the time and date cannot be found. -*/ -static int os2CurrentTimeInt64(sqlite3_vfs *pVfs, sqlite3_int64 *piNow){ -#ifdef SQLITE_TEST - static const sqlite3_int64 unixEpoch = 24405875*(sqlite3_int64)8640000; -#endif - int year, month, datepart, timepart; - - DATETIME dt; - DosGetDateTime( &dt ); - - year = dt.year; - month = dt.month; - - /* Calculations from http://www.astro.keele.ac.uk/~rno/Astronomy/hjd.html - ** http://www.astro.keele.ac.uk/~rno/Astronomy/hjd-0.1.c - ** Calculate the Julian days - */ - datepart = (int)dt.day - 32076 + - 1461*(year + 4800 + (month - 14)/12)/4 + - 367*(month - 2 - (month - 14)/12*12)/12 - - 3*((year + 4900 + (month - 14)/12)/100)/4; - - /* Time in milliseconds, hours to noon added */ - timepart = 12*3600*1000 + dt.hundredths*10 + dt.seconds*1000 + - ((int)dt.minutes + dt.timezone)*60*1000 + dt.hours*3600*1000; - - *piNow = (sqlite3_int64)datepart*86400*1000 + timepart; - -#ifdef SQLITE_TEST - if( sqlite3_current_time ){ - *piNow = 1000*(sqlite3_int64)sqlite3_current_time + unixEpoch; - } -#endif - - UNUSED_PARAMETER(pVfs); - return 0; -} - -/* -** Find the current time (in Universal Coordinated Time). Write the -** current time and date as a Julian Day number into *prNow and -** return 0. Return 1 if the time and date cannot be found. -*/ -static int os2CurrentTime( sqlite3_vfs *pVfs, double *prNow ){ - int rc; - sqlite3_int64 i; - rc = os2CurrentTimeInt64(pVfs, &i); - if( !rc ){ - *prNow = i/86400000.0; - } - return rc; -} - -/* -** The idea is that this function works like a combination of -** GetLastError() and FormatMessage() on windows (or errno and -** strerror_r() on unix). After an error is returned by an OS -** function, SQLite calls this function with zBuf pointing to -** a buffer of nBuf bytes. The OS layer should populate the -** buffer with a nul-terminated UTF-8 encoded error message -** describing the last IO error to have occurred within the calling -** thread. -** -** If the error message is too large for the supplied buffer, -** it should be truncated. The return value of xGetLastError -** is zero if the error message fits in the buffer, or non-zero -** otherwise (if the message was truncated). If non-zero is returned, -** then it is not necessary to include the nul-terminator character -** in the output buffer. -** -** Not supplying an error message will have no adverse effect -** on SQLite. It is fine to have an implementation that never -** returns an error message: -** -** int xGetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ -** assert(zBuf[0]=='\0'); -** return 0; -** } -** -** However if an error message is supplied, it will be incorporated -** by sqlite into the error message available to the user using -** sqlite3_errmsg(), possibly making IO errors easier to debug. -*/ -static int os2GetLastError(sqlite3_vfs *pVfs, int nBuf, char *zBuf){ - assert(zBuf[0]=='\0'); - return 0; -} - -/* -** Initialize and deinitialize the operating system interface. -*/ -int sqlite3_os_init(void){ - static sqlite3_vfs os2Vfs = { - 3, /* iVersion */ - sizeof(os2File), /* szOsFile */ - CCHMAXPATH, /* mxPathname */ - 0, /* pNext */ - "os2", /* zName */ - 0, /* pAppData */ - - os2Open, /* xOpen */ - os2Delete, /* xDelete */ - os2Access, /* xAccess */ - os2FullPathname, /* xFullPathname */ - os2DlOpen, /* xDlOpen */ - os2DlError, /* xDlError */ - os2DlSym, /* xDlSym */ - os2DlClose, /* xDlClose */ - os2Randomness, /* xRandomness */ - os2Sleep, /* xSleep */ - os2CurrentTime, /* xCurrentTime */ - os2GetLastError, /* xGetLastError */ - os2CurrentTimeInt64, /* xCurrentTimeInt64 */ - 0, /* xSetSystemCall */ - 0, /* xGetSystemCall */ - 0 /* xNextSystemCall */ - }; - sqlite3_vfs_register(&os2Vfs, 1); - initUconvObjects(); -/* sqlite3OSTrace = 1; */ - return SQLITE_OK; -} -int sqlite3_os_end(void){ - freeUconvObjects(); - return SQLITE_OK; -} - -#endif /* SQLITE_OS_OS2 */ diff --git a/src/shell.c b/src/shell.c index 801ad2ca27..d2cefbd452 100644 --- a/src/shell.c +++ b/src/shell.c @@ -36,7 +36,7 @@ #include #include -#if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) +#if !defined(_WIN32) && !defined(WIN32) # include # if !defined(__RTP__) && !defined(_WRS_KERNEL) # include @@ -45,10 +45,6 @@ # include #endif -#ifdef __OS2__ -# include -#endif - #ifdef HAVE_EDITLINE # include #endif @@ -92,7 +88,7 @@ static int enableTimer = 0; #define IsDigit(X) isdigit((unsigned char)X) #define ToLower(X) (char)tolower((unsigned char)X) -#if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) && !defined(__RTP__) && !defined(_WRS_KERNEL) +#if !defined(_WIN32) && !defined(WIN32) && !defined(_WRS_KERNEL) #include #include @@ -2696,7 +2692,7 @@ static char *find_home_dir(void){ static char *home_dir = NULL; if( home_dir ) return home_dir; -#if !defined(_WIN32) && !defined(WIN32) && !defined(__OS2__) && !defined(_WIN32_WCE) && !defined(__RTP__) && !defined(_WRS_KERNEL) +#if !defined(_WIN32) && !defined(WIN32) && !defined(_WIN32_WCE) && !defined(__RTP__) && !defined(_WRS_KERNEL) struct passwd *pwent; uid_t uid = getuid(); if( (pwent=getpwuid(uid)) != NULL) { @@ -2710,7 +2706,7 @@ static char *find_home_dir(void){ home_dir = "/"; #else -#if defined(_WIN32) || defined(WIN32) || defined(__OS2__) +#if defined(_WIN32) || defined(WIN32) if (!home_dir) { home_dir = getenv("USERPROFILE"); } @@ -2720,7 +2716,7 @@ static char *find_home_dir(void){ home_dir = getenv("HOME"); } -#if defined(_WIN32) || defined(WIN32) || defined(__OS2__) +#if defined(_WIN32) || defined(WIN32) if (!home_dir) { char *zDrive, *zPath; int n; @@ -2936,11 +2932,7 @@ int main(int argc, char **argv){ } } if( i Date: Thu, 21 Jun 2012 14:25:17 +0000 Subject: [PATCH 17/69] Fix the SQLITE_ZERO_MALLOC compile-time option so that it works on windows. FossilOrigin-Name: b80bc52f8964569f948c5671e9d58e4d199a08dc --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/sqliteInt.h | 17 +++++++++++++---- 3 files changed, 21 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 487849dd65..8bff07d23d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sseveral\scompiler\scompatibility\sfixes\sto\strunk. -D 2012-06-21T14:05:15.442 +C Fix\sthe\sSQLITE_ZERO_MALLOC\scompile-time\soption\sso\sthat\sit\sworks\son\swindows. +D 2012-06-21T14:25:17.094 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c 74e47ddb99bf7997985dc89bbdd5875637501ad1 F src/sqlite.h.in 39f041ce71a0d994e2487014fc9e8721595f5bc0 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 29b5348f0056d9b46d0bb94d4853db21568afde9 +F src/sqliteInt.h aedc97651f686dccebd8a5c742835a2a5e8e99c0 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P ff828c67e5d3c1afa5bc3a304b9c6fcc7b3ea5fa 21266c68afb067ff40062df1e8b383dfd247c17b -R 2cae3db7f4ceb9e36c95e758c69ad1d1 -U mistachkin -Z 41747913182fa12ccba50300e60c3ef8 +P d3d491a5461e21d84c6425977b80deedc7fa8a3a +R 4e4a92cea90d72a4247a162f53436ce4 +U drh +Z 2bf16bd82723641a320d98b1a298580f diff --git a/manifest.uuid b/manifest.uuid index 5b4cc84b00..9b3a2071a2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d3d491a5461e21d84c6425977b80deedc7fa8a3a \ No newline at end of file +b80bc52f8964569f948c5671e9d58e4d199a08dc \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index e696e917ee..4665162f7a 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -149,6 +149,7 @@ ** ** SQLITE_SYSTEM_MALLOC // Use normal system malloc() ** SQLITE_WIN32_MALLOC // Use Win32 native heap API +** SQLITE_ZERO_MALLOC // Use a stub allocator that always fails ** SQLITE_MEMDEBUG // Debugging version of system malloc() ** ** On Windows, if the SQLITE_WIN32_MALLOC_VALIDATE macro is defined and the @@ -162,11 +163,19 @@ ** If none of the above are defined, then set SQLITE_SYSTEM_MALLOC as ** the default. */ -#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)>1 -# error "At most one of the following compile-time configuration options\ - is allows: SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG" +#if defined(SQLITE_SYSTEM_MALLOC) \ + + defined(SQLITE_WIN32_MALLOC) \ + + defined(SQLITE_ZERO_MALLOC) \ + + defined(SQLITE_MEMDEBUG)>1 +# error "Two or more of the following compile-time configuration options\ + are defined but at most one is allows:\ + SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\ + SQLITE_ZERO_MALLOC" #endif -#if defined(SQLITE_SYSTEM_MALLOC)+defined(SQLITE_WIN32_MALLOC)+defined(SQLITE_MEMDEBUG)==0 +#if defined(SQLITE_SYSTEM_MALLOC) \ + + defined(SQLITE_WIN32_MALLOC) \ + + defined(SQLITE_ZERO_MALLOC) \ + + defined(SQLITE_MEMDEBUG)==0 # define SQLITE_SYSTEM_MALLOC 1 #endif From 42c96dc8ffc029d3bf955f4d8d98045ecee2485c Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 21 Jun 2012 14:31:40 +0000 Subject: [PATCH 18/69] Increase the version number to 3.7.14 and rerun autoconf FossilOrigin-Name: 8c9f564a2a07603f1852ccb45089fe84591cf68f --- VERSION | 2 +- configure | 18 +++++++++--------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/VERSION b/VERSION index 214b521fe2..35c6ac5179 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.7.13 +3.7.14 diff --git a/configure b/configure index cf50e609ea..e1fd1686b8 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.62 for sqlite 3.7.13. +# Generated by GNU Autoconf 2.62 for sqlite 3.7.14. # # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, # 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. @@ -743,8 +743,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='sqlite' PACKAGE_TARNAME='sqlite' -PACKAGE_VERSION='3.7.13' -PACKAGE_STRING='sqlite 3.7.13' +PACKAGE_VERSION='3.7.14' +PACKAGE_STRING='sqlite 3.7.14' PACKAGE_BUGREPORT='' # Factoring default headers for most tests. @@ -1485,7 +1485,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures sqlite 3.7.13 to adapt to many kinds of systems. +\`configure' configures sqlite 3.7.14 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1550,7 +1550,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of sqlite 3.7.13:";; + short | recursive ) echo "Configuration of sqlite 3.7.14:";; esac cat <<\_ACEOF @@ -1666,7 +1666,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -sqlite configure 3.7.13 +sqlite configure 3.7.14 generated by GNU Autoconf 2.62 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, @@ -1680,7 +1680,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by sqlite $as_me 3.7.13, which was +It was created by sqlite $as_me 3.7.14, which was generated by GNU Autoconf 2.62. Invocation command line was $ $0 $@ @@ -14032,7 +14032,7 @@ exec 6>&1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by sqlite $as_me 3.7.13, which was +This file was extended by sqlite $as_me 3.7.14, which was generated by GNU Autoconf 2.62. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -14085,7 +14085,7 @@ Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_version="\\ -sqlite config.status 3.7.13 +sqlite config.status 3.7.14 configured by $0, generated by GNU Autoconf 2.62, with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" diff --git a/manifest b/manifest index 8bff07d23d..12d02fcd2c 100644 --- a/manifest +++ b/manifest @@ -1,12 +1,12 @@ -C Fix\sthe\sSQLITE_ZERO_MALLOC\scompile-time\soption\sso\sthat\sit\sworks\son\swindows. -D 2012-06-21T14:25:17.094 +C Increase\sthe\sversion\snumber\sto\s3.7.14\sand\srerun\sautoconf +D 2012-06-21T14:31:40.163 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc e893726c32ff402760eea125c7baaf928ed24257 F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 -F VERSION 3e857b9b826e818eec9411eafe2c3fa22c1dbb8a +F VERSION a71848df48082f1d6585d4b0819d530fc455485d F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 F addopcodes.awk 17dc593f791f874d2c23a0f9360850ded0286531 F art/sqlite370.eps aa97a671332b432a54e1d74ff5e8775be34200c2 @@ -15,7 +15,7 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 0921066a13130082764ab4ab6456f7b5bebe56de F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 79405675c313ce4a5e94afac6ec880bb3e27b4f1 x +F configure 8f973617dbc3fca46d26104070b75c17ef70beb7 x F configure.ac 9ee886c21c095b3272137b1553ae416c8b8c8557 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 3091574143dd3415669b6745843ff8d011d33549 @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P d3d491a5461e21d84c6425977b80deedc7fa8a3a -R 4e4a92cea90d72a4247a162f53436ce4 +P b80bc52f8964569f948c5671e9d58e4d199a08dc +R d9c7ca44b5bae5cf9a1d5fac839a060e U drh -Z 2bf16bd82723641a320d98b1a298580f +Z 9bb5699eedb76c21c7cf92db7d26e31a diff --git a/manifest.uuid b/manifest.uuid index 9b3a2071a2..8f13b9be82 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b80bc52f8964569f948c5671e9d58e4d199a08dc \ No newline at end of file +8c9f564a2a07603f1852ccb45089fe84591cf68f \ No newline at end of file From c722a2c2e41554d9aa1027e55a608515b9909c12 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 21 Jun 2012 15:02:26 +0000 Subject: [PATCH 19/69] Disable the atof1.test module when compiling on MSVC. FossilOrigin-Name: 0f706acfc7181f2714a06b2c232677ebeede3a44 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test_config.c | 15 +++++++++++++++ test/atof1.test | 9 +++++++-- 4 files changed, 31 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index bd1f483817..de8e9b1ae0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Move\svariable\sdeclaration\sto\sfix\scompilation\swith\sMSVC. -D 2012-06-19T04:36:48.907 +C Disable\sthe\satof1.test\smodule\swhen\scompiling\son\sMSVC. +D 2012-06-21T15:02:26.644 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in d17fddaa4e81f93a7c9c7c0808aacb3fc95f79f4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -200,7 +200,7 @@ F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e F src/test_backup.c c129c91127e9b46e335715ae2e75756e25ba27de F src/test_btree.c 5b89601dcb42a33ba8b820a6b763cc9cb48bac16 -F src/test_config.c 4f7b8030287d62fe56a1d99e68b41760feae381a +F src/test_config.c 9b37587750f247186ebeb02a02e8f17c611d1866 F src/test_demovfs.c 20a4975127993f4959890016ae9ce5535a880094 F src/test_devsym.c e7498904e72ba7491d142d5c83b476c4e76993bc F src/test_func.c 3a8dd37c08ab43b76d38eea2836e34a3897bf170 @@ -274,7 +274,7 @@ F test/async2.test c0a9bd20816d7d6a2ceca7b8c03d3d69c28ffb8b F test/async3.test d73a062002376d7edc1fe3edff493edbec1fc2f7 F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 0dd8701bd588bf6e70c2557a22ae3f22b2567b4c -F test/atof1.test b765ba6bc09aa6a16234d2d66a71a5079f2a6d8a +F test/atof1.test 9bf1d25180a2e05fc12ce3940cc8003033642f68 F test/attach.test 0d112b7713611fdf0340260192749737135fda5f F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966 F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e @@ -1006,7 +1006,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 963eb24f737f184d5fcdcd92ebf90466f818cfd8 -R f969ff33ef926829900ede45cb301833 -U mistachkin -Z 0dc9aadbc42938d9910cf216fa3f6f99 +P d45f7a013f05fe7603d5e6d02df0e6bab2c7ffd8 +R e35884badae6d1997ef669d538c5ea6c +U drh +Z 9a69b4050bef2b4e8b68607c50525e88 diff --git a/manifest.uuid b/manifest.uuid index b28390f96e..4a21353a92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d45f7a013f05fe7603d5e6d02df0e6bab2c7ffd8 \ No newline at end of file +0f706acfc7181f2714a06b2c232677ebeede3a44 \ No newline at end of file diff --git a/src/test_config.c b/src/test_config.c index c04eb99a10..4f7dc64e5c 100644 --- a/src/test_config.c +++ b/src/test_config.c @@ -616,6 +616,21 @@ Tcl_SetVar2(interp, "sqlite_options", "long_double", Tcl_LinkVar(interp, "TEMP_STORE", (char *)&(cv_TEMP_STORE), TCL_LINK_INT | TCL_LINK_READ_ONLY); } + +#ifdef _MSC_VER + { + static const int cv__MSC_VER = 1; + Tcl_LinkVar(interp, "_MSC_VER", (char *)&(cv__MSC_VER), + TCL_LINK_INT | TCL_LINK_READ_ONLY); + } +#endif +#ifdef __GNUC__ + { + static const int cv___GNUC__ = 1; + Tcl_LinkVar(interp, "__GNUC__", (char *)&(cv___GNUC__), + TCL_LINK_INT | TCL_LINK_READ_ONLY); + } +#endif } diff --git a/test/atof1.test b/test/atof1.test index 66e1bee518..76eb4273b9 100644 --- a/test/atof1.test +++ b/test/atof1.test @@ -15,6 +15,11 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +if {![info exists __GNUC__]} { + finish_test + return +} + expr srand(1) for {set i 1} {$i<20000} {incr i} { set pow [expr {int((rand()-0.5)*100)}] @@ -24,7 +29,7 @@ for {set i 1} {$i<20000} {incr i} { # Verify that text->real conversions get exactly same ieee754 floating- # point value in SQLite as they do in TCL. # - do_test 1.$i.1 { + do_test atof1-1.$i.1 { set y [db eval "SELECT $xf=\$x"] if {!$y} { puts -nonewline \173[db eval "SELECT real2hex($xf), real2hex(\$x)"]\175 @@ -38,7 +43,7 @@ for {set i 1} {$i<20000} {incr i} { # Verify that round-trip real->text->real conversions using the quote() # function preserve the bits of the numeric value exactly. # - do_test 1.$i.2 { + do_test atof1-1.$i.2 { set y [db eval {SELECT $x=CAST(quote($x) AS real)}] if {!$y} { db eval {SELECT real2hex($x) a, real2hex(CAST(quote($x) AS real)) b} {} From f1c6bc5cd3552772bf749df91ffeee2d37f62d1f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 21 Jun 2012 15:09:20 +0000 Subject: [PATCH 20/69] Remove more references to OS/2. FossilOrigin-Name: eebd594d6bd09c77727620a818d7dc0b091f55b4 --- Makefile.msc | 13 ++----------- Makefile.vxworks | 8 +++----- manifest | 30 +++++++++++++++--------------- manifest.uuid | 2 +- src/sqlite.h.in | 7 +++---- test/loadext.test | 2 +- test/misc7.test | 2 +- test/releasetest.tcl | 2 -- tool/mksqlite3c-noext.tcl | 3 --- tool/mksqlite3internalh.tcl | 1 - tool/omittest.tcl | 8 +++----- 11 files changed, 29 insertions(+), 49 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index a80db8c638..c42f949d6e 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -303,8 +303,8 @@ LIBOBJS0 = alter.lo analyze.lo attach.lo auth.lo \ icu.lo insert.lo journal.lo legacy.lo loadext.lo \ main.lo malloc.lo mem0.lo mem1.lo mem2.lo mem3.lo mem5.lo \ memjournal.lo \ - mutex.lo mutex_noop.lo mutex_os2.lo mutex_unix.lo mutex_w32.lo \ - notify.lo opcodes.lo os.lo os_os2.lo os_unix.lo os_win.lo \ + mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \ + notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \ pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \ random.lo resolve.lo rowset.lo rtree.lo select.lo status.lo \ table.lo tokenize.lo trigger.lo \ @@ -366,14 +366,12 @@ SRC = \ $(TOP)\src\mutex.c \ $(TOP)\src\mutex.h \ $(TOP)\src\mutex_noop.c \ - $(TOP)\src\mutex_os2.c \ $(TOP)\src\mutex_unix.c \ $(TOP)\src\mutex_w32.c \ $(TOP)\src\notify.c \ $(TOP)\src\os.c \ $(TOP)\src\os.h \ $(TOP)\src\os_common.h \ - $(TOP)\src\os_os2.c \ $(TOP)\src\os_unix.c \ $(TOP)\src\os_win.c \ $(TOP)\src\pager.c \ @@ -535,7 +533,6 @@ TESTSRC2 = \ $(TOP)\src\wal.c \ $(TOP)\src\mem5.c \ $(TOP)\src\os.c \ - $(TOP)\src\os_os2.c \ $(TOP)\src\os_unix.c \ $(TOP)\src\os_win.c \ $(TOP)\src\pager.c \ @@ -776,9 +773,6 @@ mutex.lo: $(TOP)\src\mutex.c $(HDR) mutex_noop.lo: $(TOP)\src\mutex_noop.c $(HDR) $(LTCOMPILE) -c $(TOP)\src\mutex_noop.c -mutex_os2.lo: $(TOP)\src\mutex_os2.c $(HDR) - $(LTCOMPILE) -c $(TOP)\src\mutex_os2.c - mutex_unix.lo: $(TOP)\src\mutex_unix.c $(HDR) $(LTCOMPILE) -c $(TOP)\src\mutex_unix.c @@ -806,9 +800,6 @@ os_unix.lo: $(TOP)\src\os_unix.c $(HDR) os_win.lo: $(TOP)\src\os_win.c $(HDR) $(LTCOMPILE) -c $(TOP)\src\os_win.c -os_os2.lo: $(TOP)\src\os_os2.c $(HDR) - $(LTCOMPILE) -c $(TOP)\src\os_os2.c - pragma.lo: $(TOP)\src\pragma.c $(HDR) $(LTCOMPILE) -c $(TOP)\src\pragma.c diff --git a/Makefile.vxworks b/Makefile.vxworks index 4398c18265..25bc853943 100644 --- a/Makefile.vxworks +++ b/Makefile.vxworks @@ -204,8 +204,8 @@ LIBOBJ+= alter.o analyze.o attach.o auth.o \ icu.o insert.o journal.o legacy.o loadext.o \ main.o malloc.o mem0.o mem1.o mem2.o mem3.o mem5.o \ memjournal.o \ - mutex.o mutex_noop.o mutex_os2.o mutex_unix.o mutex_w32.o \ - notify.o opcodes.o os.o os_os2.o os_unix.o os_win.o \ + mutex.o mutex_noop.o mutex_unix.o mutex_w32.o \ + notify.o opcodes.o os.o os_unix.o os_win.o \ pager.o parse.o pcache.o pcache1.o pragma.o prepare.o printf.o \ random.o resolve.o rowset.o rtree.o select.o status.o \ table.o tokenize.o trigger.o \ @@ -256,14 +256,12 @@ SRC = \ $(TOP)/src/mutex.c \ $(TOP)/src/mutex.h \ $(TOP)/src/mutex_noop.c \ - $(TOP)/src/mutex_os2.c \ $(TOP)/src/mutex_unix.c \ $(TOP)/src/mutex_w32.c \ $(TOP)/src/notify.c \ $(TOP)/src/os.c \ $(TOP)/src/os.h \ $(TOP)/src/os_common.h \ - $(TOP)/src/os_os2.c \ $(TOP)/src/os_unix.c \ $(TOP)/src/os_win.c \ $(TOP)/src/pager.c \ @@ -396,7 +394,7 @@ TESTSRC2 = \ $(TOP)/src/attach.c $(TOP)/src/backup.c $(TOP)/src/btree.c \ $(TOP)/src/build.c $(TOP)/src/ctime.c $(TOP)/src/date.c \ $(TOP)/src/expr.c $(TOP)/src/func.c $(TOP)/src/insert.c $(TOP)/src/os.c \ - $(TOP)/src/os_os2.c $(TOP)/src/os_unix.c $(TOP)/src/os_win.c \ + $(TOP)/src/os_unix.c $(TOP)/src/os_win.c \ $(TOP)/src/pager.c $(TOP)/src/pragma.c $(TOP)/src/prepare.c \ $(TOP)/src/printf.c $(TOP)/src/random.c $(TOP)/src/pcache.c \ $(TOP)/src/pcache1.c $(TOP)/src/select.c $(TOP)/src/tokenize.c \ diff --git a/manifest b/manifest index 12d02fcd2c..1e64ec685c 100644 --- a/manifest +++ b/manifest @@ -1,10 +1,10 @@ -C Increase\sthe\sversion\snumber\sto\s3.7.14\sand\srerun\sautoconf -D 2012-06-21T14:31:40.163 +C Remove\smore\sreferences\sto\sOS/2. +D 2012-06-21T15:09:20.823 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc e893726c32ff402760eea125c7baaf928ed24257 -F Makefile.vxworks 3b7fe7a0571fdadc61363ebc1b23732d2d6363ca +F Makefile.msc 0100213e86c66ed5ac37ea98446406c06f012203 +F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d F aclocal.m4 a5c22d164aff7ed549d53a90fa56d56955281f50 @@ -178,7 +178,7 @@ F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c 74e47ddb99bf7997985dc89bbdd5875637501ad1 -F src/sqlite.h.in 39f041ce71a0d994e2487014fc9e8721595f5bc0 +F src/sqlite.h.in 34640d183e570e81ae1e057a668fdbb55625e802 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h aedc97651f686dccebd8a5c742835a2a5e8e99c0 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -566,7 +566,7 @@ F test/laststmtchanges.test ae613f53819206b3222771828d024154d51db200 F test/like.test 7b4aaa4a8192fdec90e0a905984c92a688c51e48 F test/like2.test 3b2ee13149ba4a8a60b59756f4e5d345573852da F test/limit.test 2db7b3b34fb925b8e847d583d2eb67531d0ce67e -F test/loadext.test dab17f7014f8079698dbd4b02705562b0ce6db5f +F test/loadext.test 2b5e249c51c986a5aff1f0950cf7ba30976c8f22 F test/loadext2.test 0bcaeb4d81cd5b6e883fdfea3c1bdbe1f173cbca F test/lock.test db74fdf5a73bad29ab3d862ea78bf1068972cc1d F test/lock2.test 5242d8ac4e2d59c403aebff606af449b455aceff @@ -616,7 +616,7 @@ F test/misc3.test fe55130a43e444ee75e2156ff75dc96e964b5738 F test/misc4.test 9c078510fbfff05a9869a0b6d8b86a623ad2c4f6 F test/misc5.test 528468b26d03303b1f047146e5eefc941b9069f5 F test/misc6.test 953cc693924d88e6117aeba16f46f0bf5abede91 -F test/misc7.test 4337d84e441f36cee62656f9f7ba8bc22a7ca721 +F test/misc7.test f00dad9a004da659330013e6f21819d018b683d3 F test/misuse.test ba4fb5d1a6101d1c171ea38b3c613d0661c83054 F test/multiplex.test e08cc7177bd6d85990ee1d71100bb6c684c02256 F test/multiplex2.test 580ca5817c7edbe4cc68fa150609c9473393003a @@ -657,7 +657,7 @@ F test/randexpr1.test eda062a97e60f9c38ae8d806b03b0ddf23d796df F test/rdonly.test c267d050a1d9a6a321de502b737daf28821a518d F test/reindex.test 44edd3966b474468b823d481eafef0c305022254 F test/releasetest.mk 2eced2f9ae701fd0a29e714a241760503ccba25a -F test/releasetest.tcl fa302d03fd9acfce6d910553a33473bfcf561958 +F test/releasetest.tcl 4014e2bfb93f276d82a604e7a5eda62c129916c9 F test/rollback.test a1b4784b864331eae8b2a98c189efa2a8b11ff07 F test/rowhash.test 0bc1d31415e4575d10cacf31e1a66b5cc0f8be81 F test/rowid.test e58e0acef38b527ed1b0b70d3ada588f804af287 @@ -977,12 +977,12 @@ F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 -F tool/mksqlite3c-noext.tcl 105023aa86f696a74b1d6a4929d1e1c3baf9471c +F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl 589c7f44e990be1b8443cfe4808dce392b0327fa F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8 -F tool/mksqlite3internalh.tcl 7b43894e21bcb1bb39e11547ce7e38a063357e87 +F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 -F tool/omittest.tcl 72a49b8a9a8b0bf213a438180307a0df836d4380 +F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c F tool/restore_jrnl.tcl 6957a34f8f1f0f8285e07536225ec3b292a9024a F tool/rollback-test.c 9fc98427d1e23e84429d7e6d07d9094fbdec65a5 @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P b80bc52f8964569f948c5671e9d58e4d199a08dc -R d9c7ca44b5bae5cf9a1d5fac839a060e -U drh -Z 9bb5699eedb76c21c7cf92db7d26e31a +P 8c9f564a2a07603f1852ccb45089fe84591cf68f +R fcffc83b93b7e49de73883c31a2c7d5e +U mistachkin +Z 5f63191d32609910374c52c28186aa72 diff --git a/manifest.uuid b/manifest.uuid index 8f13b9be82..052ef8fa2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c9f564a2a07603f1852ccb45089fe84591cf68f \ No newline at end of file +eebd594d6bd09c77727620a818d7dc0b091f55b4 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index f273937ca5..ea36673ad3 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -5489,7 +5489,6 @@ int sqlite3_vfs_unregister(sqlite3_vfs*); ** implementations are available in the SQLite core: ** **
    -**
  • SQLITE_MUTEX_OS2 **
  • SQLITE_MUTEX_PTHREADS **
  • SQLITE_MUTEX_W32 **
  • SQLITE_MUTEX_NOOP @@ -5497,9 +5496,9 @@ int sqlite3_vfs_unregister(sqlite3_vfs*); ** ** ^The SQLITE_MUTEX_NOOP implementation is a set of routines ** that does no real locking and is appropriate for use in -** a single-threaded application. ^The SQLITE_MUTEX_OS2, -** SQLITE_MUTEX_PTHREADS, and SQLITE_MUTEX_W32 implementations -** are appropriate for use on OS/2, Unix, and Windows. +** a single-threaded application. ^The SQLITE_MUTEX_PTHREADS and +** SQLITE_MUTEX_W32 implementations are appropriate for use on Unix +** and Windows. ** ** ^(If SQLite is compiled with the SQLITE_MUTEX_APPDEF preprocessor ** macro defined (with "-DSQLITE_MUTEX_APPDEF=1"), then no mutex diff --git a/test/loadext.test b/test/loadext.test index 8f8339ecb3..72eff12f7a 100644 --- a/test/loadext.test +++ b/test/loadext.test @@ -23,7 +23,7 @@ ifcapable !load_ext { # The name of the test extension varies by operating system. # -if {$::tcl_platform(platform) eq "windows" || $::tcl_platform(platform) eq "os2"} { +if {$::tcl_platform(platform) eq "windows"} { set testextension ./testloadext.dll } else { set testextension ./libtestloadext.so diff --git a/test/misc7.test b/test/misc7.test index 146dca0412..4868c12ac0 100644 --- a/test/misc7.test +++ b/test/misc7.test @@ -377,7 +377,7 @@ do_test misc7-16.X { # These tests do not work on windows due to restrictions in the # windows file system. # -if {$tcl_platform(platform)!="windows" && $tcl_platform(platform)!="os2"} { +if {$tcl_platform(platform)!="windows"} { # Some network filesystems (ex: AFP) do not support setting read-only # permissions. Only run these tests if full unix permission setting diff --git a/test/releasetest.tcl b/test/releasetest.tcl index 7725630187..83377d6fa2 100644 --- a/test/releasetest.tcl +++ b/test/releasetest.tcl @@ -218,8 +218,6 @@ proc run_test_suite {name testtarget config} { if {$::tcl_platform(platform)=="windows"} { append opts " -DSQLITE_OS_WIN=1" - } elseif {$::tcl_platform(platform)=="os2"} { - append opts " -DSQLITE_OS_OS2=1" } else { append opts " -DSQLITE_OS_UNIX=1" } diff --git a/tool/mksqlite3c-noext.tcl b/tool/mksqlite3c-noext.tcl index 6ad30237c6..017ad6292f 100644 --- a/tool/mksqlite3c-noext.tcl +++ b/tool/mksqlite3c-noext.tcl @@ -100,7 +100,6 @@ foreach hdr { opcodes.h os_common.h os.h - os_os2.h pager.h parse.h pcache.h @@ -233,7 +232,6 @@ foreach file { mem5.c mutex.c mutex_noop.c - mutex_os2.c mutex_unix.c mutex_w32.c malloc.c @@ -244,7 +242,6 @@ foreach file { hash.c opcodes.c - os_os2.c os_unix.c os_win.c diff --git a/tool/mksqlite3internalh.tcl b/tool/mksqlite3internalh.tcl index f02a62df73..406ef5c457 100644 --- a/tool/mksqlite3internalh.tcl +++ b/tool/mksqlite3internalh.tcl @@ -61,7 +61,6 @@ foreach hdr { opcodes.h os_common.h os.h - os_os2.h pager.h parse.h sqlite3ext.h diff --git a/tool/omittest.tcl b/tool/omittest.tcl index 7f13a4cbe3..3351b96b32 100644 --- a/tool/omittest.tcl +++ b/tool/omittest.tcl @@ -53,8 +53,6 @@ proc run_quick_test {dir omit_symbol_list} { if {$::tcl_platform(platform)=="windows"} { append opts "OPTS += -DSQLITE_OS_WIN=1\n" set target "testfixture.exe" - } elseif {$::tcl_platform(platform)=="os2"} { - append opts "OPTS += -DSQLITE_OS_OS2=1\n" } else { append opts "OPTS += -DSQLITE_OS_UNIX=1\n" } @@ -93,7 +91,7 @@ proc run_quick_test {dir omit_symbol_list} { # of trying to build the sqlite shell. The sqlite shell won't build # with some of the OMIT options (i.e OMIT_COMPLETE). set sqlite3_dummy $dir/sqlite3 - if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} { + if {$::tcl_platform(platform)=="windows"} { append sqlite3_dummy ".exe" } if {![file exists $sqlite3_dummy]} { @@ -127,8 +125,8 @@ proc run_quick_test {dir omit_symbol_list} { # proc process_options {argv} { set ::MAKEBIN make ;# Default value - if {$::tcl_platform(platform)=="windows" || $::tcl_platform(platform)=="os2"} { - set ::MAKEFILE ./Makefile ;# Default value on Windows and OS2 + if {$::tcl_platform(platform)=="windows"} { + set ::MAKEFILE ./Makefile ;# Default value on Windows } else { set ::MAKEFILE ./Makefile.linux-gcc ;# Default value } From 20b1ff0760c200ae2abbdba33d448d84c77ed17f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 21 Jun 2012 15:12:30 +0000 Subject: [PATCH 21/69] Fix spelling typo. FossilOrigin-Name: 6131a0002fea5d6f3b416a63a466bf2b69d1e12d --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqliteInt.h | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 1e64ec685c..9bfbdfbfa5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\smore\sreferences\sto\sOS/2. -D 2012-06-21T15:09:20.823 +C Fix\sspelling\stypo. +D 2012-06-21T15:12:30.926 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -180,7 +180,7 @@ F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d F src/shell.c 74e47ddb99bf7997985dc89bbdd5875637501ad1 F src/sqlite.h.in 34640d183e570e81ae1e057a668fdbb55625e802 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h aedc97651f686dccebd8a5c742835a2a5e8e99c0 +F src/sqliteInt.h 4e092561a4d9c384c3b9dfeebdef868a3566561c F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8c9f564a2a07603f1852ccb45089fe84591cf68f -R fcffc83b93b7e49de73883c31a2c7d5e +P eebd594d6bd09c77727620a818d7dc0b091f55b4 +R be7f54310076aeaf2e41fd02ae207bae U mistachkin -Z 5f63191d32609910374c52c28186aa72 +Z 44f889ecf2b83e0a51162901a7e23f5e diff --git a/manifest.uuid b/manifest.uuid index 052ef8fa2a..18af6b4a3f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -eebd594d6bd09c77727620a818d7dc0b091f55b4 \ No newline at end of file +6131a0002fea5d6f3b416a63a466bf2b69d1e12d \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 4665162f7a..ca409670bb 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -168,7 +168,7 @@ + defined(SQLITE_ZERO_MALLOC) \ + defined(SQLITE_MEMDEBUG)>1 # error "Two or more of the following compile-time configuration options\ - are defined but at most one is allows:\ + are defined but at most one is allowed:\ SQLITE_SYSTEM_MALLOC, SQLITE_WIN32_MALLOC, SQLITE_MEMDEBUG,\ SQLITE_ZERO_MALLOC" #endif From 5afbd60a1d75de447049d34293ac2826b66f37d0 Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 21 Jun 2012 17:21:52 +0000 Subject: [PATCH 22/69] Remove code that was incorrectly changing SQLITE_MISUSE errors into SQLITE_OK in sqlite3_finalize(). FossilOrigin-Name: d5e6880279210ca63e2d5e7f6d009f30566f1242 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbeapi.c | 1 - 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 3103353fbf..54253a585a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sthe\ssqlite3_close_v2()\sinterface\s(from\sthe\sdeferred-close\sbranch)\sthat\nallows\sclose\soperations\sto\shappen\sout-of-order\sin\sbindings\sto\ngarbage-collected\slangauges. -D 2012-06-21T15:51:42.711 +C Remove\scode\sthat\swas\sincorrectly\schanging\sSQLITE_MISUSE\serrors\sinto\sSQLITE_OK\nin\ssqlite3_finalize(). +D 2012-06-21T17:21:52.202 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -240,7 +240,7 @@ F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd F src/vdbe.c f5ad3c06dc3fe647097065829c013f3f1b9eadca F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb F src/vdbeInt.h 6ff4180a05683566a8835d12f7ec504b22932c82 -F src/vdbeapi.c f8ba09132fe654ffd068058cef490426aca9fca6 +F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4cebd60704f92bb3689c126f46feadc3516d3d45 37d9bc061d5ecfe37ccbd6f559986d7ae0449179 -R 41d5610ed2033955b4202ff788697dde +P fb8893abeefabe9de44e34dcf4327764481189f5 +R 1407ab77c9d83dad7f51ec0e9878a545 U drh -Z c18db60333d2fd8d859babd08906006b +Z f514219a89248d947572eba2b55a152c diff --git a/manifest.uuid b/manifest.uuid index 9e7abc1ff8..7b21713036 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fb8893abeefabe9de44e34dcf4327764481189f5 \ No newline at end of file +d5e6880279210ca63e2d5e7f6d009f30566f1242 \ No newline at end of file diff --git a/src/vdbeapi.c b/src/vdbeapi.c index e25acd9449..b9a88a6ab8 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -74,7 +74,6 @@ int sqlite3_finalize(sqlite3_stmt *pStmt){ if( vdbeSafety(v) ) return SQLITE_MISUSE_BKPT; sqlite3_mutex_enter(db->mutex); rc = sqlite3VdbeFinalize(v); - if( (rc&0xff)==SQLITE_MISUSE ) rc = SQLITE_OK; rc = sqlite3ApiExit(db, rc); sqlite3LeaveMutexAndCloseZombie(db); } From bbb0be8688e1a6bdec19341f4af004cecfb01cc0 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 27 Jun 2012 16:12:27 +0000 Subject: [PATCH 23/69] Update the shell so that it works with SQLITE_OMIT_FLOATING_POINT and SQLITE_OMIT_AUTOINIT. FossilOrigin-Name: 95c0c995fd18c2de907a39fc52299c8abe502b68 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 54253a585a..1975ca3773 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Remove\scode\sthat\swas\sincorrectly\schanging\sSQLITE_MISUSE\serrors\sinto\sSQLITE_OK\nin\ssqlite3_finalize(). -D 2012-06-21T17:21:52.202 +C Update\sthe\sshell\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_FLOATING_POINT\sand\nSQLITE_OMIT_AUTOINIT. +D 2012-06-27T16:12:27.595 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -177,7 +177,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d -F src/shell.c 74e47ddb99bf7997985dc89bbdd5875637501ad1 +F src/shell.c 88e34bc18cc385c243b2de2c7c6db33826b32147 F src/sqlite.h.in 310ae7e538883fa1619ab0638c775ce11ad43015 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 2bc2ebc2ff1a2b530ee5ed9ffd46c6fce93b244c @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P fb8893abeefabe9de44e34dcf4327764481189f5 -R 1407ab77c9d83dad7f51ec0e9878a545 +P d5e6880279210ca63e2d5e7f6d009f30566f1242 +R 6769e93fb0dcc5b38c2d7d47cf25ddd0 U drh -Z f514219a89248d947572eba2b55a152c +Z aef2b290fbb1b4163dab2604e1f1a752 diff --git a/manifest.uuid b/manifest.uuid index 7b21713036..5c3bdeb361 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d5e6880279210ca63e2d5e7f6d009f30566f1242 \ No newline at end of file +95c0c995fd18c2de907a39fc52299c8abe502b68 \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index ad919709a0..4d1ca7eac6 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1449,6 +1449,7 @@ static int process_input(struct callback_data *p, FILE *in); */ static void open_db(struct callback_data *p){ if( p->db==0 ){ + sqlite3_initialize(); sqlite3_open(p->zDbFilename, &p->db); db = p->db; if( db && sqlite3_errcode(db)==SQLITE_OK ){ @@ -2464,7 +2465,7 @@ static int do_meta_command(char *zLine, struct callback_data *p){ open_db(p); output_file_close(p->traceOut); p->traceOut = output_file_open(azArg[1]); -#ifndef SQLITE_OMIT_TRACE +#if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT) if( p->traceOut==0 ){ sqlite3_trace(p->db, 0, 0); }else{ From 2f3de3232ce18cd72ec8edd829824a927b817bd8 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 27 Jun 2012 16:41:31 +0000 Subject: [PATCH 24/69] Another changes to the shell in support of SQLITE_OMIT_AUTOINIT. FossilOrigin-Name: 3b4f5add04259eec145066312bcd532182cc339c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/shell.c | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 1975ca3773..ad7995d713 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sshell\sso\sthat\sit\sworks\swith\sSQLITE_OMIT_FLOATING_POINT\sand\nSQLITE_OMIT_AUTOINIT. -D 2012-06-27T16:12:27.595 +C Another\schanges\sto\sthe\sshell\sin\ssupport\sof\sSQLITE_OMIT_AUTOINIT. +D 2012-06-27T16:41:31.500 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -177,7 +177,7 @@ F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d -F src/shell.c 88e34bc18cc385c243b2de2c7c6db33826b32147 +F src/shell.c 076e1c90d594644f36027c8ecff9a392cf2d3a06 F src/sqlite.h.in 310ae7e538883fa1619ab0638c775ce11ad43015 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h 2bc2ebc2ff1a2b530ee5ed9ffd46c6fce93b244c @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P d5e6880279210ca63e2d5e7f6d009f30566f1242 -R 6769e93fb0dcc5b38c2d7d47cf25ddd0 +P 95c0c995fd18c2de907a39fc52299c8abe502b68 +R 8764407565c7470a7af4e28914ff89fc U drh -Z aef2b290fbb1b4163dab2604e1f1a752 +Z 848177401525cd9b79cf5683d5f4213a diff --git a/manifest.uuid b/manifest.uuid index 5c3bdeb361..ecee8360b8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95c0c995fd18c2de907a39fc52299c8abe502b68 \ No newline at end of file +3b4f5add04259eec145066312bcd532182cc339c \ No newline at end of file diff --git a/src/shell.c b/src/shell.c index 4d1ca7eac6..baedcceb59 100644 --- a/src/shell.c +++ b/src/shell.c @@ -2772,6 +2772,7 @@ static int process_sqliterc( #endif return 1; } + sqlite3_initialize(); zBuf = sqlite3_mprintf("%s/.sqliterc",home_dir); sqliterc = zBuf; } From e37f99cbef0a0e62d4704097e50a5bc7ff316852 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 30 Jun 2012 16:22:05 +0000 Subject: [PATCH 25/69] Make use of the predefined nmake command macro CC when possible instead of the literal string 'cl.exe'. Improve support for cross-compilation. Eliminate problematic use of double quotes in macro preprocessing expressions. FossilOrigin-Name: 6c88229aa39775a7438befebe1640a30affc72c8 --- Makefile.msc | 60 +++++++++++++++++++++++++++++++++++---------------- manifest | 14 ++++++------ manifest.uuid | 2 +- 3 files changed, 49 insertions(+), 27 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index c42f949d6e..5d961bffcd 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -42,16 +42,38 @@ SYMBOLS = 1 # DEBUG = 0 +# Check for the predefined command macro CC. This should point to the compiler +# binary for the target platform. If it does not exist, simply define it to +# the legacy default value 'cl.exe'. +# +!IFNDEF CC +CC = cl.exe +!ENDIF + +# Check for the command macro NCC. This should point to the compiler binary +# for the platform the compilation process is taking place on. If it does not +# exist, simply define it to have the same value as the CC macro. When +# cross-compiling, it is suggested that this macro be modified via the command +# line (since nmake itself does not provide a built-in method to guess it). +# For example, to use the x86 compiler when cross-compiling for x64, a command +# line similar to the following could be used: +# +# nmake /f Makefile.msc "NCC=""%VCINSTALLDIR%\bin\cl.exe""" +# +!IFNDEF NCC +NCC = $(CC) +!ENDIF + # C Compiler and options for use in building executables that # will run on the platform that is doing the build. # -BCC = cl.exe -W3 +BCC = $(NCC) -W3 # C Compile and options for use in building executables that # will run on the target platform. (BCC and TCC are usually the # same unless your are cross-compiling.) # -TCC = cl.exe -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise +TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise # When compiling the library for use in the WinRT environment, # the following compile-time options must be used as well to @@ -135,43 +157,43 @@ TCC = $(TCC) -DSQLITE_WIN32_MALLOC_VALIDATE=1 # prior to running nmake in order to match the actual installed location and # version on this machine. # -!if "$(TCLINCDIR)" == "" +!IFNDEF TCLINCDIR TCLINCDIR = c:\tcl\include -!endif +!ENDIF -!if "$(TCLLIBDIR)" == "" +!IFNDEF TCLLIBDIR TCLLIBDIR = c:\tcl\lib -!endif +!ENDIF -!if "$(LIBTCL)" == "" +!IFNDEF LIBTCL LIBTCL = tcl85.lib -!endif +!ENDIF # The locations of the ICU header and library files. These variables # (ICUINCDIR, ICULIBDIR, and LIBICU) may be overridden via the environment # prior to running nmake in order to match the actual installed location on # this machine. # -!if "$(ICUINCDIR)" == "" +!IFNDEF ICUINCDIR ICUINCDIR = c:\icu\include -!endif +!ENDIF -!if "$(ICULIBDIR)" == "" +!IFNDEF ICULIBDIR ICULIBDIR = c:\icu\lib -!endif +!ENDIF -!if "$(LIBICU)" == "" +!IFNDEF LIBICU LIBICU = icuuc.lib icuin.lib -!endif +!ENDIF # This is the command to use for tclsh - normally just "tclsh", but we may # know the specific version we want to use. This variable (TCLSH_CMD) may be # overridden via the environment prior to running nmake in order to select a # specific Tcl shell to use. # -!if "$(TCLSH_CMD)" == "" +!IFNDEF TCLSH_CMD TCLSH_CMD = tclsh85 -!endif +!ENDIF # Compiler options needed for programs that use the readline() library. # @@ -191,9 +213,9 @@ TCC = $(TCC) -DSQLITE_THREAD_OVERRIDE_LOCK=-1 # Any target libraries which libsqlite must be linked against # -!if "$(TLIBS)" == "" +!IFNDEF TLIBS TLIBS = -!endif +!ENDIF # Flags controlling use of the in memory btree implementation # @@ -255,7 +277,7 @@ LTLINK = $(TCC) -Fe$@ # Note that the vcvars*.bat family of batch files typically # set this for you. Otherwise, the linker will attempt # to deduce the binary type based on the object files. -!IF "$(PLATFORM)"!="" +!IFDEF PLATFORM LTLINKOPTS = /MACHINE:$(PLATFORM) LTLIBOPTS = /MACHINE:$(PLATFORM) !ENDIF diff --git a/manifest b/manifest index ad7995d713..ead73d4c61 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Another\schanges\sto\sthe\sshell\sin\ssupport\sof\sSQLITE_OMIT_AUTOINIT. -D 2012-06-27T16:41:31.500 +C Make\suse\sof\sthe\spredefined\snmake\scommand\smacro\sCC\swhen\spossible\sinstead\sof\sthe\sliteral\sstring\s'cl.exe'.\s\sImprove\ssupport\sfor\scross-compilation.\s\sEliminate\sproblematic\suse\sof\sdouble\squotes\sin\smacro\spreprocessing\sexpressions. +D 2012-06-30T16:22:05.485 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 0100213e86c66ed5ac37ea98446406c06f012203 +F Makefile.msc d5fe268f23e35af9a6b8c6c7df983dda65f0a017 F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 95c0c995fd18c2de907a39fc52299c8abe502b68 -R 8764407565c7470a7af4e28914ff89fc -U drh -Z 848177401525cd9b79cf5683d5f4213a +P 3b4f5add04259eec145066312bcd532182cc339c +R 437136894c0f887fea4db99bcef8bbec +U mistachkin +Z e6de48dad2c2672c700a9587a09ef1b4 diff --git a/manifest.uuid b/manifest.uuid index ecee8360b8..486e7319bb 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -3b4f5add04259eec145066312bcd532182cc339c \ No newline at end of file +6c88229aa39775a7438befebe1640a30affc72c8 \ No newline at end of file From 228aeffb86710c62986b2abe13701e2789b3a7bd Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 30 Jun 2012 19:24:09 +0000 Subject: [PATCH 26/69] Simplify usage of some linker options in the MSVC makefile. FossilOrigin-Name: 03016020664a7459cb01c8ac9016b20af8a416bb --- Makefile.msc | 15 +++++++++++---- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 5d961bffcd..c5feb9d0ed 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -50,6 +50,14 @@ DEBUG = 0 CC = cl.exe !ENDIF +# Check for the command macro LD. This should point to the linker binary for +# the target platform. If it does not exist, simply define it to the legacy +# default value 'link.exe'. +# +!IFNDEF LD +LD = link.exe +!ENDIF + # Check for the command macro NCC. This should point to the compiler binary # for the platform the compilation process is taking place on. If it does not # exist, simply define it to have the same value as the CC macro. When @@ -292,8 +300,7 @@ LTLINKOPTS = $(LTLINKOPTS) /APPCONTAINER # If either debugging or symbols are enabled, enable PDBs. !IF $(DEBUG)>0 || $(SYMBOLS)!=0 -LTLINKOPTS = $(LTLINKOPTS) /DEBUG -BCC = $(BCC) /DEBUG +LDFLAGS = /DEBUG !ENDIF # Start with the Tcl related linker options. @@ -933,7 +940,7 @@ sqlite3.h: $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP) > sqlite3.h mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c - $(BCC) -Femkkeywordhash.exe $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)\tool\mkkeywordhash.c + $(BCC) -Fe$@ $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)\tool\mkkeywordhash.c keywordhash.h: $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe .\mkkeywordhash.exe > keywordhash.h @@ -1078,4 +1085,4 @@ sqlite3.def: libsqlite3.lib | sort >> sqlite3.def sqlite3.dll: $(LIBOBJ) sqlite3.def - link $(LTLINKOPTS) $(LTLIBPATHS) /DLL /DEF:sqlite3.def /OUT:$@ $(LIBOBJ) $(LTLIBS) $(TLIBS) + $(LD) $(LDFLAGS) $(LTLINKOPTS) $(LTLIBPATHS) /DLL /DEF:sqlite3.def /OUT:$@ $(LIBOBJ) $(LTLIBS) $(TLIBS) diff --git a/manifest b/manifest index ead73d4c61..248fe642c4 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Make\suse\sof\sthe\spredefined\snmake\scommand\smacro\sCC\swhen\spossible\sinstead\sof\sthe\sliteral\sstring\s'cl.exe'.\s\sImprove\ssupport\sfor\scross-compilation.\s\sEliminate\sproblematic\suse\sof\sdouble\squotes\sin\smacro\spreprocessing\sexpressions. -D 2012-06-30T16:22:05.485 +C Simplify\susage\sof\ssome\slinker\soptions\sin\sthe\sMSVC\smakefile. +D 2012-06-30T19:24:09.458 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc d5fe268f23e35af9a6b8c6c7df983dda65f0a017 +F Makefile.msc 04ebadf5e94d566d4ef9f636416f68e17205120f F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 3b4f5add04259eec145066312bcd532182cc339c -R 437136894c0f887fea4db99bcef8bbec +P 6c88229aa39775a7438befebe1640a30affc72c8 +R 0706037ca6af4d59d9bcb1545687aa13 U mistachkin -Z e6de48dad2c2672c700a9587a09ef1b4 +Z 4412848c1478fd90700fa3f54861d772 diff --git a/manifest.uuid b/manifest.uuid index 486e7319bb..c2ca553335 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6c88229aa39775a7438befebe1640a30affc72c8 \ No newline at end of file +03016020664a7459cb01c8ac9016b20af8a416bb \ No newline at end of file From bd58d5f7a38dca22c1c2abc2942aad5a1fe13d99 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 30 Jun 2012 22:22:34 +0000 Subject: [PATCH 27/69] Setup the necessary library paths for cross-compilation with MSVC. FossilOrigin-Name: 7fac56ed9feda819e66070bd5e06db8cad77e8bd --- Makefile.msc | 62 ++++++++++++++++++++++++++++++++++++++++++--------- manifest | 12 +++++----- manifest.uuid | 2 +- 3 files changed, 58 insertions(+), 18 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index c5feb9d0ed..e16ced35e4 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -19,6 +19,11 @@ USE_ICU = 0 # USE_CRT_DLL = 0 +# Set this non-0 to use the native libraries paths for cross-compiling +# the command line tools needed during the compilation process. +# +USE_NATIVE_LIBPATHS = 0 + # Set this non-0 to compile binaries suitable for the WinRT environment. # This setting does not apply to any binaries that require Tcl to operate # properly (i.e. the text fixture, etc). @@ -43,7 +48,7 @@ SYMBOLS = 1 DEBUG = 0 # Check for the predefined command macro CC. This should point to the compiler -# binary for the target platform. If it does not exist, simply define it to +# binary for the target platform. If it is not defined, simply define it to # the legacy default value 'cl.exe'. # !IFNDEF CC @@ -51,7 +56,7 @@ CC = cl.exe !ENDIF # Check for the command macro LD. This should point to the linker binary for -# the target platform. If it does not exist, simply define it to the legacy +# the target platform. If it is not defined, simply define it to the legacy # default value 'link.exe'. # !IFNDEF LD @@ -59,25 +64,53 @@ LD = link.exe !ENDIF # Check for the command macro NCC. This should point to the compiler binary -# for the platform the compilation process is taking place on. If it does not -# exist, simply define it to have the same value as the CC macro. When +# for the platform the compilation process is taking place on. If it is not +# defined, simply define it to have the same value as the CC macro. When # cross-compiling, it is suggested that this macro be modified via the command # line (since nmake itself does not provide a built-in method to guess it). # For example, to use the x86 compiler when cross-compiling for x64, a command -# line similar to the following could be used: +# line similar to the following could be used (all on one line): # -# nmake /f Makefile.msc "NCC=""%VCINSTALLDIR%\bin\cl.exe""" +# nmake /f Makefile.msc +# "NCC=""%VCINSTALLDIR%\bin\cl.exe""" +# USE_NATIVE_LIBPATHS=1 # !IFNDEF NCC NCC = $(CC) !ENDIF -# C Compiler and options for use in building executables that +# Check for the MSVC runtime library path macro. Othertise, this +# value will default to the 'lib' directory underneath the MSVC +# installation directory. +# +!IFNDEF NCRTLIBPATH +NCRTLIBPATH = $(VCINSTALLDIR)\lib +!ENDIF + +# Check for the Platform SDK library path macro. Othertise, this +# value will default to the 'lib' directory underneath the Windows +# SDK installation directory (the environment variable used appears +# to be available when using Visual C++ 2008 or later via the +# command line). +# +!IFNDEF NSDKLIBPATH +NSDKLIBPATH = $(WINDOWSSDKDIR)\lib +!ENDIF + +# C compiler and options for use in building executables that # will run on the platform that is doing the build. # BCC = $(NCC) -W3 -# C Compile and options for use in building executables that +# Check if the native library paths should be used when compiling +# the command line tools used during the compilation process. If +# so, set the necessary macro now. +# +!IF $(USE_NATIVE_LIBPATHS)!=0 +NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)" +!ENDIF + +# C compiler and options for use in building executables that # will run on the target platform. (BCC and TCC are usually the # same unless your are cross-compiling.) # @@ -142,11 +175,18 @@ TCC = $(TCC) -DSQLITE_ENABLE_IOTRACE !ENDIF # -# Prevent warnings about "insecure" runtime library functions being used. +# Prevent warnings about "insecure" MSVC runtime library functions +# being used. # TCC = $(TCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS BCC = $(BCC) -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS +# +# Prevent warnings about "deprecated" POSIX functions being used. +# +TCC = $(TCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS +BCC = $(BCC) -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS + # # Use native Win32 heap instead of malloc/free? # @@ -684,7 +724,7 @@ lempar.c: $(TOP)\src\lempar.c copy $(TOP)\src\lempar.c . lemon.exe: $(TOP)\tool\lemon.c lempar.c - $(BCC) -Fe$@ $(TOP)\tool\lemon.c + $(BCC) -Daccess=_access -Fe$@ $(TOP)\tool\lemon.c /link $(NLTLIBPATHS) # Rules to build individual *.lo files from generated *.c files. This # applies to: @@ -940,7 +980,7 @@ sqlite3.h: $(TOP)\src\sqlite.h.in $(TOP)\manifest.uuid $(TOP)\VERSION $(TCLSH_CMD) $(TOP)\tool\mksqlite3h.tcl $(TOP) > sqlite3.h mkkeywordhash.exe: $(TOP)\tool\mkkeywordhash.c - $(BCC) -Fe$@ $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)\tool\mkkeywordhash.c + $(BCC) -Fe$@ $(OPT_FEATURE_FLAGS) $(OPTS) $(TOP)\tool\mkkeywordhash.c /link $(NLTLIBPATHS) keywordhash.h: $(TOP)\tool\mkkeywordhash.c mkkeywordhash.exe .\mkkeywordhash.exe > keywordhash.h diff --git a/manifest b/manifest index 248fe642c4..f2ab12f8b8 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Simplify\susage\sof\ssome\slinker\soptions\sin\sthe\sMSVC\smakefile. -D 2012-06-30T19:24:09.458 +C Setup\sthe\snecessary\slibrary\spaths\sfor\scross-compilation\swith\sMSVC. +D 2012-06-30T22:22:34.095 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 04ebadf5e94d566d4ef9f636416f68e17205120f +F Makefile.msc 56ff0fcc3fc3b275aec7f6acb34b3c0526c684bc F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 6c88229aa39775a7438befebe1640a30affc72c8 -R 0706037ca6af4d59d9bcb1545687aa13 +P 03016020664a7459cb01c8ac9016b20af8a416bb +R 3838aec4be451692e3019372e4566300 U mistachkin -Z 4412848c1478fd90700fa3f54861d772 +Z 6999152625f8f616344bc02a959eabf4 diff --git a/manifest.uuid b/manifest.uuid index c2ca553335..d46c3a3f2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -03016020664a7459cb01c8ac9016b20af8a416bb \ No newline at end of file +7fac56ed9feda819e66070bd5e06db8cad77e8bd \ No newline at end of file From 2deb165f4b07bbac98e6ce4b4e983073dd9ff6a3 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 13 Jul 2012 16:15:20 +0000 Subject: [PATCH 28/69] Update test_spellfix.c with latest changes. FossilOrigin-Name: cba2a65870481df213e006b07e74f0ca19d2d57c --- manifest | 16 +- manifest.uuid | 2 +- src/test8.c | 30 +- src/test_spellfix.c | 1461 +++++++++++++++++++++++++++++++++++++------ 4 files changed, 1322 insertions(+), 187 deletions(-) diff --git a/manifest b/manifest index f2ab12f8b8..4901be8cae 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Setup\sthe\snecessary\slibrary\spaths\sfor\scross-compilation\swith\sMSVC. -D 2012-06-30T22:22:34.095 +C Update\stest_spellfix.c\swith\slatest\schanges. +D 2012-07-13T16:15:20.128 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -192,7 +192,7 @@ F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 F src/test6.c 417e1e214734393c24a8ee80b41485a9c4169123 F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 -F src/test8.c 235f1d19716fa768c46fc461ccbf529b2c9e4399 +F src/test8.c c4bcd39c9b157a28f5c4efefbb6bb1174037cace F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e @@ -221,7 +221,7 @@ F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f -F src/test_spellfix.c 495535f3eb57acdc384572da570e869bb1834bf4 +F src/test_spellfix.c 1de8d8c086efa50bb6660ea5988e8630ef9144aa F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 03016020664a7459cb01c8ac9016b20af8a416bb -R 3838aec4be451692e3019372e4566300 -U mistachkin -Z 6999152625f8f616344bc02a959eabf4 +P 7fac56ed9feda819e66070bd5e06db8cad77e8bd +R 8322d35d4441c91cd733d64b44bd2f2e +U dan +Z 4817f8644451c5f84c464c55e7d56257 diff --git a/manifest.uuid b/manifest.uuid index d46c3a3f2a..45760e0dc2 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7fac56ed9feda819e66070bd5e06db8cad77e8bd \ No newline at end of file +cba2a65870481df213e006b07e74f0ca19d2d57c \ No newline at end of file diff --git a/src/test8.c b/src/test8.c index 372eef664a..5ee62961f8 100644 --- a/src/test8.c +++ b/src/test8.c @@ -1370,6 +1370,31 @@ static int declare_vtab( return TCL_OK; } +#include "test_spellfix.c" + +/* +** Register the spellfix virtual table module. +*/ +static int register_spellfix_module( + ClientData clientData, + Tcl_Interp *interp, + int objc, + Tcl_Obj *CONST objv[] +){ + static sqlite3_module aMod[3]; + int iMod; + sqlite3 *db; + + if( objc!=2 ){ + Tcl_WrongNumArgs(interp, 1, objv, "DB"); + return TCL_ERROR; + } + if( getDbPointer(interp, Tcl_GetString(objv[1]), &db) ) return TCL_ERROR; + + sqlite3Spellfix1Register(db); + return TCL_OK; +} + #endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */ /* @@ -1382,8 +1407,9 @@ int Sqlitetest8_Init(Tcl_Interp *interp){ Tcl_ObjCmdProc *xProc; void *clientData; } aObjCmd[] = { - { "register_echo_module", register_echo_module, 0 }, - { "sqlite3_declare_vtab", declare_vtab, 0 }, + { "register_echo_module", register_echo_module, 0 }, + { "register_spellfix_module", register_spellfix_module, 0 }, + { "sqlite3_declare_vtab", declare_vtab, 0 }, }; int i; for(i=0; i /* ** Character classes for ASCII characters: @@ -295,13 +296,14 @@ ** 3 'C' Other fricatives or back stops: C G J K Q S X Z ** 4 'D' Alveolar stops: D T ** 5 'H' Letter H at the beginning of a word -** 6 'L' Glides: L R -** 7 'M' Nasals: M N -** 8 'W' Letter W at the beginning of a word -** 9 'Y' Letter Y at the beginning of a word. -** 10 '9' A digit: 0 1 2 3 4 5 6 7 8 9 -** 11 ' ' White space -** 12 '?' Other. +** 6 'L' Glide: L +** 7 'R' Semivowel: R +** 8 'M' Nasals: M N +** 9 'W' Letter W at the beginning of a word +** 10 'Y' Letter Y at the beginning of a word. +** 11 '9' A digit: 0 1 2 3 4 5 6 7 8 9 +** 12 ' ' White space +** 13 '?' Other. */ #define CCLASS_SILENT 0 #define CCLASS_VOWEL 1 @@ -310,76 +312,177 @@ #define CCLASS_D 4 #define CCLASS_H 5 #define CCLASS_L 6 -#define CCLASS_M 7 -#define CCLASS_W 8 -#define CCLASS_Y 9 -#define CCLASS_DIGIT 10 -#define CCLASS_SPACE 11 -#define CCLASS_OTHER 12 +#define CCLASS_R 7 +#define CCLASS_M 8 +#define CCLASS_W 9 +#define CCLASS_Y 10 +#define CCLASS_DIGIT 11 +#define CCLASS_SPACE 12 +#define CCLASS_OTHER 13 /* ** The following table gives the character class for non-initial ASCII ** characters. */ static const unsigned char midClass[] = { - /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ - /* 0x */ 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 12, 11, 12, 12, 12, - /* 1x */ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - /* 2x */ 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - /* 3x */ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, - /* 4x */ 12, 1, 2, 3, 4, 1, 2, 3, 0, 1, 3, 3, 6, 7, 7, 1, - /* 5x */ 2, 3, 6, 3, 4, 1, 2, 0, 3, 1, 3, 12, 12, 12, 12, 12, - /* 6x */ 12, 1, 2, 3, 4, 1, 2, 3, 0, 1, 3, 3, 6, 7, 7, 1, - /* 7x */ 2, 3, 6, 3, 4, 1, 2, 0, 3, 1, 3, 12, 12, 12, 12, 12, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_SPACE, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_SPACE, /* */ CCLASS_SPACE, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_SPACE, + /* ! */ CCLASS_OTHER, /* " */ CCLASS_OTHER, /* # */ CCLASS_OTHER, + /* $ */ CCLASS_OTHER, /* % */ CCLASS_OTHER, /* & */ CCLASS_OTHER, + /* ' */ CCLASS_SILENT, /* ( */ CCLASS_OTHER, /* ) */ CCLASS_OTHER, + /* * */ CCLASS_OTHER, /* + */ CCLASS_OTHER, /* , */ CCLASS_OTHER, + /* - */ CCLASS_OTHER, /* . */ CCLASS_OTHER, /* / */ CCLASS_OTHER, + /* 0 */ CCLASS_DIGIT, /* 1 */ CCLASS_DIGIT, /* 2 */ CCLASS_DIGIT, + /* 3 */ CCLASS_DIGIT, /* 4 */ CCLASS_DIGIT, /* 5 */ CCLASS_DIGIT, + /* 6 */ CCLASS_DIGIT, /* 7 */ CCLASS_DIGIT, /* 8 */ CCLASS_DIGIT, + /* 9 */ CCLASS_DIGIT, /* : */ CCLASS_OTHER, /* ; */ CCLASS_OTHER, + /* < */ CCLASS_OTHER, /* = */ CCLASS_OTHER, /* > */ CCLASS_OTHER, + /* ? */ CCLASS_OTHER, /* @ */ CCLASS_OTHER, /* A */ CCLASS_VOWEL, + /* B */ CCLASS_B, /* C */ CCLASS_C, /* D */ CCLASS_D, + /* E */ CCLASS_VOWEL, /* F */ CCLASS_B, /* G */ CCLASS_C, + /* H */ CCLASS_SILENT, /* I */ CCLASS_VOWEL, /* J */ CCLASS_C, + /* K */ CCLASS_C, /* L */ CCLASS_L, /* M */ CCLASS_M, + /* N */ CCLASS_M, /* O */ CCLASS_VOWEL, /* P */ CCLASS_B, + /* Q */ CCLASS_C, /* R */ CCLASS_R, /* S */ CCLASS_C, + /* T */ CCLASS_D, /* U */ CCLASS_VOWEL, /* V */ CCLASS_B, + /* W */ CCLASS_SILENT, /* X */ CCLASS_C, /* Y */ CCLASS_VOWEL, + /* Z */ CCLASS_C, /* [ */ CCLASS_OTHER, /* \ */ CCLASS_OTHER, + /* ] */ CCLASS_OTHER, /* ^ */ CCLASS_OTHER, /* _ */ CCLASS_OTHER, + /* ` */ CCLASS_OTHER, /* a */ CCLASS_VOWEL, /* b */ CCLASS_B, + /* c */ CCLASS_C, /* d */ CCLASS_D, /* e */ CCLASS_VOWEL, + /* f */ CCLASS_B, /* g */ CCLASS_C, /* h */ CCLASS_SILENT, + /* i */ CCLASS_VOWEL, /* j */ CCLASS_C, /* k */ CCLASS_C, + /* l */ CCLASS_L, /* m */ CCLASS_M, /* n */ CCLASS_M, + /* o */ CCLASS_VOWEL, /* p */ CCLASS_B, /* q */ CCLASS_C, + /* r */ CCLASS_R, /* s */ CCLASS_C, /* t */ CCLASS_D, + /* u */ CCLASS_VOWEL, /* v */ CCLASS_B, /* w */ CCLASS_SILENT, + /* x */ CCLASS_C, /* y */ CCLASS_VOWEL, /* z */ CCLASS_C, + /* { */ CCLASS_OTHER, /* | */ CCLASS_OTHER, /* } */ CCLASS_OTHER, + /* ~ */ CCLASS_OTHER, /* */ CCLASS_OTHER, }; - /* ** This tables gives the character class for ASCII characters that form the ** initial character of a word. The only difference from midClass is with ** the letters H, W, and Y. */ static const unsigned char initClass[] = { - /* x0 x1 x2 x3 x4 x5 x6 x7 x8 x9 xa xb xc xd xe xf */ - /* 0x */ 12, 12, 12, 12, 12, 12, 12, 12, 12, 11, 11, 12, 11, 12, 12, 12, - /* 1x */ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - /* 2x */ 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, - /* 3x */ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 12, - /* 4x */ 12, 1, 2, 3, 4, 1, 2, 3, 5, 1, 3, 3, 6, 7, 7, 1, - /* 5x */ 2, 3, 6, 3, 4, 1, 2, 8, 3, 9, 3, 12, 12, 12, 12, 12, - /* 6x */ 12, 1, 2, 3, 4, 1, 2, 3, 5, 1, 3, 3, 6, 7, 7, 1, - /* 7x */ 2, 3, 6, 3, 4, 1, 2, 8, 3, 9, 3, 12, 12, 12, 12, 12, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_SPACE, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_SPACE, /* */ CCLASS_SPACE, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, + /* */ CCLASS_OTHER, /* */ CCLASS_OTHER, /* */ CCLASS_SPACE, + /* ! */ CCLASS_OTHER, /* " */ CCLASS_OTHER, /* # */ CCLASS_OTHER, + /* $ */ CCLASS_OTHER, /* % */ CCLASS_OTHER, /* & */ CCLASS_OTHER, + /* ' */ CCLASS_OTHER, /* ( */ CCLASS_OTHER, /* ) */ CCLASS_OTHER, + /* * */ CCLASS_OTHER, /* + */ CCLASS_OTHER, /* , */ CCLASS_OTHER, + /* - */ CCLASS_OTHER, /* . */ CCLASS_OTHER, /* / */ CCLASS_OTHER, + /* 0 */ CCLASS_DIGIT, /* 1 */ CCLASS_DIGIT, /* 2 */ CCLASS_DIGIT, + /* 3 */ CCLASS_DIGIT, /* 4 */ CCLASS_DIGIT, /* 5 */ CCLASS_DIGIT, + /* 6 */ CCLASS_DIGIT, /* 7 */ CCLASS_DIGIT, /* 8 */ CCLASS_DIGIT, + /* 9 */ CCLASS_DIGIT, /* : */ CCLASS_OTHER, /* ; */ CCLASS_OTHER, + /* < */ CCLASS_OTHER, /* = */ CCLASS_OTHER, /* > */ CCLASS_OTHER, + /* ? */ CCLASS_OTHER, /* @ */ CCLASS_OTHER, /* A */ CCLASS_VOWEL, + /* B */ CCLASS_B, /* C */ CCLASS_C, /* D */ CCLASS_D, + /* E */ CCLASS_VOWEL, /* F */ CCLASS_B, /* G */ CCLASS_C, + /* H */ CCLASS_SILENT, /* I */ CCLASS_VOWEL, /* J */ CCLASS_C, + /* K */ CCLASS_C, /* L */ CCLASS_L, /* M */ CCLASS_M, + /* N */ CCLASS_M, /* O */ CCLASS_VOWEL, /* P */ CCLASS_B, + /* Q */ CCLASS_C, /* R */ CCLASS_R, /* S */ CCLASS_C, + /* T */ CCLASS_D, /* U */ CCLASS_VOWEL, /* V */ CCLASS_B, + /* W */ CCLASS_W, /* X */ CCLASS_C, /* Y */ CCLASS_Y, + /* Z */ CCLASS_C, /* [ */ CCLASS_OTHER, /* \ */ CCLASS_OTHER, + /* ] */ CCLASS_OTHER, /* ^ */ CCLASS_OTHER, /* _ */ CCLASS_OTHER, + /* ` */ CCLASS_OTHER, /* a */ CCLASS_VOWEL, /* b */ CCLASS_B, + /* c */ CCLASS_C, /* d */ CCLASS_D, /* e */ CCLASS_VOWEL, + /* f */ CCLASS_B, /* g */ CCLASS_C, /* h */ CCLASS_SILENT, + /* i */ CCLASS_VOWEL, /* j */ CCLASS_C, /* k */ CCLASS_C, + /* l */ CCLASS_L, /* m */ CCLASS_M, /* n */ CCLASS_M, + /* o */ CCLASS_VOWEL, /* p */ CCLASS_B, /* q */ CCLASS_C, + /* r */ CCLASS_R, /* s */ CCLASS_C, /* t */ CCLASS_D, + /* u */ CCLASS_VOWEL, /* v */ CCLASS_B, /* w */ CCLASS_W, + /* x */ CCLASS_C, /* y */ CCLASS_Y, /* z */ CCLASS_C, + /* { */ CCLASS_OTHER, /* | */ CCLASS_OTHER, /* } */ CCLASS_OTHER, + /* ~ */ CCLASS_OTHER, /* */ CCLASS_OTHER, }; /* -** Mapping from the character class number (0-12) to a symbol for each +** Mapping from the character class number (0-13) to a symbol for each ** character class. Note that initClass[] can be used to map the class ** symbol back into the class number. */ -static const unsigned char className[] = ".ABCDHLMWY9 ?"; +static const unsigned char className[] = ".ABCDHLRMWY9 ?"; /* -** Generate a string of character classes corresponding to the -** ASCII characters in the input string zIn. If the input is not -** ASCII then the behavior is undefined. +** Generate a "phonetic hash" from a string of ASCII characters +** in zIn[0..nIn-1]. +** +** * Map characters by character class as defined above. +** * Omit double-letters +** * Omit vowels beside R and L +** * Omit T when followed by CH +** * Omit W when followed by R +** * Omit D when followed by J or G +** * Omit K in KN or G in GN at the beginning of a word ** ** Space to hold the result is obtained from sqlite3_malloc() ** ** Return NULL if memory allocation fails. */ -static unsigned char *characterClassString(const unsigned char *zIn, int nIn){ +static unsigned char *phoneticHash(const unsigned char *zIn, int nIn){ unsigned char *zOut = sqlite3_malloc( nIn + 1 ); int i; int nOut = 0; char cPrev = 0x77; + char cPrevX = 0x77; const unsigned char *aClass = initClass; if( zOut==0 ) return 0; + if( nIn>2 ){ + switch( zIn[0] ){ + case 'g': + case 'k': { + if( zIn[1]=='n' ){ zIn++; nIn--; } + break; + } + } + } + if( zIn[0]=='k' && zIn[1]=='n' ){ zIn++, nIn--; } for(i=0; icB */ subCost = substituteCost(cx[xB-1], cA, cB); @@ -624,9 +734,9 @@ static int editdist(const char *zA, const char *zB){ } /* Free the wagner matrix and return the result */ - if( cA=='*' && nB>nA ){ - res = m[nA]; - for(xB=nA+1; xB<=nB; xB++){ + if( cA=='*' ){ + res = m[1]; + for(xB=1; xB<=nB; xB++){ if( m[xB]nLang; i++){ + EditDist3Cost *pCost, *pNext; + pCost = p->a[i].pCost; + while( pCost ){ + pNext = pCost->pNext; + sqlite3_free(pCost); + pCost = pNext; + } + } + sqlite3_free(p->a); + memset(p, 0, sizeof(*p)); +} +static void editDist3ConfigDelete(void *pIn){ + EditDist3Config *p = (EditDist3Config*)pIn; + editDist3ConfigClear(p); + sqlite3_free(p); +} + +/* +** Load all edit-distance weights from a table. +*/ +static int editDist3ConfigLoad( + EditDist3Config *p, /* The edit distance configuration to load */ + sqlite3 *db, /* Load from this database */ + const char *zTable /* Name of the table from which to load */ +){ + sqlite3_stmt *pStmt; + int rc; + char *zSql; + int iLangPrev = -9999; + EditDist3Lang *pLang; + + zSql = sqlite3_mprintf("SELECT iLang, cFrom, cTo, iCost" + " FROM \"%w\" WHERE iLang>=0 ORDER BY iLang", zTable); + if( zSql==0 ) return SQLITE_NOMEM; + rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0); + sqlite3_free(zSql); + if( rc ) return rc; + editDist3ConfigClear(p); + while( sqlite3_step(pStmt)==SQLITE_ROW ){ + int iLang = sqlite3_column_int(pStmt, 0); + const char *zFrom = (const char*)sqlite3_column_text(pStmt, 1); + int nFrom = sqlite3_column_bytes(pStmt, 1); + const char *zTo = (const char*)sqlite3_column_text(pStmt, 2); + int nTo = sqlite3_column_bytes(pStmt, 2); + int iCost = sqlite3_column_int(pStmt, 3); + + if( nFrom>100 || nFrom<0 || nTo>100 || nTo<0 ) continue; + if( iCost<0 ) continue; + if( iLang!=iLangPrev ){ + EditDist3Lang *pNew; + p->nLang++; + pNew = sqlite3_realloc(p->a, p->nLang*sizeof(p->a[0])); + if( pNew==0 ){ rc = SQLITE_NOMEM; break; } + p->a = pNew; + pLang = &p->a[p->nLang-1]; + pLang->iLang = iLang; + pLang->iInsCost = 100; + pLang->iDelCost = 100; + pLang->iSubCost = 200; + pLang->pCost = 0; + iLangPrev = iLang; + } + if( nFrom==1 && zFrom[0]=='?' && nTo==0 ){ + pLang->iDelCost = iCost; + }else if( nFrom==0 && nTo==1 && zTo[0]=='?' ){ + pLang->iInsCost = iCost; + }else if( nFrom==1 && nTo==1 && zFrom[0]=='?' && zTo[0]=='?' ){ + pLang->iSubCost = iCost; + }else{ + EditDist3Cost *pCost; + int nExtra = nFrom + nTo - 4; + if( nExtra<0 ) nExtra = 0; + pCost = sqlite3_malloc( sizeof(*pCost) + nExtra ); + if( pCost==0 ){ rc = SQLITE_NOMEM; break; } + pCost->nFrom = nFrom; + pCost->nTo = nTo; + pCost->iCost = iCost; + memcpy(pCost->a, zFrom, nFrom); + memcpy(pCost->a + nFrom, zTo, nTo); + pCost->pNext = pLang->pCost; + pLang->pCost = pCost; + } + } + sqlite3_finalize(pStmt); + return rc; +} + +/* +** Return the length (in bytes) of a utf-8 character. Or return a maximum +** of N. +*/ +static int utf8Len(unsigned char c, int N){ + int len = 1; + if( c>0x7f ){ + if( (c&0xe0)==0xc0 ){ + len = 2; + }else if( (c&0xf0)==0xe0 ){ + len = 3; + }else{ + len = 4; + } + } + if( len>N ) len = N; + return len; +} + +/* +** Return TRUE (non-zero) of the To side of the given cost matches +** the given string. +*/ +static int matchTo(EditDist3Cost *p, const char *z, int n){ + if( p->nTo>n ) return 0; + if( memcmp(p->a+p->nFrom, z, p->nTo)!=0 ) return 0; + return 1; +} + +/* +** Return TRUE (non-zero) of the To side of the given cost matches +** the given string. +*/ +static int matchFrom(EditDist3Cost *p, const char *z, int n){ + if( p->nFrom>n ) return 0; + if( memcmp(p->a, z, p->nFrom)!=0 ) return 0; + return 1; +} + +/* +** Return TRUE (non-zero) of the next FROM character and the next TO +** character are the same. +*/ +static int matchFromTo( + EditDist3FromString *pStr, /* Left hand string */ + int n1, /* Index of comparison character on the left */ + const char *z2, /* Right-handl comparison character */ + int n2 /* Bytes remaining in z2[] */ +){ + int b1 = pStr->a[n1].nByte; + if( b1>n2 ) return 0; + if( memcmp(pStr->z+n1, z2, b1)!=0 ) return 0; + return 1; +} + +/* +** Delete an EditDist3FromString objecct +*/ +static void editDist3FromStringDelete(EditDist3FromString *p){ + int i; + if( p ){ + for(i=0; in; i++){ + sqlite3_free(p->a[i].apDel); + sqlite3_free(p->a[i].apSubst); + } + sqlite3_free(p); + } +} + +/* +** Create a EditDist3FromString object. +*/ +static EditDist3FromString *editDist3FromStringNew( + const EditDist3Lang *pLang, + const char *z, + int n +){ + EditDist3FromString *pStr; + EditDist3Cost *p; + int i; + + if( n<0 ) n = (int)strlen(z); + pStr = sqlite3_malloc( sizeof(*pStr) + sizeof(pStr->a[0])*n + n + 1 ); + if( pStr==0 ) return 0; + pStr->a = (EditDist3From*)&pStr[1]; + pStr->n = n; + pStr->z = (char*)&pStr->a[n]; + memcpy(pStr->z, z, n+1); + if( n && z[n-1]=='*' ){ + pStr->isPrefix = 1; + n--; + pStr->n--; + pStr->z[n] = 0; + }else{ + pStr->isPrefix = 0; + } + + for(i=0; ia[i]; + memset(pFrom, 0, sizeof(*pFrom)); + pFrom->nByte = utf8Len((unsigned char)z[i], n-i); + for(p=pLang->pCost; p; p=p->pNext){ + EditDist3Cost **apNew; + if( i+p->nFrom>n ) continue; + if( matchFrom(p, z+i, n-i)==0 ) continue; + if( p->nTo==0 ){ + apNew = sqlite3_realloc(pFrom->apDel, + sizeof(*apNew)*(pFrom->nDel+1)); + if( apNew==0 ) break; + pFrom->apDel = apNew; + apNew[pFrom->nDel++] = p; + }else{ + apNew = sqlite3_realloc(pFrom->apSubst, + sizeof(*apNew)*(pFrom->nSubst+1)); + if( apNew==0 ) break; + pFrom->apSubst = apNew; + apNew[pFrom->nSubst++] = p; + } + } + if( p ){ + editDist3FromStringDelete(pStr); + pStr = 0; + break; + } + } + return pStr; +} + +/* +** Return the number of bytes in the common prefix of two UTF8 strings. +** Only complete characters are considered. +*/ +static int editDist3PrefixLen(const char *z1, const char *z2){ + int n = 0; + while( z1[n] && z1[n]==z2[n] ){ n++; } + while( n && (z1[n]&0xc0)==0x80 ){ n--; } + return n; +} + +/* +** Return the number of bytes in the common suffix of two UTF8 strings. +** Only complete characters are considered. +*/ +static int editDist3SuffixLen(const char *z1, int n1, const char *z2, int n2){ + int origN1 = n1; + while( n1>0 && n2>0 && z1[n1-1]==z2[n2-1] ){ n1--; n2--; } + while( n1pCost; p; p=p->pNext){ + EditDist3Cost **apNew; + if( p->nFrom>0 ) continue; + if( i2+p->nTo>n2 ) continue; + if( matchTo(p, z2+i2, n2-i2)==0 ) continue; + a2[i2].nIns++; + apNew = sqlite3_realloc(a2[i2].apIns, sizeof(*apNew)*a2[i2].nIns); + if( apNew==0 ){ + res = -1; /* Out of memory */ + goto editDist3Abort; + } + a2[i2].apIns = apNew; + a2[i2].apIns[a2[i2].nIns-1] = p; + } + } + + /* Prepare to compute the minimum edit distance */ + szRow = f.n+1; + memset(m, 0x01, (n2+1)*szRow*sizeof(m[0])); + m[0] = 0; + + /* First fill in the top-row of the matrix with FROM deletion costs */ + for(i1=0; i1iDelCost); + for(k=0; knFrom, i1, p->iCost); + } + } + + /* Fill in all subsequent rows, top-to-bottom, left-to-right */ + for(i2=0; i2iInsCost); + for(k=0; knTo), rxp, p->iCost); + } + for(i1=0; i1iDelCost); + for(k=0; knFrom, cxp, p->iCost); + } + updateCost(m, cx, cxu, pLang->iInsCost); + if( matchFromTo(&f, i1, z2+i2, n2-i2) ){ + updateCost(m, cx, cxd, 0); + } + updateCost(m, cx, cxd, pLang->iSubCost); + for(k=0; knFrom+szRow*p->nTo, cxd, p->iCost); + } + } + } + } + +#if 0 + printf(" ^"); + for(i1=0; i19999 ) printf(" ****"); + else printf(" %4d", v); + } + printf("\n"); + for(i2=0; i29999 ) printf(" ****"); + else printf(" %4d", v); + } + printf("\n"); + } +#endif + + /* Free memory allocations and return the result */ + res = (int)m[szRow*(n2+1)-1]; + if( f.isPrefix ){ + for(i2=f.n; i2nLang; i++){ + if( pConfig->a[i].iLang==iLang ) return &pConfig->a[i]; + } + return &editDist3Lang; +} + +/* +** Function: editdist3(A,B,iLang) +** editdist3(tablename) +** +** Return the cost of transforming string A into string B using edit +** weights for iLang. +** +** The second form loads edit weights into memory from a table. +*/ +static void editDist3SqlFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + EditDist3Config *pConfig = (EditDist3Config*)sqlite3_user_data(context); + sqlite3 *db = sqlite3_context_db_handle(context); + int rc; + if( argc==1 ){ + const char *zTable = (const char*)sqlite3_value_text(argv[0]); + rc = editDist3ConfigLoad(pConfig, db, zTable); + if( rc ) sqlite3_result_error_code(context, rc); + }else{ + const char *zA = (const char*)sqlite3_value_text(argv[0]); + const char *zB = (const char*)sqlite3_value_text(argv[1]); + int nA = sqlite3_value_bytes(argv[0]); + int nB = sqlite3_value_bytes(argv[1]); + int iLang = argc==3 ? sqlite3_value_int(argv[2]) : 0; + const EditDist3Lang *pLang = editDist3FindLang(pConfig, iLang); + EditDist3FromString *pFrom; + int dist; + + pFrom = editDist3FromStringNew(pLang, zA, nA); + if( pFrom==0 ){ + sqlite3_result_error_nomem(context); + return; + } + dist = editDist3Core(pFrom, zB, nB, pLang); + editDist3FromStringDelete(pFrom); + sqlite3_result_int(context, dist); + } +} + +/* +** Register the editDist3 function with SQLite +*/ +static int editDist3Install(sqlite3 *db){ + int rc; + EditDist3Config *pConfig = sqlite3_malloc( sizeof(*pConfig) ); + if( pConfig==0 ) return SQLITE_NOMEM; + memset(pConfig, 0, sizeof(*pConfig)); + rc = sqlite3_create_function_v2(db, "editdist3", + 2, SQLITE_UTF8, pConfig, editDist3SqlFunc, 0, 0, 0); + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function_v2(db, "editdist3", + 3, SQLITE_UTF8, pConfig, editDist3SqlFunc, 0, 0, 0); + } + if( rc==SQLITE_OK ){ + rc = sqlite3_create_function_v2(db, "editdist3", + 1, SQLITE_UTF8, pConfig, editDist3SqlFunc, 0, 0, + editDist3ConfigDelete); + }else{ + sqlite3_free(pConfig); + } + return rc; +} +/* End configurable cost unicode edit distance routines +****************************************************************************** +****************************************************************************** +** Begin transliterate unicode-to-ascii implementation +*/ + +#if !SQLITE_AMALGAMATION /* ** This lookup table is used to help decode the first byte of ** a multi-byte UTF8 character. @@ -1018,7 +1733,9 @@ static const struct { { 0x0427, 0x43, 0x68 }, /* Ч to Ch */ { 0x0428, 0x53, 0x68 }, /* Ш to Sh */ { 0x0429, 0x53, 0x68 }, /* Щ to Shch */ + { 0x042A, 0x61, 0x00 }, /* to A */ { 0x042B, 0x59, 0x00 }, /* Ы to Y */ + { 0x042C, 0x59, 0x00 }, /* to Y */ { 0x042D, 0x45, 0x00 }, /* Э to E */ { 0x042E, 0x49, 0x75 }, /* Ю to Iu */ { 0x042F, 0x49, 0x61 }, /* Я to Ia */ @@ -1048,7 +1765,9 @@ static const struct { { 0x0447, 0x63, 0x68 }, /* ч to ch */ { 0x0448, 0x73, 0x68 }, /* ш to sh */ { 0x0449, 0x73, 0x68 }, /* щ to shch */ + { 0x044A, 0x61, 0x00 }, /* to a */ { 0x044B, 0x79, 0x00 }, /* ы to y */ + { 0x044C, 0x79, 0x00 }, /* to y */ { 0x044D, 0x65, 0x00 }, /* э to e */ { 0x044E, 0x69, 0x75 }, /* ю to iu */ { 0x044F, 0x69, 0x61 }, /* я to ia */ @@ -1222,25 +1941,157 @@ static void scriptCodeSqlFunc( sqlite3_result_int(context, res); } -/***************************************************************************** -** Fuzzy-search virtual table -*****************************************************************************/ +/* End transliterate +****************************************************************************** +****************************************************************************** +** Begin Polloc & Zamora SPEEDCOP style keying functions. +*/ +/* +** The Pollock & Zamora skeleton function. Move all consonants to the +** front and all vowels to the end, removing duplicates. Except if the +** first letter is a vowel then it remains as the first letter. +*/ +static void pollockSkeletonKey(const char *zIn, char *zOut){ + int i, j; + unsigned char c; + char seen[26]; + static const unsigned char isVowel[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }; + memset(seen, 0, sizeof(seen)); + for(i=j=0; (c = (unsigned char)zIn[i])!=0; i++){ + if( c<'a' || c>'z' ) continue; + if( j>0 || isVowel[c-'a'] ) continue; + if( seen[c-'a'] ) continue; + seen[c-'a'] = 1; + zOut[j++] = c; + } + for(i=0; (c = (unsigned char)zIn[i])!=0; i++){ + if( c<'a' || c>'z' ) continue; + if( seen[c-'a'] ) continue; + if( !isVowel[c-'a'] ) continue; + seen[c-'a'] = 1; + zOut[j++] = c; + } + zOut[j] = 0; +} + +/* +** Function: pollock_skeleton(X) +** +** Return the Pollock and Zamora skeleton key for a string X of all +** lower-case letters. +*/ +static void pollockSkeletonSqlFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + const char *zIn = (const char*)sqlite3_value_text(argv[0]); + int nIn = sqlite3_value_bytes(argv[0]); + char *zOut; + if( zIn ){ + zOut = sqlite3_malloc( nIn + 1 ); + if( zOut==0 ){ + sqlite3_result_error_nomem(context); + }else{ + pollockSkeletonKey(zIn, zOut); + sqlite3_result_text(context, (char*)zOut, -1, sqlite3_free); + } + } +} + +/* +** The Pollock & Zamora omission key. +** +** The key consists of unique consonants in the following order: +** +** jkqxzvwybfmgpdhclntsr +** +** These are followed by unique vowels in input order. +*/ +static void pollockOmissionKey(const char *zIn, char *zOut){ + int i, j; + unsigned char c; + char seen[26]; + static const unsigned char isVowel[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }; + static const unsigned char constOrder[] = "jkqxzvwybfmgpdhclntsr"; + + memset(seen, 0, sizeof(seen)); + for(i=j=0; (c = (unsigned char)zIn[i])!=0; i++){ + if( c<'a' || c>'z' ) continue; + if( isVowel[c-'a'] ) continue; + if( seen[c-'a'] ) continue; + seen[c-'a'] = 1; + } + for(i=0; (c = constOrder[i])!=0; i++){ + if( seen[c-'a'] ) zOut[j++] = c; + } + for(i=0; (c = (unsigned char)zIn[i])!=0; i++){ + if( c<'a' || c>'z' ) continue; + if( seen[c-'a'] ) continue; + if( !isVowel[c-'a'] ) continue; + seen[c-'a'] = 1; + zOut[j++] = c; + } + zOut[j] = 0; +} + +/* +** Function: pollock_omission(X) +** +** Return the Pollock and Zamora omission key for a string X of all +** lower-case letters. +*/ +static void pollockOmissionSqlFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + const char *zIn = (const char*)sqlite3_value_text(argv[0]); + int nIn = sqlite3_value_bytes(argv[0]); + char *zOut; + if( zIn ){ + zOut = sqlite3_malloc( nIn + 1 ); + if( zOut==0 ){ + sqlite3_result_error_nomem(context); + }else{ + pollockOmissionKey(zIn, zOut); + sqlite3_result_text(context, (char*)zOut, -1, sqlite3_free); + } + } +} + + +/* End SPEEDCOP keying functions +****************************************************************************** +****************************************************************************** +** Begin spellfix1 virtual table. +*/ + +/* Maximum length of a phonehash used for querying the shadow table */ +#define SPELLFIX_MX_HASH 8 + +/* Maximum number of hash strings to examine per query */ +#define SPELLFIX_MX_RUN 8 typedef struct spellfix1_vtab spellfix1_vtab; typedef struct spellfix1_cursor spellfix1_cursor; /* Fuzzy-search virtual table object */ struct spellfix1_vtab { - sqlite3_vtab base; /* Base class - must be first */ - sqlite3 *db; /* Database connection */ - char *zDbName; /* Name of database holding this table */ - char *zTableName; /* Name of the virtual table */ + sqlite3_vtab base; /* Base class - must be first */ + sqlite3 *db; /* Database connection */ + char *zDbName; /* Name of database holding this table */ + char *zTableName; /* Name of the virtual table */ + char *zCostTable; /* Table holding edit-distance cost numbers */ + EditDist3Config *pConfig3; /* Parsed edit distance costs */ }; /* Fuzzy-search cursor object */ struct spellfix1_cursor { sqlite3_vtab_cursor base; /* Base class - must be first */ - spellfix1_vtab *pVTab; /* The table to which this cursor belongs */ + spellfix1_vtab *pVTab; /* The table to which this cursor belongs */ int nRow; /* Number of rows of content */ int nAlloc; /* Number of allocated rows */ int iRow; /* Current row of content */ @@ -1248,12 +2099,13 @@ struct spellfix1_cursor { int iTop; /* Value of the top= constraint */ int iScope; /* Value of the scope= constraint */ int nSearch; /* Number of vocabulary items checked */ - struct spellfix1_row { /* For each row of content */ + struct spellfix1_row { /* For each row of content */ sqlite3_int64 iRowid; /* Rowid for this row */ char *zWord; /* Text for this row */ int iRank; /* Rank for this row */ int iDistance; /* Distance from pattern for this row */ int iScore; /* Score for sorting */ + char zHash[SPELLFIX_MX_HASH]; /* the phonehash used for this match */ } *a; }; @@ -1297,6 +2149,8 @@ static int spellfix1Uninit(int isDestroy, sqlite3_vtab *pVTab){ } if( rc==SQLITE_OK ){ sqlite3_free(p->zTableName); + editDist3ConfigDelete(p->pConfig3); + sqlite3_free(p->zCostTable); sqlite3_free(p); } return rc; @@ -1308,6 +2162,38 @@ static int spellfix1Destroy(sqlite3_vtab *pVTab){ return spellfix1Uninit(1, pVTab); } +/* +** Make a copy of a string. Remove leading and trailing whitespace +** and dequote it. +*/ +static char *spellfix1Dequote(const char *zIn){ + char *zOut; + int i, j; + char c; + while( isspace(zIn[0]) ) zIn++; + zOut = sqlite3_mprintf("%s", zIn); + if( zOut==0 ) return 0; + i = (int)strlen(zOut); + while( i>0 && isspace(zOut[i-1]) ){ i--; } + zOut[i] = 0; + c = zOut[0]; + if( c=='\'' || c=='"' ){ + for(i=1, j=0; zOut[i]; i++){ + zOut[j++] = zOut[i]; + if( zOut[i]==c ){ + if( zOut[i+1]==c ){ + i++; + }else{ + zOut[j-1] = 0; + break; + } + } + } + } + return zOut; +} + + /* ** xConnect/xCreate method for the spellfix1 module. Arguments are: ** @@ -1330,6 +2216,7 @@ static int spellfix1Init( const char *zTableName = argv[2]; int nDbName; int rc = SQLITE_OK; + int i; if( argc<3 ){ *pzErr = sqlite3_mprintf( @@ -1352,9 +2239,20 @@ static int spellfix1Init( }else{ rc = sqlite3_declare_vtab(db, "CREATE TABLE x(word,rank,distance,langid," - "score,top HIDDEN,scope HIDDEN,srchcnt HIDDEN," - "soundslike HIDDEN)" + "score, phonehash,top HIDDEN,scope HIDDEN,srchcnt HIDDEN," + "soundslike HIDDEN,command HIDDEN)" ); +#define SPELLFIX_COL_WORD 0 +#define SPELLFIX_COL_RANK 1 +#define SPELLFIX_COL_DISTANCE 2 +#define SPELLFIX_COL_LANGID 3 +#define SPELLFIX_COL_SCORE 4 +#define SPELLFIX_COL_PHONEHASH 5 +#define SPELLFIX_COL_TOP 6 +#define SPELLFIX_COL_SCOPE 7 +#define SPELLFIX_COL_SRCHCNT 8 +#define SPELLFIX_COL_SOUNDSLIKE 9 +#define SPELLFIX_COL_COMMAND 10 } if( rc==SQLITE_OK && isCreate ){ sqlite3_uint64 r; @@ -1376,6 +2274,14 @@ static int spellfix1Init( zDbName, zModule, r, zTableName ); } + for(i=3; rc==SQLITE_OK && ia[idx].iRowid = sqlite3_column_int64(pStmt, 0); + pCur->a[idx].iRank = iRank; + pCur->a[idx].iDistance = iDist; + pCur->a[idx].iScore = iScore; + memcpy(pCur->a[idx].zHash, zHash1, iScope+1); + if( pCur->nRownAlloc ) pCur->nRow++; + if( pCur->nRow==pCur->nAlloc ){ + iWorst = pCur->a[0].iScore; + idxWorst = 0; + for(i=1; inRow; i++){ + iScore = pCur->a[i].iScore; + if( iWorstpVTab; + const unsigned char *zMatchThis; /* RHS of the MATCH operator */ + EditDist3FromString *pMatchStr3 = 0; /* zMatchThis as an editdist string */ + char *zPattern; /* Transliteration of zMatchThis */ + int nPattern; /* Length of zPattern */ + int iLimit = 20; /* Max number of rows of output */ + int iScope = 3; /* Use this many characters of zClass */ + int iLang = 0; /* Language code */ + char *zSql; /* SQL of shadow table query */ + sqlite3_stmt *pStmt; /* Shadow table query */ + int rc; /* Result code */ + int idx = 1; /* Next available filter parameter */ + spellfix1_vtab *p = pCur->pVTab; /* The virtual table that owns pCur */ + MatchQuery x; /* For passing info to RunQuery() */ + + /* Load the cost table if we have not already done so */ + if( p->zCostTable!=0 && p->pConfig3==0 ){ + p->pConfig3 = sqlite3_malloc( sizeof(p->pConfig3[0]) ); + if( p->pConfig3==0 ) return SQLITE_NOMEM; + memset(p->pConfig3, 0, sizeof(p->pConfig3[0])); + rc = editDist3ConfigLoad(p->pConfig3, p->db, p->zCostTable); + if( rc ) return rc; + } + memset(&x, 0, sizeof(x)); + x.iScope = 3; /* Default scope if none specified by "WHERE scope=N" */ + x.iMaxDist = -1; /* Maximum allowed edit distance */ if( idxNum&2 ){ iLang = sqlite3_value_int(argv[idx++]); @@ -1592,83 +2676,79 @@ static int spellfix1FilterForMatch( if( iLimit<1 ) iLimit = 1; } if( idxNum&8 ){ - iScope = sqlite3_value_int(argv[idx++]); - if( iScope<1 ) iScope = 1; + x.iScope = sqlite3_value_int(argv[idx++]); + if( x.iScope<1 ) x.iScope = 1; + if( x.iScope>SPELLFIX_MX_HASH-2 ) x.iScope = SPELLFIX_MX_HASH-2; } - spellfix1ResetCursor(pCur, iLimit); - zPatternIn = sqlite3_value_text(argv[0]); - if( zPatternIn==0 ) return SQLITE_OK; - zPattern = (char*)transliterate(zPatternIn, sqlite3_value_bytes(argv[0])); + if( idxNum&(16|32) ){ + x.iMaxDist = sqlite3_value_int(argv[idx++]); + if( idxNum&16 ) x.iMaxDist--; + if( x.iMaxDist<0 ) x.iMaxDist = 0; + } + spellfix1ResetCursor(pCur); + spellfix1ResizeCursor(pCur, iLimit); + zMatchThis = sqlite3_value_text(argv[0]); + if( zMatchThis==0 ) return SQLITE_OK; + if( p->pConfig3 ){ + x.pLang = editDist3FindLang(p->pConfig3, iLang); + pMatchStr3 = editDist3FromStringNew(x.pLang, (const char*)zMatchThis, -1); + }else{ + x.pLang = 0; + } + zPattern = (char*)transliterate(zMatchThis, sqlite3_value_bytes(argv[0])); if( zPattern==0 ) return SQLITE_NOMEM; nPattern = strlen(zPattern); if( zPattern[nPattern-1]=='*' ) nPattern--; - if( nPatterniScope ){ - zClass[iScope] = 0; - nClass = iScope; - } zSql = sqlite3_mprintf( "SELECT id, word, rank, k1" " FROM \"%w\".\"%w_vocab\"" - " WHERE langid=%d AND k2 GLOB '%q*'", - p->zDbName, p->zTableName, iLang, zClass + " WHERE langid=%d AND k2>=?1 AND k2zDbName, p->zTableName, iLang ); rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); - if( rc==SQLITE_OK ){ - const char *zK1; - int iDist; - int iRank; - int iScore; - int iWorst = 999999999; - int idx; - int idxWorst; - int i; + pCur->iLang = iLang; + x.pCur = pCur; + x.pStmt = pStmt; + x.zPattern = zPattern; + x.nPattern = nPattern; + x.pMatchStr3 = pMatchStr3; + x.iLang = iLang; + x.rc = rc; + x.pConfig3 = p->pConfig3; + if( x.rc==SQLITE_OK ){ + spellfix1RunQuery(&x, zPattern, nPattern); + } - while( sqlite3_step(pStmt)==SQLITE_ROW ){ - zK1 = (const char*)sqlite3_column_text(pStmt, 3); - if( zK1==0 ) continue; - pCur->nSearch++; - iRank = sqlite3_column_int(pStmt, 2); - iDist = editdist(zPattern, zK1); - iScore = spellfix1Score(iDist,iRank); - if( pCur->nRownAlloc ){ - idx = pCur->nRow; - }else if( iScorea[idx].zWord); - }else{ - continue; - } - pCur->a[idx].zWord = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1)); - pCur->a[idx].iRowid = sqlite3_column_int64(pStmt, 0); - pCur->a[idx].iRank = iRank; - pCur->a[idx].iDistance = iDist; - pCur->a[idx].iScore = iScore; - if( pCur->nRownAlloc ) pCur->nRow++; - if( pCur->nRow==pCur->nAlloc ){ - iWorst = pCur->a[0].iScore; - idxWorst = 0; - for(i=1; inRow; i++){ - iScore = pCur->a[i].iScore; - if( iWorsta, pCur->nRow, sizeof(pCur->a[0]), spellfix1RowCompare); - pCur->iTop = iLimit; - pCur->iScope = iScope; +#endif + + if( pCur->a ){ + qsort(pCur->a, pCur->nRow, sizeof(pCur->a[0]), spellfix1RowCompare); + pCur->iTop = iLimit; + pCur->iScope = iScope; + } sqlite3_finalize(pStmt); sqlite3_free(zPattern); - sqlite3_free(zClass); - return SQLITE_OK; + editDist3FromStringDelete(pMatchStr3); + return pCur->a ? x.rc : SQLITE_NOMEM; } /* @@ -1680,7 +2760,8 @@ static int spellfix1FilterForFullScan( int argc, sqlite3_value **argv ){ - spellfix1ResetCursor(pCur, 0); + spellfix1ResetCursor(pCur); + spellfix1ResizeCursor(pCur, 0); return SQLITE_OK; } @@ -1729,35 +2810,39 @@ static int spellfix1Eof(sqlite3_vtab_cursor *cur){ static int spellfix1Column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ spellfix1_cursor *pCur = (spellfix1_cursor*)cur; switch( i ){ - case 0: { + case SPELLFIX_COL_WORD: { sqlite3_result_text(ctx, pCur->a[pCur->iRow].zWord, -1, SQLITE_STATIC); break; } - case 1: { + case SPELLFIX_COL_RANK: { sqlite3_result_int(ctx, pCur->a[pCur->iRow].iRank); break; } - case 2: { + case SPELLFIX_COL_DISTANCE: { sqlite3_result_int(ctx, pCur->a[pCur->iRow].iDistance); break; } - case 3: { + case SPELLFIX_COL_LANGID: { sqlite3_result_int(ctx, pCur->iLang); break; } - case 4: { + case SPELLFIX_COL_SCORE: { sqlite3_result_int(ctx, pCur->a[pCur->iRow].iScore); break; } - case 5: { + case SPELLFIX_COL_PHONEHASH: { + sqlite3_result_text(ctx, pCur->a[pCur->iRow].zHash, -1, SQLITE_STATIC); + break; + } + case SPELLFIX_COL_TOP: { sqlite3_result_int(ctx, pCur->iTop); break; } - case 6: { + case SPELLFIX_COL_SCOPE: { sqlite3_result_int(ctx, pCur->iScope); break; } - case 7: { + case SPELLFIX_COL_SRCHCNT: { sqlite3_result_int(ctx, pCur->nSearch); break; } @@ -1799,20 +2884,37 @@ static int spellfix1Update( " WHERE id=%lld", p->zDbName, p->zTableName, rowid); }else{ - const unsigned char *zWord = sqlite3_value_text(argv[2]); - int nWord = sqlite3_value_bytes(argv[2]); - int iLang = sqlite3_value_int(argv[5]); - int iRank = sqlite3_value_int(argv[3]); - const unsigned char *zSoundslike = sqlite3_value_text(argv[10]); - int nSoundslike = sqlite3_value_bytes(argv[10]); + const unsigned char *zWord = sqlite3_value_text(argv[SPELLFIX_COL_WORD+2]); + int nWord = sqlite3_value_bytes(argv[SPELLFIX_COL_WORD+2]); + int iLang = sqlite3_value_int(argv[SPELLFIX_COL_LANGID+2]); + int iRank = sqlite3_value_int(argv[SPELLFIX_COL_RANK+2]); + const unsigned char *zSoundslike = + sqlite3_value_text(argv[SPELLFIX_COL_SOUNDSLIKE+2]); + int nSoundslike = sqlite3_value_bytes(argv[SPELLFIX_COL_SOUNDSLIKE+2]); char *zK1, *zK2; int i; char c; if( zWord==0 ){ - pVTab->zErrMsg = sqlite3_mprintf("%w.word may not be NULL", - p->zTableName); - return SQLITE_CONSTRAINT; + /* Inserts of the form: INSERT INTO table(command) VALUES('xyzzy'); + ** cause zWord to be NULL, so we look at the "command" column to see + ** what special actions to take */ + const char *zCmd = + (const char*)sqlite3_value_text(argv[SPELLFIX_COL_COMMAND+2]); + if( zCmd==0 ){ + pVTab->zErrMsg = sqlite3_mprintf("%s.word may not be NULL", + p->zTableName); + return SQLITE_CONSTRAINT; + } + if( strcmp(zCmd,"reset")==0 ){ + /* Reset the edit cost table (if there is one). */ + editDist3ConfigDelete(p->pConfig3); + p->pConfig3 = 0; + return SQLITE_OK; + } + pVTab->zErrMsg = sqlite3_mprintf("unknown value for %s.command: \"%w\"", + p->zTableName, zCmd); + return SQLITE_ERROR; } if( iRank<1 ) iRank = 1; if( zSoundslike ){ @@ -1824,7 +2926,7 @@ static int spellfix1Update( for(i=0; (c = zK1[i])!=0; i++){ if( c>='A' && c<='Z' ) zK1[i] += 'a' - 'A'; } - zK2 = (char*)characterClassString((const unsigned char*)zK1, i); + zK2 = (char*)phoneticHash((const unsigned char*)zK1, i); if( zK2==0 ){ sqlite3_free(zK1); return SQLITE_NOMEM; @@ -1912,16 +3014,23 @@ static int spellfix1Register(sqlite3 *db){ transliterateSqlFunc, 0, 0); nErr += sqlite3_create_function(db, "spellfix1_editdist", 2, SQLITE_UTF8, 0, editdistSqlFunc, 0, 0); - nErr += sqlite3_create_function(db, "spellfix1_charclass", 1, SQLITE_UTF8, 0, - characterClassSqlFunc, 0, 0); + nErr += sqlite3_create_function(db, "spellfix1_editdist", 3, SQLITE_UTF8, 0, + editdistSqlFunc, 0, 0); + nErr += sqlite3_create_function(db, "spellfix1_phonehash", 1, SQLITE_UTF8, 0, + phoneticHashSqlFunc, 0, 0); nErr += sqlite3_create_function(db, "spellfix1_scriptcode", 1, SQLITE_UTF8, 0, scriptCodeSqlFunc, 0, 0); + nErr += sqlite3_create_function(db, "pollock_skeleton", 1, SQLITE_UTF8, 0, + pollockSkeletonSqlFunc, 0, 0); + nErr += sqlite3_create_function(db, "pollock_omission", 1, SQLITE_UTF8, 0, + pollockOmissionSqlFunc, 0, 0); nErr += sqlite3_create_module(db, "spellfix1", &spellfix1Module, 0); + nErr += editDist3Install(db); /* Verify sanity of the translit[] table */ for(i=0; i Date: Fri, 13 Jul 2012 19:26:34 +0000 Subject: [PATCH 29/69] Add the "matchlen" column to the spellfix1 virtual table. FossilOrigin-Name: f24b9d87f6b0e8b4d26669d5c1191f9280ba14a3 --- manifest | 16 +++-- manifest.uuid | 2 +- src/test_spellfix.c | 159 ++++++++++++++++++++++++++++++++++++++------ test/spellfix.test | 147 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 296 insertions(+), 28 deletions(-) create mode 100644 test/spellfix.test diff --git a/manifest b/manifest index 4901be8cae..c081ba92f0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\stest_spellfix.c\swith\slatest\schanges. -D 2012-07-13T16:15:20.128 +C Add\sthe\s"matchlen"\scolumn\sto\sthe\sspellfix1\svirtual\stable. +D 2012-07-13T19:26:34.617 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -221,7 +221,7 @@ F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f -F src/test_spellfix.c 1de8d8c086efa50bb6660ea5988e8630ef9144aa +F src/test_spellfix.c 1c900928dad9b71c0fdcbdda9e2f52234f283660 F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae @@ -716,6 +716,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b +F test/spellfix.test 936be6f7ba1c4d096adb280c68b32f4848af8d2e F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test 08e8185b3fd5b010c90d7ad82b9dd4ea1cbf14b0 F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 @@ -1004,7 +1005,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 7fac56ed9feda819e66070bd5e06db8cad77e8bd -R 8322d35d4441c91cd733d64b44bd2f2e +P cba2a65870481df213e006b07e74f0ca19d2d57c +R 79ffd07a9c878240f73dd72d96e3ef36 +T *branch * spellfix-matchlen +T *sym-spellfix-matchlen * +T -sym-trunk * U dan -Z 4817f8644451c5f84c464c55e7d56257 +Z 642149d4a86bbb287ab54c68c79dc818 diff --git a/manifest.uuid b/manifest.uuid index 45760e0dc2..ebe0ec2458 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cba2a65870481df213e006b07e74f0ca19d2d57c \ No newline at end of file +f24b9d87f6b0e8b4d26669d5c1191f9280ba14a3 \ No newline at end of file diff --git a/src/test_spellfix.c b/src/test_spellfix.c index 67a9920932..d80ce8f013 100644 --- a/src/test_spellfix.c +++ b/src/test_spellfix.c @@ -101,6 +101,11 @@ ** by default (unless overridden by ORDER BY) returns ** results in order of increasing score. ** +** matchlen For prefix queries, the number of characters in the prefix +** of the returned value (word) that matched the query term. +** For non-prefix queries, the number of characters in the +** returned value. +** ** top (HIDDEN) For any query, this value is the same on all ** rows. It is an integer which is the maximum number of ** rows that will be output. The actually number of rows @@ -605,8 +610,14 @@ static int substituteCost(char cPrev, char cFrom, char cTo){ ** -1 One of the inputs is NULL ** -2 Non-ASCII characters on input ** -3 Unable to allocate memory +** +** If pnMatch is not NULL, then *pnMatch is set to the number of bytes +** of zB that matched the pattern in zA. If zA does not end with a '*', +** then this value is always the number of bytes in zB (i.e. strlen(zB)). +** If zA does end in a '*', then it is the number of bytes in the prefix +** of zB that was deemed to match zA. */ -static int editdist1(const char *zA, const char *zB, int iLangId){ +static int editdist1(const char *zA, const char *zB, int iLangId, int *pnMatch){ int nA, nB; /* Number of characters in zA[] and zB[] */ int xA, xB; /* Loop counters for zA[] and zB[] */ char cA, cB; /* Current character of zA and zB */ @@ -619,12 +630,14 @@ static int editdist1(const char *zA, const char *zB, int iLangId){ char *cx; /* Corresponding character values */ int *toFree = 0; /* Malloced space */ int mStack[60+15]; /* Stack space to use if not too much is needed */ + int nMatch = 0; /* Early out if either input is NULL */ if( zA==0 || zB==0 ) return -1; /* Skip any common prefix */ - while( zA[0] && zA[0]==zB[0] ){ dc = zA[0]; zA++; zB++; } + while( zA[0] && zA[0]==zB[0] ){ dc = zA[0]; zA++; zB++; nMatch++; } + if( pnMatch ) *pnMatch = nMatch; if( zA[0]==0 && zB[0]==0 ) return 0; #if 0 @@ -737,10 +750,14 @@ static int editdist1(const char *zA, const char *zB, int iLangId){ if( cA=='*' ){ res = m[1]; for(xB=1; xB<=nB; xB++){ - if( m[xB]=128 ){ + int xTop, xBtm, x; + xTop = sizeof(translit)/sizeof(translit[0]) - 1; + xBtm = 0; + while( xTop>=xBtm ){ + x = (xTop + xBtm)/2; + if( translit[x].cFrom==c ){ + if( translit[x].cTo1 ) nOut++; + if( c==0x0429 || c== 0x0449 ) nOut += 2; + break; + }else if( translit[x].cFrom>c ){ + xTop = x-1; + }else{ + xBtm = x+1; + } + } + } + } + + return nChar; +} + + /* ** spellfix1_translit(X) ** @@ -2092,6 +2177,7 @@ struct spellfix1_vtab { struct spellfix1_cursor { sqlite3_vtab_cursor base; /* Base class - must be first */ spellfix1_vtab *pVTab; /* The table to which this cursor belongs */ + char *zPattern; /* rhs of MATCH clause */ int nRow; /* Number of rows of content */ int nAlloc; /* Number of allocated rows */ int iRow; /* Current row of content */ @@ -2105,6 +2191,7 @@ struct spellfix1_cursor { int iRank; /* Rank for this row */ int iDistance; /* Distance from pattern for this row */ int iScore; /* Score for sorting */ + int iMatchlen; /* Value of matchlen column (or -1) */ char zHash[SPELLFIX_MX_HASH]; /* the phonehash used for this match */ } *a; }; @@ -2200,7 +2287,7 @@ static char *spellfix1Dequote(const char *zIn){ ** argv[0] -> module name ("spellfix1") ** argv[1] -> database name ** argv[2] -> table name -** argv[3].. -> optional arguments (currently ignored) +** argv[3].. -> optional arguments (i.e. "edit_cost_table" parameter) */ static int spellfix1Init( int isCreate, @@ -2238,21 +2325,23 @@ static int spellfix1Init( rc = SQLITE_NOMEM; }else{ rc = sqlite3_declare_vtab(db, - "CREATE TABLE x(word,rank,distance,langid," - "score, phonehash,top HIDDEN,scope HIDDEN,srchcnt HIDDEN," - "soundslike HIDDEN,command HIDDEN)" + "CREATE TABLE x(word,rank,distance,langid, " + "score, matchlen, phonehash, " + "top HIDDEN, scope HIDDEN, srchcnt HIDDEN, " + "soundslike HIDDEN, command HIDDEN)" ); #define SPELLFIX_COL_WORD 0 #define SPELLFIX_COL_RANK 1 #define SPELLFIX_COL_DISTANCE 2 #define SPELLFIX_COL_LANGID 3 #define SPELLFIX_COL_SCORE 4 -#define SPELLFIX_COL_PHONEHASH 5 -#define SPELLFIX_COL_TOP 6 -#define SPELLFIX_COL_SCOPE 7 -#define SPELLFIX_COL_SRCHCNT 8 -#define SPELLFIX_COL_SOUNDSLIKE 9 -#define SPELLFIX_COL_COMMAND 10 +#define SPELLFIX_COL_MATCHLEN 5 +#define SPELLFIX_COL_PHONEHASH 6 +#define SPELLFIX_COL_TOP 7 +#define SPELLFIX_COL_SCOPE 8 +#define SPELLFIX_COL_SRCHCNT 9 +#define SPELLFIX_COL_SOUNDSLIKE 10 +#define SPELLFIX_COL_COMMAND 11 } if( rc==SQLITE_OK && isCreate ){ sqlite3_uint64 r; @@ -2350,6 +2439,7 @@ static int spellfix1Close(sqlite3_vtab_cursor *cur){ spellfix1_cursor *pCur = (spellfix1_cursor *)cur; spellfix1ResetCursor(pCur); spellfix1ResizeCursor(pCur, 0); + sqlite3_free(pCur->zPattern); sqlite3_free(pCur); return SQLITE_OK; } @@ -2583,15 +2673,16 @@ static void spellfix1RunQuery(MatchQuery *p, const char *zQuery, int nQuery){ } } while( sqlite3_step(pStmt)==SQLITE_ROW ){ + int iMatchlen = -1; iRank = sqlite3_column_int(pStmt, 2); if( p->pMatchStr3 ){ int nWord = sqlite3_column_bytes(pStmt, 1); zWord = (const char*)sqlite3_column_text(pStmt, 1); - iDist = editDist3Core(p->pMatchStr3, zWord, nWord, p->pLang); + iDist = editDist3Core(p->pMatchStr3, zWord, nWord, p->pLang, &iMatchlen); }else{ zK1 = (const char*)sqlite3_column_text(pStmt, 3); if( zK1==0 ) continue; - iDist = editdist1(p->zPattern, zK1, pCur->iLang); + iDist = editdist1(p->zPattern, zK1, pCur->iLang, 0); } pCur->nSearch++; iScore = spellfix1Score(iDist,iRank); @@ -2615,6 +2706,7 @@ static void spellfix1RunQuery(MatchQuery *p, const char *zQuery, int nQuery){ pCur->a[idx].iRank = iRank; pCur->a[idx].iDistance = iDist; pCur->a[idx].iScore = iScore; + pCur->a[idx].iMatchlen = iMatchlen; memcpy(pCur->a[idx].zHash, zHash1, iScope+1); if( pCur->nRownAlloc ) pCur->nRow++; if( pCur->nRow==pCur->nAlloc ){ @@ -2696,6 +2788,8 @@ static int spellfix1FilterForMatch( x.pLang = 0; } zPattern = (char*)transliterate(zMatchThis, sqlite3_value_bytes(argv[0])); + sqlite3_free(pCur->zPattern); + pCur->zPattern = zPattern; if( zPattern==0 ) return SQLITE_NOMEM; nPattern = strlen(zPattern); if( zPattern[nPattern-1]=='*' ) nPattern--; @@ -2746,7 +2840,6 @@ static int spellfix1FilterForMatch( pCur->iScope = iScope; } sqlite3_finalize(pStmt); - sqlite3_free(zPattern); editDist3FromStringDelete(pMatchStr3); return pCur->a ? x.rc : SQLITE_NOMEM; } @@ -2830,6 +2923,30 @@ static int spellfix1Column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i sqlite3_result_int(ctx, pCur->a[pCur->iRow].iScore); break; } + case SPELLFIX_COL_MATCHLEN: { + int iMatchlen = pCur->a[pCur->iRow].iMatchlen; + if( iMatchlen<0 ){ + int nPattern = strlen(pCur->zPattern); + char *zWord = pCur->a[pCur->iRow].zWord; + int nWord = strlen(zWord); + + if( nPattern>0 && pCur->zPattern[nPattern-1]=='*' ){ + char *zTranslit; + int res; + zTranslit = (char *)transliterate((unsigned char *)zWord, nWord); + if( !zTranslit ) return SQLITE_NOMEM; + res = editdist1(pCur->zPattern, zTranslit, pCur->iLang, &iMatchlen); + sqlite3_free(zTranslit); + if( res<0 ) return SQLITE_NOMEM; + iMatchlen = translen_to_charlen(zWord, nWord, iMatchlen); + }else{ + iMatchlen = utf8Charlen(zWord, nWord); + } + } + + sqlite3_result_int(ctx, iMatchlen); + break; + } case SPELLFIX_COL_PHONEHASH: { sqlite3_result_text(ctx, pCur->a[pCur->iRow].zHash, -1, SQLITE_STATIC); break; diff --git a/test/spellfix.test b/test/spellfix.test new file mode 100644 index 0000000000..7459ca2cd6 --- /dev/null +++ b/test/spellfix.test @@ -0,0 +1,147 @@ +# 2012 July 12 +# +# 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. +# +#*********************************************************************** +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set testprefix spellfix + +register_spellfix_module db + +set vocab { +rabbi rabbit rabbits rabble rabid rabies raccoon raccoons race raced racer +racers races racetrack racial racially racing rack racked racket racketeer +racketeering racketeers rackets racking racks radar radars radial radially +radian radiance radiant radiantly radiate radiated radiates radiating radiation +radiations radiator radiators radical radically radicals radices radii radio +radioactive radioastronomy radioed radiography radioing radiology radios radish +radishes radium radius radix radon raft rafter rafters rafts rag rage raged +rages ragged raggedly raggedness raging rags ragweed raid raided raider raiders +raiding raids rail railed railer railers railing railroad railroaded railroader +railroaders railroading railroads rails railway railways raiment rain rainbow +raincoat raincoats raindrop raindrops rained rainfall rainier rainiest raining +rains rainstorm rainy raise raised raiser raisers raises raisin raising rake +raked rakes raking rallied rallies rally rallying ram ramble rambler rambles +rambling ramblings ramification ramifications ramp rampage rampant rampart +ramps ramrod rams ran ranch ranched rancher ranchers ranches ranching rancid +random randomization randomize randomized randomizes randomly randomness randy +rang range ranged rangeland ranger rangers ranges ranging rangy rank ranked +ranker rankers rankest ranking rankings rankle rankly rankness ranks ransack +ransacked ransacking ransacks ransom ransomer ransoming ransoms rant ranted +ranter ranters ranting rants rap rapacious rape raped raper rapes rapid +rapidity rapidly rapids rapier raping rapport rapprochement raps rapt raptly +rapture raptures rapturous rare rarely rareness rarer rarest rarity rascal +rascally rascals rash rasher rashly rashness rasp raspberry rasped rasping +rasps raster rat rate rated rater raters rates rather ratification ratified +ratifies ratify ratifying rating ratings ratio ration rational rationale +rationales rationalities rationality rationalization rationalizations +rationalize rationalized rationalizes rationalizing rationally rationals +rationing rations ratios rats rattle rattled rattler rattlers rattles +rattlesnake rattlesnakes rattling raucous ravage ravaged ravager ravagers +ravages ravaging rave raved raven ravening ravenous ravenously ravens raves +ravine ravines raving ravings raw rawer rawest rawly rawness ray rays raze +razor razors re reabbreviate reabbreviated reabbreviates reabbreviating reach +reachability reachable reachably reached reacher reaches reaching reacquired +react reacted reacting reaction reactionaries reactionary reactions reactivate +reactivated reactivates reactivating reactivation reactive reactively +reactivity reactor reactors reacts read readability readable reader readers +readied readier readies readiest readily readiness reading readings readjusted +readout readouts reads ready readying real realest realign realigned realigning +realigns realism realist realistic realistically realists realities reality +} + +do_test 1.1 { + execsql { CREATE VIRTUAL TABLE t1 USING spellfix1 } + foreach word $vocab { + execsql { INSERT INTO t1(word) VALUES($word) } + } +} {} + +foreach {tn word res} { + 1 raxpi* {rasping 5 rasped 5 raspberry 6 rasp 4 rasps 4} + 2 ril* {rail 4 railway 4 railing 4 rails 4 railways 4} + 3 rilis* {realist 6 realistic 6 realistically 6 realists 6 realism 6} + 4 reail* {realities 3 reality 3 real 3 realest 3 realist 3} + 5 ras* {rasp 3 rash 3 rasped 3 rasping 3 rasps 3} + 6 realistss* {realists 8 realigns 8 realistic 9 realistically 9 realest 7} + 7 realistss {realists 8 realist 7 realigns 8 realistic 9 realest 7} + 8 rllation* {realities 9 reality 7 rallied 7 railed 4} + 9 renstom* {rainstorm 8 ransomer 6 ransom 6 ransoming 6 ransoms 6} +} { + do_execsql_test 1.2.$tn { + SELECT word, matchlen FROM t1 WHERE word MATCH $word LIMIT 5 + } $res +} + + +do_execsql_test 2.1 { + CREATE VIRTUAL TABLE t2 USING spellfix1; + INSERT INTO t2 (word, soundslike) VALUES('school', 'skuul'); + INSERT INTO t2 (word, soundslike) VALUES('psalm', 'sarm'); + SELECT word, matchlen FROM t2 WHERE word MATCH 'sar*' LIMIT 5; +} {psalm 4} + +do_execsql_test 2.2 { + SELECT word, matchlen FROM t2 WHERE word MATCH 'skol*' LIMIT 5; +} {school 6} + +set vocab { +kangaroo kanji kappa karate keel keeled keeling keels keen keener keenest +keenly keenness keep keeper keepers keeping keeps ken kennel kennels kept +kerchief kerchiefs kern kernel kernels kerosene ketchup kettle +kettles key keyboard keyboards keyed keyhole keying keynote keypad keypads keys +keystroke keystrokes keyword keywords kick kicked kicker kickers kicking +kickoff kicks kid kidded kiddie kidding kidnap kidnapper kidnappers kidnapping +kidnappings kidnaps kidney kidneys kids kill killed killer killers killing +killingly killings killjoy kills kilobit kilobits kiloblock kilobyte kilobytes +kilogram kilograms kilohertz kilohm kilojoule kilometer kilometers kiloton +kilovolt kilowatt kiloword kimono kin kind kinder kindergarten kindest +kindhearted kindle kindled kindles kindling kindly kindness kindred kinds +kinetic king kingdom kingdoms kingly kingpin kings kink kinky kinship kinsman +kiosk kiss kissed kisser kissers kisses kissing kit kitchen kitchenette +kitchens kite kited kites kiting kits kitten kittenish kittens kitty klaxon +kludge kludges klystron knack knapsack knapsacks knave knaves knead kneads knee +kneecap kneed kneeing kneel kneeled kneeling kneels knees knell knells knelt +knew knife knifed knifes knifing knight knighted knighthood knighting knightly +knights knit knits knives knob knobs knock knockdown knocked knocker knockers +knocking knockout knocks knoll knolls knot knots knotted knotting know knowable +knower knowhow knowing knowingly knowledge knowledgeable known knows knuckle +knuckled knuckles koala kosher kudo +} + +do_execsql_test 3.1 { + CREATE TABLE costs(iLang, cFrom, cTo, iCost); + INSERT INTO costs VALUES(0, 'a', 'e', 1); + INSERT INTO costs VALUES(0, 'e', 'i', 1); + INSERT INTO costs VALUES(0, 'i', 'o', 1); + INSERT INTO costs VALUES(0, 'o', 'u', 1); + INSERT INTO costs VALUES(0, 'u', 'a', 1); + CREATE VIRTUAL TABLE t3 USING spellfix1(edit_cost_table=costs); +} + +do_test 3.2 { + foreach w $vocab { + execsql { INSERT INTO t3(word) VALUES($w) } + } +} {} + +breakpoint +foreach {tn word res} { + 1 kos* {kosher 3 kiosk 4 kudo 2 kappa 1 keypad 1} + 2 kellj* {killjoy 5 killed 4 killingly 4 kill 4 killer 4} + 3 kellj {kill 4 kills 5 killjoy 7 keel 4 killed 6} +} { + do_execsql_test 1.2.$tn { + SELECT word, matchlen FROM t3 WHERE word MATCH $word LIMIT 5 + } $res +} + +finish_test From 5885e762697744189296de5c540f8f8e874bfa2a Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 16 Jul 2012 10:06:12 +0000 Subject: [PATCH 30/69] If a specific database is nominated as part of a "PRAGMA integrity_check" or "PRAGMA quick_check" command, search for problems in the nominated database only. i.e. "PRAGMA main.quick_check" now only scans the main database, not all attached databases as before. FossilOrigin-Name: 4353e40b74f577f224f190c429bfe03cf6a5c6d6 --- manifest | 14 +++++----- manifest.uuid | 2 +- src/pragma.c | 16 +++++++++++- test/pragma.test | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 89 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 4901be8cae..ba54373845 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\stest_spellfix.c\swith\slatest\schanges. -D 2012-07-13T16:15:20.128 +C If\sa\sspecific\sdatabase\sis\snominated\sas\spart\sof\sa\s"PRAGMA\sintegrity_check"\sor\s"PRAGMA\squick_check"\scommand,\ssearch\sfor\sproblems\sin\sthe\snominated\sdatabase\sonly.\si.e.\s"PRAGMA\smain.quick_check"\snow\sonly\sscans\sthe\smain\sdatabase,\snot\sall\sattached\sdatabases\sas\sbefore. +D 2012-07-16T10:06:12.788 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -170,7 +170,7 @@ F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c F src/pcache1.c 2234d84f9c003d800a57f00f8535c91667fa4f6c -F src/pragma.c eee3e3161f82a1e06f632a8d2a82b29ba3c45889 +F src/pragma.c 97f9357f0e7e5fb46a2519f14539550aa07db49f F src/prepare.c 33291b83cca285718048d219c67b8298501fa3a5 F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 @@ -642,7 +642,7 @@ F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/permutations.test 2af90e00cea9e7e7c0a6b16d34727cb5bbae14dd -F test/pragma.test cb736bcc75b8b629af21ac0ad83ba1d054a2107b +F test/pragma.test a62f73293b0f0d79b0c87f8dd32d46fe53b0bd17 F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test 5b075c3c790c7b2a61419bc199db87aaf48b8301 @@ -1004,7 +1004,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 7fac56ed9feda819e66070bd5e06db8cad77e8bd -R 8322d35d4441c91cd733d64b44bd2f2e +P cba2a65870481df213e006b07e74f0ca19d2d57c +R 2c8947c00bca721d7703f91176d94433 U dan -Z 4817f8644451c5f84c464c55e7d56257 +Z f57f4dc603e6879ace3edbe2fb8156d2 diff --git a/manifest.uuid b/manifest.uuid index 45760e0dc2..c37c8336d7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cba2a65870481df213e006b07e74f0ca19d2d57c \ No newline at end of file +4353e40b74f577f224f190c429bfe03cf6a5c6d6 \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index b66290c0e8..a41e0e433f 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1160,6 +1160,19 @@ void sqlite3Pragma( int isQuick = (sqlite3Tolower(zLeft[0])=='q'); + /* If the PRAGMA command was of the form "PRAGMA .integrity_check", + ** then iDb is set to the index of the database identified by . + ** In this case, the integrity of database iDb only is verified by + ** the VDBE created below. + ** + ** Otherwise, if the command was simply "PRAGMA integrity_check" (or + ** "PRAGMA quick_check"), then iDb is set to 0. In this case, set iDb + ** to -1 here, to indicate that the VDBE should verify the integrity + ** of all attached databases. */ + assert( iDb>=0 ); + assert( iDb==0 || pId2->z ); + if( pId2->z==0 ) iDb = -1; + /* Initialize the VDBE program */ if( sqlite3ReadSchema(pParse) ) goto pragma_out; pParse->nMem = 6; @@ -1183,6 +1196,7 @@ void sqlite3Pragma( int cnt = 0; if( OMIT_TEMPDB && i==1 ) continue; + if( iDb>=0 && i!=iDb ) continue; sqlite3CodeVerifySchema(pParse, i); addr = sqlite3VdbeAddOp1(v, OP_IfPos, 1); /* Halt if out of errors */ @@ -1194,7 +1208,7 @@ void sqlite3Pragma( ** Begin by filling registers 2, 3, ... with the root pages numbers ** for all tables and indices in the database. */ - assert( sqlite3SchemaMutexHeld(db, iDb, 0) ); + assert( sqlite3SchemaMutexHeld(db, i, 0) ); pTbls = &db->aDb[i].pSchema->tblHash; for(x=sqliteHashFirst(pTbls); x; x=sqliteHashNext(x)){ Table *pTab = sqliteHashData(x); diff --git a/test/pragma.test b/test/pragma.test index e249897fe3..3c8d23a1fc 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -16,6 +16,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix pragma # Do not use a codec for tests in this file, as the database file is # manipulated directly using tcl scripts (using the [hexio_write] command). @@ -41,6 +42,8 @@ do_not_use_codec # reset when the schema is reloaded. # pragma-16.*: Test proxy locking # pragma-20.*: Test data_store_directory. +# pragma-22.*: Test that "PRAGMA [db].integrity_check" respects the "db" +# directive - if it is present. # ifcapable !pragma { @@ -1554,4 +1557,67 @@ do_test pragma-20.8 { forcedelete data_dir } ;# endif windows +do_test 21.1 { + # Create a corrupt database in testerr.db. And a non-corrupt at test.db. + # + db close + forcedelete test.db + sqlite3 db test.db + execsql { + PRAGMA page_size = 1024; + PRAGMA auto_vacuum = 0; + CREATE TABLE t1(a PRIMARY KEY, b); + INSERT INTO t1 VALUES(1, 1); + } + for {set i 0} {$i < 10} {incr i} { + execsql { INSERT INTO t1 SELECT a + (1 << $i), b + (1 << $i) FROM t1 } + } + db close + forcecopy test.db testerr.db + hexio_write testerr.db 15000 [string repeat 55 100] +} {100} + +set mainerr {*** in database main *** +Multiple uses for byte 672 of page 15} +set auxerr {*** in database aux *** +Multiple uses for byte 672 of page 15} + +do_test 22.2 { + catch { db close } + sqlite3 db testerr.db + execsql { PRAGMA integrity_check } +} [list $mainerr] + +do_test 22.3.1 { + catch { db close } + sqlite3 db test.db + execsql { + ATTACH 'testerr.db' AS 'aux'; + PRAGMA integrity_check; + } +} [list $auxerr] +do_test 22.3.2 { + execsql { PRAGMA main.integrity_check; } +} {ok} +do_test 22.3.3 { + execsql { PRAGMA aux.integrity_check; } +} [list $auxerr] + +do_test 22.4.1 { + catch { db close } + sqlite3 db testerr.db + execsql { + ATTACH 'test.db' AS 'aux'; + PRAGMA integrity_check; + } +} [list $mainerr] +do_test 22.4.2 { + execsql { PRAGMA main.integrity_check; } +} [list $mainerr] +do_test 22.4.3 { + execsql { PRAGMA aux.integrity_check; } +} {ok} + finish_test + + From b4a553e7f024bf1d53e0f640833bde91aa835d83 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 16 Jul 2012 14:52:49 +0000 Subject: [PATCH 31/69] Fix a bug in the phonetic-hash routine in spellfix1: Even if the first character of a word is deemed to be "silent", do not apply the special handling intended for the first character of each word to the second. FossilOrigin-Name: 6333b42dd292e8e567c3fce1c371d6f58021af88 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/test_spellfix.c | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 010cecc7bb..24bbafdb5b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\strunk\schanges. -D 2012-07-16T10:25:54.662 +C Fix\sa\sbug\sin\sthe\sphonetic-hash\sroutine\sin\sspellfix1:\sEven\sif\sthe\sfirst\scharacter\sof\sa\sword\sis\sdeemed\sto\sbe\s"silent",\sdo\snot\sapply\sthe\sspecial\shandling\sintended\sfor\sthe\sfirst\scharacter\sof\seach\sword\sto\sthe\ssecond. +D 2012-07-16T14:52:49.791 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -221,7 +221,7 @@ F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f -F src/test_spellfix.c 1c900928dad9b71c0fdcbdda9e2f52234f283660 +F src/test_spellfix.c 1b31d1ea6404dab6353eb2b07871344940c4469d F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P f24b9d87f6b0e8b4d26669d5c1191f9280ba14a3 4353e40b74f577f224f190c429bfe03cf6a5c6d6 -R 41982e9e09fbd84544b16a8024815a54 +P 90df64ab803001819b3ebbb41d596aedbd9961b1 +R 6fff5cd40b7efe568d75dafae19dd7da U dan -Z df39f17a0a50d7df733c6d4551aaf8e2 +Z 85a8e8a94773032ba7ff59559399f217 diff --git a/manifest.uuid b/manifest.uuid index e3850d5fef..d7199d204a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -90df64ab803001819b3ebbb41d596aedbd9961b1 \ No newline at end of file +6333b42dd292e8e567c3fce1c371d6f58021af88 \ No newline at end of file diff --git a/src/test_spellfix.c b/src/test_spellfix.c index d80ce8f013..84d42417b1 100644 --- a/src/test_spellfix.c +++ b/src/test_spellfix.c @@ -479,6 +479,7 @@ static unsigned char *phoneticHash(const unsigned char *zIn, int nIn){ c = aClass[c&0x7f]; if( c==CCLASS_SPACE ) continue; if( c==CCLASS_OTHER && cPrev!=CCLASS_DIGIT ) continue; + aClass = midClass; if( c==CCLASS_VOWEL && (cPrevX==CCLASS_R || cPrevX==CCLASS_L) ){ continue; /* No vowels beside L or R */ } @@ -488,8 +489,6 @@ static unsigned char *phoneticHash(const unsigned char *zIn, int nIn){ cPrev = c; if( c==CCLASS_SILENT ) continue; cPrevX = c; - if( c==CCLASS_SPACE ) continue; - aClass = midClass; c = className[c]; if( c!=zOut[nOut-1] ) zOut[nOut++] = c; } From 13a2bed30984126af67cdebfea97d829bbdeb3df Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 16 Jul 2012 22:16:44 +0000 Subject: [PATCH 32/69] Fix compiler warnings about unused code in spellfix. Fix the editDist3Core() routine to return the matchlen in characters instead of bytes. FossilOrigin-Name: f96d4e7bd7d81b05b1490bf5d79c77ff583e444c --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/test8.c | 2 -- src/test_spellfix.c | 15 +++++++++++---- 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 24bbafdb5b..3f4d31497d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\sthe\sphonetic-hash\sroutine\sin\sspellfix1:\sEven\sif\sthe\sfirst\scharacter\sof\sa\sword\sis\sdeemed\sto\sbe\s"silent",\sdo\snot\sapply\sthe\sspecial\shandling\sintended\sfor\sthe\sfirst\scharacter\sof\seach\sword\sto\sthe\ssecond. -D 2012-07-16T14:52:49.791 +C Fix\scompiler\swarnings\sabout\sunused\scode\sin\sspellfix.\s\sFix\sthe\seditDist3Core()\nroutine\sto\sreturn\sthe\smatchlen\sin\scharacters\sinstead\sof\sbytes. +D 2012-07-16T22:16:44.619 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -192,7 +192,7 @@ F src/test4.c d1e5a5e904d4b444cf572391fdcb017638e36ff7 F src/test5.c a6d1ac55ac054d0b2b8f37b5e655b6c92645a013 F src/test6.c 417e1e214734393c24a8ee80b41485a9c4169123 F src/test7.c 2e0781754905c8adc3268d8f0967e7633af58843 -F src/test8.c c4bcd39c9b157a28f5c4efefbb6bb1174037cace +F src/test8.c 8bcce65e5ee027fbfd7da41d28371aabbfd369ff F src/test9.c bea1e8cf52aa93695487badedd6e1886c321ea60 F src/test_async.c 0612a752896fad42d55c3999a5122af10dcf22ad F src/test_autoext.c 30e7bd98ab6d70a62bb9ba572e4c7df347fe645e @@ -221,7 +221,7 @@ F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f -F src/test_spellfix.c 1b31d1ea6404dab6353eb2b07871344940c4469d +F src/test_spellfix.c 5ed989693d4040f4d343316c338e25c5a6a1f05d F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 90df64ab803001819b3ebbb41d596aedbd9961b1 -R 6fff5cd40b7efe568d75dafae19dd7da -U dan -Z 85a8e8a94773032ba7ff59559399f217 +P 6333b42dd292e8e567c3fce1c371d6f58021af88 +R 30ab5f90b7df8ebe4d6fa220655edbc4 +U drh +Z d0f2f984dce6f521f6a371c3f57d729a diff --git a/manifest.uuid b/manifest.uuid index d7199d204a..efc4ac1f2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6333b42dd292e8e567c3fce1c371d6f58021af88 \ No newline at end of file +f96d4e7bd7d81b05b1490bf5d79c77ff583e444c \ No newline at end of file diff --git a/src/test8.c b/src/test8.c index 5ee62961f8..53cb149a04 100644 --- a/src/test8.c +++ b/src/test8.c @@ -1381,8 +1381,6 @@ static int register_spellfix_module( int objc, Tcl_Obj *CONST objv[] ){ - static sqlite3_module aMod[3]; - int iMod; sqlite3 *db; if( objc!=2 ){ diff --git a/src/test_spellfix.c b/src/test_spellfix.c index 84d42417b1..cc3531268b 100644 --- a/src/test_spellfix.c +++ b/src/test_spellfix.c @@ -1113,6 +1113,7 @@ static EditDist3FromString *editDist3FromStringNew( return pStr; } +#if 0 /* No longer used */ /* ** Return the number of bytes in the common prefix of two UTF8 strings. ** Only complete characters are considered. @@ -1134,6 +1135,7 @@ static int editDist3SuffixLen(const char *z1, int n1, const char *z2, int n2){ while( n1 Date: Tue, 17 Jul 2012 02:56:05 +0000 Subject: [PATCH 33/69] Amplification of a comment in wal.c. Change the aReadMark[] processing so that one read mark is left at zero when a WAL resets. FossilOrigin-Name: 8c9ee1d78f99394eef73a177141ca9e1c67e4e07 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/wal.c | 8 +++++--- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 8fdf833849..514241b4fd 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\sspellfix1\schanges\sfor\ssupporting\smatchlen\sinto\strunk. -D 2012-07-16T23:13:19.737 +C Amplification\sof\sa\scomment\sin\swal.c.\s\sChange\sthe\saReadMark[]\sprocessing\sso\nthat\sone\sread\smark\sis\sleft\sat\szero\swhen\sa\sWAL\sresets. +D 2012-07-17T02:56:05.199 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -247,7 +247,7 @@ F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 -F src/wal.c 7bb3ad807afc7973406c805d5157ec7a2f65e146 +F src/wal.c 16345cdccc95e13b493854f1253b8395fcd519fa F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c 24c7494d8875ead994b4dfe5461340c27fd424ca @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 4353e40b74f577f224f190c429bfe03cf6a5c6d6 f96d4e7bd7d81b05b1490bf5d79c77ff583e444c -R 30ab5f90b7df8ebe4d6fa220655edbc4 +P 6f167adf6050632e8c52f9ac4fb5583bcf27c576 +R aff021ec3312340384303b11ff294204 U drh -Z 5a5e4c2b59deca5c96bae885212173df +Z 0bb1d32f801f3ecf912dcdccb6dd8135 diff --git a/manifest.uuid b/manifest.uuid index f2743547c6..9ca2d06a05 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f167adf6050632e8c52f9ac4fb5583bcf27c576 \ No newline at end of file +8c9ee1d78f99394eef73a177141ca9e1c67e4e07 \ No newline at end of file diff --git a/src/wal.c b/src/wal.c index b077d27d9e..931279eda3 100644 --- a/src/wal.c +++ b/src/wal.c @@ -142,8 +142,9 @@ ** byte order of the host computer. ** ** The purpose of the wal-index is to answer this question quickly: Given -** a page number P, return the index of the last frame for page P in the WAL, -** or return NULL if there are no frames for page P in the WAL. +** a page number P and a maximum frame index M, return the index of the +** last frame in the wal before frame M for page P in the WAL, or return +** NULL if there are no frames for page P in the WAL prior to M. ** ** The wal-index consists of a header region, followed by an one or ** more index blocks. @@ -2611,7 +2612,8 @@ static int walRestartLog(Wal *pWal){ aSalt[1] = salt1; walIndexWriteHdr(pWal); pInfo->nBackfill = 0; - for(i=1; iaReadMark[i] = READMARK_NOT_USED; + pInfo->aReadMark[1] = 0; + for(i=2; iaReadMark[i] = READMARK_NOT_USED; assert( pInfo->aReadMark[0]==0 ); walUnlockExclusive(pWal, WAL_READ_LOCK(1), WAL_NREADER-1); }else if( rc!=SQLITE_BUSY ){ From 5373b76bdc82139a07b3bd32126eb42bb193b27a Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 17 Jul 2012 14:37:12 +0000 Subject: [PATCH 34/69] Ensure that there is always at least one aReadMark slot usable by an unprivileged reader while a checkpoint is running. Also, if one or more transactions are recovered from a log file, initialize one of the aReadMark slots to contain mxFrame as part of the recovery process. FossilOrigin-Name: e4163596339c2166f9c4356ab824fff8bda8d0b0 --- manifest | 22 ++++----- manifest.uuid | 2 +- src/test_vfs.c | 28 +++++++++++ src/wal.c | 3 +- test/wal2.test | 6 ++- test/wal3.test | 2 +- test/walro.test | 125 ++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 172 insertions(+), 16 deletions(-) diff --git a/manifest b/manifest index 514241b4fd..8576e56420 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Amplification\sof\sa\scomment\sin\swal.c.\s\sChange\sthe\saReadMark[]\sprocessing\sso\nthat\sone\sread\smark\sis\sleft\sat\szero\swhen\sa\sWAL\sresets. -D 2012-07-17T02:56:05.199 +C Ensure\sthat\sthere\sis\salways\sat\sleast\sone\saReadMark\sslot\susable\sby\san\sunprivileged\sreader\swhile\sa\scheckpoint\sis\srunning.\sAlso,\sif\sone\sor\smore\stransactions\sare\srecovered\sfrom\sa\slog\sfile,\sinitialize\sone\sof\sthe\saReadMark\sslots\sto\scontain\smxFrame\sas\spart\sof\sthe\srecovery\sprocess. +D 2012-07-17T14:37:12.494 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -227,7 +227,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4 -F src/test_vfs.c 9d934e111021d56c629efc73a796648c9519ad12 +F src/test_vfs.c da6d0d982b11756c94c1760196355d33d03ff745 F src/test_vfstrace.c 6b28adb2a0e8ecd0f2e3581482e1f658b11b4067 F src/test_wholenumber.c 3d2b9ed1505c40ad5c5ca2ad16ae7a289d6cc251 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 @@ -247,7 +247,7 @@ F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 -F src/wal.c 16345cdccc95e13b493854f1253b8395fcd519fa +F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 F src/walker.c 3112bb3afe1d85dc52317cb1d752055e9a781f8f F src/where.c 24c7494d8875ead994b4dfe5461340c27fd424ca @@ -926,8 +926,8 @@ F test/vtab_alter.test 9e374885248f69e251bdaacf480b04a197f125e5 F test/vtab_err.test 0d4d8eb4def1d053ac7c5050df3024fd47a3fbd8 F test/vtab_shared.test 82f463886e18d7f8395a4b6167c91815efe54839 F test/wal.test a040047d7f2b9f34bc4d597964e5e7c09609c635 -F test/wal2.test d5021064bebfc717fe2bf4db2536ea030b76a773 -F test/wal3.test 6504bbf348b2d6dfade64a064f1050fd617e8706 +F test/wal2.test 7ca814723c487de87d945cdc85c9a0fa45fa8de8 +F test/wal3.test b22eb662bcbc148c5f6d956eaf94b047f7afe9c0 F test/wal4.test 4744e155cd6299c6bd99d3eab1c82f77db9cdb3c F test/wal5.test f58ed4b8b542f71c7441da12fbd769d99b362437 F test/wal6.test 2e3bc767d9c2ce35c47106148d43fcbd072a93b3 @@ -945,7 +945,7 @@ F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 -F test/walro.test e6bb27762c9f22601cbb8bff6e0acfd124e74b63 +F test/walro.test f183c0003060a64793f9bfafef4c479418ed7fa8 F test/walshared.test 6dda2293880c300baf5d791c307f653094585761 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a F test/walthread.test a2ed5270eb695284d4ad27d252517bdc3317ee2a @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 6f167adf6050632e8c52f9ac4fb5583bcf27c576 -R aff021ec3312340384303b11ff294204 -U drh -Z 0bb1d32f801f3ecf912dcdccb6dd8135 +P 8c9ee1d78f99394eef73a177141ca9e1c67e4e07 +R 21a0c6942de3e9593e3e93f462c443c7 +U dan +Z a98d8c358c03bd601d60af308961371e diff --git a/manifest.uuid b/manifest.uuid index 9ca2d06a05..dad8b25eaa 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8c9ee1d78f99394eef73a177141ca9e1c67e4e07 \ No newline at end of file +e4163596339c2166f9c4356ab824fff8bda8d0b0 \ No newline at end of file diff --git a/src/test_vfs.c b/src/test_vfs.c index d1c34a38e4..fd2aa9fb07 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -81,6 +81,7 @@ struct Testvfs { Tcl_Obj *pScript; /* Script to execute */ TestvfsBuffer *pBuffer; /* List of shared buffers */ int isNoshm; + int isFullshm; int mask; /* Mask controlling [script] and [ioerr] */ @@ -760,6 +761,7 @@ static int tvfsShmOpen(sqlite3_file *pFile){ pFd = tvfsGetFd(pFile); p = (Testvfs *)pFd->pVfs->pAppData; + assert( 0==p->isFullshm ); assert( pFd->pShmId && pFd->pShm==0 && pFd->pNext==0 ); /* Evaluate the Tcl script: @@ -820,6 +822,10 @@ static int tvfsShmMap( TestvfsFd *pFd = tvfsGetFd(pFile); Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData); + if( p->isFullshm ){ + return sqlite3OsShmMap(pFd->pReal, iPage, pgsz, isWrite, pp); + } + if( 0==pFd->pShm ){ rc = tvfsShmOpen(pFile); if( rc!=SQLITE_OK ){ @@ -864,6 +870,10 @@ static int tvfsShmLock( int nLock; char zLock[80]; + if( p->isFullshm ){ + return sqlite3OsShmLock(pFd->pReal, ofst, n, flags); + } + if( p->pScript && p->mask&TESTVFS_SHMLOCK_MASK ){ sqlite3_snprintf(sizeof(zLock), zLock, "%d %d", ofst, n); nLock = (int)strlen(zLock); @@ -919,6 +929,11 @@ static void tvfsShmBarrier(sqlite3_file *pFile){ TestvfsFd *pFd = tvfsGetFd(pFile); Testvfs *p = (Testvfs *)(pFd->pVfs->pAppData); + if( p->isFullshm ){ + sqlite3OsShmBarrier(pFd->pReal); + return; + } + if( p->pScript && p->mask&TESTVFS_SHMBARRIER_MASK ){ tvfsExecTcl(p, "xShmBarrier", Tcl_NewStringObj(pFd->pShm->zFile, -1), pFd->pShmId, 0 @@ -936,6 +951,10 @@ static int tvfsShmUnmap( TestvfsBuffer *pBuffer = pFd->pShm; TestvfsFd **ppFd; + if( p->isFullshm ){ + return sqlite3OsShmUnmap(pFd->pReal, deleteFlag); + } + if( !pBuffer ) return SQLITE_OK; assert( pFd->pShmId && pFd->pShm ); @@ -1350,6 +1369,7 @@ static int testvfs_cmd( int i; int isNoshm = 0; /* True if -noshm is passed */ + int isFullshm = 0; /* True if -fullshm is passed */ int isDefault = 0; /* True if -default is passed */ int szOsFile = 0; /* Value passed to -szosfile */ int mxPathname = -1; /* Value passed to -mxpathname */ @@ -1365,6 +1385,7 @@ static int testvfs_cmd( if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isNoshm) ){ return TCL_ERROR; } + if( isNoshm ) isFullshm = 0; } else if( nSwitch>2 && 0==strncmp("-default", zSwitch, nSwitch) ){ if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isDefault) ){ @@ -1386,6 +1407,12 @@ static int testvfs_cmd( return TCL_ERROR; } } + else if( nSwitch>2 && 0==strncmp("-fullshm", zSwitch, nSwitch) ){ + if( Tcl_GetBooleanFromObj(interp, objv[i+1], &isFullshm) ){ + return TCL_ERROR; + } + if( isFullshm ) isNoshm = 0; + } else{ goto bad_args; } @@ -1427,6 +1454,7 @@ static int testvfs_cmd( pVfs->szOsFile = szOsFile; p->pVfs = pVfs; p->isNoshm = isNoshm; + p->isFullshm = isFullshm; p->mask = TESTVFS_ALL_MASK; sqlite3_vfs_register(pVfs, isDefault); diff --git a/src/wal.c b/src/wal.c index 931279eda3..28749fd31e 100644 --- a/src/wal.c +++ b/src/wal.c @@ -1199,6 +1199,7 @@ finished: pInfo->nBackfill = 0; pInfo->aReadMark[0] = 0; for(i=1; iaReadMark[i] = READMARK_NOT_USED; + if( pWal->hdr.mxFrame ) pInfo->aReadMark[1] = pWal->hdr.mxFrame; /* If more than one frame was recovered from the log file, report an ** event via sqlite3_log(). This is to help with identifying performance @@ -1699,7 +1700,7 @@ static int walCheckpoint( assert( y<=pWal->hdr.mxFrame ); rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1); if( rc==SQLITE_OK ){ - pInfo->aReadMark[i] = READMARK_NOT_USED; + pInfo->aReadMark[i] = (i==1 ? mxSafeFrame : READMARK_NOT_USED); walUnlockExclusive(pWal, WAL_READ_LOCK(i), 1); }else if( rc==SQLITE_BUSY ){ mxSafeFrame = y; diff --git a/test/wal2.test b/test/wal2.test index f30c0117f9..22db67991f 100644 --- a/test/wal2.test +++ b/test/wal2.test @@ -126,9 +126,11 @@ set RECOVER [list \ {1 7 unlock exclusive} {0 1 unlock exclusive} \ ] set READ [list \ - {4 1 lock exclusive} {4 1 unlock exclusive} \ {4 1 lock shared} {4 1 unlock shared} \ ] +set INITSLOT [list \ + {4 1 lock exclusive} {4 1 unlock exclusive} \ +] foreach {tn iInsert res wal_index_hdr_mod wal_locks} " 2 5 {5 15} 0 {$RECOVER $READ} @@ -141,7 +143,7 @@ foreach {tn iInsert res wal_index_hdr_mod wal_locks} " 9 12 {12 78} 7 {$RECOVER $READ} 10 13 {13 91} 8 {$RECOVER $READ} 11 14 {14 105} 9 {$RECOVER $READ} - 12 15 {15 120} -1 {$READ} + 12 15 {15 120} -1 {$INITSLOT $READ} " { do_test wal2-1.$tn.1 { diff --git a/test/wal3.test b/test/wal3.test index ccab93e5da..18e6075a4a 100644 --- a/test/wal3.test +++ b/test/wal3.test @@ -655,7 +655,7 @@ T filter xShmLock T script lock_callback proc lock_callback {method file handle spec} { - if {$spec == "4 1 unlock exclusive"} { + if {$spec == "1 7 unlock exclusive"} { T filter {} set ::r [catchsql { SELECT * FROM b } db2] } diff --git a/test/walro.test b/test/walro.test index 3ae7d53cd9..81e3e62ee9 100644 --- a/test/walro.test +++ b/test/walro.test @@ -163,6 +163,131 @@ do_multiclient_test tn { do_test 1.3.2.4 { code1 { sqlite3_extended_errcode db } } {SQLITE_READONLY_RECOVERY} + + #----------------------------------------------------------------------- + # Test cases 1.4.* check that checkpoints and log wraps don't prevent + # read-only connections from reading the database. + do_test 1.4.1 { + code1 { db close } + forcedelete test.db-shm + file exists test.db-shm + } {0} + + # Open one read-only and one read-write connection. Write some data + # and then run a checkpoint using the read-write connection. Then + # check the read-only connection can still read. + do_test 1.4.2 { + code1 { sqlite3 db file:test.db?readonly_shm=1 } + code2 { sqlite3 db2 test.db } + csql2 { + INSERT INTO t1 VALUES(1, 2); + INSERT INTO t1 VALUES(3, 4); + INSERT INTO t1 VALUES(5, 6); + PRAGMA wal_checkpoint; + } + } {0 {0 3 3}} + do_test 1.4.3 { + csql1 { SELECT * FROM t1 } + } {0 {a b c d e f g h i j k l 1 2 3 4 5 6}} + + # Using the read-write connection, open a transaction and write lots + # of data - causing a cache spill and a log wrap. Then check that the + # read-only connection can still read the database. + do_test 1.4.4.1 { + csql2 { + PRAGMA cache_size = 10; + BEGIN; + CREATE TABLE t2(x, y); + INSERT INTO t2 VALUES('abc', 'xyz'); + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + } + file size test.db-wal + } {147800} + do_test 1.4.4.2 { + csql1 { SELECT * FROM t1 } + } {0 {a b c d e f g h i j k l 1 2 3 4 5 6}} + do_test 1.4.4.3 { + csql2 COMMIT + csql1 { SELECT count(*) FROM t2 } + } {0 512} + do_test 1.4.5 { + code2 { db2 close } + code1 { db close } + } {} +} + +forcedelete test.db + +#----------------------------------------------------------------------- +# Test cases 2.* check that a read-only connection may read the +# database file while a checkpoint operation is ongoing. +# +do_multiclient_test tn { + # Do not run tests with the connections in the same process. + # + if {$tn==2} continue + + # Close all connections and delete the database. + # + code1 { db close } + code2 { db2 close } + code3 { db3 close } + forcedelete test.db + forcedelete walro + + foreach c {code1 code2 code3} { + $c { + sqlite3_shutdown + sqlite3_config_uri 1 + } + } + + proc tv_hook {x file args} { + if {[file tail $file]=="test.db-wal"} { + do_test 2.1.2 { + code2 { sqlite3 db2 file:test.db?readonly_shm=1 } + csql2 { SELECT count(*) FROM t2 } + } {0 4} + do_test 2.1.3 { + code2 { db2 close } + } {} + } + } + + do_test 2.1.1 { + testvfs tv -default 1 -fullshm 1 + tv script tv_hook + tv filter {} + code1 { sqlite3 db test.db } + csql1 { + PRAGMA journal_mode = WAL; + BEGIN; + CREATE TABLE t2(x, y); + INSERT INTO t2 VALUES('abc', 'xyz'); + INSERT INTO t2 SELECT x||y, y||x FROM t2; + INSERT INTO t2 SELECT x||y, y||x FROM t2; + COMMIT; + } + } {0 wal} + + tv filter xSync + set res [csql1 { PRAGMA wal_checkpoint }] + do_test 2.1.4 { set res } {0 {0 2 2}} + + do_test 2.1.5 { + code1 { db close } + code1 { tv delete } + } {} } finish_test + + From 3b2c9b3250b9332c15ece5574061235cf6f90139 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 23 Jul 2012 19:25:39 +0000 Subject: [PATCH 35/69] Modify the code in vdbesort.c so that most reads and writes to temporary files are aligned page-sized blocks. FossilOrigin-Name: 55e47ef338c42f95f0f071d6ec92cd2480f9f1fe --- manifest | 17 ++- manifest.uuid | 2 +- src/vdbesort.c | 385 +++++++++++++++++++++++++++++++++-------------- test/index4.test | 24 +++ 4 files changed, 305 insertions(+), 123 deletions(-) diff --git a/manifest b/manifest index 8576e56420..c893586b7a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthere\sis\salways\sat\sleast\sone\saReadMark\sslot\susable\sby\san\sunprivileged\sreader\swhile\sa\scheckpoint\sis\srunning.\sAlso,\sif\sone\sor\smore\stransactions\sare\srecovered\sfrom\sa\slog\sfile,\sinitialize\sone\sof\sthe\saReadMark\sslots\sto\scontain\smxFrame\sas\spart\sof\sthe\srecovery\sprocess. -D 2012-07-17T14:37:12.494 +C Modify\sthe\scode\sin\svdbesort.c\sso\sthat\smost\sreads\sand\swrites\sto\stemporary\sfiles\sare\saligned\spage-sized\sblocks. +D 2012-07-23T19:25:39.921 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -244,7 +244,7 @@ F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 -F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 +F src/vdbesort.c 6822221af97e57bd17091cfe5abec902c1ef04ad F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b @@ -530,7 +530,7 @@ F test/incrvacuum_ioerr.test 22f208d01c528403240e05beecc41dc98ed01637 F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7 -F test/index4.test 2983216eb8c86ee62d9ed7cb206b5cc3331c0026 +F test/index4.test 1e299862024012e0165531cce251572f7f084d15 F test/indexedby.test be501e381b82b2f8ab406309ba7aac46e221f4ad F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -1005,7 +1005,10 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8c9ee1d78f99394eef73a177141ca9e1c67e4e07 -R 21a0c6942de3e9593e3e93f462c443c7 +P e4163596339c2166f9c4356ab824fff8bda8d0b0 +R ed9539f5559c8070d5186f316e47e4b4 +T *branch * sorter-coalesce-writes +T *sym-sorter-coalesce-writes * +T -sym-trunk * U dan -Z a98d8c358c03bd601d60af308961371e +Z 0e4fc9d4c65d0946db257b091fe0d573 diff --git a/manifest.uuid b/manifest.uuid index dad8b25eaa..53013f689c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e4163596339c2166f9c4356ab824fff8bda8d0b0 \ No newline at end of file +55e47ef338c42f95f0f071d6ec92cd2480f9f1fe \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index afea1f510a..393e937d32 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -22,6 +22,7 @@ typedef struct VdbeSorterIter VdbeSorterIter; typedef struct SorterRecord SorterRecord; +typedef struct FileWriter FileWriter; /* ** NOTES ON DATA STRUCTURE USED FOR N-WAY MERGES: @@ -119,6 +120,22 @@ struct VdbeSorterIter { sqlite3_file *pFile; /* File iterator is reading from */ u8 *aAlloc; /* Allocated space */ u8 *aKey; /* Pointer to current key */ + u8 *aBuffer; /* Current read buffer */ + int nBuffer; /* Size of read buffer in bytes */ +}; + +/* +** An instance of this structure is used to separate the stream of records +** being written to files by the merge-sort code into aligned, page-sized +** blocks. +*/ +struct FileWriter { + u8 *aBuffer; /* Pointer to write buffer */ + int nBuffer; /* Size of write buffer in bytes */ + int iBufStart; /* First byte of buffer to write */ + int iBufEnd; /* Last byte of buffer to write */ + i64 iWriteOff; /* Offset of start of buffer in file */ + sqlite3_file *pFile; /* File to write to */ }; /* @@ -144,9 +161,107 @@ struct SorterRecord { */ static void vdbeSorterIterZero(sqlite3 *db, VdbeSorterIter *pIter){ sqlite3DbFree(db, pIter->aAlloc); + sqlite3DbFree(db, pIter->aBuffer); memset(pIter, 0, sizeof(VdbeSorterIter)); } +/* +** Read nByte bytes of data from the stream of data iterated by object p. +** If successful, set *ppOut to point to a buffer containing the data +** and return SQLITE_OK. Otherwise, if an error occurs, return an SQLite +** error code. +** +** The buffer indicated by *ppOut may only be considered valid until the +** next call to this function. +*/ +static int vdbeSorterIterRead( + sqlite3 *db, /* Database handle (for malloc) */ + VdbeSorterIter *p, /* Iterator */ + int nByte, /* Bytes of data to read */ + u8 **ppOut /* OUT: Pointer to buffer containing data */ +){ + int iBuf; + int nAvail; + assert( p->aBuffer ); + + iBuf = p->iReadOff % p->nBuffer; + if( iBuf==0 ){ + int nRead; + int rc; + + nRead = p->iEof - p->iReadOff; + if( nRead>p->nBuffer ) nRead = p->nBuffer; + assert( nRead>0 ); + rc = sqlite3OsRead(p->pFile, p->aBuffer, nRead, p->iReadOff); + assert( rc!=SQLITE_IOERR_SHORT_READ ); + if( rc!=SQLITE_OK ) return rc; + } + nAvail = p->nBuffer - iBuf; + + if( nByte<=nAvail ){ + *ppOut = &p->aBuffer[iBuf]; + p->iReadOff += nByte; + }else{ + int nRem; + if( p->nAllocnAlloc*2; + while( nByte>nNew ) nNew = nNew*2; + + p->aAlloc = sqlite3DbReallocOrFree(db, p->aAlloc, nNew); + if( !p->aAlloc ) return SQLITE_NOMEM; + } + + memcpy(p->aAlloc, &p->aBuffer[iBuf], nAvail); + p->iReadOff += nAvail; + nRem = nByte - nAvail; + while( nRem>0 ){ + int rc; + int nCopy; + u8 *aNext; + + nCopy = nRem; + if( nRem>p->nBuffer ) nCopy = p->nBuffer; + rc = vdbeSorterIterRead(db, p, nCopy, &aNext); + if( rc!=SQLITE_OK ) return rc; + assert( aNext!=p->aAlloc ); + + memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy); + nRem -= nCopy; + } + + *ppOut = p->aAlloc; + } + + return SQLITE_OK; +} + +/* +** Read a varint from the stream of data accessed by p. Set *pnOut to +** the value read. +*/ +static int vdbeSorterIterVarint(sqlite3 *db, VdbeSorterIter *p, u64 *pnOut){ + int iBuf; + + iBuf = p->iReadOff % p->nBuffer; + if( iBuf && (p->nBuffer-iBuf)>=9 ){ + p->iReadOff += sqlite3GetVarint(&p->aBuffer[iBuf], pnOut); + }else{ + u8 aVarint[9]; + int i; + for(i=0; iiEof>=pIter->iReadOff ); - if( pIter->iEof-pIter->iReadOff>5 ){ - nRead = 5; - }else{ - nRead = (int)(pIter->iEof - pIter->iReadOff); - } - if( nRead<=0 ){ + if( pIter->iReadOff>=pIter->iEof ){ /* This is an EOF condition */ vdbeSorterIterZero(db, pIter); return SQLITE_OK; } - rc = sqlite3OsRead(pIter->pFile, pIter->aAlloc, nRead, pIter->iReadOff); + rc = vdbeSorterIterVarint(db, pIter, &nRec); if( rc==SQLITE_OK ){ - iOff = getVarint32(pIter->aAlloc, nRec); - if( (iOff+nRec)>nRead ){ - int nRead2; /* Number of extra bytes to read */ - if( (iOff+nRec)>pIter->nAlloc ){ - int nNew = pIter->nAlloc*2; - while( (iOff+nRec)>nNew ) nNew = nNew*2; - pIter->aAlloc = sqlite3DbReallocOrFree(db, pIter->aAlloc, nNew); - if( !pIter->aAlloc ) return SQLITE_NOMEM; - pIter->nAlloc = nNew; - } - - nRead2 = iOff + nRec - nRead; - rc = sqlite3OsRead( - pIter->pFile, &pIter->aAlloc[nRead], nRead2, pIter->iReadOff+nRead - ); - } - } - - assert( rc!=SQLITE_OK || nRec>0 ); - pIter->iReadOff += iOff+nRec; - pIter->nKey = nRec; - pIter->aKey = &pIter->aAlloc[iOff]; - return rc; -} - -/* -** Write a single varint, value iVal, to file-descriptor pFile. Return -** SQLITE_OK if successful, or an SQLite error code if some error occurs. -** -** The value of *piOffset when this function is called is used as the byte -** offset in file pFile to write to. Before returning, *piOffset is -** incremented by the number of bytes written. -*/ -static int vdbeSorterWriteVarint( - sqlite3_file *pFile, /* File to write to */ - i64 iVal, /* Value to write as a varint */ - i64 *piOffset /* IN/OUT: Write offset in file pFile */ -){ - u8 aVarint[9]; /* Buffer large enough for a varint */ - int nVarint; /* Number of used bytes in varint */ - int rc; /* Result of write() call */ - - nVarint = sqlite3PutVarint(aVarint, iVal); - rc = sqlite3OsWrite(pFile, aVarint, nVarint, *piOffset); - *piOffset += nVarint; - - return rc; -} - -/* -** Read a single varint from file-descriptor pFile. Return SQLITE_OK if -** successful, or an SQLite error code if some error occurs. -** -** The value of *piOffset when this function is called is used as the -** byte offset in file pFile from whence to read the varint. If successful -** (i.e. if no IO error occurs), then *piOffset is set to the offset of -** the first byte past the end of the varint before returning. *piVal is -** set to the integer value read. If an error occurs, the final values of -** both *piOffset and *piVal are undefined. -*/ -static int vdbeSorterReadVarint( - sqlite3_file *pFile, /* File to read from */ - i64 *piOffset, /* IN/OUT: Read offset in pFile */ - i64 *piVal /* OUT: Value read from file */ -){ - u8 aVarint[9]; /* Buffer large enough for a varint */ - i64 iOff = *piOffset; /* Offset in file to read from */ - int rc; /* Return code */ - - rc = sqlite3OsRead(pFile, aVarint, 9, iOff); - if( rc==SQLITE_OK ){ - *piOffset += getVarint(aVarint, (u64 *)piVal); + pIter->nKey = (int)nRec; + rc = vdbeSorterIterRead(db, pIter, nRec, &pIter->aKey); } return rc; @@ -264,22 +301,43 @@ static int vdbeSorterIterInit( VdbeSorterIter *pIter, /* Iterator to populate */ i64 *pnByte /* IN/OUT: Increment this value by PMA size */ ){ - int rc; + int rc = SQLITE_OK; + int nBuf; + + nBuf = sqlite3BtreeGetPageSize(db->aDb[0].pBt); assert( pSorter->iWriteOff>iStart ); assert( pIter->aAlloc==0 ); + assert( pIter->aBuffer==0 ); pIter->pFile = pSorter->pTemp1; pIter->iReadOff = iStart; pIter->nAlloc = 128; pIter->aAlloc = (u8 *)sqlite3DbMallocRaw(db, pIter->nAlloc); - if( !pIter->aAlloc ){ + pIter->nBuffer = nBuf; + pIter->aBuffer = (u8 *)sqlite3DbMallocRaw(db, nBuf); + + if( !pIter->aBuffer ){ rc = SQLITE_NOMEM; }else{ - i64 nByte; /* Total size of PMA in bytes */ - rc = vdbeSorterReadVarint(pSorter->pTemp1, &pIter->iReadOff, &nByte); - *pnByte += nByte; - pIter->iEof = pIter->iReadOff + nByte; + int iBuf; + + iBuf = pIter->iReadOff % nBuf; + if( iBuf ){ + rc = sqlite3OsRead( + pSorter->pTemp1, &pIter->aBuffer[iBuf], nBuf-iBuf, iStart + ); + assert( rc!=SQLITE_IOERR_SHORT_READ ); + } + + if( rc==SQLITE_OK ){ + u64 nByte; /* Size of PMA in bytes */ + pIter->iEof = iStart + pIter->nBuffer; + rc = vdbeSorterIterVarint(db, pIter, &nByte); + pIter->iEof = pIter->iReadOff + nByte; + *pnByte += nByte; + } } + if( rc==SQLITE_OK ){ rc = vdbeSorterIterNext(db, pIter); } @@ -531,6 +589,92 @@ static int vdbeSorterSort(VdbeCursor *pCsr){ return SQLITE_OK; } +/* +** Initialize a file-writer object. +*/ +static int fileWriterInit( + sqlite3 *db, /* Database (for malloc) */ + sqlite3_file *pFile, /* File to write to */ + FileWriter *p, /* Object to populate */ + i64 iStart /* Offset of pFile to begin writing at */ +){ + int nBuf = sqlite3BtreeGetPageSize(db->aDb[0].pBt); + + memset(p, 0, sizeof(FileWriter)); + p->aBuffer = (u8 *)sqlite3DbMallocRaw(db, nBuf); + if( !p->aBuffer ) return SQLITE_NOMEM; + + p->iBufEnd = p->iBufStart = (iStart % nBuf); + p->iWriteOff = iStart - p->iBufStart; + p->nBuffer = nBuf; + p->pFile = pFile; + return SQLITE_OK; +} + +/* +** Write nData bytes of data to the file-write object. Return SQLITE_OK +** if successful, or an SQLite error code if an error occurs. +*/ +static int fileWriterWrite(FileWriter *p, u8 *pData, int nData){ + int nRem = nData; + while( nRem>0 ){ + int nCopy = nRem; + if( nCopy>(p->nBuffer - p->iBufEnd) ){ + nCopy = p->nBuffer - p->iBufEnd; + } + + memcpy(&p->aBuffer[p->iBufEnd], &pData[nData-nRem], nCopy); + p->iBufEnd += nCopy; + if( p->iBufEnd==p->nBuffer ){ + int rc = sqlite3OsWrite(p->pFile, + &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, + p->iWriteOff + p->iBufStart + ); + if( rc!=SQLITE_OK ) return rc; + p->iBufStart = p->iBufEnd = 0; + p->iWriteOff += p->nBuffer; + } + assert( p->iBufEndnBuffer ); + + nRem -= nCopy; + } + + return SQLITE_OK; +} + +/* +** Flush any buffered data to disk and clean up the file-writer object. +** The results of using the file-writer after this call are undefined. +** Return SQLITE_OK if flushing the buffered data succeeds or is not +** required. Otherwise, return an SQLite error code. +** +** Before returning, set *piEof to the offset immediately following the +** last byte written to the file. +*/ +static int fileWriterFinish(sqlite3 *db, FileWriter *p, i64 *piEof){ + int rc = SQLITE_OK; + if( p->aBuffer && p->iBufEnd>p->iBufStart ){ + rc = sqlite3OsWrite(p->pFile, + &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, + p->iWriteOff + p->iBufStart + ); + } + *piEof = (p->iWriteOff + p->iBufEnd); + sqlite3DbFree(db, p->aBuffer); + memset(p, 0, sizeof(FileWriter)); + return rc; +} + +/* +** Write value iVal encoded as a varint to the file-write object. Return +** SQLITE_OK if successful, or an SQLite error code if an error occurs. +*/ +static int fileWriterWriteVarint(FileWriter *p, u64 iVal){ + int nByte; + u8 aByte[10]; + nByte = sqlite3PutVarint(aByte, iVal); + return fileWriterWrite(p, aByte, nByte); +} /* ** Write the current contents of the in-memory linked-list to a PMA. Return @@ -547,7 +691,11 @@ static int vdbeSorterSort(VdbeCursor *pCsr){ */ static int vdbeSorterListToPMA(sqlite3 *db, VdbeCursor *pCsr){ int rc = SQLITE_OK; /* Return code */ + int rc2; /* fileWriterFinish return code */ VdbeSorter *pSorter = pCsr->pSorter; + FileWriter writer; + + memset(&writer, 0, sizeof(FileWriter)); if( pSorter->nInMemory==0 ){ assert( pSorter->pRecord==0 ); @@ -565,41 +713,32 @@ static int vdbeSorterListToPMA(sqlite3 *db, VdbeCursor *pCsr){ } if( rc==SQLITE_OK ){ - i64 iOff = pSorter->iWriteOff; + rc = fileWriterInit(db, pSorter->pTemp1, &writer, pSorter->iWriteOff); + } + + if( rc==SQLITE_OK ){ SorterRecord *p; SorterRecord *pNext = 0; - static const char eightZeros[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; + pSorter->nPMA++; - rc = vdbeSorterWriteVarint(pSorter->pTemp1, pSorter->nInMemory, &iOff); + rc = fileWriterWriteVarint(&writer, pSorter->nInMemory); for(p=pSorter->pRecord; rc==SQLITE_OK && p; p=pNext){ pNext = p->pNext; - rc = vdbeSorterWriteVarint(pSorter->pTemp1, p->nVal, &iOff); - + rc = fileWriterWriteVarint(&writer, p->nVal); if( rc==SQLITE_OK ){ - rc = sqlite3OsWrite(pSorter->pTemp1, p->pVal, p->nVal, iOff); - iOff += p->nVal; + rc = fileWriterWrite(&writer, p->pVal, p->nVal); } sqlite3DbFree(db, p); } - /* This assert verifies that unless an error has occurred, the size of - ** the PMA on disk is the same as the expected size stored in - ** pSorter->nInMemory. */ - assert( rc!=SQLITE_OK || pSorter->nInMemory==( - iOff-pSorter->iWriteOff-sqlite3VarintLen(pSorter->nInMemory) - )); - - pSorter->iWriteOff = iOff; - if( rc==SQLITE_OK ){ - /* Terminate each file with 8 extra bytes so that from any offset - ** in the file we can always read 9 bytes without a SHORT_READ error */ - rc = sqlite3OsWrite(pSorter->pTemp1, eightZeros, 8, iOff); - } pSorter->pRecord = p; } + rc2 = fileWriterFinish(db, &writer, &pSorter->iWriteOff); + if( rc==SQLITE_OK ) rc = rc2; + return rc; } @@ -642,8 +781,14 @@ int sqlite3VdbeSorterWrite( (pSorter->nInMemory>pSorter->mxPmaSize) || (pSorter->nInMemory>pSorter->mnPmaSize && sqlite3HeapNearlyFull()) )){ +#ifdef SQLITE_DEBUG + i64 nExpect = pSorter->iWriteOff + + sqlite3VarintLen(pSorter->nInMemory) + + pSorter->nInMemory; +#endif rc = vdbeSorterListToPMA(db, pCsr); pSorter->nInMemory = 0; + assert( rc!=SQLITE_OK || (nExpect==pSorter->iWriteOff) ); } return rc; @@ -704,7 +849,7 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, VdbeCursor *pCsr, int *pbEof){ return vdbeSorterSort(pCsr); } - /* Write the current b-tree to a PMA. Close the b-tree cursor. */ + /* Write the current in-memory list to a PMA. */ rc = vdbeSorterListToPMA(db, pCsr); if( rc!=SQLITE_OK ) return rc; @@ -726,8 +871,12 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, VdbeCursor *pCsr, int *pbEof){ rc==SQLITE_OK && iNew*SORTER_MAX_MERGE_COUNTnPMA; iNew++ ){ + int rc2; /* Return code from fileWriterFinish() */ + FileWriter writer; /* Object used to write to disk */ i64 nWrite; /* Number of bytes in new PMA */ + memset(&writer, 0, sizeof(FileWriter)); + /* If there are SORTER_MAX_MERGE_COUNT or less PMAs in file pTemp1, ** initialize an iterator for each of them and break out of the loop. ** These iterators will be incrementally merged as the VDBE layer calls @@ -749,24 +898,30 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, VdbeCursor *pCsr, int *pbEof){ rc = vdbeSorterOpenTempFile(db, &pTemp2); } + rc = fileWriterInit(db, pTemp2, &writer, iWrite2); + if( rc==SQLITE_OK ){ - rc = vdbeSorterWriteVarint(pTemp2, nWrite, &iWrite2); + rc = fileWriterWriteVarint(&writer, nWrite); } if( rc==SQLITE_OK ){ int bEof = 0; while( rc==SQLITE_OK && bEof==0 ){ - int nToWrite; VdbeSorterIter *pIter = &pSorter->aIter[ pSorter->aTree[1] ]; assert( pIter->pFile ); - nToWrite = pIter->nKey + sqlite3VarintLen(pIter->nKey); - rc = sqlite3OsWrite(pTemp2, pIter->aAlloc, nToWrite, iWrite2); - iWrite2 += nToWrite; + + rc = fileWriterWriteVarint(&writer, pIter->nKey); + if( rc==SQLITE_OK ){ + rc = fileWriterWrite(&writer, pIter->aKey, pIter->nKey); + } if( rc==SQLITE_OK ){ rc = sqlite3VdbeSorterNext(db, pCsr, &bEof); } } } + + rc2 = fileWriterFinish(db, &writer, &iWrite2); + if( rc==SQLITE_OK ) rc = rc2; } if( pSorter->nPMA<=SORTER_MAX_MERGE_COUNT ){ diff --git a/test/index4.test b/test/index4.test index 018ed744a1..7da77715a4 100644 --- a/test/index4.test +++ b/test/index4.test @@ -17,6 +17,30 @@ source $testdir/tester.tcl set testprefix index4 +#proc str {n} { string range [string repeat [format %.06d. $n] 20] 0 101 } +#db func str str +#do_execsql_test 1.1 { +# BEGIN; +# CREATE TABLE t1(x); +# INSERT INTO t1 VALUES(str(1)); +# INSERT INTO t1 SELECT str(rowid + 1) FROM t1; -- 2 +# INSERT INTO t1 SELECT str(rowid + 2) FROM t1; -- 4 +# INSERT INTO t1 SELECT str(rowid + 4) FROM t1; -- 8 +# INSERT INTO t1 SELECT str(rowid + 8) FROM t1; -- 16 +# INSERT INTO t1 SELECT str(rowid + 16) FROM t1; -- 32 +# INSERT INTO t1 SELECT str(rowid + 32) FROM t1; -- 64 +# INSERT INTO t1 SELECT str(rowid + 64) FROM t1; -- 128 +# INSERT INTO t1 SELECT str(rowid + 128) FROM t1; -- 256 +# INSERT INTO t1 SELECT str(rowid + 256) FROM t1; -- 512 +# INSERT INTO t1 SELECT str(rowid + 512) FROM t1; -- 1024 +# INSERT INTO t1 SELECT str(rowid + 1024) FROM t1; -- 2048 +# INSERT INTO t1 SELECT str(rowid + 2048) FROM t1; -- 4096 +# INSERT INTO t1 SELECT str(rowid + 4096) FROM t1; -- 8192 +# INSERT INTO t1 SELECT str(rowid + 8192) FROM t1; -- 16384 +# INSERT INTO t1 SELECT str(rowid + 16384) FROM t1; -- 32768 +# COMMIT; +#} + do_execsql_test 1.1 { BEGIN; CREATE TABLE t1(x); From 407fae09ee56e7b86097a98c16a606f49df342bb Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 23 Jul 2012 20:10:35 +0000 Subject: [PATCH 36/69] Fix an edge case in vdbesort.c. FossilOrigin-Name: 4ba266fc534f390267180eca8d68b8d5f0b7f832 --- manifest | 15 ++++++--------- manifest.uuid | 2 +- src/vdbesort.c | 10 +++++++--- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index c893586b7a..8ee9b917a6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sthe\scode\sin\svdbesort.c\sso\sthat\smost\sreads\sand\swrites\sto\stemporary\sfiles\sare\saligned\spage-sized\sblocks. -D 2012-07-23T19:25:39.921 +C Fix\san\sedge\scase\sin\svdbesort.c. +D 2012-07-23T20:10:35.296 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -244,7 +244,7 @@ F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 -F src/vdbesort.c 6822221af97e57bd17091cfe5abec902c1ef04ad +F src/vdbesort.c bd37dbd4a023f75e9cd1eec18e171aa6f2552d20 F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b @@ -1005,10 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P e4163596339c2166f9c4356ab824fff8bda8d0b0 -R ed9539f5559c8070d5186f316e47e4b4 -T *branch * sorter-coalesce-writes -T *sym-sorter-coalesce-writes * -T -sym-trunk * +P 55e47ef338c42f95f0f071d6ec92cd2480f9f1fe +R c1d0187a30b4d8ec69c9c7f13c2ce356 U dan -Z 0e4fc9d4c65d0946db257b091fe0d573 +Z 60c5c030c4ed6dd425cd291cf7eefd27 diff --git a/manifest.uuid b/manifest.uuid index 53013f689c..239b7c9706 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -55e47ef338c42f95f0f071d6ec92cd2480f9f1fe \ No newline at end of file +4ba266fc534f390267180eca8d68b8d5f0b7f832 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 393e937d32..7778196f1c 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -321,17 +321,21 @@ static int vdbeSorterIterInit( }else{ int iBuf; - iBuf = pIter->iReadOff % nBuf; + iBuf = iStart % nBuf; if( iBuf ){ + int nRead = nBuf - iBuf; + if( (iStart + nRead) > pSorter->iWriteOff ){ + nRead = pSorter->iWriteOff - iStart; + } rc = sqlite3OsRead( - pSorter->pTemp1, &pIter->aBuffer[iBuf], nBuf-iBuf, iStart + pSorter->pTemp1, &pIter->aBuffer[iBuf], nRead, iStart ); assert( rc!=SQLITE_IOERR_SHORT_READ ); } if( rc==SQLITE_OK ){ u64 nByte; /* Size of PMA in bytes */ - pIter->iEof = iStart + pIter->nBuffer; + pIter->iEof = pSorter->iWriteOff; rc = vdbeSorterIterVarint(db, pIter, &nByte); pIter->iEof = pIter->iReadOff + nByte; *pnByte += nByte; From 2b596da8b72647411a679b40c1a8bf2474c9b6b6 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 23 Jul 2012 21:43:19 +0000 Subject: [PATCH 37/69] Refactor field names in the SelectDest object to make them distinct and easier to grep for. FossilOrigin-Name: b589f1efb3907a68058bf2ee981dca126d083e83 --- manifest | 20 ++++----- manifest.uuid | 2 +- src/expr.c | 8 ++-- src/insert.c | 12 ++--- src/select.c | 115 ++++++++++++++++++++++++------------------------ src/sqliteInt.h | 8 ++-- 6 files changed, 83 insertions(+), 82 deletions(-) diff --git a/manifest b/manifest index 8576e56420..a71ad43270 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Ensure\sthat\sthere\sis\salways\sat\sleast\sone\saReadMark\sslot\susable\sby\san\sunprivileged\sreader\swhile\sa\scheckpoint\sis\srunning.\sAlso,\sif\sone\sor\smore\stransactions\sare\srecovered\sfrom\sa\slog\sfile,\sinitialize\sone\sof\sthe\saReadMark\sslots\sto\scontain\smxFrame\sas\spart\sof\sthe\srecovery\sprocess. -D 2012-07-17T14:37:12.494 +C Refactor\sfield\snames\sin\sthe\sSelectDest\sobject\sto\smake\sthem\sdistinct\sand\seasier\nto\sgrep\sfor. +D 2012-07-23T21:43:19.390 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -132,7 +132,7 @@ F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 500d019da966631ad957c37705642be87524463b F src/date.c 067a81c9942c497aafd2c260e13add8a7d0c7dd4 F src/delete.c 4c20ea4f6213b3bc1c6a510586864b679946e05e -F src/expr.c 06a7733d19dc725dc46ba51afd9feadb4b85d991 +F src/expr.c e2927abf9c69ce4ff9a931bd201946961c34819a F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5 F src/func.c 18dfedfb857e100b05755a1b12e88b389f957879 @@ -140,7 +140,7 @@ F src/global.c 4cfdca5cb0edd33c4d021baec4ede958cb2c793b F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 -F src/insert.c 0bbffe75c254c62a5686ab5e7f88e29235e16174 +F src/insert.c 770ed633830fb49d73d90c3fdf20b703973e1e84 F src/journal.c 552839e54d1bf76fb8f7abe51868b66acacf6a0e F src/legacy.c a199d7683d60cef73089e892409113e69c23a99f F src/lempar.c 0ee69fca0be54cd93939df98d2aca4ca46f44416 @@ -176,11 +176,11 @@ F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 -F src/select.c f6c4833c4d8e94714761d99013d74f381e084f1d +F src/select.c eecb852bc7d8c00253b9b9cbab9e528f0d4dd9a5 F src/shell.c 076e1c90d594644f36027c8ecff9a392cf2d3a06 F src/sqlite.h.in 310ae7e538883fa1619ab0638c775ce11ad43015 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h 2bc2ebc2ff1a2b530ee5ed9ffd46c6fce93b244c +F src/sqliteInt.h ed41801550b0b8fb8217fcfd2e362118062b30c0 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 8c9ee1d78f99394eef73a177141ca9e1c67e4e07 -R 21a0c6942de3e9593e3e93f462c443c7 -U dan -Z a98d8c358c03bd601d60af308961371e +P e4163596339c2166f9c4356ab824fff8bda8d0b0 +R adb51909ed26f080ecf60f96fb1f4ac0 +U drh +Z 14fefb32c4db69f21df1898d6655f0c2 diff --git a/manifest.uuid b/manifest.uuid index dad8b25eaa..4c27b7b677 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e4163596339c2166f9c4356ab824fff8bda8d0b0 \ No newline at end of file +b589f1efb3907a68058bf2ee981dca126d083e83 \ No newline at end of file diff --git a/src/expr.c b/src/expr.c index 1e46596a2f..790aa45f3b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -1701,7 +1701,7 @@ int sqlite3CodeSubselect( assert( !isRowid ); sqlite3SelectDestInit(&dest, SRT_Set, pExpr->iTable); - dest.affinity = (u8)affinity; + dest.affSdst = (u8)affinity; assert( (pExpr->iTable&0x0000FFFF)==pExpr->iTable ); pExpr->x.pSelect->iLimit = 0; if( sqlite3Select(pParse, pExpr->x.pSelect, &dest) ){ @@ -1794,11 +1794,11 @@ int sqlite3CodeSubselect( sqlite3SelectDestInit(&dest, 0, ++pParse->nMem); if( pExpr->op==TK_SELECT ){ dest.eDest = SRT_Mem; - sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iParm); + sqlite3VdbeAddOp2(v, OP_Null, 0, dest.iSDParm); VdbeComment((v, "Init subquery result")); }else{ dest.eDest = SRT_Exists; - sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iParm); + sqlite3VdbeAddOp2(v, OP_Integer, 0, dest.iSDParm); VdbeComment((v, "Init EXISTS result")); } sqlite3ExprDelete(pParse->db, pSel->pLimit); @@ -1808,7 +1808,7 @@ int sqlite3CodeSubselect( if( sqlite3Select(pParse, pSel, &dest) ){ return 0; } - rReg = dest.iParm; + rReg = dest.iSDParm; ExprSetIrreducible(pExpr); break; } diff --git a/src/insert.c b/src/insert.c index a589c8aef6..faed6470c2 100644 --- a/src/insert.c +++ b/src/insert.c @@ -597,7 +597,7 @@ void sqlite3Insert( VdbeComment((v, "SELECT eof flag")); sqlite3SelectDestInit(&dest, SRT_Coroutine, ++pParse->nMem); addrSelect = sqlite3VdbeCurrentAddr(v)+2; - sqlite3VdbeAddOp2(v, OP_Integer, addrSelect-1, dest.iParm); + sqlite3VdbeAddOp2(v, OP_Integer, addrSelect-1, dest.iSDParm); j1 = sqlite3VdbeAddOp2(v, OP_Goto, 0, 0); VdbeComment((v, "Jump over SELECT coroutine")); @@ -608,15 +608,15 @@ void sqlite3Insert( goto insert_cleanup; } sqlite3VdbeAddOp2(v, OP_Integer, 1, regEof); /* EOF <- 1 */ - sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); /* yield X */ + sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); /* yield X */ sqlite3VdbeAddOp2(v, OP_Halt, SQLITE_INTERNAL, OE_Abort); VdbeComment((v, "End of SELECT coroutine")); sqlite3VdbeJumpHere(v, j1); /* label B: */ - regFromSelect = dest.iMem; + regFromSelect = dest.iSdst; assert( pSelect->pEList ); nColumn = pSelect->pEList->nExpr; - assert( dest.nMem==nColumn ); + assert( dest.nSdst==nColumn ); /* Set useTempTable to TRUE if the result of the SELECT statement ** should be written into a temporary table (template 4). Set to @@ -652,7 +652,7 @@ void sqlite3Insert( regRec = sqlite3GetTempReg(pParse); regTempRowid = sqlite3GetTempReg(pParse); sqlite3VdbeAddOp2(v, OP_OpenEphemeral, srcTab, nColumn); - addrTop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); + addrTop = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); addrIf = sqlite3VdbeAddOp1(v, OP_If, regEof); sqlite3VdbeAddOp3(v, OP_MakeRecord, regFromSelect, nColumn, regRec); sqlite3VdbeAddOp2(v, OP_NewRowid, srcTab, regTempRowid); @@ -789,7 +789,7 @@ void sqlite3Insert( ** goto C ** D: ... */ - addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm); + addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iSDParm); addrInsTop = sqlite3VdbeAddOp1(v, OP_If, regEof); } diff --git a/src/select.c b/src/select.c index d79a6112f7..1d424caf1e 100644 --- a/src/select.c +++ b/src/select.c @@ -36,10 +36,10 @@ static void clearSelect(sqlite3 *db, Select *p){ */ void sqlite3SelectDestInit(SelectDest *pDest, int eDest, int iParm){ pDest->eDest = (u8)eDest; - pDest->iParm = iParm; - pDest->affinity = 0; - pDest->iMem = 0; - pDest->nMem = 0; + pDest->iSDParm = iParm; + pDest->affSdst = 0; + pDest->iSdst = 0; + pDest->nSdst = 0; } @@ -551,7 +551,7 @@ static void selectInnerLoop( int hasDistinct; /* True if the DISTINCT keyword is present */ int regResult; /* Start of memory holding result set */ int eDest = pDest->eDest; /* How to dispose of results */ - int iParm = pDest->iParm; /* First argument to disposal method */ + int iParm = pDest->iSDParm; /* First argument to disposal method */ int nResultCol; /* Number of result columns */ assert( v ); @@ -569,14 +569,14 @@ static void selectInnerLoop( }else{ nResultCol = pEList->nExpr; } - if( pDest->iMem==0 ){ - pDest->iMem = pParse->nMem+1; - pDest->nMem = nResultCol; + if( pDest->iSdst==0 ){ + pDest->iSdst = pParse->nMem+1; + pDest->nSdst = nResultCol; pParse->nMem += nResultCol; }else{ - assert( pDest->nMem==nResultCol ); + assert( pDest->nSdst==nResultCol ); } - regResult = pDest->iMem; + regResult = pDest->iSdst; if( nColumn>0 ){ for(i=0; iaffinity = sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affinity); + p->affinity = sqlite3CompareAffinity(pEList->a[0].pExpr, pDest->affSdst); if( pOrderBy ){ /* At first glance you would think we could optimize out the ** ORDER BY in this case since the order of entries in the set @@ -710,7 +710,7 @@ static void selectInnerLoop( pushOntoSorter(pParse, pOrderBy, p, r1); sqlite3ReleaseTempReg(pParse, r1); }else if( eDest==SRT_Coroutine ){ - sqlite3VdbeAddOp1(v, OP_Yield, pDest->iParm); + sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm); }else{ sqlite3VdbeAddOp2(v, OP_ResultRow, regResult, nColumn); sqlite3ExprCacheAffinityChange(pParse, regResult, nColumn); @@ -890,7 +890,7 @@ static void generateSortTail( ExprList *pOrderBy = p->pOrderBy; int eDest = pDest->eDest; - int iParm = pDest->iParm; + int iParm = pDest->iSDParm; int regRow; int regRowid; @@ -949,17 +949,17 @@ static void generateSortTail( testcase( eDest==SRT_Output ); testcase( eDest==SRT_Coroutine ); for(i=0; iiMem+i ); - sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest->iMem+i); + assert( regRow!=pDest->iSdst+i ); + sqlite3VdbeAddOp3(v, OP_Column, pseudoTab, i, pDest->iSdst+i); if( i==0 ){ sqlite3VdbeChangeP5(v, OPFLAG_CLEARCACHE); } } if( eDest==SRT_Output ){ - sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iMem, nColumn); - sqlite3ExprCacheAffinityChange(pParse, pDest->iMem, nColumn); + sqlite3VdbeAddOp2(v, OP_ResultRow, pDest->iSdst, nColumn); + sqlite3ExprCacheAffinityChange(pParse, pDest->iSdst, nColumn); }else{ - sqlite3VdbeAddOp1(v, OP_Yield, pDest->iParm); + sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm); } break; } @@ -1610,7 +1610,7 @@ static int multiSelect( */ if( dest.eDest==SRT_EphemTab ){ assert( p->pEList ); - sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iParm, p->pEList->nExpr); + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, dest.iSDParm, p->pEList->nExpr); sqlite3VdbeChangeP5(v, BTREE_UNORDERED); dest.eDest = SRT_Table; } @@ -1696,7 +1696,7 @@ static int multiSelect( ** of a 3-way or more compound */ assert( p->pLimit==0 ); /* Not allowed on leftward elements */ assert( p->pOffset==0 ); /* Not allowed on leftward elements */ - unionTab = dest.iParm; + unionTab = dest.iSDParm; }else{ /* We will need to create our own temporary table to hold the ** intermediate results. @@ -1753,7 +1753,7 @@ static int multiSelect( /* Convert the data in the temporary table into whatever form ** it is that we currently need. */ - assert( unionTab==dest.iParm || dest.eDest!=priorOp ); + assert( unionTab==dest.iSDParm || dest.eDest!=priorOp ); if( dest.eDest!=priorOp ){ int iCont, iBreak, iStart; assert( p->pEList ); @@ -1817,7 +1817,7 @@ static int multiSelect( p->pLimit = 0; pOffset = p->pOffset; p->pOffset = 0; - intersectdest.iParm = tab2; + intersectdest.iSDParm = tab2; explainSetInteger(iSub2, pParse->iNextSelectId); rc = sqlite3Select(pParse, p, &intersectdest); testcase( rc!=SQLITE_OK ); @@ -1911,8 +1911,8 @@ static int multiSelect( } multi_select_end: - pDest->iMem = dest.iMem; - pDest->nMem = dest.nMem; + pDest->iSdst = dest.iSdst; + pDest->nSdst = dest.nSdst; sqlite3SelectDelete(db, pDelete); return rc; } @@ -1922,8 +1922,8 @@ multi_select_end: ** Code an output subroutine for a coroutine implementation of a ** SELECT statment. ** -** The data to be output is contained in pIn->iMem. There are -** pIn->nMem columns to be output. pDest is where the output should +** The data to be output is contained in pIn->iSdst. There are +** pIn->nSdst columns to be output. pDest is where the output should ** be sent. ** ** regReturn is the number of the register holding the subroutine @@ -1961,11 +1961,11 @@ static int generateOutputSubroutine( if( regPrev ){ int j1, j2; j1 = sqlite3VdbeAddOp1(v, OP_IfNot, regPrev); - j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iMem, regPrev+1, pIn->nMem, + j2 = sqlite3VdbeAddOp4(v, OP_Compare, pIn->iSdst, regPrev+1, pIn->nSdst, (char*)pKeyInfo, p4type); sqlite3VdbeAddOp3(v, OP_Jump, j2+2, iContinue, j2+2); sqlite3VdbeJumpHere(v, j1); - sqlite3ExprCodeCopy(pParse, pIn->iMem, regPrev+1, pIn->nMem); + sqlite3ExprCodeCopy(pParse, pIn->iSdst, regPrev+1, pIn->nSdst); sqlite3VdbeAddOp2(v, OP_Integer, 1, regPrev); } if( pParse->db->mallocFailed ) return 0; @@ -1983,9 +1983,9 @@ static int generateOutputSubroutine( int r2 = sqlite3GetTempReg(pParse); testcase( pDest->eDest==SRT_Table ); testcase( pDest->eDest==SRT_EphemTab ); - sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iMem, pIn->nMem, r1); - sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iParm, r2); - sqlite3VdbeAddOp3(v, OP_Insert, pDest->iParm, r1, r2); + sqlite3VdbeAddOp3(v, OP_MakeRecord, pIn->iSdst, pIn->nSdst, r1); + sqlite3VdbeAddOp2(v, OP_NewRowid, pDest->iSDParm, r2); + sqlite3VdbeAddOp3(v, OP_Insert, pDest->iSDParm, r1, r2); sqlite3VdbeChangeP5(v, OPFLAG_APPEND); sqlite3ReleaseTempReg(pParse, r2); sqlite3ReleaseTempReg(pParse, r1); @@ -1999,13 +1999,13 @@ static int generateOutputSubroutine( */ case SRT_Set: { int r1; - assert( pIn->nMem==1 ); + assert( pIn->nSdst==1 ); p->affinity = - sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affinity); + sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst); r1 = sqlite3GetTempReg(pParse); - sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iMem, 1, r1, &p->affinity, 1); - sqlite3ExprCacheAffinityChange(pParse, pIn->iMem, 1); - sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iParm, r1); + sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &p->affinity, 1); + sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1); + sqlite3VdbeAddOp2(v, OP_IdxInsert, pDest->iSDParm, r1); sqlite3ReleaseTempReg(pParse, r1); break; } @@ -2014,7 +2014,7 @@ static int generateOutputSubroutine( /* If any row exist in the result set, record that fact and abort. */ case SRT_Exists: { - sqlite3VdbeAddOp2(v, OP_Integer, 1, pDest->iParm); + sqlite3VdbeAddOp2(v, OP_Integer, 1, pDest->iSDParm); /* The LIMIT clause will terminate the loop for us */ break; } @@ -2025,23 +2025,23 @@ static int generateOutputSubroutine( ** of the scan loop. */ case SRT_Mem: { - assert( pIn->nMem==1 ); - sqlite3ExprCodeMove(pParse, pIn->iMem, pDest->iParm, 1); + assert( pIn->nSdst==1 ); + sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1); /* The LIMIT clause will jump out of the loop for us */ break; } #endif /* #ifndef SQLITE_OMIT_SUBQUERY */ /* The results are stored in a sequence of registers - ** starting at pDest->iMem. Then the co-routine yields. + ** starting at pDest->iSdst. Then the co-routine yields. */ case SRT_Coroutine: { - if( pDest->iMem==0 ){ - pDest->iMem = sqlite3GetTempRange(pParse, pIn->nMem); - pDest->nMem = pIn->nMem; + if( pDest->iSdst==0 ){ + pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst); + pDest->nSdst = pIn->nSdst; } - sqlite3ExprCodeMove(pParse, pIn->iMem, pDest->iMem, pDest->nMem); - sqlite3VdbeAddOp1(v, OP_Yield, pDest->iParm); + sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pDest->nSdst); + sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm); break; } @@ -2055,8 +2055,8 @@ static int generateOutputSubroutine( */ default: { assert( pDest->eDest==SRT_Output ); - sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iMem, pIn->nMem); - sqlite3ExprCacheAffinityChange(pParse, pIn->iMem, pIn->nMem); + sqlite3VdbeAddOp2(v, OP_ResultRow, pIn->iSdst, pIn->nSdst); + sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, pIn->nSdst); break; } } @@ -2475,7 +2475,7 @@ static int multiSelectOrderBy( */ sqlite3VdbeResolveLabel(v, labelCmpr); sqlite3VdbeAddOp4(v, OP_Permutation, 0, 0, 0, (char*)aPermute, P4_INTARRAY); - sqlite3VdbeAddOp4(v, OP_Compare, destA.iMem, destB.iMem, nOrderBy, + sqlite3VdbeAddOp4(v, OP_Compare, destA.iSdst, destB.iSdst, nOrderBy, (char*)pKeyMerge, P4_KEYINFO_HANDOFF); sqlite3VdbeAddOp3(v, OP_Jump, addrAltB, addrAeqB, addrAgtB); @@ -3721,23 +3721,24 @@ static void explainSimpleCount( ** ** SRT_Mem Only valid if the result is a single column. ** Store the first column of the first result row -** in register pDest->iParm then abandon the rest +** in register pDest->iSDParm then abandon the rest ** of the query. This destination implies "LIMIT 1". ** ** SRT_Set The result must be a single column. Store each -** row of result as the key in table pDest->iParm. +** row of result as the key in table pDest->iSDParm. ** Apply the affinity pDest->affinity before storing ** results. Used to implement "IN (SELECT ...)". ** -** SRT_Union Store results as a key in a temporary table pDest->iParm. +** SRT_Union Store results as a key in a temporary table +** identified by pDest->iSDParm. ** -** SRT_Except Remove results from the temporary table pDest->iParm. +** SRT_Except Remove results from the temporary table pDest->iSDParm. ** -** SRT_Table Store results in temporary table pDest->iParm. +** SRT_Table Store results in temporary table pDest->iSDParm. ** This is like SRT_EphemTab except that the table ** is assumed to already be open. ** -** SRT_EphemTab Create an temporary table pDest->iParm and store +** SRT_EphemTab Create an temporary table pDest->iSDParm and store ** the result there. The cursor is left open after ** returning. This is like SRT_Table except that ** this destination uses OP_OpenEphemeral to create @@ -3745,9 +3746,9 @@ static void explainSimpleCount( ** ** SRT_Coroutine Generate a co-routine that returns a new row of ** results each time it is invoked. The entry point -** of the co-routine is stored in register pDest->iParm. +** of the co-routine is stored in register pDest->iSDParm. ** -** SRT_Exists Store a 1 in memory cell pDest->iParm if the result +** SRT_Exists Store a 1 in memory cell pDest->iSDParm if the result ** set is not empty. ** ** SRT_Discard Throw the results away. This is used by SELECT @@ -3991,7 +3992,7 @@ int sqlite3Select( /* If the output is destined for a temporary table, open that table. */ if( pDest->eDest==SRT_EphemTab ){ - sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iParm, pEList->nExpr); + sqlite3VdbeAddOp2(v, OP_OpenEphemeral, pDest->iSDParm, pEList->nExpr); } /* Set the limiter. diff --git a/src/sqliteInt.h b/src/sqliteInt.h index f7f5fd386e..c525ebd16f 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2118,10 +2118,10 @@ struct Select { typedef struct SelectDest SelectDest; struct SelectDest { u8 eDest; /* How to dispose of the results */ - u8 affinity; /* Affinity used when eDest==SRT_Set */ - int iParm; /* A parameter used by the eDest disposal method */ - int iMem; /* Base register where results are written */ - int nMem; /* Number of registers allocated */ + u8 affSdst; /* Affinity used when eDest==SRT_Set */ + int iSDParm; /* A parameter used by the eDest disposal method */ + int iSdst; /* Base register where results are written */ + int nSdst; /* Number of registers allocated */ }; /* From 35d8ac980dabde27e47d45ded8f05f715cde67af Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 24 Jul 2012 06:02:35 +0000 Subject: [PATCH 38/69] Add another define to the MSVC makefile that is sometimes required to build cleanly for WinRT. FossilOrigin-Name: d582cd890d88e873d76a23545bcd49cf093ee9d2 --- Makefile.msc | 1 + manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index e16ced35e4..03872d7de8 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -123,6 +123,7 @@ TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I. -I$(TOP)\src -fp:precise # !IF $(FOR_WINRT)!=0 TCC = $(TCC) -DSQLITE_OS_WINRT=1 +TCC = $(TCC) -DWINAPI_FAMILY=WINAPI_PARTITION_APP !ENDIF # Also, we need to dynamically link to the correct MSVC runtime diff --git a/manifest b/manifest index a71ad43270..74d8f3cb5e 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Refactor\sfield\snames\sin\sthe\sSelectDest\sobject\sto\smake\sthem\sdistinct\sand\seasier\nto\sgrep\sfor. -D 2012-07-23T21:43:19.390 +C Add\sanother\sdefine\sto\sthe\sMSVC\smakefile\sthat\sis\ssometimes\srequired\sto\sbuild\scleanly\sfor\sWinRT. +D 2012-07-24T06:02:35.411 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 56ff0fcc3fc3b275aec7f6acb34b3c0526c684bc +F Makefile.msc a2a8fcd4104a67e037351323c88e0e4822596926 F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P e4163596339c2166f9c4356ab824fff8bda8d0b0 -R adb51909ed26f080ecf60f96fb1f4ac0 -U drh -Z 14fefb32c4db69f21df1898d6655f0c2 +P b589f1efb3907a68058bf2ee981dca126d083e83 +R 75a13812cd02d645a4e2c62d598f937c +U mistachkin +Z 17af9fcca0ae08ed5daad968a9e3388d diff --git a/manifest.uuid b/manifest.uuid index 4c27b7b677..d8da19bf2a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b589f1efb3907a68058bf2ee981dca126d083e83 \ No newline at end of file +d582cd890d88e873d76a23545bcd49cf093ee9d2 \ No newline at end of file From c041c16ce147f63c3a2cd2df4597820ff6387ada Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 24 Jul 2012 19:46:38 +0000 Subject: [PATCH 39/69] Mark parameters to sorter interfaces as const where appropriate. FossilOrigin-Name: d8da26f1f43610ac83af2a5d0e170be5abaf7aaa --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/select.c | 2 +- src/vdbeInt.h | 10 +++++----- src/vdbesort.c | 30 +++++++++++++++--------------- 5 files changed, 31 insertions(+), 31 deletions(-) diff --git a/manifest b/manifest index 74d8f3cb5e..7c1d8a6053 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sanother\sdefine\sto\sthe\sMSVC\smakefile\sthat\sis\ssometimes\srequired\sto\sbuild\scleanly\sfor\sWinRT. -D 2012-07-24T06:02:35.411 +C Mark\sparameters\sto\ssorter\sinterfaces\sas\sconst\swhere\sappropriate. +D 2012-07-24T19:46:38.570 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -176,7 +176,7 @@ F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f F src/random.c cd4a67b3953b88019f8cd4ccd81394a8ddfaba50 F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 -F src/select.c eecb852bc7d8c00253b9b9cbab9e528f0d4dd9a5 +F src/select.c a365da6d7a6d7d8a10ad60ca71837ab5e9369466 F src/shell.c 076e1c90d594644f36027c8ecff9a392cf2d3a06 F src/sqlite.h.in 310ae7e538883fa1619ab0638c775ce11ad43015 F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 @@ -239,12 +239,12 @@ F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd F src/vdbe.c f5ad3c06dc3fe647097065829c013f3f1b9eadca F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb -F src/vdbeInt.h 6ff4180a05683566a8835d12f7ec504b22932c82 +F src/vdbeInt.h 986b6b11a13c517337355009e5438703ba5b0a40 F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 -F src/vdbesort.c b25814d385895544ebc8118245c8311ded7f81c9 +F src/vdbesort.c 628b2bc0cc82cae0e9946f70c5c81986e9fba91f F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P b589f1efb3907a68058bf2ee981dca126d083e83 -R 75a13812cd02d645a4e2c62d598f937c -U mistachkin -Z 17af9fcca0ae08ed5daad968a9e3388d +P d582cd890d88e873d76a23545bcd49cf093ee9d2 +R dfda5074dc19f89fe8c778d461e17987 +U drh +Z 78ad216a54a8d01eec70f561ea3dc528 diff --git a/manifest.uuid b/manifest.uuid index d8da19bf2a..4108c28d85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d582cd890d88e873d76a23545bcd49cf093ee9d2 \ No newline at end of file +d8da26f1f43610ac83af2a5d0e170be5abaf7aaa \ No newline at end of file diff --git a/src/select.c b/src/select.c index 1d424caf1e..491356acbb 100644 --- a/src/select.c +++ b/src/select.c @@ -3726,7 +3726,7 @@ static void explainSimpleCount( ** ** SRT_Set The result must be a single column. Store each ** row of result as the key in table pDest->iSDParm. -** Apply the affinity pDest->affinity before storing +** Apply the affinity pDest->affSdst before storing ** results. Used to implement "IN (SELECT ...)". ** ** SRT_Union Store results as a key in a temporary table diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 9c1af35c33..1f5694a595 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -431,11 +431,11 @@ int sqlite3VdbeTransferError(Vdbe *p); #else int sqlite3VdbeSorterInit(sqlite3 *, VdbeCursor *); void sqlite3VdbeSorterClose(sqlite3 *, VdbeCursor *); -int sqlite3VdbeSorterRowkey(VdbeCursor *, Mem *); -int sqlite3VdbeSorterNext(sqlite3 *, VdbeCursor *, int *); -int sqlite3VdbeSorterRewind(sqlite3 *, VdbeCursor *, int *); -int sqlite3VdbeSorterWrite(sqlite3 *, VdbeCursor *, Mem *); -int sqlite3VdbeSorterCompare(VdbeCursor *, Mem *, int *); +int sqlite3VdbeSorterRowkey(const VdbeCursor *, Mem *); +int sqlite3VdbeSorterNext(sqlite3 *, const VdbeCursor *, int *); +int sqlite3VdbeSorterRewind(sqlite3 *, const VdbeCursor *, int *); +int sqlite3VdbeSorterWrite(sqlite3 *, const VdbeCursor *, Mem *); +int sqlite3VdbeSorterCompare(const VdbeCursor *, Mem *, int *); #endif #if !defined(SQLITE_OMIT_SHARED_CACHE) && SQLITE_THREADSAFE>0 diff --git a/src/vdbesort.c b/src/vdbesort.c index afea1f510a..5faeca8dc7 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -259,7 +259,7 @@ static int vdbeSorterReadVarint( */ static int vdbeSorterIterInit( sqlite3 *db, /* Database handle */ - VdbeSorter *pSorter, /* Sorter object */ + const VdbeSorter *pSorter, /* Sorter object */ i64 iStart, /* Start offset in pFile */ VdbeSorterIter *pIter, /* Iterator to populate */ i64 *pnByte /* IN/OUT: Increment this value by PMA size */ @@ -303,10 +303,10 @@ static int vdbeSorterIterInit( ** has been allocated and contains an unpacked record that is used as key2. */ static void vdbeSorterCompare( - VdbeCursor *pCsr, /* Cursor object (for pKeyInfo) */ + const VdbeCursor *pCsr, /* Cursor object (for pKeyInfo) */ int bOmitRowid, /* Ignore rowid field at end of keys */ - void *pKey1, int nKey1, /* Left side of comparison */ - void *pKey2, int nKey2, /* Right side of comparison */ + const void *pKey1, int nKey1, /* Left side of comparison */ + const void *pKey2, int nKey2, /* Right side of comparison */ int *pRes /* OUT: Result of comparison */ ){ KeyInfo *pKeyInfo = pCsr->pKeyInfo; @@ -338,7 +338,7 @@ static void vdbeSorterCompare( ** multiple b-tree segments. Parameter iOut is the index of the aTree[] ** value to recalculate. */ -static int vdbeSorterDoCompare(VdbeCursor *pCsr, int iOut){ +static int vdbeSorterDoCompare(const VdbeCursor *pCsr, int iOut){ VdbeSorter *pSorter = pCsr->pSorter; int i1; int i2; @@ -464,7 +464,7 @@ static int vdbeSorterOpenTempFile(sqlite3 *db, sqlite3_file **ppFile){ ** Set *ppOut to the head of the new list. */ static void vdbeSorterMerge( - VdbeCursor *pCsr, /* For pKeyInfo */ + const VdbeCursor *pCsr, /* For pKeyInfo */ SorterRecord *p1, /* First list to merge */ SorterRecord *p2, /* Second list to merge */ SorterRecord **ppOut /* OUT: Head of merged list */ @@ -498,7 +498,7 @@ static void vdbeSorterMerge( ** if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if an error ** occurs. */ -static int vdbeSorterSort(VdbeCursor *pCsr){ +static int vdbeSorterSort(const VdbeCursor *pCsr){ int i; SorterRecord **aSlot; SorterRecord *p; @@ -545,7 +545,7 @@ static int vdbeSorterSort(VdbeCursor *pCsr){ ** Each record consists of a varint followed by a blob of data (the ** key). The varint is the number of bytes in the blob of data. */ -static int vdbeSorterListToPMA(sqlite3 *db, VdbeCursor *pCsr){ +static int vdbeSorterListToPMA(sqlite3 *db, const VdbeCursor *pCsr){ int rc = SQLITE_OK; /* Return code */ VdbeSorter *pSorter = pCsr->pSorter; @@ -608,7 +608,7 @@ static int vdbeSorterListToPMA(sqlite3 *db, VdbeCursor *pCsr){ */ int sqlite3VdbeSorterWrite( sqlite3 *db, /* Database handle */ - VdbeCursor *pCsr, /* Sorter cursor */ + const VdbeCursor *pCsr, /* Sorter cursor */ Mem *pVal /* Memory cell containing record */ ){ VdbeSorter *pSorter = pCsr->pSorter; @@ -654,7 +654,7 @@ int sqlite3VdbeSorterWrite( */ static int vdbeSorterInitMerge( sqlite3 *db, /* Database handle */ - VdbeCursor *pCsr, /* Cursor handle for this sorter */ + const VdbeCursor *pCsr, /* Cursor handle for this sorter */ i64 *pnByte /* Sum of bytes in all opened PMAs */ ){ VdbeSorter *pSorter = pCsr->pSorter; @@ -684,7 +684,7 @@ static int vdbeSorterInitMerge( ** Once the sorter has been populated, this function is called to prepare ** for iterating through its contents in sorted order. */ -int sqlite3VdbeSorterRewind(sqlite3 *db, VdbeCursor *pCsr, int *pbEof){ +int sqlite3VdbeSorterRewind(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){ VdbeSorter *pSorter = pCsr->pSorter; int rc; /* Return code */ sqlite3_file *pTemp2 = 0; /* Second temp file to use */ @@ -792,7 +792,7 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, VdbeCursor *pCsr, int *pbEof){ /* ** Advance to the next element in the sorter. */ -int sqlite3VdbeSorterNext(sqlite3 *db, VdbeCursor *pCsr, int *pbEof){ +int sqlite3VdbeSorterNext(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){ VdbeSorter *pSorter = pCsr->pSorter; int rc; /* Return code */ @@ -822,7 +822,7 @@ int sqlite3VdbeSorterNext(sqlite3 *db, VdbeCursor *pCsr, int *pbEof){ ** current key. */ static void *vdbeSorterRowkey( - VdbeSorter *pSorter, /* Sorter object */ + const VdbeSorter *pSorter, /* Sorter object */ int *pnKey /* OUT: Size of current key in bytes */ ){ void *pKey; @@ -841,7 +841,7 @@ static void *vdbeSorterRowkey( /* ** Copy the current sorter key into the memory cell pOut. */ -int sqlite3VdbeSorterRowkey(VdbeCursor *pCsr, Mem *pOut){ +int sqlite3VdbeSorterRowkey(const VdbeCursor *pCsr, Mem *pOut){ VdbeSorter *pSorter = pCsr->pSorter; void *pKey; int nKey; /* Sorter key to copy into pOut */ @@ -867,7 +867,7 @@ int sqlite3VdbeSorterRowkey(VdbeCursor *pCsr, Mem *pOut){ ** key. */ int sqlite3VdbeSorterCompare( - VdbeCursor *pCsr, /* Sorter cursor */ + const VdbeCursor *pCsr, /* Sorter cursor */ Mem *pVal, /* Value to compare to current sorter key */ int *pRes /* OUT: Result of comparison */ ){ From 9d0c0ea6012c4da933831894cb8c8ae32c92a1b1 Mon Sep 17 00:00:00 2001 From: dan Date: Thu, 26 Jul 2012 09:21:14 +0000 Subject: [PATCH 40/69] Update some comments in vdbesort.c. FossilOrigin-Name: f4b3fded231231ef15bde98d2a996b4e16415d4c --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbesort.c | 39 ++++++++++++++++++++++++++++----------- 3 files changed, 35 insertions(+), 18 deletions(-) diff --git a/manifest b/manifest index 8ee9b917a6..c3c728bb31 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\san\sedge\scase\sin\svdbesort.c. -D 2012-07-23T20:10:35.296 +C Update\ssome\scomments\sin\svdbesort.c. +D 2012-07-26T09:21:14.241 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -244,7 +244,7 @@ F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 -F src/vdbesort.c bd37dbd4a023f75e9cd1eec18e171aa6f2552d20 +F src/vdbesort.c 106796cedf32a8209e92f28560d0523193c19a9a F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b @@ -1005,7 +1005,7 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P 55e47ef338c42f95f0f071d6ec92cd2480f9f1fe -R c1d0187a30b4d8ec69c9c7f13c2ce356 +P 4ba266fc534f390267180eca8d68b8d5f0b7f832 +R e276763c29e00cdde695ab89ab0038a7 U dan -Z 60c5c030c4ed6dd425cd291cf7eefd27 +Z 42e5e7096761a49ccf3e633dc0ad5716 diff --git a/manifest.uuid b/manifest.uuid index 239b7c9706..528757c4ac 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4ba266fc534f390267180eca8d68b8d5f0b7f832 \ No newline at end of file +f4b3fded231231ef15bde98d2a996b4e16415d4c \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 7778196f1c..c00e9a2f1a 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -180,51 +180,68 @@ static int vdbeSorterIterRead( int nByte, /* Bytes of data to read */ u8 **ppOut /* OUT: Pointer to buffer containing data */ ){ - int iBuf; - int nAvail; + int iBuf; /* Offset within buffer to read from */ + int nAvail; /* Bytes of data available in buffer */ assert( p->aBuffer ); + /* If there is no more data to be read from the buffer, read the next + ** p->nBuffer bytes of data from the file into it. Or, if there are less + ** than p->nBuffer bytes remaining in the PMA, read all remaining data. */ iBuf = p->iReadOff % p->nBuffer; if( iBuf==0 ){ - int nRead; - int rc; + int nRead; /* Bytes to read from disk */ + int rc; /* sqlite3OsRead() return code */ + /* Determine how many bytes of data to read. */ nRead = p->iEof - p->iReadOff; if( nRead>p->nBuffer ) nRead = p->nBuffer; assert( nRead>0 ); + + /* Read data from the file. Return early if an error occurs. */ rc = sqlite3OsRead(p->pFile, p->aBuffer, nRead, p->iReadOff); assert( rc!=SQLITE_IOERR_SHORT_READ ); if( rc!=SQLITE_OK ) return rc; } - nAvail = p->nBuffer - iBuf; + nAvail = p->nBuffer - iBuf; if( nByte<=nAvail ){ + /* The requested data is available in the in-memory buffer. In this + ** case there is no need to make a copy of the data, just return a + ** pointer into the buffer to the caller. */ *ppOut = &p->aBuffer[iBuf]; p->iReadOff += nByte; }else{ - int nRem; + /* The requested data is not all available in the in-memory buffer. + ** In this case, allocate space at p->aAlloc[] to copy the requested + ** range into. Then return a copy of pointer p->aAlloc to the caller. */ + int nRem; /* Bytes remaining to copy */ + + /* Extend the p->aAlloc[] allocation if required. */ if( p->nAllocnAlloc*2; while( nByte>nNew ) nNew = nNew*2; - p->aAlloc = sqlite3DbReallocOrFree(db, p->aAlloc, nNew); if( !p->aAlloc ) return SQLITE_NOMEM; } + /* Copy as much data as is available in the buffer into the start of + ** p->aAlloc[]. */ memcpy(p->aAlloc, &p->aBuffer[iBuf], nAvail); p->iReadOff += nAvail; nRem = nByte - nAvail; + + /* The following loop copies up to p->nBuffer bytes per iteration into + ** the p->aAlloc[] buffer. */ while( nRem>0 ){ - int rc; - int nCopy; - u8 *aNext; + int rc; /* vdbeSorterIterRead() return code */ + int nCopy; /* Number of bytes to copy */ + u8 *aNext; /* Pointer to buffer to copy data from */ nCopy = nRem; if( nRem>p->nBuffer ) nCopy = p->nBuffer; rc = vdbeSorterIterRead(db, p, nCopy, &aNext); if( rc!=SQLITE_OK ) return rc; assert( aNext!=p->aAlloc ); - memcpy(&p->aAlloc[nByte - nRem], aNext, nCopy); nRem -= nCopy; } From 486801909ca1b4d8b3c2f69a206ca385e2966a74 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Jul 2012 02:36:06 +0000 Subject: [PATCH 41/69] Add tool to generate a VSIX package usable by Visual Studio 2012 RC. FossilOrigin-Name: 8b90e0c4dbcedaf3e61c5d49452997705be1ef98 --- manifest | 14 +- manifest.uuid | 2 +- tool/mkvsix.tcl | 365 +++++++++++++++++++++++++++++++++++++++++++ tool/win/sqlite.vsix | Bin 0 -> 34247 bytes 4 files changed, 374 insertions(+), 7 deletions(-) create mode 100644 tool/mkvsix.tcl create mode 100644 tool/win/sqlite.vsix diff --git a/manifest b/manifest index 7c1d8a6053..3444e28ebb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Mark\sparameters\sto\ssorter\sinterfaces\sas\sconst\swhere\sappropriate. -D 2012-07-24T19:46:38.570 +C Add\stool\sto\sgenerate\sa\sVSIX\spackage\susable\sby\sVisual\sStudio\s2012\sRC. +D 2012-07-27T02:36:06.349 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -982,6 +982,7 @@ F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl 589c7f44e990be1b8443cfe4808dce392b0327fa F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 +F tool/mkvsix.tcl 75fb1b601d69ead76340fa15bf9813874fed240b F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1005,7 +1006,8 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -P d582cd890d88e873d76a23545bcd49cf093ee9d2 -R dfda5074dc19f89fe8c778d461e17987 -U drh -Z 78ad216a54a8d01eec70f561ea3dc528 +F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff +P d8da26f1f43610ac83af2a5d0e170be5abaf7aaa +R e89b8d51f4ab3734c03bdfc7ca67399b +U mistachkin +Z ca7c7ef3778a69af10a33d78de2dc884 diff --git a/manifest.uuid b/manifest.uuid index 4108c28d85..364fa66bed 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d8da26f1f43610ac83af2a5d0e170be5abaf7aaa \ No newline at end of file +8b90e0c4dbcedaf3e61c5d49452997705be1ef98 \ No newline at end of file diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl new file mode 100644 index 0000000000..a5a569d475 --- /dev/null +++ b/tool/mkvsix.tcl @@ -0,0 +1,365 @@ +#!/usr/bin/tclsh +# +# This script is used to generate a VSIX (Visual Studio Extension) file for +# SQLite usable by Visual Studio. + +proc fail { {error ""} {usage false} } { + if {[string length $error] > 0} then { + puts stdout $error + if {!$usage} then {exit 1} + } + + puts stdout "usage:\ +[file tail [info nameofexecutable]]\ +[file tail [info script]] \[sourceDirectory\]" + + exit 1 +} + +proc getEnvironmentVariable { name } { + # + # NOTE: Returns the value of the specified environment variable or an empty + # string for environment variables that do not exist in the current + # process environment. + # + return [expr {[info exists ::env($name)] ? $::env($name) : ""}] +} + +proc getTemporaryPath {} { + # + # NOTE: Returns the normalized path to the first temporary directory found + # in the typical set of environment variables used for that purpose + # or an empty string to signal a failure to locate such a directory. + # + set names [list] + + foreach name [list TEMP TMP] { + lappend names [string toupper $name] [string tolower $name] \ + [string totitle $name] + } + + foreach name $names { + set value [getEnvironmentVariable $name] + + if {[string length $value] > 0} then { + return [file normalize $value] + } + } + + return "" +} + +proc appendArgs { args } { + # + # NOTE: Returns all passed arguments joined together as a single string with + # no intervening spaces between arguments. + # + eval append result $args +} + +proc readFile { fileName } { + # + # NOTE: Reads and returns the entire contents of the specified file, which + # may contain binary data. + # + set file_id [open $fileName RDONLY] + fconfigure $file_id -encoding binary -translation binary + set result [read $file_id] + close $file_id + return $result +} + +proc writeFile { fileName data } { + # + # NOTE: Writes the entire contents of the specified file, which may contain + # binary data. + # + set file_id [open $fileName {WRONLY CREAT TRUNC}] + fconfigure $file_id -encoding binary -translation binary + puts -nonewline $file_id $data + close $file_id + return "" +} + +proc substFile { fileName } { + # + # NOTE: Performs all Tcl command, variable, and backslash substitutions in + # the specified file and then re-writes the contents of that same file + # with the substituted data. + # + return [writeFile $fileName [uplevel 1 [list subst [readFile $fileName]]]] +} + +proc replacePlatform { fileName platformName } { + # + # NOTE: Returns the specified file name containing the platform name instead + # of platform placeholder tokens. + # + return [string map [list $platformName] $fileName] +} + +set script [file normalize [info script]] + +if {[string length $script] == 0} then { + fail "script file currently being evaluated is unknown" true +} + +set path [file dirname $script] +set rootName [file rootname [file tail $script]] + +############################################################################### + +# +# NOTE: Process and verify all the command line arguments. +# +set argc [llength $argv] +if {$argc != 1 && $argc != 2} then {fail} + +set binaryDirectory [lindex $argv 0] + +if {[string length $binaryDirectory] == 0} then { + fail "invalid binary directory" +} + +if {![file exists $binaryDirectory] || \ + ![file isdirectory $binaryDirectory]} then { + fail "binary directory does not exist" +} + +if {$argc == 2} then { + set sourceDirectory [lindex $argv 1] +} else { + # + # NOTE: Assume that the source directory is the parent directory of the one + # that contains this script file. + # + set sourceDirectory [file dirname $path] +} + +if {[string length $sourceDirectory] == 0} then { + fail "invalid source directory" +} + +if {![file exists $sourceDirectory] || \ + ![file isdirectory $sourceDirectory]} then { + fail "source directory does not exist" +} + +############################################################################### + +set templateFile [file join $path win sqlite.vsix] + +if {![file exists $templateFile] || \ + ![file isfile $templateFile]} then { + fail [appendArgs "template file \"" $templateFile "\" does not exist"] +} + +set currentDirectory [pwd] +set outputFile [file join $currentDirectory sqlite-output.vsix] + +if {[file exists $outputFile]} then { + fail [appendArgs "output file \"" $outputFile "\" already exists"] +} + +############################################################################### + +# +# NOTE: Make sure that a valid temporary directory exists. +# +set temporaryDirectory [getTemporaryPath] + +if {[string length $temporaryDirectory] == 0 || \ + ![file exists $temporaryDirectory] || \ + ![file isdirectory $temporaryDirectory]} then { + fail "cannot locate a usable temporary directory" +} + +# +# NOTE: Setup the staging directory to have a unique name inside of the +# configured temporary directory. +# +set stagingDirectory [file normalize [file join $temporaryDirectory \ + [appendArgs $rootName . [pid]]]] + +############################################################################### + +# +# NOTE: Configure the external zipping tool. First, see if it has already +# been pre-configured. If not, try to query it from the environment. +# Finally, fallback on the default of simply "zip", which will then +# be assumed to exist somewhere along the PATH. +# +if {![info exists zip]} then { + if {[info exists env(ZipTool)]} then { + set zip $env(ZipTool) + } + if {![info exists zip] || ![file exists $zip]} then { + set zip zip + } +} + +# +# NOTE: Configure the external unzipping tool. First, see if it has already +# been pre-configured. If not, try to query it from the environment. +# Finally, fallback on the default of simply "unzip", which will then +# be assumed to exist somewhere along the PATH. +# +if {![info exists unzip]} then { + if {[info exists env(UnZipTool)]} then { + set unzip $env(UnZipTool) + } + if {![info exists unzip] || ![file exists $unzip]} then { + set unzip unzip + } +} + +############################################################################### + +# +# NOTE: Attempt to extract the SQLite version from the "sqlite3.h" header file +# in the source directory. This script assumes that the header file has +# already been generated by the build process. +# +set pattern {^#define\s+?SQLITE_VERSION\s+?"(.*?)"$} +set data [readFile [file join $sourceDirectory sqlite3.h]] + +if {![regexp -line -- $pattern $data dummy version]} then { + fail [appendArgs "cannot locate SQLITE_VERSION value in \"" \ + [file join $sourceDirectory sqlite3.h] \"] +} + +############################################################################### + +# +# NOTE: Setup the master file list data, including the necessary flags. +# +set fileNames(source) [list "" "" "" \ + [file join $sourceDirectory sqlite3.h] \ + [file join $binaryDirectory sqlite3.lib] \ + [file join $binaryDirectory sqlite3.dll]] + +set fileNames(destination) [list \ + [file join $stagingDirectory extension.vsixmanifest] \ + [file join $stagingDirectory SDKManifest.xml] \ + [file join $stagingDirectory DesignTime CommonConfiguration \ + SQLite.WinRT.props] \ + [file join $stagingDirectory DesignTime CommonConfiguration \ + sqlite3.h] \ + [file join $stagingDirectory DesignTime CommonConfiguration \ + sqlite3.lib] \ + [file join $stagingDirectory Redist CommonConfiguration \ + sqlite3.dll]] + +set fileNames(neutral) [list 1 1 1 1 0 0] +set fileNames(subst) [list 1 1 1 0 0 0] + +############################################################################### + +# +# NOTE: Setup the list of platforms supported by this script. +# +set platformNames [list ARM x64 x86] + +############################################################################### + +# +# NOTE: Make sure the staging directory exists, creating it if necessary. +# +file mkdir $stagingDirectory + +# +# NOTE: Build the Tcl command used to extract the template package to the +# staging directory. +# +set extractCommand [list exec -- $unzip $templateFile -d $stagingDirectory] + +# +# NOTE: Extract the template package to the staging directory. +# +eval $extractCommand + +############################################################################### + +# +# NOTE: Process each file in the master file list. There are actually four +# parallel lists that contain the source file names, destination file +# names, the platform-neutral flags, and the use-subst flags. When the +# platform-neutral flag is non-zero, the file is not platform-specific. +# When the use-subst flag is non-zero, the file is considered to be a +# text file that may contain Tcl variable and/or command replacements, +# to be dynamically replaced during processing. If the source file name +# is an empty string, then the destination file name will be assumed to +# already exist in the staging directory and will not be copied; however, +# dynamic replacements may still be performed on the destination file +# prior to the package being re-zipped. +# +foreach sourceFileName $fileNames(source) \ + destinationFileName $fileNames(destination) \ + isNeutral $fileNames(neutral) useSubst $fileNames(subst) { + # + # NOTE: If the current file is platform-neutral, then only one platform will + # be processed for it, namely "neutral"; otherwise, each supported + # platform will be processed for it individually. + # + foreach platformName [expr {$isNeutral ? [list neutral] : $platformNames}] { + # + # NOTE: Does the source file need to be copied to the destination file? + # + if {[string length $sourceFileName] > 0} then { + # + # NOTE: Copy the source file to the destination file verbatim. + # + file copy [replacePlatform $sourceFileName $platformName] \ + [replacePlatform $destinationFileName $platformName] + } + + # + # NOTE: Does the destination file contain dynamic replacements that must + # be processed now? + # + if {$useSubst} then { + # + # NOTE: Perform any dynamic replacements contained in the destination + # file and then re-write it in-place. + # + substFile [replacePlatform $destinationFileName $platformName] + } + } +} + +############################################################################### + +# +# NOTE: Change the current directory to the staging directory so that the +# external archive building tool can pickup the necessary files using +# relative paths. +# +cd $stagingDirectory + +# +# NOTE: Build the Tcl command used to archive the final package in the +# output directory. +# +set archiveCommand [list exec -- $zip -r $outputFile *] + +# +# NOTE: Build the final package archive in the output directory. +# +eval $archiveCommand + +# +# NOTE: Change back to the previously saved current directory. +# +cd $currentDirectory + +# +# NOTE: Cleanup the temporary staging directory. +# +file delete -force $stagingDirectory + +############################################################################### + +# +# NOTE: Success, emit the fully qualified path of the generated VSIX file. +# +puts stdout $outputFile diff --git a/tool/win/sqlite.vsix b/tool/win/sqlite.vsix new file mode 100644 index 0000000000000000000000000000000000000000..16f7b57cd03cf43fd1c77761a25b98929305eb39 GIT binary patch literal 34247 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 literal 0 HcmV?d00001 From 31856a35b9025fcaad2b528480af1a6757124ee8 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Jul 2012 07:13:25 +0000 Subject: [PATCH 42/69] Add tool to build the core DLL for multiple platforms using MSVC. FossilOrigin-Name: e42f5812f142522852f6dc72430bc7afdd6f2ed3 --- Makefile.msc | 7 + manifest | 13 +- manifest.uuid | 2 +- tool/build-all-msvc.bat | 331 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 346 insertions(+), 7 deletions(-) create mode 100755 tool/build-all-msvc.bat diff --git a/Makefile.msc b/Makefile.msc index 03872d7de8..8e1a36cf8c 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -30,6 +30,11 @@ USE_NATIVE_LIBPATHS = 0 # FOR_WINRT = 0 +# Set this non-0 to skip attempting to look for and/or link with the Tcl +# runtime library. +# +NO_TCL = 0 + # Set this to non-0 to create and use PDBs. # SYMBOLS = 1 @@ -345,8 +350,10 @@ LDFLAGS = /DEBUG !ENDIF # Start with the Tcl related linker options. +!IF $(NO_TCL)==0 LTLIBPATHS = /LIBPATH:$(TCLLIBDIR) LTLIBS = $(LIBTCL) +!ENDIF # If ICU support is enabled, add the linker options for it. !IF $(USE_ICU)!=0 diff --git a/manifest b/manifest index 3444e28ebb..569844a12f 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\stool\sto\sgenerate\sa\sVSIX\spackage\susable\sby\sVisual\sStudio\s2012\sRC. -D 2012-07-27T02:36:06.349 +C Add\stool\sto\sbuild\sthe\score\sDLL\sfor\smultiple\splatforms\susing\sMSVC. +D 2012-07-27T07:13:25.700 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc a2a8fcd4104a67e037351323c88e0e4822596926 +F Makefile.msc d598bf4a464d2e9ecbeeea809969c2ac3bf97359 F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d @@ -966,6 +966,7 @@ F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/win32lock.test b2a539e85ae6b2d78475e016a9636b4451dc7fb9 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F test/zerodamage.test 0de750389990b1078bab203c712dc3fefd1d8b82 +F tool/build-all-msvc.bat fe0f031dce6881469b0949283a3cfa8a93032eca x F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 @@ -1007,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff -P d8da26f1f43610ac83af2a5d0e170be5abaf7aaa -R e89b8d51f4ab3734c03bdfc7ca67399b +P 8b90e0c4dbcedaf3e61c5d49452997705be1ef98 +R 352e3b46f2ff977e05b0828462f57f7b U mistachkin -Z ca7c7ef3778a69af10a33d78de2dc884 +Z 1ba4e6125d90314090d1c67374bcfabc diff --git a/manifest.uuid b/manifest.uuid index 364fa66bed..73ae6a4e94 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8b90e0c4dbcedaf3e61c5d49452997705be1ef98 \ No newline at end of file +e42f5812f142522852f6dc72430bc7afdd6f2ed3 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat new file mode 100755 index 0000000000..c5c10d0905 --- /dev/null +++ b/tool/build-all-msvc.bat @@ -0,0 +1,331 @@ +@ECHO OFF + +:: +:: build-all-msvc.bat -- +:: +:: Multi-Platform Build Tool for MSVC +:: + +SETLOCAL + +REM SET __ECHO=ECHO +REM SET __ECHO2=ECHO +IF NOT DEFINED _AECHO (SET _AECHO=REM) +IF NOT DEFINED _CECHO (SET _CECHO=REM) +IF NOT DEFINED _VECHO (SET _VECHO=REM) + +%_AECHO% Running %0 %* + +REM SET DFLAGS=/L + +%_VECHO% DFlags = '%DFLAGS%' + +SET FFLAGS=/V /F /G /H /I /R /Y /Z + +%_VECHO% FFlags = '%FFLAGS%' + +SET ROOT=%~dp0\.. +SET ROOT=%ROOT:\\=\% + +%_VECHO% Root = '%ROOT%' + +REM +REM NOTE: The first and only argument to this batch file should be the output +REM directory where the platform-specific binary directories should be +REM created. +REM +SET BINARYDIRECTORY=%1 + +IF NOT DEFINED BINARYDIRECTORY ( + GOTO usage +) + +%_VECHO% BinaryDirectory = '%BINARYDIRECTORY%' + +SET DUMMY=%2 + +IF DEFINED DUMMY ( + GOTO usage +) + +REM +REM NOTE: From this point, we need a clean error level. Reset it now. +REM +CALL :fn_ResetErrorLevel + +REM +REM NOTE: Change the current directory to the root of the source tree, saving +REM the current directory on the directory stack. +REM +%__ECHO2% PUSHD "%ROOT%" + +IF ERRORLEVEL 1 ( + ECHO Could not change directory to "%ROOT%". + GOTO errors +) + +REM +REM NOTE: This batch file requires the ComSpec environment variable to be set, +REM typically to something like "C:\Windows\System32\cmd.exe". +REM +IF NOT DEFINED ComSpec ( + ECHO The ComSpec environment variable must be defined. + GOTO errors +) + +REM +REM NOTE: This batch file requires the VcInstallDir environment variable to be +REM set. Tyipcally, this means this batch file needs to be run from an +REM MSVC command prompt. +REM +IF NOT DEFINED VCINSTALLDIR ( + ECHO The VCINSTALLDIR environment variable must be defined. + GOTO errors +) + +REM +REM NOTE: If the list of platforms is not already set, use the default list. +REM +IF NOT DEFINED PLATFORMS ( + SET PLATFORMS=x86 x86_amd64 x86_arm +) + +%_VECHO% Platforms = '%PLATFORMS%' + +REM +REM NOTE: Setup environment variables to translate between the MSVC platform +REM names and the names to be used for the platform-specific binary +REM directories. +REM +SET x86_NAME=x86 +SET x86_amd64_NAME=x64 +SET x86_arm_NAME=ARM + +%_VECHO% x86_Name = '%x86_NAME%' +%_VECHO% x86_amd64_Name = '%x86_amd64_NAME%' +%_VECHO% x86_arm_Name = '%x86_arm_NAME%' + +REM +REM NOTE: Check for the external tools needed during the build process ^(i.e. +REM those that do not get compiled as part of the build process itself^) +REM along the PATH. +REM +FOR %%T IN (gawk.exe tclsh85.exe) DO ( + SET %%T_PATH=%%~dp$PATH:T +) + +REM +REM NOTE: Set the TOOLPATH variable to contain all the directories where the +REM external tools were found in the search above. +REM +SET TOOLPATH=%gawk.exe_PATH%;%tclsh85.exe_PATH% + +%_VECHO% ToolPath = '%TOOLPATH%' + +REM +REM NOTE: This is the outer loop. There should be exactly one iteration per +REM platform. +REM +FOR %%P IN (%PLATFORMS%) DO ( + REM + REM NOTE: Using the MSVC platform name, lookup the simpler platform name to + REM be used for the name of the platform-specific binary directory via + REM the environment variables setup earlier. + REM + CALL :fn_SetVariable %%P_NAME PLATFORMNAME + + REM + REM NOTE: This is the inner loop. There should be exactly one iteration. + REM This loop is necessary because the PlatformName environment + REM variable was set above and that value is needed by some of the + REM commands contained in the inner loop. If these commands were + REM directly contained in the outer loop, the PlatformName environment + REM variable would be stuck with its initial empty value instead. + REM + FOR /F "tokens=2* delims==" %%D IN ('SET PLATFORMNAME') DO ( + REM + REM NOTE: Attempt to clean the environment of all variables used by MSVC + REM and/or Visual Studio. This block may need to be updated in the + REM future to account for additional environment variables. + REM + CALL :fn_UnsetVariable DevEnvDir + CALL :fn_UnsetVariable Framework35Version + CALL :fn_UnsetVariable FrameworkDir + CALL :fn_UnsetVariable FrameworkDir32 + CALL :fn_UnsetVariable FrameworkVersion + CALL :fn_UnsetVariable FrameworkVersion32 + CALL :fn_UnsetVariable INCLUDE + CALL :fn_UnsetVariable LIB + CALL :fn_UnsetVariable LIBPATH + CALL :fn_UnsetVariable Platform + REM CALL :fn_UnsetVariable VCINSTALLDIR + CALL :fn_UnsetVariable VSINSTALLDIR + CALL :fn_UnsetVariable WindowsSdkDir + + REM + REM NOTE: Reset the PATH here to the absolute bare minimum required. + REM + SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot% + + %_VECHO% Path = '%PATH%' + + REM + REM NOTE: Launch a nested command shell to perform the following steps: + REM + REM 1. Setup the MSVC environment for this platform using the + REM official batch file. + REM + REM 2. Make sure that no stale build output files are present. + REM + REM 3. Build the "sqlite3.dll" and "sqlite3.lib" binaries for this + REM platform. + REM + REM 4. Copy the "sqlite3.dll" and "sqlite3.lib" binaries for this + REM platform to the platform-specific directory beneath the + REM binary directory. + REM + "%ComSpec%" /C ( + REM + REM NOTE: Attempt to setup the MSVC environment for this platform. + REM + %__ECHO% CALL "%VCINSTALLDIR%\vcvarsall.bat" %%P + + IF ERRORLEVEL 1 ( + ECHO Failed to call "%VCINSTALLDIR%\vcvarsall.bat" for platform %%P. + GOTO errors + ) + + REM + REM NOTE: If this batch file is not running in "what-if" mode, check to + REM be sure we were actually able to setup the MSVC environment as + REM current versions of their official batch file do not set the + REM exit code upon failure. + REM + IF NOT DEFINED __ECHO ( + IF NOT DEFINED WindowsSdkDir ( + ECHO Cannot build, Windows SDK not found for platform %%P. + GOTO errors + ) + ) + + REM + REM NOTE: Invoke NMAKE with the MSVC makefile to clean any stale build + REM output from previous iterations of this loop and/or previous + REM runs of this batch file, etc. + REM + %__ECHO% nmake -f Makefile.msc clean + + IF ERRORLEVEL 1 ( + ECHO Failed to clean for platform %%P. + GOTO errors + ) + + REM + REM NOTE: Invoke NMAKE with the MSVC makefile to build the "sqlite3.dll" + REM binary. The x86 compiler will be used to compile the native + REM command line tools needed during the build process itself. + REM Also, disable looking for and/or linking to the native Tcl + REM runtime library. + REM + %__ECHO% nmake -f Makefile.msc sqlite3.dll "NCC=""%VCINSTALLDIR%\bin\cl.exe""" USE_NATIVE_LIBPATHS=1 NO_TCL=1 %NMAKE_ARGS% + + IF ERRORLEVEL 1 ( + ECHO Failed to build "sqlite3.dll" for platform %%P. + GOTO errors + ) + + REM + REM NOTE: Copy the "sqlite3.dll" file to the platform-specific directory + REM beneath the binary directory. + REM + %__ECHO% XCOPY sqlite3.dll "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS% + + IF ERRORLEVEL 1 ( + ECHO Failed to copy "sqlite3.dll" to "%BINARYDIRECTORY%\%%D\". + GOTO errors + ) + + REM + REM NOTE: Copy the "sqlite3.lib" file to the platform-specific directory + REM beneath the binary directory. + REM + %__ECHO% XCOPY sqlite3.lib "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS% + + IF ERRORLEVEL 1 ( + ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%D\". + GOTO errors + ) + ) + ) + + REM + REM NOTE: Handle any errors generated during the nested command shell. + REM + IF ERRORLEVEL 1 ( + GOTO errors + ) +) + +REM +REM NOTE: Restore the saved current directory from the directory stack. +REM +%__ECHO2% POPD + +IF ERRORLEVEL 1 ( + ECHO Could not restore directory. + GOTO errors +) + +REM +REM NOTE: If we get to this point, we have succeeded. +REM +GOTO no_errors + +:fn_ResetErrorLevel + VERIFY > NUL + GOTO :EOF + +:fn_SetErrorLevel + VERIFY MAYBE 2> NUL + GOTO :EOF + +:fn_SetVariable + SETLOCAL + IF NOT DEFINED %1 GOTO :EOF + IF "%2" == "" GOTO :EOF + SET __ECHO_CMD=ECHO %%%1%% + FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO ( + SET VALUE=%%V + ) + ENDLOCAL && SET %2=%VALUE% + GOTO :EOF + +:fn_UnsetVariable + IF NOT "%1" == "" ( + SET %1= + CALL :fn_ResetErrorLevel + ) + GOTO :EOF + +:usage + ECHO. + ECHO Usage: %~nx0 ^ + ECHO. + GOTO errors + +:errors + CALL :fn_SetErrorLevel + ENDLOCAL + ECHO. + ECHO Failure, errors were encountered. + GOTO end_of_file + +:no_errors + CALL :fn_ResetErrorLevel + ENDLOCAL + ECHO. + ECHO Success, no errors were encountered. + GOTO end_of_file + +:end_of_file +%__ECHO% EXIT /B %ERRORLEVEL% From fd0ba2aa22f3c78151c3be0f0841abf8a8e2b324 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Jul 2012 08:21:45 +0000 Subject: [PATCH 43/69] Modify the multi-platform build tool for MSVC to support the latest RC version. FossilOrigin-Name: 95b65883bbf476a17f09ff978df4f51af615baab --- Makefile.msc | 6 +++++- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/build-all-msvc.bat | 38 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 8e1a36cf8c..76f368f3e4 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -80,7 +80,9 @@ LD = link.exe # "NCC=""%VCINSTALLDIR%\bin\cl.exe""" # USE_NATIVE_LIBPATHS=1 # -!IFNDEF NCC +!IFDEF NCC +NCC = $(NCC:\\=\) +!ELSE NCC = $(CC) !ENDIF @@ -90,6 +92,7 @@ NCC = $(CC) # !IFNDEF NCRTLIBPATH NCRTLIBPATH = $(VCINSTALLDIR)\lib +NCRTLIBPATH = $(NCRTLIBPATH:\\=\) !ENDIF # Check for the Platform SDK library path macro. Othertise, this @@ -100,6 +103,7 @@ NCRTLIBPATH = $(VCINSTALLDIR)\lib # !IFNDEF NSDKLIBPATH NSDKLIBPATH = $(WINDOWSSDKDIR)\lib +NSDKLIBPATH = $(NSDKLIBPATH:\\=\) !ENDIF # C compiler and options for use in building executables that diff --git a/manifest b/manifest index 569844a12f..d2a58a13a1 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Add\stool\sto\sbuild\sthe\score\sDLL\sfor\smultiple\splatforms\susing\sMSVC. -D 2012-07-27T07:13:25.700 +C Modify\sthe\smulti-platform\sbuild\stool\sfor\sMSVC\sto\ssupport\sthe\slatest\sRC\sversion. +D 2012-07-27T08:21:45.506 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc d598bf4a464d2e9ecbeeea809969c2ac3bf97359 +F Makefile.msc 21c3e04a68386c867a362f6332e8c3c15e4bb237 F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d @@ -966,7 +966,7 @@ F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/win32lock.test b2a539e85ae6b2d78475e016a9636b4451dc7fb9 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F test/zerodamage.test 0de750389990b1078bab203c712dc3fefd1d8b82 -F tool/build-all-msvc.bat fe0f031dce6881469b0949283a3cfa8a93032eca x +F tool/build-all-msvc.bat c739e5376cf8519ea7a9dce7e3f0c45f16a607f9 x F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 @@ -1008,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff -P 8b90e0c4dbcedaf3e61c5d49452997705be1ef98 -R 352e3b46f2ff977e05b0828462f57f7b +P e42f5812f142522852f6dc72430bc7afdd6f2ed3 +R 68817282cd6637b6d21e0b351abec1b7 U mistachkin -Z 1ba4e6125d90314090d1c67374bcfabc +Z bf08b5aacb62102aa7b12a64799d345d diff --git a/manifest.uuid b/manifest.uuid index 73ae6a4e94..929a6482f4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e42f5812f142522852f6dc72430bc7afdd6f2ed3 \ No newline at end of file +95b65883bbf476a17f09ff978df4f51af615baab \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index c5c10d0905..e62f4c310a 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -122,6 +122,16 @@ SET TOOLPATH=%gawk.exe_PATH%;%tclsh85.exe_PATH% %_VECHO% ToolPath = '%TOOLPATH%' +REM +REM NOTE: Check for MSVC 2012 because the Windows SDK directory handling is +REM slightly different for that version. +REM +IF "%VisualStudioVersion%" == "11.0" ( + SET SET_NSDKLIBPATH=1 +) ELSE ( + CALL :fn_UnsetVariable SET_NSDKLIBPATH +) + REM REM NOTE: This is the outer loop. There should be exactly one iteration per REM platform. @@ -149,11 +159,13 @@ FOR %%P IN (%PLATFORMS%) DO ( REM future to account for additional environment variables. REM CALL :fn_UnsetVariable DevEnvDir + CALL :fn_UnsetVariable ExtensionSdkDir CALL :fn_UnsetVariable Framework35Version CALL :fn_UnsetVariable FrameworkDir CALL :fn_UnsetVariable FrameworkDir32 CALL :fn_UnsetVariable FrameworkVersion CALL :fn_UnsetVariable FrameworkVersion32 + CALL :fn_UnsetVariable FSHARPINSTALLDIR CALL :fn_UnsetVariable INCLUDE CALL :fn_UnsetVariable LIB CALL :fn_UnsetVariable LIBPATH @@ -161,6 +173,8 @@ FOR %%P IN (%PLATFORMS%) DO ( REM CALL :fn_UnsetVariable VCINSTALLDIR CALL :fn_UnsetVariable VSINSTALLDIR CALL :fn_UnsetVariable WindowsSdkDir + CALL :fn_UnsetVariable WindowsSdkDir_35 + CALL :fn_UnsetVariable WindowsSdkDir_old REM REM NOTE: Reset the PATH here to the absolute bare minimum required. @@ -208,6 +222,17 @@ FOR %%P IN (%PLATFORMS%) DO ( ) ) + REM + REM NOTE: When using MSVC 2012, the native SDK path cannot simply use + REM the "lib" sub-directory beneath the location specified in the + REM WindowsSdkDir environment variable because that location does + REM not actually contain the necessary library files for x86. + REM + IF DEFINED SET_NSDKLIBPATH ( + CALL :fn_SetVariable WindowsSdkDir NSDKLIBPATH + CALL :fn_AppendVariable NSDKLIBPATH lib\win8\um\x86 + ) + REM REM NOTE: Invoke NMAKE with the MSVC makefile to clean any stale build REM output from previous iterations of this loop and/or previous @@ -307,6 +332,19 @@ GOTO no_errors ) GOTO :EOF +:fn_AppendVariable + SET __ECHO_CMD=ECHO %%%1%% + IF DEFINED %1 ( + FOR /F "delims=" %%V IN ('%__ECHO_CMD%') DO ( + SET %1=%%V%~2 + ) + ) ELSE ( + SET %1=%~2 + ) + SET __ECHO_CMD= + CALL :fn_ResetErrorLevel + GOTO :EOF + :usage ECHO. ECHO Usage: %~nx0 ^ From f2bc4380b2b6eed936e7cac00180b27a9ca09c1a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Jul 2012 08:33:10 +0000 Subject: [PATCH 44/69] For the clean makefile targets, delete the generated VSIX file as well. FossilOrigin-Name: d575d9619abd03322b73f89882d6da7c0820f285 --- Makefile.in | 1 + Makefile.msc | 1 + main.mk | 1 + manifest | 16 ++++++++-------- manifest.uuid | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index df424cb190..db7f88eebf 100644 --- a/Makefile.in +++ b/Makefile.in @@ -941,6 +941,7 @@ clean: rm -f sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def rm -f sqlite3.c rm -f sqlite3_analyzer$(TEXE) sqlite3_analyzer.c + rm -f sqlite-output.vsix distclean: clean rm -f config.log config.status libtool Makefile sqlite3.pc diff --git a/Makefile.msc b/Makefile.msc index 76f368f3e4..c8142b4517 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -1124,6 +1124,7 @@ clean: del /Q sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def del /Q sqlite3.c del /Q sqlite3_analyzer.exe sqlite3_analyzer.exp sqlite3_analyzer.c + del /Q sqlite-output.vsix # # Windows section diff --git a/main.mk b/main.mk index 8682961881..408e609b8e 100644 --- a/main.mk +++ b/main.mk @@ -616,3 +616,4 @@ clean: rm -f threadtest3 threadtest3.exe rm -f sqlite3.c fts?amal.c tclsqlite3.c rm -f sqlite3_analyzer sqlite3_analyzer.exe sqlite3_analyzer.c + rm -f sqlite-output.vsix diff --git a/manifest b/manifest index d2a58a13a1..46a0ce0ab8 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Modify\sthe\smulti-platform\sbuild\stool\sfor\sMSVC\sto\ssupport\sthe\slatest\sRC\sversion. -D 2012-07-27T08:21:45.506 +C For\sthe\sclean\smakefile\stargets,\sdelete\sthe\sgenerated\sVSIX\sfile\sas\swell. +D 2012-07-27T08:33:10.965 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 8f6d858bf3df9978ba43df19985146a1173025e4 +F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 21c3e04a68386c867a362f6332e8c3c15e4bb237 +F Makefile.msc 4d7f170e4cef939bec3c90e149ab8241c8e36703 F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d @@ -103,7 +103,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F main.mk d109a9342d1fe135d3900aca9f5563f9480a991d +F main.mk 72026405046ed5b1f0368943b89c0aa29ad558b6 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh 4123480947681d9b434a5e7b1ee08135abe409ac @@ -1008,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff -P e42f5812f142522852f6dc72430bc7afdd6f2ed3 -R 68817282cd6637b6d21e0b351abec1b7 +P 95b65883bbf476a17f09ff978df4f51af615baab +R cce28b8205971983dc12340f78f5f90e U mistachkin -Z bf08b5aacb62102aa7b12a64799d345d +Z b490b4f938ec6505b50be516f96db421 diff --git a/manifest.uuid b/manifest.uuid index 929a6482f4..60b8488207 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -95b65883bbf476a17f09ff978df4f51af615baab \ No newline at end of file +d575d9619abd03322b73f89882d6da7c0820f285 \ No newline at end of file From 78496d55ed54dad39abb47ef5cabe3aba963c657 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Jul 2012 22:29:25 +0000 Subject: [PATCH 45/69] Minor adjustments to the multi-platform build tool for MSVC. FossilOrigin-Name: e76b8f7765a91f4306cddb245e731084008f0b8c --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/build-all-msvc.bat | 12 ++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/manifest b/manifest index 46a0ce0ab8..9d4536e162 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C For\sthe\sclean\smakefile\stargets,\sdelete\sthe\sgenerated\sVSIX\sfile\sas\swell. -D 2012-07-27T08:33:10.965 +C Minor\sadjustments\sto\sthe\smulti-platform\sbuild\stool\sfor\sMSVC. +D 2012-07-27T22:29:26.000 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -966,7 +966,7 @@ F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/win32lock.test b2a539e85ae6b2d78475e016a9636b4451dc7fb9 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F test/zerodamage.test 0de750389990b1078bab203c712dc3fefd1d8b82 -F tool/build-all-msvc.bat c739e5376cf8519ea7a9dce7e3f0c45f16a607f9 x +F tool/build-all-msvc.bat d0a65da7a96b15fabf5e8d9586ff30ebe2279163 x F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 @@ -1008,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff -P 95b65883bbf476a17f09ff978df4f51af615baab -R cce28b8205971983dc12340f78f5f90e +P d575d9619abd03322b73f89882d6da7c0820f285 +R ddae9c94b79aa7fedb3193f520c7c29e U mistachkin -Z b490b4f938ec6505b50be516f96db421 +Z 7226a750f1ba945c71fd0c02712e92d7 diff --git a/manifest.uuid b/manifest.uuid index 60b8488207..2ebe790acf 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d575d9619abd03322b73f89882d6da7c0820f285 \ No newline at end of file +e76b8f7765a91f4306cddb245e731084008f0b8c \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index e62f4c310a..e7832284ee 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -181,8 +181,6 @@ FOR %%P IN (%PLATFORMS%) DO ( REM SET PATH=%TOOLPATH%;%SystemRoot%\System32;%SystemRoot% - %_VECHO% Path = '%PATH%' - REM REM NOTE: Launch a nested command shell to perform the following steps: REM @@ -238,11 +236,13 @@ FOR %%P IN (%PLATFORMS%) DO ( REM output from previous iterations of this loop and/or previous REM runs of this batch file, etc. REM - %__ECHO% nmake -f Makefile.msc clean + IF NOT DEFINED NOCLEAN ( + %__ECHO% nmake -f Makefile.msc clean - IF ERRORLEVEL 1 ( - ECHO Failed to clean for platform %%P. - GOTO errors + IF ERRORLEVEL 1 ( + ECHO Failed to clean for platform %%P. + GOTO errors + ) ) REM From 0b5ae7299319466ae56339c9a0511528b3454956 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 27 Jul 2012 23:03:47 +0000 Subject: [PATCH 46/69] Improve consistency in handling of build outputs and native library paths in the multi-platform build tool for MSVC. FossilOrigin-Name: e71f2de2cc7c4ef5ee31da81b6615886f6e601e7 --- Makefile.msc | 6 ++++-- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/build-all-msvc.bat | 19 +++++++++++++++---- 4 files changed, 27 insertions(+), 14 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index c8142b4517..a7daea756d 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -92,9 +92,10 @@ NCC = $(CC) # !IFNDEF NCRTLIBPATH NCRTLIBPATH = $(VCINSTALLDIR)\lib -NCRTLIBPATH = $(NCRTLIBPATH:\\=\) !ENDIF +NCRTLIBPATH = $(NCRTLIBPATH:\\=\) + # Check for the Platform SDK library path macro. Othertise, this # value will default to the 'lib' directory underneath the Windows # SDK installation directory (the environment variable used appears @@ -103,9 +104,10 @@ NCRTLIBPATH = $(NCRTLIBPATH:\\=\) # !IFNDEF NSDKLIBPATH NSDKLIBPATH = $(WINDOWSSDKDIR)\lib -NSDKLIBPATH = $(NSDKLIBPATH:\\=\) !ENDIF +NSDKLIBPATH = $(NSDKLIBPATH:\\=\) + # C compiler and options for use in building executables that # will run on the platform that is doing the build. # diff --git a/manifest b/manifest index 9d4536e162..acf282d786 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Minor\sadjustments\sto\sthe\smulti-platform\sbuild\stool\sfor\sMSVC. -D 2012-07-27T22:29:26.000 +C Improve\sconsistency\sin\shandling\sof\sbuild\soutputs\sand\snative\slibrary\spaths\sin\sthe\smulti-platform\sbuild\stool\sfor\sMSVC. +D 2012-07-27T23:03:47.862 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 4d7f170e4cef939bec3c90e149ab8241c8e36703 +F Makefile.msc c1293ece66e237b545eae4484e3e81571fb5f47c F Makefile.vxworks 879f034a64062a364b21000266bbd5bc6e0c19b9 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a71848df48082f1d6585d4b0819d530fc455485d @@ -966,7 +966,7 @@ F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/win32lock.test b2a539e85ae6b2d78475e016a9636b4451dc7fb9 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F test/zerodamage.test 0de750389990b1078bab203c712dc3fefd1d8b82 -F tool/build-all-msvc.bat d0a65da7a96b15fabf5e8d9586ff30ebe2279163 x +F tool/build-all-msvc.bat f8e272fc74c48e7697f4744aacce1ee4df5edb20 x F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 @@ -1008,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff -P d575d9619abd03322b73f89882d6da7c0820f285 -R ddae9c94b79aa7fedb3193f520c7c29e +P e76b8f7765a91f4306cddb245e731084008f0b8c +R cb74972be2d529442347b1af34814a0a U mistachkin -Z 7226a750f1ba945c71fd0c02712e92d7 +Z 1c22abf12838e6e39c724ae138286b68 diff --git a/manifest.uuid b/manifest.uuid index 2ebe790acf..4ee6e83bc6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e76b8f7765a91f4306cddb245e731084008f0b8c \ No newline at end of file +e71f2de2cc7c4ef5ee31da81b6615886f6e601e7 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index e7832284ee..bc6dbf2ad8 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -225,16 +225,20 @@ FOR %%P IN (%PLATFORMS%) DO ( REM the "lib" sub-directory beneath the location specified in the REM WindowsSdkDir environment variable because that location does REM not actually contain the necessary library files for x86. + REM This must be done for each iteration because it relies upon + REM the WindowsSdkDir environment variable being set by the batch + REM file used to setup the MSVC environment. REM IF DEFINED SET_NSDKLIBPATH ( CALL :fn_SetVariable WindowsSdkDir NSDKLIBPATH - CALL :fn_AppendVariable NSDKLIBPATH lib\win8\um\x86 + CALL :fn_AppendVariable NSDKLIBPATH \lib\win8\um\x86 ) REM - REM NOTE: Invoke NMAKE with the MSVC makefile to clean any stale build - REM output from previous iterations of this loop and/or previous - REM runs of this batch file, etc. + REM NOTE: Unless prevented from doing so, invoke NMAKE with the MSVC + REM makefile to clean any stale build output from previous + REM iterations of this loop and/or previous runs of this batch + REM file, etc. REM IF NOT DEFINED NOCLEAN ( %__ECHO% nmake -f Makefile.msc clean @@ -243,6 +247,13 @@ FOR %%P IN (%PLATFORMS%) DO ( ECHO Failed to clean for platform %%P. GOTO errors ) + ) ELSE ( + REM + REM NOTE: Even when the cleaning step has been disabled, we still need + REM to remove the build output for the files we are specifically + REM wanting to build for each platform. + REM + %__ECHO% DEL /Q sqlite3.dll sqlite3.lib ) REM From 6809c96df33bf03d22700b62dcc27b7d753834b1 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 30 Jul 2012 14:53:54 +0000 Subject: [PATCH 47/69] Replace a few sqlite3_malloc()+memset() sequences with calls to sqlite3MallocZero(). FossilOrigin-Name: 305b6667265353b858b79bfea1745e64ff3bb7d3 --- manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/analyze.c | 3 +-- src/backup.c | 3 +-- src/bitvec.c | 3 +-- src/hash.c | 3 +-- src/pcache1.c | 6 ++---- src/vdbetrace.c | 3 +-- 8 files changed, 20 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index acf282d786..6d26290011 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Improve\sconsistency\sin\shandling\sof\sbuild\soutputs\sand\snative\slibrary\spaths\sin\sthe\smulti-platform\sbuild\stool\sfor\sMSVC. -D 2012-07-27T23:03:47.862 +C Replace\sa\sfew\ssqlite3_malloc()+memset()\ssequences\swith\scalls\sto\ssqlite3MallocZero(). +D 2012-07-30T14:53:54.464 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -117,11 +117,11 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 149cc80d9257971b0bff34e58fb2263e01998289 -F src/analyze.c 70c46504c0d2543ea5cdca01140b2cd3e1d886e7 +F src/analyze.c a4790912e504c8ddac273445e7aba39bbce50881 F src/attach.c 577bf5675b0c50495fc28549f2fcbdb1bac71143 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 -F src/backup.c 5524df36810668b3b5a6de2d7e3910b98e721e33 -F src/bitvec.c af50f1c8c0ff54d6bdb7a80e2fceca5a93670bef +F src/backup.c 5b31b24d6814b11de763debf342c8cd0a15a4910 +F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c f0b71054103cb77eb5e782088c16998ec4f06624 F src/btree.h 48a013f8964f12d944d90e4700df47b72dd6d923 @@ -137,7 +137,7 @@ F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5 F src/func.c 18dfedfb857e100b05755a1b12e88b389f957879 F src/global.c 4cfdca5cb0edd33c4d021baec4ede958cb2c793b -F src/hash.c 458488dcc159c301b8e7686280ab209f1fb915af +F src/hash.c 1f35276f9664dd150451b463805a952892227c73 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c 770ed633830fb49d73d90c3fdf20b703973e1e84 @@ -169,7 +169,7 @@ F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h 1b5dcc3dc8103d03e625b177023ee67764fa6b7c -F src/pcache1.c 2234d84f9c003d800a57f00f8535c91667fa4f6c +F src/pcache1.c 9fd22671c270b35131ef480bbc00392b8b5f8ab9 F src/pragma.c 97f9357f0e7e5fb46a2519f14539550aa07db49f F src/prepare.c 33291b83cca285718048d219c67b8298501fa3a5 F src/printf.c 4a9f882f1c1787a8b494a2987765acf9d97ac21f @@ -245,7 +245,7 @@ F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 F src/vdbesort.c 628b2bc0cc82cae0e9946f70c5c81986e9fba91f -F src/vdbetrace.c 79059ebd17b3c8545fab2a24253713e77e4ab392 +F src/vdbetrace.c 8bd5da325fc90f28464335e4cc4ad1407fe30835 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b F src/wal.h 29c197540b19044e6cd73487017e5e47a1d3dac6 @@ -1008,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff -P e76b8f7765a91f4306cddb245e731084008f0b8c -R cb74972be2d529442347b1af34814a0a -U mistachkin -Z 1c22abf12838e6e39c724ae138286b68 +P e71f2de2cc7c4ef5ee31da81b6615886f6e601e7 +R a7495b0145c88ec6647f7c425289b3e1 +U dan +Z 82b9855bd1443e957263d9bd8f18cf53 diff --git a/manifest.uuid b/manifest.uuid index 4ee6e83bc6..eeb9e4e8c7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e71f2de2cc7c4ef5ee31da81b6615886f6e601e7 \ No newline at end of file +305b6667265353b858b79bfea1745e64ff3bb7d3 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 4dfc331bef..810ed54d85 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -256,12 +256,11 @@ static void stat3Init( nRow = (tRowcnt)sqlite3_value_int64(argv[0]); mxSample = sqlite3_value_int(argv[1]); n = sizeof(*p) + sizeof(p->a[0])*mxSample; - p = sqlite3_malloc( n ); + p = sqlite3MallocZero( n ); if( p==0 ){ sqlite3_result_error_nomem(context); return; } - memset(p, 0, n); p->a = (struct Stat3Sample*)&p[1]; p->nRow = nRow; p->mxSample = mxSample; diff --git a/src/backup.c b/src/backup.c index 527ecb5744..4881215e96 100644 --- a/src/backup.c +++ b/src/backup.c @@ -164,7 +164,7 @@ sqlite3_backup *sqlite3_backup_init( ** EVIDENCE-OF: R-64852-21591 The sqlite3_backup object is created by a ** call to sqlite3_backup_init() and is destroyed by a call to ** sqlite3_backup_finish(). */ - p = (sqlite3_backup *)sqlite3_malloc(sizeof(sqlite3_backup)); + p = (sqlite3_backup *)sqlite3MallocZero(sizeof(sqlite3_backup)); if( !p ){ sqlite3Error(pDestDb, SQLITE_NOMEM, 0); } @@ -172,7 +172,6 @@ sqlite3_backup *sqlite3_backup_init( /* If the allocation succeeded, populate the new object. */ if( p ){ - memset(p, 0, sizeof(sqlite3_backup)); p->pSrc = findBtree(pDestDb, pSrcDb, zSrcDb); p->pDest = findBtree(pDestDb, pDestDb, zDestDb); p->pDestDb = pDestDb; diff --git a/src/bitvec.c b/src/bitvec.c index 47d33ea840..8d805a6fe5 100644 --- a/src/bitvec.c +++ b/src/bitvec.c @@ -340,10 +340,9 @@ int sqlite3BitvecBuiltinTest(int sz, int *aOp){ /* Allocate the Bitvec to be tested and a linear array of ** bits to act as the reference */ pBitvec = sqlite3BitvecCreate( sz ); - pV = sqlite3_malloc( (sz+7)/8 + 1 ); + pV = sqlite3MallocZero( (sz+7)/8 + 1 ); pTmpSpace = sqlite3_malloc(BITVEC_SZ); if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end; - memset(pV, 0, (sz+7)/8 + 1); /* NULL pBitvec tests */ sqlite3BitvecSet(0, 1); diff --git a/src/hash.c b/src/hash.c index d4daf92a6f..8d5a706564 100644 --- a/src/hash.c +++ b/src/hash.c @@ -116,14 +116,13 @@ static int rehash(Hash *pH, unsigned int new_size){ ** allocation as a benign. */ sqlite3BeginBenignMalloc(); - new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) ); + new_ht = (struct _ht *)sqlite3MallocZero( new_size*sizeof(struct _ht) ); sqlite3EndBenignMalloc(); if( new_ht==0 ) return 0; sqlite3_free(pH->ht); pH->ht = new_ht; pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht); - memset(new_ht, 0, new_size*sizeof(struct _ht)); for(elem=pH->first, pH->first=0; elem; elem = next_elem){ unsigned int h = strHash(elem->pKey, elem->nKey) % new_size; next_elem = elem->next; diff --git a/src/pcache1.c b/src/pcache1.c index c41b49e6c8..4147d2eff5 100644 --- a/src/pcache1.c +++ b/src/pcache1.c @@ -396,11 +396,10 @@ static int pcache1ResizeHash(PCache1 *p){ pcache1LeaveMutex(p->pGroup); if( p->nHash ){ sqlite3BeginBenignMalloc(); } - apNew = (PgHdr1 **)sqlite3_malloc(sizeof(PgHdr1 *)*nNew); + apNew = (PgHdr1 **)sqlite3MallocZero(sizeof(PgHdr1 *)*nNew); if( p->nHash ){ sqlite3EndBenignMalloc(); } pcache1EnterMutex(p->pGroup); if( apNew ){ - memset(apNew, 0, sizeof(PgHdr1 *)*nNew); for(i=0; inHash; i++){ PgHdr1 *pPage; PgHdr1 *pNext = p->apHash[i]; @@ -584,9 +583,8 @@ static sqlite3_pcache *pcache1Create(int szPage, int szExtra, int bPurgeable){ assert( szExtra < 300 ); sz = sizeof(PCache1) + sizeof(PGroup)*separateCache; - pCache = (PCache1 *)sqlite3_malloc(sz); + pCache = (PCache1 *)sqlite3MallocZero(sz); if( pCache ){ - memset(pCache, 0, sz); if( separateCache ){ pGroup = (PGroup*)&pCache[1]; pGroup->mxPinned = 10; diff --git a/src/vdbetrace.c b/src/vdbetrace.c index c71a7c41a4..35825c8736 100644 --- a/src/vdbetrace.c +++ b/src/vdbetrace.c @@ -169,9 +169,8 @@ void sqlite3ExplainBegin(Vdbe *pVdbe){ if( pVdbe ){ Explain *p; sqlite3BeginBenignMalloc(); - p = sqlite3_malloc( sizeof(Explain) ); + p = (Explain *)sqlite3MallocZero( sizeof(Explain) ); if( p ){ - memset(p, 0, sizeof(*p)); p->pVdbe = pVdbe; sqlite3_free(pVdbe->pExplain); pVdbe->pExplain = p; From 391b36472ae14d581ff560a0dd840007b346c42c Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 31 Jul 2012 00:43:31 +0000 Subject: [PATCH 48/69] Modify metadata for the VSIX package and add tooling support for PDBs. FossilOrigin-Name: 12cbf6a9343ffb24065f77f679e50b67bc2e43f9 --- manifest | 18 ++++---- manifest.uuid | 2 +- tool/build-all-msvc.bat | 16 ++++++- tool/mkvsix.tcl | 98 +++++++++++++++++++++++++++++++--------- tool/win/sqlite.vsix | Bin 34247 -> 32783 bytes 5 files changed, 101 insertions(+), 33 deletions(-) diff --git a/manifest b/manifest index 6d26290011..9181eaf941 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Replace\sa\sfew\ssqlite3_malloc()+memset()\ssequences\swith\scalls\sto\ssqlite3MallocZero(). -D 2012-07-30T14:53:54.464 +C Modify\smetadata\sfor\sthe\sVSIX\spackage\sand\sadd\stooling\ssupport\sfor\sPDBs. +D 2012-07-31T00:43:31.954 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -966,7 +966,7 @@ F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/win32lock.test b2a539e85ae6b2d78475e016a9636b4451dc7fb9 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F test/zerodamage.test 0de750389990b1078bab203c712dc3fefd1d8b82 -F tool/build-all-msvc.bat f8e272fc74c48e7697f4744aacce1ee4df5edb20 x +F tool/build-all-msvc.bat 1a18aa39983ae7354d834bc55a850a54fc007576 x F tool/build-shell.sh b64a481901fc9ffe5ca8812a2a9255b6cfb77381 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b F tool/extract.c 054069d81b095fbdc189a6f5d4466e40380505e2 @@ -983,7 +983,7 @@ F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl 589c7f44e990be1b8443cfe4808dce392b0327fa F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 -F tool/mkvsix.tcl 75fb1b601d69ead76340fa15bf9813874fed240b +F tool/mkvsix.tcl ce2ad5da880752426e2597382f3bf1279d5646b3 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1007,8 +1007,8 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -F tool/win/sqlite.vsix 84163b633f01f35cb47495c05dd2b640159677ff -P e71f2de2cc7c4ef5ee31da81b6615886f6e601e7 -R a7495b0145c88ec6647f7c425289b3e1 -U dan -Z 82b9855bd1443e957263d9bd8f18cf53 +F tool/win/sqlite.vsix a8778c835bbfe8d9d2066c144542c245a29ac525 +P 305b6667265353b858b79bfea1745e64ff3bb7d3 +R bd2d8408dc9dbcc7a27c7ffc1e947c79 +U mistachkin +Z 91e5f70404ea58b1f716b323c3d5addd diff --git a/manifest.uuid b/manifest.uuid index eeb9e4e8c7..eda8eaf007 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -305b6667265353b858b79bfea1745e64ff3bb7d3 \ No newline at end of file +12cbf6a9343ffb24065f77f679e50b67bc2e43f9 \ No newline at end of file diff --git a/tool/build-all-msvc.bat b/tool/build-all-msvc.bat index bc6dbf2ad8..a2d7dae3a3 100755 --- a/tool/build-all-msvc.bat +++ b/tool/build-all-msvc.bat @@ -253,7 +253,7 @@ FOR %%P IN (%PLATFORMS%) DO ( REM to remove the build output for the files we are specifically REM wanting to build for each platform. REM - %__ECHO% DEL /Q sqlite3.dll sqlite3.lib + %__ECHO% DEL /Q sqlite3.dll sqlite3.lib sqlite3.pdb ) REM @@ -291,6 +291,20 @@ FOR %%P IN (%PLATFORMS%) DO ( ECHO Failed to copy "sqlite3.lib" to "%BINARYDIRECTORY%\%%D\". GOTO errors ) + + REM + REM NOTE: Copy the "sqlite3.pdb" file to the platform-specific directory + REM beneath the binary directory unless we are prevented from doing + REM so. + REM + IF NOT DEFINED NOSYMBOLS ( + %__ECHO% XCOPY sqlite3.pdb "%BINARYDIRECTORY%\%%D\" %FFLAGS% %DFLAGS% + + IF ERRORLEVEL 1 ( + ECHO Failed to copy "sqlite3.pdb" to "%BINARYDIRECTORY%\%%D\". + GOTO errors + ) + ) ) ) diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index a5a569d475..3a570b650a 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -147,6 +147,19 @@ if {![file exists $sourceDirectory] || \ ############################################################################### +# +# NOTE: Evaluate the user-specific customizations file, if it exists. +# +set userFile [file join $path [appendArgs \ + $rootName . $tcl_platform(user) .tcl]] + +if {[file exists $userFile] && \ + [file isfile $userFile]} then { + source $userFile +} + +############################################################################### + set templateFile [file join $path win sqlite.vsix] if {![file exists $templateFile] || \ @@ -220,7 +233,7 @@ if {![info exists unzip]} then { # in the source directory. This script assumes that the header file has # already been generated by the build process. # -set pattern {^#define\s+?SQLITE_VERSION\s+?"(.*?)"$} +set pattern {^#define\s+SQLITE_VERSION\s+"(.*)"$} set data [readFile [file join $sourceDirectory sqlite3.h]] if {![regexp -line -- $pattern $data dummy version]} then { @@ -233,32 +246,62 @@ if {![regexp -line -- $pattern $data dummy version]} then { # # NOTE: Setup the master file list data, including the necessary flags. # -set fileNames(source) [list "" "" "" \ - [file join $sourceDirectory sqlite3.h] \ - [file join $binaryDirectory sqlite3.lib] \ - [file join $binaryDirectory sqlite3.dll]] +if {![info exists fileNames(source)]} then { + set fileNames(source) [list "" "" "" \ + [file join $sourceDirectory sqlite3.h] \ + [file join $binaryDirectory sqlite3.lib] \ + [file join $binaryDirectory sqlite3.dll]] -set fileNames(destination) [list \ - [file join $stagingDirectory extension.vsixmanifest] \ - [file join $stagingDirectory SDKManifest.xml] \ - [file join $stagingDirectory DesignTime CommonConfiguration \ - SQLite.WinRT.props] \ - [file join $stagingDirectory DesignTime CommonConfiguration \ - sqlite3.h] \ - [file join $stagingDirectory DesignTime CommonConfiguration \ - sqlite3.lib] \ - [file join $stagingDirectory Redist CommonConfiguration \ - sqlite3.dll]] + if {![info exists no(symbols)]} then { + lappend fileNames(source) \ + [file join $binaryDirectory sqlite3.pdb] + } +} -set fileNames(neutral) [list 1 1 1 1 0 0] -set fileNames(subst) [list 1 1 1 0 0 0] +if {![info exists fileNames(destination)]} then { + set fileNames(destination) [list \ + [file join $stagingDirectory extension.vsixmanifest] \ + [file join $stagingDirectory SDKManifest.xml] \ + [file join $stagingDirectory DesignTime CommonConfiguration \ + SQLite.WinRT.props] \ + [file join $stagingDirectory DesignTime CommonConfiguration \ + sqlite3.h] \ + [file join $stagingDirectory DesignTime CommonConfiguration \ + sqlite3.lib] \ + [file join $stagingDirectory Redist CommonConfiguration \ + sqlite3.dll]] + + if {![info exists no(symbols)]} then { + lappend fileNames(destination) \ + [file join $stagingDirectory Redist CommonConfiguration \ + sqlite3.pdb] + } +} + +if {![info exists fileNames(neutral)]} then { + set fileNames(neutral) [list 1 1 1 1 0 0] + + if {![info exists no(symbols)]} then { + lappend fileNames(neutral) 0 + } +} + +if {![info exists fileNames(subst)]} then { + set fileNames(subst) [list 1 1 1 0 0 0] + + if {![info exists no(symbols)]} then { + lappend fileNames(subst) 0 + } +} ############################################################################### # # NOTE: Setup the list of platforms supported by this script. # -set platformNames [list ARM x64 x86] +if {![info exists platformNames]} then { + set platformNames [list ARM x64 x86] +} ############################################################################### @@ -302,15 +345,26 @@ foreach sourceFileName $fileNames(source) \ # platform will be processed for it individually. # foreach platformName [expr {$isNeutral ? [list neutral] : $platformNames}] { + # + # NOTE: Use the actual platform name in the destination file name. + # + set newDestinationFileName [replacePlatform $destinationFileName \ + $platformName] + # # NOTE: Does the source file need to be copied to the destination file? # if {[string length $sourceFileName] > 0} then { # - # NOTE: Copy the source file to the destination file verbatim. + # NOTE: First, make sure the destination directory exists. + # + file mkdir [file dirname $newDestinationFileName] + + # + # NOTE: Then, copy the source file to the destination file verbatim. # file copy [replacePlatform $sourceFileName $platformName] \ - [replacePlatform $destinationFileName $platformName] + $newDestinationFileName } # @@ -322,7 +376,7 @@ foreach sourceFileName $fileNames(source) \ # NOTE: Perform any dynamic replacements contained in the destination # file and then re-write it in-place. # - substFile [replacePlatform $destinationFileName $platformName] + substFile $newDestinationFileName } } } diff --git a/tool/win/sqlite.vsix b/tool/win/sqlite.vsix index 16f7b57cd03cf43fd1c77761a25b98929305eb39..57830edeac907e93d95a82e0207b120b1de03cba 100644 GIT binary patch delta 435 zcmX@!&D7t(G@)VR!FP1DtbW2>zh(!4 z*7vi&$eLBJUC@~+6`kXeEiC+Dxk*K@!IsH7*00|v{rILAdNJj$TbEbv|xAg^?D*RLYIqp$L;BJ%hmP0lMNTd*erCqAdmZ#%yZ^> z*ESk*9elU2ybF!-nGd;Zd%gGl$B+U`}{tfjq8!`Z;Q<4*|<4# zwTu+2y?U<7`@w3TPxi|3nN?RQ5W*&V_c+PXjX=R@uQZ)O$|1}0#D z%-yV2`;?JUeX>Bk!DPJ#j>&uL{TNqIY*YeroF+##sxf6TO>SyTV|u|d`Bh^Cqv~Ym zrWmHzVv`p(nQGWGU<*|S27U$=VEBT70ub-3oGjid%XWUFx#-5c$yTj4O!uoMSF}3v RaWQZ)h_Em)Jgo*P1pt7nvNHex delta 1344 zcmeBgU^?E-G@*e}d19jyvty9&##BxwaV`cB5cK=u0A@f5kP`U{GZXy)Z)O(UN?0l^ z%=9;BF-4TSLKJz&p_;=EG%qMMC9}8$$s{i{MbdCZ69e_R$fq@?=8tmfjo0ylGmRek*SCN|&I`M86 zlc7NCd+yqHfvU{wVqOzpg}Df_yzTGW+c!H>_JrEYlx?eZYrm(3udbLrbIzQfMa!<= z7j>&)WGyk9`u*fwkp$!A7xRK5i|TGqTvY$RruM4z;zmujefxxxS`JEYtq){fQuNWz zm2IN6kbK5-@0%J5DJ}CBzxHf&)DVn0H&sc1?fQ}o{fgBQ2@iQi5_V2(IGJyp9=VY9 zZkMU61GD0mBjyuUzc0EoWl7fWX$e7QE7s^u5iFc>q3dcCYe)P|m;NP=Rm#gx_Z(m4 zP~14Le$K}9zJ#RW>8Erz*Jo{Cy~^v*@|B@|W^dh0E((fN*8kjB>h?>ms+$F-O;r7r9o~9FQZ9I5@(H;$eCsck zwMp)@x}9P==aJQ%Oh0DvrQiD`zBFvoEt(T1)DrT}s$byl-N(-52J=r=U3~lB_xL0J z&G)N5FfuAnzEESJ42p9u1_fXoFfcGONH9Fu`$S_;=2=D&N&8$e8#+X!7J*jmg_=|(7Z&( Date: Tue, 31 Jul 2012 08:15:56 +0000 Subject: [PATCH 49/69] Make the list of platforms dynamic in the SDK manifest inside the VSIX package. FossilOrigin-Name: 22b72e499d2aeba42d0531ae58f87ff023787f47 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/mkvsix.tcl | 2 +- tool/win/sqlite.vsix | Bin 32783 -> 32790 bytes 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 9181eaf941..5a918f64c6 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\smetadata\sfor\sthe\sVSIX\spackage\sand\sadd\stooling\ssupport\sfor\sPDBs. -D 2012-07-31T00:43:31.954 +C Make\sthe\slist\sof\splatforms\sdynamic\sin\sthe\sSDK\smanifest\sinside\sthe\sVSIX\spackage. +D 2012-07-31T08:15:56.966 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -983,7 +983,7 @@ F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl 589c7f44e990be1b8443cfe4808dce392b0327fa F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 -F tool/mkvsix.tcl ce2ad5da880752426e2597382f3bf1279d5646b3 +F tool/mkvsix.tcl 153187ce9f1911bc2d0caa7af9856d7b8b805e27 F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1007,8 +1007,8 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -F tool/win/sqlite.vsix a8778c835bbfe8d9d2066c144542c245a29ac525 -P 305b6667265353b858b79bfea1745e64ff3bb7d3 -R bd2d8408dc9dbcc7a27c7ffc1e947c79 +F tool/win/sqlite.vsix 60c6a9864cd8dfa221215e9ef651781440f056fc +P 12cbf6a9343ffb24065f77f679e50b67bc2e43f9 +R 7df148b047b8c83dabfec0a3d080b59e U mistachkin -Z 91e5f70404ea58b1f716b323c3d5addd +Z 610dc29b5bd32d7ba5eb2f794e90effb diff --git a/manifest.uuid b/manifest.uuid index eda8eaf007..c248519372 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -12cbf6a9343ffb24065f77f679e50b67bc2e43f9 \ No newline at end of file +22b72e499d2aeba42d0531ae58f87ff023787f47 \ No newline at end of file diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index 3a570b650a..506ab7334d 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -300,7 +300,7 @@ if {![info exists fileNames(subst)]} then { # NOTE: Setup the list of platforms supported by this script. # if {![info exists platformNames]} then { - set platformNames [list ARM x64 x86] + set platformNames [list x86 x64 ARM] } ############################################################################### diff --git a/tool/win/sqlite.vsix b/tool/win/sqlite.vsix index 57830edeac907e93d95a82e0207b120b1de03cba..9dd5c814085d0efb83f5a7e628d96a3bcf9d6123 100644 GIT binary patch delta 344 zcmV-e0jK_tfC83)0OuO<`_nW@U49E_iKh zRgle2!$1s#@0I!vs})B`;D(@~s#+=`HThn3NcFb+H}N-wHqY|GUof~^ z&zv&|ejSd3U`3q|n>kr2&;sv}1vs#kzX@k4mQ0>%iSqdhU;N>aco585=ZM9ptr2tv zeqQ=SUosQ_XP}yKAh``LOKBMb@%Tz;)j_C4LJLhF*Q=-VXWjP}{}va9FSFlzU<3`I q3I9MqPrF|G0001PlT3dw1%wGoO!Sk1e?0-_lfQpT2JCwP0001=ot)$V delta 345 zcmV-f0jBOuO<`_nW@U49E_iKh zRgm3IgFq04@0;`;HhZn0iD?>JY)ESp6Y!@rc#SZ$lPo*y>>~K~E>+Q9&g461&Yb0{ zZTWt&Zc#yk)=eiuY|t82e|$a`4MZ|~Nzj3) ziN!1G-ChpFGgH-;Zd){{&bZ)@Nr~Y>*A&U4bLKV-yRHlDyBa9sL--A$&a-^X=L4SB zu`vq4?!DL>R@7O)S(A1JYTy&H0Ry_SPhOT{$z-W^LB3A#&0dTjkA_)m46(Cms~j2y zKPPP@@0p4JGf>4`9Ugtk(zOhp=;yOVKf77PyHpNUg}+_-;R{ep0|b+ye;Bg@dqe~c rdWrr(KijS-^Z)<=VUtsTFa^)CHx;pyh<`l+-;>6FN(SY7000001~HtQ From dfbfbffd13495a0de833a9eea49c07cab3018a95 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 1 Aug 2012 20:20:27 +0000 Subject: [PATCH 50/69] Fix typos of function names sqlite3_result_error_toobig and sqlite3_result_error_nomem in the documentation. No changes to code. FossilOrigin-Name: bec97c98130f057321f3db1436a24377c3c64f81 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/sqlite.h.in | 8 ++++---- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 5a918f64c6..78dc00c12b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\sthe\slist\sof\splatforms\sdynamic\sin\sthe\sSDK\smanifest\sinside\sthe\sVSIX\spackage. -D 2012-07-31T08:15:56.966 +C Fix\stypos\sof\sfunction\snames\ssqlite3_result_error_toobig\sand\ssqlite3_result_error_nomem\sin\sthe\sdocumentation.\sNo\schanges\sto\scode. +D 2012-08-01T20:20:27.300 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -178,7 +178,7 @@ F src/resolve.c b3c70ab28cac60de33684c9aa9e5138dcf71d6dd F src/rowset.c f6a49f3e9579428024662f6e2931832511f831a1 F src/select.c a365da6d7a6d7d8a10ad60ca71837ab5e9369466 F src/shell.c 076e1c90d594644f36027c8ecff9a392cf2d3a06 -F src/sqlite.h.in 310ae7e538883fa1619ab0638c775ce11ad43015 +F src/sqlite.h.in 3e8035bc406b1571a5cc8ea46bcc831201676f1a F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 F src/sqliteInt.h ed41801550b0b8fb8217fcfd2e362118062b30c0 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d @@ -1008,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 60c6a9864cd8dfa221215e9ef651781440f056fc -P 12cbf6a9343ffb24065f77f679e50b67bc2e43f9 -R 7df148b047b8c83dabfec0a3d080b59e +P 22b72e499d2aeba42d0531ae58f87ff023787f47 +R 7a9ae759b6585bddd1352351a6c5ae73 U mistachkin -Z 610dc29b5bd32d7ba5eb2f794e90effb +Z 2e386fb6f10594ee697cff75e8a92cd8 diff --git a/manifest.uuid b/manifest.uuid index c248519372..766d2967de 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -22b72e499d2aeba42d0531ae58f87ff023787f47 \ No newline at end of file +bec97c98130f057321f3db1436a24377c3c64f81 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 69ea6d15d7..aa60f80b22 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -4152,11 +4152,11 @@ typedef void (*sqlite3_destructor_type)(void*); ** the error code is SQLITE_ERROR. ^A subsequent call to sqlite3_result_error() ** or sqlite3_result_error16() resets the error code to SQLITE_ERROR. ** -** ^The sqlite3_result_toobig() interface causes SQLite to throw an error -** indicating that a string or BLOB is too long to represent. +** ^The sqlite3_result_error_toobig() interface causes SQLite to throw an +** error indicating that a string or BLOB is too long to represent. ** -** ^The sqlite3_result_nomem() interface causes SQLite to throw an error -** indicating that a memory allocation failed. +** ^The sqlite3_result_error_nomem() interface causes SQLite to throw an +** error indicating that a memory allocation failed. ** ** ^The sqlite3_result_int() interface sets the return value ** of the application-defined function to be the 32-bit signed integer From a36421ab061fdfb8beed08b035d9c7fff75f27ef Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 3 Aug 2012 10:00:56 +0000 Subject: [PATCH 51/69] Correct comment about WinRT compiler define. No changes to code. FossilOrigin-Name: 335e91e599555d9f4e42f90576d1676c381314f4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os.h | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 78dc00c12b..5d32d1deb2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\stypos\sof\sfunction\snames\ssqlite3_result_error_toobig\sand\ssqlite3_result_error_nomem\sin\sthe\sdocumentation.\sNo\schanges\sto\scode. -D 2012-08-01T20:20:27.300 +C Correct\scomment\sabout\sWinRT\scompiler\sdefine.\s\sNo\schanges\sto\scode. +D 2012-08-03T10:00:56.291 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -160,7 +160,7 @@ F src/mutex_unix.c c3a4e00f96ba068a8dbef34084465979aaf369cc F src/mutex_w32.c 32a9b3841e2d757355f0012b860b1bc5e01eafa0 F src/notify.c 976dd0f6171d4588e89e874fcc765e92914b6d30 F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c -F src/os.h c2ebd26a68a4223fe170b003852b97d9e7211498 +F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757 F src/os_win.c e3d3d3e26b65a35d4293d753137a58510bd3299b @@ -1008,7 +1008,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 60c6a9864cd8dfa221215e9ef651781440f056fc -P 22b72e499d2aeba42d0531ae58f87ff023787f47 -R 7a9ae759b6585bddd1352351a6c5ae73 +P bec97c98130f057321f3db1436a24377c3c64f81 +R 9ab8bb2549750bb239d2842c9dc60680 U mistachkin -Z 2e386fb6f10594ee697cff75e8a92cd8 +Z b6a365cc856116cf33aff81d6af1be2b diff --git a/manifest.uuid b/manifest.uuid index 766d2967de..3024e988e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -bec97c98130f057321f3db1436a24377c3c64f81 \ No newline at end of file +335e91e599555d9f4e42f90576d1676c381314f4 \ No newline at end of file diff --git a/src/os.h b/src/os.h index 37d08fc254..1ec7d4ba11 100644 --- a/src/os.h +++ b/src/os.h @@ -92,8 +92,8 @@ #endif /* -** Determine if we are dealing with WindowsRT (Metro) as this has a different and -** incompatible API from win32. +** Determine if we are dealing with WinRT, which provides only a subset of +** the full Win32 API. */ #if !defined(SQLITE_OS_WINRT) # define SQLITE_OS_WINRT 0 From e2e2ab3a2d9f29aecf1ccac661ccddda892a6162 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 6 Aug 2012 10:51:55 +0000 Subject: [PATCH 52/69] Update description strings in the VSIX package. FossilOrigin-Name: 541e9310a7b88e0b40c6530947803527f28e51de --- manifest | 12 ++++++------ manifest.uuid | 2 +- tool/win/sqlite.vsix | Bin 32790 -> 32802 bytes 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 5d32d1deb2..830c9c3fb7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Correct\scomment\sabout\sWinRT\scompiler\sdefine.\s\sNo\schanges\sto\scode. -D 2012-08-03T10:00:56.291 +C Update\sdescription\sstrings\sin\sthe\sVSIX\spackage. +D 2012-08-06T10:51:55.331 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1007,8 +1007,8 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -F tool/win/sqlite.vsix 60c6a9864cd8dfa221215e9ef651781440f056fc -P bec97c98130f057321f3db1436a24377c3c64f81 -R 9ab8bb2549750bb239d2842c9dc60680 +F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 +P 335e91e599555d9f4e42f90576d1676c381314f4 +R eadc6c87ec15f9db6747eb42f404a18d U mistachkin -Z b6a365cc856116cf33aff81d6af1be2b +Z 9bc32025e8412eea1e17719cbb9188be diff --git a/manifest.uuid b/manifest.uuid index 3024e988e4..f7027c4945 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -335e91e599555d9f4e42f90576d1676c381314f4 \ No newline at end of file +541e9310a7b88e0b40c6530947803527f28e51de \ No newline at end of file diff --git a/tool/win/sqlite.vsix b/tool/win/sqlite.vsix index 9dd5c814085d0efb83f5a7e628d96a3bcf9d6123..4bdfda5c7df1cbd70227f33bb4b2200a7b77c25e 100644 GIT binary patch delta 879 zcmV-#1CacdfC8d`0EHcY$K~$? zZqZgNAvsLQo;}PGn64H^hb8&m9j+sVS^~qIuueer*{*eH3~ukRrqLcnTng0 zE@-sxRok{{_+h%sb-q%C%R{>4+GOfqr$fc}WJq$}Ii~PRARi&dRqFA((-s~>BZqM8 z7^F||?P;IvG-97+;yjIQ>0Zf@sUFZf-0GZcppl9HlsBBI{pMkRs&cs&EuXZpRi-+# zKbm@4Yih@}4AH2GMns*S^yoQOVHD{MK>mZi6=Js9dP&_u;%uvv;qFM-z-Y{_sc>b? zgY;eG!+u2x%yQSr5Z@TLKohm`!ex%WBHrm@a*)`^4NIMJI=lXqK!i*MFH>AcDV4gD z!hWJ(LJpEzzwZP#Ju9BO5&v6wyY2sKPwmS*Wf`}wLLiQ}&|5IyHuO66De`id$g+QJ zQh8mDDGmWM_2N~My+5<)1mJWH5*`LYWd>Jj0s#O3c$3w6E`PQBG*vhNhmbg}(Pq7P z9RhF9CX@({w!X1vW-|S(jrsugNH)=D(WzEo3o6m>65U93a<0|%YCM`O(ZCA5j7Lf> z&^wcV-R3nUI(=B7fU1bqBifQ$uQrVptU-6|JyY2fvdn8V{}fT6H`|_B6T^+IDA9Wn zcM->J+eZG~bZ->#F8+bgW@$D!4OaX0%sGSLw?TY(A2xHclA{Igkp(!grN0ZZH5N>s zDv7fB3Sa&4kbO9qHqH@?UpGe3892Q3iN0ng{>wl)<6<9N7Sb>T;^~dhs-sYjgg)vn zu2;{OFS=_m{;e*8S84(Q004La000jFBme*a00000AOHXW z!+8JzQ$$NmVQy(=Wpi{ccx`M703ZMW0000102lx}NN5MabCZdGJOT2P#(zo%_X8TprRT*Ctc{1|3d(Plkl^&M}2o68Q)*u2PTRowo288gat0Pmn&rx2HYX zX~v#q;yjIQ>0V*TR1fF_ZgoyJ(8$Dp${Wtqe)BL(xm=5uPukdjDpQ@=yQZGjn%Z$K zqcduv5mBd}9zDk@jAA(hkpG}>g_y0jUZ^`roM?42(p?cYFdDOKDqI=!Abl6nuwPLE zv)nZ@x;Mrx&_qSN2$`d=h<9q39EA08!*WjX&aOWt5Ft~+%k0)sK&9>kAah)}HoSx! zgtUI&$#_;gcO(8Wx7>Ey|5cpYAM>=zxOEi*alD1zg88ME23J2g25~nrVtQW6C;O*HI z2=r*{^LS<^(~riecVLfX6MYgLYX!EX3hgG*t<*=ST1_v;qsbBttkBDNq|^evGsWk1 z(LkcJyA=wknpi!cyhn3NcFb+H}N-w zHqY|GXkRe6ThE*`2!0)ogJ4CS51TnzDbND%kOerfmA?sRDV9v0YKijs3Sa!;ka!Tx zTIYzxr>zlm27X@pL|-x!|7W0@ak&jHOKBMb@%Tz;)j_C4LJLhF*Q=-VXWjP}{}va9 zFHlPZ1e2|Q7_$z0$N~+TnEF7vb-vL`0ssJ?ljD6i28b0zHJodcAbvan=#yQ3Spg-J zw|-m!>ys3JJ|Cb7|3E-byI%VM003?Q000jFBme*a00000AOHXWzLRl(9tMO7N=)=_ Ula+rw0p^p^e@X`IdjJ3c0Jd9(Bme*a From 428c218c90cce7bbff210a19ee01ecdc01511076 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 6 Aug 2012 18:50:11 +0000 Subject: [PATCH 53/69] When reusing pages as part of creating a new index, allocate the leaves from each free-list trunk page in ascending order, instead of trying to maximize localization for each individual allocation. This increases the chance that pages will be written to disk in ascending order by a large CREATE INDEX statement, improving overall performance. FossilOrigin-Name: d045f8b2d44e388d8c4549ff02d4ca7eff4e2038 --- manifest | 27 ++++++++--------- manifest.uuid | 2 +- src/analyze.c | 2 +- src/btree.c | 17 +++++++++-- src/btree.h | 8 +++++- src/btreeInt.h | 1 + src/build.c | 6 ++-- src/sqliteInt.h | 2 ++ src/test_vfs.c | 3 +- src/vdbe.c | 7 ++++- test/index5.test | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 11 files changed, 125 insertions(+), 25 deletions(-) create mode 100644 test/index5.test diff --git a/manifest b/manifest index 7722412b09..34d8efeb55 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\ssorter-coalesce-writes\sbranch\swith\slatest\strunk\schanges. -D 2012-08-06T18:10:09.480 +C When\sreusing\spages\sas\spart\sof\screating\sa\snew\sindex,\sallocate\sthe\sleaves\sfrom\seach\sfree-list\strunk\spage\sin\sascending\sorder,\sinstead\sof\strying\sto\smaximize\slocalization\sfor\seach\sindividual\sallocation.\sThis\sincreases\sthe\schance\sthat\spages\swill\sbe\swritten\sto\sdisk\sin\sascending\sorder\sby\sa\slarge\sCREATE\sINDEX\sstatement,\simproving\soverall\sperformance. +D 2012-08-06T18:50:11.492 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -117,16 +117,16 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in ae6f59a76e862f5c561eb32a380228a02afc3cad F src/alter.c 149cc80d9257971b0bff34e58fb2263e01998289 -F src/analyze.c a4790912e504c8ddac273445e7aba39bbce50881 +F src/analyze.c 7553068d21e32a57fc33ab6b2393fc8c1ba41410 F src/attach.c 577bf5675b0c50495fc28549f2fcbdb1bac71143 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 5b31b24d6814b11de763debf342c8cd0a15a4910 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c f0b71054103cb77eb5e782088c16998ec4f06624 -F src/btree.h 48a013f8964f12d944d90e4700df47b72dd6d923 -F src/btreeInt.h 38a639c0542c29fe8331a221c4aed0cb8686249e -F src/build.c 47c4506afe4bcb4ed1f4b5357582d1cb3402f8ad +F src/btree.c 1d366468b6f30234d76bf1da43e038d6f3ba2c9c +F src/btree.h 4aee02e879211bfcfd3f551769578d2e940ab6c2 +F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 +F src/build.c 0f6b40ad6211dcaba6159d0f9a297f0704f22142 F src/callback.c 0cb4228cdcd827dcc5def98fb099edcc9142dbcd F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c 500d019da966631ad957c37705642be87524463b @@ -180,7 +180,7 @@ F src/select.c a365da6d7a6d7d8a10ad60ca71837ab5e9369466 F src/shell.c 076e1c90d594644f36027c8ecff9a392cf2d3a06 F src/sqlite.h.in 3e8035bc406b1571a5cc8ea46bcc831201676f1a F src/sqlite3ext.h 6904f4aadf976f95241311fbffb00823075d9477 -F src/sqliteInt.h ed41801550b0b8fb8217fcfd2e362118062b30c0 +F src/sqliteInt.h c8169801f8bbfdf5873cc6fa45cb5df720c04db4 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 35939e7e03abf1b7577ce311f48f682c40de3208 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -227,7 +227,7 @@ F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae F src/test_tclvar.c f4dc67d5f780707210d6bb0eb6016a431c04c7fa F src/test_thread.c e286f2173563f2a1747c24bcda6b9d030bf4f4e4 -F src/test_vfs.c da6d0d982b11756c94c1760196355d33d03ff745 +F src/test_vfs.c c6260ef238c1142c8f8bd402db02216afd182ae3 F src/test_vfstrace.c 6b28adb2a0e8ecd0f2e3581482e1f658b11b4067 F src/test_wholenumber.c 3d2b9ed1505c40ad5c5ca2ad16ae7a289d6cc251 F src/test_wsd.c 41cadfd9d97fe8e3e4e44f61a4a8ccd6f7ca8fe9 @@ -237,7 +237,7 @@ F src/update.c d3076782c887c10e882996550345da9c4c9f9dea F src/utf.c 890c67dcfcc7a74623c95baac7535aadfe265e84 F src/util.c 0af2e515dc0dabacec931bca39525f6c3f1c5455 F src/vacuum.c 587a52bb8833d7ac15af8916f25437e2575028bd -F src/vdbe.c f5ad3c06dc3fe647097065829c013f3f1b9eadca +F src/vdbe.c 75da79cdcd58481825a06f045bc2f5ea3966eeae F src/vdbe.h 18f581cac1f4339ec3299f3e0cc6e11aec654cdb F src/vdbeInt.h 986b6b11a13c517337355009e5438703ba5b0a40 F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 @@ -531,6 +531,7 @@ F test/index.test b5429732b3b983fa810e3ac867d7ca85dae35097 F test/index2.test ee83c6b5e3173a3d7137140d945d9a5d4fdfb9d6 F test/index3.test 423a25c789fc8cc51aaf2a4370bbdde2d9e9eed7 F test/index4.test 1e299862024012e0165531cce251572f7f084d15 +F test/index5.test edc8c64ca78bee140c21ce3836820fadf47906bb F test/indexedby.test be501e381b82b2f8ab406309ba7aac46e221f4ad F test/indexfault.test 31d4ab9a7d2f6e9616933eb079722362a883eb1d F test/init.test 15c823093fdabbf7b531fe22cf037134d09587a7 @@ -1008,7 +1009,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P f4b3fded231231ef15bde98d2a996b4e16415d4c 541e9310a7b88e0b40c6530947803527f28e51de -R 29178e6d938c0a18dd53fdfdd0d9db73 +P 214f8cda1727e0eee51605be487d4cf4f2dfb6db +R 3158683ecf6a85f9d8794482d2318bc6 U dan -Z ebf9b1cca66bb54b576393e824c02bfc +Z 52fb98b324ddd516442d0480eabbc4d5 diff --git a/manifest.uuid b/manifest.uuid index 5a544c351b..c85d23ae1e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -214f8cda1727e0eee51605be487d4cf4f2dfb6db \ No newline at end of file +d045f8b2d44e388d8c4549ff02d4ca7eff4e2038 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 810ed54d85..632fdc1ac1 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -176,7 +176,7 @@ static void openStatTable( "CREATE TABLE %Q.%s(%s)", pDb->zName, zTab, aTable[i].zCols ); aRoot[i] = pParse->regRoot; - aCreateTbl[i] = 1; + aCreateTbl[i] = OPFLAG_P2ISREG; }else{ /* The table already exists. If zWhere is not NULL, delete all entries ** associated with the table zWhere. If zWhere is NULL, delete the diff --git a/src/btree.c b/src/btree.c index c16eca5f64..7f1fd7e148 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5926,7 +5926,8 @@ static int balance_nonroot( MemPage *pParent, /* Parent page of siblings being balanced */ int iParentIdx, /* Index of "the page" in pParent */ u8 *aOvflSpace, /* page-size bytes of space for parent ovfl */ - int isRoot /* True if pParent is a root-page */ + int isRoot, /* True if pParent is a root-page */ + int bBulk /* True if this call is part of a bulk load */ ){ BtShared *pBt; /* The whole database */ int nCell = 0; /* Number of cells in apCell[] */ @@ -6257,7 +6258,7 @@ static int balance_nonroot( if( rc ) goto balance_cleanup; }else{ assert( i>0 ); - rc = allocateBtreePage(pBt, &pNew, &pgno, pgno, 0); + rc = allocateBtreePage(pBt, &pNew, &pgno, (bBulk ? 1 : pgno), 0); if( rc ) goto balance_cleanup; apNew[i] = pNew; nNew++; @@ -6707,7 +6708,7 @@ static int balance(BtCursor *pCur){ ** pSpace buffer passed to the latter call to balance_nonroot(). */ u8 *pSpace = sqlite3PageMalloc(pCur->pBt->pageSize); - rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1); + rc = balance_nonroot(pParent, iIdx, pSpace, iPage==1, pCur->hints); if( pFree ){ /* If pFree is not NULL, it points to the pSpace buffer used ** by a previous call to balance_nonroot(). Its contents are @@ -8294,3 +8295,13 @@ int sqlite3BtreeSetVersion(Btree *pBtree, int iVersion){ pBt->btsFlags &= ~BTS_NO_WAL; return rc; } + +/* +** set the mask of hint flags for cursor pCsr. Currently the only valid +** values are 0 and BTREE_BULKLOAD. +*/ +void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){ + assert( mask==BTREE_BULKLOAD || mask==0 ); + pCsr->hints = mask; +} + diff --git a/src/btree.h b/src/btree.h index 9832001b7f..95897d5662 100644 --- a/src/btree.h +++ b/src/btree.h @@ -135,6 +135,12 @@ int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value); #define BTREE_USER_VERSION 6 #define BTREE_INCR_VACUUM 7 +/* +** Values that may be OR'd together to form the second argument of an +** sqlite3BtreeCursorHints() call. +*/ +#define BTREE_BULKLOAD 0x00000001 + int sqlite3BtreeCursor( Btree*, /* BTree containing table to open */ int iTable, /* Index of root page */ @@ -178,8 +184,8 @@ struct Pager *sqlite3BtreePager(Btree*); int sqlite3BtreePutData(BtCursor*, u32 offset, u32 amt, void*); void sqlite3BtreeCacheOverflow(BtCursor *); void sqlite3BtreeClearCursor(BtCursor *); - int sqlite3BtreeSetVersion(Btree *pBt, int iVersion); +void sqlite3BtreeCursorHints(BtCursor *, unsigned int mask); #ifndef NDEBUG int sqlite3BtreeCursorIsValid(BtCursor*); diff --git a/src/btreeInt.h b/src/btreeInt.h index 0d21497966..b157decec7 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -510,6 +510,7 @@ struct BtCursor { #ifndef SQLITE_OMIT_INCRBLOB u8 isIncrblobHandle; /* True if this cursor is an incr. io handle */ #endif + u8 hints; /* As configured by CursorSetHints() */ i16 iPage; /* Index of current page in apPage */ u16 aiIdx[BTCURSOR_MAX_DEPTH]; /* Current index in apPage[i] */ MemPage *apPage[BTCURSOR_MAX_DEPTH]; /* Pages from root to current page */ diff --git a/src/build.c b/src/build.c index 9f13b7b11c..776ffa4db3 100644 --- a/src/build.c +++ b/src/build.c @@ -1581,7 +1581,7 @@ void sqlite3EndTable( assert(pParse->nTab==1); sqlite3VdbeAddOp3(v, OP_OpenWrite, 1, pParse->regRoot, iDb); - sqlite3VdbeChangeP5(v, 1); + sqlite3VdbeChangeP5(v, OPFLAG_P2ISREG); pParse->nTab = 2; sqlite3SelectDestInit(&dest, SRT_Table, 1); sqlite3Select(pParse, pSelect, &dest); @@ -2397,9 +2397,7 @@ static void sqlite3RefillIndex(Parse *pParse, Index *pIndex, int memRootPage){ pKey = sqlite3IndexKeyinfo(pParse, pIndex); sqlite3VdbeAddOp4(v, OP_OpenWrite, iIdx, tnum, iDb, (char *)pKey, P4_KEYINFO_HANDOFF); - if( memRootPage>=0 ){ - sqlite3VdbeChangeP5(v, 1); - } + sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR|((memRootPage>=0)?OPFLAG_P2ISREG:0)); #ifndef SQLITE_OMIT_MERGE_SORT /* Open the sorter cursor if we are to use one. */ diff --git a/src/sqliteInt.h b/src/sqliteInt.h index c525ebd16f..b3cdb2363c 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -2317,6 +2317,8 @@ struct AuthContext { #define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */ #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */ #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */ +#define OPFLAG_BULKCSR 0x01 /* OP_Open** used to open bulk cursor */ +#define OPFLAG_P2ISREG 0x02 /* P2 to OP_Open** is a register number */ /* * Each trigger present in the database schema is stored as an instance of diff --git a/src/test_vfs.c b/src/test_vfs.c index fd2aa9fb07..93c556b56e 100644 --- a/src/test_vfs.c +++ b/src/test_vfs.c @@ -361,7 +361,8 @@ static int tvfsWrite( if( p->pScript && p->mask&TESTVFS_WRITE_MASK ){ tvfsExecTcl(p, "xWrite", - Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, 0 + Tcl_NewStringObj(pFd->zFilename, -1), pFd->pShmId, + Tcl_NewWideIntObj(iOfst) ); tvfsResultCode(p, &rc); } diff --git a/src/vdbe.c b/src/vdbe.c index 19c0255b8f..12e7325143 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -3120,6 +3120,9 @@ case OP_OpenWrite: { VdbeCursor *pCur; Db *pDb; + assert( (pOp->p5&(OPFLAG_P2ISREG|OPFLAG_BULKCSR))==pOp->p5 ); + assert( pOp->opcode==OP_OpenWrite || pOp->p5==0 ); + if( p->expired ){ rc = SQLITE_ABORT; break; @@ -3143,7 +3146,7 @@ case OP_OpenWrite: { }else{ wrFlag = 0; } - if( pOp->p5 ){ + if( pOp->p5 & OPFLAG_P2ISREG ){ assert( p2>0 ); assert( p2<=p->nMem ); pIn2 = &aMem[p2]; @@ -3174,6 +3177,8 @@ case OP_OpenWrite: { pCur->isOrdered = 1; rc = sqlite3BtreeCursor(pX, p2, wrFlag, pKeyInfo, pCur->pCursor); pCur->pKeyInfo = pKeyInfo; + assert( OPFLAG_BULKCSR==BTREE_BULKLOAD ); + sqlite3BtreeCursorHints(pCur->pCursor, (pOp->p5 & OPFLAG_BULKCSR)); /* Since it performs no memory allocation or IO, the only value that ** sqlite3BtreeCursor() may return is SQLITE_OK. */ diff --git a/test/index5.test b/test/index5.test new file mode 100644 index 0000000000..c8e94b3985 --- /dev/null +++ b/test/index5.test @@ -0,0 +1,75 @@ +# 2012 August 6 +# +# 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. +# +#*********************************************************************** +# + + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix index5 + +do_test 1.1 { + execsql { + PRAGMA page_size = 1024; + CREATE TABLE t1(x); + BEGIN; + } + for {set i 0} {$i < 100000} {incr i} { + execsql { INSERT INTO t1 VALUES(randstr(100,100)) } + } + execsql COMMIT + execsql { + CREATE INDEX i1 ON t1(x); + DROP INDEX I1; + PRAGMA main.page_size; + } +} {1024} + +db close +testvfs tvfs +tvfs filter xWrite +tvfs script write_cb +proc write_cb {xCall file handle iOfst} { + if {[file tail $file]=="test.db"} { + lappend ::write_list [expr $iOfst/1024] + } + puts "$xCall $file $args" +} + +do_test 1.2 { + sqlite3 db test.db -vfs tvfs + set ::write_list [list] + execsql { CREATE INDEX i1 ON t1(x) } +} {} + +do_test 1.3 { + set nForward 0 + set nBackward 0 + set nNoncont 0 + set iPrev [lindex $::write_list 0] + for {set i 1} {$i < [llength $::write_list]} {incr i} { + set iNext [lindex $::write_list $i] + if {$iNext==($iPrev+1)} { + incr nForward + } elseif {$iNext==($iPrev-1)} { + incr nBackward + } else { + incr nNoncont + } + set iPrev $iNext + } + + expr {$nForward > $nBackward} +} {1} +db close +tvfs delete + +finish_test + From 243be2b0e11bab0da1cf198555d5f0efcbeaaddb Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 6 Aug 2012 19:12:17 +0000 Subject: [PATCH 54/69] Fix a crash that could follow an OOM condition. FossilOrigin-Name: 2e5741f774248abc678b50711c43e38ca30c9091 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbesort.c | 5 +++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 34d8efeb55..39fe08007e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sreusing\spages\sas\spart\sof\screating\sa\snew\sindex,\sallocate\sthe\sleaves\sfrom\seach\sfree-list\strunk\spage\sin\sascending\sorder,\sinstead\sof\strying\sto\smaximize\slocalization\sfor\seach\sindividual\sallocation.\sThis\sincreases\sthe\schance\sthat\spages\swill\sbe\swritten\sto\sdisk\sin\sascending\sorder\sby\sa\slarge\sCREATE\sINDEX\sstatement,\simproving\soverall\sperformance. -D 2012-08-06T18:50:11.492 +C Fix\sa\scrash\sthat\scould\sfollow\san\sOOM\scondition. +D 2012-08-06T19:12:17.500 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -244,7 +244,7 @@ F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 -F src/vdbesort.c ad3078561072cc3faaf8084b5d7d3cd6affb5f42 +F src/vdbesort.c 1de867bfa04a54c217bfe467f43206c801912921 F src/vdbetrace.c 8bd5da325fc90f28464335e4cc4ad1407fe30835 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b @@ -1009,7 +1009,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 214f8cda1727e0eee51605be487d4cf4f2dfb6db -R 3158683ecf6a85f9d8794482d2318bc6 +P d045f8b2d44e388d8c4549ff02d4ca7eff4e2038 +R 271a84ad323420f7636b49c9d4c7979c U dan -Z 52fb98b324ddd516442d0480eabbc4d5 +Z da2600161cd5536c31009989e6b616b4 diff --git a/manifest.uuid b/manifest.uuid index c85d23ae1e..5e7b941fbe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d045f8b2d44e388d8c4549ff02d4ca7eff4e2038 \ No newline at end of file +2e5741f774248abc678b50711c43e38ca30c9091 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 1fcf0ddd27..7433e3e08c 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -919,8 +919,9 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){ rc = vdbeSorterOpenTempFile(db, &pTemp2); } - rc = fileWriterInit(db, pTemp2, &writer, iWrite2); - + if( rc==SQLITE_OK ){ + rc = fileWriterInit(db, pTemp2, &writer, iWrite2); + } if( rc==SQLITE_OK ){ rc = fileWriterWriteVarint(&writer, nWrite); } From ab8c4cf3b85d49ec5fb9522a163eda4b80507462 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 6 Aug 2012 22:29:26 +0000 Subject: [PATCH 55/69] Modify VSIX package generation tool to put the PDB files in the Debug directory. FossilOrigin-Name: 9d0720833fd52b25e62aca9ab4cf1e234fd792aa --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/mkvsix.tcl | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 45bf47c50d..2d53fb160d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\sthe\ssorter-coalesce-writes\sbranch\sinto\sthe\strunk.\sThis\simproves\sCREATE\sINDEX\sperformance\son\ssome\splatforms. -D 2012-08-06T19:28:20.956 +C Modify\sVSIX\spackage\sgeneration\stool\sto\sput\sthe\sPDB\sfiles\sin\sthe\sDebug\sdirectory. +D 2012-08-06T22:29:26.747 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -984,7 +984,7 @@ F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl 589c7f44e990be1b8443cfe4808dce392b0327fa F tool/mksqlite3h.tcl 78013ad79a5e492e5f764f3c7a8ef834255061f8 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 -F tool/mkvsix.tcl 153187ce9f1911bc2d0caa7af9856d7b8b805e27 +F tool/mkvsix.tcl 19b2ab9ea16445953a76568a5bbe4cb864f92dfe F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1009,7 +1009,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 541e9310a7b88e0b40c6530947803527f28e51de 2e5741f774248abc678b50711c43e38ca30c9091 -R 9ea05a2580296dc700acf20c4ae23876 -U dan -Z ec36f3ad854c62e55cc3fc27576cdc7b +P e1e9cb08b011e67b767091e42225f22ec862fa64 +R e7789c6a450315035c3cc54a03a15b19 +U mistachkin +Z 84444372179c1835c9283e74796447ef diff --git a/manifest.uuid b/manifest.uuid index 5a53d65817..01045ed8f6 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1e9cb08b011e67b767091e42225f22ec862fa64 \ No newline at end of file +9d0720833fd52b25e62aca9ab4cf1e234fd792aa \ No newline at end of file diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index 506ab7334d..a7517786c5 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -273,7 +273,7 @@ if {![info exists fileNames(destination)]} then { if {![info exists no(symbols)]} then { lappend fileNames(destination) \ - [file join $stagingDirectory Redist CommonConfiguration \ + [file join $stagingDirectory Redist Debug \ sqlite3.pdb] } } From 809badc93aa6377b2ba3b2b24ce105a8b6f787d1 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 7 Aug 2012 13:55:41 +0000 Subject: [PATCH 56/69] Fix a bug in walthread.test causing intermittent failures. FossilOrigin-Name: a192a718d513002b58ad585fcb3d8b9b49b4b123 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/walthread.test | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2d53fb160d..b9b6913d70 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Modify\sVSIX\spackage\sgeneration\stool\sto\sput\sthe\sPDB\sfiles\sin\sthe\sDebug\sdirectory. -D 2012-08-06T22:29:26.747 +C Fix\sa\sbug\sin\swalthread.test\scausing\sintermittent\sfailures. +D 2012-08-07T13:55:41.483 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -949,7 +949,7 @@ F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 F test/walro.test f183c0003060a64793f9bfafef4c479418ed7fa8 F test/walshared.test 6dda2293880c300baf5d791c307f653094585761 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a -F test/walthread.test a2ed5270eb695284d4ad27d252517bdc3317ee2a +F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e F test/where.test 4c9f69987ed2aa0173fa930f2b41ab9879478cd8 F test/where2.test 43d4becaf5a5df854e6c21d624a1cb84c6904554 F test/where3.test 667e75642102c97a00bf9b23d3cb267db321d006 @@ -1009,7 +1009,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P e1e9cb08b011e67b767091e42225f22ec862fa64 -R e7789c6a450315035c3cc54a03a15b19 -U mistachkin -Z 84444372179c1835c9283e74796447ef +P 9d0720833fd52b25e62aca9ab4cf1e234fd792aa +R 949e37e42acb7f9147b680b8c86a82df +U dan +Z 621c379326eb2bebdae5065332685c50 diff --git a/manifest.uuid b/manifest.uuid index 01045ed8f6..31d968f67c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9d0720833fd52b25e62aca9ab4cf1e234fd792aa \ No newline at end of file +a192a718d513002b58ad585fcb3d8b9b49b4b123 \ No newline at end of file diff --git a/test/walthread.test b/test/walthread.test index cbd6371857..6249ce11af 100644 --- a/test/walthread.test +++ b/test/walthread.test @@ -277,8 +277,8 @@ do_thread_test2 walthread-1 -seconds $seconds(walthread-1) -init { proc write_transaction {} { db eval { BEGIN; - INSERT INTO t1 VALUES(randomblob(100)); - INSERT INTO t1 VALUES(randomblob(100)); + INSERT INTO t1 VALUES(randomblob(101 + $::E(pid))); + INSERT INTO t1 VALUES(randomblob(101 + $::E(pid))); INSERT INTO t1 SELECT md5sum(x) FROM t1; COMMIT; } From 81f0740e59f0af3ac75fa27029208d39ccd90b87 Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 7 Aug 2012 14:18:18 +0000 Subject: [PATCH 57/69] Do not run test script spellfix.test if SQLITE_OMIT_VIRTUAL_TABLE is defined. Fix walro.test so that it works if DEFAULT_AUTOVACUUM is defined. FossilOrigin-Name: 26428b459b45d0fa9fcad7eb5e58bd60b04a0f83 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/spellfix.test | 2 ++ test/walro.test | 2 ++ 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index b9b6913d70..9a30337452 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\swalthread.test\scausing\sintermittent\sfailures. -D 2012-08-07T13:55:41.483 +C Do\snot\srun\stest\sscript\sspellfix.test\sif\sSQLITE_OMIT_VIRTUAL_TABLE\sis\sdefined.\sFix\swalro.test\sso\sthat\sit\sworks\sif\sDEFAULT_AUTOVACUUM\sis\sdefined. +D 2012-08-07T14:18:18.405 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -717,7 +717,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/spellfix.test 936be6f7ba1c4d096adb280c68b32f4848af8d2e +F test/spellfix.test 5af977d1a1a9e3801ed4239ee4dea92d70a53d35 F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test 08e8185b3fd5b010c90d7ad82b9dd4ea1cbf14b0 F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 @@ -946,7 +946,7 @@ F test/walhook.test ed00a40ba7255da22d6b66433ab61fab16a63483 F test/walmode.test 4022fe03ae6e830583672caa101f046438a0473c F test/walnoshm.test 84ca10c544632a756467336b7c3b864d493ee496 F test/walpersist.test 8c6b7e3ec1ba91b5e4dc4e0921d6d3f87cd356a6 -F test/walro.test f183c0003060a64793f9bfafef4c479418ed7fa8 +F test/walro.test a31deb621033442a76c3a61e44929250d06f81b1 F test/walshared.test 6dda2293880c300baf5d791c307f653094585761 F test/walslow.test e7be6d9888f83aa5d3d3c7c08aa9b5c28b93609a F test/walthread.test de8dbaf6d9e41481c460ba31ca61e163d7348f8e @@ -1009,7 +1009,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 9d0720833fd52b25e62aca9ab4cf1e234fd792aa -R 949e37e42acb7f9147b680b8c86a82df +P a192a718d513002b58ad585fcb3d8b9b49b4b123 +R 3c99e2c9fab7d765db4c9bc2b2b98c3c U dan -Z 621c379326eb2bebdae5065332685c50 +Z c2d7ea3513555d2c297d13781c66bc21 diff --git a/manifest.uuid b/manifest.uuid index 31d968f67c..34bb15cac7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a192a718d513002b58ad585fcb3d8b9b49b4b123 \ No newline at end of file +26428b459b45d0fa9fcad7eb5e58bd60b04a0f83 \ No newline at end of file diff --git a/test/spellfix.test b/test/spellfix.test index 7459ca2cd6..14a4cd722e 100644 --- a/test/spellfix.test +++ b/test/spellfix.test @@ -14,6 +14,8 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl set testprefix spellfix +ifcapable !vtab { finish_test ; return } + register_spellfix_module db set vocab { diff --git a/test/walro.test b/test/walro.test index 81e3e62ee9..465ce838c2 100644 --- a/test/walro.test +++ b/test/walro.test @@ -56,6 +56,7 @@ do_multiclient_test tn { do_test 1.1.1 { code2 { sqlite3 db2 test.db } sql2 { + PRAGMA auto_vacuum = 0; PRAGMA journal_mode = WAL; CREATE TABLE t1(x, y); INSERT INTO t1 VALUES('a', 'b'); @@ -268,6 +269,7 @@ do_multiclient_test tn { tv filter {} code1 { sqlite3 db test.db } csql1 { + PRAGMA auto_vacuum = 0; PRAGMA journal_mode = WAL; BEGIN; CREATE TABLE t2(x, y); From 38d073040d57c8598ca2e5cc5fda2a1d8e9ab01e Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 7 Aug 2012 15:19:27 +0000 Subject: [PATCH 58/69] Fix a bug in hash.c introduced by [305b66672653]. FossilOrigin-Name: 17cb5e951e419b1221ae4595d20059d90a361a39 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/hash.c | 9 +++++++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 9a30337452..d1e82d468a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Do\snot\srun\stest\sscript\sspellfix.test\sif\sSQLITE_OMIT_VIRTUAL_TABLE\sis\sdefined.\sFix\swalro.test\sso\sthat\sit\sworks\sif\sDEFAULT_AUTOVACUUM\sis\sdefined. -D 2012-08-07T14:18:18.405 +C Fix\sa\sbug\sin\shash.c\sintroduced\sby\s[305b66672653]. +D 2012-08-07T15:19:27.578 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -137,7 +137,7 @@ F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 657212460bf5cfd3ae607d12ea62092844c227b5 F src/func.c 18dfedfb857e100b05755a1b12e88b389f957879 F src/global.c 4cfdca5cb0edd33c4d021baec4ede958cb2c793b -F src/hash.c 1f35276f9664dd150451b463805a952892227c73 +F src/hash.c a4031441741932da9e7a65bee2b36b5d0e81c073 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 F src/hwtime.h d32741c8f4df852c7d959236615444e2b1063b08 F src/insert.c 770ed633830fb49d73d90c3fdf20b703973e1e84 @@ -1009,7 +1009,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P a192a718d513002b58ad585fcb3d8b9b49b4b123 -R 3c99e2c9fab7d765db4c9bc2b2b98c3c +P 26428b459b45d0fa9fcad7eb5e58bd60b04a0f83 +R 91c2befabc2142729ab9b898a169b7b2 U dan -Z c2d7ea3513555d2c297d13781c66bc21 +Z 74786c71a4a2788ff8896e58e602bf71 diff --git a/manifest.uuid b/manifest.uuid index 34bb15cac7..3a22a25201 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -26428b459b45d0fa9fcad7eb5e58bd60b04a0f83 \ No newline at end of file +17cb5e951e419b1221ae4595d20059d90a361a39 \ No newline at end of file diff --git a/src/hash.c b/src/hash.c index 8d5a706564..d7625d3913 100644 --- a/src/hash.c +++ b/src/hash.c @@ -113,16 +113,21 @@ static int rehash(Hash *pH, unsigned int new_size){ /* The inability to allocates space for a larger hash table is ** a performance hit but it is not a fatal error. So mark the - ** allocation as a benign. + ** allocation as a benign. Use sqlite3Malloc()/memset(0) instead of + ** sqlite3MallocZero() to make the allocation, as sqlite3MallocZero() + ** only zeroes the requested number of bytes whereas this module will + ** use the actual amount of space allocated for the hash table (which + ** may be larger than the requested amount). */ sqlite3BeginBenignMalloc(); - new_ht = (struct _ht *)sqlite3MallocZero( new_size*sizeof(struct _ht) ); + new_ht = (struct _ht *)sqlite3Malloc( new_size*sizeof(struct _ht) ); sqlite3EndBenignMalloc(); if( new_ht==0 ) return 0; sqlite3_free(pH->ht); pH->ht = new_ht; pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht); + memset(new_ht, 0, new_size*sizeof(struct _ht)); for(elem=pH->first, pH->first=0; elem; elem = next_elem){ unsigned int h = strHash(elem->pKey, elem->nKey) % new_size; next_elem = elem->next; From 2aba5d96f431f5a8b43c40a0c8bc4a67cf5b702f Mon Sep 17 00:00:00 2001 From: dan Date: Tue, 7 Aug 2012 17:41:50 +0000 Subject: [PATCH 59/69] Add extra tests for secure-delete mode. FossilOrigin-Name: e380cd3ce34d509e184081ecccf27fda11ce1da7 --- manifest | 13 +++--- manifest.uuid | 2 +- test/permutations.test | 2 +- test/securedel2.test | 94 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 test/securedel2.test diff --git a/manifest b/manifest index d1e82d468a..46bc3095bf 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sa\sbug\sin\shash.c\sintroduced\sby\s[305b66672653]. -D 2012-08-07T15:19:27.578 +C Add\sextra\stests\sfor\ssecure-delete\smode. +D 2012-08-07T17:41:50.005 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -642,7 +642,7 @@ F test/pageropt.test 9191867ed19a2b3db6c42d1b36b6fbc657cd1ab0 F test/pagesize.test 1dd51367e752e742f58e861e65ed7390603827a0 F test/pcache.test 065aa286e722ab24f2e51792c1f093bf60656b16 F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 -F test/permutations.test 2af90e00cea9e7e7c0a6b16d34727cb5bbae14dd +F test/permutations.test d12fabf8abdb71b79eb6c3ef3be5e875fe790071 F test/pragma.test a62f73293b0f0d79b0c87f8dd32d46fe53b0bd17 F test/pragma2.test 3a55f82b954242c642f8342b17dffc8b47472947 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 @@ -676,6 +676,7 @@ F test/schema3.test 1bc1008e1f8cb5654b248c55f27249366eb7ed38 F test/schema4.test e6a66e20cc69f0e306667c08be7fda3d11707dc5 F test/schema5.test 0103e4c0313b3725b5ae5600bdca53006ab53db3 F test/securedel.test 87a2561151af1f1e349071a89fdd77059f50113c +F test/securedel2.test 8e92bfb6559744f31e18d5c88a7076ae1deea0a8 F test/select1.test deba017eed9daa5af33de868676c997e7eebb931 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 @@ -1009,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 26428b459b45d0fa9fcad7eb5e58bd60b04a0f83 -R 91c2befabc2142729ab9b898a169b7b2 +P 17cb5e951e419b1221ae4595d20059d90a361a39 +R 2919015ca9831fb481e06469c7639f64 U dan -Z 74786c71a4a2788ff8896e58e602bf71 +Z af24cb62793571f094423bbb394787f8 diff --git a/manifest.uuid b/manifest.uuid index 3a22a25201..a2792cb79e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -17cb5e951e419b1221ae4595d20059d90a361a39 \ No newline at end of file +e380cd3ce34d509e184081ecccf27fda11ce1da7 \ No newline at end of file diff --git a/test/permutations.test b/test/permutations.test index 4370d8691d..c41c447a53 100644 --- a/test/permutations.test +++ b/test/permutations.test @@ -111,7 +111,7 @@ set allquicktests [test_set $alltests -exclude { thread003.test thread004.test thread005.test trans2.test vacuum3.test incrvacuum_ioerr.test autovacuum_crash.test btree8.test shared_err.test vtab_err.test walslow.test walcrash.test walcrash3.test - walthread.test rtree3.test indexfault.test + walthread.test rtree3.test indexfault.test securedel2.test }] if {[info exists ::env(QUICKTEST_INCLUDE)]} { set allquicktests [concat $allquicktests $::env(QUICKTEST_INCLUDE)] diff --git a/test/securedel2.test b/test/securedel2.test new file mode 100644 index 0000000000..7183f17cff --- /dev/null +++ b/test/securedel2.test @@ -0,0 +1,94 @@ +# 2012 August 7 +# +# 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 for the secure_delete pragma. +# + +set testdir [file dirname $argv0] +source $testdir/tester.tcl +set ::testprefix securedel2 + +# Generate 1000 pseudo-random 64-bit blobs. +# +for {set i 1} {$i <= 1000} {incr i} { + set aBlob($i) [string range [db one {SELECT quote(randomblob(8))}] 2 end-1] +} + +proc detect_blob_prepare {zFile} { + set nByte [file size $zFile] + set ::detect_blob_data [hexio_read $zFile 0 $nByte] +} + +proc detect_blob {zFile iBlob} { + if {$zFile != ""} { detect_blob_prepare $zFile } + string match "*$::aBlob($iBlob)*" $::detect_blob_data +} + +do_test 1.1 { + execsql { PRAGMA secure_delete = 1 } + execsql { CREATE TABLE t1(x, y) } + for {set i 1} {$i <= 1000} {incr i} { + set x "X'[string repeat $aBlob($i) 1]'" + set y "X'[string repeat $aBlob($i) 500]'" + execsql "INSERT INTO t1 VALUES($x, $y)" + } +} {} + +do_test 1.2 { detect_blob test.db 1 } {1} + +forcecopy test.db test.db.bak +do_execsql_test 1.3.1 { PRAGMA secure_delete = 0 } {0} +do_execsql_test 1.3.2 { DELETE FROM t1 WHERE rowid = 1 } +do_test 1.3.3 { detect_blob test.db 1 } {1} + +db close +forcecopy test.db.bak test.db +sqlite3 db test.db +do_execsql_test 1.4.1 { PRAGMA secure_delete = 1 } {1} +do_execsql_test 1.4.2 { DELETE FROM t1 WHERE rowid = 1 } +do_test 1.4.3 { detect_blob test.db 1 } {0} + +do_execsql_test 1.5.1 { DELETE FROM t1 WHERE rowid>850 } {} +do_test 1.5.2 { + set n 0 + detect_blob_prepare test.db + for {set i 851} {$i <= 1000} {incr i 5} { + incr n [detect_blob {} $i] + } + set n +} {0} + +db close +sqlite3 db test.db +do_test 1.6.1 { + execsql { + PRAGMA cache_size = 200; + PRAGMA secure_delete = 1; + CREATE TABLE t2(x); + SELECT * FROM t1; + } + for {set i 100} {$i < 5000} {incr i} { + execsql { INSERT INTO t2 VALUES(randomblob($i)) } + } + execsql { DELETE FROM t1 } +} {} + +do_test 1.6.2 { + set n 0 + detect_blob_prepare test.db + for {set i 2} {$i <= 850} {incr i 5} { + incr n [detect_blob {} $i] + } + set n +} {0} + +finish_test + From 07f547923ec911eaa3890db70f31d146b6b2053b Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 7 Aug 2012 22:53:01 +0000 Subject: [PATCH 60/69] Simplifications to the sorter to support full-coverage testing. FossilOrigin-Name: de804f4c90f02ca98991da185ed5e28bdd319e92 --- manifest | 14 +++---- manifest.uuid | 2 +- src/vdbesort.c | 104 +++++++++++++++++++------------------------------ 3 files changed, 49 insertions(+), 71 deletions(-) diff --git a/manifest b/manifest index 46bc3095bf..792599b37a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sextra\stests\sfor\ssecure-delete\smode. -D 2012-08-07T17:41:50.005 +C Simplifications\sto\sthe\ssorter\sto\ssupport\sfull-coverage\stesting. +D 2012-08-07T22:53:01.615 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -244,7 +244,7 @@ F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 -F src/vdbesort.c 4897215f0a0c4e731aa5ac5fc0317b62a4919e79 +F src/vdbesort.c bd5ce83f9314bfb632c8c653e9e81db31928a753 F src/vdbetrace.c 8bd5da325fc90f28464335e4cc4ad1407fe30835 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 17cb5e951e419b1221ae4595d20059d90a361a39 -R 2919015ca9831fb481e06469c7639f64 -U dan -Z af24cb62793571f094423bbb394787f8 +P e380cd3ce34d509e184081ecccf27fda11ce1da7 +R 01110266752aaa08ec8ada6a46e26710 +U drh +Z df7269861f33304988982e4a40d635e7 diff --git a/manifest.uuid b/manifest.uuid index a2792cb79e..487875b94f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e380cd3ce34d509e184081ecccf27fda11ce1da7 \ No newline at end of file +de804f4c90f02ca98991da185ed5e28bdd319e92 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 6ec30954aa..63288cfa6b 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -125,11 +125,13 @@ struct VdbeSorterIter { }; /* -** An instance of this structure is used to separate the stream of records +** An instance of this structure is used to organize the stream of records ** being written to files by the merge-sort code into aligned, page-sized -** blocks. +** blocks. Doing all I/O in aligned page-sized blocks helps I/O to go +** faster on many operating systems. */ struct FileWriter { + int eFWErr; /* Non-zero if in an error state */ u8 *aBuffer; /* Pointer to write buffer */ int nBuffer; /* Size of write buffer in bytes */ int iBufStart; /* First byte of buffer to write */ @@ -264,15 +266,13 @@ static int vdbeSorterIterVarint(sqlite3 *db, VdbeSorterIter *p, u64 *pnOut){ if( iBuf && (p->nBuffer-iBuf)>=9 ){ p->iReadOff += sqlite3GetVarint(&p->aBuffer[iBuf], pnOut); }else{ - u8 aVarint[9]; - int i; - for(i=0; iaBuffer = (u8 *)sqlite3DbMallocRaw(db, nBuf); - if( !p->aBuffer ) return SQLITE_NOMEM; - - p->iBufEnd = p->iBufStart = (iStart % nBuf); - p->iWriteOff = iStart - p->iBufStart; - p->nBuffer = nBuf; - p->pFile = pFile; - return SQLITE_OK; + if( !p->aBuffer ){ + p->eFWErr = SQLITE_NOMEM; + }else{ + p->iBufEnd = p->iBufStart = (iStart % nBuf); + p->iWriteOff = iStart - p->iBufStart; + p->nBuffer = nBuf; + p->pFile = pFile; + } } /* ** Write nData bytes of data to the file-write object. Return SQLITE_OK ** if successful, or an SQLite error code if an error occurs. */ -static int fileWriterWrite(FileWriter *p, u8 *pData, int nData){ +static void fileWriterWrite(FileWriter *p, u8 *pData, int nData){ int nRem = nData; - while( nRem>0 ){ + while( nRem>0 && p->eFWErr==0 ){ int nCopy = nRem; if( nCopy>(p->nBuffer - p->iBufEnd) ){ nCopy = p->nBuffer - p->iBufEnd; @@ -648,11 +649,10 @@ static int fileWriterWrite(FileWriter *p, u8 *pData, int nData){ memcpy(&p->aBuffer[p->iBufEnd], &pData[nData-nRem], nCopy); p->iBufEnd += nCopy; if( p->iBufEnd==p->nBuffer ){ - int rc = sqlite3OsWrite(p->pFile, + p->eFWErr = sqlite3OsWrite(p->pFile, &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, p->iWriteOff + p->iBufStart ); - if( rc!=SQLITE_OK ) return rc; p->iBufStart = p->iBufEnd = 0; p->iWriteOff += p->nBuffer; } @@ -660,8 +660,6 @@ static int fileWriterWrite(FileWriter *p, u8 *pData, int nData){ nRem -= nCopy; } - - return SQLITE_OK; } /* @@ -674,15 +672,16 @@ static int fileWriterWrite(FileWriter *p, u8 *pData, int nData){ ** last byte written to the file. */ static int fileWriterFinish(sqlite3 *db, FileWriter *p, i64 *piEof){ - int rc = SQLITE_OK; - if( p->aBuffer && p->iBufEnd>p->iBufStart ){ - rc = sqlite3OsWrite(p->pFile, + int rc; + if( p->eFWErr==0 && ALWAYS(p->aBuffer) && p->iBufEnd>p->iBufStart ){ + p->eFWErr = sqlite3OsWrite(p->pFile, &p->aBuffer[p->iBufStart], p->iBufEnd - p->iBufStart, p->iWriteOff + p->iBufStart ); } *piEof = (p->iWriteOff + p->iBufEnd); sqlite3DbFree(db, p->aBuffer); + rc = p->eFWErr; memset(p, 0, sizeof(FileWriter)); return rc; } @@ -691,11 +690,11 @@ static int fileWriterFinish(sqlite3 *db, FileWriter *p, i64 *piEof){ ** Write value iVal encoded as a varint to the file-write object. Return ** SQLITE_OK if successful, or an SQLite error code if an error occurs. */ -static int fileWriterWriteVarint(FileWriter *p, u64 iVal){ +static void fileWriterWriteVarint(FileWriter *p, u64 iVal){ int nByte; u8 aByte[10]; nByte = sqlite3PutVarint(aByte, iVal); - return fileWriterWrite(p, aByte, nByte); + fileWriterWrite(p, aByte, nByte); } /* @@ -713,7 +712,6 @@ static int fileWriterWriteVarint(FileWriter *p, u64 iVal){ */ static int vdbeSorterListToPMA(sqlite3 *db, const VdbeCursor *pCsr){ int rc = SQLITE_OK; /* Return code */ - int rc2; /* fileWriterFinish return code */ VdbeSorter *pSorter = pCsr->pSorter; FileWriter writer; @@ -734,33 +732,23 @@ static int vdbeSorterListToPMA(sqlite3 *db, const VdbeCursor *pCsr){ assert( pSorter->nPMA==0 ); } - if( rc==SQLITE_OK ){ - rc = fileWriterInit(db, pSorter->pTemp1, &writer, pSorter->iWriteOff); - } - if( rc==SQLITE_OK ){ SorterRecord *p; SorterRecord *pNext = 0; - + fileWriterInit(db, pSorter->pTemp1, &writer, pSorter->iWriteOff); pSorter->nPMA++; - rc = fileWriterWriteVarint(&writer, pSorter->nInMemory); - for(p=pSorter->pRecord; rc==SQLITE_OK && p; p=pNext){ + fileWriterWriteVarint(&writer, pSorter->nInMemory); + for(p=pSorter->pRecord; p; p=pNext){ pNext = p->pNext; - rc = fileWriterWriteVarint(&writer, p->nVal); - if( rc==SQLITE_OK ){ - rc = fileWriterWrite(&writer, p->pVal, p->nVal); - } - + fileWriterWriteVarint(&writer, p->nVal); + fileWriterWrite(&writer, p->pVal, p->nVal); sqlite3DbFree(db, p); } - pSorter->pRecord = p; + rc = fileWriterFinish(db, &writer, &pSorter->iWriteOff); } - rc2 = fileWriterFinish(db, &writer, &pSorter->iWriteOff); - if( rc==SQLITE_OK ) rc = rc2; - return rc; } @@ -920,31 +908,21 @@ int sqlite3VdbeSorterRewind(sqlite3 *db, const VdbeCursor *pCsr, int *pbEof){ rc = vdbeSorterOpenTempFile(db, &pTemp2); } - if( rc==SQLITE_OK ){ - rc = fileWriterInit(db, pTemp2, &writer, iWrite2); - } - if( rc==SQLITE_OK ){ - rc = fileWriterWriteVarint(&writer, nWrite); - } - if( rc==SQLITE_OK ){ int bEof = 0; + fileWriterInit(db, pTemp2, &writer, iWrite2); + fileWriterWriteVarint(&writer, nWrite); while( rc==SQLITE_OK && bEof==0 ){ VdbeSorterIter *pIter = &pSorter->aIter[ pSorter->aTree[1] ]; assert( pIter->pFile ); - rc = fileWriterWriteVarint(&writer, pIter->nKey); - if( rc==SQLITE_OK ){ - rc = fileWriterWrite(&writer, pIter->aKey, pIter->nKey); - } - if( rc==SQLITE_OK ){ - rc = sqlite3VdbeSorterNext(db, pCsr, &bEof); - } + fileWriterWriteVarint(&writer, pIter->nKey); + fileWriterWrite(&writer, pIter->aKey, pIter->nKey); + rc = sqlite3VdbeSorterNext(db, pCsr, &bEof); } + rc2 = fileWriterFinish(db, &writer, &iWrite2); + if( rc==SQLITE_OK ) rc = rc2; } - - rc2 = fileWriterFinish(db, &writer, &iWrite2); - if( rc==SQLITE_OK ) rc = rc2; } if( pSorter->nPMA<=SORTER_MAX_MERGE_COUNT ){ From acf239b589f783dff3cd5d1f74a42361bef79366 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 8 Aug 2012 10:14:10 +0000 Subject: [PATCH 61/69] Change to securedel2.test so that it works even if SQLITE_DEFAULT_AUTOVACUUM=1 is defined. FossilOrigin-Name: 1e6f5ea48174e3cb59e6d9fe1293fd87bd9c78f5 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/securedel2.test | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 792599b37a..aa43477458 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Simplifications\sto\sthe\ssorter\sto\ssupport\sfull-coverage\stesting. -D 2012-08-07T22:53:01.615 +C Change\sto\ssecuredel2.test\sso\sthat\sit\sworks\seven\sif\sSQLITE_DEFAULT_AUTOVACUUM=1\sis\sdefined. +D 2012-08-08T10:14:10.004 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -676,7 +676,7 @@ F test/schema3.test 1bc1008e1f8cb5654b248c55f27249366eb7ed38 F test/schema4.test e6a66e20cc69f0e306667c08be7fda3d11707dc5 F test/schema5.test 0103e4c0313b3725b5ae5600bdca53006ab53db3 F test/securedel.test 87a2561151af1f1e349071a89fdd77059f50113c -F test/securedel2.test 8e92bfb6559744f31e18d5c88a7076ae1deea0a8 +F test/securedel2.test f13a916155f790a6b9de835049641b14ef312986 F test/select1.test deba017eed9daa5af33de868676c997e7eebb931 F test/select2.test 352480e0e9c66eda9c3044e412abdf5be0215b56 F test/select3.test 2ce595f8fb8e2ac10071d3b4e424cadd4634a054 @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P e380cd3ce34d509e184081ecccf27fda11ce1da7 -R 01110266752aaa08ec8ada6a46e26710 -U drh -Z df7269861f33304988982e4a40d635e7 +P de804f4c90f02ca98991da185ed5e28bdd319e92 +R cd5e84682b160ed0910b107d04268a4b +U dan +Z f570770213d0b1556a06e6e2542482b4 diff --git a/manifest.uuid b/manifest.uuid index 487875b94f..ea7fce0f85 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -de804f4c90f02ca98991da185ed5e28bdd319e92 \ No newline at end of file +1e6f5ea48174e3cb59e6d9fe1293fd87bd9c78f5 \ No newline at end of file diff --git a/test/securedel2.test b/test/securedel2.test index 7183f17cff..b20f4f9212 100644 --- a/test/securedel2.test +++ b/test/securedel2.test @@ -34,6 +34,7 @@ proc detect_blob {zFile iBlob} { do_test 1.1 { execsql { PRAGMA secure_delete = 1 } + execsql { PRAGMA auto_vacuum = 0 } execsql { CREATE TABLE t1(x, y) } for {set i 1} {$i <= 1000} {incr i} { set x "X'[string repeat $aBlob($i) 1]'" From f64cc4996227e98e071fb422dfa92b33a5939ed0 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 8 Aug 2012 11:55:15 +0000 Subject: [PATCH 62/69] When building a b-tree as part of a CREATE INDEX or REINDEX statement, attempt to pack keys into pages as tightly as possible. FossilOrigin-Name: efea62b96c6a242c8ac2bdad70e50c87aee5e871 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index aa43477458..307d5ac4b0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Change\sto\ssecuredel2.test\sso\sthat\sit\sworks\seven\sif\sSQLITE_DEFAULT_AUTOVACUUM=1\sis\sdefined. -D 2012-08-08T10:14:10.004 +C When\sbuilding\sa\sb-tree\sas\spart\sof\sa\sCREATE\sINDEX\sor\sREINDEX\sstatement,\sattempt\sto\spack\skeys\sinto\spages\sas\stightly\sas\spossible. +D 2012-08-08T11:55:15.269 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -123,7 +123,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 5b31b24d6814b11de763debf342c8cd0a15a4910 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 1d366468b6f30234d76bf1da43e038d6f3ba2c9c +F src/btree.c 3a2dbf6f1b377790bed9cf1bb141f622d7b8f5eb F src/btree.h 4aee02e879211bfcfd3f551769578d2e940ab6c2 F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 F src/build.c 0f6b40ad6211dcaba6159d0f9a297f0704f22142 @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P de804f4c90f02ca98991da185ed5e28bdd319e92 -R cd5e84682b160ed0910b107d04268a4b +P 1e6f5ea48174e3cb59e6d9fe1293fd87bd9c78f5 +R 5b5871247315ef7c9328782279895eef U dan -Z f570770213d0b1556a06e6e2542482b4 +Z 279d19e350facc9c855651c896638780 diff --git a/manifest.uuid b/manifest.uuid index ea7fce0f85..a9618bf357 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1e6f5ea48174e3cb59e6d9fe1293fd87bd9c78f5 \ No newline at end of file +efea62b96c6a242c8ac2bdad70e50c87aee5e871 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 7f1fd7e148..3097dd692d 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6211,7 +6211,9 @@ static int balance_nonroot( d = r + 1 - leafData; assert( d Date: Wed, 8 Aug 2012 14:04:56 +0000 Subject: [PATCH 63/69] When populating an index b-tree as part of a CREATE INDEX or REINDEX statement, distribute cells between up to three siblings in balance_nonroot() instead of four. This produces identical database files, but is slightly faster. FossilOrigin-Name: b0d31e779ecf01c5a235443c05f488b177ac3045 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 9 +++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 307d5ac4b0..1c10c1b24f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\sbuilding\sa\sb-tree\sas\spart\sof\sa\sCREATE\sINDEX\sor\sREINDEX\sstatement,\sattempt\sto\spack\skeys\sinto\spages\sas\stightly\sas\spossible. -D 2012-08-08T11:55:15.269 +C When\spopulating\san\sindex\sb-tree\sas\spart\sof\sa\sCREATE\sINDEX\sor\sREINDEX\sstatement,\sdistribute\scells\sbetween\sup\sto\sthree\ssiblings\sin\sbalance_nonroot()\sinstead\sof\sfour.\sThis\sproduces\sidentical\sdatabase\sfiles,\sbut\sis\sslightly\sfaster. +D 2012-08-08T14:04:56.819 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -123,7 +123,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 5b31b24d6814b11de763debf342c8cd0a15a4910 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 3a2dbf6f1b377790bed9cf1bb141f622d7b8f5eb +F src/btree.c fe84910555e103013455e21571ac8bbed23c5c50 F src/btree.h 4aee02e879211bfcfd3f551769578d2e940ab6c2 F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 F src/build.c 0f6b40ad6211dcaba6159d0f9a297f0704f22142 @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 1e6f5ea48174e3cb59e6d9fe1293fd87bd9c78f5 -R 5b5871247315ef7c9328782279895eef +P efea62b96c6a242c8ac2bdad70e50c87aee5e871 +R 086d244755cccfb12a359b31e2d04664 U dan -Z 279d19e350facc9c855651c896638780 +Z 4b1b34d0b355564b0b946417aa1a7b3d diff --git a/manifest.uuid b/manifest.uuid index a9618bf357..8e784bd38e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -efea62b96c6a242c8ac2bdad70e50c87aee5e871 \ No newline at end of file +b0d31e779ecf01c5a235443c05f488b177ac3045 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 3097dd692d..6b5dd683a5 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5991,18 +5991,19 @@ static int balance_nonroot( i = pParent->nOverflow + pParent->nCell; if( i<2 ){ nxDiv = 0; - nOld = i+1; }else{ - nOld = 3; + assert( bBulk==0 || bBulk==1 ); if( iParentIdx==0 ){ nxDiv = 0; }else if( iParentIdx==i ){ - nxDiv = i-2; + nxDiv = i-2+bBulk; }else{ + assert( bBulk==0 ); nxDiv = iParentIdx-1; } - i = 2; + i = 2-bBulk; } + nOld = i+1; if( (i+nxDiv-pParent->nOverflow)==pParent->nCell ){ pRight = &pParent->aData[pParent->hdrOffset+8]; }else{ From a0aa13b67764090b15e8555dd050df76e98715cf Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 13 Aug 2012 22:05:22 +0000 Subject: [PATCH 64/69] Refer to the WaitForSingleObjectEx and SetFilePointerEx Win32 functions only for platforms where they are going to be used. FossilOrigin-Name: 9888ce9294c09749f5c958f965f949561867fea0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 1c10c1b24f..029a64c6c1 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C When\spopulating\san\sindex\sb-tree\sas\spart\sof\sa\sCREATE\sINDEX\sor\sREINDEX\sstatement,\sdistribute\scells\sbetween\sup\sto\sthree\ssiblings\sin\sbalance_nonroot()\sinstead\sof\sfour.\sThis\sproduces\sidentical\sdatabase\sfiles,\sbut\sis\sslightly\sfaster. -D 2012-08-08T14:04:56.819 +C Refer\sto\sthe\sWaitForSingleObjectEx\sand\sSetFilePointerEx\sWin32\sfunctions\sonly\sfor\splatforms\swhere\sthey\sare\sgoing\sto\sbe\sused. +D 2012-08-13T22:05:22.296 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757 -F src/os_win.c e3d3d3e26b65a35d4293d753137a58510bd3299b +F src/os_win.c 5de2e293ce912be89edcd8b1f97d25a05201d705 F src/pager.c e381c118b77dc22021a1a59d3fec24815e91df78 F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P efea62b96c6a242c8ac2bdad70e50c87aee5e871 -R 086d244755cccfb12a359b31e2d04664 -U dan -Z 4b1b34d0b355564b0b946417aa1a7b3d +P b0d31e779ecf01c5a235443c05f488b177ac3045 +R e108fe40c60912ec60f26ef742628f98 +U mistachkin +Z a85518ddd930e1856fb03005c1a29498 diff --git a/manifest.uuid b/manifest.uuid index 8e784bd38e..daa011d39a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b0d31e779ecf01c5a235443c05f488b177ac3045 \ No newline at end of file +9888ce9294c09749f5c958f965f949561867fea0 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 8509e9272d..a533453197 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -702,7 +702,7 @@ static struct win_syscall { #define osWaitForSingleObject ((DWORD(WINAPI*)(HANDLE, \ DWORD))aSyscall[60].pCurrent) -#if !SQLITE_OS_WINCE +#if SQLITE_OS_WINRT { "WaitForSingleObjectEx", (SYSCALL)WaitForSingleObjectEx, 0 }, #else { "WaitForSingleObjectEx", (SYSCALL)0, 0 }, @@ -711,7 +711,7 @@ static struct win_syscall { #define osWaitForSingleObjectEx ((DWORD(WINAPI*)(HANDLE,DWORD, \ BOOL))aSyscall[61].pCurrent) -#if !SQLITE_OS_WINCE +#if SQLITE_OS_WINRT { "SetFilePointerEx", (SYSCALL)SetFilePointerEx, 0 }, #else { "SetFilePointerEx", (SYSCALL)0, 0 }, From 1700b1c65cc286ab292c3c44158da902eb273742 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 14 Aug 2012 01:45:12 +0000 Subject: [PATCH 65/69] Refer to the file mapping Win32 API functions only when absolutely necessary. FossilOrigin-Name: 1de2237d005fa1a1e1d034820d17daf64a860f81 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/os_win.c | 13 +++++++++---- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index 029a64c6c1..6206e360d2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Refer\sto\sthe\sWaitForSingleObjectEx\sand\sSetFilePointerEx\sWin32\sfunctions\sonly\sfor\splatforms\swhere\sthey\sare\sgoing\sto\sbe\sused. -D 2012-08-13T22:05:22.296 +C Refer\sto\sthe\sfile\smapping\sWin32\sAPI\sfunctions\sonly\swhen\sabsolutely\snecessary. +D 2012-08-14T01:45:12.276 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/os.c e1acdc09ff3ac2412945cca9766e2dcf4675f31c F src/os.h 027491c77d2404c0a678bb3fb06286f331eb9b57 F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c d7c96b5d140f550f07345870112fae5d7ef99757 -F src/os_win.c 5de2e293ce912be89edcd8b1f97d25a05201d705 +F src/os_win.c 370c6f3399e3cd9f14343fb7dc4b2bbe8619d3bf F src/pager.c e381c118b77dc22021a1a59d3fec24815e91df78 F src/pager.h 8b8c9bc065a3c66769df8724dfdf492ee1aab3c5 F src/parse.y f29df90bd3adc64b33114ab1de9fb7768fcf2099 @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P b0d31e779ecf01c5a235443c05f488b177ac3045 -R e108fe40c60912ec60f26ef742628f98 +P 9888ce9294c09749f5c958f965f949561867fea0 +R a98aa246c40b02fe38a0fee800dd8927 U mistachkin -Z a85518ddd930e1856fb03005c1a29498 +Z 9b5874d2d03bd5e6df37f953a18d9b36 diff --git a/manifest.uuid b/manifest.uuid index daa011d39a..0feb2de849 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -9888ce9294c09749f5c958f965f949561867fea0 \ No newline at end of file +1de2237d005fa1a1e1d034820d17daf64a860f81 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index a533453197..2cbd2cee54 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -288,7 +288,8 @@ static struct win_syscall { #define osCreateFileW ((HANDLE(WINAPI*)(LPCWSTR,DWORD,DWORD, \ LPSECURITY_ATTRIBUTES,DWORD,DWORD,HANDLE))aSyscall[5].pCurrent) -#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) +#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) && \ + !defined(SQLITE_OMIT_WAL)) { "CreateFileMappingW", (SYSCALL)CreateFileMappingW, 0 }, #else { "CreateFileMappingW", (SYSCALL)0, 0 }, @@ -600,7 +601,7 @@ static struct win_syscall { LPOVERLAPPED))aSyscall[45].pCurrent) #endif -#if !SQLITE_OS_WINRT +#if SQLITE_OS_WINCE || (!SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL)) { "MapViewOfFile", (SYSCALL)MapViewOfFile, 0 }, #else { "MapViewOfFile", (SYSCALL)0, 0 }, @@ -670,7 +671,11 @@ static struct win_syscall { #define osUnlockFileEx ((BOOL(WINAPI*)(HANDLE,DWORD,DWORD,DWORD, \ LPOVERLAPPED))aSyscall[55].pCurrent) +#if SQLITE_OS_WINCE || !defined(SQLITE_OMIT_WAL) { "UnmapViewOfFile", (SYSCALL)UnmapViewOfFile, 0 }, +#else + { "UnmapViewOfFile", (SYSCALL)0, 0 }, +#endif #define osUnmapViewOfFile ((BOOL(WINAPI*)(LPCVOID))aSyscall[56].pCurrent) @@ -729,7 +734,7 @@ static struct win_syscall { #define osGetFileInformationByHandleEx ((BOOL(WINAPI*)(HANDLE, \ FILE_INFO_BY_HANDLE_CLASS,LPVOID,DWORD))aSyscall[63].pCurrent) -#if SQLITE_OS_WINRT +#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL) { "MapViewOfFileFromApp", (SYSCALL)MapViewOfFileFromApp, 0 }, #else { "MapViewOfFileFromApp", (SYSCALL)0, 0 }, @@ -793,7 +798,7 @@ static struct win_syscall { #define osGetProcessHeap ((HANDLE(WINAPI*)(VOID))aSyscall[71].pCurrent) -#if SQLITE_OS_WINRT +#if SQLITE_OS_WINRT && !defined(SQLITE_OMIT_WAL) { "CreateFileMappingFromApp", (SYSCALL)CreateFileMappingFromApp, 0 }, #else { "CreateFileMappingFromApp", (SYSCALL)0, 0 }, From c16eb6934d8f457e7ce044fc804ed92de88e66ed Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 14 Aug 2012 17:29:27 +0000 Subject: [PATCH 66/69] Update the spellfix virtual table to the latest development code. FossilOrigin-Name: 6954fef006431d153de6e63e362b8d260ebeb1c6 --- manifest | 16 +- manifest.uuid | 2 +- src/test_spellfix.c | 746 ++++++++++++-------------------------------- test/spellfix.test | 7 +- 4 files changed, 204 insertions(+), 567 deletions(-) diff --git a/manifest b/manifest index 6206e360d2..42bcaa0a49 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Refer\sto\sthe\sfile\smapping\sWin32\sAPI\sfunctions\sonly\swhen\sabsolutely\snecessary. -D 2012-08-14T01:45:12.276 +C Update\sthe\sspellfix\svirtual\stable\sto\sthe\slatest\sdevelopment\scode. +D 2012-08-14T17:29:27.517 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -221,7 +221,7 @@ F src/test_quota.h 8761e463b25e75ebc078bd67d70e39b9c817a0cb F src/test_rtree.c aba603c949766c4193f1068b91c787f57274e0d9 F src/test_schema.c 8c06ef9ddb240c7a0fcd31bc221a6a2aade58bf0 F src/test_server.c 2f99eb2837dfa06a4aacf24af24c6affdf66a84f -F src/test_spellfix.c 5ed989693d4040f4d343316c338e25c5a6a1f05d +F src/test_spellfix.c 3a260d237fabbf5884389aa8c0e516b4e61ab98a F src/test_stat.c d1569c7a4839f13e80187e2c26b2ab4da2d03935 F src/test_superlock.c 2b97936ca127d13962c3605dbc9a4ef269c424cd F src/test_syscall.c a992d8c80ea91fbf21fb2dd570db40e77dd7e6ae @@ -718,7 +718,7 @@ F test/speed3.test d32043614c08c53eafdc80f33191d5bd9b920523 F test/speed4.test abc0ad3399dcf9703abed2fff8705e4f8e416715 F test/speed4p.explain 6b5f104ebeb34a038b2f714150f51d01143e59aa F test/speed4p.test 0e51908951677de5a969b723e03a27a1c45db38b -F test/spellfix.test 5af977d1a1a9e3801ed4239ee4dea92d70a53d35 +F test/spellfix.test 8bdb52dc612711660cfb64540b11830f21827983 F test/sqllimits1.test b1aae27cc98eceb845e7f7adf918561256e31298 F test/stat.test 08e8185b3fd5b010c90d7ad82b9dd4ea1cbf14b0 F test/stmt.test 25d64e3dbf9a3ce89558667d7f39d966fe2a71b9 @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 9888ce9294c09749f5c958f965f949561867fea0 -R a98aa246c40b02fe38a0fee800dd8927 -U mistachkin -Z 9b5874d2d03bd5e6df37f953a18d9b36 +P 1de2237d005fa1a1e1d034820d17daf64a860f81 +R c6a6a5e27cc06765fbb21bed044152b3 +U drh +Z f62627106b46abb8dea1d772e4525d54 diff --git a/manifest.uuid b/manifest.uuid index 0feb2de849..a2aa6fb25c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1de2237d005fa1a1e1d034820d17daf64a860f81 \ No newline at end of file +6954fef006431d153de6e63e362b8d260ebeb1c6 \ No newline at end of file diff --git a/src/test_spellfix.c b/src/test_spellfix.c index cc3531268b..92755cd1d6 100644 --- a/src/test_spellfix.c +++ b/src/test_spellfix.c @@ -10,276 +10,9 @@ ** ************************************************************************* ** -** This module implements a VIRTUAL TABLE that can be used to search -** a large vocabulary for close matches. For example, this virtual -** table can be used to suggest corrections to misspelled words. Or, -** it could be used with FTS4 to do full-text search using potentially -** misspelled words. -** -** Create an instance of the virtual table this way: -** -** CREATE VIRTUAL TABLE demo USING spellfix1; -** -** The "spellfix1" term is the name of this module. The "demo" is the -** name of the virtual table you will be creating. The table is initially -** empty. You have to populate it with your vocabulary. Suppose you -** have a list of words in a table named "big_vocabulary". Then do this: -** -** INSERT INTO demo(word) SELECT word FROM big_vocabulary; -** -** If you intend to use this virtual table in cooperation with an FTS4 -** table (for spelling correctly of search terms) then you can extract -** the vocabulary using an fts3aux table: -** -** INSERT INTO demo(word) SELECT term FROM search_aux WHERE col='*'; -** -** You can also provide the virtual table with a "rank" for each word. -** The "rank" is an estimate of how common the word is. Larger numbers -** mean the word is more common. If you omit the rank when populating -** the table, then a rank of 1 is assumed. But if you have rank -** information, you can supply it and the virtual table will show a -** slight preference for selecting more commonly used terms. To -** populate the rank from an fts4aux table "search_aux" do something -** like this: -** -** INSERT INTO demo(word,rank) -** SELECT term, documents FROM search_aux WHERE col='*'; -** -** To query the virtual table, include a MATCH operator in the WHERE -** clause. For example: -** -** SELECT word FROM demo WHERE word MATCH 'kennasaw'; -** -** Using a dataset of American place names (derived from -** http://geonames.usgs.gov/domestic/download_data.htm) the query above -** returns 20 results beginning with: -** -** kennesaw -** kenosha -** kenesaw -** kenaga -** keanak -** -** If you append the character '*' to the end of the pattern, then -** a prefix search is performed. For example: -** -** SELECT word FROM demo WHERE word MATCH 'kennes*'; -** -** Yields 20 results beginning with: -** -** kennesaw -** kennestone -** kenneson -** kenneys -** keanes -** keenes -** -** The virtual table actually has a unique rowid with five columns plus three -** extra hidden columns. The columns are as follows: -** -** rowid A unique integer number associated with each -** vocabulary item in the table. This can be used -** as a foreign key on other tables in the database. -** -** word The text of the word that matches the pattern. -** Both word and pattern can contains unicode characters -** and can be mixed case. -** -** rank This is the rank of the word, as specified in the -** original INSERT statement. -** -** distance This is an edit distance or Levensthein distance going -** from the pattern to the word. -** -** langid This is the language-id of the word. All queries are -** against a single language-id, which defaults to 0. -** For any given query this value is the same on all rows. -** -** score The score is a combination of rank and distance. The -** idea is that a lower score is better. The virtual table -** attempts to find words with the lowest score and -** by default (unless overridden by ORDER BY) returns -** results in order of increasing score. -** -** matchlen For prefix queries, the number of characters in the prefix -** of the returned value (word) that matched the query term. -** For non-prefix queries, the number of characters in the -** returned value. -** -** top (HIDDEN) For any query, this value is the same on all -** rows. It is an integer which is the maximum number of -** rows that will be output. The actually number of rows -** output might be less than this number, but it will never -** be greater. The default value for top is 20, but that -** can be changed for each query by including a term of -** the form "top=N" in the WHERE clause of the query. -** -** scope (HIDDEN) For any query, this value is the same on all -** rows. The scope is a measure of how widely the virtual -** table looks for matching words. Smaller values of -** scope cause a broader search. The scope is normally -** choosen automatically and is capped at 4. Applications -** can change the scope by including a term of the form -** "scope=N" in the WHERE clause of the query. Increasing -** the scope will make the query run faster, but will reduce -** the possible corrections. -** -** srchcnt (HIDDEN) For any query, this value is the same on all -** rows. This value is an integer which is the number of -** of words examined using the edit-distance algorithm to -** find the top matches that are ultimately displayed. This -** value is for diagnostic use only. -** -** soundslike (HIDDEN) When inserting vocabulary entries, this field -** can be set to an spelling that matches what the word -** sounds like. See the DEALING WITH UNUSUAL AND DIFFICULT -** SPELLINGS section below for details. -** -** When inserting into or updating the virtual table, only the rowid, word, -** rank, and langid may be changes. Any attempt to set or modify the values -** of distance, score, top, scope, or srchcnt is silently ignored. -** -** ALGORITHM -** -** A shadow table named "%_vocab" (where the % is replaced by the name of -** the virtual table; Ex: "demo_vocab" for the "demo" virtual table) is -** constructed with these columns: -** -** id The unique id (INTEGER PRIMARY KEY) -** -** rank The rank of word. -** -** langid The language id for this entry. -** -** word The original UTF8 text of the vocabulary word -** -** k1 The word transliterated into lower-case ASCII. -** There is a standard table of mappings from non-ASCII -** characters into ASCII. Examples: "æ" -> "ae", -** "þ" -> "th", "ß" -> "ss", "á" -> "a", ... The -** accessory function spellfix1_translit(X) will do -** the non-ASCII to ASCII mapping. The built-in lower(X) -** function will convert to lower-case. Thus: -** k1 = lower(spellfix1_translit(word)). -** -** k2 This field holds a phonetic code derived from k1. Letters -** that have similar sounds are mapped into the same symbol. -** For example, all vowels and vowel clusters become the -** single symbol "A". And the letters "p", "b", "f", and -** "v" all become "B". All nasal sounds are represented -** as "N". And so forth. The mapping is base on -** ideas found in Soundex, Metaphone, and other -** long-standing phonetic matching systems. This key can -** be generated by the function spellfix1_phonehash(X). -** Hence: k2 = spellfix1_phonehash(k1) -** -** There is also a function for computing the Wagner edit distance or the -** Levenshtein distance between a pattern and a word. This function -** is exposed as spellfix1_editdist(X,Y). The edit distance function -** returns the "cost" of converting X into Y. Some transformations -** cost more than others. Changing one vowel into a different vowel, -** for example is relatively cheap, as is doubling a constant, or -** omitting the second character of a double-constant. Other transformations -** or more expensive. The idea is that the edit distance function returns -** a low cost of words that are similar and a higher cost for words -** that are futher apart. In this implementation, the maximum cost -** of any single-character edit (delete, insert, or substitute) is 100, -** with lower costs for some edits (such as transforming vowels). -** -** The "score" for a comparison is the edit distance between the pattern -** and the word, adjusted down by the base-2 logorithm of the word rank. -** For example, a match with distance 100 but rank 1000 would have a -** score of 122 (= 100 - log2(1000) + 32) where as a match with distance -** 100 with a rank of 1 would have a score of 131 (100 - log2(1) + 32). -** (NB: The constant 32 is added to each score to keep it from going -** negative in case the edit distance is zero.) In this way, frequently -** used words get a slightly lower cost which tends to move them toward -** the top of the list of alternative spellings. -** -** A straightforward implementation of a spelling corrector would be -** to compare the search term against every word in the vocabulary -** and select the 20 with the lowest scores. However, there will -** typically be hundreds of thousands or millions of words in the -** vocabulary, and so this approach is not fast enough. -** -** Suppose the term that is being spell-corrected is X. To limit -** the search space, X is converted to a k2-like key using the -** equivalent of: -** -** key = spellfix1_phonehash(lower(spellfix1_translit(X))) -** -** This key is then limited to "scope" characters. The default scope -** value is 4, but an alternative scope can be specified using the -** "scope=N" term in the WHERE clause. After the key has been truncated, -** the edit distance is run against every term in the vocabulary that -** has a k2 value that begins with the abbreviated key. -** -** For example, suppose the input word is "Paskagula". The phonetic -** key is "BACACALA" which is then truncated to 4 characters "BACA". -** The edit distance is then run on the 4980 entries (out of -** 272,597 entries total) of the vocabulary whose k2 values begin with -** BACA, yielding "Pascagoula" as the best match. -** -** Only terms of the vocabulary with a matching langid are searched. -** Hence, the same table can contain entries from multiple languages -** and only the requested language will be used. The default langid -** is 0. -** -** DEALING WITH UNUSUAL AND DIFFICULT SPELLINGS -** -** The algorithm above works quite well for most cases, but there are -** exceptions. These exceptions can be dealt with by making additional -** entries in the virtual table using the "soundslike" column. -** -** For example, many words of Greek origin begin with letters "ps" where -** the "p" is silent. Ex: psalm, pseudonym, psoriasis, psyche. In -** another example, many Scottish surnames can be spelled with an -** initial "Mac" or "Mc". Thus, "MacKay" and "McKay" are both pronounced -** the same. -** -** Accommodation can be made for words that are not spelled as they -** sound by making additional entries into the virtual table for the -** same word, but adding an alternative spelling in the "soundslike" -** column. For example, the canonical entry for "psalm" would be this: -** -** INSERT INTO demo(word) VALUES('psalm'); -** -** To enhance the ability to correct the spelling of "salm" into -** "psalm", make an addition entry like this: -** -** INSERT INTO demo(word,soundslike) VALUES('psalm','salm'); -** -** It is ok to make multiple entries for the same word as long as -** each entry has a different soundslike value. Note that if no -** soundslike value is specified, the soundslike defaults to the word -** itself. -** -** Listed below are some cases where it might make sense to add additional -** soundslike entries. The specific entries will depend on the application -** and the target language. -** -** * Silent "p" in words beginning with "ps": psalm, psyche -** -** * Silent "p" in words beginning with "pn": pneumonia, pneumatic -** -** * Silent "p" in words beginning with "pt": pterodactyl, ptolemaic -** -** * Silent "d" in words beginning with "dj": djinn, Djikarta -** -** * Silent "k" in words beginning with "kn": knight, Knuthson -** -** * Silent "g" in words beginning with "gn": gnarly, gnome, gnat -** -** * "Mac" versus "Mc" beginning Scottish surnames -** -** * "Tch" sounds in Slavic words: Tchaikovsky vs. Chaykovsky -** -** * The letter "j" pronounced like "h" in Spanish: LaJolla -** -** * Words beginning with "wr" versus "r": write vs. rite -** -** * Miscellanous problem words such as "debt", "tsetse", -** "Nguyen", "Van Nuyes". +** This module implements the spellfix1 VIRTUAL TABLE that can be used +** to search a large vocabulary for close matches. See separate +** documentation files (spellfix1.wiki and editdist3.wiki) for details. */ #if SQLITE_CORE # include "sqliteInt.h" @@ -306,7 +39,7 @@ ** 8 'M' Nasals: M N ** 9 'W' Letter W at the beginning of a word ** 10 'Y' Letter Y at the beginning of a word. -** 11 '9' A digit: 0 1 2 3 4 5 6 7 8 9 +** 11 '9' Digits: 0 1 2 3 4 5 6 7 8 9 ** 12 ' ' White space ** 13 '?' Other. */ @@ -466,7 +199,6 @@ static unsigned char *phoneticHash(const unsigned char *zIn, int nIn){ } } } - if( zIn[0]=='k' && zIn[1]=='n' ){ zIn++, nIn--; } for(i=0; i=CCLASS_B && classFrom<=CCLASS_Y && classTo>=CCLASS_B && classTo<=CCLASS_Y ){ @@ -616,7 +348,7 @@ static int substituteCost(char cPrev, char cFrom, char cTo){ ** If zA does end in a '*', then it is the number of bytes in the prefix ** of zB that was deemed to match zA. */ -static int editdist1(const char *zA, const char *zB, int iLangId, int *pnMatch){ +static int editdist1(const char *zA, const char *zB, int *pnMatch){ int nA, nB; /* Number of characters in zA[] and zB[] */ int xA, xB; /* Loop counters for zA[] and zB[] */ char cA, cB; /* Current character of zA and zB */ @@ -645,10 +377,10 @@ static int editdist1(const char *zA, const char *zB, int iLangId, int *pnMatch){ /* Verify input strings and measure their lengths */ for(nA=0; zA[nA]; nA++){ - if( zA[nA]>127 ) return -2; + if( zA[nA]&0x80 ) return -2; } for(nB=0; zB[nB]; nB++){ - if( zB[nB]>127 ) return -2; + if( zB[nB]&0x80 ) return -2; } /* Special processing if either string is empty */ @@ -756,7 +488,9 @@ static int editdist1(const char *zA, const char *zB, int iLangId, int *pnMatch){ } }else{ res = m[nB]; - if( pnMatch ) *pnMatch = -1; + /* In the current implementation, pnMatch is always NULL if zA does + ** not end in "*" */ + assert( pnMatch==0 ); } sqlite3_free(toFree); return res; @@ -764,7 +498,6 @@ static int editdist1(const char *zA, const char *zB, int iLangId, int *pnMatch){ /* ** Function: editdist(A,B) -** editdist(A,B,langid) ** ** Return the cost of transforming string A into string B. Both strings ** must be pure ASCII text. If A ends with '*' then it is assumed to be @@ -776,11 +509,10 @@ static void editdistSqlFunc( int argc, sqlite3_value **argv ){ - int langid = argc==2 ? 0 : sqlite3_value_int(argv[2]); int res = editdist1( (const char*)sqlite3_value_text(argv[0]), (const char*)sqlite3_value_text(argv[1]), - langid, 0); + 0); if( res<0 ){ if( res==(-3) ){ sqlite3_result_error_nomem(context); @@ -924,7 +656,7 @@ static int editDist3ConfigLoad( const char *zTable /* Name of the table from which to load */ ){ sqlite3_stmt *pStmt; - int rc; + int rc, rc2; char *zSql; int iLangPrev = -9999; EditDist3Lang *pLang; @@ -939,24 +671,26 @@ static int editDist3ConfigLoad( while( sqlite3_step(pStmt)==SQLITE_ROW ){ int iLang = sqlite3_column_int(pStmt, 0); const char *zFrom = (const char*)sqlite3_column_text(pStmt, 1); - int nFrom = sqlite3_column_bytes(pStmt, 1); + int nFrom = zFrom ? sqlite3_column_bytes(pStmt, 1) : 0; const char *zTo = (const char*)sqlite3_column_text(pStmt, 2); - int nTo = sqlite3_column_bytes(pStmt, 2); + int nTo = zTo ? sqlite3_column_bytes(pStmt, 2) : 0; int iCost = sqlite3_column_int(pStmt, 3); - if( nFrom>100 || nFrom<0 || nTo>100 || nTo<0 ) continue; + assert( zFrom!=0 || nFrom==0 ); + assert( zTo!=0 || nTo==0 ); + if( nFrom>100 || nTo>100 ) continue; if( iCost<0 ) continue; if( iLang!=iLangPrev ){ EditDist3Lang *pNew; - p->nLang++; - pNew = sqlite3_realloc(p->a, p->nLang*sizeof(p->a[0])); + pNew = sqlite3_realloc(p->a, (p->nLang+1)*sizeof(p->a[0])); if( pNew==0 ){ rc = SQLITE_NOMEM; break; } p->a = pNew; - pLang = &p->a[p->nLang-1]; + pLang = &p->a[p->nLang]; + p->nLang++; pLang->iLang = iLang; pLang->iInsCost = 100; pLang->iDelCost = 100; - pLang->iSubCost = 200; + pLang->iSubCost = 150; pLang->pCost = 0; iLangPrev = iLang; } @@ -981,7 +715,8 @@ static int editDist3ConfigLoad( pLang->pCost = pCost; } } - sqlite3_finalize(pStmt); + rc2 = sqlite3_finalize(pStmt); + if( rc==SQLITE_OK ) rc = rc2; return rc; } @@ -1019,7 +754,7 @@ static int matchTo(EditDist3Cost *p, const char *z, int n){ ** the given string. */ static int matchFrom(EditDist3Cost *p, const char *z, int n){ - if( p->nFrom>n ) return 0; + assert( p->nFrom<=n ); if( memcmp(p->a, z, p->nFrom)!=0 ) return 0; return 1; } @@ -1066,10 +801,12 @@ static EditDist3FromString *editDist3FromStringNew( EditDist3Cost *p; int i; + if( z==0 ) return 0; if( n<0 ) n = (int)strlen(z); pStr = sqlite3_malloc( sizeof(*pStr) + sizeof(pStr->a[0])*n + n + 1 ); if( pStr==0 ) return 0; pStr->a = (EditDist3From*)&pStr[1]; + memset(pStr->a, 0, sizeof(pStr->a[0])*n); pStr->n = n; pStr->z = (char*)&pStr->a[n]; memcpy(pStr->z, z, n+1); @@ -1113,30 +850,6 @@ static EditDist3FromString *editDist3FromStringNew( return pStr; } -#if 0 /* No longer used */ -/* -** Return the number of bytes in the common prefix of two UTF8 strings. -** Only complete characters are considered. -*/ -static int editDist3PrefixLen(const char *z1, const char *z2){ - int n = 0; - while( z1[n] && z1[n]==z2[n] ){ n++; } - while( n && (z1[n]&0xc0)==0x80 ){ n--; } - return n; -} - -/* -** Return the number of bytes in the common suffix of two UTF8 strings. -** Only complete characters are considered. -*/ -static int editDist3SuffixLen(const char *z1, int n1, const char *z2, int n2){ - int origN1 = n1; - while( n1>0 && n2>0 && z1[n1-1]==z2[n2-1] ){ n1--; n2--; } - while( n10. */ + if( NEVER(n==0) ){ c = i = 0; }else{ c = z[0]; @@ -1880,10 +1583,10 @@ static const struct { */ static unsigned char *transliterate(const unsigned char *zIn, int nIn){ unsigned char *zOut = sqlite3_malloc( nIn*4 + 1 ); - int i, c, sz, nOut; + int c, sz, nOut; if( zOut==0 ) return 0; - i = nOut = 0; - while( i0 ){ c = utf8Read(zIn, nIn, &sz); zIn += sz; nIn -= sz; @@ -2035,128 +1738,6 @@ static void scriptCodeSqlFunc( /* End transliterate ****************************************************************************** ****************************************************************************** -** Begin Polloc & Zamora SPEEDCOP style keying functions. -*/ -/* -** The Pollock & Zamora skeleton function. Move all consonants to the -** front and all vowels to the end, removing duplicates. Except if the -** first letter is a vowel then it remains as the first letter. -*/ -static void pollockSkeletonKey(const char *zIn, char *zOut){ - int i, j; - unsigned char c; - char seen[26]; - static const unsigned char isVowel[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }; - memset(seen, 0, sizeof(seen)); - for(i=j=0; (c = (unsigned char)zIn[i])!=0; i++){ - if( c<'a' || c>'z' ) continue; - if( j>0 || isVowel[c-'a'] ) continue; - if( seen[c-'a'] ) continue; - seen[c-'a'] = 1; - zOut[j++] = c; - } - for(i=0; (c = (unsigned char)zIn[i])!=0; i++){ - if( c<'a' || c>'z' ) continue; - if( seen[c-'a'] ) continue; - if( !isVowel[c-'a'] ) continue; - seen[c-'a'] = 1; - zOut[j++] = c; - } - zOut[j] = 0; -} - -/* -** Function: pollock_skeleton(X) -** -** Return the Pollock and Zamora skeleton key for a string X of all -** lower-case letters. -*/ -static void pollockSkeletonSqlFunc( - sqlite3_context *context, - int argc, - sqlite3_value **argv -){ - const char *zIn = (const char*)sqlite3_value_text(argv[0]); - int nIn = sqlite3_value_bytes(argv[0]); - char *zOut; - if( zIn ){ - zOut = sqlite3_malloc( nIn + 1 ); - if( zOut==0 ){ - sqlite3_result_error_nomem(context); - }else{ - pollockSkeletonKey(zIn, zOut); - sqlite3_result_text(context, (char*)zOut, -1, sqlite3_free); - } - } -} - -/* -** The Pollock & Zamora omission key. -** -** The key consists of unique consonants in the following order: -** -** jkqxzvwybfmgpdhclntsr -** -** These are followed by unique vowels in input order. -*/ -static void pollockOmissionKey(const char *zIn, char *zOut){ - int i, j; - unsigned char c; - char seen[26]; - static const unsigned char isVowel[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, - 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0 }; - static const unsigned char constOrder[] = "jkqxzvwybfmgpdhclntsr"; - - memset(seen, 0, sizeof(seen)); - for(i=j=0; (c = (unsigned char)zIn[i])!=0; i++){ - if( c<'a' || c>'z' ) continue; - if( isVowel[c-'a'] ) continue; - if( seen[c-'a'] ) continue; - seen[c-'a'] = 1; - } - for(i=0; (c = constOrder[i])!=0; i++){ - if( seen[c-'a'] ) zOut[j++] = c; - } - for(i=0; (c = (unsigned char)zIn[i])!=0; i++){ - if( c<'a' || c>'z' ) continue; - if( seen[c-'a'] ) continue; - if( !isVowel[c-'a'] ) continue; - seen[c-'a'] = 1; - zOut[j++] = c; - } - zOut[j] = 0; -} - -/* -** Function: pollock_omission(X) -** -** Return the Pollock and Zamora omission key for a string X of all -** lower-case letters. -*/ -static void pollockOmissionSqlFunc( - sqlite3_context *context, - int argc, - sqlite3_value **argv -){ - const char *zIn = (const char*)sqlite3_value_text(argv[0]); - int nIn = sqlite3_value_bytes(argv[0]); - char *zOut; - if( zIn ){ - zOut = sqlite3_malloc( nIn + 1 ); - if( zOut==0 ){ - sqlite3_result_error_nomem(context); - }else{ - pollockOmissionKey(zIn, zOut); - sqlite3_result_text(context, (char*)zOut, -1, sqlite3_free); - } - } -} - - -/* End SPEEDCOP keying functions -****************************************************************************** -****************************************************************************** ** Begin spellfix1 virtual table. */ @@ -2164,7 +1745,7 @@ static void pollockOmissionSqlFunc( #define SPELLFIX_MX_HASH 8 /* Maximum number of hash strings to examine per query */ -#define SPELLFIX_MX_RUN 8 +#define SPELLFIX_MX_RUN 1 typedef struct spellfix1_vtab spellfix1_vtab; typedef struct spellfix1_cursor spellfix1_cursor; @@ -2187,10 +1768,11 @@ struct spellfix1_cursor { int nRow; /* Number of rows of content */ int nAlloc; /* Number of allocated rows */ int iRow; /* Current row of content */ - int iLang; /* Value of the lang= constraint */ + int iLang; /* Value of the langid= constraint */ int iTop; /* Value of the top= constraint */ int iScope; /* Value of the scope= constraint */ int nSearch; /* Number of vocabulary items checked */ + sqlite3_stmt *pFullScan; /* Shadow query for a full table scan */ struct spellfix1_row { /* For each row of content */ sqlite3_int64 iRowid; /* Rowid for this row */ char *zWord; /* Text for this row */ @@ -2267,11 +1849,13 @@ static char *spellfix1Dequote(const char *zIn){ zOut = sqlite3_mprintf("%s", zIn); if( zOut==0 ) return 0; i = (int)strlen(zOut); +#if 0 /* The parser will never leave spaces at the end */ while( i>0 && isspace(zOut[i-1]) ){ i--; } +#endif zOut[i] = 0; c = zOut[0]; if( c=='\'' || c=='"' ){ - for(i=1, j=0; zOut[i]; i++){ + for(i=1, j=0; ALWAYS(zOut[i]); i++){ zOut[j++] = zOut[i]; if( zOut[i]==c ){ if( zOut[i+1]==c ){ @@ -2311,31 +1895,25 @@ static int spellfix1Init( int rc = SQLITE_OK; int i; - if( argc<3 ){ - *pzErr = sqlite3_mprintf( - "%s: wrong number of CREATE VIRTUAL TABLE arguments", argv[0] - ); - rc = SQLITE_ERROR; + nDbName = strlen(zDbName); + pNew = sqlite3_malloc( sizeof(*pNew) + nDbName + 1); + if( pNew==0 ){ + rc = SQLITE_NOMEM; }else{ - nDbName = strlen(zDbName); - pNew = sqlite3_malloc( sizeof(*pNew) + nDbName + 1); - if( pNew==0 ){ + memset(pNew, 0, sizeof(*pNew)); + pNew->zDbName = (char*)&pNew[1]; + memcpy(pNew->zDbName, zDbName, nDbName+1); + pNew->zTableName = sqlite3_mprintf("%s", zTableName); + pNew->db = db; + if( pNew->zTableName==0 ){ rc = SQLITE_NOMEM; }else{ - memset(pNew, 0, sizeof(*pNew)); - pNew->zDbName = (char*)&pNew[1]; - memcpy(pNew->zDbName, zDbName, nDbName+1); - pNew->zTableName = sqlite3_mprintf("%s", zTableName); - pNew->db = db; - if( pNew->zTableName==0 ){ - rc = SQLITE_NOMEM; - }else{ - rc = sqlite3_declare_vtab(db, - "CREATE TABLE x(word,rank,distance,langid, " - "score, matchlen, phonehash, " - "top HIDDEN, scope HIDDEN, srchcnt HIDDEN, " - "soundslike HIDDEN, command HIDDEN)" - ); + rc = sqlite3_declare_vtab(db, + "CREATE TABLE x(word,rank,distance,langid, " + "score, matchlen, phonehash HIDDEN, " + "top HIDDEN, scope HIDDEN, srchcnt HIDDEN, " + "soundslike HIDDEN, command HIDDEN)" + ); #define SPELLFIX_COL_WORD 0 #define SPELLFIX_COL_RANK 1 #define SPELLFIX_COL_DISTANCE 2 @@ -2348,39 +1926,44 @@ static int spellfix1Init( #define SPELLFIX_COL_SRCHCNT 9 #define SPELLFIX_COL_SOUNDSLIKE 10 #define SPELLFIX_COL_COMMAND 11 + } + if( rc==SQLITE_OK && isCreate ){ + sqlite3_uint64 r; + spellfix1DbExec(&rc, db, + "CREATE TABLE IF NOT EXISTS \"%w\".\"%w_vocab\"(\n" + " id INTEGER PRIMARY KEY,\n" + " rank INT,\n" + " langid INT,\n" + " word TEXT,\n" + " k1 TEXT,\n" + " k2 TEXT\n" + ");\n", + zDbName, zTableName + ); + sqlite3_randomness(sizeof(r), &r); + spellfix1DbExec(&rc, db, + "CREATE INDEX IF NOT EXISTS \"%w\".\"%w_index_%llx\" " + "ON \"%w_vocab\"(langid,k2);", + zDbName, zModule, r, zTableName + ); + } + for(i=3; rc==SQLITE_OK && ibase); + }else{ + *ppVTab = (sqlite3_vtab *)pNew; + } return rc; } @@ -2417,6 +2000,10 @@ static void spellfix1ResetCursor(spellfix1_cursor *pCur){ pCur->nRow = 0; pCur->iRow = 0; pCur->nSearch = 0; + if( pCur->pFullScan ){ + sqlite3_finalize(pCur->pFullScan); + pCur->pFullScan = 0; + } } /* @@ -2535,7 +2122,7 @@ static int spellfix1BestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){ int idx = 2; pIdxInfo->idxNum = iPlan; if( pIdxInfo->nOrderBy==1 - && pIdxInfo->aOrderBy[0].iColumn==4 + && pIdxInfo->aOrderBy[0].iColumn==SPELLFIX_COL_SCORE && pIdxInfo->aOrderBy[0].desc==0 ){ pIdxInfo->orderByConsumed = 1; /* Default order by iScore */ @@ -2640,9 +2227,9 @@ static void spellfix1RunQuery(MatchQuery *p, const char *zQuery, int nQuery){ char zHash2[SPELLFIX_MX_HASH]; char *zClass; int nClass; + int rc; if( pCur->a==0 || p->rc ) return; /* Prior memory allocation failure */ - if( p->nRun>=SPELLFIX_MX_RUN ) return; zClass = (char*)phoneticHash((unsigned char*)zQuery, nQuery); if( zClass==0 ){ p->rc = SQLITE_NOMEM; @@ -2666,18 +2253,27 @@ static void spellfix1RunQuery(MatchQuery *p, const char *zQuery, int nQuery){ memcpy(zHash2, zHash1, iScope); zHash2[iScope] = 'Z'; zHash2[iScope+1] = 0; +#if SPELLFIX_MX_RUN>1 for(i=0; inRun; i++){ if( strcmp(p->azPrior[i], zHash1)==0 ) return; } +#endif + assert( p->nRunazPrior[p->nRun++], zHash1, iScope+1); - sqlite3_bind_text(pStmt, 1, zHash1, -1, SQLITE_STATIC); - sqlite3_bind_text(pStmt, 2, zHash2, -1, SQLITE_STATIC); + if( sqlite3_bind_text(pStmt, 1, zHash1, -1, SQLITE_STATIC)==SQLITE_NOMEM + || sqlite3_bind_text(pStmt, 2, zHash2, -1, SQLITE_STATIC)==SQLITE_NOMEM + ){ + p->rc = SQLITE_NOMEM; + return; + } +#if SPELLFIX_MX_RUN>1 for(i=0; inRow; i++){ if( pCur->a[i].iScore>iWorst ){ iWorst = pCur->a[i].iScore; idxWorst = i; } } +#endif while( sqlite3_step(pStmt)==SQLITE_ROW ){ int iMatchlen = -1; iRank = sqlite3_column_int(pStmt, 2); @@ -2688,7 +2284,11 @@ static void spellfix1RunQuery(MatchQuery *p, const char *zQuery, int nQuery){ }else{ zK1 = (const char*)sqlite3_column_text(pStmt, 3); if( zK1==0 ) continue; - iDist = editdist1(p->zPattern, zK1, pCur->iLang, 0); + iDist = editdist1(p->zPattern, zK1, 0); + } + if( iDist<0 ){ + p->rc = SQLITE_NOMEM; + break; } pCur->nSearch++; iScore = spellfix1Score(iDist,iRank); @@ -2708,6 +2308,10 @@ static void spellfix1RunQuery(MatchQuery *p, const char *zQuery, int nQuery){ continue; } pCur->a[idx].zWord = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 1)); + if( pCur->a[idx].zWord==0 ){ + p->rc = SQLITE_NOMEM; + break; + } pCur->a[idx].iRowid = sqlite3_column_int64(pStmt, 0); pCur->a[idx].iRank = iRank; pCur->a[idx].iDistance = iDist; @@ -2727,7 +2331,8 @@ static void spellfix1RunQuery(MatchQuery *p, const char *zQuery, int nQuery){ } } } - sqlite3_reset(pStmt); + rc = sqlite3_reset(pStmt); + if( rc ) p->rc = rc; } /* @@ -2748,7 +2353,7 @@ static int spellfix1FilterForMatch( int iScope = 3; /* Use this many characters of zClass */ int iLang = 0; /* Language code */ char *zSql; /* SQL of shadow table query */ - sqlite3_stmt *pStmt; /* Shadow table query */ + sqlite3_stmt *pStmt = 0; /* Shadow table query */ int rc; /* Result code */ int idx = 1; /* Next available filter parameter */ spellfix1_vtab *p = pCur->pVTab; /* The virtual table that owns pCur */ @@ -2790,13 +2395,20 @@ static int spellfix1FilterForMatch( if( p->pConfig3 ){ x.pLang = editDist3FindLang(p->pConfig3, iLang); pMatchStr3 = editDist3FromStringNew(x.pLang, (const char*)zMatchThis, -1); + if( pMatchStr3==0 ){ + x.rc = SQLITE_NOMEM; + goto filter_exit; + } }else{ x.pLang = 0; } zPattern = (char*)transliterate(zMatchThis, sqlite3_value_bytes(argv[0])); sqlite3_free(pCur->zPattern); pCur->zPattern = zPattern; - if( zPattern==0 ) return SQLITE_NOMEM; + if( zPattern==0 ){ + x.rc = SQLITE_NOMEM; + goto filter_exit; + } nPattern = strlen(zPattern); if( zPattern[nPattern-1]=='*' ) nPattern--; zSql = sqlite3_mprintf( @@ -2805,6 +2417,11 @@ static int spellfix1FilterForMatch( " WHERE langid=%d AND k2>=?1 AND k2zDbName, p->zTableName, iLang ); + if( zSql==0 ){ + x.rc = SQLITE_NOMEM; + pStmt = 0; + goto filter_exit; + } rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0); sqlite3_free(zSql); pCur->iLang = iLang; @@ -2820,34 +2437,18 @@ static int spellfix1FilterForMatch( spellfix1RunQuery(&x, zPattern, nPattern); } -#if 0 - /* Convert "ght" to "t" in the original pattern and try again */ - if( x.rc==SQLITE_OK ){ - int i, j; /* Loop counters */ - char zQuery[50]; /* Space for alternative query string */ - for(i=j=0; ia ){ qsort(pCur->a, pCur->nRow, sizeof(pCur->a[0]), spellfix1RowCompare); pCur->iTop = iLimit; pCur->iScope = iScope; + }else{ + x.rc = SQLITE_NOMEM; } + +filter_exit: sqlite3_finalize(pStmt); editDist3FromStringDelete(pMatchStr3); - return pCur->a ? x.rc : SQLITE_NOMEM; + return x.rc; } /* @@ -2859,9 +2460,25 @@ static int spellfix1FilterForFullScan( int argc, sqlite3_value **argv ){ + int rc; + char *zSql; + spellfix1_vtab *pVTab = pCur->pVTab; spellfix1ResetCursor(pCur); - spellfix1ResizeCursor(pCur, 0); - return SQLITE_OK; + zSql = sqlite3_mprintf( + "SELECT word, rank, NULL, langid, id FROM \"%w\".\"%w_vocab\"", + pVTab->zDbName, pVTab->zTableName); + if( zSql==0 ) return SQLITE_NOMEM; + rc = sqlite3_prepare_v2(pVTab->db, zSql, -1, &pCur->pFullScan, 0); + sqlite3_free(zSql); + pCur->nRow = pCur->iRow = 0; + if( rc==SQLITE_OK ){ + rc = sqlite3_step(pCur->pFullScan); + if( rc==SQLITE_ROW ){ pCur->iRow = -1; rc = SQLITE_OK; } + if( rc==SQLITE_DONE ){ rc = SQLITE_OK; } + }else{ + pCur->iRow = 0; + } + return rc; } @@ -2891,7 +2508,14 @@ static int spellfix1Filter( */ static int spellfix1Next(sqlite3_vtab_cursor *cur){ spellfix1_cursor *pCur = (spellfix1_cursor *)cur; - if( pCur->iRow < pCur->nRow ) pCur->iRow++; + if( pCur->iRow < pCur->nRow ){ + if( pCur->pFullScan ){ + int rc = sqlite3_step(pCur->pFullScan); + if( rc!=SQLITE_ROW ) pCur->iRow = pCur->nRow; + }else{ + pCur->iRow++; + } + } return SQLITE_OK; } @@ -2906,8 +2530,20 @@ static int spellfix1Eof(sqlite3_vtab_cursor *cur){ /* ** Return columns from the current row. */ -static int spellfix1Column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i){ +static int spellfix1Column( + sqlite3_vtab_cursor *cur, + sqlite3_context *ctx, + int i +){ spellfix1_cursor *pCur = (spellfix1_cursor*)cur; + if( pCur->pFullScan ){ + if( i<=SPELLFIX_COL_LANGID ){ + sqlite3_result_value(ctx, sqlite3_column_value(pCur->pFullScan, i)); + }else{ + sqlite3_result_null(ctx); + } + return SQLITE_OK; + } switch( i ){ case SPELLFIX_COL_WORD: { sqlite3_result_text(ctx, pCur->a[pCur->iRow].zWord, -1, SQLITE_STATIC); @@ -2941,7 +2577,7 @@ static int spellfix1Column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i int res; zTranslit = (char *)transliterate((unsigned char *)zWord, nWord); if( !zTranslit ) return SQLITE_NOMEM; - res = editdist1(pCur->zPattern, zTranslit, pCur->iLang, &iMatchlen); + res = editdist1(pCur->zPattern, zTranslit, &iMatchlen); sqlite3_free(zTranslit); if( res<0 ) return SQLITE_NOMEM; iMatchlen = translen_to_charlen(zWord, nWord, iMatchlen); @@ -2982,7 +2618,11 @@ static int spellfix1Column(sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i */ static int spellfix1Rowid(sqlite3_vtab_cursor *cur, sqlite_int64 *pRowid){ spellfix1_cursor *pCur = (spellfix1_cursor*)cur; - *pRowid = pCur->a[pCur->iRow].iRowid; + if( pCur->pFullScan ){ + *pRowid = sqlite3_column_int64(pCur->pFullScan, 4); + }else{ + *pRowid = pCur->a[pCur->iRow].iRowid; + } return SQLITE_OK; } @@ -3066,8 +2706,8 @@ static int spellfix1Update( rowid = sqlite3_value_int64(argv[0]); newRowid = *pRowid = sqlite3_value_int64(argv[1]); spellfix1DbExec(&rc, db, - "UPDATE \"%w\".\"%w_vocab\" SET id=%lld, rank=%d, lang=%d," - " word=%Q, rank=%d, k1=%Q, k2=%Q WHERE id=%lld", + "UPDATE \"%w\".\"%w_vocab\" SET id=%lld, rank=%d, langid=%d," + " word=%Q, k1=%Q, k2=%Q WHERE id=%lld", p->zDbName, p->zTableName, newRowid, iRank, iLang, zWord, zK1, zK2, rowid ); @@ -3096,6 +2736,8 @@ static int spellfix1Rename(sqlite3_vtab *pVTab, const char *zNew){ if( rc==SQLITE_OK ){ sqlite3_free(p->zTableName); p->zTableName = zNewName; + }else{ + sqlite3_free(zNewName); } return rc; } @@ -3137,16 +2779,10 @@ static int spellfix1Register(sqlite3 *db){ transliterateSqlFunc, 0, 0); nErr += sqlite3_create_function(db, "spellfix1_editdist", 2, SQLITE_UTF8, 0, editdistSqlFunc, 0, 0); - nErr += sqlite3_create_function(db, "spellfix1_editdist", 3, SQLITE_UTF8, 0, - editdistSqlFunc, 0, 0); nErr += sqlite3_create_function(db, "spellfix1_phonehash", 1, SQLITE_UTF8, 0, phoneticHashSqlFunc, 0, 0); nErr += sqlite3_create_function(db, "spellfix1_scriptcode", 1, SQLITE_UTF8, 0, scriptCodeSqlFunc, 0, 0); - nErr += sqlite3_create_function(db, "pollock_skeleton", 1, SQLITE_UTF8, 0, - pollockSkeletonSqlFunc, 0, 0); - nErr += sqlite3_create_function(db, "pollock_omission", 1, SQLITE_UTF8, 0, - pollockOmissionSqlFunc, 0, 0); nErr += sqlite3_create_module(db, "spellfix1", &spellfix1Module, 0); nErr += editDist3Install(db); diff --git a/test/spellfix.test b/test/spellfix.test index 14a4cd722e..b2182a69f3 100644 --- a/test/spellfix.test +++ b/test/spellfix.test @@ -137,12 +137,13 @@ do_test 3.2 { breakpoint foreach {tn word res} { - 1 kos* {kosher 3 kiosk 4 kudo 2 kappa 1 keypad 1} - 2 kellj* {killjoy 5 killed 4 killingly 4 kill 4 killer 4} + 1 kos* {kosher 3 kiosk 4 kudo 2 kiss 3 kissed 3} + 2 kellj* {killjoy 5 kill 4 killed 4 killer 4 killers 4} 3 kellj {kill 4 kills 5 killjoy 7 keel 4 killed 6} } { do_execsql_test 1.2.$tn { - SELECT word, matchlen FROM t3 WHERE word MATCH $word LIMIT 5 + SELECT word, matchlen FROM t3 WHERE word MATCH $word + ORDER BY score, word LIMIT 5 } $res } From ec73930adc09d2e237b4f8cdf6e9d51a67ecb00f Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 14 Aug 2012 18:43:39 +0000 Subject: [PATCH 67/69] Add an assert() to the btree rebalancer in order to silence a clang/scan-build warning. FossilOrigin-Name: 6730579cf5c6c74cb293e7237d896d3a3a36b691 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/btree.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index 42bcaa0a49..61ec3496c3 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sspellfix\svirtual\stable\sto\sthe\slatest\sdevelopment\scode. -D 2012-08-14T17:29:27.517 +C Add\san\sassert()\sto\sthe\sbtree\srebalancer\sin\sorder\sto\ssilence\sa\s\nclang/scan-build\swarning. +D 2012-08-14T18:43:39.547 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -123,7 +123,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 5b31b24d6814b11de763debf342c8cd0a15a4910 F src/bitvec.c 26675fe8e431dc555e6f2d0e11e651d172234aa1 F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c fe84910555e103013455e21571ac8bbed23c5c50 +F src/btree.c 82b6fcbec3101ff951f47797f407d5eb5d06fa44 F src/btree.h 4aee02e879211bfcfd3f551769578d2e940ab6c2 F src/btreeInt.h 4e5c2bd0f9b36b2a815a6d84f771a61a65830621 F src/build.c 0f6b40ad6211dcaba6159d0f9a297f0704f22142 @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 1de2237d005fa1a1e1d034820d17daf64a860f81 -R c6a6a5e27cc06765fbb21bed044152b3 +P 6954fef006431d153de6e63e362b8d260ebeb1c6 +R c7501b04ad663e9c70817cec3b4cff7e U drh -Z f62627106b46abb8dea1d772e4525d54 +Z aedea036152f85450c01ebb017cff317 diff --git a/manifest.uuid b/manifest.uuid index a2aa6fb25c..a961a38622 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6954fef006431d153de6e63e362b8d260ebeb1c6 \ No newline at end of file +6730579cf5c6c74cb293e7237d896d3a3a36b691 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index 6b5dd683a5..097f02323e 100644 --- a/src/btree.c +++ b/src/btree.c @@ -6473,6 +6473,7 @@ static int balance_nonroot( ** sibling page j. If the siblings are not leaf pages of an ** intkey b-tree, then cell i was a divider cell. */ assert( j+1 < ArraySize(apCopy) ); + assert( j+1 < nOld ); pOld = apCopy[++j]; iNextOld = i + !leafData + pOld->nCell + pOld->nOverflow; if( pOld->nOverflow ){ @@ -8307,4 +8308,3 @@ void sqlite3BtreeCursorHints(BtCursor *pCsr, unsigned int mask){ assert( mask==BTREE_BULKLOAD || mask==0 ); pCsr->hints = mask; } - From 8b64b3977e2557848f7654e84de2e7af568dfd4a Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 14 Aug 2012 19:04:27 +0000 Subject: [PATCH 68/69] Silence three harmless compiler warnings in vdbesort.c. FossilOrigin-Name: a5431c86df442c6e6dfaeae8e8aa62b56d204e97 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/vdbesort.c | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 61ec3496c3..fa8c06418b 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\san\sassert()\sto\sthe\sbtree\srebalancer\sin\sorder\sto\ssilence\sa\s\nclang/scan-build\swarning. -D 2012-08-14T18:43:39.547 +C Silence\sthree\sharmless\scompiler\swarnings\sin\svdbesort.c. +D 2012-08-14T19:04:27.492 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -244,7 +244,7 @@ F src/vdbeapi.c 88ea823bbcb4320f5a6607f39cd7c2d3cc4c26b1 F src/vdbeaux.c dce80038c3c41f2680e5ab4dd0f7e0d8b7ff9071 F src/vdbeblob.c 32f2a4899d67f69634ea4dd93e3f651936d732cb F src/vdbemem.c cb55e84b8e2c15704968ee05f0fae25883299b74 -F src/vdbesort.c bd5ce83f9314bfb632c8c653e9e81db31928a753 +F src/vdbesort.c 0dc1b274dcb4d4c8e71b0b2b15261f286caba39b F src/vdbetrace.c 8bd5da325fc90f28464335e4cc4ad1407fe30835 F src/vtab.c bb8ea3a26608bb1357538a5d2fc72beba6638998 F src/wal.c 9294df6f96aae5909ae1a9b733fd1e1b4736978b @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 6954fef006431d153de6e63e362b8d260ebeb1c6 -R c7501b04ad663e9c70817cec3b4cff7e +P 6730579cf5c6c74cb293e7237d896d3a3a36b691 +R 7ea1e8d09a42f7daed61f69d5f68ea70 U drh -Z aedea036152f85450c01ebb017cff317 +Z 6a9fd56c83b0e144f530abdc3bddd4ea diff --git a/manifest.uuid b/manifest.uuid index a961a38622..4dc7f489ce 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6730579cf5c6c74cb293e7237d896d3a3a36b691 \ No newline at end of file +a5431c86df442c6e6dfaeae8e8aa62b56d204e97 \ No newline at end of file diff --git a/src/vdbesort.c b/src/vdbesort.c index 63288cfa6b..ba1e9f0f23 100644 --- a/src/vdbesort.c +++ b/src/vdbesort.c @@ -195,7 +195,7 @@ static int vdbeSorterIterRead( int rc; /* sqlite3OsRead() return code */ /* Determine how many bytes of data to read. */ - nRead = p->iEof - p->iReadOff; + nRead = (int)(p->iEof - p->iReadOff); if( nRead>p->nBuffer ) nRead = p->nBuffer; assert( nRead>0 ); @@ -300,7 +300,7 @@ static int vdbeSorterIterNext( rc = vdbeSorterIterVarint(db, pIter, &nRec); if( rc==SQLITE_OK ){ pIter->nKey = (int)nRec; - rc = vdbeSorterIterRead(db, pIter, nRec, &pIter->aKey); + rc = vdbeSorterIterRead(db, pIter, (int)nRec, &pIter->aKey); } return rc; @@ -343,7 +343,7 @@ static int vdbeSorterIterInit( if( iBuf ){ int nRead = nBuf - iBuf; if( (iStart + nRead) > pSorter->iWriteOff ){ - nRead = pSorter->iWriteOff - iStart; + nRead = (int)(pSorter->iWriteOff - iStart); } rc = sqlite3OsRead( pSorter->pTemp1, &pIter->aBuffer[iBuf], nRead, iStart From e74f4651da9d37fef98d83b293ed220d2ca6a7e4 Mon Sep 17 00:00:00 2001 From: drh Date: Wed, 15 Aug 2012 16:06:54 +0000 Subject: [PATCH 69/69] Change autoconf so that the --with-tcl=DIR option will override the TCL configuration that is found using tclsh. FossilOrigin-Name: 772d0de3f311f2035f8a42f01371c96c9fa587ce --- configure | 18 ++++++++++-------- configure.ac | 18 ++++++++++-------- manifest | 14 +++++++------- manifest.uuid | 2 +- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/configure b/configure index e1fd1686b8..af10fe3bd1 100755 --- a/configure +++ b/configure @@ -12778,14 +12778,16 @@ $as_echo "$as_me: error: ${with_tclconfig} directory doesn't contain tclConfig.s fi # Start autosearch by asking tclsh - if test x"$cross_compiling" = xno; then - for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig="$i" - break - fi - done + if test x"${ac_cv_c_tclconfig}" = x ; then + if test x"$cross_compiling" = xno; then + for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` + do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig="$i" + break + fi + done + fi fi # then check for a private Tcl installation diff --git a/configure.ac b/configure.ac index aac1d472f2..882c3ccf92 100644 --- a/configure.ac +++ b/configure.ac @@ -388,14 +388,16 @@ if test "${use_tcl}" = "yes" ; then fi # Start autosearch by asking tclsh - if test x"$cross_compiling" = xno; then - for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` - do - if test -f "$i/tclConfig.sh" ; then - ac_cv_c_tclconfig="$i" - break - fi - done + if test x"${ac_cv_c_tclconfig}" = x ; then + if test x"$cross_compiling" = xno; then + for i in `echo 'puts stdout $auto_path' | ${TCLSH_CMD}` + do + if test -f "$i/tclConfig.sh" ; then + ac_cv_c_tclconfig="$i" + break + fi + done + fi fi # then check for a private Tcl installation diff --git a/manifest b/manifest index fa8c06418b..7248b97071 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Silence\sthree\sharmless\scompiler\swarnings\sin\svdbesort.c. -D 2012-08-14T19:04:27.492 +C Change\sautoconf\sso\sthat\sthe\s--with-tcl=DIR\soption\swill\soverride\sthe\nTCL\sconfiguration\sthat\sis\sfound\susing\stclsh. +D 2012-08-15T16:06:54.475 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in abd5c10d21d1395f140d9e50ea999df8fa4d6376 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -15,8 +15,8 @@ F art/sqlite370.jpg d512473dae7e378a67e28ff96a34da7cb331def2 F config.guess 226d9a188c6196f3033ffc651cbc9dcee1a42977 F config.h.in 0921066a13130082764ab4ab6456f7b5bebe56de F config.sub 9ebe4c3b3dab6431ece34f16828b594fb420da55 -F configure 8f973617dbc3fca46d26104070b75c17ef70beb7 x -F configure.ac 9ee886c21c095b3272137b1553ae416c8b8c8557 +F configure e2d0e3b67d2b1b1049d389fd671275d79bb80457 x +F configure.ac 6e909664785b8184db2179013cd9d574f96ca3a3 F contrib/sqlitecon.tcl 210a913ad63f9f991070821e599d600bd913e0ad F doc/lemon.html 3091574143dd3415669b6745843ff8d011d33549 F doc/pager-invariants.txt 870107036470d7c419e93768676fae2f8749cf9e @@ -1010,7 +1010,7 @@ F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 67d8a99aceb56384a81b3f30d6c71743146d2cc9 -P 6730579cf5c6c74cb293e7237d896d3a3a36b691 -R 7ea1e8d09a42f7daed61f69d5f68ea70 +P a5431c86df442c6e6dfaeae8e8aa62b56d204e97 +R 6123b9c9d97ee6d2b788aa279b8a3858 U drh -Z 6a9fd56c83b0e144f530abdc3bddd4ea +Z 4d101c802bb37b58a1c59c63393cf7ab diff --git a/manifest.uuid b/manifest.uuid index 4dc7f489ce..1bfbcb6c13 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a5431c86df442c6e6dfaeae8e8aa62b56d204e97 \ No newline at end of file +772d0de3f311f2035f8a42f01371c96c9fa587ce \ No newline at end of file